@phuetz/code-buddy 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/README.fr.md +56 -0
  2. package/README.md +73 -16
  3. package/codebuddy-runtime.json +5 -5
  4. package/dist/agent/codebuddy-agent.d.ts +18 -0
  5. package/dist/agent/codebuddy-agent.js +45 -8
  6. package/dist/agent/execution/agent-executor.d.ts +0 -9
  7. package/dist/agent/execution/agent-executor.js +165 -12
  8. package/dist/agent/execution/context-pipeline.d.ts +9 -0
  9. package/dist/agent/execution/context-pipeline.js +64 -2
  10. package/dist/agent/execution/tool-loop-guard.d.ts +76 -0
  11. package/dist/agent/execution/tool-loop-guard.js +165 -0
  12. package/dist/agent/execution/tool-selection-strategy.js +19 -2
  13. package/dist/agent/facades/session-facade.d.ts +0 -6
  14. package/dist/agent/facades/session-facade.js +0 -45
  15. package/dist/agent/hermes-claw-migrate.d.ts +0 -21
  16. package/dist/agent/hermes-claw-migrate.js +9 -4
  17. package/dist/agent/hermes-protocol-gateways.js +8 -1
  18. package/dist/agent/repo-profiler.js +17 -4
  19. package/dist/agent/self-improvement/authored-tool-runtime.js +10 -2
  20. package/dist/agent/self-improvement/evolution/ast-novelty.d.ts +5 -0
  21. package/dist/agent/self-improvement/evolution/ast-novelty.js +58 -23
  22. package/dist/agent/self-improvement/evolution/code-variant-store.d.ts +3 -0
  23. package/dist/agent/self-improvement/evolution/evolution-engine.js +2 -0
  24. package/dist/agent/self-improvement/evolution/protected-paths.js +6 -0
  25. package/dist/agent/self-improvement/evolution/variant-fitness.d.ts +13 -2
  26. package/dist/agent/self-improvement/evolution/variant-fitness.js +184 -58
  27. package/dist/agent/self-improvement/evolution/worktree-scorer.d.ts +2 -0
  28. package/dist/agent/self-improvement/evolution/worktree-scorer.js +15 -0
  29. package/dist/agent/self-improvement/evolutionary-archive.d.ts +2 -1
  30. package/dist/agent/self-improvement/evolutionary-archive.js +34 -5
  31. package/dist/agent/self-improvement/proposal-store.d.ts +1 -0
  32. package/dist/agent/self-improvement/proposal-store.js +79 -17
  33. package/dist/agent/self-improvement/skill-apply-journal.d.ts +44 -0
  34. package/dist/agent/self-improvement/skill-apply-journal.js +178 -0
  35. package/dist/agent/self-improvement/skill-behavior-benchmark.d.ts +3 -0
  36. package/dist/agent/self-improvement/skill-behavior-benchmark.js +19 -0
  37. package/dist/agent/self-improvement/skill-behavior-gate.d.ts +34 -0
  38. package/dist/agent/self-improvement/skill-behavior-gate.js +96 -0
  39. package/dist/agent/self-improvement/skill-engine.d.ts +22 -0
  40. package/dist/agent/self-improvement/skill-engine.js +385 -13
  41. package/dist/agent/self-improvement/skill-gate.d.ts +2 -0
  42. package/dist/agent/self-improvement/skill-gate.js +17 -2
  43. package/dist/agent/self-improvement/skill-mutator.d.ts +6 -1
  44. package/dist/agent/self-improvement/skill-mutator.js +51 -15
  45. package/dist/agent/self-improvement/skill-types.d.ts +2 -1
  46. package/dist/agent/self-improvement/types.d.ts +11 -0
  47. package/dist/agent/tool-handler.d.ts +1 -1
  48. package/dist/agent/tool-handler.js +28 -9
  49. package/dist/auth/profile-manager.js +1 -1
  50. package/dist/channels/companion-channel-turn.d.ts +53 -4
  51. package/dist/channels/companion-channel-turn.js +218 -16
  52. package/dist/channels/slash-parity.d.ts +4 -6
  53. package/dist/channels/slash-parity.js +9 -44
  54. package/dist/cli/session-commands.d.ts +9 -0
  55. package/dist/cli/session-commands.js +45 -5
  56. package/dist/cli/session-picker.d.ts +43 -0
  57. package/dist/cli/session-picker.js +128 -0
  58. package/dist/codebuddy/a2a-call-tool-defs.d.ts +26 -0
  59. package/dist/codebuddy/a2a-call-tool-defs.js +12 -0
  60. package/dist/codebuddy/fleet-tool-defs.d.ts +1 -0
  61. package/dist/codebuddy/fleet-tool-defs.js +24 -0
  62. package/dist/codebuddy/providers/chatgpt-headers.d.ts +18 -0
  63. package/dist/codebuddy/providers/chatgpt-headers.js +37 -0
  64. package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +2 -1
  65. package/dist/codebuddy/providers/provider-chatgpt-responses.js +10 -23
  66. package/dist/codebuddy/providers/provider-openai-compat.js +1 -1
  67. package/dist/codebuddy/ragchat-tool-defs.d.ts +31 -0
  68. package/dist/codebuddy/ragchat-tool-defs.js +19 -0
  69. package/dist/codebuddy/resource-catalog-tool-defs.d.ts +28 -0
  70. package/dist/codebuddy/resource-catalog-tool-defs.js +18 -0
  71. package/dist/codebuddy/tool-definitions/agent-tools.js +2 -2
  72. package/dist/codebuddy/tool-definitions/code-exec-tools.js +5 -1
  73. package/dist/codebuddy/tool-definitions/cron-tools.js +6 -0
  74. package/dist/codebuddy/tool-definitions/self-describe-tools.js +6 -1
  75. package/dist/codebuddy/tools.d.ts +0 -6
  76. package/dist/codebuddy/tools.js +25 -3
  77. package/dist/commands/cli/daemon-commands.js +3 -1
  78. package/dist/commands/cli/evolve-command.js +21 -5
  79. package/dist/commands/cli/fleet-collaboration-commands.d.ts +2 -0
  80. package/dist/commands/cli/fleet-collaboration-commands.js +57 -0
  81. package/dist/commands/cli/fleet-commands.js +29 -0
  82. package/dist/commands/cli/fleet-mission-commands.d.ts +3 -0
  83. package/dist/commands/cli/fleet-mission-commands.js +72 -0
  84. package/dist/commands/cli/fleet-rooms-commands.d.ts +10 -0
  85. package/dist/commands/cli/fleet-rooms-commands.js +289 -0
  86. package/dist/commands/cli/tools-commands.js +2 -1
  87. package/dist/commands/cli/triage-command.d.ts +8 -0
  88. package/dist/commands/cli/triage-command.js +72 -0
  89. package/dist/commands/cli/utility-commands.js +25 -1
  90. package/dist/commands/client-dispatcher.d.ts +7 -0
  91. package/dist/commands/client-dispatcher.js +73 -21
  92. package/dist/commands/cron-cli/index.d.ts +3 -1
  93. package/dist/commands/cron-cli/index.js +25 -0
  94. package/dist/commands/device-auth.d.ts +10 -0
  95. package/dist/commands/device-auth.js +91 -0
  96. package/dist/commands/enhanced-command-handler.d.ts +9 -0
  97. package/dist/commands/enhanced-command-handler.js +28 -6
  98. package/dist/commands/handlers/agent-handlers.d.ts +1 -1
  99. package/dist/commands/handlers/agent-handlers.js +4 -4
  100. package/dist/commands/handlers/channel-handlers.js +53 -2
  101. package/dist/commands/handlers/export-handlers.d.ts +3 -2
  102. package/dist/commands/handlers/export-handlers.js +55 -28
  103. package/dist/commands/handlers/extra-handlers.js +5 -1
  104. package/dist/commands/handlers/grill-me-handler.js +26 -18
  105. package/dist/commands/handlers/memory-handlers.d.ts +6 -2
  106. package/dist/commands/handlers/memory-handlers.js +35 -15
  107. package/dist/commands/handlers/missing-handlers.d.ts +2 -2
  108. package/dist/commands/handlers/missing-handlers.js +4 -4
  109. package/dist/commands/handlers/resources-handler.d.ts +12 -0
  110. package/dist/commands/handlers/resources-handler.js +52 -0
  111. package/dist/commands/handlers/starter-handlers.d.ts +1 -1
  112. package/dist/commands/handlers/starter-handlers.js +32 -2
  113. package/dist/commands/handlers/switch-handler.d.ts +1 -1
  114. package/dist/commands/handlers/switch-handler.js +15 -0
  115. package/dist/commands/handlers/test-handlers.js +4 -86
  116. package/dist/commands/handlers/ui-handlers.js +11 -5
  117. package/dist/commands/login-chatgpt.d.ts +8 -0
  118. package/dist/commands/login-chatgpt.js +17 -0
  119. package/dist/commands/mcp-import.d.ts +11 -0
  120. package/dist/commands/mcp-import.js +67 -0
  121. package/dist/commands/mcp-invoke.d.ts +2 -0
  122. package/dist/commands/mcp-invoke.js +68 -0
  123. package/dist/commands/mcp.js +4 -0
  124. package/dist/commands/pipeline.d.ts +7 -1
  125. package/dist/commands/pipeline.js +104 -7
  126. package/dist/commands/resources.d.ts +2 -0
  127. package/dist/commands/resources.js +64 -0
  128. package/dist/commands/skills-cli/index.js +35 -12
  129. package/dist/commands/slash/builtin-commands.js +16 -3
  130. package/dist/commands/slash/index.d.ts +3 -1
  131. package/dist/commands/slash/index.js +2 -0
  132. package/dist/commands/slash/surfaces.d.ts +53 -0
  133. package/dist/commands/slash/surfaces.js +177 -0
  134. package/dist/commands/slash/types.d.ts +17 -0
  135. package/dist/commands/try.d.ts +1 -1
  136. package/dist/commands/try.js +1 -1
  137. package/dist/companion/companion-identity.d.ts +43 -0
  138. package/dist/companion/companion-identity.js +136 -0
  139. package/dist/companion/companion-toolset.d.ts +66 -0
  140. package/dist/companion/companion-toolset.js +368 -0
  141. package/dist/companion/companion-turn.d.ts +10 -2
  142. package/dist/companion/companion-turn.js +38 -1
  143. package/dist/config/code-exec-policy.d.ts +25 -0
  144. package/dist/config/code-exec-policy.js +39 -0
  145. package/dist/config/model-tools.d.ts +9 -0
  146. package/dist/config/model-tools.js +4 -0
  147. package/dist/context/context-manager-v2.js +2 -2
  148. package/dist/context/lm-resizer-compressor.js +3 -2
  149. package/dist/context/lm-resizer-diagnostics.d.ts +9 -0
  150. package/dist/context/lm-resizer-diagnostics.js +30 -0
  151. package/dist/context/tool-output-masking.js +3 -4
  152. package/dist/curator/curator.d.ts +6 -0
  153. package/dist/curator/curator.js +53 -3
  154. package/dist/daemon/cron-agent-bridge.d.ts +6 -0
  155. package/dist/daemon/cron-agent-bridge.js +31 -4
  156. package/dist/doctor/index.d.ts +11 -2
  157. package/dist/doctor/index.js +84 -21
  158. package/dist/doctor/integrations.d.ts +179 -0
  159. package/dist/doctor/integrations.js +227 -0
  160. package/dist/doctor/triage.d.ts +108 -0
  161. package/dist/doctor/triage.js +304 -0
  162. package/dist/fleet/collaboration.d.ts +44 -0
  163. package/dist/fleet/collaboration.js +170 -0
  164. package/dist/fleet/fleet-listener.d.ts +1 -0
  165. package/dist/fleet/fleet-listener.js +87 -46
  166. package/dist/fleet/fleet-registry.d.ts +2 -0
  167. package/dist/fleet/resource-catalog.d.ts +245 -0
  168. package/dist/fleet/resource-catalog.js +211 -0
  169. package/dist/fleet/rooms/room-access.d.ts +138 -0
  170. package/dist/fleet/rooms/room-access.js +196 -0
  171. package/dist/fleet/rooms/room-client.d.ts +158 -0
  172. package/dist/fleet/rooms/room-client.js +685 -0
  173. package/dist/fleet/rooms/room-event.d.ts +139 -0
  174. package/dist/fleet/rooms/room-event.js +330 -0
  175. package/dist/fleet/rooms/room-filter.d.ts +48 -0
  176. package/dist/fleet/rooms/room-filter.js +152 -0
  177. package/dist/fleet/rooms/room-hub.d.ts +154 -0
  178. package/dist/fleet/rooms/room-hub.js +363 -0
  179. package/dist/fleet/rooms/room-identity.d.ts +26 -0
  180. package/dist/fleet/rooms/room-identity.js +82 -0
  181. package/dist/fleet/rooms/room-lock.d.ts +34 -0
  182. package/dist/fleet/rooms/room-lock.js +180 -0
  183. package/dist/fleet/rooms/room-observations.d.ts +7 -0
  184. package/dist/fleet/rooms/room-observations.js +61 -0
  185. package/dist/fleet/rooms/room-server.d.ts +28 -0
  186. package/dist/fleet/rooms/room-server.js +75 -0
  187. package/dist/fleet/rooms/room-store.d.ts +119 -0
  188. package/dist/fleet/rooms/room-store.js +448 -0
  189. package/dist/fleet/rooms/room-ws-bridge.d.ts +27 -0
  190. package/dist/fleet/rooms/room-ws-bridge.js +137 -0
  191. package/dist/fleet/sensory-mission-bridge.d.ts +42 -0
  192. package/dist/fleet/sensory-mission-bridge.js +136 -0
  193. package/dist/git/worktree-sessions.js +1 -0
  194. package/dist/harness/contract.d.ts +4 -4
  195. package/dist/harness/fleet-supervisor.d.ts +16 -0
  196. package/dist/harness/fleet-supervisor.js +64 -0
  197. package/dist/harness/index.d.ts +4 -0
  198. package/dist/harness/index.js +4 -0
  199. package/dist/harness/mission-runner.d.ts +3 -0
  200. package/dist/harness/mission-runner.js +53 -0
  201. package/dist/harness/mission-store.d.ts +93 -0
  202. package/dist/harness/mission-store.js +297 -0
  203. package/dist/harness/tool-harness.d.ts +56 -0
  204. package/dist/harness/tool-harness.js +153 -0
  205. package/dist/hooks/use-enhanced-input.js +48 -4
  206. package/dist/hooks/use-input-handler.d.ts +1 -0
  207. package/dist/hooks/use-input-handler.js +82 -22
  208. package/dist/hooks/use-input-history.js +1 -0
  209. package/dist/identity/lisa-introspection.js +5 -2
  210. package/dist/identity/operational-self-model.d.ts +2 -0
  211. package/dist/identity/operational-self-model.js +4 -0
  212. package/dist/index.js +52 -6
  213. package/dist/mcp/client.js +6 -0
  214. package/dist/mcp/config.d.ts +20 -0
  215. package/dist/mcp/config.js +121 -8
  216. package/dist/mcp/import-normalize.d.ts +12 -0
  217. package/dist/mcp/import-normalize.js +114 -0
  218. package/dist/mcp/transports.d.ts +10 -5
  219. package/dist/mcp/transports.js +61 -99
  220. package/dist/mcp/types.d.ts +5 -0
  221. package/dist/media/comfyui-recipe-contract.d.ts +7 -7
  222. package/dist/memory/facts-memory.d.ts +11 -1
  223. package/dist/memory/facts-memory.js +47 -8
  224. package/dist/memory/memory-candidate-queue.d.ts +2 -2
  225. package/dist/memory/memory-candidate-queue.js +6 -6
  226. package/dist/memory/persistent-memory.d.ts +13 -8
  227. package/dist/memory/persistent-memory.js +77 -30
  228. package/dist/nodes/device-node.js +5 -9
  229. package/dist/observability/mobile-supervision-gateway-contract.js +20 -7
  230. package/dist/observability/run-event-writer.d.ts +21 -0
  231. package/dist/observability/run-event-writer.js +81 -0
  232. package/dist/observability/run-store.d.ts +5 -0
  233. package/dist/observability/run-store.js +18 -13
  234. package/dist/observability/run-trajectory.js +1 -1
  235. package/dist/optimization/prompt-cache.d.ts +19 -2
  236. package/dist/optimization/prompt-cache.js +41 -6
  237. package/dist/orchestration/orchestrator.d.ts +21 -0
  238. package/dist/orchestration/orchestrator.js +122 -15
  239. package/dist/persistence/session-content.d.ts +8 -0
  240. package/dist/persistence/session-content.js +76 -0
  241. package/dist/persistence/session-handoff.d.ts +64 -0
  242. package/dist/persistence/session-handoff.js +80 -0
  243. package/dist/persistence/session-history.d.ts +4 -0
  244. package/dist/persistence/session-history.js +38 -0
  245. package/dist/persistence/session-store.d.ts +9 -0
  246. package/dist/persistence/session-store.js +48 -20
  247. package/dist/personas/persona-manager.js +17 -1
  248. package/dist/plugins/code-explorer/CodeExplorerManager.d.ts +10 -4
  249. package/dist/plugins/code-explorer/CodeExplorerManager.js +69 -16
  250. package/dist/plugins/plugin-manager.js +10 -1
  251. package/dist/prompts/prompt-manager.js +11 -4
  252. package/dist/prompts/system-base.js +6 -2
  253. package/dist/protocols/a2a/codebuddy-executor.d.ts +11 -2
  254. package/dist/protocols/a2a/codebuddy-executor.js +9 -8
  255. package/dist/protocols/a2a/index.d.ts +1 -1
  256. package/dist/protocols/a2a/jsonrpc-v1.d.ts +41 -0
  257. package/dist/protocols/a2a/jsonrpc-v1.js +145 -0
  258. package/dist/protocols/a2a/peer-config.d.ts +20 -0
  259. package/dist/protocols/a2a/peer-config.js +55 -0
  260. package/dist/providers/codex-oauth.js +30 -6
  261. package/dist/providers/model-provider-compat.js +2 -1
  262. package/dist/sandbox/os-sandbox.d.ts +1 -1
  263. package/dist/scheduler/cron-scheduler.d.ts +15 -2
  264. package/dist/scheduler/cron-scheduler.js +35 -4
  265. package/dist/scheduler/job-notepad.d.ts +69 -0
  266. package/dist/scheduler/job-notepad.js +339 -0
  267. package/dist/security/audit-logger.d.ts +1 -1
  268. package/dist/security/compute-confinement.d.ts +4 -0
  269. package/dist/security/compute-confinement.js +89 -0
  270. package/dist/security/session-encryption.d.ts +4 -0
  271. package/dist/security/session-encryption.js +31 -0
  272. package/dist/sensory/voice-loop.d.ts +17 -0
  273. package/dist/sensory/voice-loop.js +72 -15
  274. package/dist/server/auth/device-session-context.d.ts +9 -0
  275. package/dist/server/auth/device-session-context.js +13 -0
  276. package/dist/server/auth/device-store.d.ts +89 -0
  277. package/dist/server/auth/device-store.js +261 -0
  278. package/dist/server/auth/device-token.d.ts +3 -0
  279. package/dist/server/auth/device-token.js +6 -0
  280. package/dist/server/auth/jwt.js +4 -0
  281. package/dist/server/index.d.ts +0 -10
  282. package/dist/server/index.js +28 -0
  283. package/dist/server/middleware/auth.js +3 -2
  284. package/dist/server/routes/a2a-jsonrpc.d.ts +9 -0
  285. package/dist/server/routes/a2a-jsonrpc.js +66 -0
  286. package/dist/server/routes/a2a-protocol.d.ts +12 -0
  287. package/dist/server/routes/a2a-protocol.js +1 -1
  288. package/dist/server/routes/device-auth.d.ts +4 -0
  289. package/dist/server/routes/device-auth.js +40 -0
  290. package/dist/server/types.d.ts +4 -0
  291. package/dist/server/websocket/handler.d.ts +13 -0
  292. package/dist/server/websocket/handler.js +102 -17
  293. package/dist/services/prompt-builder.d.ts +2 -0
  294. package/dist/services/prompt-builder.js +13 -5
  295. package/dist/services/runtime-settings-context.d.ts +73 -0
  296. package/dist/services/runtime-settings-context.js +69 -0
  297. package/dist/skills/executor.js +2 -0
  298. package/dist/skills/hub.js +16 -14
  299. package/dist/skills/local-inventory.d.ts +21 -0
  300. package/dist/skills/local-inventory.js +72 -0
  301. package/dist/skills/skill-loader.js +2 -2
  302. package/dist/skills/skill-usage-store.d.ts +49 -0
  303. package/dist/skills/skill-usage-store.js +121 -0
  304. package/dist/testing/ai-integration-tests.js +8 -5
  305. package/dist/themes/theme-manager.d.ts +12 -0
  306. package/dist/themes/theme-manager.js +29 -0
  307. package/dist/themes/theme-schema.d.ts +24 -24
  308. package/dist/tools/a2a-call-tool.d.ts +34 -0
  309. package/dist/tools/a2a-call-tool.js +75 -0
  310. package/dist/tools/bash/streaming-executor.d.ts +1 -0
  311. package/dist/tools/bash/streaming-executor.js +78 -90
  312. package/dist/tools/code-exec-preflight-runner.d.ts +41 -0
  313. package/dist/tools/code-exec-preflight-runner.js +254 -0
  314. package/dist/tools/code-exec-preflight.d.ts +44 -0
  315. package/dist/tools/code-exec-preflight.js +501 -0
  316. package/dist/tools/code-exec-tool.d.ts +48 -1
  317. package/dist/tools/code-exec-tool.js +191 -47
  318. package/dist/tools/comment-watcher.js +29 -12
  319. package/dist/tools/core-code-inspection.d.ts +56 -0
  320. package/dist/tools/core-code-inspection.js +86 -0
  321. package/dist/tools/create-skill-tool.d.ts +2 -3
  322. package/dist/tools/create-skill-tool.js +16 -75
  323. package/dist/tools/cronjob-tool.d.ts +1 -0
  324. package/dist/tools/cronjob-tool.js +1 -0
  325. package/dist/tools/env-doctor-tool.d.ts +2 -0
  326. package/dist/tools/env-doctor-tool.js +4 -3
  327. package/dist/tools/execute-code-rpc-invoker.d.ts +1 -1
  328. package/dist/tools/execute-code-rpc-invoker.js +35 -19
  329. package/dist/tools/execute-code-runner.d.ts +2 -0
  330. package/dist/tools/execute-code-runner.js +52 -17
  331. package/dist/tools/fleet-room-tool.d.ts +104 -0
  332. package/dist/tools/fleet-room-tool.js +124 -0
  333. package/dist/tools/integration-tool-hints.d.ts +4 -0
  334. package/dist/tools/integration-tool-hints.js +19 -0
  335. package/dist/tools/list-peers-tool.d.ts +3 -0
  336. package/dist/tools/list-peers-tool.js +11 -4
  337. package/dist/tools/media-generation-tool.d.ts +16 -1
  338. package/dist/tools/media-generation-tool.js +341 -9
  339. package/dist/tools/merge-conflict-tool.js +53 -25
  340. package/dist/tools/metadata.d.ts +1 -5
  341. package/dist/tools/metadata.js +21 -28
  342. package/dist/tools/ragchat-tool.d.ts +39 -0
  343. package/dist/tools/ragchat-tool.js +105 -0
  344. package/dist/tools/registry/fleet-tools.d.ts +9 -0
  345. package/dist/tools/registry/fleet-tools.js +22 -1
  346. package/dist/tools/registry/knowledge-tools.d.ts +2 -2
  347. package/dist/tools/registry/knowledge-tools.js +2 -2
  348. package/dist/tools/registry/lessons-tools.d.ts +7 -0
  349. package/dist/tools/registry/lessons-tools.js +43 -3
  350. package/dist/tools/registry/memory-tools.d.ts +1 -1
  351. package/dist/tools/registry/memory-tools.js +8 -8
  352. package/dist/tools/registry/research-tools.d.ts +1 -0
  353. package/dist/tools/registry/research-tools.js +4 -13
  354. package/dist/tools/registry/self-describe-tools.d.ts +1 -1
  355. package/dist/tools/registry/self-describe-tools.js +43 -30
  356. package/dist/tools/resource-catalog-tool.d.ts +38 -0
  357. package/dist/tools/resource-catalog-tool.js +46 -0
  358. package/dist/tools/skills-inspection-tool.js +30 -1
  359. package/dist/tools/stream-tool-output.d.ts +3 -0
  360. package/dist/tools/stream-tool-output.js +33 -0
  361. package/dist/tools/tool-call-scheduler.d.ts +10 -0
  362. package/dist/tools/tool-call-scheduler.js +58 -0
  363. package/dist/tools/tool-effect.d.ts +5 -0
  364. package/dist/tools/tool-effect.js +26 -0
  365. package/dist/tools/tool-search.d.ts +12 -11
  366. package/dist/tools/tool-search.js +67 -26
  367. package/dist/tools/types.d.ts +6 -0
  368. package/dist/ui/components/ChatHistory.d.ts +1 -1
  369. package/dist/ui/components/ChatHistory.js +2 -2
  370. package/dist/ui/components/ChatInput.d.ts +2 -1
  371. package/dist/ui/components/ChatInput.js +42 -88
  372. package/dist/ui/components/ChatInterface.d.ts +4 -2
  373. package/dist/ui/components/ChatInterface.js +27 -63
  374. package/dist/ui/components/CommandSuggestions.d.ts +0 -1
  375. package/dist/ui/components/CommandSuggestions.js +4 -6
  376. package/dist/ui/components/FileAutocomplete.js +1 -1
  377. package/dist/ui/components/KeyboardHelp.js +8 -6
  378. package/dist/ui/components/ModelSelection.js +6 -5
  379. package/dist/ui/components/StatusBar.d.ts +2 -1
  380. package/dist/ui/components/StatusBar.js +8 -7
  381. package/dist/ui/context/theme-context.js +3 -2
  382. package/dist/ui/index.d.ts +1 -1
  383. package/dist/ui/index.js +1 -1
  384. package/dist/ui/utils/markdown-renderer.js +4 -13
  385. package/dist/utils/atomic-write.d.ts +22 -0
  386. package/dist/utils/atomic-write.js +29 -0
  387. package/dist/utils/bounded-output.d.ts +16 -0
  388. package/dist/utils/bounded-output.js +63 -0
  389. package/dist/utils/device-store-file.d.ts +4 -0
  390. package/dist/utils/device-store-file.js +40 -0
  391. package/dist/utils/export-manager.d.ts +9 -0
  392. package/dist/utils/export-manager.js +19 -0
  393. package/dist/utils/first-use-hints.d.ts +25 -0
  394. package/dist/utils/first-use-hints.js +58 -0
  395. package/dist/utils/history-manager.js +1 -1
  396. package/dist/utils/update-notifier.js +16 -18
  397. package/dist/wizard/environment-detection.d.ts +5 -1
  398. package/dist/wizard/environment-detection.js +49 -7
  399. package/dist/wizard/onboarding.d.ts +5 -1
  400. package/dist/wizard/onboarding.js +90 -30
  401. package/dist/wizard/provider-onboarding.d.ts +2 -0
  402. package/dist/wizard/provider-onboarding.js +55 -17
  403. package/package.json +7 -3
