Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: pass named fields to agent-account API wrappers (#9203)
Adam Eivy8707be7e2b83
diff --git a/client/src/components/agents/tabs/OverviewTab.jsx b/client/src/components/agents/tabs/OverviewTab.jsxindex 9f6765f611..349f464a89 100644--- a/client/src/components/agents/tabs/OverviewTab.jsx+++ b/client/src/components/agents/tabs/OverviewTab.jsx@@ -194,7 +194,7 @@ export default function OverviewTab({ agentId, agent, onAgentUpdate }) {const handleEngage = async () => {if (!agentId || !quickAccountId) return;setEngaging(true);- const result = await api.engageAgent(agentId, quickAccountId, 1, 3);+ const result = await api.engageAgent({ agentId, accountId: quickAccountId, maxComments: 1, maxVotes: 3 });setEngaging(false);toast.success(`Engaged: ${result.votes?.length || 0} votes, ${result.comments?.length || 0} comments`);refetchRateLimits();@@ -203,7 +203,7 @@ export default function OverviewTab({ agentId, agent, onAgentUpdate }) {const handleCheckPosts = async () => {if (!agentId || !quickAccountId) return;setChecking(true);- const result = await api.checkAgentPosts(agentId, quickAccountId, 7, 2, 10).catch(() => null);+ const result = await api.checkAgentPosts({ agentId, accountId: quickAccountId, days: 7, maxReplies: 2, maxUpvotes: 10 }).catch(() => null);setChecking(false);if (!result) return;toast.success(`Checked ${result.postsChecked} posts: ${result.engagement?.upvoted?.length || 0} upvotes, ${result.engagement?.replied?.length || 0} replies`);@@ -214,7 +214,7 @@ export default function OverviewTab({ agentId, agent, onAgentUpdate }) {const handleExplore = async () => {if (!agentId || !quickAccountId) return;setExploring(true);- const result = await api.moltworldExplore(quickAccountId, agentId).catch(() => null);+ const result = await api.moltworldExplore({ accountId: quickAccountId, agentId }).catch(() => null);setExploring(false);if (!result) return;toast.success(`Explored (${result.x}, ${result.y}) — ${result.nearby || 0} agents nearby`);@@ -223,7 +223,7 @@ export default function OverviewTab({ agentId, agent, onAgentUpdate }) {const handleBuild = async () => {if (!agentId || !quickAccountId) return;- const result = await api.moltworldBuild(quickAccountId, agentId, 0, 0, 0, 'stone', 'place').catch(() => null);+ const result = await api.moltworldBuild({ accountId: quickAccountId, agentId, x: 0, y: 0, z: 0, type: 'stone', action: 'place' }).catch(() => null);if (result) toast.success('Block placed');refetchRateLimits();};@@ -236,9 +236,9 @@ export default function OverviewTab({ agentId, agent, onAgentUpdate }) {const handleAccountSubmit = async (e) => {e.preventDefault();- const result = await api.registerPlatformAccount(- agentId, accountForm.platform, accountForm.name, accountForm.description- );+ const result = await api.registerPlatformAccount({+ agentId, platform: accountForm.platform, name: accountForm.name, description: accountForm.description+ });resetAccountForm();fetchAccounts();diff --git a/client/src/components/agents/tabs/PublishedTab.jsx b/client/src/components/agents/tabs/PublishedTab.jsxindex 1e9c8545ec..0d2b94e5ee 100644--- a/client/src/components/agents/tabs/PublishedTab.jsx+++ b/client/src/components/agents/tabs/PublishedTab.jsx@@ -33,7 +33,7 @@ export default function PublishedTab({ agentId }) {return;}setPublishedLoading(true);- const data = await api.getAgentPublished(agentId, selectedAccountId, publishedDays);+ const data = await api.getAgentPublished({ agentId, accountId: selectedAccountId, days: publishedDays });setPublished(data);setPublishedLoading(false);}, [agentId, selectedAccountId, publishedDays]);diff --git a/client/src/components/agents/tabs/ToolsTab.jsx b/client/src/components/agents/tabs/ToolsTab.jsxindex 18fa1202d5..48ec95124b 100644--- a/client/src/components/agents/tabs/ToolsTab.jsx+++ b/client/src/components/agents/tabs/ToolsTab.jsx@@ -119,7 +119,7 @@ export default function ToolsTab({ agentId, agent }) {const handleBrowseFeed = async () => {if (!selectedAccountId) return;setFeedLoading(true);- const feed = await api.getAgentFeed(selectedAccountId, feedSort, 25);+ const feed = await api.getAgentFeed({ accountId: selectedAccountId, sort: feedSort, limit: 25 });setFeedPosts(feed.posts || feed || []);setFeedLoading(false);};@@ -127,7 +127,7 @@ export default function ToolsTab({ agentId, agent }) {const handleFindRelevant = async () => {if (!agentId || !selectedAccountId) return;setFeedLoading(true);- const posts = await api.getAgentRelevantPosts(agentId, selectedAccountId, 10);+ const posts = await api.getAgentRelevantPosts({ agentId, accountId: selectedAccountId, maxResults: 10 });setFeedPosts(posts);setFeedLoading(false);};@@ -145,7 +145,7 @@ export default function ToolsTab({ agentId, agent }) {if (!agentId || !selectedAccountId) return;setGenerating(true);const contentConfig = agent?.aiConfig?.content || agent?.aiConfig;- const generated = await api.generateAgentPost(agentId, selectedAccountId, selectedSubmolt, contentConfig?.providerId, contentConfig?.model);+ const generated = await api.generateAgentPost({ agentId, accountId: selectedAccountId, submolt: selectedSubmolt, providerId: contentConfig?.providerId, model: contentConfig?.model });setPostTitle(generated.title);setPostContent(generated.content);setGenerating(false);@@ -166,7 +166,7 @@ export default function ToolsTab({ agentId, agent }) {const handlePublishPost = async () => {if (!postTitle || !postContent) return;setPublishing(true);- const result = await api.publishAgentPost(agentId, selectedAccountId, selectedSubmolt, postTitle, postContent).catch(() => null);+ const result = await api.publishAgentPost({ agentId, accountId: selectedAccountId, submolt: selectedSubmolt, title: postTitle, content: postContent }).catch(() => null);if (!result) {setPublishing(false);@@ -178,11 +178,11 @@ export default function ToolsTab({ agentId, agent }) {if (result?.verificationFailed) {toast.error('Post verification failed — draft preserved for retry');} else {- await api.updateAgentDraft(agentId, activeDraftId, {+ await api.updateAgentDraft({ agentId, draftId: activeDraftId, data: {status: 'published',publishedPostId: result?.id || result?._id || result?.post_id || null,publishedAt: new Date().toISOString()- }).catch(err => console.warn('⚠️ Failed to mark draft published: ' + err.message));+ } }).catch(err => console.warn('⚠️ Failed to mark draft published: ' + err.message));setActiveDraftId(null);toast.success('Post published');}@@ -204,10 +204,10 @@ export default function ToolsTab({ agentId, agent }) {if (!selectedPost) return;setGeneratingComment(true);const contentConfig = agent?.aiConfig?.content || agent?.aiConfig;- const generated = await api.generateAgentComment(- agentId, selectedAccountId, selectedPost.id, replyToId || undefined,- contentConfig?.providerId, contentConfig?.model- );+ const generated = await api.generateAgentComment({+ agentId, accountId: selectedAccountId, postId: selectedPost.id, parentId: replyToId || undefined,+ providerId: contentConfig?.providerId, model: contentConfig?.model+ });setCommentContent(generated.content);setGeneratingComment(false);@@ -228,9 +228,9 @@ export default function ToolsTab({ agentId, agent }) {const handlePublishComment = async () => {if (!selectedPost || !commentContent) return;setPublishingComment(true);- const result = await api.publishAgentComment(- agentId, selectedAccountId, selectedPost.id, commentContent, replyToId || undefined- ).catch(() => null);+ const result = await api.publishAgentComment({+ agentId, accountId: selectedAccountId, postId: selectedPost.id, content: commentContent, parentId: replyToId || undefined+ }).catch(() => null);if (!result) {setPublishingComment(false);@@ -242,10 +242,10 @@ export default function ToolsTab({ agentId, agent }) {if (result?.verificationFailed) {toast.error('Comment verification failed — draft preserved for retry');} else {- await api.updateAgentDraft(agentId, activeDraftId, {+ await api.updateAgentDraft({ agentId, draftId: activeDraftId, data: {status: 'published',publishedAt: new Date().toISOString()- }).catch(err => console.warn('⚠️ Failed to mark comment draft published: ' + err.message));+ } }).catch(err => console.warn('⚠️ Failed to mark comment draft published: ' + err.message));setActiveDraftId(null);toast.success('Comment published');}@@ -268,7 +268,7 @@ export default function ToolsTab({ agentId, agent }) {if (!agentId || !selectedAccountId) return;setEngaging(true);setEngageResult(null);- const result = await api.engageAgent(agentId, selectedAccountId, 1, 3);+ const result = await api.engageAgent({ agentId, accountId: selectedAccountId, maxComments: 1, maxVotes: 3 });setEngageResult(result);setEngaging(false);toast.success(`Engaged: ${result.votes?.length || 0} votes, ${result.comments?.length || 0} comments`);@@ -280,7 +280,7 @@ export default function ToolsTab({ agentId, agent }) {if (!agentId || !selectedAccountId) return;setChecking(true);setCheckResult(null);- const result = await api.checkAgentPosts(agentId, selectedAccountId, 7, 2, 10).catch(() => null);+ const result = await api.checkAgentPosts({ agentId, accountId: selectedAccountId, days: 7, maxReplies: 2, maxUpvotes: 10 }).catch(() => null);setChecking(false);if (!result) return;setCheckResult(result);diff --git a/client/src/components/agents/tabs/WorldTab.jsx b/client/src/components/agents/tabs/WorldTab.jsxindex 7029f9d834..2003913bb6 100644--- a/client/src/components/agents/tabs/WorldTab.jsx+++ b/client/src/components/agents/tabs/WorldTab.jsx@@ -266,16 +266,16 @@ export default function WorldTab({ agentId }) {const y = random ? undefined : (moveY !== '' ? parseInt(moveY, 10) : undefined);if (wsConnected && !random && x != null && y != null) {- await api.moltworldWsMove(x, y, moveThinking || undefined).catch(() => null);+ await api.moltworldWsMove({ x, y, thought: moveThinking || undefined }).catch(() => null);setMoving(false);toast.success(`Move sent via WS to (${x}, ${y})`);refreshAfterAction();return;}- const result = await api.moltworldExplore(- accountId, agentId, x, y, moveThinking || undefined- ).catch(() => null);+ const result = await api.moltworldExplore({+ accountId, agentId, x, y, thinking: moveThinking || undefined+ }).catch(() => null);setMoving(false);if (!result) { fetchRateLimits(); return; }updateFromJoinResponse(result);@@ -297,7 +297,7 @@ export default function WorldTab({ agentId }) {return;}- const result = await api.moltworldThink(accountId, thought, agentId).catch(() => null);+ const result = await api.moltworldThink({ accountId, agentId, thought }).catch(() => null);setThinking(false);if (!result) { fetchRateLimits(); return; }toast.success('Thought sent');@@ -308,11 +308,11 @@ export default function WorldTab({ agentId }) {const handleBuild = async () => {if (!accountId || buildX === '' || buildY === '') return;setBuilding(true);- const result = await api.moltworldBuild(+ const result = await api.moltworldBuild({accountId, agentId,- parseInt(buildX, 10), parseInt(buildY, 10), parseInt(buildZ || '0', 10),- blockType, buildAction- ).catch(() => null);+ x: parseInt(buildX, 10), y: parseInt(buildY, 10), z: parseInt(buildZ || '0', 10),+ type: blockType, action: buildAction+ }).catch(() => null);setBuilding(false);if (!result) { fetchRateLimits(); return; }toast.success(`Block ${buildAction}d at (${buildX}, ${buildY}, ${buildZ})`);@@ -333,9 +333,9 @@ export default function WorldTab({ agentId }) {return;}- const result = await api.moltworldSay(- accountId, sayMessage, sayTo || undefined, agentId- ).catch(() => null);+ const result = await api.moltworldSay({+ accountId, agentId, message: sayMessage, sayTo: sayTo || undefined+ }).catch(() => null);setSaying(false);if (!result) { fetchRateLimits(); return; }updateFromJoinResponse(result);@@ -358,7 +358,7 @@ export default function WorldTab({ agentId }) {if (params.y != null) params.y = parseInt(params.y, 10);if (params.z != null) params.z = parseInt(params.z, 10);- await api.moltworldAddToQueue(agentId, newActionType, params).catch(() => null);+ await api.moltworldAddToQueue({ agentId, actionType: newActionType, params }).catch(() => null);setShowAddForm(false);setNewActionParams({});toast.success('Action queued');diff --git a/client/src/services/apiAccounts.js b/client/src/services/apiAccounts.jsindex 354525d4f5..f21c23d4d9 100644--- a/client/src/services/apiAccounts.js+++ b/client/src/services/apiAccounts.js@@ -8,7 +8,7 @@ export const getPlatformAccounts = (agentId = null, platform = null, options = {const query = params.toString();return request(`/agents/accounts${query ? `?${query}` : ''}`, options);};-export const registerPlatformAccount = (agentId, platform, name, description) => request('/agents/accounts', {+export const registerPlatformAccount = ({ agentId, platform, name, description }) => request('/agents/accounts', {method: 'POST',body: JSON.stringify({ agentId, platform, name, description })});@@ -17,33 +17,33 @@ export const testPlatformAccount = (id) => request(`/agents/accounts/${id}/test`export const claimPlatformAccount = (id) => request(`/agents/accounts/${id}/claim`, { method: 'POST' });// Agent Tools-export const generateAgentPost = (agentId, accountId, submolt, providerId, model) => request('/agents/tools/generate-post', {+export const generateAgentPost = ({ agentId, accountId, submolt, providerId, model }) => request('/agents/tools/generate-post', {method: 'POST',body: JSON.stringify({ agentId, accountId, submolt, providerId, model })});-export const generateAgentComment = (agentId, accountId, postId, parentId, providerId, model) => request('/agents/tools/generate-comment', {+export const generateAgentComment = ({ agentId, accountId, postId, parentId, providerId, model }) => request('/agents/tools/generate-comment', {method: 'POST',body: JSON.stringify({ agentId, accountId, postId, parentId, providerId, model })});-export const publishAgentPost = (agentId, accountId, submolt, title, content) => request('/agents/tools/publish-post', {+export const publishAgentPost = ({ agentId, accountId, submolt, title, content }) => request('/agents/tools/publish-post', {method: 'POST',body: JSON.stringify({ agentId, accountId, submolt, title, content })});-export const publishAgentComment = (agentId, accountId, postId, content, parentId) => request('/agents/tools/publish-comment', {+export const publishAgentComment = ({ agentId, accountId, postId, content, parentId }) => request('/agents/tools/publish-comment', {method: 'POST',body: JSON.stringify({ agentId, accountId, postId, content, parentId })});-export const engageAgent = (agentId, accountId, maxComments, maxVotes) => request('/agents/tools/engage', {+export const engageAgent = ({ agentId, accountId, maxComments, maxVotes }) => request('/agents/tools/engage', {method: 'POST',body: JSON.stringify({ agentId, accountId, maxComments, maxVotes })});-export const getAgentFeed = (accountId, sort, limit) => {+export const getAgentFeed = ({ accountId, sort, limit }) => {const params = new URLSearchParams({ accountId });if (sort) params.set('sort', sort);if (limit) params.set('limit', limit);return request(`/agents/tools/feed?${params}`);};-export const getAgentRelevantPosts = (agentId, accountId, maxResults) => {+export const getAgentRelevantPosts = ({ agentId, accountId, maxResults }) => {const params = new URLSearchParams({ agentId, accountId });if (maxResults) params.set('maxResults', maxResults);return request(`/agents/tools/relevant-posts?${params}`);@@ -51,19 +51,19 @@ export const getAgentRelevantPosts = (agentId, accountId, maxResults) => {export const getAgentSubmolts = (accountId) => request(`/agents/tools/submolts?accountId=${accountId}`);export const getAgentPost = (accountId, postId) => request(`/agents/tools/post/${postId}?accountId=${accountId}`);export const getAgentRateLimits = (accountId) => request(`/agents/tools/rate-limits?accountId=${accountId}`);-export const getAgentPublished = (agentId, accountId, days = 7) =>+export const getAgentPublished = ({ agentId, accountId, days = 7 }) =>request(`/agents/tools/published?agentId=${agentId}&accountId=${accountId}&days=${days}`);-export const checkAgentPosts = (agentId, accountId, days, maxReplies, maxUpvotes) =>+export const checkAgentPosts = ({ agentId, accountId, days, maxReplies, maxUpvotes }) =>request('/agents/tools/check-posts', {method: 'POST',body: JSON.stringify({ agentId, accountId, days, maxReplies, maxUpvotes })});-export const moltworldBuild = (accountId, agentId, x, y, z, type, action) =>+export const moltworldBuild = ({ accountId, agentId, x, y, z = 0, type, action }) =>request('/agents/tools/moltworld/build', {method: 'POST',body: JSON.stringify({ accountId, agentId, x, y, z, type, action })});-export const moltworldExplore = (accountId, agentId, x, y, thinking) =>+export const moltworldExplore = ({ accountId, agentId, x, y, thinking }) =>request('/agents/tools/moltworld/explore', {method: 'POST',body: JSON.stringify({ accountId, agentId, x, y, thinking })@@ -72,12 +72,12 @@ export const moltworldStatus = (accountId) =>request(`/agents/tools/moltworld/status?accountId=${accountId}`);export const moltworldRateLimits = (accountId) =>request(`/agents/tools/moltworld/rate-limits?accountId=${accountId}`);-export const moltworldThink = (accountId, thought, agentId) =>+export const moltworldThink = ({ accountId, agentId, thought }) =>request('/agents/tools/moltworld/think', {method: 'POST',body: JSON.stringify({ accountId, agentId, thought })});-export const moltworldSay = (accountId, message, sayTo, agentId) =>+export const moltworldSay = ({ accountId, agentId, message, sayTo }) =>request('/agents/tools/moltworld/say', {method: 'POST',body: JSON.stringify({ accountId, agentId, message, ...(sayTo ? { sayTo } : {}) })@@ -86,7 +86,7 @@ export const moltworldSay = (accountId, message, sayTo, agentId) =>// Moltworld Action Queueexport const moltworldGetQueue = (agentId) =>request(`/agents/tools/moltworld/queue/${agentId}`);-export const moltworldAddToQueue = (agentId, actionType, params, scheduledFor) =>+export const moltworldAddToQueue = ({ agentId, actionType, params, scheduledFor }) =>request('/agents/tools/moltworld/queue', {method: 'POST',body: JSON.stringify({ agentId, actionType, params, scheduledFor })@@ -104,7 +104,7 @@ export const moltworldWsDisconnect = () =>request('/agents/tools/moltworld/ws/disconnect', { method: 'POST' });export const moltworldWsStatus = (options = {}) =>request('/agents/tools/moltworld/ws/status', options);-export const moltworldWsMove = (x, y, thought) =>+export const moltworldWsMove = ({ x, y, thought }) =>request('/agents/tools/moltworld/ws/move', {method: 'POST',body: JSON.stringify({ x, y, ...(thought ? { thought } : {}) })@@ -126,7 +126,7 @@ export const createAgentDraft = (data) => request('/agents/tools/drafts', {method: 'POST',body: JSON.stringify(data)});-export const updateAgentDraft = (agentId, draftId, data) => request(`/agents/tools/drafts/${draftId}?agentId=${agentId}`, {+export const updateAgentDraft = ({ agentId, draftId, data }) => request(`/agents/tools/drafts/${draftId}?agentId=${agentId}`, {method: 'PUT',body: JSON.stringify(data)});diff --git a/client/src/services/apiAccounts.test.js b/client/src/services/apiAccounts.test.jsnew file mode 100644index 0000000000..15051340fe--- /dev/null+++ b/client/src/services/apiAccounts.test.js@@ -0,0 +1,40 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';++vi.mock('./apiCore.js', () => ({ request: vi.fn(async () => ({})) }));++import { request } from './apiCore.js';+import { generateAgentComment, moltworldBuild, moltworldSay } from './apiAccounts.js';++const lastCall = () => {+ const [path, options] = request.mock.calls.at(-1);+ return { path, method: options.method, body: JSON.parse(options.body) };+};++describe('apiAccounts named-field wrappers', () => {+ beforeEach(() => request.mockClear());++ it('generateAgentComment posts every named field', async () => {+ await generateAgentComment({ agentId: 'a1', accountId: 'c1', postId: 'p1', parentId: 'r1', providerId: 'prov', model: 'm' });+ expect(lastCall()).toEqual({+ path: '/agents/tools/generate-comment',+ method: 'POST',+ body: { agentId: 'a1', accountId: 'c1', postId: 'p1', parentId: 'r1', providerId: 'prov', model: 'm' }+ });+ });++ it('moltworldBuild posts coordinates and defaults z to 0', async () => {+ await moltworldBuild({ accountId: 'c1', agentId: 'a1', x: 1, y: 2, type: 'stone', action: 'place' });+ expect(lastCall()).toEqual({+ path: '/agents/tools/moltworld/build',+ method: 'POST',+ body: { accountId: 'c1', agentId: 'a1', x: 1, y: 2, z: 0, type: 'stone', action: 'place' }+ });+ });++ it('moltworldSay includes sayTo only when set', async () => {+ await moltworldSay({ accountId: 'c1', agentId: 'a1', message: 'hi', sayTo: 'bob' });+ expect(lastCall().body).toEqual({ accountId: 'c1', agentId: 'a1', message: 'hi', sayTo: 'bob' });+ await moltworldSay({ accountId: 'c1', agentId: 'a1', message: 'hi' });+ expect(lastCall().body).toEqual({ accountId: 'c1', agentId: 'a1', message: 'hi' });+ });+});