@phuetz/code-buddy 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/README.fr.md +56 -0
  2. package/README.md +73 -16
  3. package/codebuddy-runtime.json +5 -5
  4. package/dist/agent/codebuddy-agent.d.ts +18 -0
  5. package/dist/agent/codebuddy-agent.js +45 -8
  6. package/dist/agent/execution/agent-executor.d.ts +0 -9
  7. package/dist/agent/execution/agent-executor.js +165 -12
  8. package/dist/agent/execution/context-pipeline.d.ts +9 -0
  9. package/dist/agent/execution/context-pipeline.js +64 -2
  10. package/dist/agent/execution/tool-loop-guard.d.ts +76 -0
  11. package/dist/agent/execution/tool-loop-guard.js +165 -0
  12. package/dist/agent/execution/tool-selection-strategy.js +19 -2
  13. package/dist/agent/facades/session-facade.d.ts +0 -6
  14. package/dist/agent/facades/session-facade.js +0 -45
  15. package/dist/agent/hermes-claw-migrate.d.ts +0 -21
  16. package/dist/agent/hermes-claw-migrate.js +9 -4
  17. package/dist/agent/hermes-protocol-gateways.js +8 -1
  18. package/dist/agent/repo-profiler.js +17 -4
  19. package/dist/agent/self-improvement/authored-tool-runtime.js +10 -2
  20. package/dist/agent/self-improvement/evolution/ast-novelty.d.ts +5 -0
  21. package/dist/agent/self-improvement/evolution/ast-novelty.js +58 -23
  22. package/dist/agent/self-improvement/evolution/code-variant-store.d.ts +3 -0
  23. package/dist/agent/self-improvement/evolution/evolution-engine.js +2 -0
  24. package/dist/agent/self-improvement/evolution/protected-paths.js +6 -0
  25. package/dist/agent/self-improvement/evolution/variant-fitness.d.ts +13 -2
  26. package/dist/agent/self-improvement/evolution/variant-fitness.js +184 -58
  27. package/dist/agent/self-improvement/evolution/worktree-scorer.d.ts +2 -0
  28. package/dist/agent/self-improvement/evolution/worktree-scorer.js +15 -0
  29. package/dist/agent/self-improvement/evolutionary-archive.d.ts +2 -1
  30. package/dist/agent/self-improvement/evolutionary-archive.js +34 -5
  31. package/dist/agent/self-improvement/proposal-store.d.ts +1 -0
  32. package/dist/agent/self-improvement/proposal-store.js +79 -17
  33. package/dist/agent/self-improvement/skill-apply-journal.d.ts +44 -0
  34. package/dist/agent/self-improvement/skill-apply-journal.js +178 -0
  35. package/dist/agent/self-improvement/skill-behavior-benchmark.d.ts +3 -0
  36. package/dist/agent/self-improvement/skill-behavior-benchmark.js +19 -0
  37. package/dist/agent/self-improvement/skill-behavior-gate.d.ts +34 -0
  38. package/dist/agent/self-improvement/skill-behavior-gate.js +96 -0
  39. package/dist/agent/self-improvement/skill-engine.d.ts +22 -0
  40. package/dist/agent/self-improvement/skill-engine.js +385 -13
  41. package/dist/agent/self-improvement/skill-gate.d.ts +2 -0
  42. package/dist/agent/self-improvement/skill-gate.js +17 -2
  43. package/dist/agent/self-improvement/skill-mutator.d.ts +6 -1
  44. package/dist/agent/self-improvement/skill-mutator.js +51 -15
  45. package/dist/agent/self-improvement/skill-types.d.ts +2 -1
  46. package/dist/agent/self-improvement/types.d.ts +11 -0
  47. package/dist/agent/tool-handler.d.ts +1 -1
  48. package/dist/agent/tool-handler.js +28 -9
  49. package/dist/auth/profile-manager.js +1 -1
  50. package/dist/channels/companion-channel-turn.d.ts +53 -4
  51. package/dist/channels/companion-channel-turn.js +218 -16
  52. package/dist/channels/slash-parity.d.ts +4 -6
  53. package/dist/channels/slash-parity.js +9 -44
  54. package/dist/cli/session-commands.d.ts +9 -0
  55. package/dist/cli/session-commands.js +45 -5
  56. package/dist/cli/session-picker.d.ts +43 -0
  57. package/dist/cli/session-picker.js +128 -0
  58. package/dist/codebuddy/a2a-call-tool-defs.d.ts +26 -0
  59. package/dist/codebuddy/a2a-call-tool-defs.js +12 -0
  60. package/dist/codebuddy/fleet-tool-defs.d.ts +1 -0
  61. package/dist/codebuddy/fleet-tool-defs.js +24 -0
  62. package/dist/codebuddy/providers/chatgpt-headers.d.ts +18 -0
  63. package/dist/codebuddy/providers/chatgpt-headers.js +37 -0
  64. package/dist/codebuddy/providers/provider-chatgpt-responses.d.ts +2 -1
  65. package/dist/codebuddy/providers/provider-chatgpt-responses.js +10 -23
  66. package/dist/codebuddy/providers/provider-openai-compat.js +1 -1
  67. package/dist/codebuddy/ragchat-tool-defs.d.ts +31 -0
  68. package/dist/codebuddy/ragchat-tool-defs.js +19 -0
  69. package/dist/codebuddy/resource-catalog-tool-defs.d.ts +28 -0
  70. package/dist/codebuddy/resource-catalog-tool-defs.js +18 -0
  71. package/dist/codebuddy/tool-definitions/agent-tools.js +2 -2
  72. package/dist/codebuddy/tool-definitions/code-exec-tools.js +5 -1
  73. package/dist/codebuddy/tool-definitions/cron-tools.js +6 -0
  74. package/dist/codebuddy/tool-definitions/self-describe-tools.js +6 -1
  75. package/dist/codebuddy/tools.d.ts +0 -6
  76. package/dist/codebuddy/tools.js +25 -3
  77. package/dist/commands/cli/daemon-commands.js +3 -1
  78. package/dist/commands/cli/evolve-command.js +21 -5
  79. package/dist/commands/cli/fleet-collaboration-commands.d.ts +2 -0
  80. package/dist/commands/cli/fleet-collaboration-commands.js +57 -0
  81. package/dist/commands/cli/fleet-commands.js +29 -0
  82. package/dist/commands/cli/fleet-mission-commands.d.ts +3 -0
  83. package/dist/commands/cli/fleet-mission-commands.js +72 -0
  84. package/dist/commands/cli/fleet-rooms-commands.d.ts +10 -0
  85. package/dist/commands/cli/fleet-rooms-commands.js +289 -0
  86. package/dist/commands/cli/tools-commands.js +2 -1
  87. package/dist/commands/cli/triage-command.d.ts +8 -0
  88. package/dist/commands/cli/triage-command.js +72 -0
  89. package/dist/commands/cli/utility-commands.js +25 -1
  90. package/dist/commands/client-dispatcher.d.ts +7 -0
  91. package/dist/commands/client-dispatcher.js +73 -21
  92. package/dist/commands/cron-cli/index.d.ts +3 -1
  93. package/dist/commands/cron-cli/index.js +25 -0
  94. package/dist/commands/device-auth.d.ts +10 -0
  95. package/dist/commands/device-auth.js +91 -0
  96. package/dist/commands/enhanced-command-handler.d.ts +9 -0
  97. package/dist/commands/enhanced-command-handler.js +28 -6
  98. package/dist/commands/handlers/agent-handlers.d.ts +1 -1
  99. package/dist/commands/handlers/agent-handlers.js +4 -4
  100. package/dist/commands/handlers/channel-handlers.js +53 -2
  101. package/dist/commands/handlers/export-handlers.d.ts +3 -2
  102. package/dist/commands/handlers/export-handlers.js +55 -28
  103. package/dist/commands/handlers/extra-handlers.js +5 -1
  104. package/dist/commands/handlers/grill-me-handler.js +26 -18
  105. package/dist/commands/handlers/memory-handlers.d.ts +6 -2
  106. package/dist/commands/handlers/memory-handlers.js +35 -15
  107. package/dist/commands/handlers/missing-handlers.d.ts +2 -2
  108. package/dist/commands/handlers/missing-handlers.js +4 -4
  109. package/dist/commands/handlers/resources-handler.d.ts +12 -0
  110. package/dist/commands/handlers/resources-handler.js +52 -0
  111. package/dist/commands/handlers/starter-handlers.d.ts +1 -1
  112. package/dist/commands/handlers/starter-handlers.js +32 -2
  113. package/dist/commands/handlers/switch-handler.d.ts +1 -1
  114. package/dist/commands/handlers/switch-handler.js +15 -0
  115. package/dist/commands/handlers/test-handlers.js +4 -86
  116. package/dist/commands/handlers/ui-handlers.js +11 -5
  117. package/dist/commands/login-chatgpt.d.ts +8 -0
  118. package/dist/commands/login-chatgpt.js +17 -0
  119. package/dist/commands/mcp-import.d.ts +11 -0
  120. package/dist/commands/mcp-import.js +67 -0
  121. package/dist/commands/mcp-invoke.d.ts +2 -0
  122. package/dist/commands/mcp-invoke.js +68 -0
  123. package/dist/commands/mcp.js +4 -0
  124. package/dist/commands/pipeline.d.ts +7 -1
  125. package/dist/commands/pipeline.js +104 -7
  126. package/dist/commands/resources.d.ts +2 -0
  127. package/dist/commands/resources.js +64 -0
  128. package/dist/commands/skills-cli/index.js +35 -12
  129. package/dist/commands/slash/builtin-commands.js +16 -3
  130. package/dist/commands/slash/index.d.ts +3 -1
  131. package/dist/commands/slash/index.js +2 -0
  132. package/dist/commands/slash/surfaces.d.ts +53 -0
  133. package/dist/commands/slash/surfaces.js +177 -0
  134. package/dist/commands/slash/types.d.ts +17 -0
  135. package/dist/commands/try.d.ts +1 -1
  136. package/dist/commands/try.js +1 -1
  137. package/dist/companion/companion-identity.d.ts +43 -0
  138. package/dist/companion/companion-identity.js +136 -0
  139. package/dist/companion/companion-toolset.d.ts +66 -0
  140. package/dist/companion/companion-toolset.js +368 -0
  141. package/dist/companion/companion-turn.d.ts +10 -2
  142. package/dist/companion/companion-turn.js +38 -1
  143. package/dist/config/code-exec-policy.d.ts +25 -0
  144. package/dist/config/code-exec-policy.js +39 -0
  145. package/dist/config/model-tools.d.ts +9 -0
  146. package/dist/config/model-tools.js +4 -0
  147. package/dist/context/context-manager-v2.js +2 -2
  148. package/dist/context/lm-resizer-compressor.js +3 -2
  149. package/dist/context/lm-resizer-diagnostics.d.ts +9 -0
  150. package/dist/context/lm-resizer-diagnostics.js +30 -0
  151. package/dist/context/tool-output-masking.js +3 -4
  152. package/dist/curator/curator.d.ts +6 -0
  153. package/dist/curator/curator.js +53 -3
  154. package/dist/daemon/cron-agent-bridge.d.ts +6 -0
  155. package/dist/daemon/cron-agent-bridge.js +31 -4
  156. package/dist/doctor/index.d.ts +11 -2
  157. package/dist/doctor/index.js +84 -21
  158. package/dist/doctor/integrations.d.ts +179 -0
  159. package/dist/doctor/integrations.js +227 -0
  160. package/dist/doctor/triage.d.ts +108 -0
  161. package/dist/doctor/triage.js +304 -0
  162. package/dist/fleet/collaboration.d.ts +44 -0
  163. package/dist/fleet/collaboration.js +170 -0
  164. package/dist/fleet/fleet-listener.d.ts +1 -0
  165. package/dist/fleet/fleet-listener.js +87 -46
  166. package/dist/fleet/fleet-registry.d.ts +2 -0
  167. package/dist/fleet/resource-catalog.d.ts +245 -0
  168. package/dist/fleet/resource-catalog.js +211 -0
  169. package/dist/fleet/rooms/room-access.d.ts +138 -0
  170. package/dist/fleet/rooms/room-access.js +196 -0
  171. package/dist/fleet/rooms/room-client.d.ts +158 -0
  172. package/dist/fleet/rooms/room-client.js +685 -0
  173. package/dist/fleet/rooms/room-event.d.ts +139 -0
  174. package/dist/fleet/rooms/room-event.js +330 -0
  175. package/dist/fleet/rooms/room-filter.d.ts +48 -0
  176. package/dist/fleet/rooms/room-filter.js +152 -0
  177. package/dist/fleet/rooms/room-hub.d.ts +154 -0
  178. package/dist/fleet/rooms/room-hub.js +363 -0
  179. package/dist/fleet/rooms/room-identity.d.ts +26 -0
  180. package/dist/fleet/rooms/room-identity.js +82 -0
  181. package/dist/fleet/rooms/room-lock.d.ts +34 -0
  182. package/dist/fleet/rooms/room-lock.js +180 -0
  183. package/dist/fleet/rooms/room-observations.d.ts +7 -0
  184. package/dist/fleet/rooms/room-observations.js +61 -0
  185. package/dist/fleet/rooms/room-server.d.ts +28 -0
  186. package/dist/fleet/rooms/room-server.js +75 -0
  187. package/dist/fleet/rooms/room-store.d.ts +119 -0
  188. package/dist/fleet/rooms/room-store.js +448 -0
  189. package/dist/fleet/rooms/room-ws-bridge.d.ts +27 -0
  190. package/dist/fleet/rooms/room-ws-bridge.js +137 -0
  191. package/dist/fleet/sensory-mission-bridge.d.ts +42 -0
  192. package/dist/fleet/sensory-mission-bridge.js +136 -0
  193. package/dist/git/worktree-sessions.js +1 -0
  194. package/dist/harness/contract.d.ts +4 -4
  195. package/dist/harness/fleet-supervisor.d.ts +16 -0
  196. package/dist/harness/fleet-supervisor.js +64 -0
  197. package/dist/harness/index.d.ts +4 -0
  198. package/dist/harness/index.js +4 -0
  199. package/dist/harness/mission-runner.d.ts +3 -0
  200. package/dist/harness/mission-runner.js +53 -0
  201. package/dist/harness/mission-store.d.ts +93 -0
  202. package/dist/harness/mission-store.js +297 -0
  203. package/dist/harness/tool-harness.d.ts +56 -0
  204. package/dist/harness/tool-harness.js +153 -0
  205. package/dist/hooks/use-enhanced-input.js +48 -4
  206. package/dist/hooks/use-input-handler.d.ts +1 -0
  207. package/dist/hooks/use-input-handler.js +82 -22
  208. package/dist/hooks/use-input-history.js +1 -0
  209. package/dist/identity/lisa-introspection.js +5 -2
  210. package/dist/identity/operational-self-model.d.ts +2 -0
  211. package/dist/identity/operational-self-model.js +4 -0
  212. package/dist/index.js +52 -6
  213. package/dist/mcp/client.js +6 -0
  214. package/dist/mcp/config.d.ts +20 -0
  215. package/dist/mcp/config.js +121 -8
  216. package/dist/mcp/import-normalize.d.ts +12 -0
  217. package/dist/mcp/import-normalize.js +114 -0
  218. package/dist/mcp/transports.d.ts +10 -5
  219. package/dist/mcp/transports.js +61 -99
  220. package/dist/mcp/types.d.ts +5 -0
  221. package/dist/media/comfyui-recipe-contract.d.ts +7 -7
  222. package/dist/memory/facts-memory.d.ts +11 -1
  223. package/dist/memory/facts-memory.js +47 -8
  224. package/dist/memory/memory-candidate-queue.d.ts +2 -2
  225. package/dist/memory/memory-candidate-queue.js +6 -6
  226. package/dist/memory/persistent-memory.d.ts +13 -8
  227. package/dist/memory/persistent-memory.js +77 -30
  228. package/dist/nodes/device-node.js +5 -9
  229. package/dist/observability/mobile-supervision-gateway-contract.js +20 -7
  230. package/dist/observability/run-event-writer.d.ts +21 -0
  231. package/dist/observability/run-event-writer.js +81 -0
  232. package/dist/observability/run-store.d.ts +5 -0
  233. package/dist/observability/run-store.js +18 -13
  234. package/dist/observability/run-trajectory.js +1 -1
  235. package/dist/optimization/prompt-cache.d.ts +19 -2
  236. package/dist/optimization/prompt-cache.js +41 -6
  237. package/dist/orchestration/orchestrator.d.ts +21 -0
  238. package/dist/orchestration/orchestrator.js +122 -15
  239. package/dist/persistence/session-content.d.ts +8 -0
  240. package/dist/persistence/session-content.js +76 -0
  241. package/dist/persistence/session-handoff.d.ts +64 -0
  242. package/dist/persistence/session-handoff.js +80 -0
  243. package/dist/persistence/session-history.d.ts +4 -0
  244. package/dist/persistence/session-history.js +38 -0
  245. package/dist/persistence/session-store.d.ts +9 -0
  246. package/dist/persistence/session-store.js +48 -20
  247. package/dist/personas/persona-manager.js +17 -1
  248. package/dist/plugins/code-explorer/CodeExplorerManager.d.ts +10 -4
  249. package/dist/plugins/code-explorer/CodeExplorerManager.js +69 -16
  250. package/dist/plugins/plugin-manager.js +10 -1
  251. package/dist/prompts/prompt-manager.js +11 -4
  252. package/dist/prompts/system-base.js +6 -2
  253. package/dist/protocols/a2a/codebuddy-executor.d.ts +11 -2
  254. package/dist/protocols/a2a/codebuddy-executor.js +9 -8
  255. package/dist/protocols/a2a/index.d.ts +1 -1
  256. package/dist/protocols/a2a/jsonrpc-v1.d.ts +41 -0
  257. package/dist/protocols/a2a/jsonrpc-v1.js +145 -0
  258. package/dist/protocols/a2a/peer-config.d.ts +20 -0
  259. package/dist/protocols/a2a/peer-config.js +55 -0
  260. package/dist/providers/codex-oauth.js +30 -6
  261. package/dist/providers/model-provider-compat.js +2 -1
  262. package/dist/sandbox/os-sandbox.d.ts +1 -1
  263. package/dist/scheduler/cron-scheduler.d.ts +15 -2
  264. package/dist/scheduler/cron-scheduler.js +35 -4
  265. package/dist/scheduler/job-notepad.d.ts +69 -0
  266. package/dist/scheduler/job-notepad.js +339 -0
  267. package/dist/security/audit-logger.d.ts +1 -1
  268. package/dist/security/compute-confinement.d.ts +4 -0
  269. package/dist/security/compute-confinement.js +89 -0
  270. package/dist/security/session-encryption.d.ts +4 -0
  271. package/dist/security/session-encryption.js +31 -0
  272. package/dist/sensory/voice-loop.d.ts +17 -0
  273. package/dist/sensory/voice-loop.js +72 -15
  274. package/dist/server/auth/device-session-context.d.ts +9 -0
  275. package/dist/server/auth/device-session-context.js +13 -0
  276. package/dist/server/auth/device-store.d.ts +89 -0
  277. package/dist/server/auth/device-store.js +261 -0
  278. package/dist/server/auth/device-token.d.ts +3 -0
  279. package/dist/server/auth/device-token.js +6 -0
  280. package/dist/server/auth/jwt.js +4 -0
  281. package/dist/server/index.d.ts +0 -10
  282. package/dist/server/index.js +28 -0
  283. package/dist/server/middleware/auth.js +3 -2
  284. package/dist/server/routes/a2a-jsonrpc.d.ts +9 -0
  285. package/dist/server/routes/a2a-jsonrpc.js +66 -0
  286. package/dist/server/routes/a2a-protocol.d.ts +12 -0
  287. package/dist/server/routes/a2a-protocol.js +1 -1
  288. package/dist/server/routes/device-auth.d.ts +4 -0
  289. package/dist/server/routes/device-auth.js +40 -0
  290. package/dist/server/types.d.ts +4 -0
  291. package/dist/server/websocket/handler.d.ts +13 -0
  292. package/dist/server/websocket/handler.js +102 -17
  293. package/dist/services/prompt-builder.d.ts +2 -0
  294. package/dist/services/prompt-builder.js +13 -5
  295. package/dist/services/runtime-settings-context.d.ts +73 -0
  296. package/dist/services/runtime-settings-context.js +69 -0
  297. package/dist/skills/executor.js +2 -0
  298. package/dist/skills/hub.js +16 -14
  299. package/dist/skills/local-inventory.d.ts +21 -0
  300. package/dist/skills/local-inventory.js +72 -0
  301. package/dist/skills/skill-loader.js +2 -2
  302. package/dist/skills/skill-usage-store.d.ts +49 -0
  303. package/dist/skills/skill-usage-store.js +121 -0
  304. package/dist/testing/ai-integration-tests.js +8 -5
  305. package/dist/themes/theme-manager.d.ts +12 -0
  306. package/dist/themes/theme-manager.js +29 -0
  307. package/dist/themes/theme-schema.d.ts +24 -24
  308. package/dist/tools/a2a-call-tool.d.ts +34 -0
  309. package/dist/tools/a2a-call-tool.js +75 -0
  310. package/dist/tools/bash/streaming-executor.d.ts +1 -0
  311. package/dist/tools/bash/streaming-executor.js +78 -90
  312. package/dist/tools/code-exec-preflight-runner.d.ts +41 -0
  313. package/dist/tools/code-exec-preflight-runner.js +254 -0
  314. package/dist/tools/code-exec-preflight.d.ts +44 -0
  315. package/dist/tools/code-exec-preflight.js +501 -0
  316. package/dist/tools/code-exec-tool.d.ts +48 -1
  317. package/dist/tools/code-exec-tool.js +191 -47
  318. package/dist/tools/comment-watcher.js +29 -12
  319. package/dist/tools/core-code-inspection.d.ts +56 -0
  320. package/dist/tools/core-code-inspection.js +86 -0
  321. package/dist/tools/create-skill-tool.d.ts +2 -3
  322. package/dist/tools/create-skill-tool.js +16 -75
  323. package/dist/tools/cronjob-tool.d.ts +1 -0
  324. package/dist/tools/cronjob-tool.js +1 -0
  325. package/dist/tools/env-doctor-tool.d.ts +2 -0
  326. package/dist/tools/env-doctor-tool.js +4 -3
  327. package/dist/tools/execute-code-rpc-invoker.d.ts +1 -1
  328. package/dist/tools/execute-code-rpc-invoker.js +35 -19
  329. package/dist/tools/execute-code-runner.d.ts +2 -0
  330. package/dist/tools/execute-code-runner.js +52 -17
  331. package/dist/tools/fleet-room-tool.d.ts +104 -0
  332. package/dist/tools/fleet-room-tool.js +124 -0
  333. package/dist/tools/integration-tool-hints.d.ts +4 -0
  334. package/dist/tools/integration-tool-hints.js +19 -0
  335. package/dist/tools/list-peers-tool.d.ts +3 -0
  336. package/dist/tools/list-peers-tool.js +11 -4
  337. package/dist/tools/media-generation-tool.d.ts +16 -1
  338. package/dist/tools/media-generation-tool.js +341 -9
  339. package/dist/tools/merge-conflict-tool.js +53 -25
  340. package/dist/tools/metadata.d.ts +1 -5
  341. package/dist/tools/metadata.js +21 -28
  342. package/dist/tools/ragchat-tool.d.ts +39 -0
  343. package/dist/tools/ragchat-tool.js +105 -0
  344. package/dist/tools/registry/fleet-tools.d.ts +9 -0
  345. package/dist/tools/registry/fleet-tools.js +22 -1
  346. package/dist/tools/registry/knowledge-tools.d.ts +2 -2
  347. package/dist/tools/registry/knowledge-tools.js +2 -2
  348. package/dist/tools/registry/lessons-tools.d.ts +7 -0
  349. package/dist/tools/registry/lessons-tools.js +43 -3
  350. package/dist/tools/registry/memory-tools.d.ts +1 -1
  351. package/dist/tools/registry/memory-tools.js +8 -8
  352. package/dist/tools/registry/research-tools.d.ts +1 -0
  353. package/dist/tools/registry/research-tools.js +4 -13
  354. package/dist/tools/registry/self-describe-tools.d.ts +1 -1
  355. package/dist/tools/registry/self-describe-tools.js +43 -30
  356. package/dist/tools/resource-catalog-tool.d.ts +38 -0
  357. package/dist/tools/resource-catalog-tool.js +46 -0
  358. package/dist/tools/skills-inspection-tool.js +30 -1
  359. package/dist/tools/stream-tool-output.d.ts +3 -0
  360. package/dist/tools/stream-tool-output.js +33 -0
  361. package/dist/tools/tool-call-scheduler.d.ts +10 -0
  362. package/dist/tools/tool-call-scheduler.js +58 -0
  363. package/dist/tools/tool-effect.d.ts +5 -0
  364. package/dist/tools/tool-effect.js +26 -0
  365. package/dist/tools/tool-search.d.ts +12 -11
  366. package/dist/tools/tool-search.js +67 -26
  367. package/dist/tools/types.d.ts +6 -0
  368. package/dist/ui/components/ChatHistory.d.ts +1 -1
  369. package/dist/ui/components/ChatHistory.js +2 -2
  370. package/dist/ui/components/ChatInput.d.ts +2 -1
  371. package/dist/ui/components/ChatInput.js +42 -88
  372. package/dist/ui/components/ChatInterface.d.ts +4 -2
  373. package/dist/ui/components/ChatInterface.js +27 -63
  374. package/dist/ui/components/CommandSuggestions.d.ts +0 -1
  375. package/dist/ui/components/CommandSuggestions.js +4 -6
  376. package/dist/ui/components/FileAutocomplete.js +1 -1
  377. package/dist/ui/components/KeyboardHelp.js +8 -6
  378. package/dist/ui/components/ModelSelection.js +6 -5
  379. package/dist/ui/components/StatusBar.d.ts +2 -1
  380. package/dist/ui/components/StatusBar.js +8 -7
  381. package/dist/ui/context/theme-context.js +3 -2
  382. package/dist/ui/index.d.ts +1 -1
  383. package/dist/ui/index.js +1 -1
  384. package/dist/ui/utils/markdown-renderer.js +4 -13
  385. package/dist/utils/atomic-write.d.ts +22 -0
  386. package/dist/utils/atomic-write.js +29 -0
  387. package/dist/utils/bounded-output.d.ts +16 -0
  388. package/dist/utils/bounded-output.js +63 -0
  389. package/dist/utils/device-store-file.d.ts +4 -0
  390. package/dist/utils/device-store-file.js +40 -0
  391. package/dist/utils/export-manager.d.ts +9 -0
  392. package/dist/utils/export-manager.js +19 -0
  393. package/dist/utils/first-use-hints.d.ts +25 -0
  394. package/dist/utils/first-use-hints.js +58 -0
  395. package/dist/utils/history-manager.js +1 -1
  396. package/dist/utils/update-notifier.js +16 -18
  397. package/dist/wizard/environment-detection.d.ts +5 -1
  398. package/dist/wizard/environment-detection.js +49 -7
  399. package/dist/wizard/onboarding.d.ts +5 -1
  400. package/dist/wizard/onboarding.js +90 -30
  401. package/dist/wizard/provider-onboarding.d.ts +2 -0
  402. package/dist/wizard/provider-onboarding.js +55 -17
  403. package/package.json +7 -3
