Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

fix(tools): use portable first-party schemas

BlueSkyID66604b935814101
diff --git a/bin/auto-tasks-contract.cjs b/bin/auto-tasks-contract.cjs
index 59a07509..074a7d6c 100644
--- a/bin/auto-tasks-contract.cjs
+++ b/bin/auto-tasks-contract.cjs
@@ -29,3 +29,38 @@ exports.shape = (z, bound) => {
limit: z.number().int().min(1).max(50).optional().describe('List only; default 20. Pages may be smaller to bound result size.'),
};
};
+
+/** Portable discovery only; shape() remains the strict execution validator. */
+exports.inputSchema = (z, bound) => {
+ const { zodToJsonSchema } = require('zod-to-json-schema');
+ const schema = zodToJsonSchema(z.object(exports.shape(z, bound)).strict(), { $refStrategy: 'none' });
+ const fields = schema.properties;
+ const flatten = (union, discriminator, description) => ({
+ type: 'object',
+ additionalProperties: false,
+ properties: {
+ ...Object.assign({}, ...union.anyOf.map(branch => branch.properties)),
+ [discriminator]: {
+ type: 'string',
+ enum: union.anyOf.map(branch => branch.properties[discriminator].const),
+ description,
+ },
+ },
+ required: [discriminator],
+ ...(union.description ? { description: union.description } : {}),
+ });
+ fields.schedule = flatten(fields.schedule, 'type', 'one_time requires at; hourly requires interval_hours; daily requires hour/minute; weekly also requires weekday; monthly also requires day. Omit fields belonging to other types.');
+ fields.recipient = flatten(fields.recipient, 'kind', 'commander takes kind only; agent also requires id and name.');
+ const cutoff = fields.end_condition;
+ fields.end_condition = {
+ ...flatten(cutoff.anyOf[0], 'type', 'date requires date; count requires max_runs. Omit fields belonging to the other type.'),
+ type: ['object', 'null'],
+ description: cutoff.description,
+ };
+ for (const name of ['project_id', 'skill', 'connector']) {
+ if (!fields[name]) continue;
+ const { anyOf, ...metadata } = fields[name];
+ fields[name] = { ...anyOf[0], ...metadata, type: [anyOf[0].type, 'null'] };
+ }
+ return schema;
+};
diff --git a/bin/orkas-bridge.cjs b/bin/orkas-bridge.cjs
index 1eed9cb4..f6f522f3 100644
--- a/bin/orkas-bridge.cjs
+++ b/bin/orkas-bridge.cjs
@@ -520,6 +520,19 @@ if (hasCapability('commander.handoff')) {
async function main() {
const transport = new StdioServerTransport();
+ if (hasCapability('automation')) {
+ const inputSchema = require('./auto-tasks-contract.cjs').inputSchema(z, true);
+ const send = transport.send.bind(transport);
+ // MCP's Zod conversion emits unions. Project only this owned discovery
+ // definition; keep the registered strict Zod validator for tools/call.
+ transport.send = (message, options) => send(
+ Array.isArray(message.result?.tools)
+ ? { ...message, result: { ...message.result, tools: message.result.tools.map(tool =>
+ tool.name === 'auto_tasks' ? { ...tool, inputSchema } : tool) } }
+ : message,
+ options,
+ );
+ }
await server.connect(transport);
}
diff --git a/src/core-agent/src/evolution/skill-tools.ts b/src/core-agent/src/evolution/skill-tools.ts
index 841075c4..00444ddb 100644
--- a/src/core-agent/src/evolution/skill-tools.ts
+++ b/src/core-agent/src/evolution/skill-tools.ts
@@ -78,19 +78,6 @@ export function createSkillManageTool(
},
required: ["action"],
additionalProperties: false,
- oneOf: [
- { properties: { action: { enum: ["list"] } }, required: ["action"] },
- { properties: { action: { enum: ["read"] } }, required: ["action", "id"] },
- { properties: { action: { enum: ["delete"] } }, required: ["action", "id"] },
- {
- properties: { action: { enum: ["create"] } },
- required: ["action", "id", "name", "description", "body"],
- },
- {
- properties: { action: { enum: ["patch"] } },
- required: ["action", "id", "old_string", "new_string"],
- },
- ],
},
async execute(input) {
const action = input.action as SkillManageAction;
diff --git a/src/core-agent/src/tools/memory-tool.ts b/src/core-agent/src/tools/memory-tool.ts
index fbfee9a0..1bc59de1 100644
--- a/src/core-agent/src/tools/memory-tool.ts
+++ b/src/core-agent/src/tools/memory-tool.ts
@@ -118,12 +118,6 @@ export function createCrossSessionMemoryTool(handler: MemoryToolHandler, opts: C
},
},
required: ['action'],
- oneOf: [
- { properties: { action: { const: 'add' } }, required: ['content'] },
- { properties: { action: { const: 'replace' } }, required: ['old_text', 'content'] },
- { properties: { action: { const: 'remove' } }, required: ['old_text'] },
- { properties: { action: { const: 'list' } } },
- ],
},
async execute(input: Record<string, unknown>, _ctx: ToolContext): Promise<ToolResult> {
diff --git a/src/core-agent/src/tools/metacognition-tool.ts b/src/core-agent/src/tools/metacognition-tool.ts
index ed15f194..971f1850 100644
--- a/src/core-agent/src/tools/metacognition-tool.ts
+++ b/src/core-agent/src/tools/metacognition-tool.ts
@@ -58,10 +58,6 @@ export function createMetacognitionTool(
},
},
required: ['action', 'target'],
- oneOf: [
- { properties: { action: { const: 'read' } } },
- { properties: { action: { const: 'write' } }, required: ['content'] },
- ],
},
async execute(input: Record<string, unknown>, _ctx: ToolContext): Promise<ToolResult> {
diff --git a/src/core-agent/src/tools/process-session.ts b/src/core-agent/src/tools/process-session.ts
index 99f69c51..fdad3f2e 100644
--- a/src/core-agent/src/tools/process-session.ts
+++ b/src/core-agent/src/tools/process-session.ts
@@ -567,12 +567,6 @@ export const processSessionTool: AgentTool = defineTool({
add_newline: { type: "boolean", description: "Write only. Append a newline; default false." },
},
required: ["action"],
- oneOf: [
- { properties: { action: { enum: ["start"] } }, required: ["action", "command"] },
- { properties: { action: { enum: ["read"] } }, required: ["action", "session_id"] },
- { properties: { action: { enum: ["write"] } }, required: ["action", "session_id", "chars"] },
- { properties: { action: { enum: ["stop"] } }, required: ["action", "session_id"] },
- ],
},
executionMode: "parallel",
async execute(input, ctx) {
diff --git a/src/core-agent/src/tools/project-tasks-tool.ts b/src/core-agent/src/tools/project-tasks-tool.ts
index 097cf436..db4a3bd4 100644
--- a/src/core-agent/src/tools/project-tasks-tool.ts
+++ b/src/core-agent/src/tools/project-tasks-tool.ts
@@ -123,14 +123,6 @@ export function createProjectTasksTool(source: ProjectTasksToolHandler | Project
result_ref: { type: 'string', description: "Delivering conversation, artifact, or file reference. In a Project conversation, save produced project files with library_save and use its returned path; outside one, use the file path." },
},
required: ['action'],
- oneOf: actions.map((action) => ({
- properties: { action: { const: action } },
- required: [
- ...(selector && action !== 'list_projects' ? ['project'] : []),
- ...(action === 'create' ? ['title'] : []),
- ...(['get', 'update', 'complete'].includes(action) ? ['task_id'] : []),
- ],
- })),
},
async execute(input: Record<string, unknown>, _ctx: ToolContext): Promise<ToolResult> {
diff --git a/src/core-agent/src/tools/run-program.ts b/src/core-agent/src/tools/run-program.ts
index 885b851a..d4d11357 100644
--- a/src/core-agent/src/tools/run-program.ts
+++ b/src/core-agent/src/tools/run-program.ts
@@ -235,13 +235,14 @@ export function createRunProgramTool(opts: CreateRunProgramToolOptions): AgentTo
inputSchema: {
type: "object",
properties,
- ...(supportsSourcePath
- ? { oneOf: [{ required: ["code"] }, { required: ["path"] }] }
- : { required: ["code"] }),
+ ...(!supportsSourcePath ? { required: ["code"] } : {}),
additionalProperties: false,
},
executionTimeoutOwner: "executor",
async execute(input, ctx) {
+ if ([input.code, input.path].some((value) => value != null && typeof value !== "string")) {
+ return incompleteResult("E_PROGRAM_BAD_INPUT", "`code` and `path` must be strings when supplied.", 0);
+ }
const inlineCode = typeof input.code === "string" ? input.code : "";
const requestedPath = typeof input.path === "string" ? input.path.trim() : "";
if (Boolean(inlineCode.trim()) === Boolean(requestedPath)) {
diff --git a/src/core-agent/test/evolution.test.ts b/src/core-agent/test/evolution.test.ts
index 687dab1e..2fc2b3a7 100644
--- a/src/core-agent/test/evolution.test.ts
+++ b/src/core-agent/test/evolution.test.ts
@@ -451,12 +451,8 @@ describe("Evolution: skill_manage tool", () => {
expect(action.description).toContain("list: no fields");
expect(action.description).toContain("create: id/name/description/body");
expect(action.description).toContain("patch: id/old_string/new_string");
- const branches = Object.fromEntries(schema.oneOf.map((branch: any) => [
- branch.properties.action.enum[0],
- branch.required,
- ]));
- expect(branches.patch).toEqual(["action", "id", "old_string", "new_string"]);
- expect(branches.create).toEqual(["action", "id", "name", "description", "body"]);
+ expect(schema.required).toEqual(["action"]);
+ expect(schema).not.toHaveProperty("oneOf");
});
it("rejects fields from another skill action", async () => {
diff --git a/src/core-agent/test/memory-tool.test.ts b/src/core-agent/test/memory-tool.test.ts
index 9cd442b4..5dbf2647 100644
--- a/src/core-agent/test/memory-tool.test.ts
+++ b/src/core-agent/test/memory-tool.test.ts
@@ -56,7 +56,7 @@ describe('createCrossSessionMemoryTool', () => {
expect(properties.action.description).toContain('use list only');
expect(properties.action.description).toContain('Omit unrelated fields');
expect(def.inputSchema.additionalProperties).toBe(false);
- expect(def.inputSchema.oneOf).toHaveLength(4);
+ expect(def.inputSchema).not.toHaveProperty('oneOf');
expect(warn).not.toHaveBeenCalled();
} finally {
warn.mockRestore();
diff --git a/src/core-agent/test/metacognition-tool.test.ts b/src/core-agent/test/metacognition-tool.test.ts
index fffbd8d7..0bade5e7 100644
--- a/src/core-agent/test/metacognition-tool.test.ts
+++ b/src/core-agent/test/metacognition-tool.test.ts
@@ -25,7 +25,7 @@ describe('createMetacognitionTool', () => {
expect((tool.inputSchema as any).properties.target).toBeDefined();
expect((tool.inputSchema as any).required).toEqual(['action', 'target']);
expect((tool.inputSchema as any).additionalProperties).toBe(false);
- expect((tool.inputSchema as any).oneOf).toHaveLength(2);
+ expect((tool.inputSchema as any)).not.toHaveProperty('oneOf');
expect((tool.inputSchema as any).properties.action.description)
.toContain('Omit unrelated fields');
});
diff --git a/src/core-agent/test/process-session.test.ts b/src/core-agent/test/process-session.test.ts
index e2859cc2..40ccd2cc 100644
--- a/src/core-agent/test/process-session.test.ts
+++ b/src/core-agent/test/process-session.test.ts
@@ -94,16 +94,8 @@ describe("persistent process sessions", () => {
it("advertises action requirements and rejects fields from another lifecycle action", async () => {
const processSession = tool("process_session");
const schema = processSession.inputSchema as any;
- const branches = Object.fromEntries(schema.oneOf.map((branch: any) => [
- branch.properties.action.enum[0],
- branch.required,
- ]));
- expect(branches).toEqual({
- start: ["action", "command"],
- read: ["action", "session_id"],
- write: ["action", "session_id", "chars"],
- stop: ["action", "session_id"],
- });
+ expect(schema.required).toEqual(["action"]);
+ expect(schema).not.toHaveProperty("oneOf");
const rejected = await processSession.execute({
action: "read",
diff --git a/src/core-agent/test/project-tasks-tool.test.ts b/src/core-agent/test/project-tasks-tool.test.ts
index 3f6c5b00..d88febcc 100644
--- a/src/core-agent/test/project-tasks-tool.test.ts
+++ b/src/core-agent/test/project-tasks-tool.test.ts
@@ -60,7 +60,8 @@ describe('todo_tasks tool', () => {
const tool = createProjectTasksTool(handler);
const schema = tool.inputSchema as any;
expect(schema.additionalProperties).toBe(false);
- expect(schema.oneOf).toHaveLength(5);
+ expect(schema).not.toHaveProperty('oneOf');
+ expect(schema.required).toEqual(['action']);
expect(schema.properties.action.description).toContain('Omit unrelated fields');
const result = await tool.execute({ action: 'complete', task_id: 't_9', status: 'done' }, ctx);
diff --git a/src/core-agent/test/run-program.test.ts b/src/core-agent/test/run-program.test.ts
index fbc3029b..b527eda6 100644
--- a/src/core-agent/test/run-program.test.ts
+++ b/src/core-agent/test/run-program.test.ts
@@ -216,8 +216,8 @@ for (const row of page.records) text(row.value);` }, ctx());
code: { type: "string" },
path: { type: "string" },
},
- oneOf: [{ required: ["code"] }, { required: ["path"] }],
});
+ expect(runProgram.inputSchema).not.toHaveProperty("oneOf");
const pathDescription = (runProgram.inputSchema.properties as Record<string, { description: string }>).path.description;
expect(pathDescription).toContain("Workspace-visible UTF-8 QuickJS source");
expect(pathDescription).toContain("Use instead of code, not together");
diff --git a/src/main/features/auto_tasks_tool.ts b/src/main/features/auto_tasks_tool.ts
index 1994d935..c3a8934c 100644
--- a/src/main/features/auto_tasks_tool.ts
+++ b/src/main/features/auto_tasks_tool.ts
@@ -1,6 +1,5 @@
/** One host-bound automation executor shared by Commander, named Agents, and CLI. */
import { z } from 'zod';
-import { zodToJsonSchema } from 'zod-to-json-schema';
import type { AgentTool } from '../../core-agent/src/tools/base';
import * as autoTasks from './auto_tasks';
import { projectExists } from './projects';
@@ -31,7 +30,7 @@ export function createAutoTasksTool(opts: { userId: string; cid?: string; projec
return {
name: 'auto_tasks',
description: contract.description,
- inputSchema: zodToJsonSchema(schema) as any,
+ inputSchema: contract.inputSchema(z, !!opts.projectId),
async execute(input) {
const fail = (error: string) => ({ content: JSON.stringify({ ok: false, error }), isError: true });
const parsed = schema.safeParse(input);
diff --git a/src/main/model/core-agent/chat-history-tools.ts b/src/main/model/core-agent/chat-history-tools.ts
index e9a5a1e6..1f14b2e8 100644
--- a/src/main/model/core-agent/chat-history-tools.ts
+++ b/src/main/model/core-agent/chat-history-tools.ts
@@ -726,27 +726,8 @@ export function createChatHistoryTool(opts: ChatHistoryToolsOpts): AgentTool {
...readProperties,
scope: scopeProperty,
},
+ additionalProperties: false,
required: currentOnly ? ['action', 'scope'] : ['action'],
- oneOf: [
- {
- // The root owns field types/descriptions; each closed branch owns
- // which fields its action accepts. An action enum alone does not
- // exclude the other action's root-level properties.
- properties: {
- action: { enum: ['search'] },
- ...Object.fromEntries(Object.keys(searchProperties).map((key) => [key, {}])),
- },
- additionalProperties: false,
- required: ['query'],
- },
- {
- properties: {
- action: { enum: ['read'] },
- ...Object.fromEntries(Object.keys(readProperties).map((key) => [key, {}])),
- },
- additionalProperties: false,
- },
- ],
},
async execute(input, ctx) {
const action = String(input.action ?? '').trim() as ChatHistoryAction;
diff --git a/src/main/model/core-agent/kb-tools.ts b/src/main/model/core-agent/kb-tools.ts
index 8bdecc91..3730edec 100644
--- a/src/main/model/core-agent/kb-tools.ts
+++ b/src/main/model/core-agent/kb-tools.ts
@@ -536,10 +536,6 @@ export function createLibraryTool(opts: KbToolsOpts): AgentTool {
type: 'string',
description: 'Search: optional exact-path filter. Read: required Library-relative path. Omit for list.',
};
- const branch = (action: LibraryAction, required: string[]) => ({
- properties: { action: { enum: [action] } },
- required: ['action', ...required],
- });
return {
name: 'library',
@@ -562,11 +558,6 @@ export function createLibraryTool(opts: KbToolsOpts): AgentTool {
path: pathProperty,
},
required: ['action'],
- oneOf: [
- branch('list', (list.inputSchema.required as string[] | undefined) ?? []),
- branch('search', (search.inputSchema.required as string[] | undefined) ?? []),
- branch('read', (read.inputSchema.required as string[] | undefined) ?? []),
- ],
},
async execute(input, ctx) {
const action = String(input.action ?? '').trim() as LibraryAction;
diff --git a/src/main/model/core-agent/local-tools.ts b/src/main/model/core-agent/local-tools.ts
index f843501c..e5b7bb08 100644
--- a/src/main/model/core-agent/local-tools.ts
+++ b/src/main/model/core-agent/local-tools.ts
@@ -4392,12 +4392,6 @@ function createInteractiveCliTool(opts: LocalToolsOpts): AgentTool {
reason: { type: 'string', description: 'Close only. Brief reason for a forced close.' },
},
required: ['action'],
- oneOf: [
- { properties: { action: { enum: ['start'] } }, required: ['action', 'command'] },
- { properties: { action: { enum: ['read'] } }, required: ['action', 'session_id'] },
- { properties: { action: { enum: ['send'] } }, required: ['action', 'session_id', 'input'] },
- { properties: { action: { enum: ['close'] } }, required: ['action', 'session_id'] },
- ],
},
async execute(input, ctx) {
const action = String(input.action ?? '') as InteractiveCliAction;
diff --git a/src/main/model/core-agent/office-tools.ts b/src/main/model/core-agent/office-tools.ts
index 08309c36..5e40a1e7 100644
--- a/src/main/model/core-agent/office-tools.ts
+++ b/src/main/model/core-agent/office-tools.ts
@@ -797,15 +797,8 @@ function createXlsxTool(opts: OfficeToolsOpts): AgentTool {
required: ['type'],
};
const cellSchema = {
- oneOf: [
- { type: 'string' },
- { type: 'number' },
- { type: 'boolean' },
- {
- type: 'object',
- properties: xlsxCellPropertySchema(),
- },
- ],
+ type: ['string', 'number', 'boolean', 'object'],
+ properties: xlsxCellPropertySchema(),
};
const columnSchema = {
type: 'object',
diff --git a/src/main/model/core-agent/tool-catalog-revision.ts b/src/main/model/core-agent/tool-catalog-revision.ts
index c9cb33f7..8d60758c 100644
--- a/src/main/model/core-agent/tool-catalog-revision.ts
+++ b/src/main/model/core-agent/tool-catalog-revision.ts
@@ -5,4 +5,4 @@
* it as their current-state oracle without pulling the Electron runtime or the
* tool catalog's logger/path dependency chain into model-eval processes.
*/
-export const TOOL_CATALOG_REVISION = '29';
+export const TOOL_CATALOG_REVISION = '30';
diff --git a/src/main/model/core-agent/tool-result-tools.ts b/src/main/model/core-agent/tool-result-tools.ts
index f59830f6..b584d654 100644
--- a/src/main/model/core-agent/tool-result-tools.ts
+++ b/src/main/model/core-agent/tool-result-tools.ts
@@ -279,7 +279,7 @@ function createToolResultTool(opts: ToolResultToolsOpts): AgentTool {
},
explode: {
type: 'string',
- description: 'Expand one advertised array by its record-relative path; no dataset prefix or [].',
+ description: 'Expand one advertised array by its record-relative path; no dataset prefix or []. With explode, field, filters.field and group_by use $item.<field>, $parent.<field>, or $index; scalar items use $item.',
},
field: {
type: 'string',
@@ -364,27 +364,28 @@ function createToolResultTool(opts: ToolResultToolsOpts): AgentTool {
},
required: ['ref', 'cursor'],
};
- const materializeRequest = {
- type: 'object',
- additionalProperties: false,
- properties: { ref: refProperty() },
- required: ['ref'],
- };
const actionProperty = {
type: 'string',
enum: ['search', 'query', 'read', 'materialize'],
- description: 'Choose exactly one operation and use only that action\'s request fields.',
+ description: 'search: narrow text lookup; query: deterministic aggregates; read: exact source excerpts; materialize: session-scoped UTF-8 copies for full-data calculations that query cannot express. Use one operation per call.',
};
- // The request shapes are advertised once, as the union of `requests.items`;
- // the action branches below only bind `action` to its purpose. Pairing each
- // action with its request shape is enforced at runtime
- // (`toolResultActionRequestError`), so repeating the full item schema per
- // branch bought no enforcement and cost ~1,100 tokens on every model request.
- const actionBranch = (action: ToolResultAction, description: string) => ({
+ // Conditional requirements and incompatible fields remain enforced by the
+ // selected action's executor. Keep one portable closed object for provider
+ // admission instead of nested union composition.
+ const requestSchema = {
+ type: 'object',
+ additionalProperties: false,
properties: {
- action: { type: 'string', enum: [action], description },
+ ...structuredRequest.properties,
+ query: searchRequest.properties.query,
+ match: textCountRequest.properties.match,
+ count_unit: textCountRequest.properties.count_unit,
+ cursor: readRequest.properties.cursor,
+ max_tokens: readRequest.properties.max_tokens,
},
- });
+ required: ['ref'],
+ description: 'Use only fields for the selected action. materialize takes ref only.',
+ };
return {
name: 'tool_result',
description:
@@ -399,16 +400,10 @@ function createToolResultTool(opts: ToolResultToolsOpts): AgentTool {
minItems: 1,
maxItems: TOOL_RESULT_BATCH_MAX_ITEMS,
description: 'One to eight same-action requests using only that action\'s fields (search: ref+query; query: ref+operation…; read: ref+cursor; materialize: ref). Retrieval actions share one 4K-token model-step budget.',
- items: { oneOf: [searchRequest, structuredRequest, textCountRequest, readRequest, materializeRequest] },
+ items: requestSchema,
},
},
required: ['action', 'requests'],
- oneOf: [
- actionBranch('search', 'Search 1-8 narrow text expressions; do not include cursor or aggregate fields.'),
- actionBranch('query', 'Run 1-8 deterministic aggregates matching the marker data type.'),
- actionBranch('read', 'Read 1-8 exact source excerpts by cursor for inspection; do not prefetch sequential chunks.'),
- actionBranch('materialize', 'Create 1-8 session-scoped UTF-8 working copies for full-data calculations that query cannot express; process them with an available local runtime.'),
- ],
},
async execute(input, ctx) {
const action = String(input.action ?? '') as ToolResultAction;
diff --git a/test/main/features/local_agents/bridge_e2e.test.ts b/test/main/features/local_agents/bridge_e2e.test.ts
index 8fcfefcc..6875e6d6 100644
--- a/test/main/features/local_agents/bridge_e2e.test.ts
+++ b/test/main/features/local_agents/bridge_e2e.test.ts
@@ -476,6 +476,9 @@ describe('orkas-bridge.cjs › MCP stdio e2e', () => {
expect(await autoTasks.getTask(TEST_UID, automationId)).toMatchObject({ project_id: pid, enabled: false });
const { createAutoTasksTool } = await import('../../../../src/main/features/auto_tasks_tool');
const nativeAuto = createAutoTasksTool({ userId: TEST_UID, projectId: pid });
+ const automationSchema = listed.result.tools.find((t: any) => t.name === 'auto_tasks').inputSchema;
+ expect(automationSchema).toEqual(nativeAuto.inputSchema);
+ expect(JSON.stringify(listed.result.tools)).not.toMatch(/"(?:oneOf|anyOf)":/);
const queryAuto = { action: 'list', enabled: false, offset: 0, limit: 1 };
const autoPage = await client.request(90, 'tools/call', { name: 'auto_tasks', arguments: queryAuto });
const nativeAutoPage = JSON.parse((await nativeAuto.execute(queryAuto, { state: {} })).content);
diff --git a/test/main/model/core-agent/chat-history-tools.test.ts b/test/main/model/core-agent/chat-history-tools.test.ts
index a7e9677c..919704f3 100644
--- a/test/main/model/core-agent/chat-history-tools.test.ts
+++ b/test/main/model/core-agent/chat-history-tools.test.ts
@@ -674,7 +674,8 @@ describe('chat-history-tools › shape', () => {
expect(schema.properties.scope.enum).toEqual(['current', 'all']);
expect(chatHistory.inputSchema.required).toEqual(['action']);
expect(JSON.stringify(chatHistory.inputSchema)).not.toMatch(/project/i);
- expect(schema.oneOf).toHaveLength(2);
+ expect(schema.additionalProperties).toBe(false);
+ expect(schema).not.toHaveProperty('oneOf');
});
it.each([false, true])('keeps action-specific schema validation aligned with execution (currentOnly=%s)', async (currentOnly) => {
@@ -708,25 +709,27 @@ describe('chat-history-tools › shape', () => {
expect(result.isError).toBeFalsy();
expect(result.content).toContain('contractword');
}
- // These are valid field types but belong to a different action. The
- // sampled search+cid failure must be excluded by the advertised schema.
+ // Portable schemas admit known fields independently of the selected
+ // action; the executor still rejects cross-action combinations.
for (const invalid of [
{ ...search, cid: 'sibling' },
{ ...read, query: 'contractword' },
{ ...read, k: 2 },
{ ...read, include_current: true },
- { ...search, unknown_field: true },
]) {
- expect(schema.Check(invalid), JSON.stringify(invalid)).toBe(false);
+ const hiddenFromCurrentOnly = currentOnly && ('cid' in invalid || 'include_current' in invalid);
+ expect(schema.Check(invalid), JSON.stringify(invalid)).toBe(!hiddenFromCurrentOnly);
const result = await tool.execute(invalid, ctxFor());
expect(result.isError).toBe(true);
expect(result.content).toContain('unsupported field(s)');
}
- expect(schema.Check({ action: 'search', scope })).toBe(false);
+ const unknown = { ...search, unknown_field: true };
+ expect(schema.Check(unknown)).toBe(false);
+ expect((await tool.execute(unknown, ctxFor())).isError).toBe(true);
+ expect(schema.Check({ action: 'search', scope })).toBe(true);
+ expect((await tool.execute({ action: 'search', scope }, ctxFor())).isError).toBe(true);
expect(schema.Check({ ...search, action: 'invalid' })).toBe(false);
- // Legacy search+page is still tolerated at execution, but must not be
- // advertised to models generating new calls.
- expect(schema.Check({ ...search, page: read.page })).toBe(false);
+ expect(schema.Check({ ...search, page: read.page })).toBe(true);
});
it('keeps action guidance on the tool and paging semantics on their fields', async () => {
@@ -780,10 +783,8 @@ describe('chat-history-tools › shape', () => {
{ id: 'm0', ts: '2026-01-01T00:00:00Z', from: 'user', text: 'find schemaunionword here' },
]);
const [, , chatHistory] = await createChatHistoryActions({ userId: TEST_UID });
- const searchBranch = (chatHistory.inputSchema as any).oneOf.find(
- (branch: any) => branch.properties.action.enum[0] === 'search',
- );
- expect(searchBranch.properties).not.toHaveProperty('page');
+ expect((chatHistory.inputSchema as any).properties).toHaveProperty('page');
+ expect((chatHistory.inputSchema as any)).not.toHaveProperty('oneOf');
const result = await chatHistory.execute({
action: 'search',
diff --git a/test/main/model/core-agent/injected-tool-fixture.ts b/test/main/model/core-agent/injected-tool-fixture.ts
index 7d150e96..5d6c15d1 100644
--- a/test/main/model/core-agent/injected-tool-fixture.ts
+++ b/test/main/model/core-agent/injected-tool-fixture.ts
@@ -3,8 +3,13 @@ import {
getBuiltinTools,
type AgentTool,
} from '../../../../src/core-agent/src/tools';
+import { createSkillManageTool } from '../../../../src/core-agent/src/evolution/skill-tools';
+import type { SkillStore } from '../../../../src/core-agent/src/evolution/skill-store';
import { createCrossSessionMemoryTool } from '../../../../src/core-agent/src/tools/memory-tool';
import { createMetacognitionTool } from '../../../../src/core-agent/src/tools/metacognition-tool';
+import { createProjectTasksTool } from '../../../../src/core-agent/src/tools/project-tasks-tool';
+import { createRunProgramTool } from '../../../../src/core-agent/src/tools/run-program';
+import { createAutoTasksTool } from '../../../../src/main/features/auto_tasks_tool';
import { createChatHistoryTool } from '../../../../src/main/model/core-agent/chat-history-tools';
import { createFileTools, createLocalTools } from '../../../../src/main/model/core-agent/local-tools';
import { createGenerateSpeechTool } from '../../../../src/main/model/core-agent/generate-speech-tool';
@@ -14,8 +19,27 @@ import { createVideoGenTool } from '../../../../src/main/model/core-agent/video-
import { createLibraryTool } from '../../../../src/main/model/core-agent/kb-tools';
import { createOfficeTools } from '../../../../src/main/model/core-agent/office-tools';
import { createPdfTools } from '../../../../src/main/model/core-agent/pdf-tools';
+import { createToolResultTools } from '../../../../src/main/model/core-agent/tool-result-tools';
import { buildBrowserTool } from '../../../../src/main/features/group_chat/browser_tool';
+/** Late/runtime definitions omitted from the common actor-budget corpus below.
+ * Dependencies fail closed: schema inspection must not read or mutate state. */
+export function enumerateRuntimeSchemaTools(): AgentTool[] {
+ const fail = async () => { throw new Error('Schema probe must not execute tools'); };
+ const store = { list: fail, read: fail, touch: fail, create: fail, patch: fail, delete: fail };
+ return [
+ createSkillManageTool(store as unknown as SkillStore),
+ createAutoTasksTool({ userId: 'schema-probe' }),
+ createProjectTasksTool({ list: fail, get: fail, create: fail, update: fail, complete: fail }),
+ createRunProgramTool({ listToolNames: () => [], invokeTool: fail, loadSourceFile: fail }),
+ ...createToolResultTools({
+ toolResultsDir: '/unused',
+ materializeDir: '/unused',
+ isProgrammaticToolCallContext: () => false,
+ }),
+ ];
+}
+
/**
* Assemble the stable built-in tool corpus measured by both runner-facing
* gates. Keeping this in one fixture makes the catalog anti-drift check and
diff --git a/test/main/model/core-agent/kb-tools.test.ts b/test/main/model/core-agent/kb-tools.test.ts
index 8fd6d1c2..679fee51 100644
--- a/test/main/model/core-agent/kb-tools.test.ts
+++ b/test/main/model/core-agent/kb-tools.test.ts
@@ -467,22 +467,15 @@ describe('kb-tools › shape', () => {
expect(library.inputSchema.required).toEqual(['action']);
});
- it('advertises action-discriminated schemas while enforcing action-specific fields', async () => {
+ it('advertises one portable schema while enforcing action-specific fields', async () => {
const library = await createLibrary();
const schema = library.inputSchema as any;
- const branches = Object.fromEntries(schema.oneOf.map((branch: any) => [
- branch.properties.action.enum[0], branch,
- ]));
expect(schema.properties).toHaveProperty('scope');
expect(schema.properties).toHaveProperty('query');
expect(schema.properties).toHaveProperty('path');
expect(schema.additionalProperties).toBe(false);
- expect(schema.oneOf).toHaveLength(3);
- expect(Object.keys(branches.list.properties)).toEqual(['action']);
- expect(Object.keys(branches.search.properties)).toEqual(['action']);
- expect(Object.keys(branches.read.properties)).toEqual(['action']);
- expect(branches.search.required).toEqual(['action', 'query']);
- expect(branches.read.required).toEqual(['action', 'path']);
+ expect(schema.required).toEqual(['action']);
+ expect(schema).not.toHaveProperty('oneOf');
const missingAction = await library.execute({ query: 'alpha' }, ctxFor());
const crossActionField = await library.execute({
diff --git a/test/main/model/core-agent/local-tools.test.ts b/test/main/model/core-agent/local-tools.test.ts
index 4d6ea46a..a1bb29e4 100644
--- a/test/main/model/core-agent/local-tools.test.ts
+++ b/test/main/model/core-agent/local-tools.test.ts
@@ -304,21 +304,13 @@ async function buildBashTool() {
}
describe('local-tools › interactive CLI action contract', () => {
- it('advertises branch requirements and rejects cross-action fields before session lookup', async () => {
+ it('advertises a portable action schema and rejects cross-action fields before session lookup', async () => {
const { createLocalTools } = await import('../../../../src/main/model/core-agent/local-tools');
const interactive = createLocalTools({ userId: UID, cid: CID })
.find((tool) => tool.name === 'interactive_cli')!;
const schema = interactive.inputSchema as any;
- const branches = Object.fromEntries(schema.oneOf.map((branch: any) => [
- branch.properties.action.enum[0],
- branch.required,
- ]));
- expect(branches).toEqual({
- start: ['action', 'command'],
- read: ['action', 'session_id'],
- send: ['action', 'session_id', 'input'],
- close: ['action', 'session_id'],
- });
+ expect(schema.required).toEqual(['action']);
+ expect(schema).not.toHaveProperty('oneOf');
const rejected = await interactive.execute({
action: 'close',
diff --git a/test/main/model/core-agent/office-tools.test.ts b/test/main/model/core-agent/office-tools.test.ts
index 1bef1ffc..22806a21 100644
--- a/test/main/model/core-agent/office-tools.test.ts
+++ b/test/main/model/core-agent/office-tools.test.ts
@@ -204,8 +204,9 @@ describe('Office built-in tools', () => {
});
expect(Object.keys(schema.properties)).toEqual(['path', 'sheets', 'preview']);
const sheetProps = schema.properties.sheets.items.properties;
- const cellObjectSchema = sheetProps.rows.items.items.oneOf.find((item: any) => item.type === 'object');
- const cellProps = cellObjectSchema.properties;
+ const cellSchema = sheetProps.rows.items.items;
+ expect(cellSchema.type).toEqual(['string', 'number', 'boolean', 'object']);
+ const cellProps = cellSchema.properties;
const chartProps = sheetProps.charts.items.properties;
expect(cellProps).toEqual(expect.objectContaining({
formula: expect.any(Object),
@@ -818,8 +819,7 @@ describe('Office built-in tools', () => {
it('shares the XLSX cell property contract between create_xlsx and XLSX edit operations', () => {
const create = getTool('create_xlsx').inputSchema as any;
const edit = getTool('edit_office').inputSchema as any;
- const createCell = create.properties.sheets.items.properties.rows.items.items.oneOf
- .find((item: any) => item.type === 'object').properties;
+ const createCell = create.properties.sheets.items.properties.rows.items.items.properties;
const editProps = edit.properties.operations.items.properties.props;
for (const key of ['value', 'formula', 'format', 'type', 'bold', 'italic', 'fill', 'font.name', 'font.color']) {
diff --git a/test/main/model/core-agent/tool-catalog.test.ts b/test/main/model/core-agent/tool-catalog.test.ts
index 583684fa..7465e51c 100644
--- a/test/main/model/core-agent/tool-catalog.test.ts
+++ b/test/main/model/core-agent/tool-catalog.test.ts
@@ -493,13 +493,14 @@ describe('tool-catalog', () => {
const fingerprint = createHash('sha256')
.update(JSON.stringify(schemas))
.digest('hex');
- // Requester-confirmed schema repair: chat_history closes each action
- // branch so search/read cannot advertise fields the executor rejects.
- // Existing runtime operations, scope grants, and legacy calls are unchanged.
+ // Requester-confirmed portable object schemas replace first-party action
+ // unions; executors retain conditional requirements and scope checks.
+ // XLSX cells use an equivalent primitive/object type array, and nested
+ // tool-result/automation unions are flattened without widening execution.
expect(
fingerprint,
'A model-visible field, enum, bound, default, or required rule changed; review it as a schema change, not description cleanup.',
- ).toBe('5606c89ec9be9bfc0d7a6c09b67c98940ed36a4e14381294b741e4434a93f76c');
+ ).toBe('4214c9aa583d6737d867d28ad27930c187cc2c973e50608f793de1896665bd85');
});
it('keeps the reviewed stable tool corpus within the description budgets', () => {
diff --git a/test/main/model/core-agent/tool-result-tools.test.ts b/test/main/model/core-agent/tool-result-tools.test.ts
index 558418e2..ab4052c9 100644
--- a/test/main/model/core-agent/tool-result-tools.test.ts
+++ b/test/main/model/core-agent/tool-result-tools.test.ts
@@ -283,15 +283,13 @@ describe('persisted tool-result retrieval', () => {
it('explains record-relative explode syntax at the provider boundary', () => {
const schema = toToolDefinition(getTool(tools, 'tool_result')).inputSchema as any;
- const structured = schema.properties.requests.items.oneOf.find(
- (shape: any) => shape.properties.explode,
- );
- const description = structured.properties.explode.description;
+ const request = schema.properties.requests.items;
+ const description = request.properties.explode.description;
expect(description).toMatch(/record-relative/i);
expect(description).toMatch(/no dataset prefix or \[\]/i);
- expect(structured.description).toMatch(/With explode, field, filters.field and group_by/);
- expect(structured.description).toMatch(/\$item\.<field>[\s\S]*\$parent\.<field>[\s\S]*\$index/);
- expect(structured.description).toContain('scalar items use $item');
+ expect(description).toMatch(/With explode, field, filters.field and group_by/);
+ expect(description).toMatch(/\$item\.<field>[\s\S]*\$parent\.<field>[\s\S]*\$index/);
+ expect(description).toContain('scalar items use $item');
expect(description).not.toContain('Subsequent paths');
});
@@ -411,7 +409,6 @@ describe('persisted tool-result retrieval', () => {
pattern?: string;
properties?: Record<string, Schema>;
items?: Schema;
- oneOf?: Schema[];
};
const definitions = tools.map(toToolDefinition);
const refs: Schema[] = [];
@@ -420,12 +417,10 @@ describe('persisted tool-result retrieval', () => {
if (schema.properties?.ref) refs.push(schema.properties.ref);
for (const property of Object.values(schema.properties ?? {})) visit(property);
visit(schema.items);
- for (const branch of schema.oneOf ?? []) visit(branch);
};
for (const tool of definitions) visit(tool.inputSchema as Schema);
- // search, structured aggregate, text count, read, materialize: one ref each.
- expect(refs).toHaveLength(5);
+ expect(refs).toHaveLength(1);
for (const schema of refs) {
expect(schema.pattern).toBe(TOOL_RESULT_REF_SCHEMA_PATTERN);
expect(schema.description).toMatch(/persisted-output/i);
@@ -439,45 +434,29 @@ describe('persisted tool-result retrieval', () => {
}
});
- it('advertises one action-discriminated canonical batch request', async () => {
+ it('advertises one portable canonical batch request', async () => {
expect(tools.map((tool) => tool.name)).toEqual(['tool_result']);
const schema = getTool(tools, 'tool_result').inputSchema as any;
- const branches = Object.fromEntries(schema.oneOf.map((branch: any) => [
- branch.properties.action.enum[0], branch,
- ]));
expect(schema.required).toEqual(['action', 'requests']);
expect(schema.properties.action.enum).toEqual(['search', 'query', 'read', 'materialize']);
- // The action branches only bind `action`; the request shapes are advertised
- // once as the `requests.items` union (the per-action pairing is enforced at
- // runtime, see the rejected-shape case below).
- expect(Object.keys(branches).sort()).toEqual(['materialize', 'query', 'read', 'search']);
- for (const branch of Object.values(branches) as any[]) {
- expect(Object.keys(branch.properties)).toEqual(['action']);
- }
- const shapes = schema.properties.requests.items.oneOf as any[];
- expect(shapes).toHaveLength(5);
- const byKeys = (keys: string[]) => shapes.find(
- (shape) => JSON.stringify(Object.keys(shape.properties).sort()) === JSON.stringify([...keys].sort()),
- );
- expect(byKeys(['ref', 'query'])).toBeTruthy();
- expect(byKeys(['ref', 'cursor', 'max_tokens'])).toBeTruthy();
- expect(byKeys(['ref'])).toBeTruthy();
- const structured = shapes.find((shape) => shape.properties.operation?.enum?.includes('sum'));
- const textCount = shapes.find((shape) => shape.properties.match);
- expect(structured.properties.operation.enum).toEqual(['count', 'sum', 'average', 'minimum', 'maximum']);
- expect(structured.required).toEqual(['ref', 'operation']);
- expect(structured.properties).not.toHaveProperty('match');
- expect(structured.properties).not.toHaveProperty('count_unit');
- expect(structured.description)
- .toMatch(/\$item[\s\S]*\$parent[\s\S]*\$index/);
- expect(textCount.required).toEqual(['ref', 'operation', 'match', 'count_unit']);
- expect(textCount.properties).not.toHaveProperty('dataset');
+ expect(schema).not.toHaveProperty('oneOf');
+ const request = schema.properties.requests.items;
+ expect(request.required).toEqual(['ref']);
+ expect(request.additionalProperties).toBe(false);
+ expect(request).not.toHaveProperty('oneOf');
+ expect(request).not.toHaveProperty('anyOf');
+ expect(request.properties.operation.enum).toEqual(['count', 'sum', 'average', 'minimum', 'maximum']);
+ expect(request.properties).toEqual(expect.objectContaining({
+ ref: expect.any(Object), query: expect.any(Object), cursor: expect.any(Object),
+ max_tokens: expect.any(Object), operation: expect.any(Object), match: expect.any(Object),
+ count_unit: expect.any(Object), dataset: expect.any(Object),
+ }));
expect(getTool(tools, 'tool_result').description).toMatch(/at most one tool_result call per model step/i);
- expect(branches.materialize.properties.action.description)
+ expect(schema.properties.action.description)
.toMatch(/full-data calculations.*query cannot express/);
- expect(branches.read.properties.action.description).toMatch(/source excerpts/);
- expect(branches.read.properties.action.description).not.toMatch(/query\/search cannot answer/);
+ expect(schema.properties.action.description).toMatch(/source excerpts/);
+ expect(schema.properties.action.description).not.toMatch(/query\/search cannot answer/);
const invalid = await getTool(tools, 'tool_result').execute({
action: 'unknown',
diff --git a/test/main/model/core-agent/tool-schema-compat.test.ts b/test/main/model/core-agent/tool-schema-compat.test.ts
new file mode 100644
index 00000000..9736113f
--- /dev/null
+++ b/test/main/model/core-agent/tool-schema-compat.test.ts
@@ -0,0 +1,137 @@
+import { describe, expect, it, vi } from 'vitest';
+import { AjvJsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/ajv';
+import { createPiProvider } from '../../../../src/core-agent/src/providers/pi-provider';
+import { toToolDefinition } from '../../../../src/core-agent/src/tools/base';
+import { buildCustomOpenAICompatibleModel } from '../../../../src/main/model/core-agent/external-providers';
+import { enumerateAllInjectedTools, enumerateRuntimeSchemaTools } from './injected-tool-fixture';
+
+function definitions() {
+ return [
+ ...enumerateAllInjectedTools(),
+ ...enumerateRuntimeSchemaTools(),
+ ].map(tool => ({ ...toToolDefinition(tool) }));
+}
+
+function containsUnion(value: unknown): boolean {
+ if (!value || typeof value !== 'object') return false;
+ return Object.entries(value).some(([key, child]) => ['oneOf', 'anyOf'].includes(key) || containsUnion(child));
+}
+
+function nestedSchema(tools: ReturnType<typeof definitions>, name: 'tool_result' | 'create_xlsx'): any {
+ const schema = tools.find(tool => tool.name === name)!.inputSchema as any;
+ return name === 'tool_result'
+ ? schema.properties.requests.items
+ : schema.properties.sheets.items.properties.rows.items.items;
+}
+
+describe('first-party tool schema portability through the real SDK', () => {
+ it.each(['complete', 'stream'] as const)('admits common and runtime tools on %s and rejects root or nested unions', async mode => {
+ const requestFetch = vi.spyOn(globalThis, 'fetch').mockImplementation(async (_url, init) => {
+ const payload = JSON.parse(String(init?.body));
+ expect(payload.tools.length).toBeGreaterThan(30);
+ expect(payload.tools.map((tool: any) => tool.function.name)).toEqual(expect.arrayContaining([
+ 'skill_manage', 'tool_result', 'todo_tasks', 'run_program',
+ 'cross_session_memory', 'create_xlsx', 'auto_tasks',
+ ]));
+ const invalid = payload.tools.some((tool: any) => {
+ const schema = tool.function.parameters;
+ return schema.type !== 'object' || containsUnion(schema)
+ || ['allOf', 'enum', 'const', 'not'].some(key => Object.hasOwn(schema, key));
+ });
+ if (invalid) {
+ return new Response(JSON.stringify({
+ error: { message: 'Unsupported root composition or union', type: 'invalid_request_error' },
+ }), { status: 400, headers: { 'content-type': 'application/json' } });
+ }
+ const chunk = (delta: object, finish_reason: string | null) => ({
+ id: 'fixture', object: 'chat.completion.chunk', created: 1, model: 'schema-test',
+ choices: [{ index: 0, delta, finish_reason }],
+ });
+ return new Response(
+ [chunk({ role: 'assistant', content: 'hello' }, null), chunk({}, 'stop')]
+ .map(value => `data: ${JSON.stringify(value)}\n\n`).join('') + 'data: [DONE]\n\n',
+ { headers: { 'content-type': 'text/event-stream' } },
+ );
+ });
+ try {
+ const provider = createPiProvider({
+ provider: 'custom',
+ apiKey: 'synthetic',
+ customModel: buildCustomOpenAICompatibleModel('schema-test', {
+ baseUrl: 'https://schema.example.test/v1', contextWindow: 128000, maxTokens: 1024,
+ }),
+ });
+ for (const legacy of [null, 'root', 'tool_result', 'create_xlsx', 'auto_tasks'] as const) {
+ const tools = definitions();
+ if (legacy === 'root') {
+ tools[0].inputSchema = { ...tools[0].inputSchema, oneOf: [{ required: ['action'] }] };
+ } else if (legacy) {
+ const tool = tools.find(candidate => candidate.name === legacy)!;
+ tool.inputSchema = structuredClone(tool.inputSchema);
+ const node = legacy === 'auto_tasks'
+ ? (tool.inputSchema as any).properties.schedule
+ : nestedSchema(tools, legacy);
+ node.anyOf = [{ type: 'object' }, { type: 'string' }];
+ }
+ const request = {
+ model: 'schema-test',
+ messages: [{ role: 'user' as const, content: [{ type: 'text' as const, text: 'hello' }] }],
+ tools,
+ };
+ if (mode === 'complete') {
+ if (legacy) await expect(provider.complete(request)).rejects.toThrow(/Unsupported root composition or union/);
+ else expect((await provider.complete(request)).content).toContainEqual({ type: 'text', text: 'hello' });
+ } else {
+ const events = [];
+ for await (const event of provider.stream(request)) events.push(event);
+ expect(events.some(event => event.type === 'error')).toBe(Boolean(legacy));
+ if (!legacy) expect(events.some(event => event.type === 'message_end')).toBe(true);
+ }
+ }
+ expect(requestFetch).toHaveBeenCalledTimes(5);
+ } finally {
+ requestFetch.mockRestore();
+ }
+ });
+});
+
+describe('portable field schemas', () => {
+ const ref = 'grep_files.0123456789abcdef';
+
+ it('retains tool-result field types, bounds, and closed properties', () => {
+ const schema = nestedSchema(definitions(), 'tool_result');
+ expect(containsUnion(schema)).toBe(false);
+ const accepts = new AjvJsonSchemaValidator().getValidator(schema);
+ for (const value of [
+ { ref, query: 'needle' },
+ { ref, operation: 'sum', field: 'amount' },
+ { ref, operation: 'count', match: 'needle', count_unit: 'occurrences' },
+ { ref, cursor: 0 },
+ { ref },
+ ]) expect(accepts(value).valid, JSON.stringify(value)).toBe(true);
+ for (const value of [
+ null, [], {}, { ref, cursor: -1 }, { ref, unexpected: true },
+ { ref, operation: 'unknown' }, { ref, count_unit: 'unknown' }, { ref, max_tokens: 255 },
+ ]) expect(accepts(value).valid, JSON.stringify(value)).toBe(false);
+ });
+
+ it('preserves XLSX cell acceptance exactly using type arrays', () => {
+ const schema = nestedSchema(definitions(), 'create_xlsx');
+ expect(containsUnion(schema)).toBe(false);
+ expect(schema.type).toEqual(['string', 'number', 'boolean', 'object']);
+ const validator = new AjvJsonSchemaValidator();
+ const accepts = validator.getValidator(schema);
+ const previous = validator.getValidator({ oneOf: [
+ { type: 'string' }, { type: 'number' }, { type: 'boolean' },
+ { type: 'object', properties: schema.properties },
+ ] });
+ const valid = ['text', '', 0, -1.5, false, true, {}, { value: 3, bold: true }, { formula: 'SUM(A1:A3)', format: '0.00' }];
+ const invalid = [null, [], ['text'], { value: [] }, { formula: 3 }, { bold: 'yes' }, { type: 'unknown' }];
+ for (const [values, expected] of [[valid, true], [invalid, false]] as const) {
+ for (const value of values) {
+ expect(accepts(value).valid, JSON.stringify(value)).toBe(expected);
+ expect(previous(value).valid, JSON.stringify(value)).toBe(expected);
+ }
+ }
+ });
+});
diff --git a/test/main/model/runner.test.ts b/test/main/model/runner.test.ts
index 4d996154..baccadd4 100644
--- a/test/main/model/runner.test.ts
+++ b/test/main/model/runner.test.ts
@@ -2073,7 +2073,6 @@ describe('runner › scoped tool loading', () => {
description: string;
inputSchema: {
properties?: Record<string, { description?: string }>;
- oneOf?: Array<{ required: string[] }>;
};
}>;
};
@@ -2094,10 +2093,7 @@ describe('runner › scoped tool loading', () => {
expect(programDefinition().inputSchema.properties?.path?.description)
.toContain('execute exactly as saved');
expect(programDefinition().description).not.toContain('read_files raw_text:true');
- expect(programDefinition().inputSchema.oneOf).toEqual([
- { required: ['code'] },
- { required: ['path'] },
- ]);
+ expect(programDefinition().inputSchema).not.toHaveProperty('oneOf');
const savedResult = await runner.tools.get('run_program')?.execute(
{ path: 'saved-program.js' },
{ workingDir: workspace, state: {}, signal: undefined },