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,6 @@
1
+ /**
2
+ * Shared types for cli-claw Agent Runner.
3
+ *
4
+ * These types are used across index.ts, stream-processor.ts, and mcp-tools.ts.
5
+ */
6
+ export {};
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Utility functions for cli-claw Agent Runner.
3
+ *
4
+ * Pure utility functions with no side effects or state dependencies.
5
+ */
6
+ /**
7
+ * Shorten a string to maxLen, appending "..." if truncated.
8
+ */
9
+ export function shorten(input, maxLen = 180) {
10
+ if (input.length <= maxLen)
11
+ return input;
12
+ return `${input.slice(0, maxLen)}...`;
13
+ }
14
+ /**
15
+ * Recursively redact sensitive fields (tokens, passwords, API keys, etc.)
16
+ * from an object. Limits recursion depth to 3 levels.
17
+ */
18
+ export function redactSensitive(input, depth = 0) {
19
+ if (depth > 3)
20
+ return '[truncated]';
21
+ if (input == null)
22
+ return input;
23
+ if (typeof input === 'string' || typeof input === 'number' || typeof input === 'boolean') {
24
+ return input;
25
+ }
26
+ if (Array.isArray(input)) {
27
+ return input.slice(0, 10).map((item) => redactSensitive(item, depth + 1));
28
+ }
29
+ if (typeof input === 'object') {
30
+ const obj = input;
31
+ const out = {};
32
+ for (const [k, v] of Object.entries(obj)) {
33
+ if (/(token|password|secret|api[_-]?key|authorization|cookie)/iu.test(k)) {
34
+ out[k] = '[REDACTED]';
35
+ }
36
+ else {
37
+ out[k] = redactSensitive(v, depth + 1);
38
+ }
39
+ }
40
+ return out;
41
+ }
42
+ return '[unsupported]';
43
+ }
44
+ /**
45
+ * Summarize tool input for display in stream events.
46
+ * Extracts key fields (command, query, path, etc.) or serializes the object.
47
+ */
48
+ export function summarizeToolInput(input) {
49
+ if (input == null)
50
+ return undefined;
51
+ if (typeof input === 'string') {
52
+ return shorten(input.trim());
53
+ }
54
+ if (typeof input === 'object') {
55
+ const obj = input;
56
+ const keyCandidates = ['command', 'query', 'path', 'pattern', 'prompt', 'url', 'name'];
57
+ for (const key of keyCandidates) {
58
+ const value = obj[key];
59
+ if (typeof value === 'string' && value.trim()) {
60
+ return `${key}: ${shorten(value.trim())}`;
61
+ }
62
+ }
63
+ try {
64
+ const json = JSON.stringify(redactSensitive(obj));
65
+ // Skip empty or trivial objects (e.g. {} at content_block_start)
66
+ if (!json || json === '{}' || json === '[]')
67
+ return undefined;
68
+ return shorten(json);
69
+ }
70
+ catch {
71
+ return undefined;
72
+ }
73
+ }
74
+ return undefined;
75
+ }
76
+ /**
77
+ * Extract a skill name from Skill tool input.
78
+ * Tries skillName, skill, name, command fields, then regex-matches leading slashes.
79
+ */
80
+ export function extractSkillName(toolName, input) {
81
+ if (toolName !== 'Skill')
82
+ return undefined;
83
+ if (!input || typeof input !== 'object')
84
+ return undefined;
85
+ const obj = input;
86
+ const raw = (typeof obj.skillName === 'string' && obj.skillName) ||
87
+ (typeof obj.skill === 'string' && obj.skill) ||
88
+ (typeof obj.name === 'string' && obj.name) ||
89
+ (typeof obj.command === 'string' && obj.command) ||
90
+ '';
91
+ if (!raw)
92
+ return undefined;
93
+ const matched = raw.match(/\/([A-Za-z0-9._-]+)/);
94
+ if (matched && matched[1])
95
+ return matched[1];
96
+ return raw.replace(/^\/+/, '').trim() || undefined;
97
+ }
98
+ /**
99
+ * Sanitize a string for use as a filename.
100
+ * Lowercases, replaces non-alphanumeric characters with hyphens, trims, and limits length.
101
+ */
102
+ export function sanitizeFilename(summary) {
103
+ return summary
104
+ .toLowerCase()
105
+ .replace(/[^\p{L}\p{N}]+/gu, '-')
106
+ .replace(/^-+|-+$/g, '')
107
+ .slice(0, 50);
108
+ }
109
+ /**
110
+ * Generate a fallback conversation archive filename based on current time.
111
+ */
112
+ export function generateFallbackName() {
113
+ const time = new Date();
114
+ return `conversation-${time.getHours().toString().padStart(2, '0')}${time.getMinutes().toString().padStart(2, '0')}`;
115
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "cli-claw-agent-runner",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Container-side agent runner for cli-claw",
6
+ "main": "dist/index.js",
7
+ "scripts": {
8
+ "build": "npm run build:shared && npm run build:runner",
9
+ "start": "node dist/index.js",
10
+ "build:shared": "tsc -p ../../shared/tsconfig.json",
11
+ "build:runner": "tsc"
12
+ },
13
+ "dependencies": {
14
+ "@agentclientprotocol/sdk": "^0.18.0",
15
+ "@anthropic-ai/claude-agent-sdk": "*",
16
+ "cron-parser": "^5.0.0",
17
+ "zod": "^4.0.0"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^22.10.7",
21
+ "typescript": "^5.9.3"
22
+ },
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/RyanProMax/cli-claw.git",
27
+ "directory": "container/agent-runner"
28
+ },
29
+ "author": "riba2534",
30
+ "keywords": [
31
+ "claude-agent-sdk",
32
+ "agent-runner",
33
+ "mcp",
34
+ "cli-claw"
35
+ ]
36
+ }
@@ -0,0 +1,31 @@
1
+ ## 安全守则
2
+
3
+ ### 红线操作(必须暂停并请求用户确认)
4
+
5
+ 以下操作在执行前**必须**向用户说明意图并获得明确批准,绝不可静默执行:
6
+
7
+ - **破坏性命令**:`rm -rf /`、`rm -rf ~`、`mkfs`、`dd if=`、`wipefs`、批量删除系统文件
8
+ - **凭据/认证篡改**:修改 `authorized_keys`、`sshd_config`、`passwd`、`.gnupg/` 下的文件
9
+ - **数据外泄**:将 token、API key、密码、私钥通过 `curl`、`wget`、`nc`、`scp`、`rsync` 发送到外部地址
10
+ - **持久化机制**:`crontab -e`、`useradd`/`usermod`、创建 systemd 服务、修改 `/etc/rc.local`
11
+ - **远程代码执行**:`curl | sh`、`wget | bash`、`eval "$(curl ...)"`、`base64 -d | bash`、可疑的 `$()` 链式替换
12
+ - **私钥与助记词**:绝不主动索要用户的加密货币私钥或助记词明文,绝不将已知的密钥信息写入日志或发送到外部
13
+
14
+ ### 黄线操作(可执行,但必须记录到日期记忆)
15
+
16
+ 以下操作执行后,如有 `memory_append` 工具可用,使用它记录时间、命令、原因和结果:
17
+
18
+ - 所有 `sudo` 命令
19
+ - 全局包安装(`pip install`、`npm install -g`)
20
+ - Docker 容器操作(`docker run`、`docker exec`)
21
+ - 防火墙规则变更(`iptables`、`ufw`)
22
+ - PM2 进程管理(启动/停止/删除进程)
23
+ - 系统服务管理(`systemctl start/stop/restart`)
24
+
25
+ ### Skill / MCP 安装审查
26
+
27
+ 安装任何外部 Skill 或 MCP Server 前,必须:
28
+
29
+ 1. 检查源代码,扫描是否包含可疑指令(`curl | sh`、环境变量读取如 `$ANTHROPIC_API_KEY`、文件外传)
30
+ 2. 确认不会修改 cli-claw 核心配置文件(`~/.cli-claw/config/`、`.claude/`)
31
+ 3. 向用户说明来源和风险评估,等待明确批准后再安装
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Predefined SubAgent definitions for cli-claw.
3
+ *
4
+ * These agents are registered via the SDK `agents` option in query(),
5
+ * making them available as Task tool targets within the agent session.
6
+ */
7
+
8
+ import type { AgentDefinition } from '@anthropic-ai/claude-agent-sdk';
9
+
10
+ export const PREDEFINED_AGENTS: Record<string, AgentDefinition> = {
11
+ 'code-reviewer': {
12
+ description: 'Code review agent that analyzes code quality, best practices, and potential issues',
13
+ prompt:
14
+ 'You are a strict code reviewer. Focus on correctness, security, performance, and maintainability. ' +
15
+ 'Point out specific issues with file:line references. Be concise and actionable.',
16
+ tools: ['Read', 'Glob', 'Grep'],
17
+ maxTurns: 15,
18
+ },
19
+ 'web-researcher': {
20
+ description: 'Web research agent that searches and extracts information from web pages',
21
+ prompt:
22
+ 'You are an efficient web researcher. Search for information, extract key facts, and summarize findings. ' +
23
+ 'Always cite sources with URLs. Prefer authoritative sources.',
24
+ tools: ['WebSearch', 'WebFetch', 'Read', 'Write'],
25
+ maxTurns: 20,
26
+ },
27
+ };
@@ -0,0 +1,16 @@
1
+ /** IM channel type → JID prefix mapping. Shared between main server and agent-runner. */
2
+ export const CHANNEL_PREFIXES: Record<string, string> = {
3
+ feishu: 'feishu:',
4
+ telegram: 'telegram:',
5
+ qq: 'qq:',
6
+ wechat: 'wechat:',
7
+ dingtalk: 'dingtalk:',
8
+ };
9
+
10
+ /** Determine the channel type from a JID string. Returns 'web' for unrecognized prefixes. */
11
+ export function getChannelFromJid(jid: string): string {
12
+ for (const [type, prefix] of Object.entries(CHANNEL_PREFIXES)) {
13
+ if (jid.startsWith(prefix)) return type;
14
+ }
15
+ return 'web';
16
+ }
@@ -0,0 +1,40 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+
5
+ export interface CodexCliConfig {
6
+ model: string | null;
7
+ reasoningEffort: string | null;
8
+ }
9
+
10
+ function normalizeTomlString(value: string | undefined): string | null {
11
+ if (!value) return null;
12
+ const trimmed = value.trim();
13
+ return trimmed || null;
14
+ }
15
+
16
+ function readTomlString(content: string, key: string): string | null {
17
+ const match = content.match(
18
+ new RegExp(`^${key}\\s*=\\s*["']([^"']+)["']\\s*$`, 'm'),
19
+ );
20
+ return normalizeTomlString(match?.[1]);
21
+ }
22
+
23
+ export function readCodexCliConfig(
24
+ configPath = path.join(os.homedir(), '.codex', 'config.toml'),
25
+ ): CodexCliConfig {
26
+ try {
27
+ if (!fs.existsSync(configPath)) {
28
+ return { model: null, reasoningEffort: null };
29
+ }
30
+ const content = fs.readFileSync(configPath, 'utf-8');
31
+ return {
32
+ model: readTomlString(content, 'model'),
33
+ reasoningEffort:
34
+ readTomlString(content, 'model_reasoning_effort') ??
35
+ readTomlString(content, 'reasoning_effort'),
36
+ };
37
+ } catch {
38
+ return { model: null, reasoningEffort: null };
39
+ }
40
+ }
@@ -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
+ }