Skip to content

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

address review (codex): align creative tool contracts with wrapped services

[._.]/ Adam Eivy492747aaa0d9
diff --git a/server/services/creative/toolRegistry.test.js b/server/services/creative/toolRegistry.test.js
index 4e3c539099..f9c04a5d31 100644
--- a/server/services/creative/toolRegistry.test.js
+++ b/server/services/creative/toolRegistry.test.js
@@ -12,6 +12,7 @@ vi.mock('../voice/tools.js', () => ({
parameters: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] },
}
: null),
+ dispatchTool: vi.fn(async () => ({ summary: 'voice catalog result', results: [] })),
}));
// Mock the autonomy config + budget/usage services so gating is deterministic.
@@ -43,6 +44,7 @@ vi.mock('../catalogDB.js', () => ({ listIngredients: vi.fn(async () => ({ items:
vi.mock('../creativeDirector/autoCast.js', () => ({ suggestCastForBrief: vi.fn(async () => []) }));
import { loadState } from '../cosState.js';
+import { dispatchTool as dispatchVoiceTool } from '../voice/tools.js';
import { getDomainBudgetStatus, recordDomainUsage } from '../domainUsage.js';
import { createSeries } from '../pipeline/series.js';
import { generateStage } from '../pipeline/textStages.js';
@@ -195,6 +197,14 @@ describe('budget charging', () => {
expect(recordDomainUsage).not.toHaveBeenCalled();
});
+ it('catalog.searchIngredients delegates to the voice catalog_lookup tool (honors the hydrated contract)', async () => {
+ setMode('execute');
+ const out = await dispatchCreativeTool('catalog.searchIngredients', { query: 'noir' }, { some: 'ctx' });
+ expect(dispatchVoiceTool).toHaveBeenCalledWith('catalog_lookup', { query: 'noir' }, { some: 'ctx' });
+ expect(out.ok).toBe(true);
+ expect(recordDomainUsage).not.toHaveBeenCalled(); // free tool
+ });
+
it('rejects when the budget is exhausted, without executing', async () => {
setMode('execute');
getDomainBudgetStatus.mockResolvedValue({ withinBudget: false, exceeded: 'actions' });
diff --git a/server/services/creative/tools/catalog.js b/server/services/creative/tools/catalog.js
index a4e8cb639f..63ad5f1f5f 100644
--- a/server/services/creative/tools/catalog.js
+++ b/server/services/creative/tools/catalog.js
@@ -6,21 +6,23 @@
*/
import { z } from 'zod';
-import { listIngredients } from '../../catalogDB.js';
+import { dispatchTool as dispatchVoiceTool } from '../../voice/tools.js';
import { suggestCastForBrief } from '../../creativeDirector/autoCast.js';
import { COST_FREE, COST_LLM } from './shared.js';
export const CATALOG_TOOLS = [
{
name: 'catalog.searchIngredients',
- // description + parameters are hydrated from the voice `catalog_lookup` tool
- // (single source of the ingredient-search schema); the guard guarantees the
- // hydration resolves, so no authored fallback is needed here. Only the Zod
- // `schema` (used for arg validation) is local.
+ // Full conductor over the voice `catalog_lookup` tool: description +
+ // parameters are hydrated from it (single source of the ingredient-search
+ // schema; the guard guarantees hydration resolves) AND execute delegates to
+ // its implementation via dispatchVoiceTool — so the advertised input AND
+ // result shape (default limit 5/max 20, snippet + refsCount) are honored
+ // exactly, with no re-implementation.
costClass: COST_FREE,
hydrateFrom: 'catalog_lookup',
- schema: z.object({ query: z.string().min(1), type: z.string().optional(), limit: z.number().int().positive().max(50).optional() }),
- execute: ({ query, type, limit }) => listIngredients({ query, type, limit: limit ?? 20 }),
+ schema: z.object({ query: z.string().min(1), type: z.string().optional(), limit: z.number().int().positive().max(20).optional() }),
+ execute: (args, ctx) => dispatchVoiceTool('catalog_lookup', args, ctx),
},
{
name: 'catalog.suggestCastForBrief',
diff --git a/server/services/creative/tools/pipeline.js b/server/services/creative/tools/pipeline.js
index 3027bfb572..2060919f0f 100644
--- a/server/services/creative/tools/pipeline.js
+++ b/server/services/creative/tools/pipeline.js
@@ -17,13 +17,17 @@ export const PIPELINE_TOOLS = [
name: 'pipeline.createSeries',
description: 'Create a new pipeline series record. Persists a record; returns it.',
costClass: COST_FREE,
- schema: z.object({}).passthrough(),
+ // The wrapped service rejects a missing/blank `name`; require it here so a
+ // bad orchestrator call fails the gate instead of the service.
+ schema: z.object({ name: z.string().min(1) }).passthrough(),
parameters: {
type: 'object',
properties: {
- name: { type: 'string', description: 'Optional series name.' },
+ name: { type: 'string', description: 'Series name (required).' },
universeId: { type: 'string', description: 'Optional universe to attach the series to.' },
+ premise: { type: 'string', description: 'Optional series premise.' },
},
+ required: ['name'],
},
execute: (args) => createSeries(args),
},
diff --git a/server/services/creative/tools/storyBuilder.js b/server/services/creative/tools/storyBuilder.js
index ac3568b210..67811c123e 100644
--- a/server/services/creative/tools/storyBuilder.js
+++ b/server/services/creative/tools/storyBuilder.js
@@ -10,15 +10,21 @@ import { COST_FREE, COST_LLM } from './shared.js';
export const STORY_BUILDER_TOOLS = [
{
name: 'storyBuilder.createStorySession',
- description: 'Create a new story-builder session (optionally minting a universe). Persists the session; returns its id.',
+ description: 'Create a new story-builder session (optionally minting a universe/series from the title + seed). Persists the session; returns its id.',
costClass: COST_FREE,
- schema: z.object({}).passthrough(),
+ // The wrapped service requires a non-empty `title` (it doubles as the minted
+ // universe/series name); other fields are optional passthrough.
+ schema: z.object({ title: z.string().min(1) }).passthrough(),
parameters: {
type: 'object',
properties: {
- name: { type: 'string', description: 'Optional session name.' },
- universeId: { type: 'string', description: 'Optional existing universe to attach to.' },
+ title: { type: 'string', description: 'Session title (also used as the minted universe/series name).' },
+ seedIdea: { type: 'string', description: 'Optional seed idea that seeds the universe starter prompt.' },
+ universeId: { type: 'string', description: 'Optional existing universe to attach to (instead of minting one).' },
+ seriesId: { type: 'string', description: 'Optional existing series to attach to.' },
+ intakeMode: { type: 'string', description: "Intake mode (default 'seed')." },
},
+ required: ['title'],
},
execute: (args) => createStorySession(args),
},