open-multi-agent-kit 0.93.0 → 0.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/README.md +2 -2
  3. package/dist/core/agent-session.d.ts +7 -14
  4. package/dist/core/agent-session.d.ts.map +1 -1
  5. package/dist/core/agent-session.js +78 -347
  6. package/dist/core/agent-session.js.map +1 -1
  7. package/dist/core/package-manager.d.ts.map +1 -1
  8. package/dist/core/package-manager.js +11 -1
  9. package/dist/core/package-manager.js.map +1 -1
  10. package/dist/core/sandbox/default-policy.d.ts +14 -0
  11. package/dist/core/sandbox/default-policy.d.ts.map +1 -0
  12. package/dist/core/sandbox/default-policy.js +58 -0
  13. package/dist/core/sandbox/default-policy.js.map +1 -0
  14. package/dist/core/sdk.d.ts.map +1 -1
  15. package/dist/core/sdk.js +1 -1
  16. package/dist/core/sdk.js.map +1 -1
  17. package/dist/core/session-bash-runtime.d.ts +62 -0
  18. package/dist/core/session-bash-runtime.d.ts.map +1 -0
  19. package/dist/core/session-bash-runtime.js +167 -0
  20. package/dist/core/session-bash-runtime.js.map +1 -0
  21. package/dist/core/session-bash-service.d.ts +61 -0
  22. package/dist/core/session-bash-service.d.ts.map +1 -0
  23. package/dist/core/session-bash-service.js +155 -0
  24. package/dist/core/session-bash-service.js.map +1 -0
  25. package/dist/core/session-compaction-service.d.ts +48 -0
  26. package/dist/core/session-compaction-service.d.ts.map +1 -0
  27. package/dist/core/session-compaction-service.js +250 -0
  28. package/dist/core/session-compaction-service.js.map +1 -0
  29. package/dist/core/skills-catalog-cache.d.ts +25 -0
  30. package/dist/core/skills-catalog-cache.d.ts.map +1 -0
  31. package/dist/core/skills-catalog-cache.js +123 -0
  32. package/dist/core/skills-catalog-cache.js.map +1 -0
  33. package/dist/core/skills.d.ts +6 -0
  34. package/dist/core/skills.d.ts.map +1 -1
  35. package/dist/core/skills.js +25 -4
  36. package/dist/core/skills.js.map +1 -1
  37. package/dist/core/system-prompt.d.ts.map +1 -1
  38. package/dist/core/system-prompt.js +1 -1
  39. package/dist/core/system-prompt.js.map +1 -1
  40. package/dist/core/tools/bash.d.ts +3 -0
  41. package/dist/core/tools/bash.d.ts.map +1 -1
  42. package/dist/core/tools/bash.js +3 -2
  43. package/dist/core/tools/bash.js.map +1 -1
  44. package/dist/core/tools/diagnostics.d.ts +29 -0
  45. package/dist/core/tools/diagnostics.d.ts.map +1 -0
  46. package/dist/core/tools/diagnostics.js +325 -0
  47. package/dist/core/tools/diagnostics.js.map +1 -0
  48. package/dist/core/tools/index.d.ts +2 -1
  49. package/dist/core/tools/index.d.ts.map +1 -1
  50. package/dist/core/tools/index.js +18 -1
  51. package/dist/core/tools/index.js.map +1 -1
  52. package/dist/core/verified-bash-adapter.d.ts +18 -1
  53. package/dist/core/verified-bash-adapter.d.ts.map +1 -1
  54. package/dist/core/verified-bash-adapter.js +38 -1
  55. package/dist/core/verified-bash-adapter.js.map +1 -1
  56. package/dist/core/verified-bash-runtime.d.ts +13 -0
  57. package/dist/core/verified-bash-runtime.d.ts.map +1 -0
  58. package/dist/core/verified-bash-runtime.js +81 -0
  59. package/dist/core/verified-bash-runtime.js.map +1 -0
  60. package/dist/index.d.ts +4 -2
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +4 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/types/evidence.d.ts +1 -1
  65. package/dist/types/evidence.d.ts.map +1 -1
  66. package/dist/types/evidence.js.map +1 -1
  67. package/dist/utils/frontmatter.d.ts.map +1 -1
  68. package/dist/utils/frontmatter.js +31 -5
  69. package/dist/utils/frontmatter.js.map +1 -1
  70. package/docs/environment-variables.md +4 -0
  71. package/docs/sdk.md +10 -4
  72. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  73. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  74. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  75. package/examples/extensions/gondolin/package-lock.json +2 -2
  76. package/examples/extensions/gondolin/package.json +1 -1
  77. package/examples/extensions/sandbox/package-lock.json +2 -2
  78. package/examples/extensions/sandbox/package.json +1 -1
  79. package/examples/extensions/with-deps/package-lock.json +2 -2
  80. package/examples/extensions/with-deps/package.json +1 -1
  81. package/npm-shrinkwrap.json +15 -15
  82. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../../src/core/tools/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC,CAAC;IACxG,QAAQ,EAAE,IAAI,CAAC,QAAQ,CACtB,IAAI,CAAC,KAAK,CACT;QACC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACpB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAC1B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;KACpB,EACD;QACC,WAAW,EAAE,yEAAyE;KACtF,CACD,CACD;IACD,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC,CAAC;CACpG,CAAC,CAAC;AAmBH,M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AAI,GACT,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;gBAC1C,CAAC,CAAC,iBAAiB;gBACnB,CAAC,CAAC;oBACA,GAAG,MAAM,CAAC,GAAG,CACZ,CAAC,CAAC,EAAE,EAAE,CACL,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,QAAQ,GAAG,CAC3F;oBACD,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACjG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC;iBAC7D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;QAAA,CAChG;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAW,EAAuC;IACvF,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,GAAG,CAAC,CAAC,CAAC;AAAA,CAChE","sourcesContent":["/**\n * Compiler-backed diagnostics tool (LSP-class value via project-native checkers).\n *\n * Routes per language to the checker the project already uses and normalizes\n * output to `SEVERITY path:line:col message`. Fail-soft by construction: a\n * missing checker, missing project marker, or checker crash reports `skipped`\n * for that language instead of throwing. Results are TTL-cached (5 s) since\n * project-wide checks are expensive.\n *\n * | language | checker (first found) | scope |\n * |------------|------------------------------------------|-------------------|\n * | typescript | `tsc --noEmit -p <nearest tsconfig>` | project |\n * | python | `pyright --outputjson` / `ruff check` | file or project |\n * | go | `go vet ./...` | module |\n * | rust | `cargo check --message-format short` | workspace |\n */\nimport { spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AgentTool } from \"omk-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst diagnosticsSchema = Type.Object({\n\tpath: Type.Optional(Type.String({ description: \"Restrict diagnostics to this file (relative to cwd)\" })),\n\tlanguage: Type.Optional(\n\t\tType.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"auto\"),\n\t\t\t\tType.Literal(\"typescript\"),\n\t\t\t\tType.Literal(\"python\"),\n\t\t\t\tType.Literal(\"go\"),\n\t\t\t\tType.Literal(\"rust\"),\n\t\t\t],\n\t\t\t{\n\t\t\t\tdescription: \"Language to check; auto detects from path extension and project markers\",\n\t\t\t},\n\t\t),\n\t),\n\ttimeout: Type.Optional(Type.Number({ description: \"Per-language timeout in seconds (default 90)\" })),\n});\n\nexport type DiagnosticsToolInput = Static<typeof diagnosticsSchema>;\n\nexport interface DiagnosticLine {\n\treadonly language: string;\n\treadonly severity: \"error\" | \"warning\" | \"info\";\n\treadonly path: string;\n\treadonly line: number;\n\treadonly column: number;\n\treadonly message: string;\n}\n\nexport interface DiagnosticsToolDetails {\n\treadonly diagnostics: readonly DiagnosticLine[];\n\treadonly skipped: readonly { language: string; reason: string }[];\n\treadonly counts: Record<string, number>;\n}\n\nconst CACHE_TTL_MS = 5_000;\nconst MAX_DIAGNOSTICS = 50;\nconst DEFAULT_TIMEOUT_MS = 90_000;\n\nconst cache = new Map<string, { at: number; result: LanguageResult }>();\n\ninterface LanguageResult {\n\treadonly lines: readonly DiagnosticLine[];\n\treadonly skippedReason?: string;\n}\n\nfunction commandExists(command: string): Promise<boolean> {\n\treturn new Promise((resolve) => {\n\t\tconst probe = spawn(\"sh\", [\"-c\", `command -v ${command}`], { stdio: \"ignore\" });\n\t\tprobe.on(\"close\", (code) => resolve(code === 0));\n\t\tprobe.on(\"error\", () => resolve(false));\n\t});\n}\n\nfunction run(\n\tcommand: string,\n\targs: readonly string[],\n\tcwd: string,\n\ttimeoutMs: number,\n): Promise<{ code: number | null; out: string }> {\n\treturn new Promise((resolve) => {\n\t\tconst child = spawn(command, args, { cwd, stdio: [\"ignore\", \"pipe\", \"pipe\"], windowsHide: true });\n\t\tlet out = \"\";\n\t\tconst timer = setTimeout(() => {\n\t\t\tchild.kill(\"SIGKILL\");\n\t\t}, timeoutMs);\n\t\tchild.stdout.on(\"data\", (d: Buffer) => {\n\t\t\tif (out.length < 4 * 1024 * 1024) out += d.toString(\"utf8\");\n\t\t});\n\t\tchild.stderr.on(\"data\", (d: Buffer) => {\n\t\t\tif (out.length < 4 * 1024 * 1024) out += d.toString(\"utf8\");\n\t\t});\n\t\tchild.on(\"close\", (code) => {\n\t\t\tclearTimeout(timer);\n\t\t\tresolve({ code, out });\n\t\t});\n\t\tchild.on(\"error\", () => {\n\t\t\tclearTimeout(timer);\n\t\t\tresolve({ code: null, out });\n\t\t});\n\t});\n}\n\nfunction nearestMarker(cwd: string, names: readonly string[]): string | undefined {\n\t// ponytail: project markers live at the session root in this harness; walk up\n\t// at most 4 levels for nested worktrees.\n\tlet dir = cwd;\n\tfor (let level = 0; level <= 4; level++) {\n\t\tfor (const name of names) {\n\t\t\tif (existsSync(join(dir, name))) return dir;\n\t\t}\n\t\tconst parent = join(dir, \"..\");\n\t\tif (parent === dir) return undefined;\n\t\tdir = parent;\n\t}\n\treturn undefined;\n}\n\nconst TS_ERROR = /^(?<path>.+?)\\((?<line>\\d+),(?<col>\\d+)\\): error TS\\d+: (?<msg>.+)$/;\n\nfunction parseTsc(out: string, language: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\tfor (const raw of out.split(\"\\n\")) {\n\t\tconst match = TS_ERROR.exec(raw.trim());\n\t\tif (match?.groups) {\n\t\t\tlines.push({\n\t\t\t\tlanguage,\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: match.groups.path,\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t});\n\t\t}\n\t}\n\treturn lines;\n}\n\nconst PYRIGHT_ISSUE = /^(?<path>.+?):(?<line>\\d+):(?<col>\\d+) - (?<sev>error|warning|information): (?<msg>.+)$/;\n\nfunction parsePyright(out: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\t// pyright --outputjson wraps issues in JSON; fall back to the text form when absent.\n\ttry {\n\t\tconst parsed = JSON.parse(out) as {\n\t\t\tgeneralDiagnostics?: {\n\t\t\t\tfile: string;\n\t\t\t\tseverity: string;\n\t\t\t\trange: { start: { line: number; character: number } };\n\t\t\t\tmessage: string;\n\t\t\t}[];\n\t\t};\n\t\tfor (const issue of parsed.generalDiagnostics ?? []) {\n\t\t\tlines.push({\n\t\t\t\tlanguage: \"python\",\n\t\t\t\tseverity: issue.severity === \"error\" ? \"error\" : issue.severity === \"warning\" ? \"warning\" : \"info\",\n\t\t\t\tpath: issue.file,\n\t\t\t\tline: issue.range.start.line + 1,\n\t\t\t\tcolumn: issue.range.start.character + 1,\n\t\t\t\tmessage: issue.message,\n\t\t\t});\n\t\t}\n\t\treturn lines;\n\t} catch {\n\t\tfor (const raw of out.split(\"\\n\")) {\n\t\t\tconst match = PYRIGHT_ISSUE.exec(raw.trim());\n\t\t\tif (match?.groups) {\n\t\t\t\tlines.push({\n\t\t\t\t\tlanguage: \"python\",\n\t\t\t\t\tseverity: match.groups.sev === \"error\" ? \"error\" : match.groups.sev === \"warning\" ? \"warning\" : \"info\",\n\t\t\t\t\tpath: match.groups.path,\n\t\t\t\t\tline: Number(match.groups.line),\n\t\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n}\n\nconst RUFF_ISSUE = /^(?<path>.+?):(?<line>\\d+):(?<col>\\d+): (?<msg>.+)$/;\n\nfunction parseRuff(out: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\tfor (const raw of out.split(\"\\n\")) {\n\t\tconst match = RUFF_ISSUE.exec(raw.trim());\n\t\tif (match?.groups) {\n\t\t\tlines.push({\n\t\t\t\tlanguage: \"python\",\n\t\t\t\tseverity: \"warning\",\n\t\t\t\tpath: match.groups.path,\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t});\n\t\t}\n\t}\n\treturn lines;\n}\n\nconst GO_VET = /^(?:#\\s+\\S+\\s+)?(?<path>.+?\\.go):(?<line>\\d+):(?<col>\\d+): (?<msg>.+)$/;\n\nfunction parseGoVet(out: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\tfor (const raw of out.split(\"\\n\")) {\n\t\tconst match = GO_VET.exec(raw.trim());\n\t\tif (match?.groups) {\n\t\t\tlines.push({\n\t\t\t\tlanguage: \"go\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: match.groups.path,\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t});\n\t\t}\n\t}\n\treturn lines;\n}\n\nconst CARGO_SHORT = /^(?<path>.+?):(?<line>\\d+):(?<col>\\d+): (?<msg>.+)$/;\n\nfunction parseCargo(out: string): DiagnosticLine[] {\n\tconst lines: DiagnosticLine[] = [];\n\tfor (const raw of out.split(\"\\n\")) {\n\t\tconst match = CARGO_SHORT.exec(raw.trim());\n\t\tif (match?.groups) {\n\t\t\tconst sev = match.groups.msg.startsWith(\"warning\") ? \"warning\" : \"error\";\n\t\t\tlines.push({\n\t\t\t\tlanguage: \"rust\",\n\t\t\t\tseverity: sev,\n\t\t\t\tpath: match.groups.path,\n\t\t\t\tline: Number(match.groups.line),\n\t\t\t\tcolumn: Number(match.groups.col),\n\t\t\t\tmessage: match.groups.msg.trim(),\n\t\t\t});\n\t\t}\n\t}\n\treturn lines;\n}\n\nasync function checkTypeScript(cwd: string, path: string | undefined, timeoutMs: number): Promise<LanguageResult> {\n\tconst root = nearestMarker(cwd, [\"tsconfig.json\", \"tsconfig.build.json\"]);\n\tif (!root) return { lines: [], skippedReason: \"no tsconfig found\" };\n\tconst tsc = join(cwd, \"node_modules\", \".bin\", \"tsc\");\n\tconst localBin = existsSync(tsc) ? tsc : join(root, \"node_modules\", \".bin\", \"tsc\");\n\tconst bin = existsSync(localBin) ? localBin : \"tsc\";\n\tconst config = existsSync(join(root, \"tsconfig.json\")) ? \"tsconfig.json\" : \"tsconfig.build.json\";\n\tconst { code, out } = await run(bin, [\"--noEmit\", \"-p\", config, \"--pretty\", \"false\"], root, timeoutMs);\n\tif (code === null) return { lines: [], skippedReason: \"tsc spawn failed\" };\n\treturn { lines: parseTsc(out, \"typescript\").filter((d) => !path || d.path.includes(path)) };\n}\n\nasync function checkPython(cwd: string, path: string | undefined, timeoutMs: number): Promise<LanguageResult> {\n\tconst target = path ?? \".\";\n\tif (await commandExists(\"pyright\")) {\n\t\tconst { code, out } = await run(\"pyright\", [\"--outputjson\", target], cwd, timeoutMs);\n\t\tif (code === null) return { lines: [], skippedReason: \"pyright spawn failed\" };\n\t\treturn { lines: parsePyright(out) };\n\t}\n\tif (await commandExists(\"ruff\")) {\n\t\tconst { code, out } = await run(\"ruff\", [\"check\", \"--no-cache\", target], cwd, timeoutMs);\n\t\tif (code === null) return { lines: [], skippedReason: \"ruff spawn failed\" };\n\t\treturn { lines: parseRuff(out) };\n\t}\n\treturn { lines: [], skippedReason: \"pyright/ruff not installed\" };\n}\n\nasync function checkGo(cwd: string, path: string | undefined, timeoutMs: number): Promise<LanguageResult> {\n\tconst root = nearestMarker(cwd, [\"go.mod\"]);\n\tif (!root) return { lines: [], skippedReason: \"no go.mod found\" };\n\tif (!(await commandExists(\"go\"))) return { lines: [], skippedReason: \"go not installed\" };\n\tconst { code, out } = await run(\"go\", [\"vet\", \"./...\"], root, timeoutMs);\n\tif (code === null) return { lines: [], skippedReason: \"go vet spawn failed\" };\n\treturn { lines: parseGoVet(out).filter((d) => !path || d.path.includes(path)) };\n}\n\nasync function checkRust(cwd: string, path: string | undefined, timeoutMs: number): Promise<LanguageResult> {\n\tconst root = nearestMarker(cwd, [\"Cargo.toml\"]);\n\tif (!root) return { lines: [], skippedReason: \"no Cargo.toml found\" };\n\tif (!(await commandExists(\"cargo\"))) return { lines: [], skippedReason: \"cargo not installed\" };\n\tconst { code, out } = await run(\"cargo\", [\"check\", \"--quiet\", \"--message-format\", \"short\"], root, timeoutMs);\n\tif (code === null) return { lines: [], skippedReason: \"cargo spawn failed\" };\n\treturn { lines: parseCargo(out).filter((d) => !path || d.path.includes(path)) };\n}\n\nconst CHECKERS = {\n\ttypescript: checkTypeScript,\n\tpython: checkPython,\n\tgo: checkGo,\n\trust: checkRust,\n} as const;\n\ntype Language = keyof typeof CHECKERS;\n\nfunction detectLanguages(cwd: string, path: string | undefined): Language[] {\n\tif (path) {\n\t\tif (/\\.tsx?$/.test(path)) return [\"typescript\"];\n\t\tif (/\\.py$/.test(path)) return [\"python\"];\n\t\tif (/\\.go$/.test(path)) return [\"go\"];\n\t\tif (/\\.rs$/.test(path)) return [\"rust\"];\n\t}\n\tconst detected: Language[] = [];\n\tif (nearestMarker(cwd, [\"tsconfig.json\", \"tsconfig.build.json\"])) detected.push(\"typescript\");\n\tif (nearestMarker(cwd, [\"pyproject.toml\", \"setup.py\", \"setup.cfg\", \"requirements.txt\"])) detected.push(\"python\");\n\tif (nearestMarker(cwd, [\"go.mod\"])) detected.push(\"go\");\n\tif (nearestMarker(cwd, [\"Cargo.toml\"])) detected.push(\"rust\");\n\treturn detected.length > 0 ? detected : [\"typescript\", \"python\", \"go\", \"rust\"];\n}\n\nasync function checkLanguage(\n\tlanguage: Language,\n\tcwd: string,\n\tpath: string | undefined,\n\ttimeoutMs: number,\n): Promise<LanguageResult> {\n\tconst key = `${language}${cwd}${path ?? \"\"}`;\n\tconst cached = cache.get(key);\n\tif (cached && Date.now() - cached.at < CACHE_TTL_MS) return cached.result;\n\tconst result = await CHECKERS[language](cwd, path, timeoutMs);\n\tif (cache.size >= 16) {\n\t\tconst oldest = cache.keys().next().value;\n\t\tif (oldest !== undefined) cache.delete(oldest);\n\t}\n\tcache.set(key, { at: Date.now(), result });\n\treturn result;\n}\n\nexport function createDiagnosticsToolDefinition(\n\tcwd: string,\n): ToolDefinition<typeof diagnosticsSchema, DiagnosticsToolDetails> {\n\treturn {\n\t\tname: \"diagnostics\",\n\t\tlabel: \"diagnostics\",\n\t\tdescription:\n\t\t\t\"Run the project's own type/lint checkers (tsc, pyright/ruff, go vet, cargo check) and return normalized diagnostics. Missing checkers or missing project markers are reported as skipped, never as tool errors.\",\n\t\tpromptSnippet: \"Get compiler/lint diagnostics for the workspace or a file\",\n\t\tparameters: diagnosticsSchema,\n\t\tasync execute(_toolCallId, { path, language, timeout }: DiagnosticsToolInput) {\n\t\t\tconst timeoutMs = timeout !== undefined && timeout > 0 ? timeout * 1000 : DEFAULT_TIMEOUT_MS;\n\t\t\tconst languages = language && language !== \"auto\" ? [language] : detectLanguages(cwd, path);\n\t\t\tconst settled = await Promise.all(languages.map((lang) => checkLanguage(lang, cwd, path, timeoutMs)));\n\t\t\tconst diagnostics: DiagnosticLine[] = [];\n\t\t\tconst skipped: { language: string; reason: string }[] = [];\n\t\t\tfor (let index = 0; index < languages.length; index++) {\n\t\t\t\tconst result = settled[index];\n\t\t\t\tif (result.skippedReason) skipped.push({ language: languages[index], reason: result.skippedReason });\n\t\t\t\tdiagnostics.push(...result.lines);\n\t\t\t}\n\t\t\tconst capped = diagnostics.slice(0, MAX_DIAGNOSTICS);\n\t\t\tconst counts: Record<string, number> = {};\n\t\t\tfor (const d of diagnostics) counts[d.language] = (counts[d.language] ?? 0) + 1;\n\t\t\tconst text =\n\t\t\t\tcapped.length === 0 && skipped.length === 0\n\t\t\t\t\t? \"No diagnostics.\"\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...capped.map(\n\t\t\t\t\t\t\t\t(d) =>\n\t\t\t\t\t\t\t\t\t`${d.severity.toUpperCase()} ${d.path}:${d.line}:${d.column} ${d.message} (${d.language})`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t...(diagnostics.length > capped.length ? [`... ${diagnostics.length - capped.length} more`] : []),\n\t\t\t\t\t\t\t...skipped.map((s) => `${s.language}: skipped (${s.reason})`),\n\t\t\t\t\t\t].join(\"\\n\");\n\t\t\treturn { content: [{ type: \"text\", text }], details: { diagnostics: capped, skipped, counts } };\n\t\t},\n\t};\n}\n\nexport function createDiagnosticsTool(cwd: string): AgentTool<typeof diagnosticsSchema> {\n\treturn wrapToolDefinition(createDiagnosticsToolDefinition(cwd));\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.ts";
