@andorra-labs/code 0.1.12 → 0.1.14

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 (617) hide show
  1. package/dist/src/account-presentation.d.ts +1 -37
  2. package/dist/src/account-presentation.js +6 -43
  3. package/dist/src/activity.d.ts +0 -25
  4. package/dist/src/activity.js +1 -23
  5. package/dist/src/agent-definitions.d.ts +0 -26
  6. package/dist/src/agent-definitions.js +0 -43
  7. package/dist/src/agent-execution.d.ts +0 -2
  8. package/dist/src/agent-execution.js +347 -554
  9. package/dist/src/agent-mcp-catalog.d.ts +0 -8
  10. package/dist/src/agent-mcp-catalog.js +0 -2
  11. package/dist/src/agent-mcp.d.ts +0 -56
  12. package/dist/src/agent-mcp.js +11 -155
  13. package/dist/src/agent-modifiers.d.ts +0 -1
  14. package/dist/src/agent-modifiers.js +25 -68
  15. package/dist/src/analytics.d.ts +0 -66
  16. package/dist/src/analytics.js +0 -45
  17. package/dist/src/andorra/endpoint.d.ts +7 -0
  18. package/dist/src/andorra/endpoint.js +46 -0
  19. package/dist/src/andorra/entry.d.ts +21 -0
  20. package/dist/src/andorra/entry.js +100 -0
  21. package/dist/src/andorra/errors.d.ts +2 -0
  22. package/dist/src/andorra/errors.js +39 -0
  23. package/dist/src/andorra/hosted.d.ts +52 -0
  24. package/dist/src/andorra/hosted.js +126 -0
  25. package/dist/src/andorra/monitor.d.ts +151 -0
  26. package/dist/src/andorra/monitor.js +393 -0
  27. package/dist/src/andorra/notices.d.ts +7 -0
  28. package/dist/src/andorra/notices.js +15 -0
  29. package/dist/src/andorra/opt-in.d.ts +58 -0
  30. package/dist/src/andorra/opt-in.js +112 -0
  31. package/dist/src/andorra/request-watch.d.ts +6 -0
  32. package/dist/src/andorra/request-watch.js +10 -0
  33. package/dist/src/andorra/state.d.ts +86 -0
  34. package/dist/src/andorra/state.js +238 -0
  35. package/dist/src/andorra/terminal.d.ts +68 -0
  36. package/dist/src/andorra/terminal.js +125 -0
  37. package/dist/src/andorra/usage-format.d.ts +9 -0
  38. package/dist/src/andorra/usage-format.js +19 -0
  39. package/dist/src/anthropic-console-auth.d.ts +0 -24
  40. package/dist/src/anthropic-console-auth.js +0 -37
  41. package/dist/src/anthropic-credentials.d.ts +0 -25
  42. package/dist/src/anthropic-credentials.js +9 -29
  43. package/dist/src/app-server/protocol.d.ts +18 -246
  44. package/dist/src/app-server/protocol.js +1 -132
  45. package/dist/src/app-server/reasoning.d.ts +0 -31
  46. package/dist/src/app-server/reasoning.js +0 -54
  47. package/dist/src/app-server/terminal.d.ts +0 -36
  48. package/dist/src/app-server/terminal.js +3 -39
  49. package/dist/src/app-server/workspace.d.ts +0 -167
  50. package/dist/src/app-server/workspace.js +4 -406
  51. package/dist/src/app-server.d.ts +52 -925
  52. package/dist/src/app-server.js +828 -3076
  53. package/dist/src/artifacts.d.ts +0 -10
  54. package/dist/src/artifacts.js +1 -11
  55. package/dist/src/attachments.d.ts +4 -98
  56. package/dist/src/attachments.js +10 -130
  57. package/dist/src/auth/AuthManager.d.ts +9 -93
  58. package/dist/src/auth/AuthManager.js +164 -186
  59. package/dist/src/auth/callback-page.d.ts +0 -1
  60. package/dist/src/auth/callback-page.js +0 -4
  61. package/dist/src/auth/callback.d.ts +0 -25
  62. package/dist/src/auth/callback.js +1 -29
  63. package/dist/src/auth/deployment.d.ts +1 -16
  64. package/dist/src/auth/deployment.js +1 -16
  65. package/dist/src/auth/index.d.ts +1 -12
  66. package/dist/src/auth/index.js +1 -12
  67. package/dist/src/auth/lock.d.ts +0 -1
  68. package/dist/src/auth/lock.js +0 -1
  69. package/dist/src/auth/store.d.ts +33 -108
  70. package/dist/src/auth/store.js +55 -130
  71. package/dist/src/auth/types.d.ts +0 -8
  72. package/dist/src/auth-commands.d.ts +0 -5
  73. package/dist/src/auth-commands.js +0 -1
  74. package/dist/src/automation-runner.d.ts +0 -9
  75. package/dist/src/automation-runner.js +0 -11
  76. package/dist/src/automation-service.d.ts +0 -10
  77. package/dist/src/automation-service.js +3 -17
  78. package/dist/src/automation-tool.js +0 -5
  79. package/dist/src/automation-worker-shutdown.d.ts +0 -1
  80. package/dist/src/automation-worker-shutdown.js +0 -3
  81. package/dist/src/automations.d.ts +23 -2
  82. package/dist/src/automations.js +91 -12
  83. package/dist/src/background-tasks.d.ts +0 -23
  84. package/dist/src/background-tasks.js +0 -11
  85. package/dist/src/boot-trace.d.ts +0 -13
  86. package/dist/src/boot-trace.js +1 -14
  87. package/dist/src/browser-activity.js +0 -2
  88. package/dist/src/browser-bridge.d.ts +0 -2
  89. package/dist/src/browser-bridge.js +0 -27
  90. package/dist/src/browser-captcha-tool.d.ts +0 -13
  91. package/dist/src/browser-captcha-tool.js +3 -35
  92. package/dist/src/browser-extensions-tool.d.ts +24 -0
  93. package/dist/src/browser-extensions-tool.js +137 -0
  94. package/dist/src/browser-extensions.d.ts +127 -0
  95. package/dist/src/browser-extensions.js +729 -0
  96. package/dist/src/browser-observation.d.ts +0 -15
  97. package/dist/src/browser-observation.js +1 -22
  98. package/dist/src/browser-panel-tool.d.ts +1 -37
  99. package/dist/src/browser-panel-tool.js +3 -73
  100. package/dist/src/browser-runner.d.ts +0 -1
  101. package/dist/src/browser-runner.js +5 -46
  102. package/dist/src/browser-server.d.ts +0 -6
  103. package/dist/src/browser-server.js +6 -229
  104. package/dist/src/browser-session.d.ts +0 -25
  105. package/dist/src/browser-session.js +1 -71
  106. package/dist/src/browser-stealth.d.ts +19 -13
  107. package/dist/src/browser-stealth.js +22 -38
  108. package/dist/src/browser-ui/app.js +7 -174
  109. package/dist/src/browser-ui/style.css +0 -68
  110. package/dist/src/browser-ui/tokens.css +15 -97
  111. package/dist/src/browser-view.d.ts +106 -295
  112. package/dist/src/browser-view.js +551 -587
  113. package/dist/src/capabilities.d.ts +0 -8
  114. package/dist/src/capabilities.js +0 -29
  115. package/dist/src/capsolver.d.ts +0 -13
  116. package/dist/src/capsolver.js +0 -15
  117. package/dist/src/clarification-ui.d.ts +0 -7
  118. package/dist/src/clarification-ui.js +0 -8
  119. package/dist/src/claude-executable.d.ts +0 -1
  120. package/dist/src/claude-executable.js +1 -2
  121. package/dist/src/claude-provider.d.ts +6 -19
  122. package/dist/src/claude-provider.js +155 -63
  123. package/dist/src/cli-executable.d.ts +0 -16
  124. package/dist/src/cli-executable.js +0 -7
  125. package/dist/src/cli-process.d.ts +0 -26
  126. package/dist/src/cli-process.js +0 -18
  127. package/dist/src/cli-sign-in.d.ts +0 -20
  128. package/dist/src/cli-sign-in.js +1 -17
  129. package/dist/src/cli.d.ts +1 -55
  130. package/dist/src/cli.js +118 -742
  131. package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
  132. package/dist/src/code-intelligence/CodeIntelligenceManager.js +26 -99
  133. package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
  134. package/dist/src/code-intelligence/ContextLedger.js +0 -10
  135. package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
  136. package/dist/src/code-intelligence/ContextRouter.js +0 -8
  137. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
  138. package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
  139. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
  140. package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
  141. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
  142. package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
  143. package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
  144. package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
  145. package/dist/src/code-intelligence/repository.d.ts +0 -9
  146. package/dist/src/code-intelligence/repository.js +1 -11
  147. package/dist/src/code-intelligence/types.d.ts +0 -8
  148. package/dist/src/codex-auth.d.ts +0 -44
  149. package/dist/src/codex-auth.js +0 -45
  150. package/dist/src/codex-browser-auth.d.ts +0 -13
  151. package/dist/src/codex-browser-auth.js +3 -20
  152. package/dist/src/codex-errors.js +0 -2
  153. package/dist/src/codex-executable.d.ts +0 -2
  154. package/dist/src/codex-executable.js +1 -7
  155. package/dist/src/codex-provider.d.ts +0 -13
  156. package/dist/src/codex-provider.js +0 -28
  157. package/dist/src/codex-rpc.d.ts +0 -10
  158. package/dist/src/codex-rpc.js +0 -12
  159. package/dist/src/coding-tools.d.ts +4 -26
  160. package/dist/src/coding-tools.js +161 -181
  161. package/dist/src/command-metrics.d.ts +0 -4
  162. package/dist/src/command-output-tap.d.ts +0 -11
  163. package/dist/src/command-output-tap.js +0 -3
  164. package/dist/src/command-screens.d.ts +41 -1
  165. package/dist/src/command-screens.js +316 -113
  166. package/dist/src/commands.d.ts +12 -63
  167. package/dist/src/commands.js +98 -127
  168. package/dist/src/completion-gates.d.ts +0 -47
  169. package/dist/src/completion-gates.js +0 -14
  170. package/dist/src/completion.d.ts +0 -98
  171. package/dist/src/completion.js +2 -239
  172. package/dist/src/config.d.ts +15 -115
  173. package/dist/src/config.js +123 -172
  174. package/dist/src/context-budget.d.ts +0 -22
  175. package/dist/src/context-budget.js +0 -44
  176. package/dist/src/context-compaction.d.ts +29 -6
  177. package/dist/src/context-compaction.js +94 -25
  178. package/dist/src/context-selection.d.ts +0 -24
  179. package/dist/src/context-selection.js +0 -34
  180. package/dist/src/dashboard-view.d.ts +2 -2
  181. package/dist/src/dashboard-view.js +11 -37
  182. package/dist/src/dashboard.d.ts +0 -2
  183. package/dist/src/dashboard.js +0 -9
  184. package/dist/src/deadline.d.ts +0 -45
  185. package/dist/src/deadline.js +0 -54
  186. package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
  187. package/dist/src/decision/ContinuationAdapter.js +0 -5
  188. package/dist/src/decision/DecisionEngine.d.ts +0 -4
  189. package/dist/src/decision/DecisionManager.d.ts +0 -1
  190. package/dist/src/decision/DecisionManager.js +2 -7
  191. package/dist/src/decision/DecisionPolicy.d.ts +0 -1
  192. package/dist/src/decision/DecisionPolicy.js +0 -1
  193. package/dist/src/decision/FactContinuations.d.ts +11 -43
  194. package/dist/src/decision/FactContinuations.js +126 -95
  195. package/dist/src/decision/FactServiceGate.d.ts +0 -1
  196. package/dist/src/decision/FactServiceGate.js +0 -4
  197. package/dist/src/decision/PreparedSteps.d.ts +0 -15
  198. package/dist/src/decision/PreparedSteps.js +1 -11
  199. package/dist/src/decision/applyToolMenu.d.ts +0 -1
  200. package/dist/src/decision/applyToolMenu.js +2 -6
  201. package/dist/src/decision/checks.d.ts +15 -28
  202. package/dist/src/decision/checks.js +118 -49
  203. package/dist/src/decision/facts.d.ts +0 -16
  204. package/dist/src/decision/facts.js +0 -30
  205. package/dist/src/decision/guidancePolicy.js +0 -1
  206. package/dist/src/decision/hostedPolicy.d.ts +0 -6
  207. package/dist/src/decision/hostedPolicy.js +0 -7
  208. package/dist/src/decision/hostedSkills.d.ts +0 -19
  209. package/dist/src/decision/hostedSkills.js +0 -19
  210. package/dist/src/decision/optimizationPolicy.d.ts +0 -3
  211. package/dist/src/decision/optimizationPolicy.js +1 -4
  212. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
  213. package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
  214. package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
  215. package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
  216. package/dist/src/decision/routeTools.d.ts +0 -8
  217. package/dist/src/decision/routeTools.js +1 -8
  218. package/dist/src/decision/toolFamilies.d.ts +0 -1
  219. package/dist/src/decision/toolFamilies.js +1 -2
  220. package/dist/src/decision/toolMenu.d.ts +0 -3
  221. package/dist/src/decision/toolMenu.js +0 -4
  222. package/dist/src/decision/types.d.ts +1 -6
  223. package/dist/src/default-graph.d.ts +0 -9
  224. package/dist/src/default-graph.js +0 -9
  225. package/dist/src/delegation-changes.d.ts +0 -56
  226. package/dist/src/delegation-changes.js +4 -130
  227. package/dist/src/diff-preview.d.ts +0 -1
  228. package/dist/src/diff-preview.js +0 -17
  229. package/dist/src/duration.d.ts +0 -50
  230. package/dist/src/duration.js +0 -50
  231. package/dist/src/efficiency.d.ts +0 -39
  232. package/dist/src/efficiency.js +0 -16
  233. package/dist/src/engine/protocol.d.ts +0 -2
  234. package/dist/src/engine/protocol.js +0 -2
  235. package/dist/src/engine-streams.d.ts +0 -9
  236. package/dist/src/extensions.d.ts +3 -2
  237. package/dist/src/extensions.js +63 -35
  238. package/dist/src/favicons.d.ts +0 -26
  239. package/dist/src/favicons.js +0 -34
  240. package/dist/src/file-diff.d.ts +2 -58
  241. package/dist/src/file-diff.js +0 -32
  242. package/dist/src/file-read-key.d.ts +0 -7
  243. package/dist/src/file-read-key.js +0 -7
  244. package/dist/src/file-read-state.d.ts +0 -1
  245. package/dist/src/file-read-state.js +0 -4
  246. package/dist/src/firefox-cookies.d.ts +0 -34
  247. package/dist/src/firefox-cookies.js +1 -55
  248. package/dist/src/git-identity-audit.d.ts +27 -0
  249. package/dist/src/git-identity-audit.js +286 -0
  250. package/dist/src/git-identity-guard.d.ts +4 -0
  251. package/dist/src/git-identity-guard.js +998 -0
  252. package/dist/src/git-identity-hold.d.ts +12 -0
  253. package/dist/src/git-identity-hold.js +81 -0
  254. package/dist/src/git-summary.d.ts +0 -58
  255. package/dist/src/git-summary.js +2 -212
  256. package/dist/src/goal-completion-verification.d.ts +2 -2
  257. package/dist/src/goal-completion-verification.js +3 -6
  258. package/dist/src/graph-account.d.ts +0 -21
  259. package/dist/src/graph-account.js +0 -17
  260. package/dist/src/graph-editor-session.d.ts +0 -1
  261. package/dist/src/graph-editor-session.js +0 -3
  262. package/dist/src/graph-health.d.ts +9 -61
  263. package/dist/src/graph-health.js +34 -59
  264. package/dist/src/graph-manager-chat.d.ts +36 -153
  265. package/dist/src/graph-manager-chat.js +161 -182
  266. package/dist/src/graph-provider-portability.d.ts +1 -21
  267. package/dist/src/graph-provider-portability.js +6 -45
  268. package/dist/src/graph-quota.d.ts +0 -33
  269. package/dist/src/graph-quota.js +1 -44
  270. package/dist/src/graph-runner.d.ts +0 -1
  271. package/dist/src/graph-runner.js +58 -391
  272. package/dist/src/graph-selection.d.ts +0 -14
  273. package/dist/src/graph-selection.js +2 -15
  274. package/dist/src/graph-server.d.ts +2 -10
  275. package/dist/src/graph-server.js +39 -101
  276. package/dist/src/graph-studio-features.d.ts +0 -5
  277. package/dist/src/graph-studio-features.js +2 -42
  278. package/dist/src/graph-sync.d.ts +0 -78
  279. package/dist/src/graph-sync.js +5 -201
  280. package/dist/src/graph-tool.d.ts +0 -18
  281. package/dist/src/graph-tool.js +0 -27
  282. package/dist/src/graph-ui/app.js +176 -492
  283. package/dist/src/graph-ui/compat.js +0 -7
  284. package/dist/src/graph-ui/controls.css +0 -48
  285. package/dist/src/graph-ui/controls.js +0 -88
  286. package/dist/src/graph-ui/drafts.js +0 -12
  287. package/dist/src/graph-ui/edge-router.js +0 -62
  288. package/dist/src/graph-ui/embed.js +0 -59
  289. package/dist/src/graph-ui/icons.js +0 -8
  290. package/dist/src/graph-ui/library.css +0 -5
  291. package/dist/src/graph-ui/manager-markdown.js +0 -11
  292. package/dist/src/graph-ui/manager-state.js +1 -78
  293. package/dist/src/graph-ui/manager.css +0 -18
  294. package/dist/src/graph-ui/manager.js +43 -185
  295. package/dist/src/graph-ui/model-picker.js +0 -29
  296. package/dist/src/graph-ui/sidebar.js +2 -3
  297. package/dist/src/graph-ui/skill-picker.js +373 -39
  298. package/dist/src/graph-ui/studio-canvas.js +3 -38
  299. package/dist/src/graph-ui/studio.css +0 -18
  300. package/dist/src/graph-ui/studio.js +3 -71
  301. package/dist/src/graph-ui/style.css +16 -136
  302. package/dist/src/graph-ui/theme.js +1 -26
  303. package/dist/src/graph-ui/tokens.css +19 -118
  304. package/dist/src/graphs.d.ts +6 -157
  305. package/dist/src/graphs.js +66 -269
  306. package/dist/src/grep-regex-worker.js +0 -2
  307. package/dist/src/grep-regex.d.ts +1 -5
  308. package/dist/src/grep-regex.js +6 -8
  309. package/dist/src/grok-provider.d.ts +0 -17
  310. package/dist/src/grok-provider.js +1 -26
  311. package/dist/src/handoffs.d.ts +0 -11
  312. package/dist/src/handoffs.js +0 -13
  313. package/dist/src/hardened-runtime.d.ts +0 -10
  314. package/dist/src/hardened-runtime.js +9 -47
  315. package/dist/src/harness-home.d.ts +21 -0
  316. package/dist/src/harness-home.js +87 -0
  317. package/dist/src/host-process-guard.d.ts +0 -50
  318. package/dist/src/host-process-guard.js +0 -641
  319. package/dist/src/limits.d.ts +0 -64
  320. package/dist/src/limits.js +0 -62
  321. package/dist/src/managed-sign-in.d.ts +0 -12
  322. package/dist/src/managed-sign-in.js +0 -16
  323. package/dist/src/markdown.d.ts +0 -28
  324. package/dist/src/markdown.js +1 -175
  325. package/dist/src/mcp.d.ts +0 -99
  326. package/dist/src/mcp.js +4 -170
  327. package/dist/src/membership-errors.d.ts +0 -14
  328. package/dist/src/membership-errors.js +1 -14
  329. package/dist/src/membership.d.ts +9 -59
  330. package/dist/src/membership.js +20 -91
  331. package/dist/src/memory/LocalToolMemory.d.ts +0 -1
  332. package/dist/src/memory/LocalToolMemory.js +2 -7
  333. package/dist/src/memory/MemoryDistiller.js +0 -15
  334. package/dist/src/memory/MemoryManager.d.ts +0 -3
  335. package/dist/src/memory/MemoryManager.js +6 -18
  336. package/dist/src/memory/MemoryPolicy.d.ts +0 -2
  337. package/dist/src/memory/MemoryPolicy.js +0 -2
  338. package/dist/src/memory/MemoryProvider.d.ts +0 -6
  339. package/dist/src/memory/MemoryRetriever.js +0 -7
  340. package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
  341. package/dist/src/memory/PermissionMemoryProvider.js +0 -1
  342. package/dist/src/memory/ProjectMemory.d.ts +5 -40
  343. package/dist/src/memory/ProjectMemory.js +22 -47
  344. package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
  345. package/dist/src/memory/ToolFailureLessons.js +0 -6
  346. package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
  347. package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
  348. package/dist/src/memory/redaction.d.ts +0 -5
  349. package/dist/src/memory/redaction.js +0 -11
  350. package/dist/src/memory/repository.d.ts +0 -6
  351. package/dist/src/memory/repository.js +2 -12
  352. package/dist/src/memory/types.d.ts +0 -1
  353. package/dist/src/model-context-windows.d.ts +2 -0
  354. package/dist/src/model-context-windows.js +24 -0
  355. package/dist/src/model-health-cache.d.ts +0 -38
  356. package/dist/src/model-health-cache.js +2 -50
  357. package/dist/src/model-metadata.d.ts +1 -18
  358. package/dist/src/model-metadata.js +42 -45
  359. package/dist/src/model-override.d.ts +0 -36
  360. package/dist/src/model-override.js +0 -43
  361. package/dist/src/model-tiers.d.ts +0 -13
  362. package/dist/src/model-tiers.js +0 -23
  363. package/dist/src/opencode-catalog.d.ts +0 -2
  364. package/dist/src/opencode-catalog.js +0 -11
  365. package/dist/src/opencode-cli-provider.d.ts +0 -35
  366. package/dist/src/opencode-cli-provider.js +1 -44
  367. package/dist/src/opencode-provider.d.ts +0 -2
  368. package/dist/src/opencode-provider.js +1 -16
  369. package/dist/src/package-name.d.ts +0 -2
  370. package/dist/src/package-name.js +0 -2
  371. package/dist/src/paged-transcript.d.ts +0 -11
  372. package/dist/src/paged-transcript.js +2 -20
  373. package/dist/src/palette.d.ts +1 -63
  374. package/dist/src/palette.js +1 -64
  375. package/dist/src/permissions.d.ts +0 -15
  376. package/dist/src/permissions.js +17 -21
  377. package/dist/src/powershell-pool.d.ts +0 -9
  378. package/dist/src/powershell-pool.js +3 -26
  379. package/dist/src/process-warnings.d.ts +4 -0
  380. package/dist/src/process-warnings.js +103 -0
  381. package/dist/src/profile.d.ts +0 -43
  382. package/dist/src/profile.js +0 -43
  383. package/dist/src/project-reservation.d.ts +11 -0
  384. package/dist/src/project-reservation.js +143 -0
  385. package/dist/src/provider-connection.d.ts +0 -18
  386. package/dist/src/provider-connection.js +15 -39
  387. package/dist/src/provider-engine.d.ts +0 -21
  388. package/dist/src/provider-engine.js +1 -96
  389. package/dist/src/provider-import.d.ts +0 -49
  390. package/dist/src/provider-import.js +0 -60
  391. package/dist/src/provider-keys.d.ts +1 -36
  392. package/dist/src/provider-keys.js +5 -48
  393. package/dist/src/provider-settings.d.ts +16 -3
  394. package/dist/src/provider-settings.js +36 -52
  395. package/dist/src/providers.d.ts +14 -219
  396. package/dist/src/providers.js +69 -326
  397. package/dist/src/pull-requests.d.ts +0 -173
  398. package/dist/src/pull-requests.js +5 -195
  399. package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
  400. package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
  401. package/dist/src/qa/command-policy.d.ts +0 -23
  402. package/dist/src/qa/command-policy.js +0 -30
  403. package/dist/src/qa/guidance.d.ts +0 -21
  404. package/dist/src/qa/guidance.js +0 -20
  405. package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
  406. package/dist/src/qa/profile/ProjectInspector.js +0 -6
  407. package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
  408. package/dist/src/qa/profile/QaConfigLoader.js +0 -6
  409. package/dist/src/qa/profile/QaProfile.d.ts +0 -7
  410. package/dist/src/qa/profile/QaProfile.js +0 -7
  411. package/dist/src/qa/profile/yaml.d.ts +0 -9
  412. package/dist/src/qa/profile/yaml.js +0 -13
  413. package/dist/src/qa/qa-authorize.d.ts +0 -19
  414. package/dist/src/qa/qa-authorize.js +4 -11
  415. package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
  416. package/dist/src/qa/runtime/ProcessManager.js +4 -41
  417. package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
  418. package/dist/src/qa/runtime/PtyManager.js +1 -7
  419. package/dist/src/qa/runtime/changes.d.ts +0 -11
  420. package/dist/src/qa/runtime/changes.js +1 -3
  421. package/dist/src/qa/tools.d.ts +0 -10
  422. package/dist/src/qa/tools.js +0 -12
  423. package/dist/src/qa/types.d.ts +0 -13
  424. package/dist/src/react-runtime.d.ts +2 -21
  425. package/dist/src/react-runtime.js +107 -422
  426. package/dist/src/read-document-doc.d.ts +0 -6
  427. package/dist/src/read-document-doc.js +0 -55
  428. package/dist/src/read-document-docx.d.ts +0 -16
  429. package/dist/src/read-document-docx.js +2 -69
  430. package/dist/src/read-document-text.d.ts +0 -17
  431. package/dist/src/read-document-text.js +0 -22
  432. package/dist/src/read-document-tool.d.ts +0 -31
  433. package/dist/src/read-document-tool.js +0 -30
  434. package/dist/src/read-document.d.ts +0 -49
  435. package/dist/src/read-document.js +1 -67
  436. package/dist/src/read-image.d.ts +0 -32
  437. package/dist/src/read-image.js +0 -33
  438. package/dist/src/remote/cert.d.ts +0 -18
  439. package/dist/src/remote/cert.js +0 -44
  440. package/dist/src/remote/client.d.ts +0 -70
  441. package/dist/src/remote/client.js +1 -116
  442. package/dist/src/remote/command.js +0 -17
  443. package/dist/src/remote/engine-pool.d.ts +0 -152
  444. package/dist/src/remote/engine-pool.js +22 -339
  445. package/dist/src/remote/errors.d.ts +0 -15
  446. package/dist/src/remote/errors.js +0 -7
  447. package/dist/src/remote/network.d.ts +0 -26
  448. package/dist/src/remote/network.js +1 -34
  449. package/dist/src/remote/pairing.d.ts +16 -51
  450. package/dist/src/remote/pairing.js +50 -57
  451. package/dist/src/remote/pem.d.ts +0 -4
  452. package/dist/src/remote/pem.js +0 -4
  453. package/dist/src/remote/roots.d.ts +0 -20
  454. package/dist/src/remote/roots.js +0 -8
  455. package/dist/src/remote/serve.d.ts +0 -47
  456. package/dist/src/remote/serve.js +0 -30
  457. package/dist/src/remote/server.d.ts +0 -14
  458. package/dist/src/remote/server.js +1 -79
  459. package/dist/src/remote/types.d.ts +1 -32
  460. package/dist/src/remote/types.js +0 -10
  461. package/dist/src/run-control.d.ts +2 -9
  462. package/dist/src/run-control.js +9 -13
  463. package/dist/src/run-progress.d.ts +0 -170
  464. package/dist/src/run-progress.js +0 -285
  465. package/dist/src/run-records.d.ts +0 -443
  466. package/dist/src/run-records.js +14 -687
  467. package/dist/src/run-temp.d.ts +12 -0
  468. package/dist/src/run-temp.js +50 -0
  469. package/dist/src/runtime.d.ts +12 -228
  470. package/dist/src/runtime.js +2 -128
  471. package/dist/src/sandbox-child.js +0 -1
  472. package/dist/src/save-lock.d.ts +0 -12
  473. package/dist/src/save-lock.js +0 -28
  474. package/dist/src/screen-selection.d.ts +0 -23
  475. package/dist/src/screen-selection.js +0 -22
  476. package/dist/src/secret-redaction.d.ts +0 -12
  477. package/dist/src/secret-redaction.js +0 -45
  478. package/dist/src/session-changes.d.ts +4 -80
  479. package/dist/src/session-changes.js +25 -130
  480. package/dist/src/session-goal.d.ts +129 -0
  481. package/dist/src/session-goal.js +230 -0
  482. package/dist/src/session-monitor.d.ts +1 -10
  483. package/dist/src/session-monitor.js +2 -39
  484. package/dist/src/session-reaper.d.ts +0 -15
  485. package/dist/src/session-reaper.js +0 -14
  486. package/dist/src/session-skills.d.ts +15 -44
  487. package/dist/src/session-skills.js +75 -60
  488. package/dist/src/session-summary.d.ts +0 -26
  489. package/dist/src/session-summary.js +0 -32
  490. package/dist/src/session-title.d.ts +0 -1
  491. package/dist/src/session-title.js +0 -2
  492. package/dist/src/sessions.d.ts +3 -122
  493. package/dist/src/sessions.js +9 -178
  494. package/dist/src/shell.d.ts +3 -20
  495. package/dist/src/shell.js +8 -72
  496. package/dist/src/side-panel.d.ts +5 -99
  497. package/dist/src/side-panel.js +76 -133
  498. package/dist/src/sign-in-detection.d.ts +0 -39
  499. package/dist/src/sign-in-detection.js +0 -43
  500. package/dist/src/sign-in-offer.d.ts +1 -19
  501. package/dist/src/sign-in-offer.js +0 -13
  502. package/dist/src/skill-commands.d.ts +0 -1
  503. package/dist/src/skill-commands.js +1 -4
  504. package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
  505. package/dist/src/skills/bundled/graph-manager/errors.md +1 -1
  506. package/dist/src/skills/bundled/provenance.json +738 -738
  507. package/dist/src/skills/invocable-skills.d.ts +0 -18
  508. package/dist/src/skills/invocable-skills.js +0 -17
  509. package/dist/src/skills/project-skills.d.ts +0 -1
  510. package/dist/src/skills/project-skills.js +0 -3
  511. package/dist/src/skills/prompt-skills.js +0 -14
  512. package/dist/src/skills/runtime-skills.d.ts +0 -13
  513. package/dist/src/skills/runtime-skills.js +0 -37
  514. package/dist/src/stall-recovery.d.ts +0 -25
  515. package/dist/src/stall-recovery.js +0 -38
  516. package/dist/src/stray-files.d.ts +0 -9
  517. package/dist/src/stray-files.js +0 -16
  518. package/dist/src/structured-step.d.ts +0 -22
  519. package/dist/src/structured-step.js +0 -22
  520. package/dist/src/subagent-run.d.ts +2 -163
  521. package/dist/src/subagent-run.js +18 -376
  522. package/dist/src/subagent-tree.d.ts +32 -0
  523. package/dist/src/subagent-tree.js +128 -0
  524. package/dist/src/telemetry/aggregate.d.ts +0 -37
  525. package/dist/src/telemetry/aggregate.js +0 -40
  526. package/dist/src/telemetry/capture-core.d.ts +0 -87
  527. package/dist/src/telemetry/capture-core.js +0 -67
  528. package/dist/src/telemetry/capture.d.ts +0 -1
  529. package/dist/src/telemetry/capture.js +0 -3
  530. package/dist/src/telemetry/classify.d.ts +0 -58
  531. package/dist/src/telemetry/classify.js +0 -60
  532. package/dist/src/telemetry/decision-capture.d.ts +0 -1
  533. package/dist/src/telemetry/emitter.d.ts +0 -30
  534. package/dist/src/telemetry/emitter.js +1 -62
  535. package/dist/src/telemetry/gate.d.ts +0 -29
  536. package/dist/src/telemetry/gate.js +0 -22
  537. package/dist/src/telemetry/identity.d.ts +0 -13
  538. package/dist/src/telemetry/identity.js +0 -29
  539. package/dist/src/telemetry/outbox.d.ts +0 -64
  540. package/dist/src/telemetry/outbox.js +1 -108
  541. package/dist/src/telemetry/schema.d.ts +1 -49
  542. package/dist/src/telemetry/schema.js +3 -84
  543. package/dist/src/telemetry/state.d.ts +0 -53
  544. package/dist/src/telemetry/state.js +0 -64
  545. package/dist/src/telemetry/surface.d.ts +0 -31
  546. package/dist/src/telemetry/surface.js +1 -39
  547. package/dist/src/telemetry/uploader.d.ts +0 -11
  548. package/dist/src/telemetry/uploader.js +0 -46
  549. package/dist/src/telemetry/uploads.d.ts +0 -11
  550. package/dist/src/telemetry/uploads.js +0 -11
  551. package/dist/src/telemetry/version.d.ts +0 -4
  552. package/dist/src/telemetry/version.js +0 -14
  553. package/dist/src/telemetry/workspace.d.ts +0 -7
  554. package/dist/src/telemetry/workspace.js +1 -22
  555. package/dist/src/terminal-ui.d.ts +33 -521
  556. package/dist/src/terminal-ui.js +145 -884
  557. package/dist/src/test-edit-guard.d.ts +74 -0
  558. package/dist/src/test-edit-guard.js +269 -0
  559. package/dist/src/text.d.ts +0 -1
  560. package/dist/src/text.js +0 -1
  561. package/dist/src/time-limit.d.ts +0 -36
  562. package/dist/src/time-limit.js +0 -37
  563. package/dist/src/timers.d.ts +0 -161
  564. package/dist/src/timers.js +0 -126
  565. package/dist/src/todos.d.ts +0 -1
  566. package/dist/src/todos.js +0 -3
  567. package/dist/src/token-rate.d.ts +0 -94
  568. package/dist/src/token-rate.js +0 -154
  569. package/dist/src/tool-activity.d.ts +0 -6
  570. package/dist/src/tool-activity.js +0 -7
  571. package/dist/src/tool-availability.d.ts +0 -13
  572. package/dist/src/tool-availability.js +1 -14
  573. package/dist/src/tool-call-clock.d.ts +1 -4
  574. package/dist/src/tool-call-clock.js +0 -13
  575. package/dist/src/tool-catalog.d.ts +0 -11
  576. package/dist/src/tool-catalog.js +0 -23
  577. package/dist/src/tool-dependencies.d.ts +0 -5
  578. package/dist/src/tool-dependencies.js +0 -4
  579. package/dist/src/tool-diff-stats.d.ts +0 -23
  580. package/dist/src/tool-diff-stats.js +0 -49
  581. package/dist/src/tool-errors.d.ts +9 -7
  582. package/dist/src/tool-errors.js +13 -6
  583. package/dist/src/tool-failure-tracker.d.ts +3 -11
  584. package/dist/src/tool-failure-tracker.js +19 -27
  585. package/dist/src/tool-names.d.ts +0 -16
  586. package/dist/src/tool-names.js +0 -12
  587. package/dist/src/tool-profile.d.ts +6 -0
  588. package/dist/src/tool-profile.js +23 -0
  589. package/dist/src/tool-result-filter.d.ts +0 -19
  590. package/dist/src/tool-result-filter.js +1 -66
  591. package/dist/src/tool-schema-compatibility.d.ts +0 -6
  592. package/dist/src/tool-schema-compatibility.js +0 -9
  593. package/dist/src/tools.d.ts +0 -4
  594. package/dist/src/tools.js +11 -114
  595. package/dist/src/trajectory.d.ts +0 -13
  596. package/dist/src/trajectory.js +23 -79
  597. package/dist/src/transcript.d.ts +0 -41
  598. package/dist/src/transcript.js +5 -60
  599. package/dist/src/types.d.ts +4 -168
  600. package/dist/src/untracked-file-removal.js +0 -20
  601. package/dist/src/update-check.d.ts +0 -14
  602. package/dist/src/update-check.js +1 -15
  603. package/dist/src/update.d.ts +0 -35
  604. package/dist/src/update.js +0 -100
  605. package/dist/src/usage-analytics.d.ts +17 -17
  606. package/dist/src/usage-analytics.js +168 -209
  607. package/dist/src/web-search.d.ts +0 -23
  608. package/dist/src/web-search.js +1 -27
  609. package/dist/src/widgets.d.ts +0 -25
  610. package/dist/src/widgets.js +0 -24
  611. package/dist/src/workspace-facts.d.ts +0 -12
  612. package/dist/src/workspace-facts.js +1 -18
  613. package/dist/src/workspace-git-metadata.d.ts +0 -16
  614. package/dist/src/workspace-git-metadata.js +0 -21
  615. package/dist/src/workspace-instructions.d.ts +3 -15
  616. package/dist/src/workspace-instructions.js +6 -19
  617. package/package.json +13 -2
