@agent-native/core 0.28.5 → 0.29.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/coding-tools/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,+BAA+B;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,IAAI,CAAC;IACzD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;KACnB,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9C;AAcD,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,+BAAoC,GAC5C,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,WAAW,CAAC,CA+OzD;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE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,CAAC;CAC9C;AAcD,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,+BAAoC,GAC5C,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,WAAW,CAAC,CAwPzD;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,OAAO,CAAC,mBAAmB,CAAC,CA4B9B;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,SAA2B,EACnC,OAAO,GAAE;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAUR;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAqC/D"}
@@ -14,25 +14,25 @@ export function createCodingToolRegistry(options = {}) {
14
14
  return {
15
15
  bash: {
16
16
  tool: {
17
- description: "Run a bash command. Use this for file discovery and search (rg --files, rg, find, ls), tests, builds, package commands, git status/diff, and project CLIs.",
17
+ description: "Run a shell command. This is the tool for file discovery, directory listing, and search: reach first for `rg <pattern>` and `rg --files`, which are much faster than `grep` or `find`. Also use it to run tests, builds, package scripts, `git status`/`git diff`, and project CLIs. Use the read tool to view a single file's contents; use bash for everything else. Very long output is truncated.",
18
18
  parameters: {
19
19
  type: "object",
20
20
  properties: {
21
21
  command: {
22
22
  type: "string",
23
- description: "The bash command to run.",
23
+ description: "The shell command to run (executed via bash).",
24
24
  },
25
25
  cwd: {
26
26
  type: "string",
27
- description: "Optional working directory, relative to the workspace unless absolute paths are allowed.",
27
+ description: "Working directory for the command. Relative to the workspace root unless absolute paths are allowed. Defaults to the workspace root.",
28
28
  },
29
29
  timeoutMs: {
30
30
  type: "string",
31
- description: "Optional timeout in milliseconds.",
31
+ description: "Timeout in milliseconds; the command is killed if it exceeds this. Defaults to 30000, capped at 600000.",
32
32
  },
33
33
  stdin: {
34
34
  type: "string",
35
- description: "Optional stdin to pipe into the command.",
35
+ description: "Text to pipe into the command's stdin.",
36
36
  },
37
37
  },
38
38
  required: ["command"],
@@ -74,21 +74,21 @@ export function createCodingToolRegistry(options = {}) {
74
74
  read: {
75
75
  readOnly: true,
76
76
  tool: {
77
- description: "Read a UTF-8 text file with line numbers. Use bash for directories, file lists, and search.",
77
+ description: "Read a single UTF-8 text file, returned with 1-based line numbers. For a large file, use offset and limit to page through it instead of reading the whole thing. Read a file before editing it so your edit's oldText matches exactly. Use bash (`ls`, `rg --files`, `rg`) for directory listings, file discovery, and search; this tool reads one file only.",
78
78
  parameters: {
79
79
  type: "object",
80
80
  properties: {
81
81
  path: {
82
82
  type: "string",
83
- description: "File path to read.",
83
+ description: "Path to the file to read, relative to the workspace root unless absolute paths are allowed.",
84
84
  },
85
85
  offset: {
86
86
  type: "string",
87
- description: "1-based line number to start reading from.",
87
+ description: "1-based line number to start reading from. Defaults to the first line.",
88
88
  },
89
89
  limit: {
90
90
  type: "string",
91
- description: "Maximum number of lines to read.",
91
+ description: "Maximum number of lines to read from offset. Defaults to the rest of the file.",
92
92
  },
93
93
  },
94
94
  required: ["path"],
@@ -114,30 +114,30 @@ export function createCodingToolRegistry(options = {}) {
114
114
  },
115
115
  edit: {
116
116
  tool: {
117
- description: "Edit an existing UTF-8 text file by replacing exact text. Prefer this for focused source changes. oldText must match exactly and uniquely unless replaceAll is true. For batch edits, pass edits as a JSON array of {oldText,newText,replaceAll}.",
117
+ description: "Edit an existing UTF-8 text file by replacing exact text. Prefer this over write for changes to existing files. Read the file first so oldText matches byte-for-byte, including whitespace and indentation. oldText must occur EXACTLY ONCE in the file: include enough surrounding context to make it unique. The edit fails (and the file is left unchanged) if oldText is not found or matches more than once, unless replaceAll is true, which replaces every occurrence. To apply several edits to one file in a single call, pass edits as a JSON array of {oldText, newText, replaceAll} objects; they apply in order, and any failure aborts the whole call.",
118
118
  parameters: {
119
119
  type: "object",
120
120
  properties: {
121
121
  path: {
122
122
  type: "string",
123
- description: "File path to edit.",
123
+ description: "Path to the file to edit, relative to the workspace root unless absolute paths are allowed.",
124
124
  },
125
125
  oldText: {
126
126
  type: "string",
127
- description: "Exact text to replace for a single edit.",
127
+ description: "Exact existing text to replace, for a single edit. Must match the file exactly and uniquely (include surrounding context) unless replaceAll is true.",
128
128
  },
129
129
  newText: {
130
130
  type: "string",
131
- description: "Replacement text for a single edit.",
131
+ description: "Text to replace oldText with, for a single edit.",
132
132
  },
133
133
  replaceAll: {
134
134
  type: "string",
135
- description: 'Set to "true" to replace every occurrence.',
135
+ description: 'Set to "true" to replace every occurrence of oldText instead of requiring a unique match. Defaults to "false".',
136
136
  enum: ["true", "false"],
137
137
  },
138
138
  edits: {
139
139
  type: "string",
140
- description: 'Optional JSON array of edits, e.g. [{"oldText":"foo","newText":"bar"}].',
140
+ description: 'JSON array of edits to apply to this file in one call, e.g. [{"oldText":"foo","newText":"bar"},{"oldText":"baz","newText":"qux","replaceAll":"true"}]. When provided, the top-level oldText/newText are ignored.',
141
141
  },
142
142
  },
143
143
  required: ["path"],
@@ -184,17 +184,17 @@ export function createCodingToolRegistry(options = {}) {
184
184
  },
185
185
  write: {
186
186
  tool: {
187
- description: "Create or fully overwrite a UTF-8 text file. Prefer edit for existing files unless a complete rewrite is intended.",
187
+ description: "Create a new UTF-8 text file, or fully overwrite an existing one with the given content. Missing parent directories are created. For changes to an existing file, prefer edit; only use write when you intend to replace the entire file. Default to ASCII content unless the file already uses other characters or there is a clear reason not to.",
188
188
  parameters: {
189
189
  type: "object",
190
190
  properties: {
191
191
  path: {
192
192
  type: "string",
193
- description: "File path to write.",
193
+ description: "Path to the file to write, relative to the workspace root unless absolute paths are allowed.",
194
194
  },
195
195
  content: {
196
196
  type: "string",
197
- description: "Full file content.",
197
+ description: "Full contents to write. This replaces the entire file; existing content is not preserved.",
198
198
  },
199
199
  },
200
200
  required: ["path", "content"],
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coding-tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAgC7B,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAC1C,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAE5C,MAAM,cAAc,GAAG,IAAI,GAAG,EAA4B,CAAC;AAE3D,MAAM,UAAU,wBAAwB,CACtC,UAA2C,EAAE;IAE7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,KAAK,CAAC;IACrD,MAAM,gBAAgB,GACpB,OAAO,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;IACzD,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,wBAAwB,CAAC;IAC1E,MAAM,gBAAgB,GACpB,OAAO,CAAC,gBAAgB,IAAI,2BAA2B,CAAC;IAE1D,OAAO;QACL,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,WAAW,EACT,4JAA4J;gBAC9J,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,0BAA0B;yBACxC;wBACD,GAAG,EAAE;4BACH,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,0FAA0F;yBAC7F;wBACD,SAAS,EAAE;4BACT,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,mCAAmC;y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AAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,QAAgB;IACvD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/E,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { ActionEntry } from \"../agent/production-agent.js\";\n\nexport interface CodingCommandResult {\n code: number | null;\n stdout: string;\n stderr: string;\n timedOut: boolean;\n}\n\nexport interface CreateCodingToolRegistryOptions {\n cwd?: string;\n restrictToCwd?: boolean;\n commandTimeoutMs?: number;\n maxOutputChars?: number;\n maxFileReadChars?: number;\n bashThrowsOnNonZero?: boolean;\n canWrite?: (toolName: \"edit\" | \"write\") => string | null;\n beforeBash?: (input: {\n command: string;\n cwd: string;\n timeoutMs: number;\n }) => string | null | Promise<string | null>;\n}\n\ninterface EditOperation {\n oldText: string;\n newText: string;\n replaceAll: boolean;\n}\n\nconst DEFAULT_COMMAND_TIMEOUT_MS = 30_000;\nconst DEFAULT_MAX_OUTPUT_CHARS = 50_000;\nconst DEFAULT_MAX_FILE_READ_CHARS = 120_000;\n\nconst mutationQueues = new Map<string, Promise<unknown>>();\n\nexport function createCodingToolRegistry(\n options: CreateCodingToolRegistryOptions = {},\n): Record<\"bash\" | \"read\" | \"edit\" | \"write\", ActionEntry> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const restrictToCwd = options.restrictToCwd ?? false;\n const commandTimeoutMs =\n options.commandTimeoutMs ?? DEFAULT_COMMAND_TIMEOUT_MS;\n const maxOutputChars = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT_CHARS;\n const maxFileReadChars =\n options.maxFileReadChars ?? DEFAULT_MAX_FILE_READ_CHARS;\n\n return {\n bash: {\n tool: {\n description:\n \"Run a bash command. Use this for file discovery and search (rg --files, rg, find, ls), tests, builds, package commands, git status/diff, and project CLIs.\",\n parameters: {\n type: \"object\",\n properties: {\n command: {\n type: \"string\",\n description: \"The bash command to run.\",\n },\n cwd: {\n type: \"string\",\n description:\n \"Optional working directory, relative to the workspace unless absolute paths are allowed.\",\n },\n timeoutMs: {\n type: \"string\",\n description: \"Optional timeout in milliseconds.\",\n },\n stdin: {\n type: \"string\",\n description: \"Optional stdin to pipe into the command.\",\n },\n },\n required: [\"command\"],\n },\n },\n run: async (args) => {\n const command = stringArg(args.command);\n if (!command) return \"Error: command is required.\";\n const commandCwd =\n resolveCodingPath(cwd, stringArg(args.cwd) || \".\", {\n restrictToCwd,\n allowEmpty: true,\n }) ?? \"\";\n if (!commandCwd) {\n return \"Error: cwd must stay inside the workspace.\";\n }\n const requestedTimeoutMs = Number(args.timeoutMs);\n const timeoutMs =\n Number.isFinite(requestedTimeoutMs) && requestedTimeoutMs > 0\n ? Math.min(requestedTimeoutMs, 10 * 60_000)\n : commandTimeoutMs;\n\n const policyResult =\n (await options.beforeBash?.({\n command,\n cwd: commandCwd,\n timeoutMs,\n })) ?? null;\n if (policyResult) return policyResult;\n\n const result = await runCodingCommand(command, commandCwd, timeoutMs, {\n stdin: stringArg(args.stdin) || undefined,\n });\n if (options.bashThrowsOnNonZero && result.code !== 0) {\n throw new Error(formatCodingCommandResult(result, maxOutputChars));\n }\n return formatCodingCommandResult(result, maxOutputChars, {\n omitEmptyExitCode: options.bashThrowsOnNonZero && result.code === 0,\n });\n },\n },\n read: {\n readOnly: true,\n tool: {\n description:\n \"Read a UTF-8 text file with line numbers. Use bash for directories, file lists, and search.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description: \"File path to read.\",\n },\n offset: {\n type: \"string\",\n description: \"1-based line number to start reading from.\",\n },\n limit: {\n type: \"string\",\n description: \"Maximum number of lines to read.\",\n },\n },\n required: [\"path\"],\n },\n },\n run: async (args) => {\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n if (!fs.existsSync(filePath)) {\n return `Error: file not found: ${requestedPath}`;\n }\n const stat = fs.statSync(filePath);\n if (!stat.isFile()) {\n return `Error: ${requestedPath} is not a file. Use bash for directories and file lists.`;\n }\n const content = fs.readFileSync(filePath, \"utf8\");\n return truncateCodingOutput(\n formatFileReadOutput(cwd, filePath, content, args),\n maxFileReadChars,\n );\n },\n },\n edit: {\n tool: {\n description:\n \"Edit an existing UTF-8 text file by replacing exact text. Prefer this for focused source changes. oldText must match exactly and uniquely unless replaceAll is true. For batch edits, pass edits as a JSON array of {oldText,newText,replaceAll}.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description: \"File path to edit.\",\n },\n oldText: {\n type: \"string\",\n description: \"Exact text to replace for a single edit.\",\n },\n newText: {\n type: \"string\",\n description: \"Replacement text for a single edit.\",\n },\n replaceAll: {\n type: \"string\",\n description: 'Set to \"true\" to replace every occurrence.',\n enum: [\"true\", \"false\"],\n },\n edits: {\n type: \"string\",\n description:\n 'Optional JSON array of edits, e.g. [{\"oldText\":\"foo\",\"newText\":\"bar\"}].',\n },\n },\n required: [\"path\"],\n },\n },\n run: async (args) => {\n const permissionError = options.canWrite?.(\"edit\") ?? null;\n if (permissionError) return permissionError;\n\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n const edits = parseEditOperations(args);\n\n return queueFileMutation(filePath, async () => {\n if (!fs.existsSync(filePath)) {\n throw new Error(`file not found: ${requestedPath}`);\n }\n const stat = fs.statSync(filePath);\n if (!stat.isFile()) {\n throw new Error(`${requestedPath} is not a file`);\n }\n\n let content = fs.readFileSync(filePath, \"utf8\");\n let replacements = 0;\n for (const edit of edits) {\n const count = countOccurrences(content, edit.oldText);\n if (count === 0) {\n throw new Error(\n `oldText was not found in ${requestedPath}: ${previewText(\n edit.oldText,\n )}`,\n );\n }\n if (!edit.replaceAll && count !== 1) {\n throw new Error(\n `oldText matched ${count} times in ${requestedPath}; make it unique or set replaceAll=true.`,\n );\n }\n content = edit.replaceAll\n ? content.split(edit.oldText).join(edit.newText)\n : content.replace(edit.oldText, edit.newText);\n replacements += edit.replaceAll ? count : 1;\n }\n\n fs.writeFileSync(filePath, content, \"utf8\");\n return `Edited ${path.relative(cwd, filePath) || requestedPath} (${replacements} replacement${replacements === 1 ? \"\" : \"s\"}).`;\n });\n },\n },\n write: {\n tool: {\n description:\n \"Create or fully overwrite a UTF-8 text file. Prefer edit for existing files unless a complete rewrite is intended.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description: \"File path to write.\",\n },\n content: {\n type: \"string\",\n description: \"Full file content.\",\n },\n },\n required: [\"path\", \"content\"],\n },\n },\n run: async (args) => {\n const permissionError = options.canWrite?.(\"write\") ?? null;\n if (permissionError) return permissionError;\n\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n const content = stringArg(args.content);\n\n return queueFileMutation(filePath, async () => {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n const existed = fs.existsSync(filePath);\n fs.writeFileSync(filePath, content, \"utf8\");\n const bytes = Buffer.byteLength(content, \"utf8\");\n const lines = content.split(\"\\n\").length;\n return `${existed ? \"Updated\" : \"Created\"} ${path.relative(cwd, filePath) || requestedPath} (${lines} lines, ${bytes} bytes).`;\n });\n },\n },\n };\n}\n\nexport async function runCodingCommand(\n command: string,\n cwd: string,\n timeoutMs: number,\n options: { stdin?: string } = {},\n): Promise<CodingCommandResult> {\n const child = spawn(command, {\n cwd,\n shell: true,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n env: { ...process.env, FORCE_COLOR: \"0\" },\n });\n let stdout = \"\";\n let stderr = \"\";\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill(\"SIGTERM\");\n }, timeoutMs);\n child.stdout?.on(\"data\", (chunk) => {\n stdout += chunk.toString();\n });\n child.stderr?.on(\"data\", (chunk) => {\n stderr += chunk.toString();\n });\n if (options.stdin) child.stdin?.end(options.stdin);\n else child.stdin?.end();\n const code = await new Promise<number | null>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"exit\", resolve);\n });\n clearTimeout(timer);\n return { code, stdout, stderr, timedOut };\n}\n\nexport function formatCodingCommandResult(\n result: CodingCommandResult,\n maxChars = DEFAULT_MAX_OUTPUT_CHARS,\n options: { omitEmptyExitCode?: boolean } = {},\n): string {\n const parts = [\n options.omitEmptyExitCode && result.code === 0\n ? \"\"\n : `exitCode: ${result.code}`,\n result.timedOut ? \"timedOut: true\" : \"\",\n result.stdout ? `stdout:\\n${result.stdout}` : \"\",\n result.stderr ? `stderr:\\n${result.stderr}` : \"\",\n ].filter(Boolean);\n return truncateCodingOutput(parts.join(\"\\n\\n\") || \"(no output)\", maxChars);\n}\n\nexport function truncateCodingOutput(value: string, max: number): string {\n if (value.length <= max) return value;\n return `${value.slice(0, max)}\\n\\n...[truncated ${value.length - max} chars]`;\n}\n\nexport function isReadOnlyShellCommand(command: string): boolean {\n const normalized = command.trim().toLowerCase();\n if (!normalized) return false;\n\n // Read-only modes get a deliberately tiny shell grammar: one command only,\n // no redirection, pipes, sequencing, backgrounding, or command substitution.\n // Prefix allowlists are not safe until these shell forms are excluded.\n if (/[\\n\\r;&|<>]/.test(normalized)) return false;\n if (/\\$\\(|`|\\${|\\\\\\n/.test(command)) return false;\n\n // `sed` can WRITE even in `-n` mode via the `w`/`W` commands or `-i`\n // (e.g. `sed -n '1w out.txt' file`), so the `^sed -n` allowlist entry\n // below is not safe on its own. Reject any sed that can write.\n if (/^sed\\b/.test(normalized)) {\n if (/(^|\\s)-i(\\b|=)|--in-place/.test(normalized)) return false;\n // `w`/`W` used as a sed command: preceded by an address/separator\n // (digit, $, /, }, ;, quote, space) and followed by a filename arg or\n // end. Catches `1w f`, `$w f`, `/re/w f`, `s/x/y/w f`, `2W f`; leaves\n // prints like `/window/p`, `1,5p`, `s/a/b/` untouched.\n if (/[\\s'\"0-9$}/;](w|W)([\\s'\"]|$)/.test(normalized)) return false;\n }\n\n const allowedPrefixes = [\n /^pwd\\b/,\n /^ls\\b/,\n /^find\\b/,\n /^rg\\b/,\n /^grep\\b/,\n /^cat\\b/,\n /^sed\\s+-n\\b/,\n /^head\\b/,\n /^tail\\b/,\n /^wc\\b/,\n /^git\\s+(status|diff|show|log)\\b/,\n /^git\\s+branch\\s+--show-current\\b/,\n ];\n return allowedPrefixes.some((pattern) => pattern.test(normalized));\n}\n\nfunction resolveCodingPath(\n cwd: string,\n value: string,\n options: { restrictToCwd: boolean; allowEmpty?: boolean },\n): string | null {\n if (!value.trim() && !options.allowEmpty) return null;\n const target = value.trim() || \".\";\n const resolved = path.isAbsolute(target)\n ? path.resolve(target)\n : path.resolve(cwd, target);\n if (!options.restrictToCwd) return resolved;\n\n const relative = path.relative(cwd, resolved);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) return null;\n return resolved;\n}\n\nfunction formatFileReadOutput(\n cwd: string,\n filePath: string,\n content: string,\n args: Record<string, unknown>,\n): string {\n const lines = content.split(\"\\n\");\n const offset = positiveInteger(args.offset, 1);\n const limit = positiveInteger(args.limit, lines.length - offset + 1);\n const selected = lines.slice(offset - 1, offset - 1 + limit);\n const body = selected\n .map((line, index) => `${String(offset + index).padStart(5)} | ${line}`)\n .join(\"\\n\");\n return `${path.relative(cwd, filePath) || filePath} (${lines.length} lines)\\n${body}`;\n}\n\nfunction parseEditOperations(args: Record<string, unknown>): EditOperation[] {\n const editsJson = stringArg(args.edits);\n if (editsJson.trim()) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(editsJson);\n } catch (err) {\n throw new Error(\n `edits must be valid JSON: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n if (!Array.isArray(parsed) || parsed.length === 0) {\n throw new Error(\"edits must be a non-empty JSON array.\");\n }\n return parsed.map((edit, index) => {\n if (!edit || typeof edit !== \"object\") {\n throw new Error(`edits[${index}] must be an object.`);\n }\n return normalizeEditOperation(edit as Record<string, unknown>, index);\n });\n }\n\n return [normalizeEditOperation(args, 0)];\n}\n\nfunction normalizeEditOperation(\n edit: Record<string, unknown>,\n index: number,\n): EditOperation {\n const oldText = typeof edit.oldText === \"string\" ? edit.oldText : undefined;\n const newText = typeof edit.newText === \"string\" ? edit.newText : undefined;\n if (!oldText) {\n throw new Error(\n index === 0\n ? \"oldText is required and cannot be empty.\"\n : `edits[${index}].oldText is required and cannot be empty.`,\n );\n }\n if (newText === undefined) {\n throw new Error(\n index === 0\n ? \"newText is required.\"\n : `edits[${index}].newText is required.`,\n );\n }\n return {\n oldText,\n newText,\n replaceAll: stringArg(edit.replaceAll).toLowerCase() === \"true\",\n };\n}\n\nfunction countOccurrences(value: string, needle: string): number {\n let count = 0;\n let index = 0;\n while (true) {\n index = value.indexOf(needle, index);\n if (index === -1) return count;\n count += 1;\n index += needle.length;\n }\n}\n\nfunction queueFileMutation<T>(filePath: string, task: () => Promise<T> | T) {\n const previous = mutationQueues.get(filePath) ?? Promise.resolve();\n const next = previous.catch(() => undefined).then(task);\n let queued: Promise<unknown>;\n queued = next.finally(() => {\n if (mutationQueues.get(filePath) === queued)\n mutationQueues.delete(filePath);\n });\n mutationQueues.set(filePath, queued);\n return next;\n}\n\nfunction previewText(value: string): string {\n const oneLine = value.replace(/\\s+/g, \" \").trim();\n return oneLine.length > 80 ? `${oneLine.slice(0, 80)}...` : oneLine;\n}\n\nfunction stringArg(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction positiveInteger(value: unknown, fallback: number): number {\n const parsed = Number(value);\n return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : fallback;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coding-tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAgC7B,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAC1C,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAE5C,MAAM,cAAc,GAAG,IAAI,GAAG,EAA4B,CAAC;AAE3D,MAAM,UAAU,wBAAwB,CACtC,UAA2C,EAAE;IAE7C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,KAAK,CAAC;IACrD,MAAM,gBAAgB,GACpB,OAAO,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;IACzD,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,wBAAwB,CAAC;IAC1E,MAAM,gBAAgB,GACpB,OAAO,CAAC,gBAAgB,IAAI,2BAA2B,CAAC;IAE1D,OAAO;QACL,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,WAAW,EACT,uYAAuY;gBACzY,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,+CAA+C;yBAC7D;wBACD,GAAG,EAAE;4BACH,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,sIAAsI;yBAC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,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AACtE,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,QAAgB;IACvD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/E,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { ActionEntry } from \"../agent/production-agent.js\";\n\nexport interface CodingCommandResult {\n code: number | null;\n stdout: string;\n stderr: string;\n timedOut: boolean;\n}\n\nexport interface CreateCodingToolRegistryOptions {\n cwd?: string;\n restrictToCwd?: boolean;\n commandTimeoutMs?: number;\n maxOutputChars?: number;\n maxFileReadChars?: number;\n bashThrowsOnNonZero?: boolean;\n canWrite?: (toolName: \"edit\" | \"write\") => string | null;\n beforeBash?: (input: {\n command: string;\n cwd: string;\n timeoutMs: number;\n }) => string | null | Promise<string | null>;\n}\n\ninterface EditOperation {\n oldText: string;\n newText: string;\n replaceAll: boolean;\n}\n\nconst DEFAULT_COMMAND_TIMEOUT_MS = 30_000;\nconst DEFAULT_MAX_OUTPUT_CHARS = 50_000;\nconst DEFAULT_MAX_FILE_READ_CHARS = 120_000;\n\nconst mutationQueues = new Map<string, Promise<unknown>>();\n\nexport function createCodingToolRegistry(\n options: CreateCodingToolRegistryOptions = {},\n): Record<\"bash\" | \"read\" | \"edit\" | \"write\", ActionEntry> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const restrictToCwd = options.restrictToCwd ?? false;\n const commandTimeoutMs =\n options.commandTimeoutMs ?? DEFAULT_COMMAND_TIMEOUT_MS;\n const maxOutputChars = options.maxOutputChars ?? DEFAULT_MAX_OUTPUT_CHARS;\n const maxFileReadChars =\n options.maxFileReadChars ?? DEFAULT_MAX_FILE_READ_CHARS;\n\n return {\n bash: {\n tool: {\n description:\n \"Run a shell command. This is the tool for file discovery, directory listing, and search: reach first for `rg <pattern>` and `rg --files`, which are much faster than `grep` or `find`. Also use it to run tests, builds, package scripts, `git status`/`git diff`, and project CLIs. Use the read tool to view a single file's contents; use bash for everything else. Very long output is truncated.\",\n parameters: {\n type: \"object\",\n properties: {\n command: {\n type: \"string\",\n description: \"The shell command to run (executed via bash).\",\n },\n cwd: {\n type: \"string\",\n description:\n \"Working directory for the command. Relative to the workspace root unless absolute paths are allowed. Defaults to the workspace root.\",\n },\n timeoutMs: {\n type: \"string\",\n description:\n \"Timeout in milliseconds; the command is killed if it exceeds this. Defaults to 30000, capped at 600000.\",\n },\n stdin: {\n type: \"string\",\n description: \"Text to pipe into the command's stdin.\",\n },\n },\n required: [\"command\"],\n },\n },\n run: async (args) => {\n const command = stringArg(args.command);\n if (!command) return \"Error: command is required.\";\n const commandCwd =\n resolveCodingPath(cwd, stringArg(args.cwd) || \".\", {\n restrictToCwd,\n allowEmpty: true,\n }) ?? \"\";\n if (!commandCwd) {\n return \"Error: cwd must stay inside the workspace.\";\n }\n const requestedTimeoutMs = Number(args.timeoutMs);\n const timeoutMs =\n Number.isFinite(requestedTimeoutMs) && requestedTimeoutMs > 0\n ? Math.min(requestedTimeoutMs, 10 * 60_000)\n : commandTimeoutMs;\n\n const policyResult =\n (await options.beforeBash?.({\n command,\n cwd: commandCwd,\n timeoutMs,\n })) ?? null;\n if (policyResult) return policyResult;\n\n const result = await runCodingCommand(command, commandCwd, timeoutMs, {\n stdin: stringArg(args.stdin) || undefined,\n });\n if (options.bashThrowsOnNonZero && result.code !== 0) {\n throw new Error(formatCodingCommandResult(result, maxOutputChars));\n }\n return formatCodingCommandResult(result, maxOutputChars, {\n omitEmptyExitCode: options.bashThrowsOnNonZero && result.code === 0,\n });\n },\n },\n read: {\n readOnly: true,\n tool: {\n description:\n \"Read a single UTF-8 text file, returned with 1-based line numbers. For a large file, use offset and limit to page through it instead of reading the whole thing. Read a file before editing it so your edit's oldText matches exactly. Use bash (`ls`, `rg --files`, `rg`) for directory listings, file discovery, and search; this tool reads one file only.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to read, relative to the workspace root unless absolute paths are allowed.\",\n },\n offset: {\n type: \"string\",\n description:\n \"1-based line number to start reading from. Defaults to the first line.\",\n },\n limit: {\n type: \"string\",\n description:\n \"Maximum number of lines to read from offset. Defaults to the rest of the file.\",\n },\n },\n required: [\"path\"],\n },\n },\n run: async (args) => {\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n if (!fs.existsSync(filePath)) {\n return `Error: file not found: ${requestedPath}`;\n }\n const stat = fs.statSync(filePath);\n if (!stat.isFile()) {\n return `Error: ${requestedPath} is not a file. Use bash for directories and file lists.`;\n }\n const content = fs.readFileSync(filePath, \"utf8\");\n return truncateCodingOutput(\n formatFileReadOutput(cwd, filePath, content, args),\n maxFileReadChars,\n );\n },\n },\n edit: {\n tool: {\n description:\n \"Edit an existing UTF-8 text file by replacing exact text. Prefer this over write for changes to existing files. Read the file first so oldText matches byte-for-byte, including whitespace and indentation. oldText must occur EXACTLY ONCE in the file: include enough surrounding context to make it unique. The edit fails (and the file is left unchanged) if oldText is not found or matches more than once, unless replaceAll is true, which replaces every occurrence. To apply several edits to one file in a single call, pass edits as a JSON array of {oldText, newText, replaceAll} objects; they apply in order, and any failure aborts the whole call.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to edit, relative to the workspace root unless absolute paths are allowed.\",\n },\n oldText: {\n type: \"string\",\n description:\n \"Exact existing text to replace, for a single edit. Must match the file exactly and uniquely (include surrounding context) unless replaceAll is true.\",\n },\n newText: {\n type: \"string\",\n description: \"Text to replace oldText with, for a single edit.\",\n },\n replaceAll: {\n type: \"string\",\n description:\n 'Set to \"true\" to replace every occurrence of oldText instead of requiring a unique match. Defaults to \"false\".',\n enum: [\"true\", \"false\"],\n },\n edits: {\n type: \"string\",\n description:\n 'JSON array of edits to apply to this file in one call, e.g. [{\"oldText\":\"foo\",\"newText\":\"bar\"},{\"oldText\":\"baz\",\"newText\":\"qux\",\"replaceAll\":\"true\"}]. When provided, the top-level oldText/newText are ignored.',\n },\n },\n required: [\"path\"],\n },\n },\n run: async (args) => {\n const permissionError = options.canWrite?.(\"edit\") ?? null;\n if (permissionError) return permissionError;\n\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n const edits = parseEditOperations(args);\n\n return queueFileMutation(filePath, async () => {\n if (!fs.existsSync(filePath)) {\n throw new Error(`file not found: ${requestedPath}`);\n }\n const stat = fs.statSync(filePath);\n if (!stat.isFile()) {\n throw new Error(`${requestedPath} is not a file`);\n }\n\n let content = fs.readFileSync(filePath, \"utf8\");\n let replacements = 0;\n for (const edit of edits) {\n const count = countOccurrences(content, edit.oldText);\n if (count === 0) {\n throw new Error(\n `oldText was not found in ${requestedPath}: ${previewText(\n edit.oldText,\n )}`,\n );\n }\n if (!edit.replaceAll && count !== 1) {\n throw new Error(\n `oldText matched ${count} times in ${requestedPath}; make it unique or set replaceAll=true.`,\n );\n }\n content = edit.replaceAll\n ? content.split(edit.oldText).join(edit.newText)\n : content.replace(edit.oldText, edit.newText);\n replacements += edit.replaceAll ? count : 1;\n }\n\n fs.writeFileSync(filePath, content, \"utf8\");\n return `Edited ${path.relative(cwd, filePath) || requestedPath} (${replacements} replacement${replacements === 1 ? \"\" : \"s\"}).`;\n });\n },\n },\n write: {\n tool: {\n description:\n \"Create a new UTF-8 text file, or fully overwrite an existing one with the given content. Missing parent directories are created. For changes to an existing file, prefer edit; only use write when you intend to replace the entire file. Default to ASCII content unless the file already uses other characters or there is a clear reason not to.\",\n parameters: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description:\n \"Path to the file to write, relative to the workspace root unless absolute paths are allowed.\",\n },\n content: {\n type: \"string\",\n description:\n \"Full contents to write. This replaces the entire file; existing content is not preserved.\",\n },\n },\n required: [\"path\", \"content\"],\n },\n },\n run: async (args) => {\n const permissionError = options.canWrite?.(\"write\") ?? null;\n if (permissionError) return permissionError;\n\n const requestedPath = stringArg(args.path);\n const filePath = resolveCodingPath(cwd, requestedPath, {\n restrictToCwd,\n });\n if (!filePath) return \"Error: path must stay inside the workspace.\";\n const content = stringArg(args.content);\n\n return queueFileMutation(filePath, async () => {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n const existed = fs.existsSync(filePath);\n fs.writeFileSync(filePath, content, \"utf8\");\n const bytes = Buffer.byteLength(content, \"utf8\");\n const lines = content.split(\"\\n\").length;\n return `${existed ? \"Updated\" : \"Created\"} ${path.relative(cwd, filePath) || requestedPath} (${lines} lines, ${bytes} bytes).`;\n });\n },\n },\n };\n}\n\nexport async function runCodingCommand(\n command: string,\n cwd: string,\n timeoutMs: number,\n options: { stdin?: string } = {},\n): Promise<CodingCommandResult> {\n const child = spawn(command, {\n cwd,\n shell: true,\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n env: { ...process.env, FORCE_COLOR: \"0\" },\n });\n let stdout = \"\";\n let stderr = \"\";\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill(\"SIGTERM\");\n }, timeoutMs);\n child.stdout?.on(\"data\", (chunk) => {\n stdout += chunk.toString();\n });\n child.stderr?.on(\"data\", (chunk) => {\n stderr += chunk.toString();\n });\n if (options.stdin) child.stdin?.end(options.stdin);\n else child.stdin?.end();\n const code = await new Promise<number | null>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"exit\", resolve);\n });\n clearTimeout(timer);\n return { code, stdout, stderr, timedOut };\n}\n\nexport function formatCodingCommandResult(\n result: CodingCommandResult,\n maxChars = DEFAULT_MAX_OUTPUT_CHARS,\n options: { omitEmptyExitCode?: boolean } = {},\n): string {\n const parts = [\n options.omitEmptyExitCode && result.code === 0\n ? \"\"\n : `exitCode: ${result.code}`,\n result.timedOut ? \"timedOut: true\" : \"\",\n result.stdout ? `stdout:\\n${result.stdout}` : \"\",\n result.stderr ? `stderr:\\n${result.stderr}` : \"\",\n ].filter(Boolean);\n return truncateCodingOutput(parts.join(\"\\n\\n\") || \"(no output)\", maxChars);\n}\n\nexport function truncateCodingOutput(value: string, max: number): string {\n if (value.length <= max) return value;\n return `${value.slice(0, max)}\\n\\n...[truncated ${value.length - max} chars]`;\n}\n\nexport function isReadOnlyShellCommand(command: string): boolean {\n const normalized = command.trim().toLowerCase();\n if (!normalized) return false;\n\n // Read-only modes get a deliberately tiny shell grammar: one command only,\n // no redirection, pipes, sequencing, backgrounding, or command substitution.\n // Prefix allowlists are not safe until these shell forms are excluded.\n if (/[\\n\\r;&|<>]/.test(normalized)) return false;\n if (/\\$\\(|`|\\${|\\\\\\n/.test(command)) return false;\n\n // `sed` can WRITE even in `-n` mode via the `w`/`W` commands or `-i`\n // (e.g. `sed -n '1w out.txt' file`), so the `^sed -n` allowlist entry\n // below is not safe on its own. Reject any sed that can write.\n if (/^sed\\b/.test(normalized)) {\n if (/(^|\\s)-i(\\b|=)|--in-place/.test(normalized)) return false;\n // `w`/`W` used as a sed command: preceded by an address/separator\n // (digit, $, /, }, ;, quote, space) and followed by a filename arg or\n // end. Catches `1w f`, `$w f`, `/re/w f`, `s/x/y/w f`, `2W f`; leaves\n // prints like `/window/p`, `1,5p`, `s/a/b/` untouched.\n if (/[\\s'\"0-9$}/;](w|W)([\\s'\"]|$)/.test(normalized)) return false;\n }\n\n const allowedPrefixes = [\n /^pwd\\b/,\n /^ls\\b/,\n /^find\\b/,\n /^rg\\b/,\n /^grep\\b/,\n /^cat\\b/,\n /^sed\\s+-n\\b/,\n /^head\\b/,\n /^tail\\b/,\n /^wc\\b/,\n /^git\\s+(status|diff|show|log)\\b/,\n /^git\\s+branch\\s+--show-current\\b/,\n ];\n return allowedPrefixes.some((pattern) => pattern.test(normalized));\n}\n\nfunction resolveCodingPath(\n cwd: string,\n value: string,\n options: { restrictToCwd: boolean; allowEmpty?: boolean },\n): string | null {\n if (!value.trim() && !options.allowEmpty) return null;\n const target = value.trim() || \".\";\n const resolved = path.isAbsolute(target)\n ? path.resolve(target)\n : path.resolve(cwd, target);\n if (!options.restrictToCwd) return resolved;\n\n const relative = path.relative(cwd, resolved);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) return null;\n return resolved;\n}\n\nfunction formatFileReadOutput(\n cwd: string,\n filePath: string,\n content: string,\n args: Record<string, unknown>,\n): string {\n const lines = content.split(\"\\n\");\n const offset = positiveInteger(args.offset, 1);\n const limit = positiveInteger(args.limit, lines.length - offset + 1);\n const selected = lines.slice(offset - 1, offset - 1 + limit);\n const body = selected\n .map((line, index) => `${String(offset + index).padStart(5)} | ${line}`)\n .join(\"\\n\");\n return `${path.relative(cwd, filePath) || filePath} (${lines.length} lines)\\n${body}`;\n}\n\nfunction parseEditOperations(args: Record<string, unknown>): EditOperation[] {\n const editsJson = stringArg(args.edits);\n if (editsJson.trim()) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(editsJson);\n } catch (err) {\n throw new Error(\n `edits must be valid JSON: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n if (!Array.isArray(parsed) || parsed.length === 0) {\n throw new Error(\"edits must be a non-empty JSON array.\");\n }\n return parsed.map((edit, index) => {\n if (!edit || typeof edit !== \"object\") {\n throw new Error(`edits[${index}] must be an object.`);\n }\n return normalizeEditOperation(edit as Record<string, unknown>, index);\n });\n }\n\n return [normalizeEditOperation(args, 0)];\n}\n\nfunction normalizeEditOperation(\n edit: Record<string, unknown>,\n index: number,\n): EditOperation {\n const oldText = typeof edit.oldText === \"string\" ? edit.oldText : undefined;\n const newText = typeof edit.newText === \"string\" ? edit.newText : undefined;\n if (!oldText) {\n throw new Error(\n index === 0\n ? \"oldText is required and cannot be empty.\"\n : `edits[${index}].oldText is required and cannot be empty.`,\n );\n }\n if (newText === undefined) {\n throw new Error(\n index === 0\n ? \"newText is required.\"\n : `edits[${index}].newText is required.`,\n );\n }\n return {\n oldText,\n newText,\n replaceAll: stringArg(edit.replaceAll).toLowerCase() === \"true\",\n };\n}\n\nfunction countOccurrences(value: string, needle: string): number {\n let count = 0;\n let index = 0;\n while (true) {\n index = value.indexOf(needle, index);\n if (index === -1) return count;\n count += 1;\n index += needle.length;\n }\n}\n\nfunction queueFileMutation<T>(filePath: string, task: () => Promise<T> | T) {\n const previous = mutationQueues.get(filePath) ?? Promise.resolve();\n const next = previous.catch(() => undefined).then(task);\n let queued: Promise<unknown>;\n queued = next.finally(() => {\n if (mutationQueues.get(filePath) === queued)\n mutationQueues.delete(filePath);\n });\n mutationQueues.set(filePath, queued);\n return next;\n}\n\nfunction previewText(value: string): string {\n const oneLine = value.replace(/\\s+/g, \" \").trim();\n return oneLine.length > 80 ? `${oneLine.slice(0, 80)}...` : oneLine;\n}\n\nfunction stringArg(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction positiveInteger(value: unknown, fallback: number): number {\n const parsed = Number(value);\n return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : fallback;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-chat-plugin.d.ts","sourceRoot":"","sources":["../../src/server/agent-chat-plugin.ts"],"names":[],"mappings":"AAcA,OAAO,EAQL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAqBtC,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAEl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