2
+ export { createDiagnosticsTool, createDiagnosticsToolDefinition, type DiagnosticLine, type DiagnosticsToolDetails, type DiagnosticsToolInput, } from "./diagnostics.ts";
2
3
  export { createEditTool, createEditToolDefinition, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, } from "./edit.ts";
3
4
  export { withFileMutationQueue } from "./file-mutation-queue.ts";
4
5
  export { createFindTool, createFindToolDefinition, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, } from "./find.ts";
@@ -18,7 +19,7 @@ import { type ReadToolOptions } from "./read.ts";
18
19
  import { type WriteToolOptions } from "./write.ts";
19
20
  export type Tool = AgentTool<any>;
20
21
  export type ToolDef = ToolDefinition<any, any>;
21
- export type ToolName = "read" | "bash" | "edit" | "write" | "grep" | "find" | "ls";
22
+ export type ToolName = "read" | "bash" | "edit" | "write" | "grep" | "find" | "ls" | "diagnostics";
22
23
  export declare const allToolNames: Set<ToolName>;
23
24
  export interface ToolsOptions {
24
25
  read?: ReadToolOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;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zB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,EAAE,CAAC,EAAE,aAAa,CAAC;CACnB;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAmBrG;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAmBxF;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO1F;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO5F;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAUvG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAU1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"omk-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,qBAAqB,EACrB,+BAA+B,EAC/B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,K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,CAW1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateDiagnosticsTool,\n\tcreateDiagnosticsToolDefinition,\n\ttype DiagnosticLine,\n\ttype DiagnosticsToolDetails,\n\ttype DiagnosticsToolInput,\n} from \"./diagnostics.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"omk-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createDiagnosticsTool, createDiagnosticsToolDefinition } from \"./diagnostics.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\" | \"diagnostics\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"diagnostics\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"diagnostics\":\n\t\t\treturn createDiagnosticsToolDefinition(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"diagnostics\":\n\t\t\treturn createDiagnosticsTool(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tdiagnostics: createDiagnosticsToolDefinition(cwd),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tdiagnostics: createDiagnosticsTool(cwd),\n\t};\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export { createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.js";