@@ -13,42 +13,45 @@ import { commandTimingSummary } from './command-metrics.js';
13
13
  import { runPooledPowerShell } from './powershell-pool.js';
14
14
  import { withStrayFileNotice } from './stray-files.js';
15
15
  import { assertNotHostKill, assertNotHostKillArgv, hostShellOf } from './host-process-guard.js';
16
+ import { assertNotGitIdentityOverride, assertNotGitIdentityOverrideArgv } from './git-identity-guard.js';
17
+ import { assertNoHoldEscape, withIdentityAudit } from './git-identity-audit.js';
16
18
  import { getQaProcessManager, PERSISTENT_JOBS_SUPPORTED } from './qa/runtime/ProcessManager.js';
17
19
  import { clipText } from './text.js';
18
20
  import { matchesFileRead, storeFileRead } from './file-read-state.js';
19
- import { FileReadRequiredError } from './tool-errors.js';
21
+ import { CommandExitError, FileReadRequiredError } from './tool-errors.js';
20
22
  import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
21
23
  import { withGrepRegex } from './grep-regex.js';
22
24
  import { claimReadImages, readImageObservation } from './read-image.js';
23
25
  import { READ_PDF_RENDER_PAGES, legacyTextObservation, readDocumentObservation } from './read-document-tool.js';
