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 { BuiltInTool } from '$lib/enums';
9 import type { AgenticSection } from '$lib/utils';
10 import { parseToolArgs } from './_shared';
12 export type ExecShellCommandMeta = {
16 export function parseExecShellCommandMeta(section: AgenticSection): ExecShellCommandMeta | null {
17 const args = parseToolArgs(BuiltInTool.EXEC_SHELL_COMMAND, section);
18 if (!args) return null;
20 const commandRaw = args.command ?? args.cmd ?? args.shell_command;
21 if (typeof commandRaw !== 'string' || !commandRaw) return null;
22 return { command: commandRaw };