2
+ export { createDiagnosticsTool, createDiagnosticsToolDefinition, } from "./diagnostics.js";
2
3
  export { createEditTool, createEditToolDefinition, } from "./edit.js";
3
4
  export { withFileMutationQueue } from "./file-mutation-queue.js";
4
5
  export { createFindTool, createFindToolDefinition, } from "./find.js";
@@ -8,13 +9,23 @@ export { createReadTool, createReadToolDefinition, } from "./read.js";
8
9
  export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, truncateLine, truncateTail, } from "./truncate.js";
9
10
  export { createWriteTool, createWriteToolDefinition, } from "./write.js";
10
11
  import { createBashTool, createBashToolDefinition } from "./bash.js";
12
+ import { createDiagnosticsTool, createDiagnosticsToolDefinition } from "./diagnostics.js";
11
13
  import { createEditTool, createEditToolDefinition } from "./edit.js";
12
14
  import { createFindTool, createFindToolDefinition } from "./find.js";
13
15
  import { createGrepTool, createGrepToolDefinition } from "./grep.js";
14
16
  import { createLsTool, createLsToolDefinition } from "./ls.js";
15
17
  import { createReadTool, createReadToolDefinition } from "./read.js";
16
18
  import { createWriteTool, createWriteToolDefinition } from "./write.js";
17
- export const allToolNames = new Set(["read", "bash", "edit", "write", "grep", "find", "ls"]);
19
+ export const allToolNames = new Set([
20
+ "read",
21
+ "bash",
22
+ "edit",
23
+ "write",
24
+ "grep",
25
+ "find",
26
+ "ls",
27
+ "diagnostics",
28
+ ]);
18
29
  export function createToolDefinition(toolName, cwd, options) {
19
30
  switch (toolName) {
20
31
  case "read":
@@ -31,6 +42,8 @@ export function createToolDefinition(toolName, cwd, options) {
31
42
  return createFindToolDefinition(cwd, options?.find);
32
43
  case "ls":
33
44
  return createLsToolDefinition(cwd, options?.ls);
45
+ case "diagnostics":
46
+ return createDiagnosticsToolDefinition(cwd);
34
47
  default:
35
48
  throw new Error(`Unknown tool name: ${toolName}`);
36
49
  }
@@ -51,6 +64,8 @@ export function createTool(toolName, cwd, options) {
51
64
  return createFindTool(cwd, options?.find);
52
65
  case "ls":
53
66
  return createLsTool(cwd, options?.ls);
67
+ case "diagnostics":
68
+ return createDiagnosticsTool(cwd);
54
69
  default:
55
70
  throw new Error(`Unknown tool name: ${toolName}`);
56
71
  }
@@ -80,6 +95,7 @@ export function createAllToolDefinitions(cwd, options) {
80
95
  grep: createGrepToolDefinition(cwd, options?.grep),
81
96
  find: createFindToolDefinition(cwd, options?.find),
82
97
  ls: createLsToolDefinition(cwd, options?.ls),
98
+ diagnostics: createDiagnosticsToolDefinition(cwd),
83
99
  };
84
100
  }
85
101
  export function createCodingTools(cwd, options) {
@@ -107,6 +123,7 @@ export function createAllTools(cwd, options) {
107
123
  grep: createGrepTool(cwd, options?.grep),
108
124
  find: createFindTool(cwd, options?.find),
109
125
  ls: createLsTool(cwd, options?.ls),
126
+ diagnostics: createDiagnosticsTool(cwd),
110
127
  };
111
128
  }
112
129
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,GAKtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,eAAe,EACf,yBAAyB,GAIzB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAwB,cAAc,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAwB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,wBAAwB,EA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I,CAAC;QAClC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;KAC9B,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAsB,EAA0B;IAC3F,OAAO;QACN,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;KAClC,CAAC;AAAA,CACF","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"omk-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\";\nexport const allToolNames: Set<ToolName> = new Set([\"read\", \"bash\", \"edit\", \"write\", \"grep\", \"find\", \"ls\"]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAA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,UAAU,cAAc,CAAC,GAAW,EAAE,OAAsB,EAA0B;IAC3F,OAAO;QACN,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,WAAW,EAAE,qBAAqB,CAAC,GAAG,CAAC;KACvC,CAAC;AAAA,CACF","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateDiagnosticsTool,\n\tcreateDiagnosticsToolDefinition,\n\ttype DiagnosticLine,\n\ttype DiagnosticsToolDetails,\n\ttype DiagnosticsToolInput,\n} from \"./diagnostics.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"omk-agent-core\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createDiagnosticsTool, createDiagnosticsToolDefinition } from \"./diagnostics.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\" | \"diagnostics\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"diagnostics\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"diagnostics\":\n\t\t\treturn createDiagnosticsToolDefinition(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"diagnostics\":\n\t\t\treturn createDiagnosticsTool(cwd);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tdiagnostics: createDiagnosticsToolDefinition(cwd),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tdiagnostics: createDiagnosticsTool(cwd),\n\t};\n}\n"]}
@@ -16,6 +16,10 @@ export interface VerifiedBashExecutionRequest {
16
16
  readonly executor?: "bash-tool" | "ci-runner";
17
17
  readonly toolCallId?: string;
18
18
  readonly signal?: AbortSignal;
19
+ /** Optional process env forwarded to BashOperations.exec (session PI_*, spawnHook). */
20
+ readonly env?: NodeJS.ProcessEnv;
21
+ /** Optional live output fan-out; receipt capture still runs independently. */
22
+ readonly onData?: (data: Buffer) => void;
19
23
  }
