@phuetz/code-buddy 1.1.0 → 1.3.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 (381) hide show
  1. package/README.md +211 -163
  2. package/dist/agent/autonomous/agentic-coding-contract.d.ts +12 -12
  3. package/dist/agent/base-agent.d.ts +4 -0
  4. package/dist/agent/base-agent.js +6 -0
  5. package/dist/agent/codebuddy-agent.d.ts +1 -1
  6. package/dist/agent/codebuddy-agent.js +69 -14
  7. package/dist/agent/execution/agent-executor.js +122 -12
  8. package/dist/agent/execution/tool-dependency-graph.js +7 -0
  9. package/dist/agent/execution/tool-hooks.d.ts +6 -0
  10. package/dist/agent/execution/tool-hooks.js +13 -5
  11. package/dist/agent/execution/tool-selection-strategy.d.ts +11 -2
  12. package/dist/agent/execution/tool-selection-strategy.js +67 -10
  13. package/dist/agent/extended-thinking.d.ts +8 -0
  14. package/dist/agent/extended-thinking.js +27 -0
  15. package/dist/agent/facades/infrastructure-facade.d.ts +9 -2
  16. package/dist/agent/facades/infrastructure-facade.js +15 -6
  17. package/dist/agent/hermes-browser-backends.js +151 -11
  18. package/dist/agent/hermes-claw-migrate.d.ts +59 -0
  19. package/dist/agent/hermes-claw-migrate.js +427 -26
  20. package/dist/agent/hermes-parity-manifest.js +78 -71
  21. package/dist/agent/hermes-runtime-lifecycle.d.ts +67 -0
  22. package/dist/agent/hermes-runtime-lifecycle.js +468 -0
  23. package/dist/agent/middleware/index.d.ts +1 -0
  24. package/dist/agent/middleware/index.js +1 -0
  25. package/dist/agent/middleware/visual-validation-middleware.d.ts +17 -0
  26. package/dist/agent/middleware/visual-validation-middleware.js +67 -0
  27. package/dist/agent/model-benchmark.d.ts +77 -0
  28. package/dist/agent/model-benchmark.js +309 -0
  29. package/dist/agent/model-tier.d.ts +14 -0
  30. package/dist/agent/model-tier.js +71 -0
  31. package/dist/agent/multi-agent/agents/orchestrator-agent.js +17 -6
  32. package/dist/agent/multi-agent/multi-agent-system.js +3 -1
  33. package/dist/agent/multi-agent/session-fleet-bridge.d.ts +2 -0
  34. package/dist/agent/multi-agent/session-fleet-bridge.js +9 -1
  35. package/dist/agent/multi-agent/session-tools.js +22 -5
  36. package/dist/agent/reasoning/mcts.js +20 -6
  37. package/dist/agent/self-improvement/authored-artifact-gate.d.ts +18 -0
  38. package/dist/agent/self-improvement/authored-artifact-gate.js +42 -0
  39. package/dist/agent/self-improvement/authored-tool-runtime.d.ts +27 -0
  40. package/dist/agent/self-improvement/authored-tool-runtime.js +57 -0
  41. package/dist/agent/self-improvement/authored-tool-store.d.ts +24 -0
  42. package/dist/agent/self-improvement/authored-tool-store.js +57 -0
  43. package/dist/agent/self-improvement/llm-tool-proposer.d.ts +41 -0
  44. package/dist/agent/self-improvement/llm-tool-proposer.js +136 -0
  45. package/dist/agent/self-improvement/sandbox-scorer.d.ts +17 -0
  46. package/dist/agent/self-improvement/sandbox-scorer.js +43 -0
  47. package/dist/agent/self-improvement/self-knowledge.d.ts +8 -0
  48. package/dist/agent/self-improvement/self-knowledge.js +24 -0
  49. package/dist/agent/self-improvement/skill-benchmark.d.ts +9 -0
  50. package/dist/agent/self-improvement/skill-benchmark.js +22 -0
  51. package/dist/agent/self-improvement/skill-consolidator.d.ts +71 -0
  52. package/dist/agent/self-improvement/skill-consolidator.js +137 -0
  53. package/dist/agent/self-improvement/skill-engine.d.ts +42 -0
  54. package/dist/agent/self-improvement/skill-engine.js +87 -0
  55. package/dist/agent/self-improvement/skill-gate.d.ts +19 -0
  56. package/dist/agent/self-improvement/skill-gate.js +62 -0
  57. package/dist/agent/self-improvement/skill-mutator.d.ts +74 -0
  58. package/dist/agent/self-improvement/skill-mutator.js +223 -0
  59. package/dist/agent/self-improvement/skill-proposer.d.ts +40 -0
  60. package/dist/agent/self-improvement/skill-proposer.js +82 -0
  61. package/dist/agent/self-improvement/skill-types.d.ts +41 -0
  62. package/dist/agent/self-improvement/skill-types.js +13 -0
  63. package/dist/agent/self-improvement/tool-benchmark.d.ts +10 -0
  64. package/dist/agent/self-improvement/tool-benchmark.js +37 -0
  65. package/dist/agent/self-improvement/tool-engine.d.ts +54 -0
  66. package/dist/agent/self-improvement/tool-engine.js +101 -0
  67. package/dist/agent/self-improvement/tool-gate.d.ts +20 -0
  68. package/dist/agent/self-improvement/tool-gate.js +78 -0
  69. package/dist/agent/self-improvement/tool-proposer.d.ts +31 -0
  70. package/dist/agent/self-improvement/tool-proposer.js +34 -0
  71. package/dist/agent/self-improvement/tool-skill-mutator.d.ts +40 -0
  72. package/dist/agent/self-improvement/tool-skill-mutator.js +79 -0
  73. package/dist/agent/self-improvement/tool-types.d.ts +48 -0
  74. package/dist/agent/self-improvement/tool-types.js +9 -0
  75. package/dist/agent/self-improvement/types.d.ts +3 -1
  76. package/dist/agent/session-end-flush.d.ts +6 -1
  77. package/dist/agent/session-end-flush.js +20 -4
  78. package/dist/agent/streaming/streaming-handler.d.ts +7 -0
  79. package/dist/agent/streaming/streaming-handler.js +8 -1
  80. package/dist/agent/tool-executor.js +1 -0
  81. package/dist/agent/tool-handler.d.ts +5 -0
  82. package/dist/agent/tool-handler.js +133 -4
  83. package/dist/browser-automation/browser-operator-executor.js +15 -0
  84. package/dist/browser-automation/browser-use-runner.d.ts +96 -0
  85. package/dist/browser-automation/browser-use-runner.js +492 -0
  86. package/dist/browser-automation/camofox-runner.d.ts +107 -0
  87. package/dist/browser-automation/camofox-runner.js +287 -0
  88. package/dist/channels/dingtalk/index.js +3 -0
  89. package/dist/channels/discord/client.d.ts +9 -0
  90. package/dist/channels/discord/client.js +12 -0
  91. package/dist/channels/feishu/index.d.ts +167 -1
  92. package/dist/channels/feishu/index.js +432 -7
  93. package/dist/channels/gateway-lifecycle.d.ts +132 -0
  94. package/dist/channels/gateway-lifecycle.js +219 -0
  95. package/dist/channels/google-chat/index.d.ts +5 -1
  96. package/dist/channels/google-chat/index.js +5 -1
  97. package/dist/channels/imessage/index.d.ts +14 -0
  98. package/dist/channels/imessage/index.js +64 -17
  99. package/dist/channels/index.d.ts +4 -0
  100. package/dist/channels/index.js +4 -0
  101. package/dist/channels/irc/index.d.ts +73 -3
  102. package/dist/channels/irc/index.js +446 -11
  103. package/dist/channels/line/index.js +3 -0
  104. package/dist/channels/mattermost/index.d.ts +51 -4
  105. package/dist/channels/mattermost/index.js +303 -20
  106. package/dist/channels/nextcloud-talk/index.d.ts +89 -8
  107. package/dist/channels/nextcloud-talk/index.js +367 -16
  108. package/dist/channels/nostr/index.d.ts +121 -1
  109. package/dist/channels/nostr/index.js +396 -8
  110. package/dist/channels/ntfy/index.js +3 -0
  111. package/dist/channels/qq/index.js +3 -0
  112. package/dist/channels/slash-parity.d.ts +117 -0
  113. package/dist/channels/slash-parity.js +185 -0
  114. package/dist/channels/synology-chat/index.js +3 -0
  115. package/dist/channels/teams/index.d.ts +3 -0
  116. package/dist/channels/teams/index.js +3 -0
  117. package/dist/channels/telegram/client.d.ts +9 -0
  118. package/dist/channels/telegram/client.js +12 -0
  119. package/dist/channels/twilio-voice/index.js +3 -0
  120. package/dist/channels/webchat/index.d.ts +7 -1
  121. package/dist/channels/webchat/index.js +7 -1
  122. package/dist/channels/wecom/index.js +3 -0
  123. package/dist/channels/weixin/index.js +3 -0
  124. package/dist/channels/zalo/index.js +3 -0
  125. package/dist/cli/config-loader.js +1 -1
  126. package/dist/codebuddy/client.d.ts +30 -1
  127. package/dist/codebuddy/client.js +167 -20
  128. package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +5 -0
  129. package/dist/codebuddy/providers/provider-chatgpt-responses.js +7 -1
  130. package/dist/codebuddy/providers/provider-gemini-native.js +1 -1
  131. package/dist/codebuddy/providers/provider-openai-compat.d.ts +5 -0
  132. package/dist/codebuddy/providers/provider-openai-compat.js +82 -2
  133. package/dist/codebuddy/tool-definitions/computer-control-tools.js +32 -2
  134. package/dist/codebuddy/tool-definitions/core-tools.js +3 -3
  135. package/dist/codebuddy/tool-definitions/index.d.ts +2 -1
  136. package/dist/codebuddy/tool-definitions/index.js +2 -1
  137. package/dist/codebuddy/tool-definitions/multimodal-tools.d.ts +1 -0
  138. package/dist/codebuddy/tool-definitions/multimodal-tools.js +44 -1
  139. package/dist/codebuddy/tool-definitions/windows-tools.d.ts +2 -0
  140. package/dist/codebuddy/tool-definitions/windows-tools.js +34 -0
  141. package/dist/codebuddy/tools.d.ts +8 -1
  142. package/dist/codebuddy/tools.js +67 -24
  143. package/dist/commands/cli/hermes-commands.js +108 -0
  144. package/dist/commands/cli/improve-command.js +123 -0
  145. package/dist/commands/cli/native-engine-commands.js +102 -3
  146. package/dist/commands/cli/utility-commands.js +45 -0
  147. package/dist/commands/enhanced-command-handler.js +2 -2
  148. package/dist/commands/goal-cli.d.ts +30 -0
  149. package/dist/commands/goal-cli.js +210 -27
  150. package/dist/commands/handlers/goal-handler.d.ts +9 -2
  151. package/dist/commands/handlers/goal-handler.js +36 -9
  152. package/dist/commands/handlers/infra-handlers.js +36 -0
  153. package/dist/commands/handlers/memory-handlers.js +96 -1
  154. package/dist/commands/handlers/missing-handlers.d.ts +1 -1
  155. package/dist/commands/handlers/missing-handlers.js +26 -3
  156. package/dist/commands/headless-slash.d.ts +2 -0
  157. package/dist/commands/headless-slash.js +12 -0
  158. package/dist/commands/llm-provider-resolution.d.ts +5 -3
  159. package/dist/commands/llm-provider-resolution.js +87 -33
  160. package/dist/commands/ollama.d.ts +25 -0
  161. package/dist/commands/ollama.js +100 -0
  162. package/dist/commands/provider.d.ts +5 -0
  163. package/dist/commands/provider.js +106 -55
  164. package/dist/commands/skills-cli/index.js +123 -0
  165. package/dist/commands/slash/builtin-commands.js +1 -1
  166. package/dist/commands/spec-next.js +2 -1
  167. package/dist/commands/spec-plan.js +5 -16
  168. package/dist/commands/tunnel.d.ts +2 -0
  169. package/dist/commands/tunnel.js +48 -0
  170. package/dist/companion/percepts.js +11 -1
  171. package/dist/config/config-resolver.d.ts +2 -1
  172. package/dist/config/config-resolver.js +54 -41
  173. package/dist/config/constants.d.ts +28 -0
  174. package/dist/config/constants.js +7 -0
  175. package/dist/config/env-schema.js +756 -0
  176. package/dist/config/model-tools.js +4 -4
  177. package/dist/config/toml-config.d.ts +16 -0
  178. package/dist/config/toml-config.js +3 -0
  179. package/dist/context/bootstrap-loader.js +6 -23
  180. package/dist/context/context-manager-v2.js +1 -0
  181. package/dist/context/import-directive-parser.d.ts +4 -0
  182. package/dist/context/import-directive-parser.js +51 -6
  183. package/dist/context/instruction-excludes.d.ts +30 -1
  184. package/dist/context/instruction-excludes.js +71 -1
  185. package/dist/context/jit-context.d.ts +8 -10
  186. package/dist/context/jit-context.js +28 -106
  187. package/dist/context/project-context.d.ts +90 -0
  188. package/dist/context/project-context.js +295 -0
  189. package/dist/daemon/autonomous-daemon.d.ts +1 -1
  190. package/dist/daemon/autonomous-daemon.js +3 -3
  191. package/dist/daemon/autonomous-loop.d.ts +31 -1
  192. package/dist/daemon/autonomous-loop.js +91 -4
  193. package/dist/daemon/colab-goal.js +9 -1
  194. package/dist/daemon/cron-agent-bridge.d.ts +12 -3
  195. package/dist/daemon/cron-agent-bridge.js +25 -9
  196. package/dist/desktop/codebuddy-engine-adapter.d.ts +32 -0
  197. package/dist/desktop/codebuddy-engine-adapter.js +257 -80
  198. package/dist/desktop/engine-adapter.d.ts +14 -0
  199. package/dist/desktop-automation/automation-manager.js +16 -0
  200. package/dist/desktop-automation/omniparser-runner.d.ts +63 -0
  201. package/dist/desktop-automation/omniparser-runner.js +115 -0
  202. package/dist/desktop-automation/smart-snapshot.d.ts +11 -0
  203. package/dist/desktop-automation/smart-snapshot.js +72 -5
  204. package/dist/doctor/index.js +40 -23
  205. package/dist/events/types.d.ts +11 -0
  206. package/dist/fleet/colab-store.js +14 -2
  207. package/dist/fleet/peer-session-bridge.js +50 -12
  208. package/dist/fleet/peer-tool-bridge.js +14 -0
  209. package/dist/goals/goal-decomposer.d.ts +27 -0
  210. package/dist/goals/goal-decomposer.js +293 -0
  211. package/dist/goals/goal-judge-client.d.ts +15 -0
  212. package/dist/goals/goal-judge-client.js +45 -0
  213. package/dist/goals/goal-judge.d.ts +2 -0
  214. package/dist/goals/goal-judge.js +35 -6
  215. package/dist/goals/goal-loop.d.ts +14 -0
  216. package/dist/goals/goal-loop.js +47 -2
  217. package/dist/goals/goal-manager.d.ts +6 -0
  218. package/dist/goals/goal-manager.js +67 -14
  219. package/dist/goals/goal-state.d.ts +13 -0
  220. package/dist/goals/goal-state.js +83 -13
  221. package/dist/goals/goal-store.d.ts +3 -0
  222. package/dist/goals/goal-store.js +31 -15
  223. package/dist/harness/contract.d.ts +28 -28
  224. package/dist/hooks/user-hooks.js +17 -3
  225. package/dist/identity/identity-manager.js +3 -2
  226. package/dist/index.js +481 -26
  227. package/dist/input/text-to-speech.d.ts +2 -6
  228. package/dist/input/text-to-speech.js +2 -27
  229. package/dist/integrations/screenpipe/screenpipe-client.d.ts +10 -0
  230. package/dist/integrations/screenpipe/screenpipe-client.js +12 -2
  231. package/dist/integrations/tailscale.d.ts +13 -0
  232. package/dist/integrations/tailscale.js +87 -34
  233. package/dist/knowledge/workspace-indexer.js +53 -9
  234. package/dist/mcp/client.js +1 -0
  235. package/dist/mcp/mcp-desktop-tools.d.ts +23 -0
  236. package/dist/mcp/mcp-desktop-tools.js +158 -0
  237. package/dist/mcp/mcp-resources.js +2 -3
  238. package/dist/mcp/mcp-server.js +2 -0
  239. package/dist/memory/enhanced-memory.d.ts +10 -0
  240. package/dist/memory/enhanced-memory.js +33 -2
  241. package/dist/memory/index.d.ts +3 -1
  242. package/dist/memory/index.js +4 -1
  243. package/dist/memory/memory-auto-proposer.d.ts +23 -0
  244. package/dist/memory/memory-auto-proposer.js +308 -0
  245. package/dist/memory/memory-candidate-queue.d.ts +92 -0
  246. package/dist/memory/memory-candidate-queue.js +261 -0
  247. package/dist/memory/persistent-memory.d.ts +45 -2
  248. package/dist/memory/persistent-memory.js +236 -40
  249. package/dist/ml/bayesian-qualifier.d.ts +1 -1
  250. package/dist/ml/bayesian-qualifier.js +35 -2
  251. package/dist/openclaw/gateway-bridge.js +5 -0
  252. package/dist/plugins/marketplace.d.ts +1 -0
  253. package/dist/plugins/marketplace.js +7 -0
  254. package/dist/prompts/execution-discipline.d.ts +14 -0
  255. package/dist/prompts/execution-discipline.js +29 -0
  256. package/dist/prompts/variation-injector.js +9 -2
  257. package/dist/protocols/acp/acp-agentic-runner.d.ts +7 -6
  258. package/dist/protocols/acp/acp-agentic-runner.js +115 -18
  259. package/dist/protocols/acp/acp-session-store.d.ts +23 -0
  260. package/dist/protocols/acp/acp-session-store.js +77 -0
  261. package/dist/protocols/acp/acp-stdio-server.d.ts +7 -0
  262. package/dist/protocols/acp/acp-stdio-server.js +71 -16
  263. package/dist/providers/active-llm-registry.d.ts +37 -0
  264. package/dist/providers/active-llm-registry.js +186 -0
  265. package/dist/providers/auxiliary-provider.d.ts +25 -0
  266. package/dist/providers/auxiliary-provider.js +192 -0
  267. package/dist/providers/codex-oauth.d.ts +1 -1
  268. package/dist/providers/codex-oauth.js +27 -4
  269. package/dist/providers/index.d.ts +3 -0
  270. package/dist/providers/index.js +4 -0
  271. package/dist/providers/provider-catalog.d.ts +70 -0
  272. package/dist/providers/provider-catalog.js +738 -0
  273. package/dist/providers/provider-fallback.d.ts +35 -0
  274. package/dist/providers/provider-fallback.js +171 -0
  275. package/dist/providers/xai-oauth.d.ts +128 -0
  276. package/dist/providers/xai-oauth.js +735 -0
  277. package/dist/scheduler/cron-scheduler.d.ts +15 -3
  278. package/dist/scheduler/cron-scheduler.js +53 -7
  279. package/dist/scheduler/script-runner.d.ts +2 -0
  280. package/dist/scheduler/script-runner.js +19 -4
  281. package/dist/scheduler/watchdog-handlers.js +7 -20
  282. package/dist/search/usearch-index.js +7 -2
  283. package/dist/security/tool-policy/tool-groups.js +2 -0
  284. package/dist/sensory/dreaming.d.ts +45 -0
  285. package/dist/sensory/dreaming.js +114 -0
  286. package/dist/sensory/heartbeat-scheduler.d.ts +38 -0
  287. package/dist/sensory/heartbeat-scheduler.js +72 -0
  288. package/dist/sensory/reactions.d.ts +24 -0
  289. package/dist/sensory/reactions.js +31 -0
  290. package/dist/sensory/screen-reaction.d.ts +23 -0
  291. package/dist/sensory/screen-reaction.js +59 -0
  292. package/dist/sensory/sensory-bridge.d.ts +23 -0
  293. package/dist/sensory/sensory-bridge.js +85 -0
  294. package/dist/sensory/sensory-memory.d.ts +20 -0
  295. package/dist/sensory/sensory-memory.js +39 -0
  296. package/dist/sensory/speech-reaction.d.ts +21 -0
  297. package/dist/sensory/speech-reaction.js +83 -0
  298. package/dist/sensory/vision-reaction.d.ts +31 -0
  299. package/dist/sensory/vision-reaction.js +74 -0
  300. package/dist/server/index.js +106 -2
  301. package/dist/server/routes/mobile.d.ts +12 -4
  302. package/dist/server/routes/mobile.js +116 -1
  303. package/dist/server/tls-config.d.ts +35 -0
  304. package/dist/server/tls-config.js +142 -0
  305. package/dist/server/tunnel-manager.d.ts +20 -0
  306. package/dist/server/tunnel-manager.js +58 -0
  307. package/dist/server/websocket/fleet-bridge.js +5 -0
  308. package/dist/services/prompt-builder.d.ts +11 -0
  309. package/dist/services/prompt-builder.js +124 -17
  310. package/dist/shared/engine-types.d.ts +15 -1
  311. package/dist/sidecar/sidecar-bridge.d.ts +1 -0
  312. package/dist/sidecar/sidecar-bridge.js +21 -10
  313. package/dist/skills/parser.js +3 -0
  314. package/dist/skills/skill-importer.d.ts +58 -0
  315. package/dist/skills/skill-importer.js +261 -0
  316. package/dist/skills/skill-sources.d.ts +20 -0
  317. package/dist/skills/skill-sources.js +102 -0
  318. package/dist/skills/types.d.ts +6 -0
  319. package/dist/spec/spec-store.js +8 -1
  320. package/dist/talk-mode/providers/audioreader-tts.d.ts +1 -1
  321. package/dist/talk-mode/providers/audioreader-tts.js +8 -8
  322. package/dist/templates/project-scaffolding.js +3 -2
  323. package/dist/themes/theme-schema.d.ts +10 -10
  324. package/dist/tools/application-profiles.js +38 -0
  325. package/dist/tools/bash/bash-tool.d.ts +1 -0
  326. package/dist/tools/bash/bash-tool.js +16 -2
  327. package/dist/tools/bash/command-validator.js +3 -0
  328. package/dist/tools/bash/rtk-rewrite.d.ts +16 -0
  329. package/dist/tools/bash/rtk-rewrite.js +100 -0
  330. package/dist/tools/bash/streaming-executor.js +14 -1
  331. package/dist/tools/computer-control-tool.d.ts +16 -1
  332. package/dist/tools/computer-control-tool.js +317 -5
  333. package/dist/tools/document-generator.d.ts +14 -0
  334. package/dist/tools/document-generator.js +79 -0
  335. package/dist/tools/execute-code-rpc-invoker.d.ts +26 -2
  336. package/dist/tools/execute-code-rpc-invoker.js +46 -5
  337. package/dist/tools/metadata.js +28 -0
  338. package/dist/tools/office-macro-tool.d.ts +10 -0
  339. package/dist/tools/office-macro-tool.js +93 -0
  340. package/dist/tools/register-tool-handler.d.ts +25 -0
  341. package/dist/tools/register-tool-handler.js +100 -0
  342. package/dist/tools/registry/index.d.ts +2 -1
  343. package/dist/tools/registry/index.js +2 -1
  344. package/dist/tools/registry/memory-tools.d.ts +20 -0
  345. package/dist/tools/registry/memory-tools.js +225 -3
  346. package/dist/tools/registry/multimodal-tools.js +2 -2
  347. package/dist/tools/registry/vision-tools.d.ts +33 -0
  348. package/dist/tools/registry/vision-tools.js +308 -6
  349. package/dist/tools/registry/windows-tools.d.ts +2 -0
  350. package/dist/tools/registry/windows-tools.js +47 -0
  351. package/dist/tools/registry.d.ts +6 -0
  352. package/dist/tools/registry.js +8 -0
  353. package/dist/tools/route-peer-tool.js +14 -0
  354. package/dist/tools/screenshot-tool.js +14 -2
  355. package/dist/tools/text-to-speech-tool.d.ts +1 -1
  356. package/dist/tools/text-to-speech-tool.js +2 -12
  357. package/dist/tools/tool-selector.js +3 -59
  358. package/dist/utils/config-validation/schema.d.ts +40 -7
  359. package/dist/utils/config-validation/schema.js +130 -1
  360. package/dist/utils/cost-tracker.js +21 -1
  361. package/dist/utils/disk-guard.d.ts +180 -0
  362. package/dist/utils/disk-guard.js +404 -0
  363. package/dist/utils/init-project.d.ts +7 -0
  364. package/dist/utils/init-project.js +37 -0
  365. package/dist/utils/interactive-setup.js +35 -2
  366. package/dist/utils/model-utils.js +11 -2
  367. package/dist/utils/output-sanitizer.js +11 -0
  368. package/dist/utils/provider-detector.d.ts +8 -7
  369. package/dist/utils/provider-detector.js +19 -77
  370. package/dist/utils/settings-manager.d.ts +19 -0
  371. package/dist/utils/token-display.d.ts +3 -3
  372. package/dist/utils/token-display.js +22 -4
  373. package/dist/wizard/onboarding.d.ts +39 -0
  374. package/dist/wizard/onboarding.js +433 -21
  375. package/dist/wizard/provider-onboarding.d.ts +8 -23
  376. package/dist/wizard/provider-onboarding.js +39 -158
  377. package/package.json +4 -2
  378. package/dist/plugins/provider-onboarding.d.ts +0 -23
  379. package/dist/plugins/provider-onboarding.js +0 -116
  380. package/dist/utils/kokoro-tts.d.ts +0 -8
  381. package/dist/utils/kokoro-tts.js +0 -67
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Skill proposers — author a SKILL.md for a coverage scenario. A skill is pure
3
+ * guidance, so there is no held-out set to hide (unlike tools); the proposer may
4
+ * see the scenario in full. Safety is enforced downstream by the firewall gate.
5
+ *
6
+ * @module agent/self-improvement/skill-proposer
7
+ */
8
+ import type { SkillBenchmarkScenario, SkillProposal, SkillSpec } from './skill-types.js';
9
+ export interface SkillProposer {
10
+ propose(scenario: SkillBenchmarkScenario): Promise<SkillProposal | null>;
11
+ }
12
+ /** Deterministic proposer backed by a fixture map (scenarioId → spec). */
13
+ export declare class StaticSkillProposer implements SkillProposer {
14
+ private readonly specs;
15
+ constructor(specs: Map<string, SkillSpec>);
16
+ propose(scenario: SkillBenchmarkScenario): Promise<SkillProposal | null>;
17
+ }
18
+ interface MinimalClient {
19
+ chat(messages: Array<{
20
+ role: string;
21
+ content: string;
22
+ }>, tools?: unknown[]): Promise<{
23
+ choices?: Array<{
24
+ message?: {
25
+ content?: string | null;
26
+ };
27
+ }>;
28
+ }>;
29
+ }
30
+ export declare function buildSkillDraftPrompt(scenario: SkillBenchmarkScenario): string;
31
+ export interface LlmSkillProposerOptions {
32
+ client?: MinimalClient | null;
33
+ }
34
+ export declare class LlmSkillProposer implements SkillProposer {
35
+ private clientPromise;
36
+ constructor(options?: LlmSkillProposerOptions);
37
+ private getClient;
38
+ propose(scenario: SkillBenchmarkScenario): Promise<SkillProposal | null>;
39
+ }
40
+ export {};
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Skill proposers — author a SKILL.md for a coverage scenario. A skill is pure
3
+ * guidance, so there is no held-out set to hide (unlike tools); the proposer may
4
+ * see the scenario in full. Safety is enforced downstream by the firewall gate.
5
+ *
6
+ * @module agent/self-improvement/skill-proposer
7
+ */
8
+ import { toAuthoredSkillName } from './skill-mutator.js';
9
+ /** Deterministic proposer backed by a fixture map (scenarioId → spec). */
10
+ export class StaticSkillProposer {
11
+ specs;
12
+ constructor(specs) {
13
+ this.specs = specs;
14
+ }
15
+ async propose(scenario) {
16
+ const spec = this.specs.get(scenario.id);
17
+ if (!spec)
18
+ return null;
19
+ return { id: `skill-proposal:${scenario.id}`, targetScenarioId: scenario.id, spec };
20
+ }
21
+ }
22
+ export function buildSkillDraftPrompt(scenario) {
23
+ return [
24
+ `Write a SKILL.md that gives you reusable guidance for this situation:`,
25
+ ` ${scenario.query}`,
26
+ ``,
27
+ `It MUST clearly cover these points (use these exact terms): ${JSON.stringify(scenario.expectIncludes)}.`,
28
+ ``,
29
+ `Format: a short markdown skill — a title line, a one-line "when to use", then`,
30
+ `concrete steps/notes. Keep it focused. Do NOT include any instruction to ignore`,
31
+ `safety rules, reveal or exfiltrate secrets/credentials, or run destructive`,
32
+ `commands — such content is rejected by a safety firewall.`,
33
+ ``,
34
+ `Return ONLY the SKILL.md markdown (no surrounding prose).`,
35
+ ].join('\n');
36
+ }
37
+ export class LlmSkillProposer {
38
+ clientPromise;
39
+ constructor(options = {}) {
40
+ this.clientPromise = options.client !== undefined ? Promise.resolve(options.client) : null;
41
+ }
42
+ getClient() {
43
+ if (!this.clientPromise) {
44
+ this.clientPromise = (async () => {
45
+ try {
46
+ const { detectProviderFromEnv } = await import('../../utils/provider-detector.js');
47
+ const { CodeBuddyClient } = await import('../../codebuddy/client.js');
48
+ const detected = detectProviderFromEnv();
49
+ if (!detected)
50
+ return null;
51
+ return new CodeBuddyClient(detected.apiKey, detected.defaultModel, detected.baseURL);
52
+ }
53
+ catch {
54
+ return null;
55
+ }
56
+ })();
57
+ }
58
+ return this.clientPromise;
59
+ }
60
+ async propose(scenario) {
61
+ const client = await this.getClient();
62
+ if (!client)
63
+ return null;
64
+ try {
65
+ const prompt = buildSkillDraftPrompt(scenario);
66
+ const response = await client.chat([{ role: 'user', content: prompt }], []);
67
+ const content = response?.choices?.[0]?.message?.content?.trim();
68
+ if (!content)
69
+ return null;
70
+ const spec = {
71
+ name: toAuthoredSkillName(scenario.id),
72
+ description: scenario.description,
73
+ content,
74
+ };
75
+ return { id: `llm-skill:${scenario.id}`, targetScenarioId: scenario.id, spec };
76
+ }
77
+ catch {
78
+ return null;
79
+ }
80
+ }
81
+ }
82
+ //# sourceMappingURL=skill-proposer.js.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Types for the SKILL self-improvement path. A skill is procedural guidance
3
+ * (a SKILL.md injected into context), not a deterministic function — so it is
4
+ * gated by SAFETY (the skill firewall: prompt-injection / exfiltration surface)
5
+ * plus COVERAGE (does it actually surface the expected guidance?), rather than
6
+ * the behavioural held-out gate used for executable tools. Honest by design:
7
+ * there is nothing to "run", so there is no behavioural held-out for pure
8
+ * guidance — the held-out gate stays the tool path's concern.
9
+ *
10
+ * @module agent/self-improvement/skill-types
11
+ */
12
+ export interface SkillSpec {
13
+ /** Authored skill name (slugged, namespaced authored-*). */
14
+ name: string;
15
+ description: string;
16
+ /** The full SKILL.md body. */
17
+ content: string;
18
+ }
19
+ /** Coverage scenario: the authored skill should surface `expectIncludes` for `query`. */
20
+ export interface SkillBenchmarkScenario {
21
+ id: string;
22
+ query: string;
23
+ expectIncludes: string[];
24
+ description: string;
25
+ }
26
+ export interface SkillProposal {
27
+ id: string;
28
+ targetScenarioId: string;
29
+ experienceId?: string;
30
+ spec: SkillSpec;
31
+ }
32
+ export type SkillGateRejection = 'static-scan' | 'firewall' | 'coverage-fail';
33
+ export interface SkillGateOutcome {
34
+ accepted: boolean;
35
+ proposalId: string;
36
+ scenarioId: string;
37
+ rejectionReason?: SkillGateRejection;
38
+ reasons: string[];
39
+ /** Name of the skill left installed (only when accepted AND kept). */
40
+ appliedRef?: string;
41
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Types for the SKILL self-improvement path. A skill is procedural guidance
3
+ * (a SKILL.md injected into context), not a deterministic function — so it is
4
+ * gated by SAFETY (the skill firewall: prompt-injection / exfiltration surface)
5
+ * plus COVERAGE (does it actually surface the expected guidance?), rather than
6
+ * the behavioural held-out gate used for executable tools. Honest by design:
7
+ * there is nothing to "run", so there is no behavioural held-out for pure
8
+ * guidance — the held-out gate stays the tool path's concern.
9
+ *
10
+ * @module agent/self-improvement/skill-types
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=skill-types.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Seed behavioural benchmark for self-authored TOOLS. Each scenario describes a
3
+ * small, deterministic capability with VISIBLE cases (shown to the proposer) and
4
+ * HELD-OUT cases (fresh inputs, never shown) — so a tool that hardcodes the
5
+ * visible answers is caught. Curated separately from any proposer.
6
+ *
7
+ * @module agent/self-improvement/tool-benchmark
8
+ */
9
+ import type { ToolBenchmarkScenario } from './tool-types.js';
10
+ export declare const SEED_TOOL_SCENARIOS: ToolBenchmarkScenario[];
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Seed behavioural benchmark for self-authored TOOLS. Each scenario describes a
3
+ * small, deterministic capability with VISIBLE cases (shown to the proposer) and
4
+ * HELD-OUT cases (fresh inputs, never shown) — so a tool that hardcodes the
5
+ * visible answers is caught. Curated separately from any proposer.
6
+ *
7
+ * @module agent/self-improvement/tool-benchmark
8
+ */
9
+ export const SEED_TOOL_SCENARIOS = [
10
+ {
11
+ id: 'slugify',
12
+ capability: 'Slugify the string field `text`: lowercase it, replace runs of spaces with single hyphens, and print the slug.',
13
+ description: 'authored__slugify converts text to a url slug',
14
+ visibleCases: [
15
+ { input: { text: 'Hello World' }, expectIncludes: ['hello-world'] },
16
+ { input: { text: 'Foo Bar Baz' }, expectIncludes: ['foo-bar-baz'] },
17
+ ],
18
+ heldOutCases: [
19
+ { input: { text: 'The Quick Brown' }, expectIncludes: ['the-quick-brown'] },
20
+ { input: { text: 'A B C' }, expectIncludes: ['a-b-c'] },
21
+ ],
22
+ },
23
+ {
24
+ id: 'word-count',
25
+ capability: 'Count the whitespace-separated words in the string field `text` and print the integer count.',
26
+ description: 'authored__word_count counts words',
27
+ visibleCases: [
28
+ { input: { text: 'one two three' }, expectIncludes: ['3'] },
29
+ { input: { text: 'hello' }, expectIncludes: ['1'] },
30
+ ],
31
+ heldOutCases: [
32
+ { input: { text: 'a b c d e' }, expectIncludes: ['5'] },
33
+ { input: { text: 'foo bar' }, expectIncludes: ['2'] },
34
+ ],
35
+ },
36
+ ];
37
+ //# sourceMappingURL=tool-benchmark.js.map
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ToolImprovementEngine — the tool sibling of SelfImprovementEngine. One cycle:
3
+ * pick an uncovered tool scenario → propose (redacted view) → tool gate
4
+ * (static scan → visible → held-out) → keep+archive (auto-apply) or report.
5
+ *
6
+ * Autonomy is the same fail-safe toggle: 'propose-only' (default) validates and
7
+ * reports; 'auto-apply' (CODEBUDDY_SELF_IMPROVE=true) keeps only tools that pass
8
+ * the behavioural held-out gate, and archives them (reversible — un-registerable).
9
+ *
10
+ * @module agent/self-improvement/tool-engine
11
+ */
12
+ import { EvolutionaryArchive } from './evolutionary-archive.js';
13
+ import { type Autonomy } from './engine.js';
14
+ import { type ToolMutatorPort } from './tool-skill-mutator.js';
15
+ import { type ToolProposer } from './tool-proposer.js';
16
+ import type { ToolBenchmarkScenario, ToolGateOutcome } from './tool-types.js';
17
+ export interface ToolCycleResult {
18
+ kind: 'tool_improvement_cycle';
19
+ startedAt: string;
20
+ autonomy: Autonomy;
21
+ selectedScenarioId: string | null;
22
+ proposalId: string | null;
23
+ gate: ToolGateOutcome | null;
24
+ applied: boolean;
25
+ notes: string[];
26
+ }
27
+ export interface ToolImprovementEngineOptions {
28
+ scenarios: ToolBenchmarkScenario[];
29
+ proposer: ToolProposer;
30
+ mutator?: ToolMutatorPort;
31
+ archive?: EvolutionaryArchive;
32
+ autonomy?: Autonomy;
33
+ now?: () => Date;
34
+ }
35
+ export declare class ToolImprovementEngine {
36
+ private readonly scenarios;
37
+ private readonly proposer;
38
+ private readonly mutator;
39
+ private readonly archive;
40
+ private readonly autonomy;
41
+ private readonly now;
42
+ /** Scenario ids already satisfied this run (coverage is per-scenario, not per tool name). */
43
+ private readonly covered;
44
+ constructor(options: ToolImprovementEngineOptions);
45
+ /** Run exactly one tool-improvement cycle. */
46
+ runCycle(): Promise<ToolCycleResult>;
47
+ /** Run cycles until nothing new is applied (or maxCycles). */
48
+ runLoop(maxCycles?: number): Promise<ToolCycleResult[]>;
49
+ status(): {
50
+ autonomy: Autonomy;
51
+ scenarios: number;
52
+ archive: ReturnType<EvolutionaryArchive['summary']>;
53
+ };
54
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * ToolImprovementEngine — the tool sibling of SelfImprovementEngine. One cycle:
3
+ * pick an uncovered tool scenario → propose (redacted view) → tool gate
4
+ * (static scan → visible → held-out) → keep+archive (auto-apply) or report.
5
+ *
6
+ * Autonomy is the same fail-safe toggle: 'propose-only' (default) validates and
7
+ * reports; 'auto-apply' (CODEBUDDY_SELF_IMPROVE=true) keeps only tools that pass
8
+ * the behavioural held-out gate, and archives them (reversible — un-registerable).
9
+ *
10
+ * @module agent/self-improvement/tool-engine
11
+ */
12
+ import { EvolutionaryArchive } from './evolutionary-archive.js';
13
+ import { resolveAutonomy } from './engine.js';
14
+ import { validateToolProposal } from './tool-gate.js';
15
+ import { LiveToolMutator } from './tool-skill-mutator.js';
16
+ import { toProposerView } from './tool-proposer.js';
17
+ export class ToolImprovementEngine {
18
+ scenarios;
19
+ proposer;
20
+ mutator;
21
+ archive;
22
+ autonomy;
23
+ now;
24
+ /** Scenario ids already satisfied this run (coverage is per-scenario, not per tool name). */
25
+ covered = new Set();
26
+ constructor(options) {
27
+ this.scenarios = options.scenarios;
28
+ this.proposer = options.proposer;
29
+ this.mutator = options.mutator ?? new LiveToolMutator();
30
+ this.archive = options.archive ?? new EvolutionaryArchive();
31
+ this.autonomy = options.autonomy ?? resolveAutonomy();
32
+ this.now = options.now ?? (() => new Date());
33
+ }
34
+ /** Run exactly one tool-improvement cycle. */
35
+ async runCycle() {
36
+ const startedAt = this.now().toISOString();
37
+ const base = { kind: 'tool_improvement_cycle', startedAt, autonomy: this.autonomy };
38
+ for (const scenario of this.scenarios) {
39
+ // Coverage is per-scenario: once a tool has satisfied this scenario's gate,
40
+ // don't re-author it (even if the model would pick a different name).
41
+ if (this.covered.has(scenario.id))
42
+ continue;
43
+ const proposal = await this.proposer.propose(toProposerView(scenario));
44
+ if (!proposal)
45
+ continue;
46
+ // A tool with this exact name already exists — skip (avoid dup-register).
47
+ if (this.mutator.has(proposal.spec.name)) {
48
+ this.covered.add(scenario.id);
49
+ continue;
50
+ }
51
+ const gate = await validateToolProposal(proposal, scenario, this.mutator, {
52
+ keepOnAccept: this.autonomy === 'auto-apply',
53
+ });
54
+ const applied = gate.accepted && !!gate.appliedRef;
55
+ if (applied) {
56
+ this.covered.add(scenario.id);
57
+ this.archive.append({
58
+ proposalId: proposal.id,
59
+ kind: 'tool',
60
+ targetScenarioId: scenario.id,
61
+ experienceId: proposal.experienceId,
62
+ delta: 1,
63
+ scoreAfter: gate.visiblePassed + gate.heldOutPassed,
64
+ appliedRef: gate.appliedRef,
65
+ });
66
+ }
67
+ return {
68
+ ...base,
69
+ selectedScenarioId: scenario.id,
70
+ proposalId: proposal.id,
71
+ gate,
72
+ applied,
73
+ notes: gate.reasons,
74
+ };
75
+ }
76
+ return {
77
+ ...base,
78
+ selectedScenarioId: null,
79
+ proposalId: null,
80
+ gate: null,
81
+ applied: false,
82
+ notes: ['no uncovered tool scenario with an available proposal'],
83
+ };
84
+ }
85
+ /** Run cycles until nothing new is applied (or maxCycles). */
86
+ async runLoop(maxCycles) {
87
+ const cap = Math.max(1, maxCycles ?? this.scenarios.length + 1);
88
+ const results = [];
89
+ for (let i = 0; i < cap; i++) {
90
+ const r = await this.runCycle();
91
+ results.push(r);
92
+ if (!r.applied)
93
+ break;
94
+ }
95
+ return results;
96
+ }
97
+ status() {
98
+ return { autonomy: this.autonomy, scenarios: this.scenarios.length, archive: this.archive.summary() };
99
+ }
100
+ }
101
+ //# sourceMappingURL=tool-engine.js.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Tool gate — the empirical, anti-gaming validator for an authored-tool proposal.
3
+ * Ordered, blocking, fail-closed:
4
+ * G1 static scan (authored-artifact-gate, no execution)
5
+ * G3 VISIBLE behavioural cases must all pass (the tool actually works)
6
+ * G4 HELD-OUT behavioural cases must all pass (fresh inputs the proposer never
7
+ * saw — a tool that hardcodes the visible outputs fails here → rejected).
8
+ * A scenario with no held-out cases is rejected (anti-gaming is then undefined).
9
+ *
10
+ * Scoring never registers the tool; registration happens only on accept+keep.
11
+ *
12
+ * @module agent/self-improvement/tool-gate
13
+ */
14
+ import type { ToolMutatorPort } from './tool-skill-mutator.js';
15
+ import type { ToolBenchmarkScenario, ToolGateOutcome, ToolProposal } from './tool-types.js';
16
+ export interface ValidateToolOptions {
17
+ /** auto-apply: keep (register) an accepted tool. propose-only: report only. */
18
+ keepOnAccept: boolean;
19
+ }
20
+ export declare function validateToolProposal(proposal: ToolProposal, scenario: ToolBenchmarkScenario, mutator: ToolMutatorPort, options: ValidateToolOptions): Promise<ToolGateOutcome>;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Tool gate — the empirical, anti-gaming validator for an authored-tool proposal.
3
+ * Ordered, blocking, fail-closed:
4
+ * G1 static scan (authored-artifact-gate, no execution)
5
+ * G3 VISIBLE behavioural cases must all pass (the tool actually works)
6
+ * G4 HELD-OUT behavioural cases must all pass (fresh inputs the proposer never
7
+ * saw — a tool that hardcodes the visible outputs fails here → rejected).
8
+ * A scenario with no held-out cases is rejected (anti-gaming is then undefined).
9
+ *
10
+ * Scoring never registers the tool; registration happens only on accept+keep.
11
+ *
12
+ * @module agent/self-improvement/tool-gate
13
+ */
14
+ import { inspectAuthoredCode } from './authored-artifact-gate.js';
15
+ import { scoreToolCases } from './sandbox-scorer.js';
16
+ export async function validateToolProposal(proposal, scenario, mutator, options) {
17
+ const zero = {
18
+ proposalId: proposal.id,
19
+ scenarioId: scenario.id,
20
+ visiblePassed: 0,
21
+ visibleTotal: scenario.visibleCases.length,
22
+ heldOutPassed: 0,
23
+ heldOutTotal: scenario.heldOutCases.length,
24
+ };
25
+ // G1 — static scan (no execution).
26
+ const scan = inspectAuthoredCode(proposal.spec.code, 'code');
27
+ if (!scan.ok) {
28
+ return { ...zero, accepted: false, rejectionReason: 'static-scan', reasons: scan.reasons };
29
+ }
30
+ // Fail-closed: a scenario with no held-out cases can't defend against gaming.
31
+ if (scenario.heldOutCases.length === 0) {
32
+ return {
33
+ ...zero,
34
+ accepted: false,
35
+ rejectionReason: 'heldout-fail',
36
+ reasons: ['scenario has no held-out cases — anti-gaming is undefined, refusing'],
37
+ };
38
+ }
39
+ // G3 — visible behavioural cases (the tool must actually work).
40
+ const visible = await scoreToolCases(proposal.spec, scenario.visibleCases);
41
+ if (visible.passed < visible.total) {
42
+ return {
43
+ ...zero,
44
+ accepted: false,
45
+ visiblePassed: visible.passed,
46
+ rejectionReason: 'visible-fail',
47
+ reasons: visible.failures,
48
+ };
49
+ }
50
+ // G4 — held-out cases on FRESH inputs (catches hardcoded-output gaming).
51
+ const heldOut = await scoreToolCases(proposal.spec, scenario.heldOutCases);
52
+ if (heldOut.passed < heldOut.total) {
53
+ return {
54
+ ...zero,
55
+ accepted: false,
56
+ visiblePassed: visible.passed,
57
+ heldOutPassed: heldOut.passed,
58
+ rejectionReason: 'heldout-fail',
59
+ reasons: ['held-out cases failed — likely gamed/overfit visible outputs', ...heldOut.failures],
60
+ };
61
+ }
62
+ // Accepted. Keep (auto-apply) or just report (propose-only).
63
+ let appliedRef;
64
+ if (options.keepOnAccept) {
65
+ appliedRef = mutator.register(proposal.spec).name;
66
+ }
67
+ return {
68
+ ...zero,
69
+ accepted: true,
70
+ visiblePassed: visible.passed,
71
+ heldOutPassed: heldOut.passed,
72
+ reasons: options.keepOnAccept
73
+ ? ['accepted and kept (auto-apply): passed visible + held-out, statically clean']
74
+ : ['accepted (propose-only): passed visible + held-out, not persisted'],
75
+ ...(appliedRef ? { appliedRef } : {}),
76
+ };
77
+ }
78
+ //# sourceMappingURL=tool-gate.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Tool proposer — authors a candidate tool for a scenario. It receives a REDACTED
3
+ * view of the scenario (capability + visible cases only); the held-out cases are
4
+ * never exposed, so a proposer (static or LLM) cannot overfit to them. This is the
5
+ * structural half of the anti-gaming defence (the gate is the empirical half).
6
+ *
7
+ * @module agent/self-improvement/tool-proposer
8
+ */
9
+ import type { AuthoredToolSpec } from './authored-tool-runtime.js';
10
+ import type { ToolBenchmarkScenario, ToolCase, ToolProposal } from './tool-types.js';
11
+ /** What a proposer is allowed to see — NO held-out cases. */
12
+ export interface ProposerScenarioView {
13
+ id: string;
14
+ capability: string;
15
+ description: string;
16
+ visibleCases: ToolCase[];
17
+ }
18
+ /** Redact a scenario down to what a proposer may see. */
19
+ export declare function toProposerView(scenario: ToolBenchmarkScenario): ProposerScenarioView;
20
+ export interface ToolProposer {
21
+ propose(view: ProposerScenarioView): Promise<ToolProposal | null>;
22
+ }
23
+ /**
24
+ * Deterministic proposer backed by a fixture map (scenarioId → spec). Ships first
25
+ * (testable, no LLM). The LLM proposer is Phase 3 and uses the same redacted view.
26
+ */
27
+ export declare class StaticToolProposer implements ToolProposer {
28
+ private readonly specs;
29
+ constructor(specs: Map<string, AuthoredToolSpec>);
30
+ propose(view: ProposerScenarioView): Promise<ToolProposal | null>;
31
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Tool proposer — authors a candidate tool for a scenario. It receives a REDACTED
3
+ * view of the scenario (capability + visible cases only); the held-out cases are
4
+ * never exposed, so a proposer (static or LLM) cannot overfit to them. This is the
5
+ * structural half of the anti-gaming defence (the gate is the empirical half).
6
+ *
7
+ * @module agent/self-improvement/tool-proposer
8
+ */
9
+ /** Redact a scenario down to what a proposer may see. */
10
+ export function toProposerView(scenario) {
11
+ return {
12
+ id: scenario.id,
13
+ capability: scenario.capability,
14
+ description: scenario.description,
15
+ visibleCases: scenario.visibleCases,
16
+ };
17
+ }
18
+ /**
19
+ * Deterministic proposer backed by a fixture map (scenarioId → spec). Ships first
20
+ * (testable, no LLM). The LLM proposer is Phase 3 and uses the same redacted view.
21
+ */
22
+ export class StaticToolProposer {
23
+ specs;
24
+ constructor(specs) {
25
+ this.specs = specs;
26
+ }
27
+ async propose(view) {
28
+ const spec = this.specs.get(view.id);
29
+ if (!spec)
30
+ return null;
31
+ return { id: `tool-proposal:${view.id}`, targetScenarioId: view.id, spec };
32
+ }
33
+ }
34
+ //# sourceMappingURL=tool-proposer.js.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Tool mutator port — applies/reverts an authored tool across BOTH registries
3
+ * with a proven inverse, so the engine can keep it (auto-apply) or cleanly
4
+ * un-register it (propose-only / rejection):
5
+ * - FormalToolRegistry → makes it CALLABLE (dispatch reads this),
6
+ * - legacy ToolRegistry → makes its schema VISIBLE to the model next turn.
7
+ *
8
+ * @module agent/self-improvement/tool-skill-mutator
9
+ */
10
+ import { type AuthoredToolSpec } from './authored-tool-runtime.js';
11
+ import { AuthoredToolStore } from './authored-tool-store.js';
12
+ export interface ToolMutatorPort {
13
+ register(spec: AuthoredToolSpec): {
14
+ name: string;
15
+ };
16
+ unregister(name: string): boolean;
17
+ has(name: string): boolean;
18
+ }
19
+ export interface LiveToolMutatorOptions {
20
+ /** Persist kept tools to disk so they survive a restart (default true). */
21
+ persist?: boolean;
22
+ store?: AuthoredToolStore;
23
+ }
24
+ /** Dual-registry mutator over the live singletons, with optional disk persistence. */
25
+ export declare class LiveToolMutator implements ToolMutatorPort {
26
+ private readonly persist;
27
+ private readonly store;
28
+ constructor(options?: LiveToolMutatorOptions);
29
+ register(spec: AuthoredToolSpec): {
30
+ name: string;
31
+ };
32
+ unregister(name: string): boolean;
33
+ has(name: string): boolean;
34
+ }
35
+ /**
36
+ * Re-register persisted authored tools into both registries at startup. Does NOT
37
+ * re-persist (it's loading what's already on disk). Returns the names loaded.
38
+ * Gated by callers on CODEBUDDY_SELF_IMPROVE.
39
+ */
40
+ export declare function loadAuthoredTools(workDir?: string): string[];
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Tool mutator port — applies/reverts an authored tool across BOTH registries
3
+ * with a proven inverse, so the engine can keep it (auto-apply) or cleanly
4
+ * un-register it (propose-only / rejection):
5
+ * - FormalToolRegistry → makes it CALLABLE (dispatch reads this),
6
+ * - legacy ToolRegistry → makes its schema VISIBLE to the model next turn.
7
+ *
8
+ * @module agent/self-improvement/tool-skill-mutator
9
+ */
10
+ import { FormalToolRegistry } from '../../tools/registry/tool-registry.js';
11
+ import { getToolRegistry } from '../../tools/registry.js';
12
+ import { buildAuthoredTool } from './authored-tool-runtime.js';
13
+ import { AuthoredToolStore } from './authored-tool-store.js';
14
+ /** Dual-registry mutator over the live singletons, with optional disk persistence. */
15
+ export class LiveToolMutator {
16
+ persist;
17
+ store;
18
+ constructor(options = {}) {
19
+ this.persist = options.persist ?? true;
20
+ this.store = options.store ?? new AuthoredToolStore();
21
+ }
22
+ register(spec) {
23
+ const tool = buildAuthoredTool(spec);
24
+ FormalToolRegistry.getInstance().register(tool, { override: true });
25
+ const definition = {
26
+ type: 'function',
27
+ function: {
28
+ name: spec.name,
29
+ description: spec.description,
30
+ parameters: spec.parameters,
31
+ },
32
+ };
33
+ const metadata = {
34
+ name: spec.name,
35
+ category: 'system',
36
+ keywords: ['authored', 'self-extension', 'tool'],
37
+ priority: 5,
38
+ description: spec.description,
39
+ };
40
+ getToolRegistry().registerTool(definition, metadata);
41
+ if (this.persist)
42
+ this.store.add(spec);
43
+ return { name: spec.name };
44
+ }
45
+ unregister(name) {
46
+ const a = FormalToolRegistry.getInstance().unregister(name);
47
+ const b = getToolRegistry().removeTool(name);
48
+ if (this.persist)
49
+ this.store.remove(name);
50
+ return a || b;
51
+ }
52
+ has(name) {
53
+ return FormalToolRegistry.getInstance().has(name) || getToolRegistry().getTool(name) !== undefined;
54
+ }
55
+ }
56
+ /**
57
+ * Re-register persisted authored tools into both registries at startup. Does NOT
58
+ * re-persist (it's loading what's already on disk). Returns the names loaded.
59
+ * Gated by callers on CODEBUDDY_SELF_IMPROVE.
60
+ */
61
+ export function loadAuthoredTools(workDir) {
62
+ const store = new AuthoredToolStore(workDir ? { workDir } : {});
63
+ const specs = store.list();
64
+ if (specs.length === 0)
65
+ return [];
66
+ const loader = new LiveToolMutator({ persist: false, store });
67
+ const loaded = [];
68
+ for (const spec of specs) {
69
+ try {
70
+ loader.register(spec);
71
+ loaded.push(spec.name);
72
+ }
73
+ catch {
74
+ /* skip a malformed persisted spec */
75
+ }
76
+ }
77
+ return loaded;
78
+ }
79
+ //# sourceMappingURL=tool-skill-mutator.js.map