1 // Meta parser for `exec_shell_command` tool calls. Surfaces the
2 // command text from args `command` / `cmd` / `shell_command` aliases.
3 // The exit-status and error parsing live in their own utilities
4 // (`parse-exec-shell-status.ts` / `parse-exec-shell-error.ts`) - this
5 // file only deals with what's strictly about *calling* the tool, since
6 // the error / exit status elide from call-section to result-section.
8 import { parseToolArgs } from './_shared';
9 import { BuiltInTool } from '$lib/enums';
10 import type { AgenticSection } from '$lib/utils';
12 export type ExecShellCommandMeta = {
16 export function parseExecShellCommandMeta(section: AgenticSection): ExecShellCommandMeta | null {
17 const args = parseToolArgs(BuiltInTool.EXEC_SHELL_COMMAND, section);
19 if (!args) return null;
21 const commandRaw = args.command ?? args.cmd ?? args.shell_command;
23 if (typeof commandRaw !== 'string' || !commandRaw) return null;
25 return { command: commandRaw };