From 17b979253222261a5a5ba5122a31ac7df6fa9db3 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Wed, 22 Jul 2026 23:24:43 +0800 Subject: [PATCH] refactor(tools): share terminal task schema --- packages/pty/tool-pty/src/index.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/pty/tool-pty/src/index.ts b/packages/pty/tool-pty/src/index.ts index 3d9495d5ae..9aedd4c649 100644 --- a/packages/pty/tool-pty/src/index.ts +++ b/packages/pty/tool-pty/src/index.ts @@ -84,6 +84,15 @@ const SESSION_SNAPSHOT_SCHEMA = { properties: SESSION_SNAPSHOT_PROPERTIES, } 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 { if (agent === undefined) throw new Error('terminal tools require an initiating agent') return agent @@ -162,14 +171,7 @@ export function apply(ctx: Context): void { output: { schema: { oneOf: [ - { - type: 'object', - additionalProperties: false, - properties: { - kind: { type: 'string', required: true, const: 'background' }, - taskId: { type: 'string', required: true }, - }, - }, + BACKGROUND_TASK_OUTPUT_SCHEMA, { type: 'object', additionalProperties: false,