@phuetz/code-buddy 2.0.0 → 2.2.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 (421) hide show
  1. package/README.fr.md +56 -0
  2. package/README.md +74 -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 +176 -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.d.ts +7 -0
  13. package/dist/agent/execution/tool-selection-strategy.js +32 -2
  14. package/dist/agent/facades/session-facade.d.ts +0 -6
  15. package/dist/agent/facades/session-facade.js +0 -45
  16. package/dist/agent/hermes-claw-migrate.d.ts +0 -21
  17. package/dist/agent/hermes-claw-migrate.js +9 -4
  18. package/dist/agent/hermes-protocol-gateways.js +8 -1
  19. package/dist/agent/repo-profiler.js +17 -4
  20. package/dist/agent/self-improvement/authored-tool-runtime.js +10 -2
  21. package/dist/agent/self-improvement/evolution/ast-novelty.d.ts +5 -0
  22. package/dist/agent/self-improvement/evolution/ast-novelty.js +58 -23
  23. package/dist/agent/self-improvement/evolution/code-variant-store.d.ts +3 -0
  24. package/dist/agent/self-improvement/evolution/evolution-engine.js +2 -0
  25. package/dist/agent/self-improvement/evolution/protected-paths.js +6 -0
  26. package/dist/agent/self-improvement/evolution/variant-fitness.d.ts +13 -2
  27. package/dist/agent/self-improvement/evolution/variant-fitness.js +184 -58
  28. package/dist/agent/self-improvement/evolution/worktree-scorer.d.ts +2 -0
  29. package/dist/agent/self-improvement/evolution/worktree-scorer.js +15 -0
  30. package/dist/agent/self-improvement/evolutionary-archive.d.ts +2 -1
  31. package/dist/agent/self-improvement/evolutionary-archive.js +34 -5
  32. package/dist/agent/self-improvement/proposal-store.d.ts +1 -0
  33. package/dist/agent/self-improvement/proposal-store.js +79 -17
  34. package/dist/agent/self-improvement/skill-apply-journal.d.ts +44 -0
  35. package/dist/agent/self-improvement/skill-apply-journal.js +178 -0
  36. package/dist/agent/self-improvement/skill-behavior-benchmark.d.ts +3 -0
  37. package/dist/agent/self-improvement/skill-behavior-benchmark.js +19 -0
  38. package/dist/agent/self-improvement/skill-behavior-gate.d.ts +34 -0
  39. package/dist/agent/self-improvement/skill-behavior-gate.js +96 -0
  40. package/dist/agent/self-improvement/skill-engine.d.ts +22 -0
  41. package/dist/agent/self-improvement/skill-engine.js +385 -13
  42. package/dist/agent/self-improvement/skill-gate.d.ts +2 -0
  43. package/dist/agent/self-improvement/skill-gate.js +17 -2
  44. package/dist/agent/self-improvement/skill-mutator.d.ts +6 -1
  45. package/dist/agent/self-improvement/skill-mutator.js +51 -15
  46. package/dist/agent/self-improvement/skill-types.d.ts +2 -1
  47. package/dist/agent/self-improvement/types.d.ts +11 -0
  48. package/dist/agent/tool-handler.d.ts +1 -1
  49. package/dist/agent/tool-handler.js +28 -9
  50. package/dist/auth/profile-manager.js +1 -1
  51. package/dist/channels/companion-channel-turn.d.ts +53 -4
  52. package/dist/channels/companion-channel-turn.js +218 -16
  53. package/dist/channels/slash-parity.d.ts +4 -6
  54. package/dist/channels/slash-parity.js +9 -44
  55. package/dist/cli/session-commands.d.ts +9 -0
  56. package/dist/cli/session-commands.js +45 -5
  57. package/dist/cli/session-picker.d.ts +43 -0
  58. package/dist/cli/session-picker.js +128 -0
  59. package/dist/codebuddy/a2a-call-tool-defs.d.ts +26 -0
  60. package/dist/codebuddy/a2a-call-tool-defs.js +12 -0
  61. package/dist/codebuddy/fleet-tool-defs.d.ts +2 -0
  62. package/dist/codebuddy/fleet-tool-defs.js +55 -0
  63. package/dist/codebuddy/providers/chatgpt-headers.d.ts +18 -0
  64. package/dist/codebuddy/providers/chatgpt-headers.js +37 -0
  65. package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +2 -1
  66. package/dist/codebuddy/providers/provider-chatgpt-responses.js +10 -23
  67. package/dist/codebuddy/providers/provider-openai-compat.d.ts +7 -0
  68. package/dist/codebuddy/providers/provider-openai-compat.js +29 -1
  69. package/dist/codebuddy/ragchat-tool-defs.d.ts +31 -0
  70. package/dist/codebuddy/ragchat-tool-defs.js +19 -0
  71. package/dist/codebuddy/resource-catalog-tool-defs.d.ts +28 -0
  72. package/dist/codebuddy/resource-catalog-tool-defs.js +18 -0
  73. package/dist/codebuddy/tool-definitions/agent-tools.js +2 -2
  74. package/dist/codebuddy/tool-definitions/code-exec-tools.js +5 -1
  75. package/dist/codebuddy/tool-definitions/cron-tools.js +6 -0
  76. package/dist/codebuddy/tool-definitions/self-describe-tools.js +6 -1
  77. package/dist/codebuddy/tools.d.ts +0 -6
  78. package/dist/codebuddy/tools.js +25 -3
  79. package/dist/commands/cli/daemon-commands.js +3 -1
  80. package/dist/commands/cli/evolve-command.js +21 -5
  81. package/dist/commands/cli/fleet-collaboration-commands.d.ts +2 -0
  82. package/dist/commands/cli/fleet-collaboration-commands.js +57 -0
  83. package/dist/commands/cli/fleet-commands.js +29 -0
  84. package/dist/commands/cli/fleet-mission-commands.d.ts +3 -0
  85. package/dist/commands/cli/fleet-mission-commands.js +72 -0
  86. package/dist/commands/cli/fleet-rooms-commands.d.ts +10 -0
  87. package/dist/commands/cli/fleet-rooms-commands.js +289 -0
  88. package/dist/commands/cli/tools-commands.js +2 -1
  89. package/dist/commands/cli/triage-command.d.ts +8 -0
  90. package/dist/commands/cli/triage-command.js +72 -0
  91. package/dist/commands/cli/utility-commands.js +25 -1
  92. package/dist/commands/client-dispatcher.d.ts +7 -0
  93. package/dist/commands/client-dispatcher.js +73 -21
  94. package/dist/commands/cron-cli/index.d.ts +3 -1
  95. package/dist/commands/cron-cli/index.js +25 -0
  96. package/dist/commands/device-auth.d.ts +10 -0
  97. package/dist/commands/device-auth.js +91 -0
  98. package/dist/commands/enhanced-command-handler.d.ts +9 -0
  99. package/dist/commands/enhanced-command-handler.js +28 -6
  100. package/dist/commands/handlers/agent-handlers.d.ts +1 -1
  101. package/dist/commands/handlers/agent-handlers.js +4 -4
  102. package/dist/commands/handlers/channel-handlers.js +53 -2
  103. package/dist/commands/handlers/export-handlers.d.ts +3 -2
  104. package/dist/commands/handlers/export-handlers.js +55 -28
  105. package/dist/commands/handlers/extra-handlers.js +5 -1
  106. package/dist/commands/handlers/grill-me-handler.js +26 -18
  107. package/dist/commands/handlers/memory-handlers.d.ts +6 -2
  108. package/dist/commands/handlers/memory-handlers.js +35 -15
  109. package/dist/commands/handlers/missing-handlers.d.ts +2 -2
  110. package/dist/commands/handlers/missing-handlers.js +12 -4
  111. package/dist/commands/handlers/resources-handler.d.ts +12 -0
  112. package/dist/commands/handlers/resources-handler.js +52 -0
  113. package/dist/commands/handlers/starter-handlers.d.ts +1 -1
  114. package/dist/commands/handlers/starter-handlers.js +32 -2
  115. package/dist/commands/handlers/switch-handler.d.ts +1 -1
  116. package/dist/commands/handlers/switch-handler.js +15 -0
  117. package/dist/commands/handlers/test-handlers.js +4 -86
  118. package/dist/commands/handlers/ui-handlers.js +11 -5
  119. package/dist/commands/login-chatgpt.d.ts +8 -0
  120. package/dist/commands/login-chatgpt.js +17 -0
  121. package/dist/commands/mcp-import.d.ts +11 -0
  122. package/dist/commands/mcp-import.js +67 -0
  123. package/dist/commands/mcp-invoke.d.ts +2 -0
  124. package/dist/commands/mcp-invoke.js +68 -0
  125. package/dist/commands/mcp.d.ts +13 -0
  126. package/dist/commands/mcp.js +66 -21
  127. package/dist/commands/pipeline.d.ts +7 -1
  128. package/dist/commands/pipeline.js +104 -7
  129. package/dist/commands/resources.d.ts +2 -0
  130. package/dist/commands/resources.js +64 -0
  131. package/dist/commands/skills-cli/index.js +35 -12
  132. package/dist/commands/slash/builtin-commands.js +16 -3
  133. package/dist/commands/slash/index.d.ts +3 -1
  134. package/dist/commands/slash/index.js +2 -0
  135. package/dist/commands/slash/surfaces.d.ts +53 -0
  136. package/dist/commands/slash/surfaces.js +177 -0
  137. package/dist/commands/slash/types.d.ts +17 -0
  138. package/dist/commands/try.d.ts +1 -1
  139. package/dist/commands/try.js +1 -1
  140. package/dist/companion/companion-identity.d.ts +43 -0
  141. package/dist/companion/companion-identity.js +136 -0
  142. package/dist/companion/companion-toolset.d.ts +66 -0
  143. package/dist/companion/companion-toolset.js +368 -0
  144. package/dist/companion/companion-turn.d.ts +10 -2
  145. package/dist/companion/companion-turn.js +38 -1
  146. package/dist/config/code-exec-policy.d.ts +25 -0
  147. package/dist/config/code-exec-policy.js +39 -0
  148. package/dist/config/model-tools.d.ts +9 -0
  149. package/dist/config/model-tools.js +103 -0
  150. package/dist/context/context-manager-v2.js +2 -2
  151. package/dist/context/lm-resizer-compressor.js +3 -2
  152. package/dist/context/lm-resizer-diagnostics.d.ts +9 -0
  153. package/dist/context/lm-resizer-diagnostics.js +30 -0
  154. package/dist/context/tool-output-masking.js +3 -4
  155. package/dist/curator/curator.d.ts +6 -0
  156. package/dist/curator/curator.js +53 -3
  157. package/dist/daemon/cron-agent-bridge.d.ts +6 -0
  158. package/dist/daemon/cron-agent-bridge.js +31 -4
  159. package/dist/doctor/index.d.ts +11 -2
  160. package/dist/doctor/index.js +84 -21
  161. package/dist/doctor/integrations.d.ts +197 -0
  162. package/dist/doctor/integrations.js +241 -0
  163. package/dist/doctor/triage.d.ts +108 -0
  164. package/dist/doctor/triage.js +304 -0
  165. package/dist/errors/crash-handler.js +2 -0
  166. package/dist/fleet/collaboration.d.ts +44 -0
  167. package/dist/fleet/collaboration.js +170 -0
  168. package/dist/fleet/fleet-listener.d.ts +1 -0
  169. package/dist/fleet/fleet-listener.js +87 -46
  170. package/dist/fleet/fleet-registry.d.ts +2 -0
  171. package/dist/fleet/resource-catalog.d.ts +245 -0
  172. package/dist/fleet/resource-catalog.js +211 -0
  173. package/dist/fleet/rooms/room-access.d.ts +138 -0
  174. package/dist/fleet/rooms/room-access.js +196 -0
  175. package/dist/fleet/rooms/room-client.d.ts +158 -0
  176. package/dist/fleet/rooms/room-client.js +685 -0
  177. package/dist/fleet/rooms/room-event.d.ts +139 -0
  178. package/dist/fleet/rooms/room-event.js +330 -0
  179. package/dist/fleet/rooms/room-filter.d.ts +48 -0
  180. package/dist/fleet/rooms/room-filter.js +152 -0
  181. package/dist/fleet/rooms/room-hub.d.ts +154 -0
  182. package/dist/fleet/rooms/room-hub.js +363 -0
  183. package/dist/fleet/rooms/room-identity.d.ts +26 -0
  184. package/dist/fleet/rooms/room-identity.js +82 -0
  185. package/dist/fleet/rooms/room-lock.d.ts +34 -0
  186. package/dist/fleet/rooms/room-lock.js +180 -0
  187. package/dist/fleet/rooms/room-observations.d.ts +7 -0
  188. package/dist/fleet/rooms/room-observations.js +61 -0
  189. package/dist/fleet/rooms/room-server.d.ts +28 -0
  190. package/dist/fleet/rooms/room-server.js +75 -0
  191. package/dist/fleet/rooms/room-store.d.ts +119 -0
  192. package/dist/fleet/rooms/room-store.js +448 -0
  193. package/dist/fleet/rooms/room-ws-bridge.d.ts +27 -0
  194. package/dist/fleet/rooms/room-ws-bridge.js +137 -0
  195. package/dist/fleet/sensory-mission-bridge.d.ts +42 -0
  196. package/dist/fleet/sensory-mission-bridge.js +136 -0
  197. package/dist/git/worktree-sessions.js +1 -0
  198. package/dist/harness/contract.d.ts +4 -4
  199. package/dist/harness/fleet-supervisor.d.ts +16 -0
  200. package/dist/harness/fleet-supervisor.js +64 -0
  201. package/dist/harness/index.d.ts +4 -0
  202. package/dist/harness/index.js +4 -0
  203. package/dist/harness/mission-runner.d.ts +3 -0
  204. package/dist/harness/mission-runner.js +53 -0
  205. package/dist/harness/mission-store.d.ts +93 -0
  206. package/dist/harness/mission-store.js +297 -0
  207. package/dist/harness/tool-harness.d.ts +56 -0
  208. package/dist/harness/tool-harness.js +153 -0
  209. package/dist/hooks/use-enhanced-input.js +48 -4
  210. package/dist/hooks/use-input-handler.d.ts +1 -0
  211. package/dist/hooks/use-input-handler.js +82 -22
  212. package/dist/hooks/use-input-history.js +1 -0
  213. package/dist/identity/lisa-introspection.js +5 -2
  214. package/dist/identity/operational-self-model.d.ts +2 -0
  215. package/dist/identity/operational-self-model.js +4 -0
  216. package/dist/index.js +52 -6
  217. package/dist/mcp/client.d.ts +11 -0
  218. package/dist/mcp/client.js +68 -3
  219. package/dist/mcp/config.d.ts +20 -0
  220. package/dist/mcp/config.js +121 -8
  221. package/dist/mcp/import-normalize.d.ts +12 -0
  222. package/dist/mcp/import-normalize.js +114 -0
  223. package/dist/mcp/mcp-oauth-constants.d.ts +8 -0
  224. package/dist/mcp/mcp-oauth-constants.js +9 -0
  225. package/dist/mcp/mcp-oauth-provider.d.ts +80 -0
  226. package/dist/mcp/mcp-oauth-provider.js +241 -0
  227. package/dist/mcp/mcp-oauth.d.ts +60 -1
  228. package/dist/mcp/mcp-oauth.js +241 -65
  229. package/dist/mcp/transports.d.ts +14 -5
  230. package/dist/mcp/transports.js +112 -101
  231. package/dist/mcp/types.d.ts +5 -0
  232. package/dist/media/comfyui-recipe-contract.d.ts +7 -7
  233. package/dist/memory/facts-memory.d.ts +11 -1
  234. package/dist/memory/facts-memory.js +47 -8
  235. package/dist/memory/memory-candidate-queue.d.ts +2 -2
  236. package/dist/memory/memory-candidate-queue.js +6 -6
  237. package/dist/memory/persistent-memory.d.ts +13 -8
  238. package/dist/memory/persistent-memory.js +77 -30
  239. package/dist/nodes/device-node.js +5 -9
  240. package/dist/observability/mobile-supervision-gateway-contract.js +20 -7
  241. package/dist/observability/run-event-writer.d.ts +21 -0
  242. package/dist/observability/run-event-writer.js +81 -0
  243. package/dist/observability/run-store.d.ts +5 -0
  244. package/dist/observability/run-store.js +18 -13
  245. package/dist/observability/run-trajectory.js +1 -1
  246. package/dist/optimization/prompt-cache.d.ts +19 -2
  247. package/dist/optimization/prompt-cache.js +41 -6
  248. package/dist/orchestration/orchestrator.d.ts +21 -0
  249. package/dist/orchestration/orchestrator.js +122 -15
  250. package/dist/persistence/session-content.d.ts +8 -0
  251. package/dist/persistence/session-content.js +76 -0
  252. package/dist/persistence/session-handoff.d.ts +64 -0
  253. package/dist/persistence/session-handoff.js +80 -0
  254. package/dist/persistence/session-history.d.ts +4 -0
  255. package/dist/persistence/session-history.js +38 -0
  256. package/dist/persistence/session-store.d.ts +9 -0
  257. package/dist/persistence/session-store.js +48 -20
  258. package/dist/personas/persona-manager.js +17 -1
  259. package/dist/plugins/code-explorer/CodeExplorerManager.d.ts +10 -4
  260. package/dist/plugins/code-explorer/CodeExplorerManager.js +69 -16
  261. package/dist/plugins/plugin-manager.js +10 -1
  262. package/dist/prompts/prompt-manager.js +11 -4
  263. package/dist/prompts/system-base.js +6 -2
  264. package/dist/protocols/a2a/codebuddy-executor.d.ts +11 -2
  265. package/dist/protocols/a2a/codebuddy-executor.js +9 -8
  266. package/dist/protocols/a2a/index.d.ts +1 -1
  267. package/dist/protocols/a2a/jsonrpc-v1.d.ts +41 -0
  268. package/dist/protocols/a2a/jsonrpc-v1.js +145 -0
  269. package/dist/protocols/a2a/peer-config.d.ts +20 -0
  270. package/dist/protocols/a2a/peer-config.js +55 -0
  271. package/dist/providers/codex-oauth.js +30 -6
  272. package/dist/providers/model-provider-compat.js +2 -1
  273. package/dist/sandbox/os-sandbox.d.ts +1 -1
  274. package/dist/scheduler/cron-scheduler.d.ts +15 -2
  275. package/dist/scheduler/cron-scheduler.js +35 -4
  276. package/dist/scheduler/job-notepad.d.ts +69 -0
  277. package/dist/scheduler/job-notepad.js +339 -0
  278. package/dist/security/audit-logger.d.ts +1 -1
  279. package/dist/security/compute-confinement.d.ts +4 -0
  280. package/dist/security/compute-confinement.js +89 -0
  281. package/dist/security/session-encryption.d.ts +4 -0
  282. package/dist/security/session-encryption.js +31 -0
  283. package/dist/sensory/voice-loop.d.ts +17 -0
  284. package/dist/sensory/voice-loop.js +72 -15
  285. package/dist/server/auth/device-session-context.d.ts +9 -0
  286. package/dist/server/auth/device-session-context.js +13 -0
  287. package/dist/server/auth/device-store.d.ts +89 -0
  288. package/dist/server/auth/device-store.js +261 -0
  289. package/dist/server/auth/device-token.d.ts +3 -0
  290. package/dist/server/auth/device-token.js +6 -0
  291. package/dist/server/auth/jwt.js +4 -0
  292. package/dist/server/index.d.ts +0 -10
  293. package/dist/server/index.js +28 -0
  294. package/dist/server/middleware/auth.js +3 -2
  295. package/dist/server/routes/a2a-jsonrpc.d.ts +9 -0
  296. package/dist/server/routes/a2a-jsonrpc.js +66 -0
  297. package/dist/server/routes/a2a-protocol.d.ts +12 -0
  298. package/dist/server/routes/a2a-protocol.js +1 -1
  299. package/dist/server/routes/device-auth.d.ts +4 -0
  300. package/dist/server/routes/device-auth.js +40 -0
  301. package/dist/server/types.d.ts +4 -0
  302. package/dist/server/websocket/handler.d.ts +13 -0
  303. package/dist/server/websocket/handler.js +102 -17
  304. package/dist/services/prompt-builder.d.ts +2 -0
  305. package/dist/services/prompt-builder.js +16 -6
  306. package/dist/services/runtime-settings-context.d.ts +81 -0
  307. package/dist/services/runtime-settings-context.js +79 -0
  308. package/dist/skills/executor.js +2 -0
  309. package/dist/skills/hub.js +16 -14
  310. package/dist/skills/local-inventory.d.ts +21 -0
  311. package/dist/skills/local-inventory.js +72 -0
  312. package/dist/skills/skill-loader.js +2 -2
  313. package/dist/skills/skill-usage-store.d.ts +49 -0
  314. package/dist/skills/skill-usage-store.js +121 -0
  315. package/dist/testing/ai-integration-tests.js +8 -5
  316. package/dist/themes/theme-manager.d.ts +12 -0
  317. package/dist/themes/theme-manager.js +29 -0
  318. package/dist/themes/theme-schema.d.ts +24 -24
  319. package/dist/tools/a2a-call-tool.d.ts +34 -0
  320. package/dist/tools/a2a-call-tool.js +75 -0
  321. package/dist/tools/bash/streaming-executor.d.ts +1 -0
  322. package/dist/tools/bash/streaming-executor.js +78 -90
  323. package/dist/tools/code-exec-preflight-runner.d.ts +41 -0
  324. package/dist/tools/code-exec-preflight-runner.js +254 -0
  325. package/dist/tools/code-exec-preflight.d.ts +44 -0
  326. package/dist/tools/code-exec-preflight.js +501 -0
  327. package/dist/tools/code-exec-tool.d.ts +48 -1
  328. package/dist/tools/code-exec-tool.js +191 -47
  329. package/dist/tools/comment-watcher.js +29 -12
  330. package/dist/tools/core-code-inspection.d.ts +56 -0
  331. package/dist/tools/core-code-inspection.js +86 -0
  332. package/dist/tools/create-skill-tool.d.ts +2 -3
  333. package/dist/tools/create-skill-tool.js +16 -75
  334. package/dist/tools/cronjob-tool.d.ts +1 -0
  335. package/dist/tools/cronjob-tool.js +1 -0
  336. package/dist/tools/env-doctor-tool.d.ts +2 -0
  337. package/dist/tools/env-doctor-tool.js +4 -3
  338. package/dist/tools/execute-code-rpc-invoker.d.ts +1 -1
  339. package/dist/tools/execute-code-rpc-invoker.js +35 -19
  340. package/dist/tools/execute-code-runner.d.ts +2 -0
  341. package/dist/tools/execute-code-runner.js +52 -17
  342. package/dist/tools/fleet-room-tool.d.ts +104 -0
  343. package/dist/tools/fleet-room-tool.js +124 -0
  344. package/dist/tools/integration-tool-hints.d.ts +4 -0
  345. package/dist/tools/integration-tool-hints.js +19 -0
  346. package/dist/tools/list-peers-tool.d.ts +3 -0
  347. package/dist/tools/list-peers-tool.js +11 -4
  348. package/dist/tools/media-generation-tool.d.ts +16 -1
  349. package/dist/tools/media-generation-tool.js +341 -9
  350. package/dist/tools/merge-conflict-tool.js +53 -25
  351. package/dist/tools/metadata.d.ts +1 -5
  352. package/dist/tools/metadata.js +30 -28
  353. package/dist/tools/peer-tool-invoke-tool.d.ts +61 -0
  354. package/dist/tools/peer-tool-invoke-tool.js +396 -0
  355. package/dist/tools/ragchat-tool.d.ts +39 -0
  356. package/dist/tools/ragchat-tool.js +105 -0
  357. package/dist/tools/registry/fleet-tools.d.ts +21 -3
  358. package/dist/tools/registry/fleet-tools.js +137 -4
  359. package/dist/tools/registry/index.d.ts +1 -1
  360. package/dist/tools/registry/index.js +2 -2
  361. package/dist/tools/registry/knowledge-tools.d.ts +2 -2
  362. package/dist/tools/registry/knowledge-tools.js +2 -2
  363. package/dist/tools/registry/lessons-tools.d.ts +7 -0
  364. package/dist/tools/registry/lessons-tools.js +43 -3
  365. package/dist/tools/registry/memory-tools.d.ts +1 -1
  366. package/dist/tools/registry/memory-tools.js +8 -8
  367. package/dist/tools/registry/research-tools.d.ts +1 -0
  368. package/dist/tools/registry/research-tools.js +4 -13
  369. package/dist/tools/registry/self-describe-tools.d.ts +1 -1
  370. package/dist/tools/registry/self-describe-tools.js +43 -30
  371. package/dist/tools/resource-catalog-tool.d.ts +38 -0
  372. package/dist/tools/resource-catalog-tool.js +46 -0
  373. package/dist/tools/skills-inspection-tool.js +30 -1
  374. package/dist/tools/stream-tool-output.d.ts +3 -0
  375. package/dist/tools/stream-tool-output.js +33 -0
  376. package/dist/tools/tool-call-scheduler.d.ts +10 -0
  377. package/dist/tools/tool-call-scheduler.js +58 -0
  378. package/dist/tools/tool-effect.d.ts +5 -0
  379. package/dist/tools/tool-effect.js +26 -0
  380. package/dist/tools/tool-search.d.ts +12 -11
  381. package/dist/tools/tool-search.js +67 -26
  382. package/dist/tools/types.d.ts +6 -0
  383. package/dist/ui/components/ChatHistory.d.ts +1 -1
  384. package/dist/ui/components/ChatHistory.js +2 -2
  385. package/dist/ui/components/ChatInput.d.ts +2 -1
  386. package/dist/ui/components/ChatInput.js +42 -88
  387. package/dist/ui/components/ChatInterface.d.ts +4 -2
  388. package/dist/ui/components/ChatInterface.js +27 -63
  389. package/dist/ui/components/CommandSuggestions.d.ts +0 -1
  390. package/dist/ui/components/CommandSuggestions.js +4 -6
  391. package/dist/ui/components/FileAutocomplete.js +1 -1
  392. package/dist/ui/components/KeyboardHelp.js +8 -6
  393. package/dist/ui/components/ModelSelection.js +6 -5
  394. package/dist/ui/components/StatusBar.d.ts +2 -1
  395. package/dist/ui/components/StatusBar.js +8 -7
  396. package/dist/ui/context/theme-context.js +3 -2
  397. package/dist/ui/index.d.ts +1 -1
  398. package/dist/ui/index.js +1 -1
  399. package/dist/ui/utils/markdown-renderer.js +4 -13
  400. package/dist/utils/atomic-write.d.ts +22 -0
  401. package/dist/utils/atomic-write.js +29 -0
  402. package/dist/utils/bounded-output.d.ts +16 -0
  403. package/dist/utils/bounded-output.js +63 -0
  404. package/dist/utils/config-validation/schema.d.ts +2 -2
  405. package/dist/utils/device-store-file.d.ts +4 -0
  406. package/dist/utils/device-store-file.js +40 -0
  407. package/dist/utils/export-manager.d.ts +9 -0
  408. package/dist/utils/export-manager.js +19 -0
  409. package/dist/utils/first-use-hints.d.ts +25 -0
  410. package/dist/utils/first-use-hints.js +58 -0
  411. package/dist/utils/graceful-shutdown.d.ts +8 -0
  412. package/dist/utils/graceful-shutdown.js +23 -7
  413. package/dist/utils/history-manager.js +1 -1
  414. package/dist/utils/update-notifier.js +16 -18
  415. package/dist/wizard/environment-detection.d.ts +5 -1
  416. package/dist/wizard/environment-detection.js +49 -7
  417. package/dist/wizard/onboarding.d.ts +5 -1
  418. package/dist/wizard/onboarding.js +90 -30
  419. package/dist/wizard/provider-onboarding.d.ts +2 -0
  420. package/dist/wizard/provider-onboarding.js +55 -17
  421. package/package.json +7 -3