20
24
  export type VerifiedLocalBashExecutionRequest = Omit<VerifiedBashExecutionRequest, "operations" | "shell"> & {
21
25
  readonly shellPath?: string;
@@ -26,11 +30,24 @@ export declare class VerifiedBashAdapterError extends Error {
26
30
  constructor(message: string);
27
31
  }
28
32
  /**
29
- * Bind an opt-in, caller-trusted BashOperations execution to a receipt.
33
+ * Bind a caller-trusted BashOperations execution to a receipt.
34
+ * Default session/CLI paths enable this adapter unless `OMK_VERIFIED_BASH=0`.
30
35
  * BashOperations exposes a combined output stream, so the policy records the
31
36
  * redacted bounded stream as stdout and leaves stderr empty by construction.
32
37
  */
33
38
  export declare function executeVerifiedBash(request: VerifiedBashExecutionRequest): Promise<VerifiedEvidenceExecutionResult>;
34
39
  /** Bind OMK's first-party local shell backend to the verified bash adapter. */
35
40
  export declare function executeVerifiedLocalBash(request: VerifiedLocalBashExecutionRequest): Promise<VerifiedEvidenceExecutionResult>;
41
+ export interface VerifiedBashOperationsBinding {
42
+ readonly evidenceExecutor: VerifiedEvidenceExecutor;
43
+ readonly goalId: string;
44
+ readonly laneId?: string;
45
+ readonly shell: string;
46
+ readonly workspaceScope?: WorkspaceScope;
47
+ }
48
+ /**
49
+ * Wrap BashOperations so each exec is receipt-bound. Used by AgentSession to
50
+ * inject the default-on verified path into createBashTool without circular imports.
51
+ */
52
+ export declare function createVerifiedBashOperations(inner: BashOperations, binding: VerifiedBashOperationsBinding): BashOperations;
36
53
  //# sourceMappingURL=verified-bash-adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verified-bash-adapter.d.ts","sourceRoot":"","sources":["../../src/core/verified-bash-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,+BAA+B,EAC/B,wBAAwB,EACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAA6B,MAAM,iBAAiB,CAAC;AAE5G,eAAO,MAAM,iCAAiC,yEACmC,CAAC;AAIlF,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,gBAAgB,EAAE,wBAAwB,CAAC;IACpD,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,MAAM,iCAAiC,GAAG,IAAI,CAAC,4BAA4B,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG;IAC5G,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,oBAAoB,CAAC;CAC9C,CAAC;AAEF,qBAAa,wBAAyB,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,wBAAkC;IAE/C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,4BAA4B,GACnC,OAAO,CAAC,+BAA+B,CAAC,CAgE1C;AAED,+EAA+E;AAC/E,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,iCAAiC,GACxC,OAAO,CAAC,+BAA+B,CAAC,CAS1C","sourcesContent":["import { MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES } from \"../guardrails/evidence-receipt.ts\";\nimport type {\n\tVerifiedEvidenceExecutionOutcome,\n\tVerifiedEvidenceExecutionResult,\n\tVerifiedEvidenceExecutor,\n} from \"../guardrails/verified-executor.ts\";\nimport type { WorkspaceScope } from \"../types/evidence.ts\";\nimport { getShellConfig } from \"../utils/shell.ts\";\nimport { redactSensitiveText } from \"./redaction.ts\";\nimport { type BashOperations, type BashSandboxPreflight, createLocalBashOperations } from \"./tools/bash.ts\";\n\nexport const VERIFIED_BASH_REDACTION_POLICY_ID =\n\t\"omk-bash-combined-v1+omk-sensitive-text-v1+capture-tail-128k+tail-64k\" as const;\n\nconst MAX_CAPTURE_BYTES = MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES * 2;\n\nexport interface VerifiedBashExecutionRequest {\n\treadonly evidenceExecutor: VerifiedEvidenceExecutor;\n\treadonly operations: BashOperations;\n\treadonly goalId: string;\n\treadonly laneId?: string;\n\treadonly claim: string;\n\treadonly shell: string;\n\treadonly script: string;\n\treadonly cwd: string;\n\treadonly timeoutMs: number | null;\n\treadonly workspaceScope: WorkspaceScope;\n\treadonly executor?: \"bash-tool\" | \"ci-runner\";\n\treadonly toolCallId?: string;\n\treadonly signal?: AbortSignal;\n}\n\nexport type VerifiedLocalBashExecutionRequest = Omit<VerifiedBashExecutionRequest, \"operations\" | \"shell\"> & {\n\treadonly shellPath?: string;\n\treadonly sandboxPolicy?: BashSandboxPreflight;\n};\n\nexport class VerifiedBashAdapterError extends Error {\n\treadonly code = \"INVALID_RUNNER_EXIT\" as const;\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"VerifiedBashAdapterError\";\n\t}\n}\n\n/**\n * Bind an opt-in, caller-trusted BashOperations execution to a receipt.\n * BashOperations exposes a combined output stream, so the policy records the\n * redacted bounded stream as stdout and leaves stderr empty by construction.\n */\nexport async function executeVerifiedBash(\n\trequest: VerifiedBashExecutionRequest,\n): Promise<VerifiedEvidenceExecutionResult> {\n\tlet combined = Buffer.alloc(0);\n\n\tconst capture = (data: Buffer): void => {\n\t\t// ponytail: bounded concat is simpler than a chunk deque; split if profiling shows pressure.\n\t\tconst appended = Buffer.concat([combined, data]);\n\t\tcombined = appended.byteLength > MAX_CAPTURE_BYTES ? appended.subarray(-MAX_CAPTURE_BYTES) : appended;\n\t};\n\n\tconst alreadyRedactedOutput = () => {\n\t\tconst redacted = Buffer.from(redactSensitiveText(combined.toString(\"utf8\")));\n\t\tconst bounded =\n\t\t\tredacted.byteLength > MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES\n\t\t\t\t? redacted.subarray(-MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES)\n\t\t\t\t: redacted;\n\t\treturn {\n\t\t\tredactionPolicyId: VERIFIED_BASH_REDACTION_POLICY_ID,\n\t\t\tstdout: bounded,\n\t\t\tstderr: Buffer.alloc(0),\n\t\t};\n\t};\n\n\treturn request.evidenceExecutor.execute({\n\t\tgoalId: request.goalId,\n\t\t...(request.laneId !== undefined ? { laneId: request.laneId } : {}),\n\t\tclaim: request.claim,\n\t\tcommand: { kind: \"shell\", shell: request.shell, script: request.script },\n\t\tcwd: request.cwd,\n\t\ttimeoutMs: request.timeoutMs,\n\t\tworkspaceScope: request.workspaceScope,\n\t\texecutor: request.executor ?? \"bash-tool\",\n\t\t...(request.toolCallId !== undefined ? { toolCallId: request.toolCallId } : {}),\n\t\texecute: async (): Promise<VerifiedEvidenceExecutionOutcome> => {\n\t\t\tif (request.signal?.aborted) {\n\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await request.operations.exec(request.script, request.cwd, {\n\t\t\t\t\tonData: capture,\n\t\t\t\t\t...(request.signal !== undefined ? { signal: request.signal } : {}),\n\t\t\t\t\t...(request.timeoutMs !== null ? { timeout: request.timeoutMs / 1000 } : {}),\n\t\t\t\t});\n\t\t\t\tif (request.signal?.aborted) {\n\t\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tif (result.exitCode === null || !Number.isSafeInteger(result.exitCode)) {\n\t\t\t\t\tthrow new VerifiedBashAdapterError(\n\t\t\t\t\t\t\"bash runner returned an invalid exit code without an abort or timeout signal\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn result.exitCode === 0\n\t\t\t\t\t? { status: \"passed\", exitCode: 0, alreadyRedactedOutput: alreadyRedactedOutput() }\n\t\t\t\t\t: { status: \"failed\", exitCode: result.exitCode, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t} catch (error) {\n\t\t\t\tif (request.signal?.aborted || (error instanceof Error && error.message === \"aborted\")) {\n\t\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tif (error instanceof Error && error.message.startsWith(\"timeout:\")) {\n\t\t\t\t\treturn { status: \"timeout\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t});\n}\n\n/** Bind OMK's first-party local shell backend to the verified bash adapter. */\nexport async function executeVerifiedLocalBash(\n\trequest: VerifiedLocalBashExecutionRequest,\n): Promise<VerifiedEvidenceExecutionResult> {\n\tconst { shellPath, sandboxPolicy, ...executionRequest } = request;\n\tconst { shell } = getShellConfig(shellPath);\n\tconst resolvedShellPath = shell === \"sh\" && shellPath === undefined ? undefined : shell;\n\tconst operations = createLocalBashOperations({\n\t\t...(resolvedShellPath !== undefined ? { shellPath: resolvedShellPath } : {}),\n\t\t...(sandboxPolicy !== undefined ? { sandboxPolicy } : {}),\n\t});\n\treturn executeVerifiedBash({ ...executionRequest, operations, shell });\n}\n"]}
1
+ {"version":3,"file":"verified-bash-adapter.d.ts","sourceRoot":"","sources":["../../src/core/verified-bash-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,+BAA+B,EAC/B,wBAAwB,EACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAA6B,MAAM,iBAAiB,CAAC;AAE5G,eAAO,MAAM,iCAAiC,yEACmC,CAAC;AAIlF,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,gBAAgB,EAAE,wBAAwB,CAAC;IACpD,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC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wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,6BAA6B,GACpC,cAAc,CA4BhB","sourcesContent":["import { MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES } from \"../guardrails/evidence-receipt.ts\";\nimport type {\n\tVerifiedEvidenceExecutionOutcome,\n\tVerifiedEvidenceExecutionResult,\n\tVerifiedEvidenceExecutor,\n} from \"../guardrails/verified-executor.ts\";\nimport type { WorkspaceScope } from \"../types/evidence.ts\";\nimport { getShellConfig } from \"../utils/shell.ts\";\nimport { redactSensitiveText } from \"./redaction.ts\";\nimport { type BashOperations, type BashSandboxPreflight, createLocalBashOperations } from \"./tools/bash.ts\";\n\nexport const VERIFIED_BASH_REDACTION_POLICY_ID =\n\t\"omk-bash-combined-v1+omk-sensitive-text-v1+capture-tail-128k+tail-64k\" as const;\n\nconst MAX_CAPTURE_BYTES = MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES * 2;\n\nexport interface VerifiedBashExecutionRequest {\n\treadonly evidenceExecutor: VerifiedEvidenceExecutor;\n\treadonly operations: BashOperations;\n\treadonly goalId: string;\n\treadonly laneId?: string;\n\treadonly claim: string;\n\treadonly shell: string;\n\treadonly script: string;\n\treadonly cwd: string;\n\treadonly timeoutMs: number | null;\n\treadonly workspaceScope: WorkspaceScope;\n\treadonly executor?: \"bash-tool\" | \"ci-runner\";\n\treadonly toolCallId?: string;\n\treadonly signal?: AbortSignal;\n\t/** Optional process env forwarded to BashOperations.exec (session PI_*, spawnHook). */\n\treadonly env?: NodeJS.ProcessEnv;\n\t/** Optional live output fan-out; receipt capture still runs independently. */\n\treadonly onData?: (data: Buffer) => void;\n}\n\nexport type VerifiedLocalBashExecutionRequest = Omit<VerifiedBashExecutionRequest, \"operations\" | \"shell\"> & {\n\treadonly shellPath?: string;\n\treadonly sandboxPolicy?: BashSandboxPreflight;\n};\n\nexport class VerifiedBashAdapterError extends Error {\n\treadonly code = \"INVALID_RUNNER_EXIT\" as const;\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"VerifiedBashAdapterError\";\n\t}\n}\n\n/**\n * Bind a caller-trusted BashOperations execution to a receipt.\n * Default session/CLI paths enable this adapter unless `OMK_VERIFIED_BASH=0`.\n * BashOperations exposes a combined output stream, so the policy records the\n * redacted bounded stream as stdout and leaves stderr empty by construction.\n */\nexport async function executeVerifiedBash(\n\trequest: VerifiedBashExecutionRequest,\n): Promise<VerifiedEvidenceExecutionResult> {\n\tlet combined = Buffer.alloc(0);\n\n\tconst capture = (data: Buffer): void => {\n\t\t// ponytail: bounded concat is simpler than a chunk deque; split if profiling shows pressure.\n\t\tconst appended = Buffer.concat([combined, data]);\n\t\tcombined = appended.byteLength > MAX_CAPTURE_BYTES ? appended.subarray(-MAX_CAPTURE_BYTES) : appended;\n\t\trequest.onData?.(data);\n\t};\n\n\tconst alreadyRedactedOutput = () => {\n\t\tconst redacted = Buffer.from(redactSensitiveText(combined.toString(\"utf8\")));\n\t\tconst bounded =\n\t\t\tredacted.byteLength > MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES\n\t\t\t\t? redacted.subarray(-MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES)\n\t\t\t\t: redacted;\n\t\treturn {\n\t\t\tredactionPolicyId: VERIFIED_BASH_REDACTION_POLICY_ID,\n\t\t\tstdout: bounded,\n\t\t\tstderr: Buffer.alloc(0),\n\t\t};\n\t};\n\n\treturn request.evidenceExecutor.execute({\n\t\tgoalId: request.goalId,\n\t\t...(request.laneId !== undefined ? { laneId: request.laneId } : {}),\n\t\tclaim: request.claim,\n\t\tcommand: { kind: \"shell\", shell: request.shell, script: request.script },\n\t\tcwd: request.cwd,\n\t\ttimeoutMs: request.timeoutMs,\n\t\tworkspaceScope: request.workspaceScope,\n\t\texecutor: request.executor ?? \"bash-tool\",\n\t\t...(request.toolCallId !== undefined ? { toolCallId: request.toolCallId } : {}),\n\t\texecute: async (): Promise<VerifiedEvidenceExecutionOutcome> => {\n\t\t\tif (request.signal?.aborted) {\n\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await request.operations.exec(request.script, request.cwd, {\n\t\t\t\t\tonData: capture,\n\t\t\t\t\t...(request.signal !== undefined ? { signal: request.signal } : {}),\n\t\t\t\t\t...(request.timeoutMs !== null ? { timeout: request.timeoutMs / 1000 } : {}),\n\t\t\t\t\t...(request.env !== undefined ? { env: request.env } : {}),\n\t\t\t\t});\n\t\t\t\tif (request.signal?.aborted) {\n\t\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tif (result.exitCode === null || !Number.isSafeInteger(result.exitCode)) {\n\t\t\t\t\tthrow new VerifiedBashAdapterError(\n\t\t\t\t\t\t\"bash runner returned an invalid exit code without an abort or timeout signal\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn result.exitCode === 0\n\t\t\t\t\t? { status: \"passed\", exitCode: 0, alreadyRedactedOutput: alreadyRedactedOutput() }\n\t\t\t\t\t: { status: \"failed\", exitCode: result.exitCode, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t} catch (error) {\n\t\t\t\tif (request.signal?.aborted || (error instanceof Error && error.message === \"aborted\")) {\n\t\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tif (error instanceof Error && error.message.startsWith(\"timeout:\")) {\n\t\t\t\t\treturn { status: \"timeout\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t});\n}\n\n/** Bind OMK's first-party local shell backend to the verified bash adapter. */\nexport async function executeVerifiedLocalBash(\n\trequest: VerifiedLocalBashExecutionRequest,\n): Promise<VerifiedEvidenceExecutionResult> {\n\tconst { shellPath, sandboxPolicy, ...executionRequest } = request;\n\tconst { shell } = getShellConfig(shellPath);\n\tconst resolvedShellPath = shell === \"sh\" && shellPath === undefined ? undefined : shell;\n\tconst operations = createLocalBashOperations({\n\t\t...(resolvedShellPath !== undefined ? { shellPath: resolvedShellPath } : {}),\n\t\t...(sandboxPolicy !== undefined ? { sandboxPolicy } : {}),\n\t});\n\treturn executeVerifiedBash({ ...executionRequest, operations, shell });\n}\n\nexport interface VerifiedBashOperationsBinding {\n\treadonly evidenceExecutor: VerifiedEvidenceExecutor;\n\treadonly goalId: string;\n\treadonly laneId?: string;\n\treadonly shell: string;\n\treadonly workspaceScope?: WorkspaceScope;\n}\n\n/**\n * Wrap BashOperations so each exec is receipt-bound. Used by AgentSession to\n * inject the default-on verified path into createBashTool without circular imports.\n */\nexport function createVerifiedBashOperations(\n\tinner: BashOperations,\n\tbinding: VerifiedBashOperationsBinding,\n): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, options) => {\n\t\t\tconst claim = command.length > 200 ? `bash: ${command.slice(0, 197)}...` : `bash: ${command}`;\n\t\t\tconst execution = await executeVerifiedBash({\n\t\t\t\tevidenceExecutor: binding.evidenceExecutor,\n\t\t\t\toperations: inner,\n\t\t\t\tgoalId: binding.goalId,\n\t\t\t\t...(binding.laneId !== undefined ? { laneId: binding.laneId } : {}),\n\t\t\t\tclaim,\n\t\t\t\tshell: binding.shell,\n\t\t\t\tscript: command,\n\t\t\t\tcwd,\n\t\t\t\ttimeoutMs: options.timeout !== undefined && options.timeout > 0 ? options.timeout * 1000 : null,\n\t\t\t\tworkspaceScope: binding.workspaceScope ?? { root: cwd, artifactPaths: [] },\n\t\t\t\texecutor: \"bash-tool\",\n\t\t\t\t...(options.signal !== undefined ? { signal: options.signal } : {}),\n\t\t\t\t...(options.env !== undefined ? { env: options.env } : {}),\n\t\t\t\tonData: options.onData,\n\t\t\t});\n\t\t\tconst status = execution.receipt.core.status;\n\t\t\tif (status === \"aborted\") throw new Error(\"aborted\");\n\t\t\tif (status === \"timeout\") {\n\t\t\t\tthrow new Error(`timeout:${options.timeout ?? 0}`);\n\t\t\t}\n\t\t\treturn { exitCode: execution.receipt.core.exitCode };\n\t\t},\n\t};\n}\n"]}
@@ -12,7 +12,8 @@ export class VerifiedBashAdapterError extends Error {
12
12
  }
13
13
  }
14
14
  /**
15
- * Bind an opt-in, caller-trusted BashOperations execution to a receipt.
15
+ * Bind a caller-trusted BashOperations execution to a receipt.
16
+ * Default session/CLI paths enable this adapter unless `OMK_VERIFIED_BASH=0`.
16
17
  * BashOperations exposes a combined output stream, so the policy records the
17
18
  * redacted bounded stream as stdout and leaves stderr empty by construction.
18
19
  */
@@ -22,6 +23,7 @@ export async function executeVerifiedBash(request) {
22
23
  // ponytail: bounded concat is simpler than a chunk deque; split if profiling shows pressure.
23
24
  const appended = Buffer.concat([combined, data]);
24
25
  combined = appended.byteLength > MAX_CAPTURE_BYTES ? appended.subarray(-MAX_CAPTURE_BYTES) : appended;
26
+ request.onData?.(data);
25
27
  };
26
28
  const alreadyRedactedOutput = () => {
27
29
  const redacted = Buffer.from(redactSensitiveText(combined.toString("utf8")));
@@ -53,6 +55,7 @@ export async function executeVerifiedBash(request) {
53
55
  onData: capture,
54
56
  ...(request.signal !== undefined ? { signal: request.signal } : {}),
55
57
  ...(request.timeoutMs !== null ? { timeout: request.timeoutMs / 1000 } : {}),
58
+ ...(request.env !== undefined ? { env: request.env } : {}),
56
59
  });
57
60
  if (request.signal?.aborted) {
58
61
  return { status: "aborted", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };
@@ -87,4 +90,38 @@ export async function executeVerifiedLocalBash(request) {
87
90
  });
88
91
  return executeVerifiedBash({ ...executionRequest, operations, shell });
89
92
  }
