hyacinth-ai 0.9.6

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 (704) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +205 -0
  3. package/commands.json +25 -0
  4. package/dist/agents/builtins.d.ts +8 -0
  5. package/dist/agents/builtins.js +50 -0
  6. package/dist/agents/config-loader.d.ts +15 -0
  7. package/dist/agents/config-loader.js +75 -0
  8. package/dist/agents/delegate-tool.d.ts +109 -0
  9. package/dist/agents/delegate-tool.js +407 -0
  10. package/dist/agents/index.d.ts +5 -0
  11. package/dist/agents/index.js +5 -0
  12. package/dist/agents/registry.d.ts +2 -0
  13. package/dist/agents/registry.js +2 -0
  14. package/dist/bypass/agents/companion/index.d.ts +57 -0
  15. package/dist/bypass/agents/companion/index.js +487 -0
  16. package/dist/bypass/agents/orchestrator/index.d.ts +17 -0
  17. package/dist/bypass/agents/orchestrator/index.js +414 -0
  18. package/dist/bypass/agents/orchestrator.d.ts +16 -0
  19. package/dist/bypass/agents/orchestrator.js +377 -0
  20. package/dist/bypass/agents/world-engine/agent.d.ts +41 -0
  21. package/dist/bypass/agents/world-engine/agent.js +385 -0
  22. package/dist/bypass/agents/world-engine/index.d.ts +52 -0
  23. package/dist/bypass/agents/world-engine/index.js +198 -0
  24. package/dist/bypass/agents/world-engine/sim.d.ts +14 -0
  25. package/dist/bypass/agents/world-engine/sim.js +120 -0
  26. package/dist/bypass/agents/world-engine/store.d.ts +110 -0
  27. package/dist/bypass/agents/world-engine/store.js +519 -0
  28. package/dist/bypass/agents/world-engine/ticker.d.ts +37 -0
  29. package/dist/bypass/agents/world-engine/ticker.js +214 -0
  30. package/dist/bypass/agents/world-engine/tools.d.ts +6 -0
  31. package/dist/bypass/agents/world-engine/tools.js +380 -0
  32. package/dist/bypass/agents/world-engine/types.d.ts +202 -0
  33. package/dist/bypass/agents/world-engine/types.js +56 -0
  34. package/dist/bypass/agents/world-engine.d.ts +20 -0
  35. package/dist/bypass/agents/world-engine.js +63 -0
  36. package/dist/bypass/base.d.ts +48 -0
  37. package/dist/bypass/base.js +126 -0
  38. package/dist/bypass/index.d.ts +5 -0
  39. package/dist/bypass/index.js +6 -0
  40. package/dist/bypass/manager.d.ts +41 -0
  41. package/dist/bypass/manager.js +179 -0
  42. package/dist/bypass/types.d.ts +63 -0
  43. package/dist/bypass/types.js +14 -0
  44. package/dist/channels/auto-detect.d.ts +25 -0
  45. package/dist/channels/auto-detect.js +77 -0
  46. package/dist/channels/builtin/http-webhook.d.ts +25 -0
  47. package/dist/channels/builtin/http-webhook.js +287 -0
  48. package/dist/channels/builtin/tui-channel.d.ts +33 -0
  49. package/dist/channels/builtin/tui-channel.js +61 -0
  50. package/dist/channels/builtin/tui-ws-session.d.ts +16 -0
  51. package/dist/channels/builtin/tui-ws-session.js +90 -0
  52. package/dist/channels/builtin/webui-output-handler.d.ts +30 -0
  53. package/dist/channels/builtin/webui-output-handler.js +93 -0
  54. package/dist/channels/index.d.ts +5 -0
  55. package/dist/channels/index.js +3 -0
  56. package/dist/channels/interface.d.ts +148 -0
  57. package/dist/channels/interface.js +15 -0
  58. package/dist/channels/manager.d.ts +43 -0
  59. package/dist/channels/manager.js +156 -0
  60. package/dist/channels/message-queue.d.ts +36 -0
  61. package/dist/channels/message-queue.js +91 -0
  62. package/dist/channels/plugins/clawbot/clawbot-auth.d.ts +50 -0
  63. package/dist/channels/plugins/clawbot/clawbot-auth.js +235 -0
  64. package/dist/channels/plugins/clawbot/clawbot-channel.d.ts +76 -0
  65. package/dist/channels/plugins/clawbot/clawbot-channel.js +566 -0
  66. package/dist/channels/plugins/clawbot/clawbot-client.d.ts +180 -0
  67. package/dist/channels/plugins/clawbot/clawbot-client.js +312 -0
  68. package/dist/channels/plugins/clawbot/clawbot-config.d.ts +30 -0
  69. package/dist/channels/plugins/clawbot/clawbot-config.js +28 -0
  70. package/dist/channels/plugins/clawbot/clawbot-message-queue.d.ts +27 -0
  71. package/dist/channels/plugins/clawbot/clawbot-message-queue.js +114 -0
  72. package/dist/channels/plugins/clawbot/clawbot-session.d.ts +10 -0
  73. package/dist/channels/plugins/clawbot/clawbot-session.js +26 -0
  74. package/dist/channels/plugins/clawbot/index.d.ts +17 -0
  75. package/dist/channels/plugins/clawbot/index.js +58 -0
  76. package/dist/channels/plugins/feishu/feishu-channel.d.ts +57 -0
  77. package/dist/channels/plugins/feishu/feishu-channel.js +602 -0
  78. package/dist/channels/plugins/feishu/feishu-client.d.ts +23 -0
  79. package/dist/channels/plugins/feishu/feishu-client.js +86 -0
  80. package/dist/channels/plugins/feishu/feishu-config.d.ts +53 -0
  81. package/dist/channels/plugins/feishu/feishu-config.js +35 -0
  82. package/dist/channels/plugins/feishu/feishu-event.d.ts +102 -0
  83. package/dist/channels/plugins/feishu/feishu-event.js +257 -0
  84. package/dist/channels/plugins/feishu/feishu-log-suppressor.d.ts +7 -0
  85. package/dist/channels/plugins/feishu/feishu-log-suppressor.js +34 -0
  86. package/dist/channels/plugins/feishu/feishu-message-queue.d.ts +27 -0
  87. package/dist/channels/plugins/feishu/feishu-message-queue.js +112 -0
  88. package/dist/channels/plugins/feishu/feishu-send.d.ts +44 -0
  89. package/dist/channels/plugins/feishu/feishu-send.js +232 -0
  90. package/dist/channels/plugins/feishu/feishu-session.d.ts +44 -0
  91. package/dist/channels/plugins/feishu/feishu-session.js +84 -0
  92. package/dist/channels/plugins/feishu/feishu-streaming.d.ts +49 -0
  93. package/dist/channels/plugins/feishu/feishu-streaming.js +185 -0
  94. package/dist/channels/plugins/feishu/feishu-transport.d.ts +29 -0
  95. package/dist/channels/plugins/feishu/feishu-transport.js +99 -0
  96. package/dist/channels/plugins/feishu/index.d.ts +22 -0
  97. package/dist/channels/plugins/feishu/index.js +68 -0
  98. package/dist/cli/doctor.d.ts +20 -0
  99. package/dist/cli/doctor.js +317 -0
  100. package/dist/context/cache-strategy.d.ts +76 -0
  101. package/dist/context/cache-strategy.js +123 -0
  102. package/dist/context/composer.d.ts +77 -0
  103. package/dist/context/composer.js +318 -0
  104. package/dist/context/compressor.d.ts +218 -0
  105. package/dist/context/compressor.js +909 -0
  106. package/dist/context/index.d.ts +14 -0
  107. package/dist/context/index.js +8 -0
  108. package/dist/context/interface.d.ts +33 -0
  109. package/dist/context/interface.js +2 -0
  110. package/dist/context/manifest-defaults.d.ts +51 -0
  111. package/dist/context/manifest-defaults.js +133 -0
  112. package/dist/context/manifest-loader.d.ts +16 -0
  113. package/dist/context/manifest-loader.js +103 -0
  114. package/dist/context/manifest-types.d.ts +26 -0
  115. package/dist/context/manifest-types.js +2 -0
  116. package/dist/context/precision/analyzer.d.ts +31 -0
  117. package/dist/context/precision/analyzer.js +131 -0
  118. package/dist/context/precision/companion.d.ts +27 -0
  119. package/dist/context/precision/companion.js +144 -0
  120. package/dist/context/precision/default.d.ts +14 -0
  121. package/dist/context/precision/default.js +17 -0
  122. package/dist/context/precision/index.d.ts +9 -0
  123. package/dist/context/precision/index.js +7 -0
  124. package/dist/context/precision/keyword-pool.d.ts +27 -0
  125. package/dist/context/precision/keyword-pool.js +66 -0
  126. package/dist/context/precision/strategy.d.ts +18 -0
  127. package/dist/context/precision/strategy.js +51 -0
  128. package/dist/context/precision/summary-store.d.ts +18 -0
  129. package/dist/context/precision/summary-store.js +67 -0
  130. package/dist/context/precision/types.d.ts +23 -0
  131. package/dist/context/precision/types.js +2 -0
  132. package/dist/context/profiles.d.ts +45 -0
  133. package/dist/context/profiles.js +92 -0
  134. package/dist/context/prompt-builder.d.ts +76 -0
  135. package/dist/context/prompt-builder.js +133 -0
  136. package/dist/context/retriever.d.ts +44 -0
  137. package/dist/context/retriever.js +203 -0
  138. package/dist/context/router.d.ts +122 -0
  139. package/dist/context/router.js +291 -0
  140. package/dist/context/section-resolver.d.ts +38 -0
  141. package/dist/context/section-resolver.js +398 -0
  142. package/dist/context/tokenizer.d.ts +23 -0
  143. package/dist/context/tokenizer.js +78 -0
  144. package/dist/dependency/analyzer.d.ts +33 -0
  145. package/dist/dependency/analyzer.js +242 -0
  146. package/dist/dependency/data-flow-tracker.d.ts +12 -0
  147. package/dist/dependency/data-flow-tracker.js +97 -0
  148. package/dist/dependency/function-parser.d.ts +34 -0
  149. package/dist/dependency/function-parser.js +295 -0
  150. package/dist/dependency/index.d.ts +14 -0
  151. package/dist/dependency/index.js +20 -0
  152. package/dist/dependency/parser.d.ts +10 -0
  153. package/dist/dependency/parser.js +93 -0
  154. package/dist/dependency/types.d.ts +57 -0
  155. package/dist/dependency/types.js +2 -0
  156. package/dist/env/env-collector.d.ts +45 -0
  157. package/dist/env/env-collector.js +221 -0
  158. package/dist/env/index.d.ts +3 -0
  159. package/dist/env/index.js +2 -0
  160. package/dist/event-store.d.ts +27 -0
  161. package/dist/event-store.js +71 -0
  162. package/dist/evolution/git-manager.d.ts +46 -0
  163. package/dist/evolution/git-manager.js +276 -0
  164. package/dist/evolution/index.d.ts +3 -0
  165. package/dist/evolution/index.js +2 -0
  166. package/dist/flow/bootstrap-flow.d.ts +19 -0
  167. package/dist/flow/bootstrap-flow.js +72 -0
  168. package/dist/flow/flow-registry.d.ts +12 -0
  169. package/dist/flow/flow-registry.js +74 -0
  170. package/dist/flow/flow-tools.d.ts +8 -0
  171. package/dist/flow/flow-tools.js +106 -0
  172. package/dist/flow/index.d.ts +6 -0
  173. package/dist/flow/index.js +8 -0
  174. package/dist/flow/todo-flow.d.ts +25 -0
  175. package/dist/flow/todo-flow.js +107 -0
  176. package/dist/flow/types.d.ts +78 -0
  177. package/dist/flow/types.js +12 -0
  178. package/dist/flows/bootstrap.d.ts +18 -0
  179. package/dist/flows/bootstrap.js +119 -0
  180. package/dist/flows/index.d.ts +6 -0
  181. package/dist/flows/index.js +11 -0
  182. package/dist/flows/todo.d.ts +26 -0
  183. package/dist/flows/todo.js +174 -0
  184. package/dist/flows/tools.d.ts +8 -0
  185. package/dist/flows/tools.js +119 -0
  186. package/dist/flows/types.d.ts +27 -0
  187. package/dist/flows/types.js +10 -0
  188. package/dist/gateway/cli.d.ts +5 -0
  189. package/dist/gateway/cli.js +1027 -0
  190. package/dist/gateway/factory.d.ts +80 -0
  191. package/dist/gateway/factory.js +832 -0
  192. package/dist/gateway/guardian.d.ts +8 -0
  193. package/dist/gateway/guardian.js +30 -0
  194. package/dist/gateway/index.d.ts +3 -0
  195. package/dist/gateway/index.js +3 -0
  196. package/dist/gateway/server.d.ts +17 -0
  197. package/dist/gateway/server.js +96 -0
  198. package/dist/gateway/tui.d.ts +16 -0
  199. package/dist/gateway/tui.js +3273 -0
  200. package/dist/hot-reload/agent-watcher.d.ts +24 -0
  201. package/dist/hot-reload/agent-watcher.js +175 -0
  202. package/dist/hot-reload/bundle-watcher.d.ts +12 -0
  203. package/dist/hot-reload/bundle-watcher.js +35 -0
  204. package/dist/hot-reload/channel-watcher.d.ts +19 -0
  205. package/dist/hot-reload/channel-watcher.js +54 -0
  206. package/dist/hot-reload/command-watcher.d.ts +14 -0
  207. package/dist/hot-reload/command-watcher.js +54 -0
  208. package/dist/hot-reload/config-watcher.d.ts +20 -0
  209. package/dist/hot-reload/config-watcher.js +58 -0
  210. package/dist/hot-reload/index.d.ts +12 -0
  211. package/dist/hot-reload/index.js +12 -0
  212. package/dist/hot-reload/manager.d.ts +58 -0
  213. package/dist/hot-reload/manager.js +243 -0
  214. package/dist/hot-reload/manifest-watcher.d.ts +9 -0
  215. package/dist/hot-reload/manifest-watcher.js +42 -0
  216. package/dist/hot-reload/mcp-watcher.d.ts +18 -0
  217. package/dist/hot-reload/mcp-watcher.js +64 -0
  218. package/dist/hot-reload/model-catalog-watcher.d.ts +18 -0
  219. package/dist/hot-reload/model-catalog-watcher.js +62 -0
  220. package/dist/hot-reload/plugin-watcher.d.ts +20 -0
  221. package/dist/hot-reload/plugin-watcher.js +56 -0
  222. package/dist/hot-reload/prompt-watcher.d.ts +6 -0
  223. package/dist/hot-reload/prompt-watcher.js +38 -0
  224. package/dist/hot-reload/provider-watcher.d.ts +16 -0
  225. package/dist/hot-reload/provider-watcher.js +45 -0
  226. package/dist/hot-reload/skill-watcher.d.ts +19 -0
  227. package/dist/hot-reload/skill-watcher.js +82 -0
  228. package/dist/hot-reload/tool-watcher.d.ts +16 -0
  229. package/dist/hot-reload/tool-watcher.js +168 -0
  230. package/dist/hot-reload/workflow-watcher.d.ts +19 -0
  231. package/dist/hot-reload/workflow-watcher.js +84 -0
  232. package/dist/index.d.ts +3 -0
  233. package/dist/index.js +6 -0
  234. package/dist/knowledge/fts5-retriever.d.ts +30 -0
  235. package/dist/knowledge/fts5-retriever.js +223 -0
  236. package/dist/knowledge/index.d.ts +11 -0
  237. package/dist/knowledge/index.js +14 -0
  238. package/dist/knowledge/indexer.d.ts +41 -0
  239. package/dist/knowledge/indexer.js +186 -0
  240. package/dist/knowledge/query-preprocessor.d.ts +13 -0
  241. package/dist/knowledge/query-preprocessor.js +63 -0
  242. package/dist/knowledge/retriever.d.ts +45 -0
  243. package/dist/knowledge/retriever.js +9 -0
  244. package/dist/knowledge/store.d.ts +27 -0
  245. package/dist/knowledge/store.js +61 -0
  246. package/dist/knowledge/structured-store.d.ts +78 -0
  247. package/dist/knowledge/structured-store.js +280 -0
  248. package/dist/knowledge/structured-tools.d.ts +12 -0
  249. package/dist/knowledge/structured-tools.js +151 -0
  250. package/dist/knowledge/tools.d.ts +20 -0
  251. package/dist/knowledge/tools.js +238 -0
  252. package/dist/knowledge/watcher.d.ts +28 -0
  253. package/dist/knowledge/watcher.js +113 -0
  254. package/dist/lifecycle/index.d.ts +12 -0
  255. package/dist/lifecycle/index.js +14 -0
  256. package/dist/lifecycle/interface.d.ts +94 -0
  257. package/dist/lifecycle/interface.js +2 -0
  258. package/dist/lifecycle/local-model.d.ts +62 -0
  259. package/dist/lifecycle/local-model.js +331 -0
  260. package/dist/lifecycle/manager.d.ts +70 -0
  261. package/dist/lifecycle/manager.js +374 -0
  262. package/dist/lifecycle/supervisor.d.ts +89 -0
  263. package/dist/lifecycle/supervisor.js +277 -0
  264. package/dist/lifecycle-integration-test.d.ts +2 -0
  265. package/dist/lifecycle-integration-test.js +72 -0
  266. package/dist/local-model/download-manager.d.ts +59 -0
  267. package/dist/local-model/download-manager.js +517 -0
  268. package/dist/local-model/index.d.ts +109 -0
  269. package/dist/local-model/index.js +233 -0
  270. package/dist/local-model/llamacpp-provider.d.ts +95 -0
  271. package/dist/local-model/llamacpp-provider.js +379 -0
  272. package/dist/local-model/model-bridge.d.ts +48 -0
  273. package/dist/local-model/model-bridge.js +256 -0
  274. package/dist/local-model/model-registry.d.ts +47 -0
  275. package/dist/local-model/model-registry.js +188 -0
  276. package/dist/local-model/types.d.ts +49 -0
  277. package/dist/local-model/types.js +2 -0
  278. package/dist/logging/index.d.ts +3 -0
  279. package/dist/logging/index.js +3 -0
  280. package/dist/logging/logger.d.ts +56 -0
  281. package/dist/logging/logger.js +94 -0
  282. package/dist/machine/flows/bootstrap.d.ts +18 -0
  283. package/dist/machine/flows/bootstrap.js +119 -0
  284. package/dist/machine/flows/index.d.ts +6 -0
  285. package/dist/machine/flows/index.js +11 -0
  286. package/dist/machine/flows/spec.d.ts +17 -0
  287. package/dist/machine/flows/spec.js +176 -0
  288. package/dist/machine/flows/todo.d.ts +26 -0
  289. package/dist/machine/flows/todo.js +175 -0
  290. package/dist/machine/flows/tools.d.ts +8 -0
  291. package/dist/machine/flows/tools.js +119 -0
  292. package/dist/machine/flows/types.d.ts +33 -0
  293. package/dist/machine/flows/types.js +10 -0
  294. package/dist/machine/index.d.ts +8 -0
  295. package/dist/machine/index.js +9 -0
  296. package/dist/machine/registry.d.ts +34 -0
  297. package/dist/machine/registry.js +98 -0
  298. package/dist/machine/runner.d.ts +41 -0
  299. package/dist/machine/runner.js +177 -0
  300. package/dist/machine/types.d.ts +121 -0
  301. package/dist/machine/types.js +9 -0
  302. package/dist/mcp/bridge.d.ts +33 -0
  303. package/dist/mcp/bridge.js +99 -0
  304. package/dist/mcp/client.d.ts +37 -0
  305. package/dist/mcp/client.js +161 -0
  306. package/dist/mcp/config.d.ts +15 -0
  307. package/dist/mcp/config.js +85 -0
  308. package/dist/mcp/index.d.ts +7 -0
  309. package/dist/mcp/index.js +7 -0
  310. package/dist/mcp/install-manager.d.ts +31 -0
  311. package/dist/mcp/install-manager.js +158 -0
  312. package/dist/mcp/lifecycle.d.ts +41 -0
  313. package/dist/mcp/lifecycle.js +175 -0
  314. package/dist/mcp/process-transport.d.ts +21 -0
  315. package/dist/mcp/process-transport.js +59 -0
  316. package/dist/mcp/side-effect.d.ts +5 -0
  317. package/dist/mcp/side-effect.js +21 -0
  318. package/dist/mcp/system.d.ts +95 -0
  319. package/dist/mcp/system.js +279 -0
  320. package/dist/memory/companion-session.d.ts +22 -0
  321. package/dist/memory/companion-session.js +77 -0
  322. package/dist/memory/compression-boundary.d.ts +20 -0
  323. package/dist/memory/compression-boundary.js +40 -0
  324. package/dist/memory/conversation.d.ts +34 -0
  325. package/dist/memory/conversation.js +107 -0
  326. package/dist/memory/events.d.ts +42 -0
  327. package/dist/memory/events.js +56 -0
  328. package/dist/memory/index.d.ts +7 -0
  329. package/dist/memory/index.js +6 -0
  330. package/dist/memory/memory-store.d.ts +11 -0
  331. package/dist/memory/memory-store.js +51 -0
  332. package/dist/memory/session-allowlist.d.ts +11 -0
  333. package/dist/memory/session-allowlist.js +50 -0
  334. package/dist/memory/session.d.ts +48 -0
  335. package/dist/memory/session.js +275 -0
  336. package/dist/memory/stats.d.ts +23 -0
  337. package/dist/memory/stats.js +59 -0
  338. package/dist/memory/summary.d.ts +7 -0
  339. package/dist/memory/summary.js +23 -0
  340. package/dist/multimodal/index.d.ts +66 -0
  341. package/dist/multimodal/index.js +210 -0
  342. package/dist/orchestrator/index.d.ts +5 -0
  343. package/dist/orchestrator/index.js +4 -0
  344. package/dist/orchestrator/loop.d.ts +331 -0
  345. package/dist/orchestrator/loop.js +2443 -0
  346. package/dist/orchestrator/plan-store.d.ts +81 -0
  347. package/dist/orchestrator/plan-store.js +167 -0
  348. package/dist/orchestrator/planner.d.ts +20 -0
  349. package/dist/orchestrator/planner.js +34 -0
  350. package/dist/parser/index.d.ts +2 -0
  351. package/dist/parser/index.js +2 -0
  352. package/dist/parser/router.d.ts +30 -0
  353. package/dist/parser/router.js +61 -0
  354. package/dist/plugins/api.d.ts +39 -0
  355. package/dist/plugins/api.js +85 -0
  356. package/dist/plugins/define.d.ts +27 -0
  357. package/dist/plugins/define.js +32 -0
  358. package/dist/plugins/index.d.ts +9 -0
  359. package/dist/plugins/index.js +5 -0
  360. package/dist/plugins/loader.d.ts +39 -0
  361. package/dist/plugins/loader.js +128 -0
  362. package/dist/plugins/manager.d.ts +61 -0
  363. package/dist/plugins/manager.js +257 -0
  364. package/dist/plugins/types.d.ts +82 -0
  365. package/dist/plugins/types.js +2 -0
  366. package/dist/prompts/agents/code-reviewer.md +16 -0
  367. package/dist/prompts/agents/security-auditor.md +17 -0
  368. package/dist/prompts/agents/test-writer.md +15 -0
  369. package/dist/prompts/attention/attention.md +12 -0
  370. package/dist/prompts/environment/environment.md +18 -0
  371. package/dist/prompts/environment/feishu.md +107 -0
  372. package/dist/prompts/flows/bootstrap-confirm.md +14 -0
  373. package/dist/prompts/flows/bootstrap-identity.md +11 -0
  374. package/dist/prompts/flows/bootstrap-soul.md +19 -0
  375. package/dist/prompts/flows/bootstrap-user.md +11 -0
  376. package/dist/prompts/flows/spec-checklist.md +27 -0
  377. package/dist/prompts/flows/spec-define.md +64 -0
  378. package/dist/prompts/flows/spec-executing-checklist.md +15 -0
  379. package/dist/prompts/flows/spec-executing-tasks.md +15 -0
  380. package/dist/prompts/flows/spec-spec.md +51 -0
  381. package/dist/prompts/flows/spec-tasks.md +32 -0
  382. package/dist/prompts/flows/todo-execution.md +7 -0
  383. package/dist/prompts/flows/todo-planning.md +18 -0
  384. package/dist/prompts/framework/architecture.md +131 -0
  385. package/dist/prompts/identity/identity.md +2 -0
  386. package/dist/prompts/loader.d.ts +24 -0
  387. package/dist/prompts/loader.js +102 -0
  388. package/dist/prompts/loader.ts +119 -0
  389. package/dist/prompts/orchestration/summary.md +14 -0
  390. package/dist/prompts/persona/BOOTSTRAP.md +5 -0
  391. package/dist/prompts/persona/IDENTITY.md +16 -0
  392. package/dist/prompts/persona/PartnerMemory.md +5 -0
  393. package/dist/prompts/persona/PartnerSoul.md +7 -0
  394. package/dist/prompts/persona/SOUL.md +30 -0
  395. package/dist/prompts/persona/USER.md +16 -0
  396. package/dist/prompts/precise/analyze.md +23 -0
  397. package/dist/prompts/precise/persona.md +18 -0
  398. package/dist/prompts/safety/coding-standards.md +5 -0
  399. package/dist/prompts/safety/safety.md +4 -0
  400. package/dist/prompts/skills/code-review.md +4 -0
  401. package/dist/prompts/skills/debug.md +7 -0
  402. package/dist/prompts/skills/framework-reference.md +131 -0
  403. package/dist/prompts/skills/refactor.md +6 -0
  404. package/dist/prompts/summary.md +22 -0
  405. package/dist/prompts/tools/framework-capabilities.md +241 -0
  406. package/dist/prompts/tools/tool-rules.md +15 -0
  407. package/dist/provider/anthropic.d.ts +62 -0
  408. package/dist/provider/anthropic.js +361 -0
  409. package/dist/provider/catalog.d.ts +58 -0
  410. package/dist/provider/catalog.js +97 -0
  411. package/dist/provider/compatible.d.ts +89 -0
  412. package/dist/provider/compatible.js +328 -0
  413. package/dist/provider/config.d.ts +23 -0
  414. package/dist/provider/config.js +158 -0
  415. package/dist/provider/deepseek.d.ts +25 -0
  416. package/dist/provider/deepseek.js +37 -0
  417. package/dist/provider/fallback.d.ts +51 -0
  418. package/dist/provider/fallback.js +113 -0
  419. package/dist/provider/gemini.d.ts +27 -0
  420. package/dist/provider/gemini.js +170 -0
  421. package/dist/provider/index.d.ts +36 -0
  422. package/dist/provider/index.js +42 -0
  423. package/dist/provider/interface.d.ts +62 -0
  424. package/dist/provider/interface.js +2 -0
  425. package/dist/provider/local-config.d.ts +37 -0
  426. package/dist/provider/local-config.js +146 -0
  427. package/dist/provider/local.d.ts +45 -0
  428. package/dist/provider/local.js +248 -0
  429. package/dist/provider/manager.d.ts +67 -0
  430. package/dist/provider/manager.js +355 -0
  431. package/dist/provider/mimo.d.ts +19 -0
  432. package/dist/provider/mimo.js +30 -0
  433. package/dist/provider/minimax.d.ts +22 -0
  434. package/dist/provider/minimax.js +33 -0
  435. package/dist/provider/model-catalog-loader.d.ts +42 -0
  436. package/dist/provider/model-catalog-loader.js +89 -0
  437. package/dist/provider/model-channel-registry.d.ts +130 -0
  438. package/dist/provider/model-channel-registry.js +488 -0
  439. package/dist/provider/model-router.d.ts +60 -0
  440. package/dist/provider/model-router.js +87 -0
  441. package/dist/provider/openai.d.ts +54 -0
  442. package/dist/provider/openai.js +274 -0
  443. package/dist/provider/qwen.d.ts +19 -0
  444. package/dist/provider/qwen.js +30 -0
  445. package/dist/provider/resilient.d.ts +46 -0
  446. package/dist/provider/resilient.js +181 -0
  447. package/dist/provider/retry.d.ts +16 -0
  448. package/dist/provider/retry.js +78 -0
  449. package/dist/provider/router.d.ts +68 -0
  450. package/dist/provider/router.js +145 -0
  451. package/dist/provider/tool-args-recovery.d.ts +36 -0
  452. package/dist/provider/tool-args-recovery.js +91 -0
  453. package/dist/provider/user-id.d.ts +13 -0
  454. package/dist/provider/user-id.js +53 -0
  455. package/dist/provider/zhipu.d.ts +19 -0
  456. package/dist/provider/zhipu.js +32 -0
  457. package/dist/registry/agent.registry.d.ts +57 -0
  458. package/dist/registry/agent.registry.js +224 -0
  459. package/dist/registry/base.d.ts +54 -0
  460. package/dist/registry/base.js +99 -0
  461. package/dist/registry/channel.registry.d.ts +53 -0
  462. package/dist/registry/channel.registry.js +87 -0
  463. package/dist/registry/index.d.ts +9 -0
  464. package/dist/registry/index.js +10 -0
  465. package/dist/registry/mcp.registry.d.ts +2 -0
  466. package/dist/registry/mcp.registry.js +2 -0
  467. package/dist/registry/plugin.registry.d.ts +33 -0
  468. package/dist/registry/plugin.registry.js +66 -0
  469. package/dist/registry/provider.registry.d.ts +51 -0
  470. package/dist/registry/provider.registry.js +104 -0
  471. package/dist/registry/skill.registry.d.ts +33 -0
  472. package/dist/registry/skill.registry.js +95 -0
  473. package/dist/registry/tool.registry.d.ts +68 -0
  474. package/dist/registry/tool.registry.js +185 -0
  475. package/dist/repair/loop-guard.d.ts +98 -0
  476. package/dist/repair/loop-guard.js +217 -0
  477. package/dist/repair/scavenge.d.ts +19 -0
  478. package/dist/repair/scavenge.js +81 -0
  479. package/dist/repair/storm.d.ts +7 -0
  480. package/dist/repair/storm.js +7 -0
  481. package/dist/rollback/index.d.ts +5 -0
  482. package/dist/rollback/index.js +4 -0
  483. package/dist/rollback/rollback-tool.d.ts +13 -0
  484. package/dist/rollback/rollback-tool.js +167 -0
  485. package/dist/rollback/turn-recorder.d.ts +37 -0
  486. package/dist/rollback/turn-recorder.js +183 -0
  487. package/dist/rollback/turn-store.d.ts +29 -0
  488. package/dist/rollback/turn-store.js +114 -0
  489. package/dist/rollback/types.d.ts +51 -0
  490. package/dist/rollback/types.js +9 -0
  491. package/dist/runtime/config-center.d.ts +92 -0
  492. package/dist/runtime/config-center.js +467 -0
  493. package/dist/runtime/config-schema.d.ts +201 -0
  494. package/dist/runtime/config-schema.js +2 -0
  495. package/dist/runtime/defaults.d.ts +3 -0
  496. package/dist/runtime/defaults.js +146 -0
  497. package/dist/schedule/cron.d.ts +24 -0
  498. package/dist/schedule/cron.js +145 -0
  499. package/dist/schedule/index.d.ts +6 -0
  500. package/dist/schedule/index.js +4 -0
  501. package/dist/schedule/persistence.d.ts +33 -0
  502. package/dist/schedule/persistence.js +106 -0
  503. package/dist/schedule/scheduler.d.ts +85 -0
  504. package/dist/schedule/scheduler.js +630 -0
  505. package/dist/schedule/types.d.ts +185 -0
  506. package/dist/schedule/types.js +2 -0
  507. package/dist/setup/config.d.ts +189 -0
  508. package/dist/setup/config.js +253 -0
  509. package/dist/setup/index.d.ts +3 -0
  510. package/dist/setup/index.js +3 -0
  511. package/dist/setup/model-defaults.d.ts +13 -0
  512. package/dist/setup/model-defaults.js +87 -0
  513. package/dist/setup/persona-bootstrap.d.ts +42 -0
  514. package/dist/setup/persona-bootstrap.js +379 -0
  515. package/dist/setup/wizard.d.ts +32 -0
  516. package/dist/setup/wizard.js +384 -0
  517. package/dist/skills/index.d.ts +4 -0
  518. package/dist/skills/index.js +4 -0
  519. package/dist/skills/loader.d.ts +12 -0
  520. package/dist/skills/loader.js +83 -0
  521. package/dist/skills/registry.d.ts +2 -0
  522. package/dist/skills/registry.js +2 -0
  523. package/dist/skills/skill-tool.d.ts +20 -0
  524. package/dist/skills/skill-tool.js +49 -0
  525. package/dist/tools/archive.d.ts +17 -0
  526. package/dist/tools/archive.js +131 -0
  527. package/dist/tools/ask-user.d.ts +9 -0
  528. package/dist/tools/ask-user.js +62 -0
  529. package/dist/tools/background-registry.d.ts +45 -0
  530. package/dist/tools/background-registry.js +164 -0
  531. package/dist/tools/bash.d.ts +56 -0
  532. package/dist/tools/bash.js +391 -0
  533. package/dist/tools/bundle-registry.d.ts +42 -0
  534. package/dist/tools/bundle-registry.js +239 -0
  535. package/dist/tools/bundle-tools.d.ts +11 -0
  536. package/dist/tools/bundle-tools.js +168 -0
  537. package/dist/tools/channel-info.d.ts +5 -0
  538. package/dist/tools/channel-info.js +38 -0
  539. package/dist/tools/compression.d.ts +7 -0
  540. package/dist/tools/compression.js +21 -0
  541. package/dist/tools/config.d.ts +23 -0
  542. package/dist/tools/config.js +255 -0
  543. package/dist/tools/db-query.d.ts +12 -0
  544. package/dist/tools/db-query.js +107 -0
  545. package/dist/tools/diagnostics.d.ts +30 -0
  546. package/dist/tools/diagnostics.js +111 -0
  547. package/dist/tools/diff-channel.d.ts +9 -0
  548. package/dist/tools/diff-channel.js +17 -0
  549. package/dist/tools/diff-files.d.ts +17 -0
  550. package/dist/tools/diff-files.js +88 -0
  551. package/dist/tools/disk-usage.d.ts +34 -0
  552. package/dist/tools/disk-usage.js +258 -0
  553. package/dist/tools/edit.d.ts +30 -0
  554. package/dist/tools/edit.js +235 -0
  555. package/dist/tools/executor.d.ts +32 -0
  556. package/dist/tools/executor.js +66 -0
  557. package/dist/tools/file-tracker.d.ts +20 -0
  558. package/dist/tools/file-tracker.js +44 -0
  559. package/dist/tools/filtered-registry.d.ts +29 -0
  560. package/dist/tools/filtered-registry.js +50 -0
  561. package/dist/tools/flow.d.ts +10 -0
  562. package/dist/tools/flow.js +180 -0
  563. package/dist/tools/git-tool.d.ts +24 -0
  564. package/dist/tools/git-tool.js +113 -0
  565. package/dist/tools/glob.d.ts +29 -0
  566. package/dist/tools/glob.js +152 -0
  567. package/dist/tools/grep.d.ts +14 -0
  568. package/dist/tools/grep.js +325 -0
  569. package/dist/tools/http-request.d.ts +14 -0
  570. package/dist/tools/http-request.js +126 -0
  571. package/dist/tools/index.d.ts +43 -0
  572. package/dist/tools/index.js +76 -0
  573. package/dist/tools/injection-filter.d.ts +6 -0
  574. package/dist/tools/injection-filter.js +71 -0
  575. package/dist/tools/insert.d.ts +13 -0
  576. package/dist/tools/insert.js +61 -0
  577. package/dist/tools/interface.d.ts +30 -0
  578. package/dist/tools/interface.js +2 -0
  579. package/dist/tools/json-edit.d.ts +15 -0
  580. package/dist/tools/json-edit.js +122 -0
  581. package/dist/tools/multi-edit.d.ts +9 -0
  582. package/dist/tools/multi-edit.js +146 -0
  583. package/dist/tools/path-sandbox.d.ts +14 -0
  584. package/dist/tools/path-sandbox.js +60 -0
  585. package/dist/tools/process-tools.d.ts +15 -0
  586. package/dist/tools/process-tools.js +95 -0
  587. package/dist/tools/python-bridge/bridge.d.ts +24 -0
  588. package/dist/tools/python-bridge/bridge.js +39 -0
  589. package/dist/tools/python-bridge/executor.d.ts +6 -0
  590. package/dist/tools/python-bridge/executor.js +69 -0
  591. package/dist/tools/python-bridge/index.d.ts +5 -0
  592. package/dist/tools/python-bridge/index.js +4 -0
  593. package/dist/tools/python-bridge/parser.d.ts +21 -0
  594. package/dist/tools/python-bridge/parser.js +258 -0
  595. package/dist/tools/read.d.ts +16 -0
  596. package/dist/tools/read.js +276 -0
  597. package/dist/tools/registry.d.ts +2 -0
  598. package/dist/tools/registry.js +2 -0
  599. package/dist/tools/restart.d.ts +10 -0
  600. package/dist/tools/restart.js +46 -0
  601. package/dist/tools/result-buffer.d.ts +66 -0
  602. package/dist/tools/result-buffer.js +146 -0
  603. package/dist/tools/runtime-control.d.ts +163 -0
  604. package/dist/tools/runtime-control.js +1780 -0
  605. package/dist/tools/symbol-references.d.ts +5 -0
  606. package/dist/tools/symbol-references.js +331 -0
  607. package/dist/tools/system-info.d.ts +3 -0
  608. package/dist/tools/system-info.js +55 -0
  609. package/dist/tools/write.d.ts +18 -0
  610. package/dist/tools/write.js +118 -0
  611. package/dist/tools/xref/index.d.ts +25 -0
  612. package/dist/tools/xref/index.js +25 -0
  613. package/dist/tools/xref/manager.d.ts +85 -0
  614. package/dist/tools/xref/manager.js +948 -0
  615. package/dist/tools/xref/parser.d.ts +34 -0
  616. package/dist/tools/xref/parser.js +64 -0
  617. package/dist/tools/xref/regex-parser.d.ts +26 -0
  618. package/dist/tools/xref/regex-parser.js +446 -0
  619. package/dist/tools/xref/schema.d.ts +104 -0
  620. package/dist/tools/xref/schema.js +68 -0
  621. package/dist/tools/xref/ts-parser.d.ts +20 -0
  622. package/dist/tools/xref/ts-parser.js +403 -0
  623. package/dist/tools/xref/xref-build.d.ts +20 -0
  624. package/dist/tools/xref/xref-build.js +128 -0
  625. package/dist/tools/xref/xref-graph.d.ts +24 -0
  626. package/dist/tools/xref/xref-graph.js +88 -0
  627. package/dist/tools/xref/xref-query.d.ts +30 -0
  628. package/dist/tools/xref/xref-query.js +123 -0
  629. package/dist/types.d.ts +217 -0
  630. package/dist/types.js +2 -0
  631. package/dist/ui/assistant-message.d.ts +7 -0
  632. package/dist/ui/assistant-message.js +18 -0
  633. package/dist/ui/chat-log.d.ts +52 -0
  634. package/dist/ui/chat-log.js +246 -0
  635. package/dist/ui/command-registry.d.ts +73 -0
  636. package/dist/ui/command-registry.js +838 -0
  637. package/dist/ui/diff-component.d.ts +14 -0
  638. package/dist/ui/diff-component.js +42 -0
  639. package/dist/ui/hyperlink-markdown.d.ts +10 -0
  640. package/dist/ui/hyperlink-markdown.js +21 -0
  641. package/dist/ui/markdown-message.d.ts +10 -0
  642. package/dist/ui/markdown-message.js +16 -0
  643. package/dist/ui/osc8-hyperlinks.d.ts +4 -0
  644. package/dist/ui/osc8-hyperlinks.js +142 -0
  645. package/dist/ui/pi-tui-editor.d.ts +35 -0
  646. package/dist/ui/pi-tui-editor.js +79 -0
  647. package/dist/ui/slash-commands.d.ts +16 -0
  648. package/dist/ui/slash-commands.js +29 -0
  649. package/dist/ui/slash-panel.d.ts +54 -0
  650. package/dist/ui/slash-panel.js +199 -0
  651. package/dist/ui/theme.d.ts +120 -0
  652. package/dist/ui/theme.js +154 -0
  653. package/dist/ui/tool-display.d.ts +13 -0
  654. package/dist/ui/tool-display.js +85 -0
  655. package/dist/ui/tool-execution.d.ts +22 -0
  656. package/dist/ui/tool-execution.js +87 -0
  657. package/dist/ui/tui-formatters.d.ts +2 -0
  658. package/dist/ui/tui-formatters.js +145 -0
  659. package/dist/ui/user-message.d.ts +5 -0
  660. package/dist/ui/user-message.js +11 -0
  661. package/dist/update/check.d.ts +8 -0
  662. package/dist/update/check.js +28 -0
  663. package/dist/update/config.d.ts +6 -0
  664. package/dist/update/config.js +18 -0
  665. package/dist/update/download.d.ts +3 -0
  666. package/dist/update/download.js +27 -0
  667. package/dist/update/index.d.ts +6 -0
  668. package/dist/update/index.js +5 -0
  669. package/dist/update/install.d.ts +3 -0
  670. package/dist/update/install.js +33 -0
  671. package/dist/update/types.d.ts +16 -0
  672. package/dist/update/types.js +2 -0
  673. package/dist/utils/diff.d.ts +9 -0
  674. package/dist/utils/diff.js +45 -0
  675. package/dist/utils/misc.d.ts +12 -0
  676. package/dist/utils/misc.js +34 -0
  677. package/dist/world-engine/agent.d.ts +41 -0
  678. package/dist/world-engine/agent.js +385 -0
  679. package/dist/world-engine/index.d.ts +45 -0
  680. package/dist/world-engine/index.js +160 -0
  681. package/dist/world-engine/sim.d.ts +14 -0
  682. package/dist/world-engine/sim.js +120 -0
  683. package/dist/world-engine/store.d.ts +110 -0
  684. package/dist/world-engine/store.js +519 -0
  685. package/dist/world-engine/ticker.d.ts +37 -0
  686. package/dist/world-engine/ticker.js +214 -0
  687. package/dist/world-engine/tools.d.ts +6 -0
  688. package/dist/world-engine/tools.js +380 -0
  689. package/dist/world-engine/types.d.ts +202 -0
  690. package/dist/world-engine/types.js +56 -0
  691. package/docs/api.md +180 -0
  692. package/docs/architecture.md +206 -0
  693. package/docs/diagnostics/2026-06-08-config-prompt-guidance.md +67 -0
  694. package/docs/superpowers/plans/2026-06-08-global-bootstrap-mode.md +89 -0
  695. package/docs/superpowers/specs/2026-06-08-global-bootstrap-mode-design.md +174 -0
  696. package/docs/user-guide.md +226 -0
  697. package/package.json +63 -0
  698. package/plugins/example-greeter/index.js +55 -0
  699. package/plugins/example-greeter/plugin.json +8 -0
  700. package/pnpm-workspace.yaml +5 -0
  701. package/provider_arch.md +179 -0
  702. package/start-webui.sh +27 -0
  703. package/tsconfig.tsbuildinfo +1 -0
  704. package/webui-channel-design.md +789 -0
