import { t as buildToolDeclarations } from "./declarations-DB4Yh-wL.js";

//#region src/koi/code-mode/system-prompt-snippet.ts
function buildCodeModePromptSnippet(innerTools) {
	return [
		"## CODE MODE",
		"",
		"All your tools are exposed inside a single `run_code({ js })` tool. ",
		"Instead of emitting one tool_use call per step, you write a small ",
		"JavaScript program that calls them. The program runs in a sandbox ",
		"where these globals are available:",
		"",
		"```ts",
		buildToolDeclarations(innerTools),
		"```",
		"",
		"### Why",
		"Calling many tools in one program is faster (one model round-trip ",
		"instead of N), cheaper on context (intermediate tool results stay ",
		"inside the sandbox), and far more composable — filter, map, loop, ",
		"retry, fan-out, anything you'd normally do in code.",
		"",
		"### Rules",
		"1. **Use `await`** for every `tools.x(...)` call. They're async.",
		"2. **Top-level `await` is fine.** So is wrapping the body in ",
		"   `(async () => { ... })()`. Either works.",
		"3. **Output to the user** with `text(\"...\")` — call it as many ",
		"   times as you want. Only those strings (plus the program's ",
		"   final resolved value) reach the next turn. Don't try to log ",
		"   to console — it goes nowhere.",
		"4. **`progress(\"…\")`** posts a short non-final status update ",
		"   so the user can see what step you're on without it cluttering ",
		"   the chat.",
		"5. **No imports, no require, no fetch, no process, no globalThis.** ",
		"   Only the declared `tools`, `text`, `progress`, plus normal JS ",
		"   primitives (Math, JSON, Date, Map, Set, Promise, etc.).",
		"6. **Errors thrown from `tools.*` calls propagate.** Wrap with ",
		"   try/catch if you want to recover and continue.",
		"",
		"### Pattern",
		"",
		"Prefer composing in one program over many sequential `run_code` ",
		"calls. Example:",
		"",
		"```js",
		"const files = await tools.search_files({ query: 'auth bug' });",
		"const relevant = files.results.filter(f => f.path.includes('auth')).slice(0, 5);",
		"const contents = await Promise.all(",
		"  relevant.map(f => tools.read_file({ path: f.path })),",
		");",
		"text(contents.map(c => c.details?.summary ?? '').join('\\n\\n'));",
		"```",
		"",
		"Plan first, then write one program that executes the plan. Only ",
		"fall back to multiple `run_code` calls when you genuinely need ",
		"the model to think between steps.",
		""
	].join("\n");
}

//#endregion
export { buildCodeModePromptSnippet };