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.
- package/LICENSE +21 -0
- package/README.md +245 -0
- package/config/default-groups.json +1 -0
- package/config/global-agents-md.template.md +37 -0
- package/config/mount-allowlist.json +11 -0
- package/container/Dockerfile +160 -0
- package/container/agent-runner/dist/.tsbuildinfo +1 -0
- package/container/agent-runner/dist/agent-definitions.js +22 -0
- package/container/agent-runner/dist/channel-prefixes.js +16 -0
- package/container/agent-runner/dist/codex-config.js +29 -0
- package/container/agent-runner/dist/image-detector.js +96 -0
- package/container/agent-runner/dist/index.js +2587 -0
- package/container/agent-runner/dist/mcp-tools.js +1076 -0
- package/container/agent-runner/dist/stream-event.types.js +5 -0
- package/container/agent-runner/dist/stream-processor.js +867 -0
- package/container/agent-runner/dist/types.js +6 -0
- package/container/agent-runner/dist/utils.js +115 -0
- package/container/agent-runner/package.json +36 -0
- package/container/agent-runner/prompts/security-rules.md +31 -0
- package/container/agent-runner/src/agent-definitions.ts +27 -0
- package/container/agent-runner/src/channel-prefixes.ts +16 -0
- package/container/agent-runner/src/codex-config.ts +40 -0
- package/container/agent-runner/src/image-detector.ts +116 -0
- package/container/agent-runner/src/index.ts +3107 -0
- package/container/agent-runner/src/mcp-tools.ts +1295 -0
- package/container/agent-runner/src/stream-event.types.ts +10 -0
- package/container/agent-runner/src/stream-processor.ts +932 -0
- package/container/agent-runner/src/types.ts +75 -0
- package/container/agent-runner/src/utils.ts +114 -0
- package/container/agent-runner/tsconfig.json +17 -0
- package/container/build.sh +28 -0
- package/container/entrypoint.sh +64 -0
- package/container/skills/agent-browser/SKILL.md +159 -0
- package/container/skills/install-skill/SKILL.md +64 -0
- package/container/skills/post-test-cleanup/SKILL.md +121 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/agent-output-parser.js +459 -0
- package/dist/app-root.js +52 -0
- package/dist/assistant-meta-footer.js +1 -0
- package/dist/auth.js +91 -0
- package/dist/billing.js +694 -0
- package/dist/channel-prefixes.js +16 -0
- package/dist/cli.js +86 -0
- package/dist/commands.js +79 -0
- package/dist/config.js +120 -0
- package/dist/container-runner.js +981 -0
- package/dist/daily-summary.js +210 -0
- package/dist/db.js +3683 -0
- package/dist/dingtalk.js +1347 -0
- package/dist/feishu-markdown-style.js +97 -0
- package/dist/feishu-streaming-card.js +1875 -0
- package/dist/feishu.js +1628 -0
- package/dist/file-manager.js +270 -0
- package/dist/group-queue.js +1070 -0
- package/dist/group-runtime.js +35 -0
- package/dist/host-workspace-cwd.js +85 -0
- package/dist/im-channel.js +384 -0
- package/dist/im-command-utils.js +142 -0
- package/dist/im-downloader.js +45 -0
- package/dist/im-manager.js +527 -0
- package/dist/im-utils.js +53 -0
- package/dist/image-detector.js +96 -0
- package/dist/index.js +5828 -0
- package/dist/logger.js +22 -0
- package/dist/mcp-utils.js +66 -0
- package/dist/message-attachments.js +69 -0
- package/dist/message-notifier.js +36 -0
- package/dist/middleware/auth.js +85 -0
- package/dist/mount-security.js +315 -0
- package/dist/permissions.js +67 -0
- package/dist/project-memory.js +6 -0
- package/dist/provider-pool.js +189 -0
- package/dist/qq.js +826 -0
- package/dist/reset-admin.js +42 -0
- package/dist/routes/admin.js +543 -0
- package/dist/routes/agent-definitions.js +241 -0
- package/dist/routes/agents.js +533 -0
- package/dist/routes/auth.js +675 -0
- package/dist/routes/billing.js +490 -0
- package/dist/routes/browse.js +210 -0
- package/dist/routes/bug-report.js +387 -0
- package/dist/routes/config.js +1868 -0
- package/dist/routes/files.js +671 -0
- package/dist/routes/groups.js +1367 -0
- package/dist/routes/mcp-servers.js +320 -0
- package/dist/routes/memory.js +523 -0
- package/dist/routes/monitor.js +307 -0
- package/dist/routes/skills.js +777 -0
- package/dist/routes/tasks.js +509 -0
- package/dist/routes/usage.js +64 -0
- package/dist/routes/workspace-config.js +458 -0
- package/dist/runtime-build.js +112 -0
- package/dist/runtime-command-handler.js +189 -0
- package/dist/runtime-command-registry.js +1 -0
- package/dist/runtime-config.js +1777 -0
- package/dist/runtime-identity.js +52 -0
- package/dist/schemas.js +590 -0
- package/dist/script-runner.js +64 -0
- package/dist/sdk-query.js +82 -0
- package/dist/skill-utils.js +145 -0
- package/dist/sqlite-compat.js +19 -0
- package/dist/stream-event.types.js +5 -0
- package/dist/streaming-runtime-meta.js +29 -0
- package/dist/task-scheduler.js +695 -0
- package/dist/task-utils.js +13 -0
- package/dist/telegram-pairing.js +59 -0
- package/dist/telegram.js +897 -0
- package/dist/terminal-manager.js +307 -0
- package/dist/tool-step-display.js +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.js +85 -0
- package/dist/web-context.js +161 -0
- package/dist/web.js +1377 -0
- package/dist/wechat-crypto.js +182 -0
- package/dist/wechat.js +589 -0
- package/dist/workspace-runtime-reset.js +35 -0
- package/package.json +107 -0
- package/shared/assistant-meta-footer.ts +127 -0
- package/shared/channel-prefixes.ts +16 -0
- package/shared/dist/assistant-meta-footer.d.ts +29 -0
- package/shared/dist/assistant-meta-footer.js +85 -0
- package/shared/dist/channel-prefixes.d.ts +4 -0
- package/shared/dist/channel-prefixes.js +16 -0
- package/shared/dist/image-detector.d.ts +20 -0
- package/shared/dist/image-detector.js +96 -0
- package/shared/dist/runtime-command-registry.d.ts +38 -0
- package/shared/dist/runtime-command-registry.js +185 -0
- package/shared/dist/stream-event.d.ts +65 -0
- package/shared/dist/stream-event.js +8 -0
- package/shared/dist/tool-step-display.d.ts +4 -0
- package/shared/dist/tool-step-display.js +11 -0
- package/shared/image-detector.ts +116 -0
- package/shared/runtime-command-registry.ts +252 -0
- package/shared/stream-event.ts +67 -0
- package/shared/tool-step-display.ts +21 -0
- package/shared/tsconfig.json +24 -0
- package/web/dist/assets/BillingPage-B1wBR_o-.js +52 -0
- package/web/dist/assets/ChatPage-6GBZ9nXN.css +32 -0
- package/web/dist/assets/ChatPage-BOJcXtaj.js +161 -0
- package/web/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/web/dist/assets/SettingsPage-DoY7FoZ_.js +153 -0
- package/web/dist/assets/ShareImageDialog-C1ga8b7l.js +22 -0
- package/web/dist/assets/TasksPage-CRivnNsx.js +14 -0
- package/web/dist/assets/_basePickBy-Bf-bSoS9.js +1 -0
- package/web/dist/assets/_baseUniq-zAOaCuKw.js +1 -0
- package/web/dist/assets/arc-Dm9mVQ9U.js +1 -0
- package/web/dist/assets/architectureDiagram-2XIMDMQ5-BLmzX1wr.js +36 -0
- package/web/dist/assets/band-CquvqAHh.js +1 -0
- package/web/dist/assets/blockDiagram-WCTKOSBZ-B9pcqm3j.js +132 -0
- package/web/dist/assets/c4Diagram-IC4MRINW-Cytx1q3b.js +10 -0
- package/web/dist/assets/channel-BOVj73LR.js +1 -0
- package/web/dist/assets/channel-meta-CQD0Pei-.js +41 -0
- package/web/dist/assets/chunk-4BX2VUAB-0ToDr6RE.js +1 -0
- package/web/dist/assets/chunk-55IACEB6-DQDjnXfS.js +1 -0
- package/web/dist/assets/chunk-FMBD7UC4-Di8ABm6c.js +15 -0
- package/web/dist/assets/chunk-JSJVCQXG-BZQN6rnX.js +1 -0
- package/web/dist/assets/chunk-KX2RTZJC-zBbcpaN_.js +1 -0
- package/web/dist/assets/chunk-NQ4KR5QH-BCrLoU88.js +220 -0
- package/web/dist/assets/chunk-QZHKN3VN-Bqk8juan.js +1 -0
- package/web/dist/assets/chunk-WL4C6EOR-D2YX-MHY.js +189 -0
- package/web/dist/assets/classDiagram-VBA2DB6C-DUUoMyaK.js +1 -0
- package/web/dist/assets/classDiagram-v2-RAHNMMFH-DUUoMyaK.js +1 -0
- package/web/dist/assets/clone-BmaCesfa.js +1 -0
- package/web/dist/assets/cose-bilkent-S5V4N54A-CTsv6qQA.js +1 -0
- package/web/dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
- package/web/dist/assets/dagre-KLK3FWXG-Ci4Jh9nu.js +4 -0
- package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/web/dist/assets/diagram-E7M64L7V-BFRnfTI2.js +24 -0
- package/web/dist/assets/diagram-IFDJBPK2-B7Zhnp0b.js +43 -0
- package/web/dist/assets/diagram-P4PSJMXO-BVyP7nwq.js +24 -0
- package/web/dist/assets/erDiagram-INFDFZHY-NorKdTOF.js +70 -0
- package/web/dist/assets/error-CGD5mp5f.js +1 -0
- package/web/dist/assets/flowDiagram-PKNHOUZH-Ch97nABF.js +162 -0
- package/web/dist/assets/ganttDiagram-A5KZAMGK-BQ2pLWsy.js +292 -0
- package/web/dist/assets/gitGraphDiagram-K3NZZRJ6-bcvnBsD2.js +65 -0
- package/web/dist/assets/graph-CeAEckur.js +1 -0
- package/web/dist/assets/index-CPnL1_qC.js +768 -0
- package/web/dist/assets/index-DVevCbcO.css +10 -0
- package/web/dist/assets/infoDiagram-LFFYTUFH-CcsrFdj-.js +2 -0
- package/web/dist/assets/init-Dmth1JHB.js +1 -0
- package/web/dist/assets/ishikawaDiagram-PHBUUO56-1upyMfHN.js +70 -0
- package/web/dist/assets/journeyDiagram-4ABVD52K-CKUi-V0c.js +139 -0
- package/web/dist/assets/kanban-definition-K7BYSVSG-DOnQwXfL.js +89 -0
- package/web/dist/assets/layout-BmMMqTnJ.js +1 -0
- package/web/dist/assets/linear-DiaJloY5.js +1 -0
- package/web/dist/assets/mermaid.core-BWLV1B2v.js +254 -0
- package/web/dist/assets/mindmap-definition-YRQLILUH-BeAKHVWP.js +68 -0
- package/web/dist/assets/ordinal-DILIJJjt.js +1 -0
- package/web/dist/assets/pieDiagram-SKSYHLDU-DfiMSfWo.js +30 -0
- package/web/dist/assets/quadrantDiagram-337W2JSQ-wZxZOJxd.js +7 -0
- package/web/dist/assets/requirementDiagram-Z7DCOOCP-BK4HHm17.js +73 -0
- package/web/dist/assets/sankeyDiagram-WA2Y5GQK-BX6t2avX.js +10 -0
- package/web/dist/assets/sequenceDiagram-2WXFIKYE-BPQlkbAa.js +145 -0
- package/web/dist/assets/sheet-rI0FfB1g.js +6 -0
- package/web/dist/assets/sliders-horizontal-CuijWFNK.js +6 -0
- package/web/dist/assets/sparkles-BsMYXJoT.js +11 -0
- package/web/dist/assets/square-0CqMX1Q3.js +11 -0
- package/web/dist/assets/stateDiagram-RAJIS63D-DxkV0Vwd.js +1 -0
- package/web/dist/assets/stateDiagram-v2-FVOUBMTO-qLYoiOPe.js +1 -0
- package/web/dist/assets/step-D51IIHGA.js +1 -0
- package/web/dist/assets/tasks-D8JjBTwx.js +1 -0
- package/web/dist/assets/time-O8zIGux3.js +1 -0
- package/web/dist/assets/timeline-definition-YZTLITO2-kNp1DyFc.js +61 -0
- package/web/dist/assets/treemap-KZPCXAKY-CkrClVhk.js +162 -0
- package/web/dist/assets/utils-KGAn0XTg.js +11 -0
- package/web/dist/assets/vennDiagram-LZ73GAT5-CgdzEZz4.js +34 -0
- package/web/dist/assets/xychartDiagram-JWTSCODW-DfYGPfNB.js +7 -0
- package/web/dist/assets/zap-_hKJYy7J.js +6 -0
- package/web/dist/favicon.svg +332 -0
- package/web/dist/fonts/AlibabaPuHuiTi-3-55-Regular.woff2 +0 -0
- package/web/dist/fonts/AlibabaPuHuiTi-3-65-Medium.woff2 +0 -0
- package/web/dist/fonts/AlibabaPuHuiTi-3-75-SemiBold.woff2 +0 -0
- package/web/dist/fonts/DMSans-latin-ext.woff2 +0 -0
- package/web/dist/fonts/DMSans-latin.woff2 +0 -0
- package/web/dist/icons/README.md +20 -0
- package/web/dist/icons/apple-touch-icon-180.png +0 -0
- package/web/dist/icons/icon-128.png +0 -0
- package/web/dist/icons/icon-144.png +0 -0
- package/web/dist/icons/icon-152.png +0 -0
- package/web/dist/icons/icon-192.png +0 -0
- package/web/dist/icons/icon-192.svg +332 -0
- package/web/dist/icons/icon-384.png +0 -0
- package/web/dist/icons/icon-48.png +0 -0
- package/web/dist/icons/icon-512-maskable.png +0 -0
- package/web/dist/icons/icon-512.png +0 -0
- package/web/dist/icons/icon-512.svg +332 -0
- package/web/dist/icons/icon-72.png +0 -0
- package/web/dist/icons/icon-96.png +0 -0
- package/web/dist/icons/loading-logo.svg +332 -0
- package/web/dist/icons/logo-1024.png +0 -0
- package/web/dist/icons/logo-icon.svg +332 -0
- package/web/dist/icons/logo-text.svg +332 -0
- package/web/dist/index.html +30 -0
- package/web/dist/manifest.webmanifest +1 -0
- package/web/dist/registerSW.js +1 -0
- package/web/dist/sw.js +1 -0
- package/web/dist/workbox-08d6266a.js +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cli-claw-kit",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Self-hosted multi-user AI agent platform powered by CLI runtimes.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"cli-claw": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"config",
|
|
13
|
+
"shared",
|
|
14
|
+
"shared/dist",
|
|
15
|
+
"container/build.sh",
|
|
16
|
+
"container/Dockerfile",
|
|
17
|
+
"container/entrypoint.sh",
|
|
18
|
+
"container/skills",
|
|
19
|
+
"container/agent-runner/package.json",
|
|
20
|
+
"container/agent-runner/tsconfig.json",
|
|
21
|
+
"container/agent-runner/src",
|
|
22
|
+
"container/agent-runner/dist",
|
|
23
|
+
"container/agent-runner/prompts",
|
|
24
|
+
"web/dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "npm run build:shared && npm run build:backend",
|
|
30
|
+
"build:release": "npm run build:all",
|
|
31
|
+
"prepack": "npm run build:release",
|
|
32
|
+
"release:check": "bash ./scripts/release-check.sh",
|
|
33
|
+
"start": "node dist/cli.js start",
|
|
34
|
+
"dev": "tsx src/index.ts",
|
|
35
|
+
"dev:bun": "bun src/index.ts",
|
|
36
|
+
"reset:admin": "tsx src/reset-admin.ts",
|
|
37
|
+
"typecheck": "npm run build:shared && npm run typecheck:backend",
|
|
38
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
39
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
40
|
+
"test": "vitest",
|
|
41
|
+
"dev:all": "npx concurrently --timestamp-format \"yyyy-MM-dd HH:mm:ss.SSS\" -n backend,frontend -c blue,green \"npm run dev\" \"npm run dev:web\"",
|
|
42
|
+
"dev:web": "cd web && npm run dev",
|
|
43
|
+
"build:web": "npm run build:shared && npm run build:web:local",
|
|
44
|
+
"build:all": "npm run build:shared && npm run build:backend && npm run build:web:local && npm --prefix container/agent-runner run build:runner",
|
|
45
|
+
"build:shared": "tsc -p shared/tsconfig.json",
|
|
46
|
+
"build:backend": "tsc",
|
|
47
|
+
"build:web:local": "cd web && npm run build",
|
|
48
|
+
"typecheck:backend": "tsc --noEmit"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@agentclientprotocol/sdk": "^0.18.0",
|
|
52
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.85",
|
|
53
|
+
"@hono/node-server": "^1.19.9",
|
|
54
|
+
"@larksuiteoapi/node-sdk": "^1.58.0",
|
|
55
|
+
"@types/qrcode": "^1.5.6",
|
|
56
|
+
"bcryptjs": "^3.0.3",
|
|
57
|
+
"better-sqlite3": "^11.8.1",
|
|
58
|
+
"cron-parser": "^5.5.0",
|
|
59
|
+
"dingtalk-stream": "2.1.6-beta.1",
|
|
60
|
+
"grammy": "^1.40.0",
|
|
61
|
+
"hono": "^4.11.9",
|
|
62
|
+
"node-pty": "^1.1.0",
|
|
63
|
+
"pino": "^9.6.0",
|
|
64
|
+
"pino-pretty": "^13.0.0",
|
|
65
|
+
"proxy-agent": "^6.5.0",
|
|
66
|
+
"qrcode": "^1.5.4",
|
|
67
|
+
"ws": "^8.19.0",
|
|
68
|
+
"zod": "^4.3.6"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@types/bcryptjs": "^2.4.6",
|
|
72
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
73
|
+
"@types/node": "^22.10.0",
|
|
74
|
+
"@types/ws": "^8.18.1",
|
|
75
|
+
"concurrently": "^9.2.1",
|
|
76
|
+
"prettier": "^3.8.1",
|
|
77
|
+
"tsx": "^4.19.0",
|
|
78
|
+
"typescript": "^5.9.3",
|
|
79
|
+
"vitest": "^4.1.1"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=20"
|
|
83
|
+
},
|
|
84
|
+
"license": "MIT",
|
|
85
|
+
"repository": {
|
|
86
|
+
"type": "git",
|
|
87
|
+
"url": "git+https://github.com/RyanProMax/cli-claw.git"
|
|
88
|
+
},
|
|
89
|
+
"homepage": "https://github.com/RyanProMax/cli-claw#readme",
|
|
90
|
+
"bugs": {
|
|
91
|
+
"url": "https://github.com/RyanProMax/cli-claw/issues"
|
|
92
|
+
},
|
|
93
|
+
"author": "riba2534",
|
|
94
|
+
"keywords": [
|
|
95
|
+
"claude",
|
|
96
|
+
"claude-code",
|
|
97
|
+
"codex",
|
|
98
|
+
"ai-agent",
|
|
99
|
+
"self-hosted",
|
|
100
|
+
"feishu",
|
|
101
|
+
"lark",
|
|
102
|
+
"telegram",
|
|
103
|
+
"chatbot",
|
|
104
|
+
"docker",
|
|
105
|
+
"mcp"
|
|
106
|
+
]
|
|
107
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export interface AssistantFooterRuntimeIdentity {
|
|
2
|
+
agentType?: string;
|
|
3
|
+
model?: string | null;
|
|
4
|
+
reasoningEffort?: string | null;
|
|
5
|
+
supportsReasoningEffort?: boolean | null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AssistantFooterModelUsage {
|
|
9
|
+
inputTokens?: number | null;
|
|
10
|
+
outputTokens?: number | null;
|
|
11
|
+
costUSD?: number | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AssistantFooterTokenUsage {
|
|
15
|
+
inputTokens?: number | null;
|
|
16
|
+
outputTokens?: number | null;
|
|
17
|
+
cacheReadInputTokens?: number | null;
|
|
18
|
+
cacheCreationInputTokens?: number | null;
|
|
19
|
+
costUSD?: number | null;
|
|
20
|
+
durationMs?: number | null;
|
|
21
|
+
numTurns?: number | null;
|
|
22
|
+
modelUsage?: Record<string, AssistantFooterModelUsage> | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AssistantMetaFooterInput {
|
|
26
|
+
runtimeIdentity?: AssistantFooterRuntimeIdentity | null;
|
|
27
|
+
tokenUsage?: AssistantFooterTokenUsage | string | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function normalizeText(value: string | null | undefined): string | null {
|
|
31
|
+
if (typeof value !== 'string') return null;
|
|
32
|
+
const trimmed = value.trim();
|
|
33
|
+
return trimmed || null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function normalizeNumber(value: number | null | undefined): number | null {
|
|
37
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) return null;
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function formatCompactNumber(value: number): string {
|
|
42
|
+
if (!Number.isFinite(value)) return '0';
|
|
43
|
+
if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`;
|
|
44
|
+
if (value >= 1_000) return `${(value / 1_000).toFixed(1)}K`;
|
|
45
|
+
return String(Math.round(value));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function parseAssistantTokenUsage(
|
|
49
|
+
tokenUsage?: AssistantFooterTokenUsage | string | null,
|
|
50
|
+
): AssistantFooterTokenUsage | null {
|
|
51
|
+
if (!tokenUsage) return null;
|
|
52
|
+
if (typeof tokenUsage === 'string') {
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(tokenUsage) as AssistantFooterTokenUsage;
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return tokenUsage;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getTotalTokens(usage: AssistantFooterTokenUsage | null): number | null {
|
|
63
|
+
if (!usage) return null;
|
|
64
|
+
|
|
65
|
+
const rootInput = normalizeNumber(usage.inputTokens);
|
|
66
|
+
const rootOutput = normalizeNumber(usage.outputTokens);
|
|
67
|
+
if (rootInput !== null || rootOutput !== null) {
|
|
68
|
+
return Math.max(0, (rootInput || 0) + (rootOutput || 0));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!usage.modelUsage || typeof usage.modelUsage !== 'object') return null;
|
|
72
|
+
|
|
73
|
+
let total = 0;
|
|
74
|
+
let sawAny = false;
|
|
75
|
+
for (const modelUsage of Object.values(usage.modelUsage)) {
|
|
76
|
+
const input = normalizeNumber(modelUsage?.inputTokens);
|
|
77
|
+
const output = normalizeNumber(modelUsage?.outputTokens);
|
|
78
|
+
if (input !== null || output !== null) {
|
|
79
|
+
total += (input || 0) + (output || 0);
|
|
80
|
+
sawAny = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return sawAny ? total : null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getAssistantMetaFooterParts(
|
|
88
|
+
input: AssistantMetaFooterInput,
|
|
89
|
+
): string[] {
|
|
90
|
+
const parts: string[] = [];
|
|
91
|
+
const runtimeIdentity = input.runtimeIdentity ?? null;
|
|
92
|
+
const tokenUsage = parseAssistantTokenUsage(input.tokenUsage);
|
|
93
|
+
|
|
94
|
+
const durationMs = normalizeNumber(tokenUsage?.durationMs);
|
|
95
|
+
if (durationMs !== null && durationMs > 0) {
|
|
96
|
+
parts.push(`${(durationMs / 1000).toFixed(1)}s`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const model = normalizeText(runtimeIdentity?.model);
|
|
100
|
+
if (model) {
|
|
101
|
+
parts.push(model);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const reasoningEffort = normalizeText(runtimeIdentity?.reasoningEffort);
|
|
105
|
+
if (reasoningEffort) {
|
|
106
|
+
parts.push(reasoningEffort);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const totalTokens = getTotalTokens(tokenUsage);
|
|
110
|
+
if (totalTokens !== null && totalTokens > 0) {
|
|
111
|
+
parts.push(`${formatCompactNumber(totalTokens)} tokens`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const costUSD = normalizeNumber(tokenUsage?.costUSD);
|
|
115
|
+
if (costUSD !== null && costUSD > 0) {
|
|
116
|
+
parts.push(`$${costUSD.toFixed(4)}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return parts;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function formatAssistantMetaFooter(
|
|
123
|
+
input: AssistantMetaFooterInput,
|
|
124
|
+
): string | null {
|
|
125
|
+
const parts = getAssistantMetaFooterParts(input);
|
|
126
|
+
return parts.length > 0 ? parts.join(' | ') : null;
|
|
127
|
+
}
|
|
@@ -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,29 @@
|
|
|
1
|
+
export interface AssistantFooterRuntimeIdentity {
|
|
2
|
+
agentType?: string;
|
|
3
|
+
model?: string | null;
|
|
4
|
+
reasoningEffort?: string | null;
|
|
5
|
+
supportsReasoningEffort?: boolean | null;
|
|
6
|
+
}
|
|
7
|
+
export interface AssistantFooterModelUsage {
|
|
8
|
+
inputTokens?: number | null;
|
|
9
|
+
outputTokens?: number | null;
|
|
10
|
+
costUSD?: number | null;
|
|
11
|
+
}
|
|
12
|
+
export interface AssistantFooterTokenUsage {
|
|
13
|
+
inputTokens?: number | null;
|
|
14
|
+
outputTokens?: number | null;
|
|
15
|
+
cacheReadInputTokens?: number | null;
|
|
16
|
+
cacheCreationInputTokens?: number | null;
|
|
17
|
+
costUSD?: number | null;
|
|
18
|
+
durationMs?: number | null;
|
|
19
|
+
numTurns?: number | null;
|
|
20
|
+
modelUsage?: Record<string, AssistantFooterModelUsage> | null;
|
|
21
|
+
}
|
|
22
|
+
export interface AssistantMetaFooterInput {
|
|
23
|
+
runtimeIdentity?: AssistantFooterRuntimeIdentity | null;
|
|
24
|
+
tokenUsage?: AssistantFooterTokenUsage | string | null;
|
|
25
|
+
}
|
|
26
|
+
export declare function formatCompactNumber(value: number): string;
|
|
27
|
+
export declare function parseAssistantTokenUsage(tokenUsage?: AssistantFooterTokenUsage | string | null): AssistantFooterTokenUsage | null;
|
|
28
|
+
export declare function getAssistantMetaFooterParts(input: AssistantMetaFooterInput): string[];
|
|
29
|
+
export declare function formatAssistantMetaFooter(input: AssistantMetaFooterInput): string | null;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function normalizeText(value) {
|
|
2
|
+
if (typeof value !== 'string')
|
|
3
|
+
return null;
|
|
4
|
+
const trimmed = value.trim();
|
|
5
|
+
return trimmed || null;
|
|
6
|
+
}
|
|
7
|
+
function normalizeNumber(value) {
|
|
8
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
9
|
+
return null;
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
export function formatCompactNumber(value) {
|
|
13
|
+
if (!Number.isFinite(value))
|
|
14
|
+
return '0';
|
|
15
|
+
if (value >= 1_000_000)
|
|
16
|
+
return `${(value / 1_000_000).toFixed(1)}M`;
|
|
17
|
+
if (value >= 1_000)
|
|
18
|
+
return `${(value / 1_000).toFixed(1)}K`;
|
|
19
|
+
return String(Math.round(value));
|
|
20
|
+
}
|
|
21
|
+
export function parseAssistantTokenUsage(tokenUsage) {
|
|
22
|
+
if (!tokenUsage)
|
|
23
|
+
return null;
|
|
24
|
+
if (typeof tokenUsage === 'string') {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(tokenUsage);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return tokenUsage;
|
|
33
|
+
}
|
|
34
|
+
function getTotalTokens(usage) {
|
|
35
|
+
if (!usage)
|
|
36
|
+
return null;
|
|
37
|
+
const rootInput = normalizeNumber(usage.inputTokens);
|
|
38
|
+
const rootOutput = normalizeNumber(usage.outputTokens);
|
|
39
|
+
if (rootInput !== null || rootOutput !== null) {
|
|
40
|
+
return Math.max(0, (rootInput || 0) + (rootOutput || 0));
|
|
41
|
+
}
|
|
42
|
+
if (!usage.modelUsage || typeof usage.modelUsage !== 'object')
|
|
43
|
+
return null;
|
|
44
|
+
let total = 0;
|
|
45
|
+
let sawAny = false;
|
|
46
|
+
for (const modelUsage of Object.values(usage.modelUsage)) {
|
|
47
|
+
const input = normalizeNumber(modelUsage?.inputTokens);
|
|
48
|
+
const output = normalizeNumber(modelUsage?.outputTokens);
|
|
49
|
+
if (input !== null || output !== null) {
|
|
50
|
+
total += (input || 0) + (output || 0);
|
|
51
|
+
sawAny = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return sawAny ? total : null;
|
|
55
|
+
}
|
|
56
|
+
export function getAssistantMetaFooterParts(input) {
|
|
57
|
+
const parts = [];
|
|
58
|
+
const runtimeIdentity = input.runtimeIdentity ?? null;
|
|
59
|
+
const tokenUsage = parseAssistantTokenUsage(input.tokenUsage);
|
|
60
|
+
const durationMs = normalizeNumber(tokenUsage?.durationMs);
|
|
61
|
+
if (durationMs !== null && durationMs > 0) {
|
|
62
|
+
parts.push(`${(durationMs / 1000).toFixed(1)}s`);
|
|
63
|
+
}
|
|
64
|
+
const model = normalizeText(runtimeIdentity?.model);
|
|
65
|
+
if (model) {
|
|
66
|
+
parts.push(model);
|
|
67
|
+
}
|
|
68
|
+
const reasoningEffort = normalizeText(runtimeIdentity?.reasoningEffort);
|
|
69
|
+
if (reasoningEffort) {
|
|
70
|
+
parts.push(reasoningEffort);
|
|
71
|
+
}
|
|
72
|
+
const totalTokens = getTotalTokens(tokenUsage);
|
|
73
|
+
if (totalTokens !== null && totalTokens > 0) {
|
|
74
|
+
parts.push(`${formatCompactNumber(totalTokens)} tokens`);
|
|
75
|
+
}
|
|
76
|
+
const costUSD = normalizeNumber(tokenUsage?.costUSD);
|
|
77
|
+
if (costUSD !== null && costUSD > 0) {
|
|
78
|
+
parts.push(`$${costUSD.toFixed(4)}`);
|
|
79
|
+
}
|
|
80
|
+
return parts;
|
|
81
|
+
}
|
|
82
|
+
export function formatAssistantMetaFooter(input) {
|
|
83
|
+
const parts = getAssistantMetaFooterParts(input);
|
|
84
|
+
return parts.length > 0 ? parts.join(' | ') : null;
|
|
85
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** IM channel type → JID prefix mapping. Shared between main server and agent-runner. */
|
|
2
|
+
export declare const CHANNEL_PREFIXES: Record<string, string>;
|
|
3
|
+
/** Determine the channel type from a JID string. Returns 'web' for unrecognized prefixes. */
|
|
4
|
+
export declare function getChannelFromJid(jid: string): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** IM channel type → JID prefix mapping. Shared between main server and agent-runner. */
|
|
2
|
+
export const CHANNEL_PREFIXES = {
|
|
3
|
+
feishu: 'feishu:',
|
|
4
|
+
telegram: 'telegram:',
|
|
5
|
+
qq: 'qq:',
|
|
6
|
+
wechat: 'wechat:',
|
|
7
|
+
dingtalk: 'dingtalk:',
|
|
8
|
+
};
|
|
9
|
+
/** Determine the channel type from a JID string. Returns 'web' for unrecognized prefixes. */
|
|
10
|
+
export function getChannelFromJid(jid) {
|
|
11
|
+
for (const [type, prefix] of Object.entries(CHANNEL_PREFIXES)) {
|
|
12
|
+
if (jid.startsWith(prefix))
|
|
13
|
+
return type;
|
|
14
|
+
}
|
|
15
|
+
return 'web';
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 declare function detectImageMimeTypeStrict(buffer: Buffer): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Detect image MIME type from buffer magic bytes with fallback.
|
|
10
|
+
*/
|
|
11
|
+
export declare function detectImageMimeType(buffer: Buffer): string;
|
|
12
|
+
/**
|
|
13
|
+
* Detect image MIME type from base64 payload (using header bytes only).
|
|
14
|
+
* Returns detected MIME or null if unknown/invalid.
|
|
15
|
+
*/
|
|
16
|
+
export declare function detectImageMimeTypeFromBase64Strict(base64Data: string): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Detect image MIME type from base64 payload with fallback.
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectImageMimeTypeFromBase64(base64Data: string): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
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) {
|
|
8
|
+
if (buffer.length < 12) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
// PNG: 89 50 4E 47 0D 0A 1A 0A
|
|
12
|
+
if (buffer[0] === 0x89 &&
|
|
13
|
+
buffer[1] === 0x50 &&
|
|
14
|
+
buffer[2] === 0x4e &&
|
|
15
|
+
buffer[3] === 0x47 &&
|
|
16
|
+
buffer[4] === 0x0d &&
|
|
17
|
+
buffer[5] === 0x0a &&
|
|
18
|
+
buffer[6] === 0x1a &&
|
|
19
|
+
buffer[7] === 0x0a) {
|
|
20
|
+
return 'image/png';
|
|
21
|
+
}
|
|
22
|
+
// JPEG: FF D8 FF
|
|
23
|
+
if (buffer[0] === 0xff && buffer[1] === 0xd8 && buffer[2] === 0xff) {
|
|
24
|
+
return 'image/jpeg';
|
|
25
|
+
}
|
|
26
|
+
// GIF: 47 49 46 38
|
|
27
|
+
if (buffer[0] === 0x47 &&
|
|
28
|
+
buffer[1] === 0x49 &&
|
|
29
|
+
buffer[2] === 0x46 &&
|
|
30
|
+
buffer[3] === 0x38) {
|
|
31
|
+
return 'image/gif';
|
|
32
|
+
}
|
|
33
|
+
// WebP: RIFF....WEBP
|
|
34
|
+
if (buffer[0] === 0x52 &&
|
|
35
|
+
buffer[1] === 0x49 &&
|
|
36
|
+
buffer[2] === 0x46 &&
|
|
37
|
+
buffer[3] === 0x46 &&
|
|
38
|
+
buffer.length >= 12 &&
|
|
39
|
+
buffer[8] === 0x57 &&
|
|
40
|
+
buffer[9] === 0x45 &&
|
|
41
|
+
buffer[10] === 0x42 &&
|
|
42
|
+
buffer[11] === 0x50) {
|
|
43
|
+
return 'image/webp';
|
|
44
|
+
}
|
|
45
|
+
// TIFF: 49 49 2A 00 (little-endian) or 4D 4D 00 2A (big-endian)
|
|
46
|
+
if ((buffer[0] === 0x49 &&
|
|
47
|
+
buffer[1] === 0x49 &&
|
|
48
|
+
buffer[2] === 0x2a &&
|
|
49
|
+
buffer[3] === 0x00) ||
|
|
50
|
+
(buffer[0] === 0x4d &&
|
|
51
|
+
buffer[1] === 0x4d &&
|
|
52
|
+
buffer[2] === 0x00 &&
|
|
53
|
+
buffer[3] === 0x2a)) {
|
|
54
|
+
return 'image/tiff';
|
|
55
|
+
}
|
|
56
|
+
// AVIF: ....ftypavif or ....ftypavis
|
|
57
|
+
if (buffer.length >= 12) {
|
|
58
|
+
const ftyp = buffer.toString('ascii', 4, 8);
|
|
59
|
+
if (ftyp === 'ftyp') {
|
|
60
|
+
const brand = buffer.toString('ascii', 8, 12);
|
|
61
|
+
if (brand === 'avif' || brand === 'avis') {
|
|
62
|
+
return 'image/avif';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// BMP: 42 4D
|
|
67
|
+
if (buffer[0] === 0x42 && buffer[1] === 0x4d) {
|
|
68
|
+
return 'image/bmp';
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Detect image MIME type from buffer magic bytes with fallback.
|
|
74
|
+
*/
|
|
75
|
+
export function detectImageMimeType(buffer) {
|
|
76
|
+
return detectImageMimeTypeStrict(buffer) || 'image/jpeg';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Detect image MIME type from base64 payload (using header bytes only).
|
|
80
|
+
* Returns detected MIME or null if unknown/invalid.
|
|
81
|
+
*/
|
|
82
|
+
export function detectImageMimeTypeFromBase64Strict(base64Data) {
|
|
83
|
+
try {
|
|
84
|
+
const header = Buffer.from(base64Data.slice(0, 400), 'base64');
|
|
85
|
+
return detectImageMimeTypeStrict(header);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Detect image MIME type from base64 payload with fallback.
|
|
93
|
+
*/
|
|
94
|
+
export function detectImageMimeTypeFromBase64(base64Data) {
|
|
95
|
+
return detectImageMimeTypeFromBase64Strict(base64Data) || 'image/jpeg';
|
|
96
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type RuntimeAgentType = 'claude' | 'codex';
|
|
2
|
+
export type RuntimeCommandEntrypoint = 'im' | 'web';
|
|
3
|
+
export type ReasoningEffortPreset = 'low' | 'medium' | 'high' | 'xhigh';
|
|
4
|
+
export interface RuntimeCommandDefinition {
|
|
5
|
+
name: string;
|
|
6
|
+
aliases?: string[];
|
|
7
|
+
usage: string;
|
|
8
|
+
description: string;
|
|
9
|
+
availableEntrypoints: RuntimeCommandEntrypoint[];
|
|
10
|
+
availabilityByRuntime?: RuntimeAgentType[] | 'all';
|
|
11
|
+
}
|
|
12
|
+
export interface ParsedRuntimeCommand {
|
|
13
|
+
rawName: string;
|
|
14
|
+
name: string;
|
|
15
|
+
argsText: string;
|
|
16
|
+
args: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare const RUNTIME_COMMANDS: RuntimeCommandDefinition[];
|
|
19
|
+
export declare function supportsReasoningEffort(agentType: RuntimeAgentType): boolean;
|
|
20
|
+
export declare function getModelPresets(agentType: RuntimeAgentType): string[];
|
|
21
|
+
export declare function getReasoningEffortPresets(): ReasoningEffortPreset[];
|
|
22
|
+
export declare function normalizeModelPreset(agentType: RuntimeAgentType, rawValue: string): string | null;
|
|
23
|
+
export declare function normalizeReasoningEffortPreset(rawValue: string): ReasoningEffortPreset | null;
|
|
24
|
+
export declare function findRuntimeCommand(rawName: string): RuntimeCommandDefinition | null;
|
|
25
|
+
export declare function parseRuntimeCommand(text: string): ParsedRuntimeCommand | null;
|
|
26
|
+
export declare function isCommandAvailable(options: {
|
|
27
|
+
commandName: string;
|
|
28
|
+
entrypoint: RuntimeCommandEntrypoint;
|
|
29
|
+
agentType: RuntimeAgentType;
|
|
30
|
+
}): boolean;
|
|
31
|
+
export declare function getAvailableCommands(options: {
|
|
32
|
+
entrypoint: RuntimeCommandEntrypoint;
|
|
33
|
+
agentType: RuntimeAgentType;
|
|
34
|
+
}): RuntimeCommandDefinition[];
|
|
35
|
+
export declare function formatCommandHelp(options: {
|
|
36
|
+
entrypoint: RuntimeCommandEntrypoint;
|
|
37
|
+
agentType: RuntimeAgentType;
|
|
38
|
+
}): string;
|