cli-claw-kit 0.0.1

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 (295) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +245 -0
  3. package/config/default-groups.json +1 -0
  4. package/config/global-agents-md.template.md +37 -0
  5. package/config/mount-allowlist.json +11 -0
  6. package/container/Dockerfile +160 -0
  7. package/container/agent-runner/dist/.tsbuildinfo +1 -0
  8. package/container/agent-runner/dist/agent-definitions.js +22 -0
  9. package/container/agent-runner/dist/channel-prefixes.js +16 -0
  10. package/container/agent-runner/dist/codex-config.js +29 -0
  11. package/container/agent-runner/dist/image-detector.js +96 -0
  12. package/container/agent-runner/dist/index.js +2587 -0
  13. package/container/agent-runner/dist/mcp-tools.js +1076 -0
  14. package/container/agent-runner/dist/stream-event.types.js +5 -0
  15. package/container/agent-runner/dist/stream-processor.js +867 -0
  16. package/container/agent-runner/dist/types.js +6 -0
  17. package/container/agent-runner/dist/utils.js +115 -0
  18. package/container/agent-runner/package.json +36 -0
  19. package/container/agent-runner/prompts/security-rules.md +31 -0
  20. package/container/agent-runner/src/agent-definitions.ts +27 -0
  21. package/container/agent-runner/src/channel-prefixes.ts +16 -0
  22. package/container/agent-runner/src/codex-config.ts +40 -0
  23. package/container/agent-runner/src/image-detector.ts +116 -0
  24. package/container/agent-runner/src/index.ts +3107 -0
  25. package/container/agent-runner/src/mcp-tools.ts +1295 -0
  26. package/container/agent-runner/src/stream-event.types.ts +10 -0
  27. package/container/agent-runner/src/stream-processor.ts +932 -0
  28. package/container/agent-runner/src/types.ts +75 -0
  29. package/container/agent-runner/src/utils.ts +114 -0
  30. package/container/agent-runner/tsconfig.json +17 -0
  31. package/container/build.sh +28 -0
  32. package/container/entrypoint.sh +64 -0
  33. package/container/skills/agent-browser/SKILL.md +159 -0
  34. package/container/skills/install-skill/SKILL.md +64 -0
  35. package/container/skills/post-test-cleanup/SKILL.md +121 -0
  36. package/dist/.tsbuildinfo +1 -0
  37. package/dist/agent-output-parser.js +459 -0
  38. package/dist/app-root.js +52 -0
  39. package/dist/assistant-meta-footer.js +1 -0
  40. package/dist/auth.js +91 -0
  41. package/dist/billing.js +694 -0
  42. package/dist/channel-prefixes.js +16 -0
  43. package/dist/cli.js +86 -0
  44. package/dist/commands.js +79 -0
  45. package/dist/config.js +120 -0
  46. package/dist/container-runner.js +981 -0
  47. package/dist/daily-summary.js +210 -0
  48. package/dist/db.js +3683 -0
  49. package/dist/dingtalk.js +1347 -0
  50. package/dist/feishu-markdown-style.js +97 -0
  51. package/dist/feishu-streaming-card.js +1875 -0
  52. package/dist/feishu.js +1628 -0
  53. package/dist/file-manager.js +270 -0
  54. package/dist/group-queue.js +1070 -0
  55. package/dist/group-runtime.js +35 -0
  56. package/dist/host-workspace-cwd.js +85 -0
  57. package/dist/im-channel.js +384 -0
  58. package/dist/im-command-utils.js +142 -0
  59. package/dist/im-downloader.js +45 -0
  60. package/dist/im-manager.js +527 -0
  61. package/dist/im-utils.js +53 -0
  62. package/dist/image-detector.js +96 -0
  63. package/dist/index.js +5828 -0
  64. package/dist/logger.js +22 -0
  65. package/dist/mcp-utils.js +66 -0
  66. package/dist/message-attachments.js +69 -0
  67. package/dist/message-notifier.js +36 -0
  68. package/dist/middleware/auth.js +85 -0
  69. package/dist/mount-security.js +315 -0
  70. package/dist/permissions.js +67 -0
  71. package/dist/project-memory.js +6 -0
  72. package/dist/provider-pool.js +189 -0
  73. package/dist/qq.js +826 -0
  74. package/dist/reset-admin.js +42 -0
  75. package/dist/routes/admin.js +543 -0
  76. package/dist/routes/agent-definitions.js +241 -0
  77. package/dist/routes/agents.js +533 -0
  78. package/dist/routes/auth.js +675 -0
  79. package/dist/routes/billing.js +490 -0
  80. package/dist/routes/browse.js +210 -0
  81. package/dist/routes/bug-report.js +387 -0
  82. package/dist/routes/config.js +1868 -0
  83. package/dist/routes/files.js +671 -0
  84. package/dist/routes/groups.js +1367 -0
  85. package/dist/routes/mcp-servers.js +320 -0
  86. package/dist/routes/memory.js +523 -0
  87. package/dist/routes/monitor.js +307 -0
  88. package/dist/routes/skills.js +777 -0
  89. package/dist/routes/tasks.js +509 -0
  90. package/dist/routes/usage.js +64 -0
  91. package/dist/routes/workspace-config.js +458 -0
  92. package/dist/runtime-build.js +112 -0
  93. package/dist/runtime-command-handler.js +189 -0
  94. package/dist/runtime-command-registry.js +1 -0
  95. package/dist/runtime-config.js +1777 -0
  96. package/dist/runtime-identity.js +52 -0
  97. package/dist/schemas.js +590 -0
  98. package/dist/script-runner.js +64 -0
  99. package/dist/sdk-query.js +82 -0
  100. package/dist/skill-utils.js +145 -0
  101. package/dist/sqlite-compat.js +19 -0
  102. package/dist/stream-event.types.js +5 -0
  103. package/dist/streaming-runtime-meta.js +29 -0
  104. package/dist/task-scheduler.js +695 -0
  105. package/dist/task-utils.js +13 -0
  106. package/dist/telegram-pairing.js +59 -0
  107. package/dist/telegram.js +897 -0
  108. package/dist/terminal-manager.js +307 -0
  109. package/dist/tool-step-display.js +1 -0
  110. package/dist/types.js +1 -0
  111. package/dist/utils.js +85 -0
  112. package/dist/web-context.js +161 -0
  113. package/dist/web.js +1377 -0
  114. package/dist/wechat-crypto.js +182 -0
  115. package/dist/wechat.js +589 -0
  116. package/dist/workspace-runtime-reset.js +35 -0
  117. package/package.json +107 -0
  118. package/shared/assistant-meta-footer.ts +127 -0
  119. package/shared/channel-prefixes.ts +16 -0
  120. package/shared/dist/assistant-meta-footer.d.ts +29 -0
  121. package/shared/dist/assistant-meta-footer.js +85 -0
  122. package/shared/dist/channel-prefixes.d.ts +4 -0
  123. package/shared/dist/channel-prefixes.js +16 -0
  124. package/shared/dist/image-detector.d.ts +20 -0
  125. package/shared/dist/image-detector.js +96 -0
  126. package/shared/dist/runtime-command-registry.d.ts +38 -0
  127. package/shared/dist/runtime-command-registry.js +185 -0
  128. package/shared/dist/stream-event.d.ts +65 -0
  129. package/shared/dist/stream-event.js +8 -0
  130. package/shared/dist/tool-step-display.d.ts +4 -0
  131. package/shared/dist/tool-step-display.js +11 -0
  132. package/shared/image-detector.ts +116 -0
  133. package/shared/runtime-command-registry.ts +252 -0
  134. package/shared/stream-event.ts +67 -0
  135. package/shared/tool-step-display.ts +21 -0
  136. package/shared/tsconfig.json +24 -0
  137. package/web/dist/assets/BillingPage-B1wBR_o-.js +52 -0
  138. package/web/dist/assets/ChatPage-6GBZ9nXN.css +32 -0
  139. package/web/dist/assets/ChatPage-BOJcXtaj.js +161 -0
  140. package/web/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  141. package/web/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  142. package/web/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  143. package/web/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  144. package/web/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  145. package/web/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  146. package/web/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  147. package/web/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  148. package/web/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  149. package/web/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  150. package/web/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  151. package/web/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  152. package/web/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  153. package/web/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  154. package/web/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  155. package/web/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  156. package/web/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  157. package/web/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  158. package/web/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  159. package/web/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  160. package/web/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  161. package/web/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  162. package/web/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  163. package/web/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  164. package/web/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  165. package/web/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  166. package/web/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  167. package/web/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  168. package/web/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  169. package/web/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  170. package/web/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  171. package/web/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  172. package/web/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  173. package/web/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  174. package/web/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  175. package/web/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  176. package/web/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  177. package/web/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  178. package/web/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  179. package/web/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  180. package/web/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  181. package/web/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  182. package/web/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  183. package/web/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  184. package/web/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  185. package/web/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  186. package/web/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  187. package/web/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  188. package/web/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  189. package/web/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  190. package/web/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  191. package/web/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  192. package/web/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  193. package/web/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  194. package/web/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  195. package/web/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  196. package/web/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  197. package/web/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  198. package/web/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  199. package/web/dist/assets/SettingsPage-DoY7FoZ_.js +153 -0
  200. package/web/dist/assets/ShareImageDialog-C1ga8b7l.js +22 -0
  201. package/web/dist/assets/TasksPage-CRivnNsx.js +14 -0
  202. package/web/dist/assets/_basePickBy-Bf-bSoS9.js +1 -0
  203. package/web/dist/assets/_baseUniq-zAOaCuKw.js +1 -0
  204. package/web/dist/assets/arc-Dm9mVQ9U.js +1 -0
  205. package/web/dist/assets/architectureDiagram-2XIMDMQ5-BLmzX1wr.js +36 -0
  206. package/web/dist/assets/band-CquvqAHh.js +1 -0
  207. package/web/dist/assets/blockDiagram-WCTKOSBZ-B9pcqm3j.js +132 -0
  208. package/web/dist/assets/c4Diagram-IC4MRINW-Cytx1q3b.js +10 -0
  209. package/web/dist/assets/channel-BOVj73LR.js +1 -0
  210. package/web/dist/assets/channel-meta-CQD0Pei-.js +41 -0
  211. package/web/dist/assets/chunk-4BX2VUAB-0ToDr6RE.js +1 -0
  212. package/web/dist/assets/chunk-55IACEB6-DQDjnXfS.js +1 -0
  213. package/web/dist/assets/chunk-FMBD7UC4-Di8ABm6c.js +15 -0
  214. package/web/dist/assets/chunk-JSJVCQXG-BZQN6rnX.js +1 -0
  215. package/web/dist/assets/chunk-KX2RTZJC-zBbcpaN_.js +1 -0
  216. package/web/dist/assets/chunk-NQ4KR5QH-BCrLoU88.js +220 -0
  217. package/web/dist/assets/chunk-QZHKN3VN-Bqk8juan.js +1 -0
  218. package/web/dist/assets/chunk-WL4C6EOR-D2YX-MHY.js +189 -0
  219. package/web/dist/assets/classDiagram-VBA2DB6C-DUUoMyaK.js +1 -0
  220. package/web/dist/assets/classDiagram-v2-RAHNMMFH-DUUoMyaK.js +1 -0
  221. package/web/dist/assets/clone-BmaCesfa.js +1 -0
  222. package/web/dist/assets/cose-bilkent-S5V4N54A-CTsv6qQA.js +1 -0
  223. package/web/dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
  224. package/web/dist/assets/dagre-KLK3FWXG-Ci4Jh9nu.js +4 -0
  225. package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  226. package/web/dist/assets/diagram-E7M64L7V-BFRnfTI2.js +24 -0
  227. package/web/dist/assets/diagram-IFDJBPK2-B7Zhnp0b.js +43 -0
  228. package/web/dist/assets/diagram-P4PSJMXO-BVyP7nwq.js +24 -0
  229. package/web/dist/assets/erDiagram-INFDFZHY-NorKdTOF.js +70 -0
  230. package/web/dist/assets/error-CGD5mp5f.js +1 -0
  231. package/web/dist/assets/flowDiagram-PKNHOUZH-Ch97nABF.js +162 -0
  232. package/web/dist/assets/ganttDiagram-A5KZAMGK-BQ2pLWsy.js +292 -0
  233. package/web/dist/assets/gitGraphDiagram-K3NZZRJ6-bcvnBsD2.js +65 -0
  234. package/web/dist/assets/graph-CeAEckur.js +1 -0
  235. package/web/dist/assets/index-CPnL1_qC.js +768 -0
  236. package/web/dist/assets/index-DVevCbcO.css +10 -0
  237. package/web/dist/assets/infoDiagram-LFFYTUFH-CcsrFdj-.js +2 -0
  238. package/web/dist/assets/init-Dmth1JHB.js +1 -0
  239. package/web/dist/assets/ishikawaDiagram-PHBUUO56-1upyMfHN.js +70 -0
  240. package/web/dist/assets/journeyDiagram-4ABVD52K-CKUi-V0c.js +139 -0
  241. package/web/dist/assets/kanban-definition-K7BYSVSG-DOnQwXfL.js +89 -0
  242. package/web/dist/assets/layout-BmMMqTnJ.js +1 -0
  243. package/web/dist/assets/linear-DiaJloY5.js +1 -0
  244. package/web/dist/assets/mermaid.core-BWLV1B2v.js +254 -0
  245. package/web/dist/assets/mindmap-definition-YRQLILUH-BeAKHVWP.js +68 -0
  246. package/web/dist/assets/ordinal-DILIJJjt.js +1 -0
  247. package/web/dist/assets/pieDiagram-SKSYHLDU-DfiMSfWo.js +30 -0
  248. package/web/dist/assets/quadrantDiagram-337W2JSQ-wZxZOJxd.js +7 -0
  249. package/web/dist/assets/requirementDiagram-Z7DCOOCP-BK4HHm17.js +73 -0
  250. package/web/dist/assets/sankeyDiagram-WA2Y5GQK-BX6t2avX.js +10 -0
  251. package/web/dist/assets/sequenceDiagram-2WXFIKYE-BPQlkbAa.js +145 -0
  252. package/web/dist/assets/sheet-rI0FfB1g.js +6 -0
  253. package/web/dist/assets/sliders-horizontal-CuijWFNK.js +6 -0
  254. package/web/dist/assets/sparkles-BsMYXJoT.js +11 -0
  255. package/web/dist/assets/square-0CqMX1Q3.js +11 -0
  256. package/web/dist/assets/stateDiagram-RAJIS63D-DxkV0Vwd.js +1 -0
  257. package/web/dist/assets/stateDiagram-v2-FVOUBMTO-qLYoiOPe.js +1 -0
  258. package/web/dist/assets/step-D51IIHGA.js +1 -0
  259. package/web/dist/assets/tasks-D8JjBTwx.js +1 -0
  260. package/web/dist/assets/time-O8zIGux3.js +1 -0
  261. package/web/dist/assets/timeline-definition-YZTLITO2-kNp1DyFc.js +61 -0
  262. package/web/dist/assets/treemap-KZPCXAKY-CkrClVhk.js +162 -0
  263. package/web/dist/assets/utils-KGAn0XTg.js +11 -0
  264. package/web/dist/assets/vennDiagram-LZ73GAT5-CgdzEZz4.js +34 -0
  265. package/web/dist/assets/xychartDiagram-JWTSCODW-DfYGPfNB.js +7 -0
  266. package/web/dist/assets/zap-_hKJYy7J.js +6 -0
  267. package/web/dist/favicon.svg +332 -0
  268. package/web/dist/fonts/AlibabaPuHuiTi-3-55-Regular.woff2 +0 -0
  269. package/web/dist/fonts/AlibabaPuHuiTi-3-65-Medium.woff2 +0 -0
  270. package/web/dist/fonts/AlibabaPuHuiTi-3-75-SemiBold.woff2 +0 -0
  271. package/web/dist/fonts/DMSans-latin-ext.woff2 +0 -0
  272. package/web/dist/fonts/DMSans-latin.woff2 +0 -0
  273. package/web/dist/icons/README.md +20 -0
  274. package/web/dist/icons/apple-touch-icon-180.png +0 -0
  275. package/web/dist/icons/icon-128.png +0 -0
  276. package/web/dist/icons/icon-144.png +0 -0
  277. package/web/dist/icons/icon-152.png +0 -0
  278. package/web/dist/icons/icon-192.png +0 -0
  279. package/web/dist/icons/icon-192.svg +332 -0
  280. package/web/dist/icons/icon-384.png +0 -0
  281. package/web/dist/icons/icon-48.png +0 -0
  282. package/web/dist/icons/icon-512-maskable.png +0 -0
  283. package/web/dist/icons/icon-512.png +0 -0
  284. package/web/dist/icons/icon-512.svg +332 -0
  285. package/web/dist/icons/icon-72.png +0 -0
  286. package/web/dist/icons/icon-96.png +0 -0
  287. package/web/dist/icons/loading-logo.svg +332 -0
  288. package/web/dist/icons/logo-1024.png +0 -0
  289. package/web/dist/icons/logo-icon.svg +332 -0
  290. package/web/dist/icons/logo-text.svg +332 -0
  291. package/web/dist/index.html +30 -0
  292. package/web/dist/manifest.webmanifest +1 -0
  293. package/web/dist/registerSW.js +1 -0
  294. package/web/dist/sw.js +1 -0
  295. package/web/dist/workbox-08d6266a.js +1 -0