@@ -134,11 +134,24 @@ export function registerSkillsCommands(program) {
134
134
  const all = hub.listWithIntegrity();
135
135
  const shown = opts.all ? all : all.filter((s) => s.enabled !== false);
136
136
  const health = buildSkillListHealth(all, shown);
137
- const usableCount = all.filter((skill) => skill.enabled !== false && skill.integrityOk).length;
137
+ const { readLocalSkillInventory } = await import('../../skills/local-inventory.js');
138
+ const inventory = await readLocalSkillInventory(all);
139
+ const availableSkills = inventory.entries.filter((skill) => skill.available);
140
+ const usableCount = availableSkills.filter((skill) => skill.source === 'hub').length;
138
141
  if (opts.json) {
139
- console.log(JSON.stringify({ count: shown.length, health, total: all.length, skills: shown }, null, 2));
142
+ console.log(JSON.stringify({ availableSkills, availableCount: availableSkills.length,
143
+ unavailableSkills: inventory.entries.filter((skill) => !skill.available),
144
+ discoveryErrors: inventory.errors,
145
+ count: shown.length, health, total: all.length, skills: shown }, null, 2));
140
146
  return;
141
147
  }
148
+ console.log(`\nAvailable local skills (${availableSkills.length}):`);
149
+ for (const skill of availableSkills) {
150
+ console.log(` + ${skill.name} (${skill.source})${skill.description ? ` — ${skill.description}` : ''}`);
151
+ }
152
+ if (inventory.errors.length > 0) {
153
+ console.log(`\n${inventory.errors.length} skill file(s) could not be loaded; use --json for details.`);
154
+ }
142
155
  if (shown.length === 0) {
143
156
  if (all.length === 0) {
144
157
  const { getBundledSkillsPath } = await import('../../skills/index.js');
@@ -280,26 +293,36 @@ export function registerSkillsCommands(program) {
280
293
  });
281
294
  skills
282
295
  .command('usage')
283
- .description('Show local usage telemetry, most-used first')
296
+ .description('Show local usage telemetry: hub invocations and view/use activity of every skill')
284
297
  .option('--json', 'output JSON')
285
298
  .action(async (opts) => {
286
299
  const { getSkillsHub } = await import('../../skills/hub.js');
300
+ const { listSkillActivity } = await import('../../skills/skill-usage-store.js');
287
301
  const summary = getSkillsHub().usageSummary();
302
+ const activity = listSkillActivity();
288
303
  if (opts.json) {
289
- console.log(JSON.stringify({ count: summary.length, skills: summary }, null, 2));
304
+ console.log(JSON.stringify({ count: summary.length, skills: summary, activityCount: activity.length, activity }, null, 2));
290
305
  return;
291
306
  }
292
- if (summary.length === 0) {
307
+ if (summary.length === 0 && activity.length === 0) {
293
308
  console.log('No skill usage recorded yet.');
294
309
  return;
295
310
  }
296
- console.log('\nSkill usage (most used first):');
297
- for (const skill of summary) {
298
- const u = skill.usage;
299
- const avg = u.averageDurationMs !== undefined ? `, avg ${Math.round(u.averageDurationMs)}ms` : '';
300
- console.log(` ${skill.name}: ${u.invocationCount} run(s), ${u.successCount} ok / ${u.failureCount} fail${avg}`);
301
- if (u.lastError)
302
- console.log(` last error: ${u.lastError}`);
311
+ if (summary.length > 0) {
312
+ console.log('\nSkill usage (most used first):');
313
+ for (const skill of summary) {
314
+ const u = skill.usage;
315
+ const avg = u.averageDurationMs !== undefined ? `, avg ${Math.round(u.averageDurationMs)}ms` : '';
316
+ console.log(` ${skill.name}: ${u.invocationCount} run(s), ${u.successCount} ok / ${u.failureCount} fail${avg}`);
317
+ if (u.lastError)
318
+ console.log(` last error: ${u.lastError}`);
319
+ }
320
+ }
321
+ if (activity.length > 0) {
322
+ console.log('\nSkill activity (most recent first):');
323
+ for (const entry of activity) {
324
+ console.log(` ${entry.skill}: ${entry.viewCount} view(s), ${entry.useCount} use(s), last ${entry.lastActivityAt}`);
325
+ }
303
326
  }
304
327
  console.log('');
305
328
  });
@@ -342,9 +342,12 @@ const devCommands = [
342
342
  {
343
343
  name: 'debug-issue',
344
344
  description: 'Help debug a code issue',
345
- prompt: `Help debug the described issue:
345
+ // A bare /debug-issue used to send "the described issue" with nothing
346
+ // described; the prompt now stands on its own with or without a symptom.
347
+ prompt: `Debug a problem in this project.
348
+ Reported symptom (empty if the user gave none): $ARGUMENTS
346
349
 
347
- 1. Gather information about the problem
350
+ 1. Gather information about the problem. Without a reported symptom, start from the working tree: git status --short, git diff for unstaged changes, git diff --cached for staged changes, then run the project's test script if one exists
348
351
  2. Analyze relevant code and logs
349
352
  3. Identify potential causes
350
353
  4. Suggest debugging steps
@@ -352,7 +355,10 @@ const devCommands = [
352
355
 
353
356
  Be systematic and thorough in your analysis.`,
354
357
  filePath: '',
355
- isBuiltin: true
358
+ isBuiltin: true,
359
+ arguments: [
360
+ { name: 'symptom', description: 'Error message or behaviour to debug (optional)', required: false }
361
+ ]
356
362
  },
357
363
  {
358
364
  name: 'refactor',
@@ -1309,6 +1315,13 @@ const agentControlCommands = [
1309
1315
  filePath: '',
1310
1316
  isBuiltin: true
1311
1317
  },
1318
+ {
1319
+ name: 'resources',
1320
+ description: 'List declared resources (RagChat, GPU, storage…) and observation freshness — read-only, no probe',
1321
+ prompt: '__RESOURCES__',
1322
+ filePath: '',
1323
+ isBuiltin: true
1324
+ },
1312
1325
  {
1313
1326
  name: 'new',
1314
1327
  description: 'Start a new conversation, optionally switching to a different model',
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * Exports types, built-in commands, and utilities for the slash command system.
5
5
  */
6
- export type { SlashCommand, SlashCommandArgument, SlashCommandResult, SlashCommandCategory, CategorizedSlashCommand } from './types.js';
6
+ export type { SlashCommand, SlashCommandArgument, SlashCommandResult, SlashCommandCategory, CategorizedSlashCommand, SlashSurface, SlashAvailability } from './types.js';
7
7
  export { builtinCommands, getCommandsByCategory } from './builtin-commands.js';
8
+ export { CHANNEL_SLASH_SURFACES, channelPlatformsFor, COWORK_TOKEN_SURFACES, COWORK_UNAVAILABLE_REASON, coworkHeadlessAllowlist, coworkUiEffectTokens, isEngineToken, resolveSlashAvailability, withAvailability, } from './surfaces.js';
9
+ export type { ChannelSlashSpec, CoworkTokenMode, SlashCommandWithAvailability } from './surfaces.js';
@@ -5,4 +5,6 @@
5
5
  */
6
6
  // Built-in commands
7
7
  export { builtinCommands, getCommandsByCategory } from './builtin-commands.js';
8
+ // Per-surface availability (single declaration for CLI, Cowork and the wiki)
9
+ export { CHANNEL_SLASH_SURFACES, channelPlatformsFor, COWORK_TOKEN_SURFACES, COWORK_UNAVAILABLE_REASON, coworkHeadlessAllowlist, coworkUiEffectTokens, isEngineToken, resolveSlashAvailability, withAvailability, } from './surfaces.js';
8
10
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Per-surface availability of slash commands (comparatif plan P4).
3
+ *
4
+ * Single declaration read by the CLI catalog, the Cowork main process (which
5
+ * derives its headless allowlist from it) and the generated slash wiki.
6
+ *
7
+ * Rules:
8
+ * - CLI: every built-in is available unless a command declares otherwise.
9
+ * - Cowork, DEFAULT-DENY for engine tokens (`__FOO__` prompts): a token is only
10
+ * pilotable from Cowork when it is declared below either as `headless` (runs
11
+ * through `executeHeadlessSlashToken` with this allowlist) or `ui_effect`
12
+ * (Cowork renders a native panel/effect). Undeclared tokens are unavailable
13
+ * with an explicit reason. Natural-language prompt commands are forwarded as
14
+ * prompts and are therefore available.
15
+ * - A command-level `surfaces` declaration can only RESTRICT a surface (hidden
16
+ * or unavailable); it never widens the Cowork token allowlist.
17
+ */
18
+ import type { SlashAvailability, SlashCommand, SlashSurface } from './types.js';
19
+ export type CoworkTokenMode = 'headless' | 'ui_effect';
20
+ /**
21
+ * Tokens Cowork can pilot. `headless` entries are safe to run from the Cowork
22
+ * main process today (read-only info or session-scoped goal state); see the
23
+ * rationale kept in cowork/src/main/commands/slash-command-bridge.ts.
24
+ */
25
+ export declare const COWORK_TOKEN_SURFACES: Readonly<Record<string, CoworkTokenMode>>;
26
+ /**
27
+ * Bot commands expected on each messaging platform (the `channels` surface).
28
+ * This is the single declaration read by `src/channels/slash-parity.ts`.
29
+ * A name that matches a builtin is the same command reached from a chat
30
+ * platform; `channelOnly` marks bot-only commands with no terminal builtin.
31
+ */
32
+ export interface ChannelSlashSpec {
33
+ name: string;
34
+ description: string;
35
+ required?: boolean;
36
+ channelOnly?: boolean;
37
+ }
38
+ export declare const CHANNEL_SLASH_SURFACES: Readonly<Record<string, readonly ChannelSlashSpec[]>>;
39
+ /** Platforms whose bot exposes this command; a `channels` restriction on the command removes it everywhere. */
40
+ export declare function channelPlatformsFor(command: Pick<SlashCommand, 'name' | 'surfaces'>): string[];
41
+ export declare const COWORK_UNAVAILABLE_REASON = "not pilotable from Cowork yet \u2014 use the terminal (buddy)";
42
+ export declare function isEngineToken(prompt: string): boolean;
43
+ /** Tokens the Cowork main process may run headlessly (derived, never hand-maintained elsewhere). */
44
+ export declare function coworkHeadlessAllowlist(): ReadonlySet<string>;
45
+ export declare function coworkUiEffectTokens(): ReadonlySet<string>;
46
+ /** Effective availability of one catalog command on one surface. */
47
+ export declare function resolveSlashAvailability(command: Pick<SlashCommand, 'name' | 'prompt' | 'surfaces'>, surface: SlashSurface): SlashAvailability;
48
+ export interface SlashCommandWithAvailability extends SlashCommand {
49
+ availability: Record<'cli' | 'cowork', SlashAvailability>;
50
+ /** Messaging platforms whose bot exposes the same command (from CHANNEL_SLASH_SURFACES). */
51
+ channelPlatforms: string[];
52
+ }
53
+ export declare function withAvailability(commands: readonly SlashCommand[]): SlashCommandWithAvailability[];
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Per-surface availability of slash commands (comparatif plan P4).
3
+ *
4
+ * Single declaration read by the CLI catalog, the Cowork main process (which
5
+ * derives its headless allowlist from it) and the generated slash wiki.
6
+ *
7
+ * Rules:
8
+ * - CLI: every built-in is available unless a command declares otherwise.
9
+ * - Cowork, DEFAULT-DENY for engine tokens (`__FOO__` prompts): a token is only
10
+ * pilotable from Cowork when it is declared below either as `headless` (runs
11
+ * through `executeHeadlessSlashToken` with this allowlist) or `ui_effect`
12
+ * (Cowork renders a native panel/effect). Undeclared tokens are unavailable
13
+ * with an explicit reason. Natural-language prompt commands are forwarded as
14
+ * prompts and are therefore available.
15
+ * - A command-level `surfaces` declaration can only RESTRICT a surface (hidden
16
+ * or unavailable); it never widens the Cowork token allowlist.
17
+ */
18
+ /**
19
+ * Tokens Cowork can pilot. `headless` entries are safe to run from the Cowork
20
+ * main process today (read-only info or session-scoped goal state); see the
21
+ * rationale kept in cowork/src/main/commands/slash-command-bridge.ts.
22
+ */
23
+ export const COWORK_TOKEN_SURFACES = Object.freeze({
24
+ // Headless (engine behaviour, default-deny allowlist)
25
+ __HELP__: 'headless',
26
+ __STATS__: 'headless',
27
+ __COST__: 'headless',
28
+ __TOOLS__: 'headless',
29
+ __WHOAMI__: 'headless',
30
+ __STATUS__: 'headless',
31
+ __FEATURES__: 'headless',
32
+ __HISTORY__: 'headless',
33
+ __LOG__: 'headless',
34
+ __WORKSPACE__: 'headless',
35
+ __DIFF__: 'headless',
36
+ __QUOTA__: 'headless',
37
+ __EXPORT_FORMATS__: 'headless',
38
+ __EXPORT_LIST__: 'headless',
39
+ __GOAL__: 'headless',
40
+ __SUBGOAL__: 'headless',
41
+ __RESOURCES__: 'headless',
42
+ // Native Cowork effects (panels, settings tabs, orchestrator, engine actions)
43
+ __CHANGE_MODEL__: 'ui_effect',
44
+ __SWITCH__: 'ui_effect',
45
+ __PLAN_MODE__: 'ui_effect',
46
+ __SWARM__: 'ui_effect',
47
+ __PARALLEL__: 'ui_effect',
48
+ __BATCH__: 'ui_effect',
49
+ __AGENTS__: 'ui_effect',
50
+ __FLEET__: 'ui_effect',
51
+ __TEAM__: 'ui_effect',
52
+ __LESSONS__: 'ui_effect',
53
+ __COMPANION__: 'ui_effect',
54
+ __TRACK__: 'ui_effect',
55
+ __CONFIG__: 'ui_effect',
56
+ __WORKFLOW__: 'ui_effect',
57
+ __PIPELINE__: 'ui_effect',
58
+ __PERMISSIONS__: 'ui_effect',
59
+ __POLICY__: 'ui_effect',
60
+ __APPROVALS__: 'ui_effect',
61
+ __ELEVATED__: 'ui_effect',
62
+ __BATCH_REVIEW__: 'ui_effect',
63
+ __SECURITY__: 'ui_effect',
64
+ __HOOKS__: 'ui_effect',
65
+ __PLUGINS__: 'ui_effect',
66
+ __PLUGIN__: 'ui_effect',
67
+ __THEME__: 'ui_effect',
68
+ __AVATAR__: 'ui_effect',
69
+ __VIM_MODE__: 'ui_effect',
70
+ __FAST_MODE__: 'ui_effect',
71
+ __DRY_RUN__: 'ui_effect',
72
+ __CACHE__: 'ui_effect',
73
+ __PROMPT_CACHE__: 'ui_effect',
74
+ __SELF_HEALING__: 'ui_effect',
75
+ __SEARCH__: 'ui_effect',
76
+ __SHORTCUTS__: 'ui_effect',
77
+ __PERSONA__: 'ui_effect',
78
+ __SESSIONS__: 'ui_effect',
79
+ __REMEMBER__: 'ui_effect',
80
+ __IDENTITY__: 'ui_effect',
81
+ __PAIRING__: 'ui_effect',
82
+ __VOICE__: 'ui_effect',
83
+ __SPEAK__: 'ui_effect',
84
+ __TTS__: 'ui_effect',
85
+ __EXPORT__: 'ui_effect',
86
+ __SAVE_CONVERSATION__: 'ui_effect',
87
+ __TEST__: 'ui_effect',
88
+ __THINK__: 'ui_effect',
89
+ __KNOWLEDGE_GRAPH__: 'ui_effect',
90
+ __UNDO__: 'ui_effect',
91
+ __REDO__: 'ui_effect',
92
+ __SUBAGENT__: 'ui_effect',
93
+ __AGENT__: 'ui_effect',
94
+ });
95
+ export const CHANNEL_SLASH_SURFACES = Object.freeze({
96
+ discord: [
97
+ { name: 'ask', description: 'Ask Code Buddy a question', channelOnly: true },
98
+ { name: 'status', description: 'Show bot and channel status' },
99
+ { name: 'clear', description: 'Clear conversation history' },
100
+ { name: 'help', description: 'Show available commands' },
101
+ { name: 'model', description: 'Switch or show current model' },
102
+ { name: 'think', description: 'Set reasoning depth', required: false },
103
+ { name: 'compact', description: 'Compact conversation context', required: false },
104
+ { name: 'repo', description: 'Show repository info', required: false, channelOnly: true },
105
+ ],
106
+ telegram: [
107
+ { name: 'ask', description: 'Ask Code Buddy a question', channelOnly: true },
108
+ { name: 'status', description: 'Show bot and channel status' },
109
+ { name: 'clear', description: 'Clear conversation history' },
110
+ { name: 'help', description: 'Show available commands' },
111
+ { name: 'model', description: 'Switch or show current model' },
112
+ { name: 'yolo', description: 'Toggle YOLO mode', required: false },
113
+ { name: 'repo', description: 'Show repository info', required: false, channelOnly: true },
114
+ { name: 'branch', description: 'Show branch info', required: false },
115
+ ],
116
+ slack: [
117
+ { name: 'ask', description: 'Ask Code Buddy a question', channelOnly: true },
118
+ { name: 'status', description: 'Show bot and channel status' },
119
+ { name: 'clear', description: 'Clear conversation history' },
120
+ { name: 'help', description: 'Show available commands' },
121
+ { name: 'model', description: 'Switch or show current model' },
122
+ { name: 'compact', description: 'Compact conversation context', required: false },
123
+ { name: 'think', description: 'Set reasoning depth', required: false },
124
+ ],
125
+ matrix: [
126
+ { name: 'ask', description: 'Ask Code Buddy a question', channelOnly: true },
127
+ { name: 'status', description: 'Show bot and channel status' },
128
+ { name: 'clear', description: 'Clear conversation history' },
129
+ { name: 'help', description: 'Show available commands' },
130
+ { name: 'model', description: 'Switch or show current model', required: false },
131
+ ],
132
+ });
133
+ /** Platforms whose bot exposes this command; a `channels` restriction on the command removes it everywhere. */
134
+ export function channelPlatformsFor(command) {
135
+ const declared = command.surfaces?.channels;
136
+ if (declared && declared.status !== 'available')
137
+ return [];
138
+ return Object.entries(CHANNEL_SLASH_SURFACES)
139
+ .filter(([, specs]) => specs.some((spec) => !spec.channelOnly && spec.name === command.name))
140
+ .map(([platform]) => platform);
141
+ }
142
+ export const COWORK_UNAVAILABLE_REASON = 'not pilotable from Cowork yet — use the terminal (buddy)';
143
+ export function isEngineToken(prompt) {
144
+ return prompt.length > 4 && prompt.startsWith('__') && prompt.endsWith('__');
145
+ }
146
+ /** Tokens the Cowork main process may run headlessly (derived, never hand-maintained elsewhere). */
147
+ export function coworkHeadlessAllowlist() {
148
+ return new Set(Object.entries(COWORK_TOKEN_SURFACES).filter(([, mode]) => mode === 'headless').map(([token]) => token));
149
+ }
150
+ export function coworkUiEffectTokens() {
151
+ return new Set(Object.entries(COWORK_TOKEN_SURFACES).filter(([, mode]) => mode === 'ui_effect').map(([token]) => token));
152
+ }
153
+ const AVAILABLE = { status: 'available' };
154
+ /** Effective availability of one catalog command on one surface. */
155
+ export function resolveSlashAvailability(command, surface) {
156
+ const declared = command.surfaces?.[surface];
157
+ const restricting = declared && declared.status !== 'available' ? declared : undefined;
158
+ if (surface === 'cowork') {
159
+ if (restricting)
160
+ return restricting;
161
+ if (!isEngineToken(command.prompt))
162
+ return AVAILABLE;
163
+ return COWORK_TOKEN_SURFACES[command.prompt] ? AVAILABLE : { status: 'unavailable', reason: COWORK_UNAVAILABLE_REASON };
164
+ }
165
+ return declared ?? AVAILABLE;
166
+ }
167
+ export function withAvailability(commands) {
168
+ return commands.map((command) => ({
169
+ ...command,
170
+ availability: {
171
+ cli: resolveSlashAvailability(command, 'cli'),
172
+ cowork: resolveSlashAvailability(command, 'cowork'),
173
+ },
174
+ channelPlatforms: channelPlatformsFor(command),
175
+ }));
176
+ }
177
+ //# sourceMappingURL=surfaces.js.map
@@ -32,7 +32,24 @@ export interface SlashCommand {
32
32
  isBuiltin: boolean;
33
33
  /** List of arguments accepted by the command. */
34
34
  arguments?: SlashCommandArgument[];
35
+ /**
36
+ * Optional per-surface restriction (P4). Resolution lives in `surfaces.ts`;
37
+ * a declaration can hide or disable a command on a surface, never widen the
38
+ * Cowork default-deny token allowlist.
39
+ */
40
+ surfaces?: Partial<Record<SlashSurface, SlashAvailability>>;
35
41
  }
42
+ /** Surfaces that expose slash commands. */
43
+ export type SlashSurface = 'cli' | 'cowork' | 'channels';
44
+ /** Availability of a command on a surface. */
45
+ export type SlashAvailability = {
46
+ status: 'available';
47
+ } | {
48
+ status: 'hidden';
49
+ } | {
50
+ status: 'unavailable';
51
+ reason: string;
52
+ };
36
53
  /**
37
54
  * Result of executing or parsing a slash command.
38
55
  */
@@ -54,7 +54,7 @@ export interface RunTryDemoOptions extends ResolveTryProviderOptions {
54
54
  export interface TryCommandDependencies {
55
55
  runTryDemo?: (options: RunTryDemoOptions) => Promise<number>;
56
56
  }
57
- export declare const TRY_DEMO_PROMPT = "You are driving a short coding-agent demo in an empty temporary folder.\n\nExact goal:\n1. Create fizzbuzz.js in CommonJS. Export a function fizzBuzz(value) that returns the number as a string, \"Fizz\" for multiples of 3, \"Buzz\" for multiples of 5, and \"FizzBuzz\" for multiples of 15.\n2. Create fizzbuzz.test.js using node:test and node:assert/strict. Test at least 1, 3, 5, and 15.\n3. Run exactly: node --test fizzbuzz.test.js\n4. If a test fails, fix the code and run it again.\n5. Finish with a very short summary naming the two files you created and the test result.\n\nWrite everything in English. Use the file and terminal tools directly. Do not ask for any confirmation, do not install any dependency, and do not change anything outside the working folder.";
57
+ export declare const TRY_DEMO_PROMPT = "You are driving a short coding-agent demo in an empty temporary folder.\n\nExact goal:\n1. Create fizzbuzz.js in CommonJS. Export a function fizzBuzz(value) that returns the number as a string, \"Fizz\" for multiples of 3, \"Buzz\" for multiples of 5, and \"FizzBuzz\" for multiples of 15.\n2. Create fizzbuzz.test.js using node:test and node:assert/strict. Test at least 1, 3, 5, and 15.\n3. Run exactly: node --test fizzbuzz.test.js\n4. If a test fails, fix the code and run it again.\n5. Finish with a very short summary naming the two files you created and the test result.\n\nWrite everything in English. Use the file and terminal tools with the configured permissions. Work only inside the temporary folder; no dependency installation is needed.";
58
58
  export declare const NO_TRY_PROVIDER_MESSAGE: string;
59
59
  /** Pick a coding-oriented local model without assuming one exact Ollama tag. */
60
60
  export declare function chooseOllamaModel(models: readonly string[], requested?: string): string | null;
@@ -24,7 +24,7 @@ Exact goal:
24
24
  4. If a test fails, fix the code and run it again.
25
25
  5. Finish with a very short summary naming the two files you created and the test result.
26
26
 
27
- Write everything in English. Use the file and terminal tools directly. Do not ask for any confirmation, do not install any dependency, and do not change anything outside the working folder.`;
27
+ Write everything in English. Use the file and terminal tools with the configured permissions. Work only inside the temporary folder; no dependency installation is needed.`;
28
28
  export const NO_TRY_PROVIDER_MESSAGE = [
29
29
  'No free provider is ready for the demo.',
30
30
  '',
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Companion identity resolution.
3
+ *
4
+ * Resolves who is speaking to Lisa across Telegram, PWA mobile WebSocket,
5
+ * and physical voice presence, and assigns a trust level:
6
+ * - 'owner': Full trust. Identified via Telegram allowlist/chat or PWA JWT.
7
+ * - 'present': Physical presence detected and robot named. Lower trust.
8
+ * - 'guest': Unknown / unauthenticated speaker. Fail-closed: ZERO tools.
9
+ *
10
+ * @module companion/companion-identity
11
+ */
12
+ export type CompanionIdentityRole = 'owner' | 'present' | 'guest';
13
+ export type CompanionIdentityConfidence = 'high' | 'medium' | 'none';
14
+ export interface CompanionIdentity {
15
+ role: CompanionIdentityRole;
16
+ channel: 'telegram' | 'pwa' | 'voice' | 'channel' | 'unknown';
17
+ userId?: string;
18
+ chatId?: string;
19
+ confidence: CompanionIdentityConfidence;
20
+ reason: string;
21
+ }
22
+ export interface ResolveIdentityOptions {
23
+ channel: 'telegram' | 'pwa' | 'mobile' | 'voice' | 'channel' | string;
24
+ userId?: string;
25
+ chatId?: string;
26
+ senderId?: string;
27
+ senderUsername?: string;
28
+ allowedUsers?: readonly string[];
29
+ isVoicePresence?: boolean;
30
+ robotNamed?: boolean;
31
+ env?: NodeJS.ProcessEnv;
32
+ }
33
+ /**
34
+ * Resolve identity and confidence tier from incoming channel information.
35
+ * Pure function: takes options and env, zero global side-effects.
36
+ */
37
+ export declare function resolveCompanionIdentity(options: ResolveIdentityOptions): CompanionIdentity;
38
+ /** Check if identity is owner */
39
+ export declare function isCompanionOwner(identity?: CompanionIdentity | null): boolean;
40
+ /** Check if identity is at least present (owner or present) */
41
+ export declare function isCompanionPresentOrOwner(identity?: CompanionIdentity | null): boolean;
42
+ /** Default guest identity (fail-closed) */
43
+ export declare const DEFAULT_GUEST_IDENTITY: CompanionIdentity;
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Companion identity resolution.
3
+ *
4
+ * Resolves who is speaking to Lisa across Telegram, PWA mobile WebSocket,
5
+ * and physical voice presence, and assigns a trust level:
6
+ * - 'owner': Full trust. Identified via Telegram allowlist/chat or PWA JWT.
7
+ * - 'present': Physical presence detected and robot named. Lower trust.
8
+ * - 'guest': Unknown / unauthenticated speaker. Fail-closed: ZERO tools.
9
+ *
10
+ * @module companion/companion-identity
11
+ */
12
+ /**
13
+ * Resolve identity and confidence tier from incoming channel information.
14
+ * Pure function: takes options and env, zero global side-effects.
15
+ */
16
+ export function resolveCompanionIdentity(options) {
17
+ const env = options.env ?? process.env;
18
+ const channelRaw = (options.channel || '').toLowerCase().trim();
19
+ // 1. Telegram
20
+ if (channelRaw === 'telegram') {
21
+ const alertChat = (env.CODEBUDDY_SENSORY_ALERT_CHAT ?? '').trim();
22
+ const allowed = new Set((options.allowedUsers ?? []).map((u) => u.trim().toLowerCase()));
23
+ const chatId = (options.chatId ?? '').trim();
24
+ const senderId = (options.senderId ?? options.userId ?? '').trim();
25
+ const rawUsername = (options.senderUsername ?? '').trim().toLowerCase();
26
+ const senderUsername = rawUsername.replace(/^@/, '');
27
+ const isChatAlertMatch = Boolean(alertChat && chatId && chatId === alertChat);
28
+ const isChatAllowedMatch = Boolean(chatId && allowed.has(chatId.toLowerCase()));
29
+ const isSenderIdMatch = Boolean(senderId && allowed.has(senderId.toLowerCase()));
30
+ const isUsernameMatch = Boolean(senderUsername && (allowed.has(senderUsername) || allowed.has(`@${senderUsername}`)));
31
+ if (isChatAlertMatch || isChatAllowedMatch || isSenderIdMatch || isUsernameMatch) {
32
+ return {
33
+ role: 'owner',
34
+ channel: 'telegram',
35
+ ...(senderId ? { userId: senderId } : {}),
36
+ ...(chatId ? { chatId } : {}),
37
+ confidence: 'high',
38
+ reason: isChatAlertMatch
39
+ ? 'telegram_sensory_alert_chat_match'
40
+ : isChatAllowedMatch
41
+ ? 'telegram_chat_id_allowed'
42
+ : isSenderIdMatch
43
+ ? 'telegram_sender_id_allowed'
44
+ : 'telegram_username_allowed',
45
+ };
46
+ }
47
+ return {
48
+ role: 'guest',
49
+ channel: 'telegram',
50
+ ...(chatId ? { chatId } : {}),
51
+ confidence: 'none',
52
+ reason: 'telegram_unauthorized_sender',
53
+ };
54
+ }
55
+ // 2. PWA (Mobile / Web)
56
+ if (channelRaw === 'pwa' || channelRaw === 'mobile') {
57
+ const userId = (options.userId ?? options.senderId ?? '').trim();
58
+ if (!userId) {
59
+ return {
60
+ role: 'guest',
61
+ channel: 'pwa',
62
+ confidence: 'none',
63
+ reason: 'pwa_missing_jwt_user_id',
64
+ };
65
+ }
66
+ const ownerUserId = (env.CODEBUDDY_OWNER_USER_ID ?? '').trim();
67
+ if (ownerUserId) {
68
+ if (userId === ownerUserId) {
69
+ return {
70
+ role: 'owner',
71
+ channel: 'pwa',
72
+ userId,
73
+ confidence: 'high',
74
+ reason: 'pwa_jwt_owner_matched',
75
+ };
76
+ }
77
+ return {
78
+ role: 'guest',
79
+ channel: 'pwa',
80
+ userId,
81
+ confidence: 'none',
82
+ reason: 'pwa_jwt_user_not_owner',
83
+ };
84
+ }
85
+ // Default when CODEBUDDY_OWNER_USER_ID is not set:
86
+ // Any valid JWT issued and verified by this daemon is recognized as owner.
87
+ // In a single-user self-hosted installation, only the owner holds the login credentials.
88
+ return {
89
+ role: 'owner',
90
+ channel: 'pwa',
91
+ userId,
92
+ confidence: 'high',
93
+ reason: 'pwa_jwt_valid_server_token_default_owner',
94
+ };
95
+ }
96
+ // 3. Voice
97
+ if (channelRaw === 'voice') {
98
+ if (options.isVoicePresence === true && options.robotNamed === true) {
99
+ return {
100
+ role: 'present',
101
+ channel: 'voice',
102
+ confidence: 'medium',
103
+ reason: 'voice_presence_and_robot_named',
104
+ };
105
+ }
106
+ return {
107
+ role: 'guest',
108
+ channel: 'voice',
109
+ confidence: 'none',
110
+ reason: 'voice_unauthenticated_or_unnamed',
111
+ };
112
+ }
113
+ // 4. Default / unknown channel -> fail closed
114
+ return {
115
+ role: 'guest',
116
+ channel: 'unknown',
117
+ confidence: 'none',
118
+ reason: 'unknown_channel_fail_closed',
119
+ };
120
+ }
121
+ /** Check if identity is owner */
122
+ export function isCompanionOwner(identity) {
123
+ return identity?.role === 'owner';
124
+ }
125
+ /** Check if identity is at least present (owner or present) */
126
+ export function isCompanionPresentOrOwner(identity) {
127
+ return identity?.role === 'owner' || identity?.role === 'present';
128
+ }
129
+ /** Default guest identity (fail-closed) */
130
+ export const DEFAULT_GUEST_IDENTITY = Object.freeze({
131
+ role: 'guest',
132
+ channel: 'unknown',
133
+ confidence: 'none',
134
+ reason: 'default_guest_fail_closed',
135
+ });
136
+ //# sourceMappingURL=companion-identity.js.map
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Companion Toolset definition, authorization and execution gates.
3
+ *
4
+ * Defines which tools Lisa can use based on the interlocutor's identity tier:
5
+ * - 'owner': image_generate, image_edit, remind, web_search, weather, stock_quote,
6
+ * understand_video, camera_analyze, recall.
7
+ * - 'present': same tools WITHOUT remind and WITHOUT camera (camera_analyze).
8
+ * - 'guest': NO tools (fail-closed, byte-identical to historical turn).
9
+ *
10
+ * Hard security invariants:
11
+ * - NEVER bash, shell_exec, file writing (create_file, edit, patch), MCP, fleet tools.
12
+ * - Circuit-breaker: CODEBUDDY_COMPANION_TOOLS_ENABLED (default: false -> 0 tools).
13
+ * - Surcharge: CODEBUDDY_COMPANION_TOOLS (csv list, filtered against hard constraints).
14
+ *
15
+ * @module companion/companion-toolset
16
+ */
17
+ import type { CodeBuddyTool } from '../codebuddy/client.js';
18
+ import type { ToolResult } from '../types/index.js';
19
+ import { ConfirmationService } from '../utils/confirmation-service.js';
20
+ import { FormalToolRegistry } from '../tools/registry/tool-registry.js';
21
+ import type { CompanionIdentity } from './companion-identity.js';
22
+ export declare const OWNER_COMPANION_TOOLS: readonly string[];
23
+ export declare const PRESENT_COMPANION_TOOLS: readonly string[];
24
+ export declare const GUEST_COMPANION_TOOLS: readonly string[];
25
+ /** Strictly forbidden tool patterns that can NEVER be exposed to companion */
26
+ export declare const COMPANION_FORBIDDEN_PATTERNS: readonly (string | RegExp)[];
27
+ /**
28
+ * Check if a tool is strictly forbidden for the companion.
29
+ */
30
+ export declare function isForbiddenCompanionTool(toolName: string): boolean;
31
+ /**
32
+ * Check if companion tools are enabled via circuit-breaker.
33
+ * Default is FALSE (OFF).
34
+ */
35
+ export declare function isCompanionToolsEnabled(env?: NodeJS.ProcessEnv): boolean;
36
+ /**
37
+ * Resolve allowed tool names for a given identity and environment.
38
+ */
39
+ export declare function getCompanionToolNames(identity: CompanionIdentity, env?: NodeJS.ProcessEnv): string[];
40
+ /**
41
+ * Human-friendly waiting phrase when a slow tool starts executing.
42
+ */
43
+ export declare function getCompanionToolWaitingWord(toolName: string): string | null;
44
+ /**
45
+ * Get OpenAI-compatible function tool definitions for allowed companion tools.
46
+ */
47
+ export declare function getCompanionToolDefinitions(identity: CompanionIdentity, options?: {
48
+ env?: NodeJS.ProcessEnv;
49
+ registry?: FormalToolRegistry;
50
+ }): Promise<CodeBuddyTool[]>;
51
+ export interface CompanionToolExecutionContext {
52
+ identity: CompanionIdentity;
53
+ env?: NodeJS.ProcessEnv;
54
+ cwd?: string;
55
+ signal?: AbortSignal;
56
+ registry?: FormalToolRegistry;
57
+ confirmationService?: ConfirmationService;
58
+ }
59
+ /**
60
+ * Safely execute a companion tool call.
61
+ */
62
+ export declare function executeCompanionTool(toolName: string, args: Record<string, unknown>, context: CompanionToolExecutionContext): Promise<ToolResult>;
63
+ /**
64
+ * Extract image path from tool execution result if one was created/returned.
65
+ */
66
+ export declare function extractImagePathFromToolResult(result: ToolResult, cwd?: string): string | undefined;