]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
e8adbd18b06b20f994df9bb61006eabe77861d4d
[pkg/ggml/sources/llama.cpp] /
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.
7
8 import { BuiltInTool } from '$lib/enums';
9 import type { AgenticSection } from '$lib/utils';
10 import { parseToolArgs } from './_shared';
11
12 export type ExecShellCommandMeta = {
13 command: string;
14 };
15
16 export function parseExecShellCommandMeta(section: AgenticSection): ExecShellCommandMeta | null {
17 const args = parseToolArgs(BuiltInTool.EXEC_SHELL_COMMAND, section);
18 if (!args) return null;
19
20 const commandRaw = args.command ?? args.cmd ?? args.shell_command;
21 if (typeof commandRaw !== 'string' || !commandRaw) return null;
22 return { command: commandRaw };
23 }