@@ -5,6 +5,8 @@
5
5
  * as they arrive from the spawned process.
6
6
  */
7
7
  import { spawn } from 'child_process';
8
+ import { StringDecoder } from 'node:string_decoder';
9
+ import { BoundedOutput } from '../../utils/bounded-output.js';
8
10
  import { ConfirmationService } from '../../utils/confirmation-service.js';
9
11
  import { validateCommand as validateCommandSafety } from '../../utils/input-validator.js';
10
12
  import { validateCommand } from './command-validator.js';
@@ -149,106 +151,92 @@ export async function* executeStreaming(command, timeout = 30000, deps, signal)
149
151
  });
150
152
  const runningProcesses = deps.getRunningProcesses();
151
153
  runningProcesses.add(proc);
152
- let stdout = '';
153
- let stderr = '';
154
- let timedOut = false;
155
- let aborted = false;
156
- let onAbort = () => { };
157
- const timer = setTimeout(() => {
158
- timedOut = true;
154
+ const stdout = new BoundedOutput(deps.maxOutputBytes);
155
+ const stderr = new BoundedOutput(deps.maxOutputBytes);
156
+ const pending = new BoundedOutput(deps.maxOutputBytes);
157
+ const outDecoder = new StringDecoder('utf8');
158
+ const errDecoder = new StringDecoder('utf8');
159
+ let done = false;
160
+ let failure;
161
+ let wake;
162
+ let killTimer;
163
+ const notify = () => { wake?.(); wake = undefined; };
164
+ const kill = (signal) => {
159
165
  try {
160
- proc.kill('SIGTERM');
161
- }
162
- catch { /* ignore */ }
163
- }, timeout);
164
- try {
165
- // Create a readable stream from stdout and stderr combined
166
- const chunks = [];
167
- let resolve = null;
168
- let done = false;
169
- const killProcess = () => {
170
- try {
171
- if (!isWindows && proc.pid)
172
- process.kill(-proc.pid, 'SIGTERM');
173
- else
174
- proc.kill('SIGTERM');
175
- }
176
- catch {
177
- try {
178
- proc.kill('SIGTERM');
179
- }
180
- catch { /* process already exited */ }
181
- }
182
- };
183
- onAbort = () => {
184
- aborted = true;
185
- killProcess();
186
- if (resolve) {
187
- resolve();
188
- resolve = null;
189
- }
190
- };
191
- signal?.addEventListener('abort', onAbort, { once: true });
192
- if (signal?.aborted)
193
- onAbort();
194
- const onData = (data, isStderr) => {
195
- const text = data.toString();
196
- if (isStderr)
197
- stderr += text;
166
+ if (!isWindows && proc.pid)
167
+ process.kill(-proc.pid, signal);
198
168
  else
199
- stdout += text;
200
- chunks.push(text);
201
- if (resolve) {
202
- resolve();
203
- resolve = null;
204
- }
205
- };
206
- proc.stdout?.on('data', (data) => onData(data, false));
207
- proc.stderr?.on('data', (data) => onData(data, true));
208
- proc.on('close', () => { done = true; if (resolve) {
209
- resolve();
210
- resolve = null;
211
- } });
212
- while (!done) {
213
- if (chunks.length > 0) {
214
- while (chunks.length > 0) {
215
- yield chunks.shift();
216
- }
217
- }
218
- else {
219
- await new Promise(r => { resolve = r; });
220
- }
169
+ proc.kill(signal);
221
170
  }
222
- // Yield remaining chunks
223
- while (chunks.length > 0) {
224
- yield chunks.shift();
171
+ catch { /* The process or its group already exited. */ }
172
+ };
173
+ const stop = (reason) => {
174
+ if (done || failure)
175
+ return;
176
+ failure = reason;
177
+ kill('SIGTERM');
178
+ // Sending a signal is not proof of exit. Escalate even if the parent
179
+ // closes its pipes while a descendant still holds the process group.
180
+ killTimer = setTimeout(() => {
181
+ kill('SIGKILL');
182
+ done = true;
183
+ notify();
184
+ }, 250);
185
+ notify();
186
+ };
187
+ const timer = setTimeout(() => stop(`Command timed out after ${timeout}ms`), timeout);
188
+ const onAbort = () => stop('Command aborted by user');
189
+ const onError = (error) => {
190
+ failure ??= `Command failed to start: ${error.message}`;
191
+ done = true;
192
+ notify();
193
+ };
194
+ const onClose = () => {
195
+ if (!failure)
196
+ done = true;
197
+ notify();
198
+ };
199
+ const onData = (data, target, decoder) => {
200
+ const text = decoder.write(data);
201
+ target.append(text);
202
+ pending.append(text);
203
+ notify();
204
+ };
205
+ const onStdout = (data) => onData(data, stdout, outDecoder);
206
+ const onStderr = (data) => onData(data, stderr, errDecoder);
207
+ proc.stdout?.on('data', onStdout);
208
+ proc.stderr?.on('data', onStderr);
209
+ proc.on('error', onError);
210
+ proc.on('close', onClose);
211
+ signal?.addEventListener('abort', onAbort, { once: true });
212
+ if (signal?.aborted)
213
+ onAbort();
214
+ try {
215
+ while (!done || pending.retainedBytes > 0) {
216
+ if (pending.retainedBytes > 0)
217
+ yield pending.drain();
218
+ else if (!done)
219
+ await new Promise(resolve => { wake = resolve; });
225
220
  }
226
221
  }
227
222
  finally {
228
223
  clearTimeout(timer);
224
+ clearTimeout(killTimer);
229
225
  signal?.removeEventListener('abort', onAbort);
226
+ // Also handles a consumer calling return() before the child exits.
227
+ if (!done || failure)
228
+ kill('SIGKILL');
229
+ proc.stdout?.removeListener('data', onStdout);
230
+ proc.stderr?.removeListener('data', onStderr);
231
+ proc.removeListener('close', onClose);
230
232
  runningProcesses.delete(proc);
231
- if (!proc.killed && proc.exitCode === null) {
232
- proc.kill('SIGTERM');
233
- setTimeout(() => {
234
- try {
235
- if (!proc.killed)
236
- proc.kill('SIGKILL');
237
- }
238
- catch { /* already dead */ }
239
- }, 5000);
240
- }
241
- }
242
- if (aborted) {
243
- return { success: false, error: 'Command aborted by user', output: stdout };
244
- }
245
- if (timedOut) {
246
- return { success: false, error: `Command timed out after ${timeout}ms` };
247
233
  }
248
- const exitCode = proc.exitCode ?? 0;
249
- if (exitCode !== 0) {
250
- return { success: false, error: stderr || `Exit code ${exitCode}`, output: stdout };
234
+ const output = stdout.text();
235
+ if (failure)
236
+ return { success: false, error: failure, output };
237
+ if (proc.exitCode !== 0) {
238
+ return { success: false, error: stderr.text() || `Exit code ${proc.exitCode}`, output };
251
239
  }
252
- return { success: true, output: stdout };
240
+ return { success: true, output };
253
241
  }
254
242
  //# sourceMappingURL=streaming-executor.js.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Standalone isolated TypeScript preflight compiler runner.
3
+ *
4
+ * Runs inside an isolated worker/child process with:
5
+ * - 128MB max heap limit (--max-old-space-size=128)
6
+ * - Virtual in-memory file system (zero disk I/O for guest files)
7
+ * - Bounded diagnostics (max 20 diagnostics / 16KB formatted error size)
8
+ * - Full rejection of global, compiler options, environment, and guest diagnostics
9
+ * - Complete isolation from external module imports
10
+ */
11
+ export interface PreflightWorkerPayload {
12
+ code: string;
13
+ declarations: string;
14
+ strict?: boolean;
15
+ target?: string;
16
+ }
17
+ export interface PreflightDiagnostic {
18
+ line?: number;
19
+ column?: number;
20
+ message: string;
21
+ code?: number;
22
+ category: 'error' | 'warning' | 'suggestion' | 'message';
23
+ file?: string;
24
+ }
25
+ export interface PreflightWorkerResult {
26
+ success: boolean;
27
+ diagnostics: PreflightDiagnostic[];
28
+ error?: string;
29
+ transpiledCode?: string;
30
+ declarations?: string;
31
+ }
32
+ export declare const PREFLIGHT_LIMITS: Readonly<{
33
+ timeoutMs: 5000;
34
+ maxHeapMb: 128;
35
+ maxDiagnostics: 20;
36
+ maxErrorBytes: number;
37
+ }>;
38
+ /**
39
+ * Execute isolated in-memory TypeScript compilation and diagnostic collection.
40
+ */
41
+ export declare function executePreflightCompilation(payload: PreflightWorkerPayload): PreflightWorkerResult;
@@ -0,0 +1,254 @@
1
+ /**
2
+ * Standalone isolated TypeScript preflight compiler runner.
3
+ *
4
+ * Runs inside an isolated worker/child process with:
5
+ * - 128MB max heap limit (--max-old-space-size=128)
6
+ * - Virtual in-memory file system (zero disk I/O for guest files)
7
+ * - Bounded diagnostics (max 20 diagnostics / 16KB formatted error size)
8
+ * - Full rejection of global, compiler options, environment, and guest diagnostics
9
+ * - Complete isolation from external module imports
10
+ */
11
+ import ts from 'typescript';
12
+ import path from 'node:path';
13
+ import { createRequire } from 'node:module';
14
+ export const PREFLIGHT_LIMITS = Object.freeze({
15
+ timeoutMs: 5_000,
16
+ maxHeapMb: 128,
17
+ maxDiagnostics: 20,
18
+ maxErrorBytes: 16 * 1024,
19
+ });
20
+ const require = createRequire(import.meta.url);
21
+ const tsLibDir = path.dirname(require.resolve('typescript'));
22
+ const tsLibCache = new Map();
23
+ function getCachedLibSourceFile(fileName, languageVersionOrOptions) {
24
+ const baseName = path.basename(fileName);
25
+ if (tsLibCache.has(baseName)) {
26
+ return tsLibCache.get(baseName);
27
+ }
28
+ const fullPath = path.join(tsLibDir, baseName);
29
+ if (ts.sys.fileExists(fullPath)) {
30
+ const content = ts.sys.readFile(fullPath);
31
+ if (content !== undefined) {
32
+ const sf = ts.createSourceFile(fileName, content, languageVersionOrOptions, true);
33
+ tsLibCache.set(baseName, sf);
34
+ return sf;
35
+ }
36
+ }
37
+ return undefined;
38
+ }
39
+ const defaultCompilerOptions = {
40
+ target: ts.ScriptTarget.ES2022,
41
+ module: ts.ModuleKind.ESNext,
42
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
43
+ strict: true,
44
+ noImplicitAny: true,
45
+ strictNullChecks: true,
46
+ strictFunctionTypes: true,
47
+ strictBindCallApply: true,
48
+ strictPropertyInitialization: true,
49
+ noImplicitThis: true,
50
+ alwaysStrict: true,
51
+ noUnusedLocals: false,
52
+ noUnusedParameters: false,
53
+ exactOptionalPropertyTypes: false,
54
+ noEmit: true,
55
+ skipLibCheck: true,
56
+ };
57
+ /**
58
+ * Execute isolated in-memory TypeScript compilation and diagnostic collection.
59
+ */
60
+ export function executePreflightCompilation(payload) {
61
+ const { code, declarations, strict, target } = payload;
62
+ const syntax = ts.createSourceFile('/input.ts', code, ts.ScriptTarget.ES2022, true);
63
+ let forbidden;
64
+ const inspect = (node) => {
65
+ if (ts.isImportDeclaration(node) || ts.isImportEqualsDeclaration(node) || ts.isImportTypeNode(node)
66
+ || (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword)
67
+ || (ts.isExportDeclaration(node) && node.moduleSpecifier)) {
68
+ forbidden = 'Module imports are not allowed in code_exec scripts';
69
+ }
70
+ if (ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name))
71
+ forbidden = 'Ambient module declarations are not allowed in code_exec scripts';
72
+ ts.forEachChild(node, inspect);
73
+ };
74
+ inspect(syntax);
75
+ if (syntax.referencedFiles.length || syntax.typeReferenceDirectives.length || syntax.libReferenceDirectives.length)
76
+ forbidden = 'TypeScript triple-slash reference directives are not allowed in code_exec scripts';
77
+ if (forbidden)
78
+ return { success: false, diagnostics: [{ message: forbidden, category: 'error' }], error: forbidden };
79
+ const wrappedGuestCode = `async function __codeBuddyMain() {\n${code}\n}`;
80
+ const virtualFiles = new Map([
81
+ ['/code_exec_env.d.ts', declarations],
82
+ ['/guest_code.ts', wrappedGuestCode],
83
+ ]);
84
+ let scriptTarget = ts.ScriptTarget.ES2022;
85
+ if (target) {
86
+ const targetUpper = target.toUpperCase();
87
+ if (targetUpper === 'ES2020')
88
+ scriptTarget = ts.ScriptTarget.ES2020;
89
+ else if (targetUpper === 'ES2021')
90
+ scriptTarget = ts.ScriptTarget.ES2021;
91
+ else if (targetUpper === 'ES2022')
92
+ scriptTarget = ts.ScriptTarget.ES2022;
93
+ else if (targetUpper === 'ESNEXT')
94
+ scriptTarget = ts.ScriptTarget.ESNext;
95
+ }
96
+ const compilerOptions = {
97
+ ...defaultCompilerOptions,
98
+ target: scriptTarget,
99
+ ...(strict !== undefined ? { strict } : {}),
100
+ };
101
+ const host = {
102
+ getSourceFile: (fileName, languageVersion) => {
103
+ if (virtualFiles.has(fileName)) {
104
+ return ts.createSourceFile(fileName, virtualFiles.get(fileName), languageVersion, true, ts.ScriptKind.TS);
105
+ }
106
+ if (fileName.includes('lib.') && fileName.endsWith('.d.ts')) {
107
+ return getCachedLibSourceFile(fileName, languageVersion);
108
+ }
109
+ return undefined;
110
+ },
111
+ getDefaultLibFileName: (opts) => ts.getDefaultLibFileName(opts),
112
+ writeFile: () => { },
113
+ getCurrentDirectory: () => '/',
114
+ getDirectories: () => [],
115
+ getCanonicalFileName: (fileName) => fileName,
116
+ useCaseSensitiveFileNames: () => true,
117
+ getNewLine: () => '\n',
118
+ fileExists: (fileName) => virtualFiles.has(fileName) ||
119
+ (fileName.includes('lib.') &&
120
+ ts.sys.fileExists(path.join(tsLibDir, path.basename(fileName)))),
121
+ readFile: (fileName) => virtualFiles.get(fileName) ||
122
+ (fileName.includes('lib.')
123
+ ? ts.sys.readFile(path.join(tsLibDir, path.basename(fileName)))
124
+ : undefined),
125
+ resolveModuleNameLiterals: () => [],
126
+ resolveModuleNames: () => [],
127
+ };
128
+ const program = ts.createProgram(['/code_exec_env.d.ts', '/guest_code.ts'], compilerOptions, host);
129
+ // Collect all diagnostics: syntactic, global, options, semantic, declaration
130
+ const syntacticDiagnostics = program.getSyntacticDiagnostics();
131
+ const globalDiagnostics = program.getGlobalDiagnostics();
132
+ const optionsDiagnostics = program.getOptionsDiagnostics();
133
+ const semanticDiagnostics = program.getSemanticDiagnostics();
134
+ const declarationDiagnostics = program.getDeclarationDiagnostics();
135
+ const allDiagnostics = [
136
+ ...syntacticDiagnostics,
137
+ ...globalDiagnostics,
138
+ ...optionsDiagnostics,
139
+ ...semanticDiagnostics,
140
+ ...declarationDiagnostics,
141
+ ];
142
+ const errorDiagnostics = allDiagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error);
143
+ if (errorDiagnostics.length === 0) {
144
+ let transpiledCode;
145
+ try {
146
+ const transpiled = ts.transpileModule(code, {
147
+ compilerOptions: {
148
+ target: compilerOptions.target ?? ts.ScriptTarget.ES2022,
149
+ module: ts.ModuleKind.ESNext,
150
+ },
151
+ });
152
+ transpiledCode = transpiled.outputText;
153
+ }
154
+ catch {
155
+ // Retain original code if transpilation throws
156
+ }
157
+ return {
158
+ success: true,
159
+ diagnostics: [],
160
+ transpiledCode,
161
+ declarations,
162
+ };
163
+ }
164
+ const formattedDiagnostics = [];
165
+ const errorMessages = [];
166
+ for (const d of errorDiagnostics) {
167
+ let line;
168
+ let column;
169
+ const fileName = d.file?.fileName;
170
+ if (d.file && d.start !== undefined) {
171
+ const pos = d.file.getLineAndCharacterOfPosition(d.start);
172
+ if (fileName === '/guest_code.ts') {
173
+ // Adjust line number for the async wrapper
174
+ line = Math.max(1, pos.line);
175
+ }
176
+ else {
177
+ line = pos.line + 1;
178
+ }
179
+ column = pos.character + 1;
180
+ }
181
+ const msgText = ts.flattenDiagnosticMessageText(d.messageText, '\n');
182
+ const category = d.category === ts.DiagnosticCategory.Error
183
+ ? 'error'
184
+ : d.category === ts.DiagnosticCategory.Warning
185
+ ? 'warning'
186
+ : d.category === ts.DiagnosticCategory.Suggestion
187
+ ? 'suggestion'
188
+ : 'message';
189
+ formattedDiagnostics.push({
190
+ line,
191
+ column,
192
+ message: msgText,
193
+ code: d.code,
194
+ category,
195
+ file: fileName,
196
+ });
197
+ let loc = '';
198
+ if (fileName === '/guest_code.ts') {
199
+ loc = line !== undefined ? `Line ${line}${column !== undefined ? `:${column}` : ''}: ` : '';
200
+ }
201
+ else if (fileName === '/code_exec_env.d.ts') {
202
+ loc = `[Environment${line !== undefined ? ` Line ${line}` : ''}]: `;
203
+ }
204
+ else if (fileName) {
205
+ loc = `[${fileName}${line !== undefined ? ` Line ${line}` : ''}]: `;
206
+ }
207
+ else {
208
+ loc = '[Global/Compiler]: ';
209
+ }
210
+ errorMessages.push(`${loc}${msgText}`);
211
+ }
212
+ const boundedDiagnostics = formattedDiagnostics.slice(0, PREFLIGHT_LIMITS.maxDiagnostics);
213
+ const totalErrors = errorDiagnostics.length;
214
+ const header = totalErrors > PREFLIGHT_LIMITS.maxDiagnostics
215
+ ? `TypeScript preflight validation failed (${PREFLIGHT_LIMITS.maxDiagnostics} of ${totalErrors} errors shown):\n`
216
+ : 'TypeScript preflight validation failed:\n';
217
+ let summary = header + errorMessages.slice(0, PREFLIGHT_LIMITS.maxDiagnostics).map((m) => `• ${m}`).join('\n');
218
+ if (totalErrors > PREFLIGHT_LIMITS.maxDiagnostics) {
219
+ summary += `\n…[truncated ${totalErrors - PREFLIGHT_LIMITS.maxDiagnostics} diagnostic(s)]`;
220
+ }
221
+ if (summary.length > PREFLIGHT_LIMITS.maxErrorBytes) {
222
+ const marker = '\n…[truncated diagnostics exceeding 16KB limit]';
223
+ summary = summary.slice(0, Math.max(0, PREFLIGHT_LIMITS.maxErrorBytes - marker.length)) + marker;
224
+ }
225
+ return {
226
+ success: false,
227
+ diagnostics: boundedDiagnostics,
228
+ error: summary,
229
+ declarations,
230
+ };
231
+ }
232
+ // Standalone child process IPC listener
233
+ if (typeof process.send === 'function') {
234
+ process.on('message', (rawMessage) => {
235
+ if (!rawMessage || typeof rawMessage !== 'object')
236
+ return;
237
+ const msg = rawMessage;
238
+ if (msg.type === 'compile' && msg.payload) {
239
+ try {
240
+ const result = executePreflightCompilation(msg.payload);
241
+ // Full tool catalogues can exceed the IPC pipe buffer. Exit only once
242
+ // Node has flushed the response, otherwise successful checks disappear.
243
+ process.send({ type: 'result', result }, error => process.exit(error ? 1 : 0));
244
+ }
245
+ catch (error) {
246
+ process.send({
247
+ type: 'error',
248
+ error: error instanceof Error ? error.message : String(error),
249
+ }, error => process.exit(error ? 1 : 0));
250
+ }
251
+ }
252
+ });
253
+ }
254
+ //# sourceMappingURL=code-exec-preflight-runner.js.map
@@ -0,0 +1,44 @@
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 type { IToolExecutionContext } from './registry/types.js';
16
+ import { type CodeExecRuntime, type ToolCatalogEntry } from './code-exec-tool.js';
17
+ import type { PreflightDiagnostic, PreflightWorkerResult } from './code-exec-preflight-runner.js';
18
+ export type { PreflightDiagnostic, PreflightWorkerResult as PreflightResult };
19
+ export interface PreflightOptions {
20
+ target?: string;
21
+ strict?: boolean;
22
+ catalog?: readonly ToolCatalogEntry[];
23
+ signal?: AbortSignal;
24
+ }
25
+ export declare function jsonSchemaPropertyToTs(prop: unknown, indent?: string): string;
26
+ interface ExtractedArgsType {
27
+ typeName: string;
28
+ typeDeclaration: string;
29
+ hasRequiredProps: boolean;
30
+ }
31
+ export declare function extractToolArgsType(toolName: string, parameters: unknown, typeIndex: number): ExtractedArgsType;
32
+ /**
33
+ * Resolve tool catalog entries strictly scoped to `runtime.availableTools`.
34
+ * Tools not in `runtime.availableTools` are never returned.
35
+ */
36
+ export declare function resolveScopedToolCatalog(runtime: CodeExecRuntime, context?: IToolExecutionContext): ToolCatalogEntry[];
37
+ /**
38
+ * Generate TypeScript declarations matching the scoped runtime environment.
39
+ */
40
+ export declare function generateToolDeclarations(scopedTools: readonly ToolCatalogEntry[]): string;
41
+ /**
42
+ * Execute isolated TypeScript preflight typechecking in a worker/child process.
43
+ */
44
+ export declare function runCodeExecPreflight(code: string, runtime: CodeExecRuntime, context?: IToolExecutionContext, options?: PreflightOptions): Promise<PreflightWorkerResult>;