@@ -0,0 +1,185 @@
1
+ const CLAUDE_MODEL_PRESETS = [
2
+ 'opus[1m]',
3
+ 'opus',
4
+ 'sonnet[1m]',
5
+ 'sonnet',
6
+ 'haiku',
7
+ ];
8
+ const CODEX_MODEL_PRESETS = ['gpt-5.4', 'gpt-5.4-mini'];
9
+ const REASONING_EFFORT_PRESETS = [
10
+ 'low',
11
+ 'medium',
12
+ 'high',
13
+ 'xhigh',
14
+ ];
15
+ export const RUNTIME_COMMANDS = [
16
+ {
17
+ name: 'help',
18
+ usage: '/help',
19
+ description: '查看当前入口可用命令',
20
+ availableEntrypoints: ['im', 'web'],
21
+ availabilityByRuntime: 'all',
22
+ },
23
+ {
24
+ name: 'clear',
25
+ usage: '/clear',
26
+ description: '清除当前工作区或会话上下文',
27
+ availableEntrypoints: ['im', 'web'],
28
+ availabilityByRuntime: 'all',
29
+ },
30
+ {
31
+ name: 'list',
32
+ aliases: ['ls'],
33
+ usage: '/list',
34
+ description: '查看当前用户可访问的工作区与对话',
35
+ availableEntrypoints: ['im'],
36
+ availabilityByRuntime: 'all',
37
+ },
38
+ {
39
+ name: 'status',
40
+ usage: '/status',
41
+ description: '查看当前工作区和运行状态摘要',
42
+ availableEntrypoints: ['im'],
43
+ availabilityByRuntime: 'all',
44
+ },
45
+ {
46
+ name: 'recall',
47
+ aliases: ['rc'],
48
+ usage: '/recall',
49
+ description: '回顾当前工作区最近消息',
50
+ availableEntrypoints: ['im'],
51
+ availabilityByRuntime: 'all',
52
+ },
53
+ {
54
+ name: 'where',
55
+ usage: '/where',
56
+ description: '查看当前聊天绑定位置',
57
+ availableEntrypoints: ['im'],
58
+ availabilityByRuntime: 'all',
59
+ },
60
+ {
61
+ name: 'bind',
62
+ usage: '/bind <workspace>',
63
+ description: '绑定到指定工作区或会话',
64
+ availableEntrypoints: ['im'],
65
+ availabilityByRuntime: 'all',
66
+ },
67
+ {
68
+ name: 'unbind',
69
+ usage: '/unbind',
70
+ description: '解除当前绑定',
71
+ availableEntrypoints: ['im'],
72
+ availabilityByRuntime: 'all',
73
+ },
74
+ {
75
+ name: 'new',
76
+ usage: '/new <名称>',
77
+ description: '创建新工作区并绑定过去',
78
+ availableEntrypoints: ['im'],
79
+ availabilityByRuntime: 'all',
80
+ },
81
+ {
82
+ name: 'require_mention',
83
+ usage: '/require_mention true|false',
84
+ description: '控制群聊中是否必须 @机器人',
85
+ availableEntrypoints: ['im'],
86
+ availabilityByRuntime: 'all',
87
+ },
88
+ {
89
+ name: 'sw',
90
+ aliases: ['spawn'],
91
+ usage: '/sw <任务描述>',
92
+ description: '创建并行任务',
93
+ availableEntrypoints: ['im', 'web'],
94
+ availabilityByRuntime: 'all',
95
+ },
96
+ {
97
+ name: 'model',
98
+ usage: '/model <preset>',
99
+ description: '切换当前工作区模型预设',
100
+ availableEntrypoints: ['im', 'web'],
101
+ availabilityByRuntime: 'all',
102
+ },
103
+ {
104
+ name: 'effort',
105
+ usage: '/effort <low|medium|high|xhigh>',
106
+ description: '切换当前工作区思考强度',
107
+ availableEntrypoints: ['im', 'web'],
108
+ availabilityByRuntime: ['codex'],
109
+ },
110
+ ];
111
+ function normalizeText(value) {
112
+ return value.trim().toLowerCase();
113
+ }
114
+ export function supportsReasoningEffort(agentType) {
115
+ return agentType === 'codex';
116
+ }
117
+ export function getModelPresets(agentType) {
118
+ return agentType === 'codex'
119
+ ? [...CODEX_MODEL_PRESETS]
120
+ : [...CLAUDE_MODEL_PRESETS];
121
+ }
122
+ export function getReasoningEffortPresets() {
123
+ return [...REASONING_EFFORT_PRESETS];
124
+ }
125
+ export function normalizeModelPreset(agentType, rawValue) {
126
+ const normalized = normalizeText(rawValue);
127
+ const matched = getModelPresets(agentType).find((preset) => preset.toLowerCase() === normalized);
128
+ return matched ?? null;
129
+ }
130
+ export function normalizeReasoningEffortPreset(rawValue) {
131
+ const normalized = normalizeText(rawValue);
132
+ return REASONING_EFFORT_PRESETS.find((preset) => preset === normalized) ?? null;
133
+ }
134
+ function isCommandAvailableForAgent(command, agentType) {
135
+ if (command.availabilityByRuntime === 'all' ||
136
+ !command.availabilityByRuntime) {
137
+ return true;
138
+ }
139
+ return command.availabilityByRuntime.includes(agentType);
140
+ }
141
+ export function findRuntimeCommand(rawName) {
142
+ const normalized = normalizeText(rawName);
143
+ if (!normalized)
144
+ return null;
145
+ return (RUNTIME_COMMANDS.find((command) => {
146
+ if (command.name === normalized)
147
+ return true;
148
+ return command.aliases?.some((alias) => alias === normalized);
149
+ }) ?? null);
150
+ }
151
+ export function parseRuntimeCommand(text) {
152
+ const trimmed = text.trim();
153
+ const body = trimmed.startsWith('/') ? trimmed.slice(1).trim() : trimmed;
154
+ if (!body)
155
+ return null;
156
+ const [rawName = '', ...args] = body.split(/\s+/);
157
+ const command = findRuntimeCommand(rawName);
158
+ if (!command)
159
+ return null;
160
+ return {
161
+ rawName,
162
+ name: command.name,
163
+ argsText: body.slice(rawName.length).trim(),
164
+ args,
165
+ };
166
+ }
167
+ export function isCommandAvailable(options) {
168
+ const command = findRuntimeCommand(options.commandName);
169
+ if (!command)
170
+ return false;
171
+ return (command.availableEntrypoints.includes(options.entrypoint) &&
172
+ isCommandAvailableForAgent(command, options.agentType));
173
+ }
174
+ export function getAvailableCommands(options) {
175
+ return RUNTIME_COMMANDS.filter((command) => command.availableEntrypoints.includes(options.entrypoint) &&
176
+ isCommandAvailableForAgent(command, options.agentType));
177
+ }
178
+ export function formatCommandHelp(options) {
179
+ const commands = getAvailableCommands(options);
180
+ const lines = ['可用命令:'];
181
+ for (const command of commands) {
182
+ lines.push(`- ${command.usage}:${command.description}`);
183
+ }
184
+ return lines.join('\n');
185
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Canonical StreamEvent type definitions.
3
+ *
4
+ * This is the single source of truth.
5
+ * Build step compiles this file to shared/dist/stream-event.{js,d.ts},
6
+ * and each runtime consumes those types through thin local wrappers.
7
+ */
8
+ export type StreamEventType = 'text_delta' | 'thinking_delta' | 'tool_use_start' | 'tool_use_end' | 'tool_progress' | 'hook_started' | 'hook_progress' | 'hook_response' | 'task_start' | 'task_notification' | 'todo_update' | 'usage' | 'status' | 'init';
9
+ export interface StreamRuntimeIdentity {
10
+ agentType: 'claude' | 'codex';
11
+ model?: string | null;
12
+ reasoningEffort?: string | null;
13
+ supportsReasoningEffort?: boolean | null;
14
+ }
15
+ export interface StreamEvent {
16
+ eventType: StreamEventType;
17
+ /** Correlates all stream events for a single user turn. */
18
+ turnId?: string;
19
+ /** SDK session identifier if known. */
20
+ sessionId?: string;
21
+ /** SDK message uuid if known. */
22
+ messageUuid?: string;
23
+ /** Reserved — whether this event was synthesized locally rather than emitted directly by SDK semantics. */
24
+ isSynthetic?: boolean;
25
+ text?: string;
26
+ toolName?: string;
27
+ toolUseId?: string;
28
+ parentToolUseId?: string | null;
29
+ isNested?: boolean;
30
+ skillName?: string;
31
+ toolInputSummary?: string;
32
+ elapsedSeconds?: number;
33
+ hookName?: string;
34
+ hookEvent?: string;
35
+ hookOutcome?: string;
36
+ statusText?: string;
37
+ taskDescription?: string;
38
+ taskId?: string;
39
+ taskStatus?: string;
40
+ taskSummary?: string;
41
+ isBackground?: boolean;
42
+ isTeammate?: boolean;
43
+ runtimeIdentity?: StreamRuntimeIdentity | null;
44
+ toolInput?: Record<string, unknown>;
45
+ todos?: Array<{
46
+ id: string;
47
+ content: string;
48
+ status: 'pending' | 'in_progress' | 'completed';
49
+ }>;
50
+ /** Token usage data emitted at query completion */
51
+ usage?: {
52
+ inputTokens: number;
53
+ outputTokens: number;
54
+ cacheReadInputTokens: number;
55
+ cacheCreationInputTokens: number;
56
+ costUSD: number;
57
+ durationMs: number;
58
+ numTurns: number;
59
+ modelUsage?: Record<string, {
60
+ inputTokens: number;
61
+ outputTokens: number;
62
+ costUSD: number;
63
+ }>;
64
+ };
65
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Canonical StreamEvent type definitions.
3
+ *
4
+ * This is the single source of truth.
5
+ * Build step compiles this file to shared/dist/stream-event.{js,d.ts},
6
+ * and each runtime consumes those types through thin local wrappers.
7
+ */
8
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface ToolStepDisplayOptions {
2
+ maxSummaryChars?: number;
3
+ }
4
+ export declare function formatToolStepLine(toolName: string, summary?: string | null, options?: ToolStepDisplayOptions): string;
@@ -0,0 +1,11 @@
1
+ export function formatToolStepLine(toolName, summary, options) {
2
+ const normalizedName = toolName.trim() || 'unknown';
3
+ const normalizedSummary = (summary || '').trim();
4
+ if (!normalizedSummary)
5
+ return normalizedName;
6
+ const maxSummaryChars = options?.maxSummaryChars ?? 60;
7
+ const compactSummary = normalizedSummary.length > maxSummaryChars
8
+ ? `${normalizedSummary.slice(0, maxSummaryChars)}...`
9
+ : normalizedSummary;
10
+ return `${normalizedName} · ${compactSummary}`;
11
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Detect image MIME type from buffer magic bytes.
3
+ * Canonical source — synced to src/ and container/agent-runner/src/ via make sync-types.
4
+ *
5
+ * Returns the detected MIME type or null if unknown.
6
+ */
7
+ export function detectImageMimeTypeStrict(buffer: Buffer): string | null {
8
+ if (buffer.length < 12) {
9
+ return null;
10
+ }
11
+
12
+ // PNG: 89 50 4E 47 0D 0A 1A 0A
13
+ if (
14
+ buffer[0] === 0x89 &&
15
+ buffer[1] === 0x50 &&
16
+ buffer[2] === 0x4e &&
17
+ buffer[3] === 0x47 &&
18
+ buffer[4] === 0x0d &&
19
+ buffer[5] === 0x0a &&
20
+ buffer[6] === 0x1a &&
21
+ buffer[7] === 0x0a
22
+ ) {
23
+ return 'image/png';
24
+ }
25
+
26
+ // JPEG: FF D8 FF
27
+ if (buffer[0] === 0xff && buffer[1] === 0xd8 && buffer[2] === 0xff) {
28
+ return 'image/jpeg';
29
+ }
30
+
31
+ // GIF: 47 49 46 38
32
+ if (
33
+ buffer[0] === 0x47 &&
34
+ buffer[1] === 0x49 &&
35
+ buffer[2] === 0x46 &&
36
+ buffer[3] === 0x38
37
+ ) {
38
+ return 'image/gif';
39
+ }
40
+
41
+ // WebP: RIFF....WEBP
42
+ if (
43
+ buffer[0] === 0x52 &&
44
+ buffer[1] === 0x49 &&
45
+ buffer[2] === 0x46 &&
46
+ buffer[3] === 0x46 &&
47
+ buffer.length >= 12 &&
48
+ buffer[8] === 0x57 &&
49
+ buffer[9] === 0x45 &&
50
+ buffer[10] === 0x42 &&
51
+ buffer[11] === 0x50
52
+ ) {
53
+ return 'image/webp';
54
+ }
55
+
56
+ // TIFF: 49 49 2A 00 (little-endian) or 4D 4D 00 2A (big-endian)
57
+ if (
58
+ (buffer[0] === 0x49 &&
59
+ buffer[1] === 0x49 &&
60
+ buffer[2] === 0x2a &&
61
+ buffer[3] === 0x00) ||
62
+ (buffer[0] === 0x4d &&
63
+ buffer[1] === 0x4d &&
64
+ buffer[2] === 0x00 &&
65
+ buffer[3] === 0x2a)
66
+ ) {
67
+ return 'image/tiff';
68
+ }
69
+
70
+ // AVIF: ....ftypavif or ....ftypavis
71
+ if (buffer.length >= 12) {
72
+ const ftyp = buffer.toString('ascii', 4, 8);
73
+ if (ftyp === 'ftyp') {
74
+ const brand = buffer.toString('ascii', 8, 12);
75
+ if (brand === 'avif' || brand === 'avis') {
76
+ return 'image/avif';
77
+ }
78
+ }
79
+ }
80
+
81
+ // BMP: 42 4D
82
+ if (buffer[0] === 0x42 && buffer[1] === 0x4d) {
83
+ return 'image/bmp';
84
+ }
85
+
86
+ return null;
87
+ }
88
+
89
+ /**
90
+ * Detect image MIME type from buffer magic bytes with fallback.
91
+ */
92
+ export function detectImageMimeType(buffer: Buffer): string {
93
+ return detectImageMimeTypeStrict(buffer) || 'image/jpeg';
94
+ }
95
+
96
+ /**
97
+ * Detect image MIME type from base64 payload (using header bytes only).
98
+ * Returns detected MIME or null if unknown/invalid.
99
+ */
100
+ export function detectImageMimeTypeFromBase64Strict(
101
+ base64Data: string,
102
+ ): string | null {
103
+ try {
104
+ const header = Buffer.from(base64Data.slice(0, 400), 'base64');
105
+ return detectImageMimeTypeStrict(header);
106
+ } catch {
107
+ return null;
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Detect image MIME type from base64 payload with fallback.
113
+ */
114
+ export function detectImageMimeTypeFromBase64(base64Data: string): string {
115
+ return detectImageMimeTypeFromBase64Strict(base64Data) || 'image/jpeg';
116
+ }
@@ -0,0 +1,252 @@
1
+ export type RuntimeAgentType = 'claude' | 'codex';
2
+ export type RuntimeCommandEntrypoint = 'im' | 'web';
3
+ export type ReasoningEffortPreset = 'low' | 'medium' | 'high' | 'xhigh';
4
+
5
+ const CLAUDE_MODEL_PRESETS = [
6
+ 'opus[1m]',
7
+ 'opus',
8
+ 'sonnet[1m]',
9
+ 'sonnet',
10
+ 'haiku',
11
+ ] as const;
12
+
13
+ const CODEX_MODEL_PRESETS = ['gpt-5.4', 'gpt-5.4-mini'] as const;
14
+
15
+ const REASONING_EFFORT_PRESETS = [
16
+ 'low',
17
+ 'medium',
18
+ 'high',
19
+ 'xhigh',
20
+ ] as const;
21
+
22
+ export interface RuntimeCommandDefinition {
23
+ name: string;
24
+ aliases?: string[];
25
+ usage: string;
26
+ description: string;
27
+ availableEntrypoints: RuntimeCommandEntrypoint[];
28
+ availabilityByRuntime?: RuntimeAgentType[] | 'all';
29
+ }
30
+
31
+ export interface ParsedRuntimeCommand {
32
+ rawName: string;
33
+ name: string;
34
+ argsText: string;
35
+ args: string[];
36
+ }
37
+
38
+ export const RUNTIME_COMMANDS: RuntimeCommandDefinition[] = [
39
+ {
40
+ name: 'help',
41
+ usage: '/help',
42
+ description: '查看当前入口可用命令',
43
+ availableEntrypoints: ['im', 'web'],
44
+ availabilityByRuntime: 'all',
45
+ },
46
+ {
47
+ name: 'clear',
48
+ usage: '/clear',
49
+ description: '清除当前工作区或会话上下文',
50
+ availableEntrypoints: ['im', 'web'],
51
+ availabilityByRuntime: 'all',
52
+ },
53
+ {
54
+ name: 'list',
55
+ aliases: ['ls'],
56
+ usage: '/list',
57
+ description: '查看当前用户可访问的工作区与对话',
58
+ availableEntrypoints: ['im'],
59
+ availabilityByRuntime: 'all',
60
+ },
61
+ {
62
+ name: 'status',
63
+ usage: '/status',
64
+ description: '查看当前工作区和运行状态摘要',
65
+ availableEntrypoints: ['im'],
66
+ availabilityByRuntime: 'all',
67
+ },
68
+ {
69
+ name: 'recall',
70
+ aliases: ['rc'],
71
+ usage: '/recall',
72
+ description: '回顾当前工作区最近消息',
73
+ availableEntrypoints: ['im'],
74
+ availabilityByRuntime: 'all',
75
+ },
76
+ {
77
+ name: 'where',
78
+ usage: '/where',
79
+ description: '查看当前聊天绑定位置',
80
+ availableEntrypoints: ['im'],
81
+ availabilityByRuntime: 'all',
82
+ },
83
+ {
84
+ name: 'bind',
85
+ usage: '/bind <workspace>',
86
+ description: '绑定到指定工作区或会话',
87
+ availableEntrypoints: ['im'],
88
+ availabilityByRuntime: 'all',
89
+ },
90
+ {
91
+ name: 'unbind',
92
+ usage: '/unbind',
93
+ description: '解除当前绑定',
94
+ availableEntrypoints: ['im'],
95
+ availabilityByRuntime: 'all',
96
+ },
97
+ {
98
+ name: 'new',
99
+ usage: '/new <名称>',
100
+ description: '创建新工作区并绑定过去',
101
+ availableEntrypoints: ['im'],
102
+ availabilityByRuntime: 'all',
103
+ },
104
+ {
105
+ name: 'require_mention',
106
+ usage: '/require_mention true|false',
107
+ description: '控制群聊中是否必须 @机器人',
108
+ availableEntrypoints: ['im'],
109
+ availabilityByRuntime: 'all',
110
+ },
111
+ {
112
+ name: 'sw',
113
+ aliases: ['spawn'],
114
+ usage: '/sw <任务描述>',
115
+ description: '创建并行任务',
116
+ availableEntrypoints: ['im', 'web'],
117
+ availabilityByRuntime: 'all',
118
+ },
119
+ {
120
+ name: 'model',
121
+ usage: '/model <preset>',
122
+ description: '切换当前工作区模型预设',
123
+ availableEntrypoints: ['im', 'web'],
124
+ availabilityByRuntime: 'all',
125
+ },
126
+ {
127
+ name: 'effort',
128
+ usage: '/effort <low|medium|high|xhigh>',
129
+ description: '切换当前工作区思考强度',
130
+ availableEntrypoints: ['im', 'web'],
131
+ availabilityByRuntime: ['codex'],
132
+ },
133
+ ];
134
+
135
+ function normalizeText(value: string): string {
136
+ return value.trim().toLowerCase();
137
+ }
138
+
139
+ export function supportsReasoningEffort(
140
+ agentType: RuntimeAgentType,
141
+ ): boolean {
142
+ return agentType === 'codex';
143
+ }
144
+
145
+ export function getModelPresets(agentType: RuntimeAgentType): string[] {
146
+ return agentType === 'codex'
147
+ ? [...CODEX_MODEL_PRESETS]
148
+ : [...CLAUDE_MODEL_PRESETS];
149
+ }
150
+
151
+ export function getReasoningEffortPresets(): ReasoningEffortPreset[] {
152
+ return [...REASONING_EFFORT_PRESETS];
153
+ }
154
+
155
+ export function normalizeModelPreset(
156
+ agentType: RuntimeAgentType,
157
+ rawValue: string,
158
+ ): string | null {
159
+ const normalized = normalizeText(rawValue);
160
+ const matched = getModelPresets(agentType).find(
161
+ (preset) => preset.toLowerCase() === normalized,
162
+ );
163
+ return matched ?? null;
164
+ }
165
+
166
+ export function normalizeReasoningEffortPreset(
167
+ rawValue: string,
168
+ ): ReasoningEffortPreset | null {
169
+ const normalized = normalizeText(rawValue);
170
+ return REASONING_EFFORT_PRESETS.find((preset) => preset === normalized) ?? null;
171
+ }
172
+
173
+ function isCommandAvailableForAgent(
174
+ command: RuntimeCommandDefinition,
175
+ agentType: RuntimeAgentType,
176
+ ): boolean {
177
+ if (
178
+ command.availabilityByRuntime === 'all' ||
179
+ !command.availabilityByRuntime
180
+ ) {
181
+ return true;
182
+ }
183
+ return command.availabilityByRuntime.includes(agentType);
184
+ }
185
+
186
+ export function findRuntimeCommand(
187
+ rawName: string,
188
+ ): RuntimeCommandDefinition | null {
189
+ const normalized = normalizeText(rawName);
190
+ if (!normalized) return null;
191
+ return (
192
+ RUNTIME_COMMANDS.find((command) => {
193
+ if (command.name === normalized) return true;
194
+ return command.aliases?.some((alias) => alias === normalized);
195
+ }) ?? null
196
+ );
197
+ }
198
+
199
+ export function parseRuntimeCommand(
200
+ text: string,
201
+ ): ParsedRuntimeCommand | null {
202
+ const trimmed = text.trim();
203
+ const body = trimmed.startsWith('/') ? trimmed.slice(1).trim() : trimmed;
204
+ if (!body) return null;
205
+
206
+ const [rawName = '', ...args] = body.split(/\s+/);
207
+ const command = findRuntimeCommand(rawName);
208
+ if (!command) return null;
209
+
210
+ return {
211
+ rawName,
212
+ name: command.name,
213
+ argsText: body.slice(rawName.length).trim(),
214
+ args,
215
+ };
216
+ }
217
+
218
+ export function isCommandAvailable(options: {
219
+ commandName: string;
220
+ entrypoint: RuntimeCommandEntrypoint;
221
+ agentType: RuntimeAgentType;
222
+ }): boolean {
223
+ const command = findRuntimeCommand(options.commandName);
224
+ if (!command) return false;
225
+ return (
226
+ command.availableEntrypoints.includes(options.entrypoint) &&
227
+ isCommandAvailableForAgent(command, options.agentType)
228
+ );
229
+ }
230
+
231
+ export function getAvailableCommands(options: {
232
+ entrypoint: RuntimeCommandEntrypoint;
233
+ agentType: RuntimeAgentType;
234
+ }): RuntimeCommandDefinition[] {
235
+ return RUNTIME_COMMANDS.filter(
236
+ (command) =>
237
+ command.availableEntrypoints.includes(options.entrypoint) &&
238
+ isCommandAvailableForAgent(command, options.agentType),
239
+ );
240
+ }
241
+
242
+ export function formatCommandHelp(options: {
243
+ entrypoint: RuntimeCommandEntrypoint;
244
+ agentType: RuntimeAgentType;
245
+ }): string {
246
+ const commands = getAvailableCommands(options);
247
+ const lines = ['可用命令:'];
248
+ for (const command of commands) {
249
+ lines.push(`- ${command.usage}:${command.description}`);
250
+ }
251
+ return lines.join('\n');
252
+ }