refactor(tools): share terminal task schema

This commit is contained in:
Tianyi Cui
2026-07-22 23:24:43 +08:00
parent e3112be762
commit 17b9792532

View File

@@ -84,6 +84,15 @@ const SESSION_SNAPSHOT_SCHEMA = {
properties: SESSION_SNAPSHOT_PROPERTIES, properties: SESSION_SNAPSHOT_PROPERTIES,
} as const } as const
const BACKGROUND_TASK_OUTPUT_SCHEMA = {
type: 'object',
additionalProperties: false,
properties: {
kind: { type: 'string', required: true, const: 'background' },
taskId: { type: 'string', required: true },
},
} as const
function requireAgent(agent: Agent | undefined): Agent { function requireAgent(agent: Agent | undefined): Agent {
if (agent === undefined) throw new Error('terminal tools require an initiating agent') if (agent === undefined) throw new Error('terminal tools require an initiating agent')
return agent return agent
@@ -162,14 +171,7 @@ export function apply(ctx: Context): void {
output: { output: {
schema: { schema: {
oneOf: [ oneOf: [
{ BACKGROUND_TASK_OUTPUT_SCHEMA,
type: 'object',
additionalProperties: false,
properties: {
kind: { type: 'string', required: true, const: 'background' },
taskId: { type: 'string', required: true },
},
},
{ {
type: 'object', type: 'object',
additionalProperties: false, additionalProperties: false,