26
+ import { assertCommandAvoidsHarnessHome, guardsHarnessHome, withoutHarnessHomeLines } from './harness-home.js';
27
+ import { privateRunTemp } from './run-temp.js';
28
+ // Runs an agent command with the stray-file notice and, around it, the commit identity audit. The audit
29
+ // starts git on the host, so it runs only when the command itself runs unrestricted on the host; a
30
+ // restricted profile starts nothing it did not approve.
31
+ function auditedCommand(cwd, commandText, launchPolicy, run) {
32
+ return withIdentityAudit(cwd, commandText, () => withStrayFileNotice(cwd, run), () => launchPolicy() === undefined);
33
+ }
24
34
  const execFileAsync = promisify(execFile);
25
- // Edit previews use the executor's own argument normalizer. Construction only defines metadata;
26
- // previewing never invokes the tool executor.
27
35
  registerEditArgumentPreparer(andorraCreateEditTool('.').prepareArguments);
28
36
  const excluded = new Set(['.git', 'node_modules', '.andorracode']);
29
37
  const MAX_MODEL_OUTPUT = 24_000;
30
- /** Lines returned by one Read call: both the default and the accepted maximum for `limit`. */
31
38
  const READ_MAX_LINES = 2000;
32
- /** A single line longer than this is truncated, so one minified line cannot fill the window. */
33
39
  const READ_MAX_LINE_CHARS = 2000;