93
+ /**
94
+ * Wrap BashOperations so each exec is receipt-bound. Used by AgentSession to
95
+ * inject the default-on verified path into createBashTool without circular imports.
96
+ */
97
+ export function createVerifiedBashOperations(inner, binding) {
98
+ return {
99
+ exec: async (command, cwd, options) => {
100
+ const claim = command.length > 200 ? `bash: ${command.slice(0, 197)}...` : `bash: ${command}`;
101
+ const execution = await executeVerifiedBash({
102
+ evidenceExecutor: binding.evidenceExecutor,
103
+ operations: inner,
104
+ goalId: binding.goalId,
105
+ ...(binding.laneId !== undefined ? { laneId: binding.laneId } : {}),
106
+ claim,
107
+ shell: binding.shell,
108
+ script: command,
109
+ cwd,
110
+ timeoutMs: options.timeout !== undefined && options.timeout > 0 ? options.timeout * 1000 : null,
111
+ workspaceScope: binding.workspaceScope ?? { root: cwd, artifactPaths: [] },
112
+ executor: "bash-tool",
113
+ ...(options.signal !== undefined ? { signal: options.signal } : {}),
114
+ ...(options.env !== undefined ? { env: options.env } : {}),
115
+ onData: options.onData,
116
+ });
117
+ const status = execution.receipt.core.status;
118
+ if (status === "aborted")
119
+ throw new Error("aborted");
120
+ if (status === "timeout") {
121
+ throw new Error(`timeout:${options.timeout ?? 0}`);
122
+ }
123
+ return { exitCode: execution.receipt.core.exitCode };
124
+ },
125
+ };
126
+ }
90
127
  //# sourceMappingURL=verified-bash-adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"verified-bash-adapter.js","sourceRoot":"","sources":["../../src/core/verified-bash-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,mCAAmC,CAAC;AAOtF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAkD,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5G,MAAM,CAAC,MAAM,iCAAiC,GAC7C,uEAAgF,CAAC;AAElF,MAAM,iBAAiB,GAAG,iCAAiC,GAAG,CAAC,CAAC;AAuBhE,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACzC,IAAI,GAAG,qBAA8B,CAAC;IAE/C,YAAY,OAAe,EAAE;QAC5B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,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AAG,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAClE,MAAM,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,iBAAiB,GAAG,KAAK,KAAK,IAAI,IAAI,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;IACxF,MAAM,UAAU,GAAG,yBAAyB,CAAC;QAC5C,GAAG,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;IACH,OAAO,mBAAmB,CAAC,EAAE,GAAG,gBAAgB,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AAAA,CACvE","sourcesContent":["import { MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES } from \"../guardrails/evidence-receipt.ts\";\nimport type {\n\tVerifiedEvidenceExecutionOutcome,\n\tVerifiedEvidenceExecutionResult,\n\tVerifiedEvidenceExecutor,\n} from \"../guardrails/verified-executor.ts\";\nimport type { WorkspaceScope } from \"../types/evidence.ts\";\nimport { getShellConfig } from \"../utils/shell.ts\";\nimport { redactSensitiveText } from \"./redaction.ts\";\nimport { type BashOperations, type BashSandboxPreflight, createLocalBashOperations } from \"./tools/bash.ts\";\n\nexport const VERIFIED_BASH_REDACTION_POLICY_ID =\n\t\"omk-bash-combined-v1+omk-sensitive-text-v1+capture-tail-128k+tail-64k\" as const;\n\nconst MAX_CAPTURE_BYTES = MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES * 2;\n\nexport interface VerifiedBashExecutionRequest {\n\treadonly evidenceExecutor: VerifiedEvidenceExecutor;\n\treadonly operations: BashOperations;\n\treadonly goalId: string;\n\treadonly laneId?: string;\n\treadonly claim: string;\n\treadonly shell: string;\n\treadonly script: string;\n\treadonly cwd: string;\n\treadonly timeoutMs: number | null;\n\treadonly workspaceScope: WorkspaceScope;\n\treadonly executor?: \"bash-tool\" | \"ci-runner\";\n\treadonly toolCallId?: string;\n\treadonly signal?: AbortSignal;\n}\n\nexport type VerifiedLocalBashExecutionRequest = Omit<VerifiedBashExecutionRequest, \"operations\" | \"shell\"> & {\n\treadonly shellPath?: string;\n\treadonly sandboxPolicy?: BashSandboxPreflight;\n};\n\nexport class VerifiedBashAdapterError extends Error {\n\treadonly code = \"INVALID_RUNNER_EXIT\" as const;\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"VerifiedBashAdapterError\";\n\t}\n}\n\n/**\n * Bind an opt-in, caller-trusted BashOperations execution to a receipt.\n * BashOperations exposes a combined output stream, so the policy records the\n * redacted bounded stream as stdout and leaves stderr empty by construction.\n */\nexport async function executeVerifiedBash(\n\trequest: VerifiedBashExecutionRequest,\n): Promise<VerifiedEvidenceExecutionResult> {\n\tlet combined = Buffer.alloc(0);\n\n\tconst capture = (data: Buffer): void => {\n\t\t// ponytail: bounded concat is simpler than a chunk deque; split if profiling shows pressure.\n\t\tconst appended = Buffer.concat([combined, data]);\n\t\tcombined = appended.byteLength > MAX_CAPTURE_BYTES ? appended.subarray(-MAX_CAPTURE_BYTES) : appended;\n\t};\n\n\tconst alreadyRedactedOutput = () => {\n\t\tconst redacted = Buffer.from(redactSensitiveText(combined.toString(\"utf8\")));\n\t\tconst bounded =\n\t\t\tredacted.byteLength > MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES\n\t\t\t\t? redacted.subarray(-MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES)\n\t\t\t\t: redacted;\n\t\treturn {\n\t\t\tredactionPolicyId: VERIFIED_BASH_REDACTION_POLICY_ID,\n\t\t\tstdout: bounded,\n\t\t\tstderr: Buffer.alloc(0),\n\t\t};\n\t};\n\n\treturn request.evidenceExecutor.execute({\n\t\tgoalId: request.goalId,\n\t\t...(request.laneId !== undefined ? { laneId: request.laneId } : {}),\n\t\tclaim: request.claim,\n\t\tcommand: { kind: \"shell\", shell: request.shell, script: request.script },\n\t\tcwd: request.cwd,\n\t\ttimeoutMs: request.timeoutMs,\n\t\tworkspaceScope: request.workspaceScope,\n\t\texecutor: request.executor ?? \"bash-tool\",\n\t\t...(request.toolCallId !== undefined ? { toolCallId: request.toolCallId } : {}),\n\t\texecute: async (): Promise<VerifiedEvidenceExecutionOutcome> => {\n\t\t\tif (request.signal?.aborted) {\n\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await request.operations.exec(request.script, request.cwd, {\n\t\t\t\t\tonData: capture,\n\t\t\t\t\t...(request.signal !== undefined ? { signal: request.signal } : {}),\n\t\t\t\t\t...(request.timeoutMs !== null ? { timeout: request.timeoutMs / 1000 } : {}),\n\t\t\t\t});\n\t\t\t\tif (request.signal?.aborted) {\n\t\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tif (result.exitCode === null || !Number.isSafeInteger(result.exitCode)) {\n\t\t\t\t\tthrow new VerifiedBashAdapterError(\n\t\t\t\t\t\t\"bash runner returned an invalid exit code without an abort or timeout signal\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn result.exitCode === 0\n\t\t\t\t\t? { status: \"passed\", exitCode: 0, alreadyRedactedOutput: alreadyRedactedOutput() }\n\t\t\t\t\t: { status: \"failed\", exitCode: result.exitCode, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t} catch (error) {\n\t\t\t\tif (request.signal?.aborted || (error instanceof Error && error.message === \"aborted\")) {\n\t\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tif (error instanceof Error && error.message.startsWith(\"timeout:\")) {\n\t\t\t\t\treturn { status: \"timeout\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t});\n}\n\n/** Bind OMK's first-party local shell backend to the verified bash adapter. */\nexport async function executeVerifiedLocalBash(\n\trequest: VerifiedLocalBashExecutionRequest,\n): Promise<VerifiedEvidenceExecutionResult> {\n\tconst { shellPath, sandboxPolicy, ...executionRequest } = request;\n\tconst { shell } = getShellConfig(shellPath);\n\tconst resolvedShellPath = shell === \"sh\" && shellPath === undefined ? undefined : shell;\n\tconst operations = createLocalBashOperations({\n\t\t...(resolvedShellPath !== undefined ? { shellPath: resolvedShellPath } : {}),\n\t\t...(sandboxPolicy !== undefined ? { sandboxPolicy } : {}),\n\t});\n\treturn executeVerifiedBash({ ...executionRequest, operations, shell });\n}\n"]}