@@ -0,0 +1,501 @@
1
+ /**
2
+ * TypeScript preflight validation for Code Mode (`code_exec`).
3
+ *
4
+ * Runs isolated TypeScript typechecking in a sandboxed worker/child process
5
+ * against declarations derived exclusively from the runtime-scoped tool catalog.
6
+ *
7
+ * Invariants:
8
+ * 1. Hard 5s deadline + 128MB heap isolation in a separate worker/child process.
9
+ * 2. Lazy loading: TypeScript is NOT imported in the parent process or when typecheck is false.
10
+ * 3. Bounded diagnostics: limited to 20 diagnostics and 16KB total formatted output.
11
+ * 4. Zero guest filesystem access: virtual files only in-memory; no guest file reads/writes.
12
+ * 5. No hidden tool/import exposure: declarations are generated strictly from `availableTools`.
13
+ * 6. Fail-closed: invalid code or compiler/global errors are rejected before child process spawn or tool dispatch.
14
+ */
15
+ import { spawn } from 'node:child_process';
16
+ import path from 'node:path';
17
+ import fs from 'node:fs';
18
+ import { createRequire } from 'node:module';
19
+ import { fileURLToPath } from 'node:url';
20
+ import { buildToolBindings, sanitizeToolName, CODE_EXEC_LIMITS, } from './code-exec-tool.js';
21
+ import { FormalToolRegistry } from './registry/tool-registry.js';
22
+ import { ToolRegistry } from './registry.js';
23
+ const PREFLIGHT_LIMITS = { timeoutMs: 5000, maxHeapMb: 128 };
24
+ function sanitizeJsDoc(text) {
25
+ if (!text)
26
+ return '';
27
+ return text.replace(/\*\//g, '* /');
28
+ }
29
+ function isValidIdentifier(name) {
30
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
31
+ }
32
+ function formatPropKey(name) {
33
+ return isValidIdentifier(name) ? name : JSON.stringify(name);
34
+ }
35
+ export function jsonSchemaPropertyToTs(prop, indent = ' ') {
36
+ if (!prop || typeof prop !== 'object') {
37
+ return 'any';
38
+ }
39
+ const p = prop;
40
+ if (Array.isArray(p.enum) && p.enum.length > 0) {
41
+ return p.enum
42
+ .map((item) => (typeof item === 'string' ? JSON.stringify(item) : String(item)))
43
+ .join(' | ');
44
+ }
45
+ if (Array.isArray(p.oneOf) && p.oneOf.length > 0) {
46
+ return p.oneOf.map((sub) => jsonSchemaPropertyToTs(sub, indent)).join(' | ');
47
+ }
48
+ if (Array.isArray(p.anyOf) && p.anyOf.length > 0) {
49
+ return p.anyOf.map((sub) => jsonSchemaPropertyToTs(sub, indent)).join(' | ');
50
+ }
51
+ const type = p.type;
52
+ if (Array.isArray(type)) {
53
+ return type.map((t) => jsonSchemaPropertyToTs({ ...p, type: t }, indent)).join(' | ');
54
+ }
55
+ switch (type) {
56
+ case 'string':
57
+ return 'string';
58
+ case 'number':
59
+ case 'integer':
60
+ return 'number';
61
+ case 'boolean':
62
+ return 'boolean';
63
+ case 'null':
64
+ return 'null';
65
+ case 'array': {
66
+ const items = p.items ? jsonSchemaPropertyToTs(p.items, indent) : 'any';
67
+ return `Array<${items}>`;
68
+ }
69
+ case 'object': {
70
+ const properties = p.properties;
71
+ if (properties && typeof properties === 'object' && Object.keys(properties).length > 0) {
72
+ const requiredList = Array.isArray(p.required) ? p.required : [];
73
+ const lines = ['{'];
74
+ const nextIndent = indent + ' ';
75
+ for (const [key, propDef] of Object.entries(properties)) {
76
+ const isReq = requiredList.includes(key) ||
77
+ (propDef && typeof propDef === 'object' && propDef.required === true);
78
+ const propDesc = propDef && typeof propDef === 'object'
79
+ ? propDef.description
80
+ : undefined;
81
+ if (typeof propDesc === 'string' && propDesc) {
82
+ lines.push(`${nextIndent}/** ${sanitizeJsDoc(propDesc)} */`);
83
+ }
84
+ const opt = isReq ? '' : '?';
85
+ const typeStr = jsonSchemaPropertyToTs(propDef, nextIndent);
86
+ lines.push(`${nextIndent}${formatPropKey(key)}${opt}: ${typeStr};`);
87
+ }
88
+ if (p.additionalProperties !== false) {
89
+ lines.push(`${nextIndent}[key: string]: any;`);
90
+ }
91
+ lines.push(`${indent}}`);
92
+ return lines.join('\n');
93
+ }
94
+ return 'Record<string, any>';
95
+ }
96
+ default:
97
+ return 'any';
98
+ }
99
+ }
100
+ export function extractToolArgsType(toolName, parameters, typeIndex) {
101
+ const typeName = `Args_${sanitizeToolName(toolName)}_${typeIndex}`;
102
+ if (!parameters || typeof parameters !== 'object') {
103
+ return {
104
+ typeName,
105
+ typeDeclaration: `export type ${typeName} = Record<string, any>;`,
106
+ hasRequiredProps: false,
107
+ };
108
+ }
109
+ const params = parameters;
110
+ let properties = params.properties;
111
+ let requiredList = Array.isArray(params.required) ? params.required : [];
112
+ // Formal parameter definition dictionary (e.g. BaseTool getParameters format)
113
+ if (!properties && !params.type && Object.keys(params).length > 0) {
114
+ const firstVal = Object.values(params)[0];
115
+ if (firstVal && typeof firstVal === 'object' && ('type' in firstVal || 'description' in firstVal)) {
116
+ properties = params;
117
+ requiredList = Object.entries(params)
118
+ .filter(([, v]) => v && typeof v === 'object' && v.required === true)
119
+ .map(([k]) => k);
120
+ }
121
+ }
122
+ if (!properties || Object.keys(properties).length === 0) {
123
+ return {
124
+ typeName,
125
+ typeDeclaration: `export type ${typeName} = Record<string, any>;`,
126
+ hasRequiredProps: false,
127
+ };
128
+ }
129
+ let hasRequired = false;
130
+ const lines = [`export interface ${typeName} {`];
131
+ for (const [key, propDef] of Object.entries(properties)) {
132
+ const isReq = requiredList.includes(key) ||
133
+ (propDef && typeof propDef === 'object' && propDef.required === true);
134
+ if (isReq)
135
+ hasRequired = true;
136
+ const propDesc = propDef && typeof propDef === 'object'
137
+ ? propDef.description
138
+ : undefined;
139
+ if (typeof propDesc === 'string' && propDesc) {
140
+ lines.push(` /** ${sanitizeJsDoc(propDesc)} */`);
141
+ }
142
+ const opt = isReq ? '' : '?';
143
+ const typeStr = jsonSchemaPropertyToTs(propDef, ' ');
144
+ lines.push(` ${formatPropKey(key)}${opt}: ${typeStr};`);
145
+ }
146
+ if (params.additionalProperties !== false) {
147
+ lines.push(' [key: string]: any;');
148
+ }
149
+ lines.push('}');
150
+ return {
151
+ typeName,
152
+ typeDeclaration: lines.join('\n'),
153
+ hasRequiredProps: hasRequired,
154
+ };
155
+ }
156
+ /**
157
+ * Resolve tool catalog entries strictly scoped to `runtime.availableTools`.
158
+ * Tools not in `runtime.availableTools` are never returned.
159
+ */
160
+ export function resolveScopedToolCatalog(runtime, context) {
161
+ const entries = [];
162
+ const seen = new Set();
163
+ const explicitCatalog = runtime.toolCatalog;
164
+ const contextCatalog = (context?.extra?.toolSearchCatalog ?? context?.extra?.toolCatalog);
165
+ const catalogMap = new Map();
166
+ if (Array.isArray(explicitCatalog)) {
167
+ for (const entry of explicitCatalog) {
168
+ if (entry && typeof entry.name === 'string') {
169
+ catalogMap.set(entry.name, entry);
170
+ }
171
+ }
172
+ }
173
+ if (Array.isArray(contextCatalog)) {
174
+ for (const entry of contextCatalog) {
175
+ if (entry && typeof entry.name === 'string' && !catalogMap.has(entry.name)) {
176
+ catalogMap.set(entry.name, entry);
177
+ }
178
+ }
179
+ }
180
+ const formalRegistry = FormalToolRegistry.getInstance();
181
+ const legacyRegistry = ToolRegistry.getInstance();
182
+ for (const toolName of runtime.availableTools) {
183
+ if (typeof toolName !== 'string' ||
184
+ !toolName ||
185
+ toolName === 'code_exec' ||
186
+ toolName === 'exec' ||
187
+ seen.has(toolName)) {
188
+ continue;
189
+ }
190
+ seen.add(toolName);
191
+ const fromCatalog = catalogMap.get(toolName);
192
+ if (fromCatalog) {
193
+ entries.push({
194
+ name: toolName,
195
+ description: fromCatalog.description ?? '',
196
+ parameters: fromCatalog.parameters,
197
+ });
198
+ continue;
199
+ }
200
+ const formalTool = formalRegistry.get(toolName);
201
+ if (formalTool) {
202
+ try {
203
+ const schema = formalTool.tool.getSchema();
204
+ entries.push({
205
+ name: toolName,
206
+ description: schema.description ?? formalTool.metadata.description ?? '',
207
+ parameters: schema.parameters,
208
+ });
209
+ continue;
210
+ }
211
+ catch {
212
+ // Fallback to metadata
213
+ }
214
+ }
215
+ const legacyTool = legacyRegistry.getTool(toolName);
216
+ if (legacyTool) {
217
+ entries.push({
218
+ name: toolName,
219
+ description: legacyTool.definition.function.description ?? legacyTool.metadata.description ?? '',
220
+ parameters: legacyTool.definition.function.parameters,
221
+ });
222
+ continue;
223
+ }
224
+ const meta = runtime.toolMetadata?.find((t) => t.name === toolName);
225
+ entries.push({
226
+ name: toolName,
227
+ description: meta?.description ?? '',
228
+ parameters: undefined,
229
+ });
230
+ }
231
+ return entries;
232
+ }
233
+ /**
234
+ * Generate TypeScript declarations matching the scoped runtime environment.
235
+ */
236
+ export function generateToolDeclarations(scopedTools) {
237
+ const bindings = buildToolBindings(scopedTools.map((t) => t.name));
238
+ const bindingMap = new Map(bindings.map((b) => [b.toolName, b.exposedName]));
239
+ const typeDecls = [];
240
+ const directMethods = [];
241
+ const callOverloads = [];
242
+ let typeIndex = 0;
243
+ for (const tool of scopedTools) {
244
+ const exposedName = bindingMap.get(tool.name);
245
+ const argsInfo = extractToolArgsType(tool.name, tool.parameters, ++typeIndex);
246
+ typeDecls.push(argsInfo.typeDeclaration);
247
+ const doc = tool.description ? ` /** ${sanitizeJsDoc(tool.description)} */\n` : '';
248
+ const argsParam = argsInfo.hasRequiredProps
249
+ ? `args: ${argsInfo.typeName}`
250
+ : `args?: ${argsInfo.typeName}`;
251
+ if (exposedName) {
252
+ directMethods.push(`${doc} ${exposedName}(${argsParam}): Promise<ToolResult>;`);
253
+ }
254
+ callOverloads.push(`${doc} call(name: ${JSON.stringify(tool.name)}, ${argsParam}): Promise<ToolResult>;`);
255
+ }
256
+ if (callOverloads.length === 0) {
257
+ callOverloads.push(' call(name: never, args?: never): Promise<ToolResult>;');
258
+ }
259
+ return `
260
+ export interface ToolResult {
261
+ success: boolean;
262
+ output?: string;
263
+ data?: any;
264
+ error?: string;
265
+ truncated?: boolean;
266
+ }
267
+
268
+ export interface ToolMetadataEntry {
269
+ readonly name: string;
270
+ readonly description: string;
271
+ }
272
+
273
+ ${typeDecls.join('\n\n')}
274
+
275
+ export interface Tools {
276
+ ${directMethods.join('\n')}
277
+
278
+ ${callOverloads.join('\n')}
279
+ }
280
+
281
+ declare global {
282
+ const tools: Tools;
283
+ function text(content: unknown): void;
284
+ function store(key: string, value: unknown): void;
285
+ function load<T = unknown>(key: string): T | undefined;
286
+ function yield_control(): Promise<void>;
287
+
288
+ const ALL_TOOLS: ReadonlyArray<ToolMetadataEntry>;
289
+ const ALL_TOOL_NAMES: ReadonlyArray<string>;
290
+
291
+ const console: {
292
+ log(...args: any[]): void;
293
+ error(...args: any[]): void;
294
+ warn(...args: any[]): void;
295
+ };
296
+ }
297
+
298
+ export {};
299
+ `;
300
+ }
301
+ function resolvePreflightRunnerPath() {
302
+ try {
303
+ const currentDir = path.dirname(fileURLToPath(import.meta.url));
304
+ const distPath = path.join(currentDir, 'code-exec-preflight-runner.js');
305
+ if (fs.existsSync(distPath))
306
+ return distPath;
307
+ const builtFromSourcePath = path.resolve(currentDir, '..', '..', 'dist', 'tools', 'code-exec-preflight-runner.js');
308
+ if (fs.existsSync(builtFromSourcePath))
309
+ return builtFromSourcePath;
310
+ const srcPath = path.join(currentDir, 'code-exec-preflight-runner.ts');
311
+ if (fs.existsSync(srcPath))
312
+ return srcPath;
313
+ throw new Error('Bundled preflight compiler is missing');
314
+ }
315
+ catch (error) {
316
+ throw new Error(`Cannot resolve bundled preflight compiler: ${String(error)}`);
317
+ }
318
+ }
319
+ function getRunnerSpawnArgs(runnerPath) {
320
+ const args = [`--max-old-space-size=${PREFLIGHT_LIMITS.maxHeapMb}`, '--no-warnings'];
321
+ if (runnerPath.endsWith('.ts')) {
322
+ const require = createRequire(import.meta.url);
323
+ args.push(require.resolve('tsx/cli'));
324
+ }
325
+ args.push(runnerPath);
326
+ return args;
327
+ }
328
+ function terminateWorker(child) {
329
+ try {
330
+ if (child.connected)
331
+ child.disconnect();
332
+ }
333
+ catch {
334
+ /* already disconnected */
335
+ }
336
+ try {
337
+ if (!child.killed)
338
+ child.kill('SIGKILL');
339
+ }
340
+ catch {
341
+ /* already terminated */
342
+ }
343
+ }
344
+ /**
345
+ * Execute isolated TypeScript preflight typechecking in a worker/child process.
346
+ */
347
+ export async function runCodeExecPreflight(code, runtime, context, options) {
348
+ const activeSignal = options?.signal ?? runtime.abortSignal ?? context?.abortSignal;
349
+ if (activeSignal?.aborted) {
350
+ return {
351
+ success: false,
352
+ diagnostics: [{ message: 'TypeScript preflight validation cancelled', category: 'error' }],
353
+ error: 'TypeScript preflight validation cancelled',
354
+ };
355
+ }
356
+ if (code.length > CODE_EXEC_LIMITS.maxCodeChars) {
357
+ return {
358
+ success: false,
359
+ diagnostics: [
360
+ {
361
+ message: `code exceeds the ${CODE_EXEC_LIMITS.maxCodeChars}-character limit`,
362
+ category: 'error',
363
+ },
364
+ ],
365
+ error: `code exceeds the ${CODE_EXEC_LIMITS.maxCodeChars}-character limit`,
366
+ };
367
+ }
368
+ const scopedCatalog = options?.catalog ?? resolveScopedToolCatalog(runtime, context);
369
+ if (scopedCatalog.length > 4096 || JSON.stringify(scopedCatalog).length > 1000000)
370
+ return { success: false, diagnostics: [], error: 'Preflight catalog exceeds size limit' };
371
+ const declarations = generateToolDeclarations(scopedCatalog);
372
+ if (declarations.length > 1000000)
373
+ return { success: false, diagnostics: [], error: 'Preflight declarations exceed size limit' };
374
+ const runnerPath = resolvePreflightRunnerPath();
375
+ return new Promise((resolve) => {
376
+ let settled = false;
377
+ let stderr = '';
378
+ const child = spawn(process.execPath, getRunnerSpawnArgs(runnerPath), {
379
+ cwd: runtime.cwd || process.cwd(),
380
+ env: {
381
+ HOME: '/nonexistent',
382
+ LANG: 'C.UTF-8',
383
+ LC_ALL: 'C.UTF-8',
384
+ NODE_NO_WARNINGS: '1',
385
+ PATH: process.env.PATH ?? '',
386
+ },
387
+ stdio: ['ignore', 'ignore', 'pipe', 'ipc'],
388
+ serialization: 'advanced',
389
+ windowsHide: true,
390
+ });
391
+ const finish = (result) => {
392
+ if (settled)
393
+ return;
394
+ settled = true;
395
+ clearTimeout(timer);
396
+ activeSignal?.removeEventListener('abort', onAbort);
397
+ terminateWorker(child);
398
+ resolve(result);
399
+ };
400
+ const timer = setTimeout(() => {
401
+ finish({
402
+ success: false,
403
+ diagnostics: [
404
+ {
405
+ message: `TypeScript preflight validation timed out after ${PREFLIGHT_LIMITS.timeoutMs}ms`,
406
+ category: 'error',
407
+ },
408
+ ],
409
+ error: `TypeScript preflight validation timed out after ${PREFLIGHT_LIMITS.timeoutMs}ms`,
410
+ declarations,
411
+ });
412
+ }, PREFLIGHT_LIMITS.timeoutMs);
413
+ const onAbort = () => {
414
+ finish({
415
+ success: false,
416
+ diagnostics: [
417
+ {
418
+ message: 'TypeScript preflight validation cancelled',
419
+ category: 'error',
420
+ },
421
+ ],
422
+ error: 'TypeScript preflight validation cancelled',
423
+ declarations,
424
+ });
425
+ };
426
+ if (activeSignal?.aborted) {
427
+ onAbort();
428
+ return;
429
+ }
430
+ activeSignal?.addEventListener('abort', onAbort, { once: true });
431
+ child.stderr?.on('data', (chunk) => {
432
+ if (stderr.length < 4_096) {
433
+ stderr += String(chunk).slice(0, 4_096 - stderr.length);
434
+ }
435
+ });
436
+ child.on('error', (err) => {
437
+ finish({
438
+ success: false,
439
+ diagnostics: [
440
+ {
441
+ message: `TypeScript preflight runner spawn failed: ${err.message}`,
442
+ category: 'error',
443
+ },
444
+ ],
445
+ error: `TypeScript preflight runner spawn failed: ${err.message}`,
446
+ declarations,
447
+ });
448
+ });
449
+ child.on('exit', (codeValue, signal) => {
450
+ if (settled)
451
+ return;
452
+ const detail = stderr.trim() || `exit=${codeValue ?? 'null'} signal=${signal ?? 'none'}`;
453
+ finish({
454
+ success: false,
455
+ diagnostics: [
456
+ {
457
+ message: `TypeScript preflight worker process terminated unexpectedly (heap limit ${PREFLIGHT_LIMITS.maxHeapMb}MB exceeded or crashed: ${detail})`,
458
+ category: 'error',
459
+ },
460
+ ],
461
+ error: `TypeScript preflight worker process terminated unexpectedly (${detail})`,
462
+ declarations,
463
+ });
464
+ });
465
+ child.on('message', (raw) => {
466
+ const msg = raw;
467
+ if (!msg || typeof msg !== 'object' || settled)
468
+ return;
469
+ if (msg.type === 'result' && msg.result) {
470
+ finish(msg.result);
471
+ }
472
+ else if (msg.type === 'error') {
473
+ finish({
474
+ success: false,
475
+ diagnostics: [{ message: msg.error || 'Preflight compilation error', category: 'error' }],
476
+ error: msg.error || 'Preflight compilation error',
477
+ declarations,
478
+ });
479
+ }
480
+ });
481
+ child.send({
482
+ type: 'compile',
483
+ payload: {
484
+ code,
485
+ declarations,
486
+ strict: options?.strict,
487
+ target: options?.target,
488
+ },
489
+ }, (err) => {
490
+ if (err) {
491
+ finish({
492
+ success: false,
493
+ diagnostics: [{ message: `Preflight IPC failed: ${err.message}`, category: 'error' }],
494
+ error: `Preflight IPC failed: ${err.message}`,
495
+ declarations,
496
+ });
497
+ }
498
+ });
499
+ });
500
+ }
501
+ //# sourceMappingURL=code-exec-preflight.js.map
@@ -12,10 +12,16 @@
12
12
  * busy after vm's synchronous timeout. The parent can always terminate the
13
13
  * child, and recent Node versions add the permission model as defense in depth.
14
14
  */
15
+ import { type ChildProcess } from 'node:child_process';
15
16
  import { BaseTool, type ParameterDefinition } from './base-tool.js';
16
17
  import type { IToolExecutionContext, IValidationResult } from './registry/types.js';
17
18
  import type { ToolResult } from '../types/index.js';
18
- export type ToolExecutor = (toolName: string, args: Record<string, unknown>) => Promise<ToolResult>;
19
+ export type ToolExecutor = (toolName: string, args: Record<string, unknown>, signal?: AbortSignal) => Promise<ToolResult>;
20
+ export interface ToolCatalogEntry {
21
+ name: string;
22
+ description?: string;
23
+ parameters?: unknown;
24
+ }
19
25
  /** Per-agent/per-session bridge injected by ToolHandler for one invocation. */
20
26
  export interface CodeExecRuntime {
21
27
  /** Stable isolation key. Include both the owning agent and current session. */
@@ -24,6 +30,14 @@ export interface CodeExecRuntime {
24
30
  agentId?: string;
25
31
  cwd?: string;
26
32
  availableTools: readonly string[];
33
+ toolMetadata?: readonly {
34
+ name: string;
35
+ description: string;
36
+ }[];
37
+ toolCatalog?: readonly ToolCatalogEntry[];
38
+ parallelTools?: readonly string[];
39
+ onOutput?: (delta: string) => void;
40
+ resultFormat?: 'structured' | 'legacy';
27
41
  executor: ToolExecutor;
28
42
  abortSignal?: AbortSignal;
29
43
  }
@@ -55,6 +69,39 @@ export declare function clearAllCodeExecSessions(): void;
55
69
  */
56
70
  export declare function setCodeModeToolExecutor(executor: ToolExecutor, tools: string[]): void;
57
71
  export declare function resetCodeModeState(): void;
72
+ export declare function sanitizeToolName(name: string): string;
73
+ export interface ToolBinding {
74
+ exposedName: string;
75
+ toolName: string;
76
+ }
77
+ export declare function buildToolBindings(toolNames: readonly string[]): ToolBinding[];
78
+ /** Upper bound on waiting for the sandbox process to report `close`. */
79
+ export declare const CHILD_CLOSE_GRACE_MS = 2000;
80
+ /**
81
+ * Wait for the OBSERVED `close` of the sandbox process — the event that says
82
+ * the process ended and its stdio is released. `exit` alone is not enough:
83
+ * `exitCode` can be set while stdio is still open, and the sandbox runs with
84
+ * the caller's workspace as its working directory, so the caller must not be
85
+ * told the workspace is free before the process really let go of it.
86
+ *
87
+ * @returns true when `close` was observed (or there is no process to wait for),
88
+ * false when the grace elapsed first. The caller decides what an
89
+ * unterminated sandbox means; this function never claims success.
90
+ */
91
+ export declare function waitForChildClose(child: ChildProcess, graceMs?: number): Promise<boolean>;
92
+ /**
93
+ * A sandbox process that did not close within the grace is a cleanup failure:
94
+ * it may still hold the workspace. Never report success in that case, and keep
95
+ * the original diagnosis when the run had already failed.
96
+ */
97
+ export declare function sandboxNotTerminatedResult(result: ChildRunResult, graceMs?: number): ChildRunResult;
98
+ export interface ChildRunResult {
99
+ success: boolean;
100
+ output: string;
101
+ yielded?: boolean;
102
+ storeEntries?: Array<[string, unknown]>;
103
+ timedOut?: boolean;
104
+ }
58
105
  export declare class CodeExecTool extends BaseTool {
59
106
  readonly name = "code_exec";
60
107
  readonly description = "Execute bounded JavaScript orchestration. Call registered tools with await tools.<name>({...}) or await tools.call(name, {...}); use text(), store()/load(), ALL_TOOLS, and yield_control(). Effects still pass through normal confirmations and policies.";