34
- const SEARCH_FILE_LIMIT = 262_144;
35
- const SEARCH_SCAN_LIMIT = 16 * 1024 * 1024;
36
- /**
37
- * How long a foreground shell command may run when the call names no timeout.
38
- *
39
- * Thirty seconds, the earlier default, is shorter than an ordinary package install, compile or
40
- * test run: the command was killed and the model had to notice, raise the timeout and start it
41
- * again from nothing. Two minutes covers those without leaving a hung command unnoticed for long.
42
- */
40
+ const GREP_FALLBACK_FILE_LIMIT = 20_000;
41
+ const GREP_FALLBACK_BYTE_LIMIT = 256 * 1024 * 1024;
42
+ const GREP_FALLBACK_ENTRY_LIMIT = 200_000;
43
+ const GREP_FALLBACK_TIME_MS = 30_000;
44
+ const GREP_FALLBACK_CHUNK_LINES = 20_000;
45
+ const GREP_FALLBACK_CHUNK_CHARS = 1_000_000;
46
+ const GREP_FALLBACK_TYPES = {
47
+ py: ['.py', '.pyi'], python: ['.py', '.pyi'], js: ['.js', '.jsx', '.mjs', '.cjs'], ts: ['.ts', '.tsx', '.mts', '.cts'],
48
+ rust: ['.rs'], go: ['.go'], java: ['.java'], c: ['.c', '.h'], cpp: ['.cpp', '.cc', '.cxx', '.hpp', '.hh', '.hxx', '.h'],
49
+ cs: ['.cs'], rb: ['.rb'], ruby: ['.rb'], php: ['.php'], swift: ['.swift'], kotlin: ['.kt', '.kts'], sh: ['.sh', '.bash', '.zsh'],
50
+ md: ['.md', '.markdown'], json: ['.json'], yaml: ['.yaml', '.yml'], toml: ['.toml'], html: ['.html', '.htm'], css: ['.css', '.scss', '.less'],
51
+ txt: ['.txt'], rst: ['.rst'], cfg: ['.cfg', '.ini'], sql: ['.sql'], xml: ['.xml'],
52
+ };
43
53
  export const SHELL_DEFAULT_TIMEOUT_MS = 120_000;
44
54
  export const SHELL_MAX_TIMEOUT_MS = 600_000;