1
+ {"version":3,"file":"verified-bash-adapter.js","sourceRoot":"","sources":["../../src/core/verified-bash-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,mCAAmC,CAAC;AAOtF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAkD,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5G,MAAM,CAAC,MAAM,iCAAiC,GAC7C,uEAAgF,CAAC;AAElF,MAAM,iBAAiB,GAAG,iCAAiC,GAAG,CAAC,CAAC;AA2BhE,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACzC,IAAI,GAAG,qBAA8B,CAAC;IAE/C,YAAY,OAAe,EAAE;QAC5B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IAAA,CACvC;CACD;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,OAAqC,EACM;IAC3C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EIPT_OUTPUT_BYTES } from \"../guardrails/evidence-receipt.ts\";\nimport type {\n\tVerifiedEvidenceExecutionOutcome,\n\tVerifiedEvidenceExecutionResult,\n\tVerifiedEvidenceExecutor,\n} from \"../guardrails/verified-executor.ts\";\nimport type { WorkspaceScope } from \"../types/evidence.ts\";\nimport { getShellConfig } from \"../utils/shell.ts\";\nimport { redactSensitiveText } from \"./redaction.ts\";\nimport { type BashOperations, type BashSandboxPreflight, createLocalBashOperations } from \"./tools/bash.ts\";\n\nexport const VERIFIED_BASH_REDACTION_POLICY_ID =\n\t\"omk-bash-combined-v1+omk-sensitive-text-v1+capture-tail-128k+tail-64k\" as const;\n\nconst MAX_CAPTURE_BYTES = MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES * 2;\n\nexport interface VerifiedBashExecutionRequest {\n\treadonly evidenceExecutor: VerifiedEvidenceExecutor;\n\treadonly operations: BashOperations;\n\treadonly goalId: string;\n\treadonly laneId?: string;\n\treadonly claim: string;\n\treadonly shell: string;\n\treadonly script: string;\n\treadonly cwd: string;\n\treadonly timeoutMs: number | null;\n\treadonly workspaceScope: WorkspaceScope;\n\treadonly executor?: \"bash-tool\" | \"ci-runner\";\n\treadonly toolCallId?: string;\n\treadonly signal?: AbortSignal;\n\t/** Optional process env forwarded to BashOperations.exec (session PI_*, spawnHook). */\n\treadonly env?: NodeJS.ProcessEnv;\n\t/** Optional live output fan-out; receipt capture still runs independently. */\n\treadonly onData?: (data: Buffer) => void;\n}\n\nexport type VerifiedLocalBashExecutionRequest = Omit<VerifiedBashExecutionRequest, \"operations\" | \"shell\"> & {\n\treadonly shellPath?: string;\n\treadonly sandboxPolicy?: BashSandboxPreflight;\n};\n\nexport class VerifiedBashAdapterError extends Error {\n\treadonly code = \"INVALID_RUNNER_EXIT\" as const;\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"VerifiedBashAdapterError\";\n\t}\n}\n\n/**\n * Bind a caller-trusted BashOperations execution to a receipt.\n * Default session/CLI paths enable this adapter unless `OMK_VERIFIED_BASH=0`.\n * BashOperations exposes a combined output stream, so the policy records the\n * redacted bounded stream as stdout and leaves stderr empty by construction.\n */\nexport async function executeVerifiedBash(\n\trequest: VerifiedBashExecutionRequest,\n): Promise<VerifiedEvidenceExecutionResult> {\n\tlet combined = Buffer.alloc(0);\n\n\tconst capture = (data: Buffer): void => {\n\t\t// ponytail: bounded concat is simpler than a chunk deque; split if profiling shows pressure.\n\t\tconst appended = Buffer.concat([combined, data]);\n\t\tcombined = appended.byteLength > MAX_CAPTURE_BYTES ? appended.subarray(-MAX_CAPTURE_BYTES) : appended;\n\t\trequest.onData?.(data);\n\t};\n\n\tconst alreadyRedactedOutput = () => {\n\t\tconst redacted = Buffer.from(redactSensitiveText(combined.toString(\"utf8\")));\n\t\tconst bounded =\n\t\t\tredacted.byteLength > MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES\n\t\t\t\t? redacted.subarray(-MAX_EVIDENCE_RECEIPT_OUTPUT_BYTES)\n\t\t\t\t: redacted;\n\t\treturn {\n\t\t\tredactionPolicyId: VERIFIED_BASH_REDACTION_POLICY_ID,\n\t\t\tstdout: bounded,\n\t\t\tstderr: Buffer.alloc(0),\n\t\t};\n\t};\n\n\treturn request.evidenceExecutor.execute({\n\t\tgoalId: request.goalId,\n\t\t...(request.laneId !== undefined ? { laneId: request.laneId } : {}),\n\t\tclaim: request.claim,\n\t\tcommand: { kind: \"shell\", shell: request.shell, script: request.script },\n\t\tcwd: request.cwd,\n\t\ttimeoutMs: request.timeoutMs,\n\t\tworkspaceScope: request.workspaceScope,\n\t\texecutor: request.executor ?? \"bash-tool\",\n\t\t...(request.toolCallId !== undefined ? { toolCallId: request.toolCallId } : {}),\n\t\texecute: async (): Promise<VerifiedEvidenceExecutionOutcome> => {\n\t\t\tif (request.signal?.aborted) {\n\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await request.operations.exec(request.script, request.cwd, {\n\t\t\t\t\tonData: capture,\n\t\t\t\t\t...(request.signal !== undefined ? { signal: request.signal } : {}),\n\t\t\t\t\t...(request.timeoutMs !== null ? { timeout: request.timeoutMs / 1000 } : {}),\n\t\t\t\t\t...(request.env !== undefined ? { env: request.env } : {}),\n\t\t\t\t});\n\t\t\t\tif (request.signal?.aborted) {\n\t\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tif (result.exitCode === null || !Number.isSafeInteger(result.exitCode)) {\n\t\t\t\t\tthrow new VerifiedBashAdapterError(\n\t\t\t\t\t\t\"bash runner returned an invalid exit code without an abort or timeout signal\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn result.exitCode === 0\n\t\t\t\t\t? { status: \"passed\", exitCode: 0, alreadyRedactedOutput: alreadyRedactedOutput() }\n\t\t\t\t\t: { status: \"failed\", exitCode: result.exitCode, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t} catch (error) {\n\t\t\t\tif (request.signal?.aborted || (error instanceof Error && error.message === \"aborted\")) {\n\t\t\t\t\treturn { status: \"aborted\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tif (error instanceof Error && error.message.startsWith(\"timeout:\")) {\n\t\t\t\t\treturn { status: \"timeout\", exitCode: null, alreadyRedactedOutput: alreadyRedactedOutput() };\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t});\n}\n\n/** Bind OMK's first-party local shell backend to the verified bash adapter. */\nexport async function executeVerifiedLocalBash(\n\trequest: VerifiedLocalBashExecutionRequest,\n): Promise<VerifiedEvidenceExecutionResult> {\n\tconst { shellPath, sandboxPolicy, ...executionRequest } = request;\n\tconst { shell } = getShellConfig(shellPath);\n\tconst resolvedShellPath = shell === \"sh\" && shellPath === undefined ? undefined : shell;\n\tconst operations = createLocalBashOperations({\n\t\t...(resolvedShellPath !== undefined ? { shellPath: resolvedShellPath } : {}),\n\t\t...(sandboxPolicy !== undefined ? { sandboxPolicy } : {}),\n\t});\n\treturn executeVerifiedBash({ ...executionRequest, operations, shell });\n}\n\nexport interface VerifiedBashOperationsBinding {\n\treadonly evidenceExecutor: VerifiedEvidenceExecutor;\n\treadonly goalId: string;\n\treadonly laneId?: string;\n\treadonly shell: string;\n\treadonly workspaceScope?: WorkspaceScope;\n}\n\n/**\n * Wrap BashOperations so each exec is receipt-bound. Used by AgentSession to\n * inject the default-on verified path into createBashTool without circular imports.\n */\nexport function createVerifiedBashOperations(\n\tinner: BashOperations,\n\tbinding: VerifiedBashOperationsBinding,\n): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, options) => {\n\t\t\tconst claim = command.length > 200 ? `bash: ${command.slice(0, 197)}...` : `bash: ${command}`;\n\t\t\tconst execution = await executeVerifiedBash({\n\t\t\t\tevidenceExecutor: binding.evidenceExecutor,\n\t\t\t\toperations: inner,\n\t\t\t\tgoalId: binding.goalId,\n\t\t\t\t...(binding.laneId !== undefined ? { laneId: binding.laneId } : {}),\n\t\t\t\tclaim,\n\t\t\t\tshell: binding.shell,\n\t\t\t\tscript: command,\n\t\t\t\tcwd,\n\t\t\t\ttimeoutMs: options.timeout !== undefined && options.timeout > 0 ? options.timeout * 1000 : null,\n\t\t\t\tworkspaceScope: binding.workspaceScope ?? { root: cwd, artifactPaths: [] },\n\t\t\t\texecutor: \"bash-tool\",\n\t\t\t\t...(options.signal !== undefined ? { signal: options.signal } : {}),\n\t\t\t\t...(options.env !== undefined ? { env: options.env } : {}),\n\t\t\t\tonData: options.onData,\n\t\t\t});\n\t\t\tconst status = execution.receipt.core.status;\n\t\t\tif (status === \"aborted\") throw new Error(\"aborted\");\n\t\t\tif (status === \"timeout\") {\n\t\t\t\tthrow new Error(`timeout:${options.timeout ?? 0}`);\n\t\t\t}\n\t\t\treturn { exitCode: execution.receipt.core.exitCode };\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { WorkspaceScope } from "../types/evidence.ts";
2
+ export declare function isVerifiedBashEnabled(env?: Record<string, string | undefined>): boolean;
3
+ /**
4
+ * Workspace scope for session bash receipts. Inside a git worktree the scope
5
+ * root is the toplevel and `artifactPaths` is the current dirty set (staged,
6
+ * modified, untracked; capped and sorted), which lets `captureWorkspaceFingerprint`
7
+ * bind HEAD plus a scope-limited dirty digest. Outside git, falls back to an
8
+ * empty artifact set under `cwd`. Never throws.
9
+ */
10
+ export declare function resolveSessionWorkspaceScope(cwd: string, options?: {
11
+ maxPaths?: number;
12
+ }): WorkspaceScope;
13
+ //# sourceMappingURL=verified-bash-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verified-bash-runtime.d.ts","sourceRoot":"","sources":["../../src/core/verified-bash-runtime.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wBAAgB,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAGvF;AAaD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,cAAc,CAUzG","sourcesContent":["/**\n * Default-on gate for the verified bash adapter (opt-out via OMK_VERIFIED_BASH=0).\n *\n * Mirrors ADR-OMP-009: the receipt-bound path is the default experience; the\n * exact legacy unverified path remains available as a byte-identical rollback.\n */\nimport { spawnSync } from \"node:child_process\";\nimport type { WorkspaceScope } from \"../types/evidence.ts\";\n\nexport function isVerifiedBashEnabled(env?: Record<string, string | undefined>): boolean {\n\tconst source: Record<string, string | undefined> = env ?? process.env;\n\treturn source.OMK_VERIFIED_BASH !== \"0\";\n}\n\n// ---------------------------------------------------------------------------\n// Git-aware session workspace scope (bounded, TTL-cached)\n// ---------------------------------------------------------------------------\n\nconst SCOPE_TTL_MS = 1_000;\nconst SCOPE_CACHE_MAX = 8;\nconst SCOPE_MAX_PATHS = 32;\nconst GIT_TIMEOUT_MS = 1_500;\n\nconst scopeCache = new Map<string, { at: number; scope: WorkspaceScope }>();\n\n/**\n * Workspace scope for session bash receipts. Inside a git worktree the scope\n * root is the toplevel and `artifactPaths` is the current dirty set (staged,\n * modified, untracked; capped and sorted), which lets `captureWorkspaceFingerprint`\n * bind HEAD plus a scope-limited dirty digest. Outside git, falls back to an\n * empty artifact set under `cwd`. Never throws.\n */\nexport function resolveSessionWorkspaceScope(cwd: string, options?: { maxPaths?: number }): WorkspaceScope {\n\tconst cached = scopeCache.get(cwd);\n\tif (cached && Date.now() - cached.at < SCOPE_TTL_MS) return cached.scope;\n\tconst scope = computeSessionWorkspaceScope(cwd, options?.maxPaths ?? SCOPE_MAX_PATHS);\n\tif (scopeCache.size >= SCOPE_CACHE_MAX) {\n\t\tconst oldest = scopeCache.keys().next().value;\n\t\tif (oldest !== undefined) scopeCache.delete(oldest);\n\t}\n\tscopeCache.set(cwd, { at: Date.now(), scope });\n\treturn scope;\n}\n\nfunction computeSessionWorkspaceScope(cwd: string, maxPaths: number): WorkspaceScope {\n\ttry {\n\t\tconst top = spawnSync(\"git\", [\"-C\", cwd, \"rev-parse\", \"--show-toplevel\"], {\n\t\t\tencoding: \"utf8\",\n\t\t\ttimeout: GIT_TIMEOUT_MS,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t\t});\n\t\tif (top.status !== 0 || typeof top.stdout !== \"string\") return { root: cwd, artifactPaths: [] };\n\t\tconst root = top.stdout.trim();\n\t\tif (root.length === 0) return { root: cwd, artifactPaths: [] };\n\t\tconst status = spawnSync(\"git\", [\"-C\", cwd, \"status\", \"--porcelain=v1\", \"-z\", \"--untracked-files=normal\"], {\n\t\t\ttimeout: GIT_TIMEOUT_MS,\n\t\t\tmaxBuffer: 4 * 1024 * 1024,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t\t});\n\t\tif (status.status !== 0 || !status.stdout) return { root, artifactPaths: [] };\n\t\tconst fields = status.stdout.toString(\"utf8\").split(\"\\0\");\n\t\tconst paths: string[] = [];\n\t\tfor (let index = 0; index < fields.length; index++) {\n\t\t\tconst field = fields[index];\n\t\t\tif (field.length < 4) continue;\n\t\t\tconst xy = field.slice(0, 2);\n\t\t\tif (xy === \"!!\") continue;\n\t\t\tif (xy.includes(\"R\")) index++; // rename: consume the source path field too\n\t\t\tconst artifact = field.slice(3);\n\t\t\tif (artifact.length > 0) paths.push(artifact);\n\t\t}\n\t\tconst artifactPaths = [...new Set(paths)].sort().slice(0, maxPaths);\n\t\treturn { root, artifactPaths };\n\t} catch {\n\t\treturn { root: cwd, artifactPaths: [] };\n\t}\n}\n"]}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Default-on gate for the verified bash adapter (opt-out via OMK_VERIFIED_BASH=0).
3
+ *
4
+ * Mirrors ADR-OMP-009: the receipt-bound path is the default experience; the
5
+ * exact legacy unverified path remains available as a byte-identical rollback.
6
+ */
7
+ import { spawnSync } from "node:child_process";
8
+ export function isVerifiedBashEnabled(env) {
9
+ const source = env ?? process.env;
10
+ return source.OMK_VERIFIED_BASH !== "0";
11
+ }
12
+ // ---------------------------------------------------------------------------
13
+ // Git-aware session workspace scope (bounded, TTL-cached)
14
+ // ---------------------------------------------------------------------------
15
+ const SCOPE_TTL_MS = 1_000;
16
+ const SCOPE_CACHE_MAX = 8;
17
+ const SCOPE_MAX_PATHS = 32;
18
+ const GIT_TIMEOUT_MS = 1_500;
19
+ const scopeCache = new Map();
20
+ /**
21
+ * Workspace scope for session bash receipts. Inside a git worktree the scope
22
+ * root is the toplevel and `artifactPaths` is the current dirty set (staged,
23
+ * modified, untracked; capped and sorted), which lets `captureWorkspaceFingerprint`
24
+ * bind HEAD plus a scope-limited dirty digest. Outside git, falls back to an
25
+ * empty artifact set under `cwd`. Never throws.
26
+ */
27
+ export function resolveSessionWorkspaceScope(cwd, options) {
28
+ const cached = scopeCache.get(cwd);
29
+ if (cached && Date.now() - cached.at < SCOPE_TTL_MS)
30
+ return cached.scope;
31
+ const scope = computeSessionWorkspaceScope(cwd, options?.maxPaths ?? SCOPE_MAX_PATHS);
32
+ if (scopeCache.size >= SCOPE_CACHE_MAX) {
33
+ const oldest = scopeCache.keys().next().value;
34
+ if (oldest !== undefined)
35
+ scopeCache.delete(oldest);
36
+ }
37
+ scopeCache.set(cwd, { at: Date.now(), scope });
38
+ return scope;
39
+ }
40
+ function computeSessionWorkspaceScope(cwd, maxPaths) {
41
+ try {
42
+ const top = spawnSync("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
43
+ encoding: "utf8",
44
+ timeout: GIT_TIMEOUT_MS,
45
+ stdio: ["ignore", "pipe", "ignore"],
46
+ });
47
+ if (top.status !== 0 || typeof top.stdout !== "string")
48
+ return { root: cwd, artifactPaths: [] };
49
+ const root = top.stdout.trim();
50
+ if (root.length === 0)
51
+ return { root: cwd, artifactPaths: [] };
52
+ const status = spawnSync("git", ["-C", cwd, "status", "--porcelain=v1", "-z", "--untracked-files=normal"], {
53
+ timeout: GIT_TIMEOUT_MS,
54
+ maxBuffer: 4 * 1024 * 1024,
55
+ stdio: ["ignore", "pipe", "ignore"],
56
+ });
57
+ if (status.status !== 0 || !status.stdout)
58
+ return { root, artifactPaths: [] };
59
+ const fields = status.stdout.toString("utf8").split("\0");
60
+ const paths = [];
61
+ for (let index = 0; index < fields.length; index++) {
62
+ const field = fields[index];
63
+ if (field.length < 4)
64
+ continue;
65
+ const xy = field.slice(0, 2);
66
+ if (xy === "!!")
67
+ continue;
68
+ if (xy.includes("R"))
69
+ index++; // rename: consume the source path field too
70
+ const artifact = field.slice(3);
71
+ if (artifact.length > 0)
72
+ paths.push(artifact);
73
+ }
74
+ const artifactPaths = [...new Set(paths)].sort().slice(0, maxPaths);
75
+ return { root, artifactPaths };
76
+ }
77
+ catch {
78
+ return { root: cwd, artifactPaths: [] };
79
+ }
80
+ }
81
+ //# sourceMappingURL=verified-bash-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verified-bash-runtime.js","sourceRoot":"","sources":["../../src/core/verified-bash-runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,UAAU,qBAAqB,CAAC,GAAwC,EAAW;IACxF,MAAM,MAAM,GAAuC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACtE,OAAO,MAAM,CAAC,iBAAiB,KAAK,GAAG,CAAC;AAAA,CACxC;AAED,8EAA8E;AAC9E,0DAA0D;AAC1D,8EAA8E;AAE9E,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAiD,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAAC,GAAW,EAAE,OAA+B,EAAkB;IAC1G,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,YAAY;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC;IACzE,MAAM,KAAK,GAAG,4BAA4B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,IAAI,eAAe,CAAC,CAAC;IACtF,IAAI,UAAU,CAAC,IAAI,IAAI,eAAe,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;QAC9C,IAAI,MAAM,KAAK,SAAS;YAAE,UAAU,CAAC,MAAM,CAAC,MAAM,CAA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EAAE,CAAC;QAC9E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACpD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,SAAS;YAC/B,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7B,IAAI,EAAE,KAAK,IAAI;gBAAE,SAAS;YAC1B,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,KAAK,EAAE,CAAC,CAAC,4CAA4C;YAC3E,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAChC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC;QACD,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QACpE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC;AAAA,CACD","sourcesContent":["/**\n * Default-on gate for the verified bash adapter (opt-out via OMK_VERIFIED_BASH=0).\n *\n * Mirrors ADR-OMP-009: the receipt-bound path is the default experience; the\n * exact legacy unverified path remains available as a byte-identical rollback.\n */\nimport { spawnSync } from \"node:child_process\";\nimport type { WorkspaceScope } from \"../types/evidence.ts\";\n\nexport function isVerifiedBashEnabled(env?: Record<string, string | undefined>): boolean {\n\tconst source: Record<string, string | undefined> = env ?? process.env;\n\treturn source.OMK_VERIFIED_BASH !== \"0\";\n}\n\n// ---------------------------------------------------------------------------\n// Git-aware session workspace scope (bounded, TTL-cached)\n// ---------------------------------------------------------------------------\n\nconst SCOPE_TTL_MS = 1_000;\nconst SCOPE_CACHE_MAX = 8;\nconst SCOPE_MAX_PATHS = 32;\nconst GIT_TIMEOUT_MS = 1_500;\n\nconst scopeCache = new Map<string, { at: number; scope: WorkspaceScope }>();\n\n/**\n * Workspace scope for session bash receipts. Inside a git worktree the scope\n * root is the toplevel and `artifactPaths` is the current dirty set (staged,\n * modified, untracked; capped and sorted), which lets `captureWorkspaceFingerprint`\n * bind HEAD plus a scope-limited dirty digest. Outside git, falls back to an\n * empty artifact set under `cwd`. Never throws.\n */\nexport function resolveSessionWorkspaceScope(cwd: string, options?: { maxPaths?: number }): WorkspaceScope {\n\tconst cached = scopeCache.get(cwd);\n\tif (cached && Date.now() - cached.at < SCOPE_TTL_MS) return cached.scope;\n\tconst scope = computeSessionWorkspaceScope(cwd, options?.maxPaths ?? SCOPE_MAX_PATHS);\n\tif (scopeCache.size >= SCOPE_CACHE_MAX) {\n\t\tconst oldest = scopeCache.keys().next().value;\n\t\tif (oldest !== undefined) scopeCache.delete(oldest);\n\t}\n\tscopeCache.set(cwd, { at: Date.now(), scope });\n\treturn scope;\n}\n\nfunction computeSessionWorkspaceScope(cwd: string, maxPaths: number): WorkspaceScope {\n\ttry {\n\t\tconst top = spawnSync(\"git\", [\"-C\", cwd, \"rev-parse\", \"--show-toplevel\"], {\n\t\t\tencoding: \"utf8\",\n\t\t\ttimeout: GIT_TIMEOUT_MS,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t\t});\n\t\tif (top.status !== 0 || typeof top.stdout !== \"string\") return { root: cwd, artifactPaths: [] };\n\t\tconst root = top.stdout.trim();\n\t\tif (root.length === 0) return { root: cwd, artifactPaths: [] };\n\t\tconst status = spawnSync(\"git\", [\"-C\", cwd, \"status\", \"--porcelain=v1\", \"-z\", \"--untracked-files=normal\"], {\n\t\t\ttimeout: GIT_TIMEOUT_MS,\n\t\t\tmaxBuffer: 4 * 1024 * 1024,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t\t});\n\t\tif (status.status !== 0 || !status.stdout) return { root, artifactPaths: [] };\n\t\tconst fields = status.stdout.toString(\"utf8\").split(\"\\0\");\n\t\tconst paths: string[] = [];\n\t\tfor (let index = 0; index < fields.length; index++) {\n\t\t\tconst field = fields[index];\n\t\t\tif (field.length < 4) continue;\n\t\t\tconst xy = field.slice(0, 2);\n\t\t\tif (xy === \"!!\") continue;\n\t\t\tif (xy.includes(\"R\")) index++; // rename: consume the source path field too\n\t\t\tconst artifact = field.slice(3);\n\t\t\tif (artifact.length > 0) paths.push(artifact);\n\t\t}\n\t\tconst artifactPaths = [...new Set(paths)].sort().slice(0, maxPaths);\n\t\treturn { root, artifactPaths };\n\t} catch {\n\t\treturn { root: cwd, artifactPaths: [] };\n\t}\n}\n"]}