diff options
| author | Adam Malczewski <[email protected]> | 2026-05-23 16:59:20 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-05-23 16:59:20 +0900 |
| commit | 236beefb708a6cd91b673978ddf4ebf045a9844c (patch) | |
| tree | 6522c65a0d490b41cc01297f2444f160f8dbb7f8 /packages/core/src/tools/run-shell.ts | |
| parent | 225d3ea65cfc35d211fc66e30cf05cbc693d37e4 (diff) | |
| download | dispatch-236beefb708a6cd91b673978ddf4ebf045a9844c.tar.gz dispatch-236beefb708a6cd91b673978ddf4ebf045a9844c.zip | |
feat: key fallback using agent models[] hierarchy, background tool modes, copy truncation
- Agent rate-limit fallback now iterates through agent's configured models[] in strict order
- Frontend sends agentModels with each /chat request; backend uses buildFallbackSequence()
- Emits notice event on fallback so chat shows which key failed and what's being tried next
- Child agents inherit parent's agentModels for fallback
- Added statusCode propagation from AI SDK errors for programmatic 429 detection
- Copy button truncates all tool results at 300 chars (was 200 for 4 specific tools)
- run_shell, summon, youtube_transcribe: background mode support
- summon: blocking mode by default with getResult callback
Diffstat (limited to 'packages/core/src/tools/run-shell.ts')
| -rw-r--r-- | packages/core/src/tools/run-shell.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/core/src/tools/run-shell.ts b/packages/core/src/tools/run-shell.ts index 6671c31..ec2db9c 100644 --- a/packages/core/src/tools/run-shell.ts +++ b/packages/core/src/tools/run-shell.ts @@ -54,6 +54,12 @@ export function createRunShellTool( parameters: z.object({ command: z.string().describe("The shell command to execute"), timeout: z.number().optional().describe("Timeout in milliseconds (default 2 minutes)"), + background: z + .boolean() + .optional() + .describe( + "If true, the command starts in the background and a job_id is returned immediately. Use the retrieve tool with the job_id to get the result later.", + ), }), execute: async ( args: Record<string, unknown>, @@ -61,6 +67,7 @@ export function createRunShellTool( ): Promise<string> => { const command = args.command as string; const timeout = (args.timeout as number | undefined) ?? DEFAULT_TIMEOUT; + const background = (args.background as boolean | undefined) ?? false; const [shell, shellArgs] = getShell(); const child = spawn(shell, [...shellArgs, command], { @@ -99,6 +106,23 @@ export function createRunShellTool( }); }); + // If background mode requested, register immediately and return job ID + if (background && shellStore) { + const jobId = shellStore.register({ + command, + stdout, + stderr, + completion: completionPromise, + }); + return [ + `Command started in background.`, + `job_id: ${jobId}`, + `command: ${command}`, + ``, + `Use the retrieve tool with this job_id to get the result when ready.`, + ].join("\n"); + } + const queueCallbacks = context?.queueCallbacks; if (queueCallbacks && shellStore) { |