45
- /**
46
- * What a timed-out command's error tells the model to do next.
47
- *
48
- * The bare "timed out after N ms" says the command was stopped but not that the work is lost, nor
49
- * which of the two ways forward fits: a longer timeout while one is left to ask for, or a
50
- * background job once the ceiling is reached.
51
- */
52
55
  export function shellTimeoutGuidance(message, timeout) {
53
56
  const marker = /^Shell command timed out after \d+ ms/;
54
57
  if (!marker.test(message))
@@ -73,16 +76,12 @@ async function shellPermission(policy, name, args, context) {
73
76
  const mode = permissionMode(context);
74
77
  let explicitlyApproved = false;
75
78
  let escalationAuthorized = false;
76
- // Plan mode researches read-only: an escalation (host and network access) would be a change no
77
- // plan has been approved for, so it is refused with the same guidance as a file mutation.
78
79
  if (mode === 'plan' && requested === 'require_escalated')
79
80
  throw new Error(PLAN_MODE_MUTATION_ERROR);
80
81
  if (!mode || mode === 'full-access' || requested === 'require_escalated') {
81
82
  await policy.authorize(name, { ...args, warning: 'UNSANDBOXED: entire host and network access.' }, {
82
83
  ...context, approve: async (...approval) => {
83
84
  const approved = await context.approve(...approval);
84
- // A live permission switch settles outstanding prompts with policy-changed. Never
85
- // allow an old escalation request to be re-approved after the run enters Plan.
86
85
  if (requested === 'require_escalated' && permissionMode(context) === 'plan')
87
86
  throw new Error(PLAN_MODE_MUTATION_ERROR);
88
87
  if (approved === true)
@@ -90,31 +89,18 @@ async function shellPermission(policy, name, args, context) {
90
89
  return approved;
91
90
  },
92
91
  });
93
- // Authorization may have awaited other hooks while the run switched modes.
94
92
  if (requested === 'require_escalated' && permissionMode(context) === 'plan')
95
93
  throw new Error(PLAN_MODE_MUTATION_ERROR);
96
94
  escalationAuthorized = requested === 'require_escalated';
97
95
  }
98
- // Evaluate synchronously at spawn, after filesystem/launcher discovery awaits.
99
- // Only a real per-call user grant can preserve unsandboxed execution when a
100
- // previously automatic Full Access grant has since been revoked.
101
96
  return () => {
102
97
  const live = permissionMode(context);
103
- // Spawn-time recheck is essential: even a previously granted escalation cannot
104
- // escape the read-only boundary if the run switched into Plan in the meantime.
105
98
  if (requested === 'require_escalated' && live === 'plan')
106
99
  throw new Error(PLAN_MODE_MUTATION_ERROR);
107
100
  if (explicitlyApproved)
108
101
  return undefined;
109
- // An escalation this call's own authorization granted is an audited host grant: a shell is never a
110
- // workspace-policy mutation, so without an explicit answer the journaled decision was Full Access
111
- // policy — typically the user switching the run to Full Access while this prompt was open. It holds
112
- // while Full Access is still in force at spawn; a revocation since then falls through below.
113
102
  if (escalationAuthorized && live === 'full-access')
114
103
  return undefined;
115
- // A later Full Access selection cannot create an unaudited host grant.
116
- // Keep an initially restricted call restricted; a subsequent call can
117
- // acquire Full Access through authorize and its journal events.
118
104
  if (mode && mode !== 'full-access' && live === 'full-access')
119
105
  return mode === 'read-only' || mode === 'plan' ? 'read-only' : 'workspace-write';
120
106
  if (!live || live === 'full-access')
@@ -177,13 +163,6 @@ const boolArg = (args, key) => {
177
163
  throw new Error(`${key} must be a boolean`);
178
164
  return value;
179
165
  };
180
- /**
181
- * Key for the per-context file-read state.
182
- *
183
- * Exported so other producers of the same state (the CodeGraph complete-source seed) store
184
- * entries under the key the canonical tools look up. It must be applied to a path normalized
185
- * the same way the policy's safePath normalizes it, or the entries never match.
186
- */
187
166
  export { stateKey };
188
167
  function state(context) {
189
168
  context.toolState ??= { fileReads: new Map() };
@@ -201,9 +180,6 @@ async function remember(context, resolved, content, complete, source) {
201
180
  async function rememberReadRange(context, resolved, content, start, end, lineCount) {
202
181
  const key = stateKey(resolved);
203
182
  const prior = state(context).fileReads.get(key);
204
- // Successful mutations and complete CodeGraph source are also full snapshots.
205
- // A narrow Read of identical content must not revoke their existing coverage.
206
- // Changed bytes invalidate all prior ranges, regardless of snapshot origin.
207
183
  const ranges = prior && matchesFileRead(prior, content) ? (prior.complete ? [{ start: 1, end: lineCount }] : [...(prior.ranges ?? [])]) : [];
208
184
  if (lineCount === 0) {
209
185
  await remember(context, resolved, content, true, 'Read');
@@ -230,7 +206,6 @@ async function rememberReadRange(context, resolved, content, start, end, lineCou
230
206
  source: 'Read',
231
207
  });
232
208
  }
233
- /** First unread stretch of the file, for a partial observation. */
234
209
  function firstUnreadRange(previous) {
235
210
  if (previous.complete)
236
211
  return undefined;
@@ -248,12 +223,7 @@ function firstUnreadRange(previous) {
248
223
  async function requireFreshRead(policy, context, resolved, action) {
249
224
  const previous = state(context).fileReads.get(stateKey(resolved));
250
225
  if (!previous?.complete) {
251
- // A suggested offset is only meaningful for the content the model last saw. Re-read first so
252
- // a file that changed (or shrank) since that page cannot send the model past its end.
253
226
  if (!previous) {
254
- // A file the text tools cannot hold (a document, an image, text in another encoding) can be
255
- // looked at with Read but never becomes a recorded read, so "Read it first" would send the
256
- // model round in a circle. The strict reader's own refusal is the true answer for those.
257
227
  await policy.read(context, resolved);
258
228
  throw new FileReadRequiredError(`${action} requires a complete Read (or complete CodeGraph source) of the existing file first. Read ${path.relative(context.workspace, resolved) || resolved} before modifying it.`);
259
229
  }
@@ -271,7 +241,6 @@ async function requireFreshRead(policy, context, resolved, action) {
271
241
  throw new FileReadRequiredError(`${action} refused a stale file: it changed since the last Read/CodeGraph snapshot. Read it again before modifying.`);
272
242
  return current;
273
243
  }
274
- /** A replacement whose old text the current file does not hold exactly as the call needs. */
275
244
  class EditMatchError extends Error {
276
245
  summary;
277
246
  constructor(message, summary) {
@@ -280,15 +249,7 @@ class EditMatchError extends Error {
280
249
  this.name = 'EditMatchError';
281
250
  }
282
251
  }
283
- /** The runtime prefixes a failed call's message with this before clipping it at MAX_MODEL_OUTPUT. */
284
252
  const TOOL_ERROR_PREFIX = 'Tool error: ';
285
- /**
286
- * A failure message that carries the whole file, or undefined when it cannot.
287
- *
288
- * Stricter than Read: a clipped line, a second page, or a message the runtime would clip leaves
289
- * text the model has not seen, and the caller records the file as completely read on the strength
290
- * of this message. The budget is measured on the complete message, not the file alone.
291
- */
292
253
  function messageWithWholeFile(explanation, content) {
293
254
  const lines = content.split('\n');
294
255
  if (content.endsWith('\n') || content === '')
@@ -299,7 +260,6 @@ function messageWithWholeFile(explanation, content) {
299
260
  const message = `${explanation}\n${page}`;
300
261
  return TOOL_ERROR_PREFIX.length + message.length <= MAX_MODEL_OUTPUT ? message : undefined;
301
262
  }
302
- /** The old texts an Edit call names, or undefined when the call is not a well-formed edit. */
303
263
  function editOldTexts(args) {
304
264
  if (args.edits === undefined)
305
265
  return typeof args.old_string === 'string' && args.old_string ? [args.old_string] : undefined;
@@ -328,14 +288,6 @@ function editOldTexts(args) {
328
288
  }
329
289
  return texts;
330
290
  }
331
- /**
332
- * Why an Edit's old text is not literally in the file, or undefined when every one is.
333
- *
334
- * The edit matcher also accepts near matches (Unicode and whitespace normalization). That is safe
335
- * for a file the model has read, and is exactly what must not stand in for the read: only a
336
- * literal occurrence shows the model knows the text it is replacing. Line endings are the one
337
- * difference allowed, because models write LF for files stored with CRLF.
338
- */
339
291
  function unseenEditMismatch(args, content) {
340
292
  const texts = editOldTexts(args);
341
293
  if (!texts)
@@ -352,20 +304,6 @@ function unseenEditMismatch(args, content) {
352
304
  }
353
305
  return undefined;
354
306
  }
355
- /**
356
- * Edit without the separate Read the gate would otherwise ask the model for.
357
- *
358
- * The gate exists so a mutation never rests on text the model did not see. For an Edit, old_string
359
- * occurring literally in the current file is that evidence, so a file that was never (or only
360
- * partly) Read is read here: a literal match applies the edit, and a miss returns the file in the
361
- * failure so the next call is the corrected Edit. Either way the model does not spend a call on
362
- * Read and another on resending the same Edit. A file that changed since the model last saw it is
363
- * still refused, with its current content when one message holds it. Write keeps the plain gate:
364
- * a full overwrite carries no evidence that the model knows what it replaces.
365
- *
366
- * The file counts as Read only when the edit applied or its whole content was returned; every
367
- * other outcome leaves or puts back the previous read state.
368
- */
369
307
  async function editWithoutPriorRead(policy, args, context, execute) {
370
308
  const filePath = args.file_path;
371
309
  if (typeof filePath !== 'string' || !filePath || filePath.includes('\0'))
@@ -374,7 +312,6 @@ async function editWithoutPriorRead(policy, args, context, execute) {
374
312
  const reads = state(context).fileReads, key = stateKey(resolved);
375
313
  const previous = reads.get(key);
376
314
  let content;
377
- // A missing, binary or oversized target is the tool's own error to report.
378
315
  try {
379
316
  content = await policy.read(context, resolved);
380
317
  }
@@ -391,14 +328,12 @@ async function editWithoutPriorRead(policy, args, context, execute) {
391
328
  }
392
329
  if (previous?.complete)
393
330
  return execute(args, context);
394
- // Not a well-formed edit: the gate refuses it as it always has.
395
331
  if (!editOldTexts(args))
396
332
  return execute(args, context);
397
333
  const restore = () => { if (previous)
398
334
  reads.set(key, previous);
399
335
  else
400
336
  reads.delete(key); };
401
- /** The edit cannot apply: hand the model the file, or the paged-read refusal when it is too long. */
402
337
  const missed = async (summary) => {
403
338
  const message = messageWithWholeFile(`${summary}\nFile unchanged; no replacements were applied. ${name} had not been completely Read, so it was read for this call: it is shown in full below and now counts as Read. Copy old_string from it and retry; no separate Read is needed.`, content);
404
339
  if (message !== undefined) {
@@ -492,13 +427,9 @@ export function createCodingTools(policy) {
492
427
  const limit = intArg(args, 'limit', { min: 1, max: READ_MAX_LINES }) ?? READ_MAX_LINES;
493
428
  const pages = stringArg(args, 'pages', true), render = boolArg(args, 'render') ?? false;
494
429
  const resolved = await policy.safePath(context, filePath);
495
- // An image is recognized by its signature and shown as pixels. It is not recorded as a
496
- // text read: Write and Edit cannot faithfully rewrite a file they only saw as a picture.
497
430
  const image = await policy.readImage?.(context, resolved);
498
431
  if (image)
499
432
  return readImageObservation(context, filePath, image);
500
- // A PDF or Word file is likewise recognized by its leading bytes and returned as what it
501
- // says: its text, or for a PDF its pages as images. Neither is recorded as a text read.
502
433
  const documentOptions = { offset, limit, ...(pages === undefined ? {} : { pages }), render, maxOutput: MAX_MODEL_OUTPUT, maxLineChars: READ_MAX_LINE_CHARS };
503
434
  const documentBytes = await policy.readDocument?.(context, resolved);
504
435
  if (documentBytes) {
@@ -511,8 +442,6 @@ export function createCodingTools(policy) {
511
442
  content = await policy.read(context, resolved);
512
443
  }
513
444
  catch (error) {
514
- // Text in an older encoding (UTF-16, Windows-1252) fails the strict UTF-8 reader that
515
- // Edit depends on. It is still text a model can read, so it is shown decoded, read-only.
516
445
  if (!(error instanceof Error) || !/not valid UTF-8|Binary files are not supported/.test(error.message))
517
446
  throw error;
518
447
  const decoded = await policy.readLegacyText?.(context, resolved);
@@ -533,9 +462,6 @@ export function createCodingTools(policy) {
533
462
  if (first > lines.length)
534
463
  throw new Error(`Offset ${first} is beyond end of file (${lines.length} lines total)`);
535
464
  const lastRequested = Math.min(lines.length, first + limit - 1);
536
- // The runtime clips every tool result at MAX_MODEL_OUTPUT before the model sees it, so a
537
- // page that overflows would lose its tail and the continuation footer while still being
538
- // recorded as read. Stop on the last whole line that fits, and record only that line.
539
465
  const budget = MAX_MODEL_OUTPUT - 200;
540
466
  let rendered = '';
541
467
  let emittedLast = first - 1;
@@ -549,7 +475,6 @@ export function createCodingTools(policy) {
549
475
  emittedLast = line;
550
476
  }
551
477
  if (emittedLast < first) {
552
- // A truncated line always fits this budget, so this is a defensive guard, not a path.
553
478
  rendered = `${first}\t${(lines[first - 1] ?? '').slice(0, READ_MAX_LINE_CHARS)}`;
554
479
  emittedLast = first;
555
480
  }
@@ -610,10 +535,6 @@ export function createCodingTools(policy) {
610
535
  await remember(context, resolved, updated, true, 'mutation');
611
536
  return `Replaced ${count} occurrence(s) in ${path.relative(context.workspace, resolved) || resolved}. File state is current; no Read-back is needed.`;
612
537
  }
613
- // Models sometimes send `edits` as a JSON string, or a single edit object where the
614
- // contract asks for a one-element array, so coerce before validating. The engine edit
615
- // adapter tolerated both; dropping the tolerance would turn recoverable calls into
616
- // hard failures on a path that previously worked.
617
538
  const coerceEdits = (value) => {
618
539
  let parsed = value;
619
540
  if (typeof parsed === 'string') {
@@ -672,8 +593,6 @@ export function createCodingTools(policy) {
672
593
  catch (error) {
673
594
  if (!(error instanceof Error) || !/Could not find|Found \d+ occurrences|overlap/i.test(error.message))
674
595
  throw error;
675
- // Matcher failures occur before the native atomic write. Do not imply
676
- // partial batch progress, or echo the entire generated patch as feedback.
677
596
  const failedIndex = Number(error.message.match(/edits\[(\d+)\]/)?.[1] ?? 0);
678
597
  const failed = edits[failedIndex];
679
598
  const lines = before.split(/\r?\n/);
@@ -689,8 +608,6 @@ export function createCodingTools(policy) {
689
608
  const upstream = result.content.filter(part => part.type === 'text').map(part => part.text).join('\n');
690
609
  return nativeObservation(upstream || `Successfully replaced ${edits.length} block(s) in ${path.relative(context.workspace, resolved) || resolved}. File state is current; no Read-back is needed.`);
691
610
  });
692
- // Advertise the focused single replacement contract. Older saved calls
693
- // retain batch compatibility, validated separately after normalization.
694
611
  const editSeenFile = Edit.execute;
695
612
  Edit.execute = (args, context) => editWithoutPriorRead(policy, args, context, editSeenFile);
696
613
  Edit.validationParameters = Edit.parameters;
@@ -742,7 +659,7 @@ export function createCodingTools(policy) {
742
659
  const result = await current.execute(randomUUID(), { pattern, path: resolved, limit }, context.signal);
743
660
  return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'));
744
661
  });
745
- const Grep = zTool('Grep', 'Search file contents with file-name, count or content results. Restricted modes use bounded native searches with interruptible JavaScript single-line regular expressions (5-second search budget), glob filters, context lines and offsets; type, multiline and only-matching options require unrestricted ripgrep.', { type: 'object', properties: {
662
+ const Grep = zTool('Grep', 'Search file contents with file-name, count or content results. Uses ripgrep when it is installed. Without it, and in restricted modes, a built-in search runs instead: JavaScript single-line regular expressions, glob and common type filters, context lines and offsets; multiline and only-matching need ripgrep. A result that could not cover every file starts with INCOMPLETE SEARCH and is never a plain "No matches": narrow path or glob and search again.', { type: 'object', properties: {
746
663
  pattern: { type: 'string', description: 'Regular expression to search for' },
747
664
  path: { type: 'string', description: 'File or directory inside the workspace; defaults to .' },
748
665
  glob: { type: 'string', description: 'Optional glob filter such as *.{ts,tsx}' },
@@ -774,85 +691,136 @@ export function createCodingTools(policy) {
774
691
  const limit = requestedLimit === 0 ? 2000 : requestedLimit ?? 250;
775
692
  const offset = intArg(args, 'offset', { min: 0, max: 100000 }) ?? 0;
776
693
  const resolved = await policy.safePath(context, searchPath);
777
- // Resolving rg probes PATH by executing it. Restricted searches must never
778
- // enter that resolver (or a vendor helper that downloads/spawns binaries).
779
694
  const restricted = context.pinFilePaths || (permissionMode(context) !== undefined && permissionMode(context) !== 'full-access');
780
695
  const rg = restricted ? null : andorraGetToolPath('rg');
781
696
  if (!rg) {
782
- if (type || multiline || only)
697
+ if (multiline || only)
783
698
  throw new Error(restricted
784
699
  ? 'This Grep option requires ripgrep, which is unavailable to restricted searches. Use glob and a single-line pattern instead.'
785
- : 'This Grep mode requires ripgrep (rg), which is not available. Use content mode with a narrower pattern/path or install ripgrep.');
786
- return withGrepRegex(pattern, (ignoreCase ? 'i' : '') + (mode === 'count' ? 'g' : ''), context.signal, async (scan, searchSignal) => {
700
+ : 'This Grep option (multiline or -o) requires ripgrep (rg), which is not available. Use a single-line pattern in content mode; glob, type, context lines, -i, head_limit and offset all work without ripgrep.');
701
+ const typeExtensions = type === undefined ? undefined : GREP_FALLBACK_TYPES[type.toLowerCase()];
702
+ if (type !== undefined && !typeExtensions)
703
+ throw new Error(`Grep type "${clipText(type, 40)}" needs ripgrep (rg), which is not available. Without ripgrep, type supports: ${Object.keys(GREP_FALLBACK_TYPES).join(', ')}. Use glob for anything else, for example glob "*.${clipText(type, 20)}".`);
704
+ return withGrepRegex(pattern, (ignoreCase ? 'i' : '') + (mode === 'count' ? 'g' : ''), context.signal, async (scan, searchSignal, progress) => {
787
705
  const searchContext = { ...context, signal: searchSignal };
788
706
  const info = await stat(resolved);
789
707
  searchSignal.throwIfAborted();
790
- const candidates = [];
791
- if (info.isFile())
792
- candidates.push(resolved);
793
- else
794
- for await (const candidate of policy.files(searchContext, resolved)) {
795
- searchSignal.throwIfAborted();
796
- candidates.push(candidate);
797
- }
798
708
  const rows = [];
799
- let scannedFiles = 0, scannedBytes = 0;
800
- let scanNotice = '';
709
+ let scannedFiles = 0, scannedBytes = 0, unreadable = 0;
710
+ let incomplete, moreRows = false;
711
+ const oversized = [];
712
+ const deadline = Date.now() + GREP_FALLBACK_TIME_MS;
713
+ const scanned = () => `${scannedFiles.toLocaleString('en-US')} file${scannedFiles === 1 ? '' : 's'} scanned`;
801
714
  const contextBefore = around ?? before ?? 0, contextAfter = around ?? after ?? 0;
802
- for (const candidate of candidates) {
803
- searchSignal.throwIfAborted();
715
+ const searchFile = async (candidate) => {
804
716
  const relative = path.relative(resolved, candidate).split(path.sep).join('/') || path.basename(candidate);
805
717
  if (glob && !path.matchesGlob(relative, glob) && !path.matchesGlob(path.basename(relative), glob))
806
- continue;
807
- if (++scannedFiles > 1000) {
808
- scanNotice = '\n[Search file limit reached; narrow the path/glob.]';
809
- break;
718
+ return true;
719
+ if (typeExtensions && !typeExtensions.some(extension => relative.toLowerCase().endsWith(extension)))
720
+ return true;
721
+ if (scannedFiles >= GREP_FALLBACK_FILE_LIMIT) {
722
+ incomplete = `stopped at the ${GREP_FALLBACK_FILE_LIMIT.toLocaleString('en-US')}-file scan limit`;
723
+ return false;
724
+ }
725
+ if (Date.now() > deadline) {
726
+ incomplete = `stopped after ${GREP_FALLBACK_TIME_MS / 1000} seconds with ${scanned()}`;
727
+ return false;
810
728
  }
811
729
  let source;
812
730
  try {
813
- // Discovery is not a snapshot: builds/cleanup can remove or revoke a
814
- // candidate before either stat or read. Skip it just like a failed read.
815
731
  const candidateInfo = await stat(candidate);
816
732
  searchSignal.throwIfAborted();
817
- if (candidateInfo.size > SEARCH_FILE_LIMIT)
818
- continue;
819
- if ((scannedBytes += candidateInfo.size) > SEARCH_SCAN_LIMIT) {
820
- scanNotice = '\n[Search byte limit reached at 16 MiB; narrow the path/glob.]';
821
- break;
733
+ if (candidateInfo.size > policy.fileLimit) {
734
+ oversized.push(relative);
735
+ return true;
736
+ }
737
+ if (scannedBytes + candidateInfo.size > GREP_FALLBACK_BYTE_LIMIT) {
738
+ incomplete = `stopped at the ${GREP_FALLBACK_BYTE_LIMIT / (1024 * 1024)} MiB scan limit with ${scanned()}`;
739
+ return false;
822
740
  }
823
741
  source = await policy.read(searchContext, candidate);
742
+ scannedBytes += candidateInfo.size;
824
743
  }
825
- catch {
744
+ catch (error) {
826
745
  searchSignal.throwIfAborted();
827
- continue;
746
+ if (!(error instanceof Error) || !/Binary files are not supported|not valid UTF-8/.test(error.message))
747
+ unreadable++;
748
+ return true;
828
749
  }
829
750
  searchSignal.throwIfAborted();
751
+ scannedFiles++;
752
+ progress();
830
753
  const lines = source.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
831
- let matches = 0;
832
- for (const match of await scan(lines, mode === 'count')) {
833
- const index = match.index;
834
- matches += match.count;
835
- if (mode === 'files_with_matches') {
836
- rows.push(relative);
837
- break;
838
- }
839
- if (mode === 'count')
840
- continue;
841
- const start = Math.max(0, index - contextBefore), end = Math.min(lines.length - 1, index + contextAfter);
842
- for (let cursor = start; cursor <= end; cursor++) {
843
- const marker = cursor === index ? ':' : '-';
844
- rows.push(lineNumbers ? `${relative}${marker}${cursor + 1}${marker}${clipText(lines[cursor], 800)}` : `${relative}${marker}${clipText(lines[cursor], 800)}`);
754
+ let matches = 0, settled = false;
755
+ for (let from = 0; from < lines.length && !settled;) {
756
+ let to = from, chars = 0;
757
+ while (to < lines.length && to - from < GREP_FALLBACK_CHUNK_LINES && (to === from || chars + lines[to].length <= GREP_FALLBACK_CHUNK_CHARS))
758
+ chars += lines[to++].length;
759
+ for (const match of await scan(lines.slice(from, to), mode === 'count')) {
760
+ const index = match.index + from;
761
+ matches += match.count;
762
+ if (mode === 'files_with_matches') {
763
+ rows.push(relative);
764
+ settled = true;
765
+ break;
766
+ }
767
+ if (mode === 'count')
768
+ continue;
769
+ if (rows.length >= offset + limit) {
770
+ moreRows = true;
771
+ settled = true;
772
+ break;
773
+ }
774
+ const start = Math.max(0, index - contextBefore), end = Math.min(lines.length - 1, index + contextAfter);
775
+ for (let cursor = start; cursor <= end; cursor++) {
776
+ const marker = cursor === index ? ':' : '-';
777
+ rows.push(lineNumbers ? `${relative}${marker}${cursor + 1}${marker}${clipText(lines[cursor], 800)}` : `${relative}${marker}${clipText(lines[cursor], 800)}`);
778
+ }
845
779
  }
846
- if (rows.length >= offset + limit)
847
- break;
780
+ from = to;
781
+ progress();
848
782
  }
849
783
  if (mode === 'count' && matches)
850
784
  rows.push(`${relative}:${matches}`);
851
- if (rows.length >= offset + limit)
852
- break;
785
+ return true;
786
+ };
787
+ if (info.isFile())
788
+ await searchFile(resolved);
789
+ else {
790
+ try {
791
+ for await (const candidate of policy.files(searchContext, resolved, 0, { entries: 0, limit: GREP_FALLBACK_ENTRY_LIMIT })) {
792
+ searchSignal.throwIfAborted();
793
+ progress();
794
+ if (rows.length >= offset + limit) {
795
+ moreRows = true;
796
+ break;
797
+ }
798
+ if (!await searchFile(candidate))
799
+ break;
800
+ }
801
+ }
802
+ catch (error) {
803
+ searchSignal.throwIfAborted();
804
+ if (!(error instanceof Error) || !/^Directory scan limit reached/.test(error.message))
805
+ throw error;
806
+ incomplete = `stopped at the ${GREP_FALLBACK_ENTRY_LIMIT.toLocaleString('en-US')}-entry directory scan limit with ${scanned()}`;
807
+ }
853
808
  }
854
809
  const selected = rows.slice(offset, offset + limit);
855
- return nativeObservation((selected.length ? selected.join('\n') : 'No matches') + scanNotice + `\n[Grep ${mode} fallback: ${selected.length} returned; ${restricted ? 'native restricted search' : 'ripgrep unavailable'}]`);
810
+ const more = moreRows || rows.length > offset + limit;
811
+ const narrow = `Narrow the search with path (a subdirectory or one file) or glob (for example "*.py")${restricted ? '' : `, or run ${process.platform === 'win32' ? 'Select-String' : 'grep -rn'} through the shell`}.`;
812
+ const notices = [];
813
+ if (incomplete)
814
+ notices.push(`[INCOMPLETE SEARCH: ${incomplete}. Files that were not scanned may contain matches, so this result does not show that the pattern is absent. ${narrow}]`);
815
+ if (oversized.length)
816
+ notices.push(`[Not searched, larger than ${policy.fileLimit / (1024 * 1024)} MiB: ${oversized.slice(0, 5).join(', ')}${oversized.length > 5 ? `, and ${oversized.length - 5} more` : ''}.]`);
817
+ if (unreadable)
818
+ notices.push(`[${unreadable} file${unreadable === 1 ? '' : 's'} could not be read and ${unreadable === 1 ? 'was' : 'were'} skipped.]`);
819
+ const body = selected.length ? selected.join('\n')
820
+ : incomplete ? 'No matches in the files scanned before the search stopped.'
821
+ : offset && rows.length ? `No matches at offset ${offset}; ${rows.length} precede it.` : 'No matches';
822
+ const meta = `[Grep ${mode} fallback: ${selected.length} returned${offset ? `, offset ${offset}` : ''}${more ? `, more may be available: raise head_limit or continue with offset ${offset + selected.length}` : ''}; ${scanned()}${incomplete ? ', INCOMPLETE' : ''}; ${restricted ? 'native restricted search' : 'ripgrep unavailable'}]`;
823
+ return nativeObservation([...notices, body, meta].join('\n'));
856
824
  });
857
825
  }
858
826
  const cwd = await policy.safePath(context, '.');
@@ -899,7 +867,9 @@ export function createCodingTools(policy) {
899
867
  else
900
868
  throw new Error(`Grep failed: ${String(failure.stderr ?? failure.message).trim().slice(0, 1000)}`);
901
869
  }
902
- const all = stdout.split(/\r?\n/).filter(Boolean);
870
+ let all = stdout.split(/\r?\n/).filter(Boolean);
871
+ if (guardsHarnessHome(context))
872
+ all = withoutHarnessHomeLines(all, cwd);
903
873
  const selected = all.slice(offset, offset + limit).map(line => line.length > 800 ? clipText(line, 800) + ' [line clipped]' : line);
904
874
  const truncated = offset + selected.length < all.length || stdout.length > 24_000;
905
875
  const body = selected.join('\n') || 'No matches';
@@ -911,7 +881,7 @@ export function createCodingTools(policy) {
911
881
  const syntax = kind === 'powershell'
912
882
  ? 'PowerShell syntax; use & before a quoted executable path. No cmd.exe substitution. Do not pipe a running child into Select-Object -First: it terminates the pipeline before the child completes and can cause exit 4294967295. Host output is already tail-bounded; use Select-Object -Last if further filtering is needed. Prefer file-written scripts over nested quoting for multiline Python/JavaScript. Prefer direct invocation (& $exe @args) for child processes: Windows PowerShell Start-Process -ArgumentList flattens arrays and can split a multi-word argument unless it is quoted manually. Windows PowerShell also alters what it hands a native program: piping a string into one (ssh, wsl, bash -s, docker exec) appends CRLF after the last line, so a remote shell runs that line with a stray \r, and double quotes inside a native argument are dropped. Windows PowerShell binds the content of Set-Content or Add-Content as the file name when a switch such as -NoNewline comes before a positional path: name -Path and -Value, or use Write. Send a multi-line script to a remote or POSIX shell as base64 instead: $b = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(($script -replace "`r", "") + "`n")); & ssh host "echo $b | base64 -d | bash".'
913
883
  : 'Bash syntax (Git Bash on Windows).';
914
- const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed${kind === 'powershell' ? '' : ': a command that leaves a job running (cmd &) waits for that job, and the timeout then stops it'}. Start long-running work with AsyncProcess instead${PERSISTENT_JOBS_SUPPORTED ? ', with persist: true for a service the user needs left running after you finish' : ''}.`, { type: 'object', properties: {
884
+ const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed${kind === 'powershell' ? '' : ': a command that leaves a job running (cmd &) waits for that job, and the timeout then stops it'}. Start long-running work with AsyncProcess instead${PERSISTENT_JOBS_SUPPORTED ? ', with persist: true for a service the user needs left running after you finish' : ''}.${privateRunTemp() ? ` Put scratch files in ${kind === 'powershell' ? '$env:TEMP' : '"$TMPDIR"'}, a private directory that is removed when the run ends, not in the shared system temporary directory.` : ''}`, { type: 'object', properties: {
915
885
  command: { type: 'string', description: 'Command to execute' },
916
886
  timeout: { type: 'integer', minimum: 1, maximum: SHELL_MAX_TIMEOUT_MS, description: `Timeout in milliseconds; default ${SHELL_DEFAULT_TIMEOUT_MS}, at most ${SHELL_MAX_TIMEOUT_MS}. Set it for a build, install, download or test run you expect to take longer than the default` },
917
887
  description: { type: 'string', description: 'Short active-voice description of what the command does' },
@@ -922,16 +892,12 @@ export function createCodingTools(policy) {
922
892
  const command = stringArg(args, 'command'), timeout = intArg(args, 'timeout', { min: 1, max: SHELL_MAX_TIMEOUT_MS }) ?? SHELL_DEFAULT_TIMEOUT_MS;
923
893
  if (args.description !== undefined)
924
894
  stringArg(args, 'description', true);
925
- // Before any approval is asked for: no permission mode, full access included, makes ending
926
- // the app that hosts this run a thing to approve. Read by the rules of the shell that runs it.
927
895
  assertNotHostKill(command, hostShellOf(kind));
896
+ assertNotGitIdentityOverride(command);
897
+ assertCommandAvoidsHarnessHome(command, context);
928
898
  const launchPolicy = await shellPermission(policy, name, args, context);
929
899
  const cwd = await policy.safePath(context, '.');
930
900
  const operations = { exec: async (value, directory, options) => {
931
- // The same chunks that feed the vendored tool's accumulator also feed the live transcript:
932
- // a reader who expands the running call sees the command's output as it prints. The
933
- // decoder keeps a chunk boundary from splitting a multi-byte character on the way
934
- // through; the observation the tool builds remains the authoritative text.
935
901
  const decoder = new StringDecoder('utf8');
936
902
  const report = options.onData;
937
903
  const onData = (data) => {
@@ -958,7 +924,7 @@ export function createCodingTools(policy) {
958
924
  const current = kind === 'powershell'
959
925
  ? andorraCreatePowerShellTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false })
960
926
  : andorraCreateBashTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false });
961
- return withStrayFileNotice(cwd, async () => {
927
+ return auditedCommand(cwd, command, launchPolicy, async () => {
962
928
  try {
963
929
  const result = await current.execute(randomUUID(), { command, timeout: timeout / 1000 }, context.signal);
964
930
  return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'), true);
@@ -966,6 +932,9 @@ export function createCodingTools(policy) {
966
932
  catch (error) {
967
933
  if (!(error instanceof Error))
968
934
  throw error;
935
+ const exited = /(?:^|\n\n)Command exited with code (\d+)$/.exec(error.message);
936
+ if (exited)
937
+ throw new CommandExitError(nativeObservation(error.message, true), Number(exited[1]));
969
938
  const message = shellTimeoutGuidance(error.message, timeout);
970
939
  if (message.length > MAX_MODEL_OUTPUT)
971
940
  throw new Error(nativeObservation(message, true));
@@ -975,20 +944,14 @@ export function createCodingTools(policy) {
975
944
  }
976
945
  });
977
946
  });
978
- // The vendored shell throws on any exit other than 0, so a return is a clean exit.
979
947
  return { ...tool, exitZeroOnReturn: true };
980
948
  };
981
- // Keep imported Pi spellings executable for old tests/configuration, but never
982
- // advertise them to providers. capabilityTools maps legacy graph allowlists to
983
- // the canonical surface above.
984
949
  const definitions = [andorraCreateReadTool('.'), andorraCreateWriteTool('.'), andorraCreateEditTool('.'), andorraCreateLsTool('.'), andorraCreateFindTool('.'), andorraCreateGrepTool('.')];
985
950
  const legacyNative = definitions.map(definition => ({
986
951
  name: definition.name,
987
952
  providerVisible: false,
988
953
  prepareArguments: definition.prepareArguments,
989
954
  executionMode: definition.name === 'write' || definition.name === 'edit' ? 'sequential' : 'parallel',
990
- // Preserve the Andorra wording over the imported Pi descriptions: the read tool must
991
- // not advertise image attachments, and traversal/limits are workspace-bounded.
992
955
  description: `${(definition.name === 'read' ? 'Read UTF-8 text files. Binary files and image attachments are unsupported. Output is bounded; use offset (1-based line number) and limit to read specific portions of large files.' : definition.description).replace('Respects .gitignore.', definition.name === 'find' ? 'Uses a bounded workspace traversal (1,000 results, depth 20).' : 'Respects .gitignore.')} Workspace-only; .git, node_modules and .andorracode are excluded from directory traversal. Text reads/writes have an 8 MiB file limit; observations remain bounded.`,
993
956
  parameters: definition.parameters,
994
957
  execute: async (args, context) => {
@@ -1023,7 +986,6 @@ export function createCodingTools(policy) {
1023
986
  const actual = kind === 'powershell' ? 'PowerShell (PowerShell syntax)' : kind === 'bash' ? 'Bash' : '/bin/sh';
1024
987
  return {
1025
988
  name, providerVisible: false, executionMode: 'sequential',
1026
- // 'shell' prints its own `Exit code:` line; the vendored powershell/bash throw on a non-zero exit.
1027
989
  exitZeroOnReturn: name !== 'shell',
1028
990
  description: `Legacy compatibility shell using ${actual}.`,
1029
991
  parameters: { type: 'object', properties: { command: { type: 'string' }, timeout_ms: { type: 'integer', minimum: 1, maximum: 120000 }, ...sandboxFields }, required: ['command'], additionalProperties: false },
@@ -1036,13 +998,13 @@ export function createCodingTools(policy) {
1036
998
  if (typeof timeout !== 'number' || !Number.isInteger(timeout) || timeout < 1 || timeout > 120000)
1037
999
  throw new Error('timeout_ms must be an integer from 1 to 120000');
1038
1000
  assertNotHostKill(args.command, hostShellOf(kind));
1001
+ assertNotGitIdentityOverride(args.command);
1002
+ assertCommandAvoidsHarnessHome(args.command, context);
1039
1003
  const launchPolicy = await shellPermission(policy, name, args, context);
1040
1004
  const cwd = await policy.safePath(context, '.');
1041
- // Preserve the legacy observation formats: 'shell' keeps the runShell observation,
1042
- // while explicit 'powershell'/'bash' use native tail truncation and errors.
1043
1005
  const command = args.command;
1044
1006
  if (name === 'shell')
1045
- return withStrayFileNotice(cwd, async () => nativeObservation(await runShell(command, cwd, timeout, context.signal, kind, undefined, undefined, launchPolicy), true));
1007
+ return auditedCommand(cwd, command, launchPolicy, async () => nativeObservation(await runShell(command, cwd, timeout, context.signal, kind, undefined, undefined, launchPolicy), true));
1046
1008
  const operations = { exec: async (value, directory, options) => {
1047
1009
  try {
1048
1010
  await runShell(value, directory, timeout, context.signal, kind, options.onData, undefined, launchPolicy);
@@ -1059,7 +1021,7 @@ export function createCodingTools(policy) {
1059
1021
  const current = kind === 'powershell'
1060
1022
  ? andorraCreatePowerShellTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false })
1061
1023
  : andorraCreateBashTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false });
1062
- return withStrayFileNotice(cwd, async () => {
1024
+ return auditedCommand(cwd, command, launchPolicy, async () => {
1063
1025
  try {
1064
1026
  const result = await current.execute(randomUUID(), { command, timeout: timeout / 1000 }, context.signal);
1065
1027
  return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'), true);
@@ -1087,14 +1049,27 @@ export function createCodingTools(policy) {
1087
1049
  throw new Error('args must be an array of at most 128 strings (4096 chars each, no NUL)');
1088
1050
  }
1089
1051
  const timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 30000;
1090
- // The array is judged as an array: there is no shell here to read an argument as syntax.
1091
1052
  assertNotHostKillArgv(program, argv);
1053
+ assertNotGitIdentityOverrideArgv(program, argv);
1054
+ assertCommandAvoidsHarnessHome(argv.join(' '), context);
1092
1055
  const launchPolicy = await shellPermission(policy, 'NativeExec', args, context);
1093
1056
  const cwd = await policy.safePath(context, '.');
1094
1057
  const executable = program === 'node' ? process.execPath : program === 'git' ? 'git' : andorraGetToolPath('rg');
1095
1058
  if (!executable)
1096
- throw new Error('Native executable is not installed');
1097
- return withStrayFileNotice(cwd, async () => nativeObservation(await runNativeProcess(executable, argv, cwd, timeout, context.signal, launchPolicy), true));
1059
+ throw new Error(program === 'rg'
1060
+ ? `ripgrep (rg) is not installed on this machine. Use the Grep tool instead: it searches without ripgrep. ${process.platform === 'win32' ? 'Select-String through PowerShell' : 'grep -rn through Bash'} also works.`
1061
+ : 'Native executable is not installed');
1062
+ return auditedCommand(cwd, [program, ...argv].join(' '), launchPolicy, async () => {
1063
+ try {
1064
+ return nativeObservation(await runNativeProcess(executable, argv, cwd, timeout, context.signal, launchPolicy), true);
1065
+ }
1066
+ catch (error) {
1067
+ const exited = error instanceof Error ? /^Exit code: (\d+)\n/.exec(error.message) : null;
1068
+ if (exited)
1069
+ throw new CommandExitError(nativeObservation(error.message, true), Number(exited[1]));
1070
+ throw error;
1071
+ }
1072
+ });
1098
1073
  });
1099
1074
  const AsyncProcess = zTool('AsyncProcess', `Start a shell command in the background and return immediately; inspect status/logs, wait for completion without polling, or stop it. Use for independent builds, test suites, and dev servers so other agent work can continue. Each job has a generated ID. ${PERSISTENT_JOBS_SUPPORTED
1100
1075
  ? 'Jobs are killed when the owning CLI exits unless started with persist: true. When the task is to leave a service running for the user (a web server, daemon or listener they will use after you finish), start it with persist: true and do not stop it before you finish.'
@@ -1115,6 +1090,9 @@ export function createCodingTools(policy) {
1115
1090
  if (command.length > 32000)
1116
1091
  throw new Error('Command is too long');
1117
1092
  assertNotHostKill(command, hostShellOf(defaultShellKind));
1093
+ assertNotGitIdentityOverride(command);
1094
+ await assertNoHoldEscape(command);
1095
+ assertCommandAvoidsHarnessHome(command, context);
1118
1096
  const launchPolicy = await shellPermission(policy, 'AsyncProcess', args, context);
1119
1097
  const id = `agent-${randomUUID()}`;
1120
1098
  const persist = boolArg(args, 'persist') === true;
@@ -1147,10 +1125,12 @@ export function createCodingTools(policy) {
1147
1125
  }, required: ['command'], additionalProperties: false }, 'sequential', async (args, context) => {
1148
1126
  const command = stringArg(args, 'command');
1149
1127
  assertNotHostKill(command, 'powershell');
1128
+ assertNotGitIdentityOverride(command);
1129
+ assertCommandAvoidsHarnessHome(command, context);
1150
1130
  const timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 30000;
1151
1131
  const launchPolicy = await shellPermission(policy, 'PowerShellFast', args, context);
1152
1132
  const cwd = await policy.safePath(context, '.');
1153
- return withStrayFileNotice(cwd, async () => nativeObservation(await runPooledPowerShell(command, cwd, timeout, context.signal, launchPolicy, context.onCommandOutput), true));
1133
+ return auditedCommand(cwd, command, launchPolicy, async () => nativeObservation(await runPooledPowerShell(command, cwd, timeout, context.signal, launchPolicy, context.onCommandOutput), true));
1154
1134
  });
1155
1135
  const ShellMetrics = zTool('ShellMetrics', 'Return bounded per-process command timing statistics (p50/p95/p99), startup/validation, execution, first-output and cleanup phases without leaking command arguments.', { type: 'object', properties: {}, additionalProperties: false }, 'parallel', async () => JSON.stringify(commandTimingSummary()));
1156
1136
  const platformShell = process.platform === 'win32' ? canonicalShell('PowerShell', 'powershell') : canonicalShell('Bash', 'bash');