@@ -0,0 +1,179 @@
1
+ // ============================================================
2
+ // bypass/manager — BypassManager
3
+ // ============================================================
4
+ //
5
+ // 管理所有旁路Agent的生命周期和调度。
6
+ // 由 Loop 在每轮对话前后调用 preTurn/postTurn。
7
+ //
8
+ // 职责:
9
+ // - Agent 注册与启停
10
+ // - preTurn:收集所有活跃Agent的注入内容(阻塞,等旁路LLM完成)
11
+ // - postTurn:并行调度所有Agent的后台观察(不阻塞主流程)
12
+ // - 异常隔离:单个Agent失败不影响其他Agent和主流程
13
+ // ============================================================
14
+ import { createLogger } from '../logging/logger.js';
15
+ const logger = createLogger('bypass-manager');
16
+ export class BypassManager {
17
+ /** 所有已注册的Agent */
18
+ registry = new Map();
19
+ /** 当前激活的Agent列表 */
20
+ active = [];
21
+ /** 模型路由引用(注入后所有Agent共享) */
22
+ modelRouter = null;
23
+ /** 注入模型路由(factory 初始化后调用) */
24
+ setModelRouter(router) {
25
+ this.modelRouter = router;
26
+ for (const agent of this.registry.values()) {
27
+ if ('setModelRouter' in agent) {
28
+ agent.setModelRouter(router);
29
+ }
30
+ }
31
+ }
32
+ /** 注册一个旁路Agent */
33
+ register(agent) {
34
+ this.registry.set(agent.name, agent);
35
+ if (this.modelRouter && 'setModelRouter' in agent) {
36
+ agent.setModelRouter(this.modelRouter);
37
+ }
38
+ // 注入 BypassManager 引用(供 postTurn 中调 inject() 用)
39
+ if ('_manager' in agent) {
40
+ agent._manager = this;
41
+ }
42
+ logger.info(`BypassAgent registered: ${agent.name} (modes: ${agent.modes.join(', ')})`);
43
+ }
44
+ /** 取消注册 */
45
+ unregister(name) {
46
+ this.registry.delete(name);
47
+ this.active = this.active.filter(a => a.name !== name);
48
+ }
49
+ /** 根据模式名激活对应的旁路Agent */
50
+ async activateForMode(modeName) {
51
+ // 先停用当前活跃的
52
+ await this.deactivateAll();
53
+ const toActivate = [];
54
+ for (const agent of this.registry.values()) {
55
+ if (agent.modes.includes('*') || agent.modes.includes(modeName)) {
56
+ toActivate.push(agent);
57
+ }
58
+ }
59
+ for (const agent of toActivate) {
60
+ try {
61
+ await agent.start();
62
+ this.active.push(agent);
63
+ logger.info(`BypassAgent started: ${agent.name} (mode: ${modeName})`);
64
+ }
65
+ catch (err) {
66
+ logger.warn(`BypassAgent start failed: ${agent.name}`, { error: err.message });
67
+ }
68
+ }
69
+ }
70
+ /** 手动激活指定Agent(TUI命令用) */
71
+ async activateAgent(name) {
72
+ const agent = this.registry.get(name);
73
+ if (!agent) {
74
+ logger.warn(`BypassAgent not found: ${name}`);
75
+ return;
76
+ }
77
+ if (this.active.includes(agent))
78
+ return;
79
+ try {
80
+ await agent.start();
81
+ this.active.push(agent);
82
+ logger.info(`BypassAgent manually activated: ${name}`);
83
+ }
84
+ catch (err) {
85
+ logger.warn(`BypassAgent start failed: ${name}`, { error: err.message });
86
+ }
87
+ }
88
+ /** 手动停用指定Agent(TUI命令用) */
89
+ async deactivateAgent(name) {
90
+ const agent = this.registry.get(name);
91
+ if (!agent)
92
+ return;
93
+ try {
94
+ await agent.stop();
95
+ }
96
+ catch (err) {
97
+ logger.warn(`BypassAgent stop failed: ${name}`, { error: err.message });
98
+ }
99
+ this.active = this.active.filter(a => a !== agent);
100
+ logger.info(`BypassAgent deactivated: ${name}`);
101
+ }
102
+ /** 停用所有Agent */
103
+ async deactivateAll() {
104
+ for (const agent of this.active) {
105
+ try {
106
+ await agent.stop();
107
+ }
108
+ catch (err) {
109
+ logger.warn(`BypassAgent stop failed: ${agent.name}`, { error: err.message });
110
+ }
111
+ }
112
+ this.active = [];
113
+ }
114
+ /** 某Agent是否激活 */
115
+ isActive(name) {
116
+ return this.active.some(a => a.name === name);
117
+ }
118
+ /** 获取已注册的Agent(用于直接访问Agent特有方法,如 setPendingNarration) */
119
+ getAgent(name) {
120
+ return this.registry.get(name);
121
+ }
122
+ /** 获取激活列表 */
123
+ getActiveNames() {
124
+ return this.active.map(a => a.name);
125
+ }
126
+ /** 运行时注入:旁路Agent 在 postTurn 中可调用此方法写入纠正内容 */
127
+ _pendingInjections = [];
128
+ inject(agentName, injection) {
129
+ // 清除同一 agent 的旧注入,只保留最新
130
+ this._pendingInjections = this._pendingInjections.filter(ij => ij.section !== injection.section);
131
+ this._pendingInjections.push(injection);
132
+ logger.info(`BypassAgent injected: ${agentName} → ${injection.section}`);
133
+ }
134
+ /** 消费待注入内容(由 Loop 在 compose 前调用) */
135
+ consumeInjections() {
136
+ const injs = [...this._pendingInjections];
137
+ this._pendingInjections = [];
138
+ return injs;
139
+ }
140
+ // ── preTurn:阻塞,等所有旁路Agent完成 ──────────────────────
141
+ async preTurn(ctx) {
142
+ if (this.active.length === 0) {
143
+ return { injections: [] };
144
+ }
145
+ const allInjections = [];
146
+ let transformedInput;
147
+ for (const agent of this.active) {
148
+ if (!agent.preTurn)
149
+ continue;
150
+ try {
151
+ const result = await agent.preTurn(ctx);
152
+ if (result.transformedInput !== undefined) {
153
+ transformedInput = result.transformedInput;
154
+ }
155
+ allInjections.push(...result.injections);
156
+ }
157
+ catch (err) {
158
+ logger.warn(`BypassAgent preTurn failed: ${agent.name}`, { error: err.message });
159
+ }
160
+ }
161
+ return { transformedInput, injections: allInjections };
162
+ }
163
+ // ── postTurn:后台并行,不阻塞 ──────────────────────────────
164
+ postTurn(ctx) {
165
+ if (this.active.length === 0)
166
+ return;
167
+ Promise.allSettled(this.active.map(async (agent) => {
168
+ if (!agent.postTurn)
169
+ return;
170
+ try {
171
+ await agent.postTurn(ctx);
172
+ }
173
+ catch (err) {
174
+ logger.warn(`BypassAgent postTurn failed: ${agent.name}`, { error: err.message });
175
+ }
176
+ }));
177
+ }
178
+ }
179
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1,63 @@
1
+ import type { Message } from '../types.js';
2
+ /** preTurn 上下文:旁路Agent在每轮对话前的输入 */
3
+ export interface PreTurnContext {
4
+ /** 当前用户输入(原始文本) */
5
+ userInput: string;
6
+ /** 最近 N 轮对话原始消息 */
7
+ recentHistory: Message[];
8
+ /** 当前上下文预算 { used, total } */
9
+ contextBudget: {
10
+ used: number;
11
+ total: number;
12
+ };
13
+ /** 最近几轮的工具调用名称 */
14
+ recentToolCalls: string[];
15
+ }
16
+ /** postTurn 上下文:旁路Agent在每轮对话后的输入 */
17
+ export interface PostTurnContext {
18
+ /** 当前用户输入 */
19
+ userInput: string;
20
+ /** 主Agent的回复文本 */
21
+ assistantOutput: string;
22
+ /** 本轮对话历史(含用户输入和模型回复) */
23
+ history: Message[];
24
+ /** 本轮调用的工具名称 */
25
+ toolCallsThisTurn: string[];
26
+ /** 是否为本轮用户消息的最后一次迭代(loop 结束) */
27
+ isLastIteration: boolean;
28
+ }
29
+ /** 注入到上下文中的 section */
30
+ export interface Injection {
31
+ /** 目标 section 名称(如 'timestamp', 'persona_soul') */
32
+ section: string;
33
+ /** 注入内容 */
34
+ content: string;
35
+ /** 消息角色 */
36
+ role: 'system' | 'assistant' | 'user';
37
+ /** 替换模式:replace=替换整个section, append=追加到末尾 */
38
+ mode: 'replace' | 'append';
39
+ }
40
+ /** preTurn 的返回结果 */
41
+ export interface PreTurnResult {
42
+ /** 变换后的用户输入(可选,World Engine 用于剥离 [[...]]) */
43
+ transformedInput?: string;
44
+ /** 要注入到上下文的 section 列表 */
45
+ injections: Injection[];
46
+ }
47
+ export interface BypassAgent {
48
+ /** 唯一标识 */
49
+ readonly name: string;
50
+ /** 声明适用的模式(如 ['companion'] 或 ['*'] 表示全部) */
51
+ readonly modes: string[];
52
+ /** 使用的模型通道名(对应 model-channels.json 中的通道) */
53
+ readonly modelChannel: string;
54
+ /** 启动(创建内部状态、启动定时器等) */
55
+ start(): Promise<void>;
56
+ /** 停止(清理资源、落盘) */
57
+ stop(): Promise<void>;
58
+ /** 前置介入:在 composer 组装之前调用 */
59
+ preTurn?(ctx: PreTurnContext): Promise<PreTurnResult>;
60
+ /** 后置观察:在主Agent回复之后调用(后台,不影响主流程) */
61
+ postTurn?(ctx: PostTurnContext): Promise<void>;
62
+ }
63
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,14 @@
1
+ // ============================================================
2
+ // bypass/types — 旁路Agent 接口定义
3
+ // ============================================================
4
+ //
5
+ // 旁路Agent 是独立于主Agent运行的后台观察者。
6
+ // 在主对话流的前后介入:preTurn 产出注入内容,postTurn 观察并更新内部状态。
7
+ //
8
+ // 与主Agent的差异:
9
+ // - 独立模型通道(不抢占主Agent的上下文预算)
10
+ // - 异常隔离(任何错误不影响主流程)
11
+ // - 状态持久化(跨轮保持内部状态)
12
+ // ============================================================
13
+ export {};
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,25 @@
1
+ import type { ChannelManager } from './manager.js';
2
+ import type { ChannelsInfo } from '../env/index.js';
3
+ export interface ChannelPlugin {
4
+ /** 配置 key 名(对应 config.json 中 channels 下的键名) */
5
+ configKey: string;
6
+ /** 自动注册渠道 */
7
+ autoRegister(channelManager: ChannelManager, config: unknown, channelsInfo: ChannelsInfo[]): Promise<void>;
8
+ /** Gateway 启动时执行全局设置(如日志拦截),返回清理函数 */
9
+ onGatewayInit?(): (() => void) | void;
10
+ }
11
+ export declare function registerChannelPlugin(plugin: ChannelPlugin): void;
12
+ export declare function getChannelPlugins(): ChannelPlugin[];
13
+ /**
14
+ * 自动发现渠道插件。
15
+ * 扫描 channels/plugins 下的子目录中导出的 channelPlugin 常量。
16
+ */
17
+ export declare function discoverPlugins(): Promise<void>;
18
+ /**
19
+ * 根据 config.json 注册所有配置驱动渠道。
20
+ * 不负责启动——由调用方通过 channelManager.startAll() 统一启动。
21
+ *
22
+ * @returns 已注册的渠道信息列表(用于注入到 System Prompt)
23
+ */
24
+ export declare function registerConfigChannels(channelManager: ChannelManager, cwd: string): Promise<ChannelsInfo[]>;
25
+ //# sourceMappingURL=auto-detect.d.ts.map
@@ -0,0 +1,77 @@
1
+ // ============================================================
2
+ // auto-detect.ts — 渠道自动检测(插件注册表模式)
3
+ // ============================================================
4
+ //
5
+ // 职责:
6
+ // 根据 config.json 自动检测并注册配置驱动渠道
7
+ // 通过 ChannelPlugin 注册表实现可扩展的渠道自动注册
8
+ // TUI 渠道始终默认允许,由调用方手动注册和启动
9
+ // HTTP 渠道由 serve 模式负责
10
+ //
11
+ // 使用方式:
12
+ // import { registerConfigChannels, registerChannelPlugin } from './channels/auto-detect.js';
13
+ // registerChannelPlugin(feishuChannelPlugin);
14
+ // const channelsInfo = await registerConfigChannels(channelManager, cwd);
15
+ // await channelManager.startAll(messageProcessor);
16
+ // ============================================================
17
+ import { ConfigManager } from '../setup/config.js';
18
+ // ─── 插件注册表 ─────────────────────────────────────────────────
19
+ const channelPlugins = [];
20
+ export function registerChannelPlugin(plugin) {
21
+ channelPlugins.push(plugin);
22
+ }
23
+ export function getChannelPlugins() {
24
+ return [...channelPlugins];
25
+ }
26
+ // ─── 自动注册入口 ───────────────────────────────────────────────
27
+ /**
28
+ * 自动发现渠道插件。
29
+ * 扫描 channels/plugins 下的子目录中导出的 channelPlugin 常量。
30
+ */
31
+ export async function discoverPlugins() {
32
+ const fs = await import('node:fs/promises');
33
+ const path = await import('node:path');
34
+ const fileUrl = await import('node:url');
35
+ const pluginsDir = path.join(path.dirname(fileUrl.fileURLToPath(import.meta.url)), 'plugins');
36
+ try {
37
+ const entries = await fs.readdir(pluginsDir, { withFileTypes: true });
38
+ for (const entry of entries) {
39
+ if (!entry.isDirectory())
40
+ continue;
41
+ try {
42
+ const mod = await import(`./plugins/${entry.name}/index.js`);
43
+ if (mod.channelPlugin && typeof mod.channelPlugin.autoRegister === 'function') {
44
+ channelPlugins.push(mod.channelPlugin);
45
+ }
46
+ }
47
+ catch {
48
+ // 插件加载失败,跳过
49
+ }
50
+ }
51
+ }
52
+ catch {
53
+ // plugins 目录不存在,跳过
54
+ }
55
+ }
56
+ /**
57
+ * 根据 config.json 注册所有配置驱动渠道。
58
+ * 不负责启动——由调用方通过 channelManager.startAll() 统一启动。
59
+ *
60
+ * @returns 已注册的渠道信息列表(用于注入到 System Prompt)
61
+ */
62
+ export async function registerConfigChannels(channelManager, cwd) {
63
+ // 自动发现插件(如果尚未手动注册)
64
+ if (channelPlugins.length === 0) {
65
+ await discoverPlugins();
66
+ }
67
+ const channelsInfo = [];
68
+ const configManager = new ConfigManager(cwd);
69
+ await configManager.loadEnvKeys();
70
+ const agentConfig = await configManager.load();
71
+ for (const plugin of channelPlugins) {
72
+ const config = agentConfig.channels?.[plugin.configKey];
73
+ await plugin.autoRegister(channelManager, config, channelsInfo);
74
+ }
75
+ return channelsInfo;
76
+ }
77
+ //# sourceMappingURL=auto-detect.js.map
@@ -0,0 +1,25 @@
1
+ import type { ChannelHandler, ChannelEvent, ChannelReply, ChannelConfig, ChannelStatus } from '../interface.js';
2
+ export declare class HttpWebhookChannel implements ChannelHandler {
3
+ readonly id = "http-webhook";
4
+ readonly name = "HTTP Webhook";
5
+ readonly description = "\u5185\u5EFA HTTP REST API \u6E20\u9053\uFF0C\u652F\u6301 POST /api/chat webhook \u63A5\u5165\uFF08Bearer Token \u8BA4\u8BC1\uFF09";
6
+ readonly pluginId: undefined;
7
+ private app;
8
+ private status;
9
+ private eventHandler;
10
+ private provider;
11
+ private sessionManager;
12
+ private cwd;
13
+ private maxTurns;
14
+ private maxContext;
15
+ private activeComponents;
16
+ private wsAgentFactory;
17
+ start(config: ChannelConfig): Promise<void>;
18
+ stop(): Promise<void>;
19
+ onEvent(handler: (event: ChannelEvent) => Promise<void>): void;
20
+ reply(_sessionId: string, _reply: ChannelReply): Promise<void>;
21
+ getStatus(): ChannelStatus;
22
+ handleMessage(): Promise<void>;
23
+ private ensureComponents;
24
+ }
25
+ //# sourceMappingURL=http-webhook.d.ts.map
@@ -0,0 +1,287 @@
1
+ // ============================================================
2
+ // HttpWebhookChannel — 内建 HTTP REST API 渠道(企业加固版)
3
+ // ============================================================
4
+ //
5
+ // 端点:/api/health, /api/chat, /api/sessions, /api/tools, /api/skills
6
+ // 认证:Bearer Token(HYACINTH_API_KEY 环境变量或 --api-key 参数)
7
+ // Chat 为同步 request-response 模式。
8
+ // ============================================================
9
+ import { createLogger } from '../../logging/logger.js';
10
+ import { getModelContextWindow } from '../../setup/model-defaults.js';
11
+ import { getDefaultConfig } from '../../runtime/defaults.js';
12
+ const logger = createLogger('http-webhook');
13
+ // ── 认证 ────────────────────────────────────────────────────────────
14
+ function getApiKey(config) {
15
+ return config.apiKey
16
+ || process.env.HYACINTH_API_KEY
17
+ || process.env.AGENT_API_KEY
18
+ || null;
19
+ }
20
+ function authHook(apiKey) {
21
+ return async (req, reply) => {
22
+ // /api/health 无需认证
23
+ if (req.url === '/api/health')
24
+ return;
25
+ if (!apiKey) {
26
+ return reply.status(401).send({
27
+ error: 'API key not configured. Set HYACINTH_API_KEY environment variable or pass --api-key.',
28
+ });
29
+ }
30
+ const auth = req.headers['authorization'] ?? '';
31
+ const bearer = auth.startsWith('Bearer ') ? auth.slice(7) : '';
32
+ if (bearer !== apiKey) {
33
+ return reply.status(401).send({ error: 'Invalid or missing API key. Use Authorization: Bearer <key>' });
34
+ }
35
+ };
36
+ }
37
+ // ── CollectHandler ────────────────────────────────────────────────
38
+ /** 收集 agent 输出的 handler */
39
+ class CollectHandler {
40
+ texts = [];
41
+ toolCalls = [];
42
+ statusMessages = [];
43
+ onText(content) { this.texts.push(content); }
44
+ onThinking(_content) { }
45
+ onToolUse(name, inputSummary) {
46
+ this.toolCalls.push({ name, input: inputSummary, isError: false, result: '' });
47
+ }
48
+ onToolResult(content, isError) {
49
+ const last = this.toolCalls.length > 0 ? this.toolCalls[this.toolCalls.length - 1] : undefined;
50
+ if (last && !last.result) {
51
+ last.isError = isError;
52
+ last.result = content;
53
+ }
54
+ }
55
+ onStatus(message, _level) { this.statusMessages.push(message); }
56
+ onTurnStart() { }
57
+ onFlush() { }
58
+ onInterrupt() { }
59
+ onPermissionRequest(toolName, input) {
60
+ void toolName;
61
+ void input;
62
+ return Promise.resolve(true);
63
+ }
64
+ getFullText() {
65
+ return this.texts.join('\n');
66
+ }
67
+ }
68
+ // ── HttpWebhookChannel ───────────────────────────────────────────
69
+ export class HttpWebhookChannel {
70
+ id = 'http-webhook';
71
+ name = 'HTTP Webhook';
72
+ description = '内建 HTTP REST API 渠道,支持 POST /api/chat webhook 接入(Bearer Token 认证)';
73
+ pluginId = undefined;
74
+ app = null;
75
+ status = 'registered';
76
+ eventHandler = null;
77
+ provider;
78
+ sessionManager;
79
+ cwd;
80
+ maxTurns;
81
+ maxContext;
82
+ activeComponents = null;
83
+ wsAgentFactory = null;
84
+ async start(config) {
85
+ const { port = 3000, host = '0.0.0.0' } = config;
86
+ // 从 config 获取 agentFactory(由 ChannelManager.startChannel 注入)
87
+ this.wsAgentFactory = config.agentFactory ?? null;
88
+ this.provider = config.provider;
89
+ this.sessionManager = config.sessionManager;
90
+ this.cwd = config.cwd;
91
+ this.maxTurns = config.maxTurns ?? getDefaultConfig().session.maxTurns;
92
+ this.maxContext = config.maxContext ?? getModelContextWindow(this.provider.getProviderType(), this.provider.getModel());
93
+ const apiKey = getApiKey(config);
94
+ if (!apiKey) {
95
+ logger.warn('No HYACINTH_API_KEY set — HTTP API will reject all requests except /api/health. Set the environment variable or use --api-key.');
96
+ }
97
+ const fastify = (await import('fastify')).default;
98
+ this.app = fastify({ logger: false });
99
+ // ── 安全加固(全路由)───────────────────────────────────────────
100
+ this.app.addHook('preHandler', authHook(apiKey));
101
+ this.app.addHook('onSend', async (_req, reply) => {
102
+ reply.header('X-Content-Type-Options', 'nosniff');
103
+ reply.header('X-Frame-Options', 'DENY');
104
+ reply.header('X-XSS-Protection', '1; mode=block');
105
+ reply.header('Access-Control-Allow-Origin', config.corsOrigin || '*');
106
+ reply.header('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
107
+ reply.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
108
+ });
109
+ // OPTIONS preflight
110
+ this.app.options('*', async (_req, reply) => {
111
+ return reply.status(204).send();
112
+ });
113
+ // ── Health ──────────────────────────────────────────────────
114
+ this.app.get('/api/health', async (_req, reply) => {
115
+ return reply.send({ status: 'ok', version: '1.0.0', auth: !!apiKey });
116
+ });
117
+ // ── Chat ────────────────────────────────────────────────────
118
+ this.app.post('/api/chat', async (req, reply) => {
119
+ const body = req.body;
120
+ if (!body.message) {
121
+ return reply.status(400).send({ error: 'message is required' });
122
+ }
123
+ const handler = new CollectHandler();
124
+ try {
125
+ const { createAgent } = await import('../../gateway/factory.js');
126
+ const { loop, sessionDir } = await createAgent({
127
+ cwd: this.cwd,
128
+ provider: this.provider,
129
+ maxTurns: this.maxTurns,
130
+ maxContext: this.maxContext,
131
+ outputHandler: handler,
132
+ sessionId: body.sessionId,
133
+ shouldContinue: !body.sessionId,
134
+ });
135
+ if (body.images?.length)
136
+ loop.channelImages = body.images;
137
+ await loop.run(body.message);
138
+ const sessionId = sessionDir.split(/[\\/]/).pop() ?? '';
139
+ if (this.eventHandler) {
140
+ this.eventHandler({
141
+ type: 'message',
142
+ sessionId,
143
+ userId: 'http-user',
144
+ content: body.message,
145
+ channel: this.id,
146
+ metadata: { source: 'http-webhook' },
147
+ }).catch(() => { });
148
+ }
149
+ return reply.send({
150
+ sessionId,
151
+ content: handler.getFullText(),
152
+ turns: handler.toolCalls.length,
153
+ toolCalls: handler.toolCalls.map(t => ({ name: t.name, input: t.input })),
154
+ });
155
+ }
156
+ catch (error) {
157
+ const message = error instanceof Error ? error.message : String(error);
158
+ logger.error('Chat error', undefined, { error: message });
159
+ return reply.status(500).send({ error: message });
160
+ }
161
+ });
162
+ // ── Sessions ────────────────────────────────────────────────
163
+ this.app.get('/api/sessions', async (_req, reply) => {
164
+ const sessions = await this.sessionManager.list();
165
+ return reply.send(sessions);
166
+ });
167
+ this.app.post('/api/sessions', async (_req, reply) => {
168
+ const session = await this.sessionManager.create('normal', 'http-webhook');
169
+ return reply.send({ id: session.id, createdAt: session.createdAt });
170
+ });
171
+ this.app.get('/api/sessions/:id', async (req, reply) => {
172
+ const { id } = req.params;
173
+ try {
174
+ const session = await this.sessionManager.resume(id);
175
+ return reply.send({ id: session.id, createdAt: session.createdAt });
176
+ }
177
+ catch {
178
+ return reply.status(404).send({ error: 'Session not found' });
179
+ }
180
+ });
181
+ this.app.delete('/api/sessions/:id', async (req, reply) => {
182
+ const { id } = req.params;
183
+ try {
184
+ const fs = await import('node:fs/promises');
185
+ const path = await import('node:path');
186
+ const os = await import('node:os');
187
+ const sessionDir = path.join(os.homedir(), '.agent', 'sessions', id);
188
+ await fs.rm(sessionDir, { recursive: true, force: true });
189
+ return reply.send({ ok: true });
190
+ }
191
+ catch {
192
+ return reply.status(404).send({ error: 'Session not found' });
193
+ }
194
+ });
195
+ // ── Tools & Skills ──────────────────────────────────────────
196
+ this.app.get('/api/tools', async (_req, reply) => {
197
+ const components = await this.ensureComponents();
198
+ const tools = components.toolRegistry.getAll().map(t => ({
199
+ name: t.name,
200
+ description: t.description,
201
+ }));
202
+ return reply.send(tools);
203
+ });
204
+ this.app.get('/api/skills', async (_req, reply) => {
205
+ const components = await this.ensureComponents();
206
+ const skills = components.skillRegistry.getAll().map(s => ({
207
+ name: s.name,
208
+ description: s.description,
209
+ source: s.source,
210
+ }));
211
+ return reply.send(skills);
212
+ });
213
+ // ── TUI WebSocket 端点(让 TUI 客户端通过 ws://host:port/tui 连接统一后端) ─
214
+ const { WebSocketServer } = await import('ws');
215
+ const { TuiWsSession } = await import('./tui-ws-session.js');
216
+ const { randomBytes } = await import('node:crypto');
217
+ const tuiWss = new WebSocketServer({ noServer: true });
218
+ this.app.server.on('upgrade', (request, socket, head) => {
219
+ if (request.url === '/tui') {
220
+ tuiWss.handleUpgrade(request, socket, head, (ws) => {
221
+ tuiWss.emit('connection', ws, request);
222
+ });
223
+ }
224
+ else {
225
+ socket.destroy();
226
+ }
227
+ });
228
+ tuiWss.on('connection', (ws) => {
229
+ const sessionId = `tui_${Date.now().toString(36)}-${randomBytes(3).toString('hex')}`;
230
+ const session = new TuiWsSession(ws, sessionId);
231
+ logger.info('TUI WS client connected', { sessionId });
232
+ if (this.wsAgentFactory) {
233
+ session.initialize(this.wsAgentFactory).catch((err) => {
234
+ logger.error('TUI WS init failed', err instanceof Error ? err : new Error(String(err)));
235
+ });
236
+ }
237
+ else {
238
+ logger.warn('TUI WS agentFactory not available');
239
+ }
240
+ ws.on('message', (data) => {
241
+ session.handleMessage(data).catch((err) => {
242
+ logger.error('TUI WS msg error', err instanceof Error ? err : new Error(String(err)));
243
+ });
244
+ });
245
+ ws.on('close', () => {
246
+ session.close().catch(() => { });
247
+ logger.info('TUI WS client disconnected', { sessionId });
248
+ });
249
+ });
250
+ // ── Start ───────────────────────────────────────────────────
251
+ await this.app.listen({ port: port, host: host });
252
+ this.status = 'active';
253
+ logger.info(`HTTP API listening on ${host}:${port}${apiKey ? ' (auth enabled)' : ' (auth: only /api/health)'}`);
254
+ }
255
+ async stop() {
256
+ if (this.app) {
257
+ await this.app.close();
258
+ this.app = null;
259
+ }
260
+ this.status = 'stopped';
261
+ }
262
+ onEvent(handler) {
263
+ this.eventHandler = handler;
264
+ }
265
+ async reply(_sessionId, _reply) {
266
+ // HTTP webhook 模式下回复已在 POST /api/chat 响应中同步返回
267
+ }
268
+ getStatus() { return this.status; }
269
+ async handleMessage() {
270
+ throw new Error('HTTP webhook channel does not support handleMessage');
271
+ }
272
+ async ensureComponents() {
273
+ if (!this.activeComponents) {
274
+ const { createAgent } = await import('../../gateway/factory.js');
275
+ const handler = new CollectHandler();
276
+ this.activeComponents = await createAgent({
277
+ cwd: this.cwd,
278
+ provider: this.provider,
279
+ maxTurns: this.maxTurns,
280
+ maxContext: this.maxContext,
281
+ outputHandler: handler,
282
+ });
283
+ }
284
+ return this.activeComponents;
285
+ }
286
+ }
287
+ //# sourceMappingURL=http-webhook.js.map