@graychennpm/codebridge 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +217 -2
- package/README.zh-CN.md +222 -0
- package/apps/web/public/brand/agent-logo-carbon.svg +1 -0
- package/apps/web/public/brand/agent-logo.svg +1 -0
- package/docs/zh-CN/npm-release.md +77 -0
- package/node_modules/@codebridge/agent-registry/dist/index.d.ts +32 -0
- package/node_modules/@codebridge/agent-registry/dist/index.js +177 -0
- package/node_modules/@codebridge/agent-registry/dist/setup.d.ts +9 -0
- package/node_modules/@codebridge/agent-registry/dist/setup.js +115 -0
- package/node_modules/@codebridge/agent-registry/package.json +17 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-active-session.d.ts +12 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-active-session.js +57 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-claude-activity.d.ts +9 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-claude-activity.js +49 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-config-options.d.ts +46 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-config-options.js +220 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-doctor.d.ts +3 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-doctor.js +18 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-event-mapper.d.ts +5 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-event-mapper.js +136 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-kill.d.ts +10 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-kill.js +24 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-race.d.ts +6 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-race.js +29 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-session-list.d.ts +32 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-session-list.js +218 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-session-pool.d.ts +85 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-session-pool.js +165 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-session-runner.d.ts +78 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-session-runner.js +550 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-spawn-profiles.d.ts +9 -0
- package/node_modules/@codebridge/backends/dist/acp/acp-spawn-profiles.js +28 -0
- package/node_modules/@codebridge/backends/dist/acp/headless-client.d.ts +19 -0
- package/node_modules/@codebridge/backends/dist/acp/headless-client.js +47 -0
- package/node_modules/@codebridge/backends/dist/acp/index.d.ts +9 -0
- package/node_modules/@codebridge/backends/dist/acp/index.js +9 -0
- package/node_modules/@codebridge/backends/dist/agent-setup.d.ts +60 -0
- package/node_modules/@codebridge/backends/dist/agent-setup.js +504 -0
- package/node_modules/@codebridge/backends/dist/attachment-prompt.d.ts +8 -0
- package/node_modules/@codebridge/backends/dist/attachment-prompt.js +28 -0
- package/node_modules/@codebridge/backends/dist/auth-error-hints.d.ts +8 -0
- package/node_modules/@codebridge/backends/dist/auth-error-hints.js +33 -0
- package/node_modules/@codebridge/backends/dist/codex-skill-commands.d.ts +3 -0
- package/node_modules/@codebridge/backends/dist/codex-skill-commands.js +88 -0
- package/node_modules/@codebridge/backends/dist/index.d.ts +18 -0
- package/node_modules/@codebridge/backends/dist/index.js +34 -0
- package/node_modules/@codebridge/backends/dist/pi-providers.d.ts +45 -0
- package/node_modules/@codebridge/backends/dist/pi-providers.js +148 -0
- package/node_modules/@codebridge/backends/dist/pi-session-runner.d.ts +85 -0
- package/node_modules/@codebridge/backends/dist/pi-session-runner.js +460 -0
- package/node_modules/@codebridge/backends/dist/provider-connection.d.ts +17 -0
- package/node_modules/@codebridge/backends/dist/provider-connection.js +99 -0
- package/node_modules/@codebridge/backends/dist/session-discovery.d.ts +23 -0
- package/node_modules/@codebridge/backends/dist/session-discovery.js +340 -0
- package/node_modules/@codebridge/backends/dist/skill-control-plane.d.ts +147 -0
- package/node_modules/@codebridge/backends/dist/skill-control-plane.js +832 -0
- package/node_modules/@codebridge/backends/package.json +22 -0
- package/node_modules/@codebridge/bridge/dist/alert-notification-rules.d.ts +14 -0
- package/node_modules/@codebridge/bridge/dist/alert-notification-rules.js +37 -0
- package/node_modules/@codebridge/bridge/dist/channel-config.d.ts +4 -0
- package/node_modules/@codebridge/bridge/dist/channel-config.js +9 -0
- package/node_modules/@codebridge/bridge/dist/channel-ingress.d.ts +5 -0
- package/node_modules/@codebridge/bridge/dist/channel-ingress.js +403 -0
- package/node_modules/@codebridge/bridge/dist/cli.d.ts +3 -0
- package/node_modules/@codebridge/bridge/dist/cli.js +581 -0
- package/node_modules/@codebridge/bridge/dist/deployment.d.ts +46 -0
- package/node_modules/@codebridge/bridge/dist/deployment.js +174 -0
- package/node_modules/@codebridge/bridge/dist/event-loop-lag.d.ts +19 -0
- package/node_modules/@codebridge/bridge/dist/event-loop-lag.js +33 -0
- package/node_modules/@codebridge/bridge/dist/feishu-alert-monitor.d.ts +70 -0
- package/node_modules/@codebridge/bridge/dist/feishu-alert-monitor.js +591 -0
- package/node_modules/@codebridge/bridge/dist/init-wizard.d.ts +52 -0
- package/node_modules/@codebridge/bridge/dist/init-wizard.js +571 -0
- package/node_modules/@codebridge/bridge/dist/mcp-api.d.ts +4 -0
- package/node_modules/@codebridge/bridge/dist/mcp-api.js +100 -0
- package/node_modules/@codebridge/bridge/dist/outbound-api.d.ts +31 -0
- package/node_modules/@codebridge/bridge/dist/outbound-api.js +184 -0
- package/node_modules/@codebridge/bridge/dist/outbound-publishers.d.ts +54 -0
- package/node_modules/@codebridge/bridge/dist/outbound-publishers.js +213 -0
- package/node_modules/@codebridge/bridge/dist/project-api.d.ts +4 -0
- package/node_modules/@codebridge/bridge/dist/project-api.js +161 -0
- package/node_modules/@codebridge/bridge/dist/secrets-command.d.ts +13 -0
- package/node_modules/@codebridge/bridge/dist/secrets-command.js +34 -0
- package/node_modules/@codebridge/bridge/dist/session-api.d.ts +26 -0
- package/node_modules/@codebridge/bridge/dist/session-api.js +1378 -0
- package/node_modules/@codebridge/bridge/dist/session-history-import.d.ts +24 -0
- package/node_modules/@codebridge/bridge/dist/session-history-import.js +82 -0
- package/node_modules/@codebridge/bridge/dist/session-runtime-api.d.ts +19 -0
- package/node_modules/@codebridge/bridge/dist/session-runtime-api.js +453 -0
- package/node_modules/@codebridge/bridge/dist/session-runtime-migration.d.ts +21 -0
- package/node_modules/@codebridge/bridge/dist/session-runtime-migration.js +43 -0
- package/node_modules/@codebridge/bridge/dist/session-runtime-types.d.ts +85 -0
- package/node_modules/@codebridge/bridge/dist/session-runtime-types.js +98 -0
- package/node_modules/@codebridge/bridge/dist/skill-api.d.ts +28 -0
- package/node_modules/@codebridge/bridge/dist/skill-api.js +129 -0
- package/node_modules/@codebridge/bridge/dist/startup-surfaces.d.ts +15 -0
- package/node_modules/@codebridge/bridge/dist/startup-surfaces.js +13 -0
- package/node_modules/@codebridge/bridge/dist/web-frontend.d.ts +8 -0
- package/node_modules/@codebridge/bridge/dist/web-frontend.js +76 -0
- package/node_modules/@codebridge/bridge/dist/work-item-api.d.ts +6 -0
- package/node_modules/@codebridge/bridge/dist/work-item-api.js +414 -0
- package/node_modules/@codebridge/bridge/package.json +28 -0
- package/node_modules/@codebridge/channel-feishu/dist/alert-reactions.d.ts +6 -0
- package/node_modules/@codebridge/channel-feishu/dist/alert-reactions.js +58 -0
- package/node_modules/@codebridge/channel-feishu/dist/alert-types.d.ts +35 -0
- package/node_modules/@codebridge/channel-feishu/dist/alert-types.js +2 -0
- package/node_modules/@codebridge/channel-feishu/dist/bridge.d.ts +130 -0
- package/node_modules/@codebridge/channel-feishu/dist/bridge.js +1231 -0
- package/node_modules/@codebridge/channel-feishu/dist/cardkit-writer.d.ts +48 -0
- package/node_modules/@codebridge/channel-feishu/dist/cardkit-writer.js +153 -0
- package/node_modules/@codebridge/channel-feishu/dist/chain-topics.d.ts +20 -0
- package/node_modules/@codebridge/channel-feishu/dist/chain-topics.js +35 -0
- package/node_modules/@codebridge/channel-feishu/dist/coalescing-card-writer.d.ts +12 -0
- package/node_modules/@codebridge/channel-feishu/dist/coalescing-card-writer.js +53 -0
- package/node_modules/@codebridge/channel-feishu/dist/delivery-reconciler.d.ts +19 -0
- package/node_modules/@codebridge/channel-feishu/dist/delivery-reconciler.js +53 -0
- package/node_modules/@codebridge/channel-feishu/dist/durable-markdown-card.d.ts +19 -0
- package/node_modules/@codebridge/channel-feishu/dist/durable-markdown-card.js +77 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-extra-events.d.ts +27 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-extra-events.js +24 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-http.d.ts +4 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-http.js +25 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-inbound-context.d.ts +13 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-inbound-context.js +45 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-inbound-media.d.ts +22 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-inbound-media.js +273 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-mention-gate.d.ts +13 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-mention-gate.js +22 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-outbound-file.d.ts +12 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-outbound-file.js +38 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-quoted-message.d.ts +30 -0
- package/node_modules/@codebridge/channel-feishu/dist/feishu-quoted-message.js +183 -0
- package/node_modules/@codebridge/channel-feishu/dist/index.d.ts +7 -0
- package/node_modules/@codebridge/channel-feishu/dist/index.js +3 -0
- package/node_modules/@codebridge/channel-feishu/dist/redacting-logger.d.ts +17 -0
- package/node_modules/@codebridge/channel-feishu/dist/redacting-logger.js +41 -0
- package/node_modules/@codebridge/channel-feishu/dist/run-status.d.ts +39 -0
- package/node_modules/@codebridge/channel-feishu/dist/run-status.js +166 -0
- package/node_modules/@codebridge/channel-feishu/dist/session-watcher.d.ts +98 -0
- package/node_modules/@codebridge/channel-feishu/dist/session-watcher.js +655 -0
- package/node_modules/@codebridge/channel-feishu/package.json +19 -0
- package/node_modules/@codebridge/channel-telegram/dist/coalescing-message-writer.d.ts +14 -0
- package/node_modules/@codebridge/channel-telegram/dist/coalescing-message-writer.js +56 -0
- package/node_modules/@codebridge/channel-telegram/dist/index.d.ts +3 -0
- package/node_modules/@codebridge/channel-telegram/dist/index.js +3 -0
- package/node_modules/@codebridge/channel-telegram/dist/telegram-api.d.ts +62 -0
- package/node_modules/@codebridge/channel-telegram/dist/telegram-api.js +72 -0
- package/node_modules/@codebridge/channel-telegram/dist/telegram-bridge.d.ts +64 -0
- package/node_modules/@codebridge/channel-telegram/dist/telegram-bridge.js +469 -0
- package/node_modules/@codebridge/channel-telegram/dist/telegram-session-watcher.d.ts +41 -0
- package/node_modules/@codebridge/channel-telegram/dist/telegram-session-watcher.js +184 -0
- package/node_modules/@codebridge/channel-telegram/package.json +18 -0
- package/node_modules/@codebridge/core/dist/config-schema.d.ts +1195 -0
- package/node_modules/@codebridge/core/dist/config-schema.js +293 -0
- package/node_modules/@codebridge/core/dist/config-store.d.ts +48 -0
- package/node_modules/@codebridge/core/dist/config-store.js +207 -0
- package/node_modules/@codebridge/core/dist/index.d.ts +11 -0
- package/node_modules/@codebridge/core/dist/index.js +10 -0
- package/node_modules/@codebridge/core/dist/json-file-store.d.ts +16 -0
- package/node_modules/@codebridge/core/dist/json-file-store.js +46 -0
- package/node_modules/@codebridge/core/dist/mcp-types.d.ts +7 -0
- package/node_modules/@codebridge/core/dist/mcp-types.js +2 -0
- package/node_modules/@codebridge/core/dist/mentions.d.ts +36 -0
- package/node_modules/@codebridge/core/dist/mentions.js +138 -0
- package/node_modules/@codebridge/core/dist/secret-migration.d.ts +14 -0
- package/node_modules/@codebridge/core/dist/secret-migration.js +55 -0
- package/node_modules/@codebridge/core/dist/secret-refs.d.ts +34 -0
- package/node_modules/@codebridge/core/dist/secret-refs.js +142 -0
- package/node_modules/@codebridge/core/dist/session-event-wire.d.ts +17 -0
- package/node_modules/@codebridge/core/dist/session-event-wire.js +28 -0
- package/node_modules/@codebridge/core/dist/types.d.ts +363 -0
- package/node_modules/@codebridge/core/dist/types.js +22 -0
- package/node_modules/@codebridge/core/dist/workspace-key.d.ts +11 -0
- package/node_modules/@codebridge/core/dist/workspace-key.js +25 -0
- package/node_modules/@codebridge/core/package.json +22 -0
- package/node_modules/@codebridge/mcp-runtime/dist/.tsbuildinfo +1 -0
- package/node_modules/@codebridge/mcp-runtime/dist/index.d.ts +92 -0
- package/node_modules/@codebridge/mcp-runtime/dist/index.js +377 -0
- package/node_modules/@codebridge/mcp-runtime/package.json +19 -0
- package/node_modules/@codebridge/policy/dist/capability-runtime.d.ts +123 -0
- package/node_modules/@codebridge/policy/dist/capability-runtime.js +195 -0
- package/node_modules/@codebridge/policy/dist/demo-capabilities.d.ts +4 -0
- package/node_modules/@codebridge/policy/dist/demo-capabilities.js +134 -0
- package/node_modules/@codebridge/policy/dist/equity-capabilities.d.ts +8 -0
- package/node_modules/@codebridge/policy/dist/equity-capabilities.js +35 -0
- package/node_modules/@codebridge/policy/dist/index.d.ts +107 -0
- package/node_modules/@codebridge/policy/dist/index.js +317 -0
- package/node_modules/@codebridge/policy/package.json +17 -0
- package/node_modules/@codebridge/project-catalog/dist/index.d.ts +145 -0
- package/node_modules/@codebridge/project-catalog/dist/index.js +699 -0
- package/node_modules/@codebridge/project-catalog/package.json +18 -0
- package/node_modules/@codebridge/router/dist/channel-stream-projector.d.ts +19 -0
- package/node_modules/@codebridge/router/dist/channel-stream-projector.js +68 -0
- package/node_modules/@codebridge/router/dist/command-help.d.ts +14 -0
- package/node_modules/@codebridge/router/dist/command-help.js +151 -0
- package/node_modules/@codebridge/router/dist/feishu-stream-presenter.d.ts +18 -0
- package/node_modules/@codebridge/router/dist/feishu-stream-presenter.js +193 -0
- package/node_modules/@codebridge/router/dist/index.d.ts +9 -0
- package/node_modules/@codebridge/router/dist/index.js +9 -0
- package/node_modules/@codebridge/router/dist/model-effort.d.ts +5 -0
- package/node_modules/@codebridge/router/dist/model-effort.js +33 -0
- package/node_modules/@codebridge/router/dist/orchestrator.d.ts +56 -0
- package/node_modules/@codebridge/router/dist/orchestrator.js +290 -0
- package/node_modules/@codebridge/router/dist/session-list-format.d.ts +19 -0
- package/node_modules/@codebridge/router/dist/session-list-format.js +97 -0
- package/node_modules/@codebridge/router/dist/session-rotation.d.ts +9 -0
- package/node_modules/@codebridge/router/dist/session-rotation.js +31 -0
- package/node_modules/@codebridge/router/dist/session-router.d.ts +59 -0
- package/node_modules/@codebridge/router/dist/session-router.js +182 -0
- package/node_modules/@codebridge/router/dist/slash-commands.d.ts +78 -0
- package/node_modules/@codebridge/router/dist/slash-commands.js +874 -0
- package/node_modules/@codebridge/router/package.json +18 -0
- package/node_modules/@codebridge/run-executor/dist/agent-event-aggregator.d.ts +18 -0
- package/node_modules/@codebridge/run-executor/dist/agent-event-aggregator.js +88 -0
- package/node_modules/@codebridge/run-executor/dist/index.d.ts +55 -0
- package/node_modules/@codebridge/run-executor/dist/index.js +754 -0
- package/node_modules/@codebridge/run-executor/dist/run-heartbeat.d.ts +14 -0
- package/node_modules/@codebridge/run-executor/dist/run-heartbeat.js +24 -0
- package/node_modules/@codebridge/run-executor/package.json +20 -0
- package/node_modules/@codebridge/runner-client/dist/index.d.ts +142 -0
- package/node_modules/@codebridge/runner-client/dist/index.js +439 -0
- package/node_modules/@codebridge/runner-client/package.json +18 -0
- package/node_modules/@codebridge/runner-host/dist/cli.d.ts +3 -0
- package/node_modules/@codebridge/runner-host/dist/cli.js +58 -0
- package/node_modules/@codebridge/runner-host/dist/codex-session-ownership.d.ts +13 -0
- package/node_modules/@codebridge/runner-host/dist/codex-session-ownership.js +79 -0
- package/node_modules/@codebridge/runner-host/dist/deployment-mcp-server.d.ts +10 -0
- package/node_modules/@codebridge/runner-host/dist/deployment-mcp-server.js +54 -0
- package/node_modules/@codebridge/runner-host/dist/fcb-script.d.ts +3 -0
- package/node_modules/@codebridge/runner-host/dist/fcb-script.js +99 -0
- package/node_modules/@codebridge/runner-host/dist/index.d.ts +3 -0
- package/node_modules/@codebridge/runner-host/dist/index.js +2 -0
- package/node_modules/@codebridge/runner-host/dist/materialize-attachments.d.ts +4 -0
- package/node_modules/@codebridge/runner-host/dist/materialize-attachments.js +62 -0
- package/node_modules/@codebridge/runner-host/dist/server.d.ts +150 -0
- package/node_modules/@codebridge/runner-host/dist/server.js +1295 -0
- package/node_modules/@codebridge/runner-host/dist/session-lease.d.ts +12 -0
- package/node_modules/@codebridge/runner-host/dist/session-lease.js +146 -0
- package/node_modules/@codebridge/runner-host/package.json +26 -0
- package/node_modules/@codebridge/session-catalog/dist/index.d.ts +124 -0
- package/node_modules/@codebridge/session-catalog/dist/index.js +411 -0
- package/node_modules/@codebridge/session-catalog/package.json +17 -0
- package/node_modules/@codebridge/session-coordinator/dist/coordinator.d.ts +111 -0
- package/node_modules/@codebridge/session-coordinator/dist/coordinator.js +364 -0
- package/node_modules/@codebridge/session-coordinator/dist/index.d.ts +5 -0
- package/node_modules/@codebridge/session-coordinator/dist/index.js +5 -0
- package/node_modules/@codebridge/session-coordinator/dist/lease.d.ts +14 -0
- package/node_modules/@codebridge/session-coordinator/dist/lease.js +26 -0
- package/node_modules/@codebridge/session-coordinator/dist/queued-claim.d.ts +20 -0
- package/node_modules/@codebridge/session-coordinator/dist/queued-claim.js +45 -0
- package/node_modules/@codebridge/session-coordinator/dist/recovery.d.ts +31 -0
- package/node_modules/@codebridge/session-coordinator/dist/recovery.js +114 -0
- package/node_modules/@codebridge/session-coordinator/package.json +17 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/node_modules/@codebridge/web/dist/assets/abnfDiagram-N423BO3Z-C-JdFv0U.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/arc-DsNROjzU.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/architecture-TIHT7OUA-ZEBHG2JZ.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/architectureDiagram-T3A2C74G-OsrxcwPM.js +36 -0
- package/node_modules/@codebridge/web/dist/assets/array-BifhSqXX.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/blockDiagram-VBNYF7ZC-DRgfNeNW.js +132 -0
- package/node_modules/@codebridge/web/dist/assets/c4Diagram-5PPSVZJV-BtOGKTh8.js +10 -0
- package/node_modules/@codebridge/web/dist/assets/channel-MhXyjxUS.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-2GRJ4B5K-Dy1gJ7sY.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-4I5QYGJK-1pOLR_SG.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-5RXB4S5H-CP43rgsO.js +231 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-6Q2QTUOP-Bi3Xrp6W.js +88 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-7BUUIJ7U-Bb538aSH.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-7Z6QIM7H-CILAW2Nk.js +10 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-GF5L2VYU-CAp09yhq.js +206 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-I66GZJ75-B_rJXmNu.js +128 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-JQJVKLGR-OVeOJFCx.js +156 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-KBJHAD2P-uaupp0k5.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-KEIR6QF5-BICK3FdT.js +161 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-NSK5VX7P-fIHF5wwn.js +2 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-QR6OTTB3-DxkJuF2b.js +62 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-RYQCIY6F-CC5j3u-X.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-UBXNYLIW-DB35O-6R.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-W5SLKNZC-bkRBsbq-.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-WRU74C26-DwvEoD-1.js +70 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-XXDRQBXY-DRyYA-HY.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/classDiagram-JCYQIIEL-B8r7z8ii.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/classDiagram-v2-OCEON4UE-B8r7z8ii.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/cose-bilkent-JH36ORCC-CLkwlrX7.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/cynefin-VYW2F7L2-C3_Llw02.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/cynefinDiagram-MW4NZA55-D5v7UnJy.js +62 -0
- package/node_modules/@codebridge/web/dist/assets/cytoscape.esm-B-NFISlW.js +321 -0
- package/node_modules/@codebridge/web/dist/assets/dagre-Buvkdvvj.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/dagre-VZM6K2ZE-Cr0IibwW.js +4 -0
- package/node_modules/@codebridge/web/dist/assets/defaultLocale-BFoDCU3G.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/diagram-7IWD3JNH-CpQXDIzA.js +30 -0
- package/node_modules/@codebridge/web/dist/assets/diagram-B4RE2ZJO-VaOkH0Ya.js +3 -0
- package/node_modules/@codebridge/web/dist/assets/diagram-LBJQPF4R-D0iXyNks.js +24 -0
- package/node_modules/@codebridge/web/dist/assets/diagram-Q27KOJAE-CtqYk01P.js +24 -0
- package/node_modules/@codebridge/web/dist/assets/diagram-UB23O5K3-CFnd3H1_.js +41 -0
- package/node_modules/@codebridge/web/dist/assets/dist-D2L7nRdk.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/ebnfDiagram-BXEA7PRR-B0GIbJYt.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/erDiagram-JOGREHBK-BApaLGVA.js +85 -0
- package/node_modules/@codebridge/web/dist/assets/eventmodeling-45OFAUF4-DqGGjcld.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/flowDiagram-UKHOOZJN-I_qlizLH.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/ganttDiagram-PKOTCBZU-B-QZ-J82.js +292 -0
- package/node_modules/@codebridge/web/dist/assets/gitGraph-TEB2WS4Q-DK2SJ2Ne.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/gitGraphDiagram-DS77QQ5N-B6Z-pu0D.js +106 -0
- package/node_modules/@codebridge/web/dist/assets/graphlib-DS17s2tU.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/index-8BzpyygS.js +559 -0
- package/node_modules/@codebridge/web/dist/assets/index-Bzaz89LE.css +1 -0
- package/node_modules/@codebridge/web/dist/assets/info-DKCQHKI2-CGWxt_Py.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/infoDiagram-6WML65LV-77XjrPZs.js +2 -0
- package/node_modules/@codebridge/web/dist/assets/init-C-OQMol4.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/ishikawaDiagram-WSZJBQD7-P1bZAz2x.js +70 -0
- package/node_modules/@codebridge/web/dist/assets/journeyDiagram-NVQOT4AX-C4rwMcBY.js +139 -0
- package/node_modules/@codebridge/web/dist/assets/kanban-definition-27J2QSJJ-mtw4a9bc.js +89 -0
- package/node_modules/@codebridge/web/dist/assets/line-DP4RkYqm.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/linear-DMg3PPio.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/map-BaFkSB1l.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/mermaid-parser.core-HY84kHw1.js +7 -0
- package/node_modules/@codebridge/web/dist/assets/mermaid.core-DdgCdsnM.js +42 -0
- package/node_modules/@codebridge/web/dist/assets/mindmap-definition-FAOFIHXS-Cw1EnbhZ.js +96 -0
- package/node_modules/@codebridge/web/dist/assets/ordinal-BDEzSJ7C.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/packet-7NZHBO7P-CEbrbJH3.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/path-fybaL0A-.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/pegDiagram-VL7TDLO6-CEc1Gedb.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/pie-RZYD4A2V-DPXVs-IW.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/pieDiagram-7S7Q4E2Y-hoQeGMFH.js +39 -0
- package/node_modules/@codebridge/web/dist/assets/quadrantDiagram-CIZ2JOQS-C-Nmxx0f.js +7 -0
- package/node_modules/@codebridge/web/dist/assets/radar-I7S5WNFK-BVd3X3Pd.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/railroad-3IZDKUUU-CxLxzr_v.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/railroad-abnf-AHOZXSZD-MA1zPI84.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/railroad-ebnf-EBAXGLYW-Bqug_umD.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/railroad-peg-LSFZ7HO6-DRcRFwpq.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/railroadDiagram-AXF67PYL-B007ZkL9.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/requirementDiagram-LRYGKXZP-LrTCcEi5.js +84 -0
- package/node_modules/@codebridge/web/dist/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/sankeyDiagram-W5VNT64P-Ch4mzHck.js +40 -0
- package/node_modules/@codebridge/web/dist/assets/sequenceDiagram-SI44F4Z6-CHg4OzLX.js +162 -0
- package/node_modules/@codebridge/web/dist/assets/sizeCapture-X5ZJPWSS-B0uUizjq.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/src-BrO6_odD.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/stateDiagram-OKZ733FA-7cVkr5nR.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/stateDiagram-v2-UEYNNEHI-CTy_mAXb.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/swimlanes-SLNWSIFB-BwSVF5qy.js +2 -0
- package/node_modules/@codebridge/web/dist/assets/swimlanesDiagram-ULZ7WXOC-BBQnfZ1j.js +8 -0
- package/node_modules/@codebridge/web/dist/assets/timeline-definition-Z64GVDOM-BaHEkVDV.js +120 -0
- package/node_modules/@codebridge/web/dist/assets/treeView-QDETBFTQ-CF0kLN62.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/treemap-6X3UGDF4-BB8A8uux.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/vennDiagram-T6HMQDX7-BFK12Iro.js +34 -0
- package/node_modules/@codebridge/web/dist/assets/wardley-OPB4EBWU-C_3y61zk.js +1 -0
- package/node_modules/@codebridge/web/dist/assets/wardleyDiagram-T6FBY63Y-W2oGu4WK.js +78 -0
- package/node_modules/@codebridge/web/dist/assets/xychartDiagram-ELKLHX3M-BiVRnbvz.js +7 -0
- package/node_modules/@codebridge/web/dist/brand/agent-logo-carbon.svg +1 -0
- package/node_modules/@codebridge/web/dist/brand/agent-logo.svg +1 -0
- package/node_modules/@codebridge/web/dist/brand/agnet-logo-carbon.svg +1 -0
- package/node_modules/@codebridge/web/dist/brand/agnet-logo.svg +1 -0
- package/node_modules/@codebridge/web/dist/brand/agnet-mark-carbon.svg +1 -0
- package/node_modules/@codebridge/web/dist/brand/agnet-mark.svg +1 -0
- package/node_modules/@codebridge/web/dist/fonts/CommitMono-400-Regular.otf +0 -0
- package/node_modules/@codebridge/web/dist/fonts/CommitMono-700-Regular.otf +0 -0
- package/node_modules/@codebridge/web/dist/fonts/CommitMono-OFL.txt +21 -0
- package/node_modules/@codebridge/web/dist/fonts/DepartureMono-OFL.txt +21 -0
- package/node_modules/@codebridge/web/dist/fonts/DepartureMono-Regular.woff2 +0 -0
- package/node_modules/@codebridge/web/dist/index.html +25 -0
- package/node_modules/@codebridge/web/package.json +7 -0
- package/node_modules/@codebridge/work-items/dist/index.d.ts +371 -0
- package/node_modules/@codebridge/work-items/dist/index.js +1784 -0
- package/node_modules/@codebridge/work-items/dist/session-projector.d.ts +4 -0
- package/node_modules/@codebridge/work-items/dist/session-projector.js +506 -0
- package/node_modules/@codebridge/work-items/dist/session-runtime.d.ts +274 -0
- package/node_modules/@codebridge/work-items/dist/session-runtime.js +1103 -0
- package/node_modules/@codebridge/work-items/dist/session-schema.d.ts +9 -0
- package/node_modules/@codebridge/work-items/dist/session-schema.js +292 -0
- package/node_modules/@codebridge/work-items/package.json +20 -0
- package/package.json +75 -4
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
import { resolveDefaultAgentId, } from "@codebridge/core";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { formatCompactCommandHelp, formatFullCommandHelp } from "./command-help.js";
|
|
6
|
+
import { formatDynamicModelHelp, formatDynamicOptionHelp, matchBackendConfigValue } from "./model-effort.js";
|
|
7
|
+
import { compactProjectPath, formatSessionLine, formatSessionListFooter, formatSessionListHeader } from "./session-list-format.js";
|
|
8
|
+
function canonicalDirectory(raw) {
|
|
9
|
+
if (!path.isAbsolute(raw)) {
|
|
10
|
+
return { error: `工作目录必须使用绝对路径: ${raw}` };
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const cwd = fs.realpathSync(raw);
|
|
14
|
+
if (!fs.statSync(cwd).isDirectory()) {
|
|
15
|
+
return { error: `工作目录不是目录: ${raw}` };
|
|
16
|
+
}
|
|
17
|
+
return { cwd };
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return { error: `工作目录不存在或无法访问: ${raw}` };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function handleSlashCommand(ctx) {
|
|
24
|
+
const trimmed = ctx.text.trim();
|
|
25
|
+
if (!trimmed.startsWith("/"))
|
|
26
|
+
return null;
|
|
27
|
+
const [cmd, ...rest] = trimmed.split(/\s+/);
|
|
28
|
+
const arg = rest.join(" ").trim();
|
|
29
|
+
const lower = cmd.toLowerCase();
|
|
30
|
+
switch (lower) {
|
|
31
|
+
case "/help":
|
|
32
|
+
return {
|
|
33
|
+
type: "reply",
|
|
34
|
+
text: arg.toLowerCase() === "full"
|
|
35
|
+
? formatFullCommandHelp(ctx.helpFormat)
|
|
36
|
+
: formatCompactCommandHelp(ctx.helpFormat),
|
|
37
|
+
};
|
|
38
|
+
case "/menu":
|
|
39
|
+
return {
|
|
40
|
+
type: "reply",
|
|
41
|
+
text: formatCompactCommandHelp(ctx.helpFormat),
|
|
42
|
+
};
|
|
43
|
+
case "/new":
|
|
44
|
+
case "/reset":
|
|
45
|
+
// 只 +1 代:下一句进新 session,旧 generation 的绑定与旧 run 不受影响。
|
|
46
|
+
ctx.router.incrementSlotGeneration(ctx.chatId, ctx.topicId);
|
|
47
|
+
return {
|
|
48
|
+
type: "reply",
|
|
49
|
+
text: "已新建会话,下一条消息将开启新的 Agent session。",
|
|
50
|
+
};
|
|
51
|
+
case "/stop":
|
|
52
|
+
case "/cancel":
|
|
53
|
+
case "/x":
|
|
54
|
+
if (!ctx.cancelActiveRun) {
|
|
55
|
+
return {
|
|
56
|
+
type: "reply",
|
|
57
|
+
text: "Runner 未就绪,无法停止任务。",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
{
|
|
61
|
+
const stopped = await ctx.cancelActiveRun();
|
|
62
|
+
return {
|
|
63
|
+
type: "reply",
|
|
64
|
+
text: stopped
|
|
65
|
+
? "已停止当前正在执行的 Agent 任务。"
|
|
66
|
+
: "当前没有正在运行的任务。",
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
case "/continue":
|
|
70
|
+
case "/c": {
|
|
71
|
+
if (!ctx.getSlotCommandContext || !ctx.resumeQueue) {
|
|
72
|
+
return { type: "reply", text: "Runner 未就绪,无法恢复队列。" };
|
|
73
|
+
}
|
|
74
|
+
const slot = await ctx.getSlotCommandContext();
|
|
75
|
+
if (!slot.sessionId) {
|
|
76
|
+
return { type: "reply", text: "当前槽位还没有 session,无需恢复。" };
|
|
77
|
+
}
|
|
78
|
+
const result = await ctx.resumeQueue(slot.sessionId);
|
|
79
|
+
return {
|
|
80
|
+
type: "reply",
|
|
81
|
+
text: result.queueState === "ready"
|
|
82
|
+
? "已恢复队列,等待中的消息将开始执行。"
|
|
83
|
+
: "队列未恢复(当前状态可能仍为 paused)。",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
case "/steer": {
|
|
87
|
+
if (!arg) {
|
|
88
|
+
return {
|
|
89
|
+
type: "reply",
|
|
90
|
+
text: "用法:`/steer <补充指令>`(注入当前正在执行的 ACP turn)",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (!ctx.getSlotCommandContext || !ctx.steerActiveRun) {
|
|
94
|
+
return { type: "reply", text: "Runner 未就绪,无法发送 steering。" };
|
|
95
|
+
}
|
|
96
|
+
const slot = await ctx.getSlotCommandContext();
|
|
97
|
+
if (!slot.activeRunId) {
|
|
98
|
+
return {
|
|
99
|
+
type: "reply",
|
|
100
|
+
text: "当前没有运行中的任务,无法 steering。",
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const result = await ctx.steerActiveRun(slot.activeRunId, arg);
|
|
104
|
+
return {
|
|
105
|
+
type: "reply",
|
|
106
|
+
text: result.ok
|
|
107
|
+
? `已发送 steering:${result.outcome ?? "accepted"}`
|
|
108
|
+
: `Steering 失败:${result.error ?? "当前 Agent 不支持或没有运行中的任务"}`,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
case "/approve":
|
|
112
|
+
case "/a":
|
|
113
|
+
case "/deny":
|
|
114
|
+
case "/d": {
|
|
115
|
+
if (!ctx.resolvePermission) {
|
|
116
|
+
return { type: "reply", text: "Runner 未就绪,无法回应权限请求。" };
|
|
117
|
+
}
|
|
118
|
+
const approve = lower === "/approve" || lower === "/a";
|
|
119
|
+
const resolved = await ctx.resolvePermission(approve);
|
|
120
|
+
return {
|
|
121
|
+
type: "reply",
|
|
122
|
+
text: resolved
|
|
123
|
+
? approve
|
|
124
|
+
? "✅ 已允许,任务继续。"
|
|
125
|
+
: "⛔ 已拒绝该操作,任务继续(agent 会收到拒绝结果)。"
|
|
126
|
+
: "当前没有等待回应的权限请求。",
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
case "/resume":
|
|
130
|
+
case "/r":
|
|
131
|
+
try {
|
|
132
|
+
return await handleResume(ctx, arg);
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
136
|
+
return {
|
|
137
|
+
type: "reply",
|
|
138
|
+
text: `ACP session 列表读取失败:${message}\n\n请运行 \`./scripts/start.sh doctor\` 检查 adapter。`,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
case "/session": {
|
|
142
|
+
const [action, sessionId, ...extra] = arg.split(/\s+/).filter(Boolean);
|
|
143
|
+
if ((action !== "close" && action !== "delete") ||
|
|
144
|
+
!sessionId ||
|
|
145
|
+
extra.length > 0) {
|
|
146
|
+
const operation = action === "delete" ? "delete" : "close";
|
|
147
|
+
return {
|
|
148
|
+
type: "reply",
|
|
149
|
+
text: `用法:\`/session ${operation} <sessionId>\``,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const callback = action === "close" ? ctx.closeSession : ctx.deleteSession;
|
|
153
|
+
if (!callback) {
|
|
154
|
+
return { type: "reply", text: "Runner 未就绪,无法管理 ACP session。" };
|
|
155
|
+
}
|
|
156
|
+
const result = await callback(sessionId);
|
|
157
|
+
if (!result.ok) {
|
|
158
|
+
return {
|
|
159
|
+
type: "reply",
|
|
160
|
+
text: `${action === "close" ? "关闭" : "删除"} ACP session 失败:${result.error ?? "未知错误"}`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const slot = await ctx.getSlotCommandContext?.();
|
|
164
|
+
const closedCurrent = slot?.sessionId === sessionId
|
|
165
|
+
|| (slot?.providerSessionId != null
|
|
166
|
+
&& slot.providerSessionId === sessionId);
|
|
167
|
+
if (closedCurrent) {
|
|
168
|
+
ctx.router.incrementSlotGeneration(ctx.chatId, ctx.topicId);
|
|
169
|
+
}
|
|
170
|
+
const closedLine = `已${action === "close" ? "关闭" : "删除"} ACP session:\`${sessionId}\``;
|
|
171
|
+
return {
|
|
172
|
+
type: "reply",
|
|
173
|
+
text: closedCurrent
|
|
174
|
+
? `${closedLine}\n下一条消息将开启新对话。`
|
|
175
|
+
: closedLine,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
case "/send":
|
|
179
|
+
if (!arg) {
|
|
180
|
+
return {
|
|
181
|
+
type: "reply",
|
|
182
|
+
text: "用法: `/send /绝对路径/文件` 或 `/send ~/Desktop/xx.csv`(发送 Bridge 所在机器上的文件)",
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return { type: "send_file", path: arg };
|
|
186
|
+
case "/status":
|
|
187
|
+
case "/s": {
|
|
188
|
+
const key = ctx.router.buildSessionKey(ctx.chatId, ctx.topicId);
|
|
189
|
+
const runOpts = ctx.router.resolveRunOptions(ctx.chatId, ctx.topicId, ctx.config);
|
|
190
|
+
const binding = ctx.router.getBinding(ctx.chatId, ctx.topicId);
|
|
191
|
+
const profile = ctx.config.backends[key.backendId];
|
|
192
|
+
// 当前槽位状态来自 Catalog + runtime(getSlotCommandContext),
|
|
193
|
+
// 不读 sessions.json(getSessionRecord),不读 activeChatRuns。
|
|
194
|
+
let sessionId = null;
|
|
195
|
+
let activeRunId = null;
|
|
196
|
+
if (ctx.getSlotCommandContext) {
|
|
197
|
+
const slot = await ctx.getSlotCommandContext();
|
|
198
|
+
sessionId = slot.sessionId;
|
|
199
|
+
activeRunId = slot.activeRunId;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
type: "reply",
|
|
203
|
+
text: [
|
|
204
|
+
`**backend**: ${key.backendId}`,
|
|
205
|
+
`**cwd**: ${key.cwd}`,
|
|
206
|
+
`**model**: ${runOpts.model ?? "(ACP 默认)"}${binding.model ? " _(会话覆盖)_" : profile?.model ? " _(配置默认)_" : ""}`,
|
|
207
|
+
"**transport**: acp",
|
|
208
|
+
`**effort**: ${runOpts.effort ?? "(ACP 默认)"}${binding.effort ? " _(会话覆盖)_" : profile?.effort ? " _(配置默认)_" : ""}`,
|
|
209
|
+
`**mode/permission**: ${runOpts.mode ?? "(ACP 默认)"}${binding.mode ? " _(会话覆盖)_" : profile?.claudePermissionMode ? " _(配置默认)_" : ""}`,
|
|
210
|
+
`**additionalDirectories**: ${binding.additionalDirectories?.length ? binding.additionalDirectories.join(", ") : "(none)"}`,
|
|
211
|
+
`**thinking**: ${(binding.showThinking ?? true) ? "on(显示思考/工具过程)" : "off(隐藏内部思考/工具,保留进度与最终答案)"}`,
|
|
212
|
+
`**sessionId**: ${sessionId ?? "(none)"}`,
|
|
213
|
+
`**activeRun**: ${activeRunId ?? "(none)"}`,
|
|
214
|
+
`**runnerActive**: ${activeRunId ? "是(请稍候再追问;需要中断请发 `/stop`)" : "否"}`,
|
|
215
|
+
].join("\n"),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
case "/model":
|
|
219
|
+
return handleModel(ctx, arg);
|
|
220
|
+
case "/effort":
|
|
221
|
+
return handleEffort(ctx, arg);
|
|
222
|
+
case "/transport":
|
|
223
|
+
return { type: "reply", text: "当前仅支持 ACP,无需切换 transport。" };
|
|
224
|
+
case "/permission":
|
|
225
|
+
case "/perm":
|
|
226
|
+
return handlePermission(ctx, arg);
|
|
227
|
+
case "/thinking":
|
|
228
|
+
case "/think":
|
|
229
|
+
return handleThinking(ctx, arg);
|
|
230
|
+
case "/cd": {
|
|
231
|
+
if (!arg)
|
|
232
|
+
return { type: "reply", text: "用法: `/cd /path/to/project`" };
|
|
233
|
+
const resolved = canonicalDirectory(arg);
|
|
234
|
+
if ("error" in resolved) {
|
|
235
|
+
return { type: "reply", text: resolved.error };
|
|
236
|
+
}
|
|
237
|
+
ctx.router.setBinding(ctx.chatId, { cwd: resolved.cwd }, ctx.topicId);
|
|
238
|
+
return { type: "reply", text: `已切换工作目录: ${resolved.cwd}` };
|
|
239
|
+
}
|
|
240
|
+
case "/root":
|
|
241
|
+
case "/roots":
|
|
242
|
+
return handleAdditionalDirectories(ctx, arg);
|
|
243
|
+
case "/config":
|
|
244
|
+
return handleAcpConfig(ctx, arg);
|
|
245
|
+
case "/backend":
|
|
246
|
+
case "/b": {
|
|
247
|
+
const id = arg === "default" || !arg
|
|
248
|
+
? resolveDefaultAgentId(ctx.config)
|
|
249
|
+
: arg;
|
|
250
|
+
if (!ctx.config.backends[id]) {
|
|
251
|
+
return {
|
|
252
|
+
type: "reply",
|
|
253
|
+
text: `未知 backend: ${id}。可选: ${Object.keys(ctx.config.backends).join(", ")}`,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
ctx.router.setBinding(ctx.chatId, { backendId: id }, ctx.topicId);
|
|
257
|
+
ctx.router.clearRunOverrides(ctx.chatId, ctx.topicId);
|
|
258
|
+
const profile = ctx.config.backends[id];
|
|
259
|
+
const modelHint = profile?.model ? `,model 默认 \`${profile.model}\`` : "";
|
|
260
|
+
return {
|
|
261
|
+
type: "reply",
|
|
262
|
+
text: `已切换 backend: ${id}${modelHint}(已清除上一 backend 的 model/effort 覆盖)`,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
case "/pull": {
|
|
266
|
+
const cwd = ctx.router.getBinding(ctx.chatId, ctx.topicId).cwd;
|
|
267
|
+
try {
|
|
268
|
+
const out = execSync("git pull --ff-only", {
|
|
269
|
+
cwd,
|
|
270
|
+
encoding: "utf8",
|
|
271
|
+
});
|
|
272
|
+
return { type: "reply", text: `git pull:\n${out}` };
|
|
273
|
+
}
|
|
274
|
+
catch (err) {
|
|
275
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
276
|
+
return { type: "reply", text: `git pull 失败: ${msg}` };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
case "/ws":
|
|
280
|
+
return handleWs(ctx, rest);
|
|
281
|
+
default:
|
|
282
|
+
if (lower === "/clone") {
|
|
283
|
+
return handleClone(ctx, rest);
|
|
284
|
+
}
|
|
285
|
+
return { type: "agent", prompt: trimmed };
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
async function handleAdditionalDirectories(ctx, arg) {
|
|
289
|
+
const binding = ctx.router.getBinding(ctx.chatId, ctx.topicId);
|
|
290
|
+
const directories = binding.additionalDirectories ?? [];
|
|
291
|
+
const [operation, ...pathParts] = arg.split(/\s+/).filter(Boolean);
|
|
292
|
+
const op = operation?.toLowerCase();
|
|
293
|
+
if (!arg || op === "list") {
|
|
294
|
+
return {
|
|
295
|
+
type: "reply",
|
|
296
|
+
text: directories.length
|
|
297
|
+
? ["**ACP 附加目录**", ...directories.map((dir, i) => `${i + 1}. ${dir}`)].join("\n")
|
|
298
|
+
: "当前没有 ACP 附加目录。用法:`/root add /absolute/path`",
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (op !== "add" && op !== "remove" && op !== "rm") {
|
|
302
|
+
return {
|
|
303
|
+
type: "reply",
|
|
304
|
+
text: "用法:`/roots`、`/root add /absolute/path`、`/root remove /absolute/path`",
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
const rawPath = pathParts.join(" ").trim();
|
|
308
|
+
if (!rawPath) {
|
|
309
|
+
return {
|
|
310
|
+
type: "reply",
|
|
311
|
+
text: `用法:\`/root ${op} /absolute/path\``,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
let target;
|
|
315
|
+
if (op === "add") {
|
|
316
|
+
let authorization = "";
|
|
317
|
+
if (ctx.authorizeDirectory) {
|
|
318
|
+
if (!path.isAbsolute(rawPath)) {
|
|
319
|
+
return { type: "reply", text: `工作目录必须使用绝对路径: ${rawPath}` };
|
|
320
|
+
}
|
|
321
|
+
await ctx.notifyStatus?.("⏳ Runner 正在请求 macOS 目录权限,请查看系统弹窗。").catch(() => { });
|
|
322
|
+
try {
|
|
323
|
+
const result = await ctx.authorizeDirectory(rawPath);
|
|
324
|
+
if (!result.ok && !result.path) {
|
|
325
|
+
return {
|
|
326
|
+
type: "reply",
|
|
327
|
+
text: `Runner 无法验证目录访问权限:${result.error ?? "目录不存在或无法访问"}`,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
target = result.path ?? path.resolve(rawPath);
|
|
331
|
+
authorization = result.ok
|
|
332
|
+
? "\nRunner 已验证目录访问权限。"
|
|
333
|
+
: `\nRunner 尚未获得目录访问权限:${result.error ?? "请在 macOS 弹窗中允许后重试"}`;
|
|
334
|
+
}
|
|
335
|
+
catch (err) {
|
|
336
|
+
// Runner 暂时不可用时保留旧的本地校验作为回退;正常 TCC 路径不会触碰 Bridge 的文件权限。
|
|
337
|
+
const resolved = canonicalDirectory(rawPath);
|
|
338
|
+
if ("error" in resolved)
|
|
339
|
+
return { type: "reply", text: resolved.error };
|
|
340
|
+
target = resolved.cwd;
|
|
341
|
+
authorization = `\nRunner 目录授权检查失败:${err instanceof Error ? err.message : String(err)}`;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
const resolved = canonicalDirectory(rawPath);
|
|
346
|
+
if ("error" in resolved)
|
|
347
|
+
return { type: "reply", text: resolved.error };
|
|
348
|
+
target = resolved.cwd;
|
|
349
|
+
}
|
|
350
|
+
if (target === binding.cwd) {
|
|
351
|
+
return { type: "reply", text: "附加目录不能与当前工作目录相同。" };
|
|
352
|
+
}
|
|
353
|
+
if (directories.includes(target)) {
|
|
354
|
+
return { type: "reply", text: `附加目录已存在:${target}` };
|
|
355
|
+
}
|
|
356
|
+
ctx.router.setBinding(ctx.chatId, { additionalDirectories: [...directories, target] }, ctx.topicId);
|
|
357
|
+
return {
|
|
358
|
+
type: "reply",
|
|
359
|
+
text: `已添加 ACP 附加目录:${target}${authorization}\n下一条消息生效;macOS TCC 仍需用户确认。`,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
if (!path.isAbsolute(rawPath)) {
|
|
363
|
+
return { type: "reply", text: `附加目录必须使用绝对路径: ${rawPath}` };
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
target = fs.realpathSync(rawPath);
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
target = path.resolve(rawPath);
|
|
370
|
+
}
|
|
371
|
+
if (!directories.includes(target)) {
|
|
372
|
+
return { type: "reply", text: `附加目录不存在于当前会话:${target}` };
|
|
373
|
+
}
|
|
374
|
+
ctx.router.setBinding(ctx.chatId, { additionalDirectories: directories.filter((dir) => dir !== target) }, ctx.topicId);
|
|
375
|
+
return { type: "reply", text: `已移除 ACP 附加目录:${target}` };
|
|
376
|
+
}
|
|
377
|
+
async function handleAcpConfig(ctx, arg) {
|
|
378
|
+
if (!ctx.listConfigOptions) {
|
|
379
|
+
return { type: "reply", text: "Runner 未就绪,无法读取 ACP 配置能力。" };
|
|
380
|
+
}
|
|
381
|
+
let options;
|
|
382
|
+
try {
|
|
383
|
+
options = await ctx.listConfigOptions();
|
|
384
|
+
}
|
|
385
|
+
catch (err) {
|
|
386
|
+
return {
|
|
387
|
+
type: "reply",
|
|
388
|
+
text: `ACP 配置能力读取失败:${err instanceof Error ? err.message : String(err)}`,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const binding = ctx.router.getBinding(ctx.chatId, ctx.topicId);
|
|
392
|
+
const overrides = binding.acpConfig ?? {};
|
|
393
|
+
const [configId, ...valueParts] = arg.split(/\s+/).filter(Boolean);
|
|
394
|
+
if (!configId) {
|
|
395
|
+
if (!options.length)
|
|
396
|
+
return { type: "reply", text: "当前 ACP 适配器没有可配置项。" };
|
|
397
|
+
return {
|
|
398
|
+
type: "reply",
|
|
399
|
+
text: [
|
|
400
|
+
"**ACP 实时配置**",
|
|
401
|
+
...options.map((option) => {
|
|
402
|
+
const value = overrides[option.id] ?? option.currentValue ?? "(默认)";
|
|
403
|
+
return `- \`${option.id}\` · ${option.name} · ${option.type ?? "select"} · 当前: \`${String(value)}\``;
|
|
404
|
+
}),
|
|
405
|
+
"",
|
|
406
|
+
"用法:`/config <id> <value>`;恢复默认:`/config <id> default`",
|
|
407
|
+
].join("\n"),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
const option = options.find((candidate) => candidate.id === configId);
|
|
411
|
+
if (!option)
|
|
412
|
+
return { type: "reply", text: `未知 ACP config id:\`${configId}\`` };
|
|
413
|
+
const rawValue = valueParts.join(" ").trim();
|
|
414
|
+
if (!rawValue) {
|
|
415
|
+
return {
|
|
416
|
+
type: "reply",
|
|
417
|
+
text: `用法:\`/config ${configId} <value>\`\n当前:\`${String(overrides[configId] ?? option.currentValue ?? "(默认)")}\``,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
if (rawValue.toLowerCase() === "default") {
|
|
421
|
+
const next = { ...overrides };
|
|
422
|
+
delete next[configId];
|
|
423
|
+
ctx.router.setBinding(ctx.chatId, { acpConfig: next }, ctx.topicId);
|
|
424
|
+
return { type: "reply", text: `已清除 ACP config 覆盖:\`${configId}\`` };
|
|
425
|
+
}
|
|
426
|
+
let value;
|
|
427
|
+
if (option.type === "boolean") {
|
|
428
|
+
const lowerValue = rawValue.toLowerCase();
|
|
429
|
+
if (["true", "on", "1", "yes"].includes(lowerValue))
|
|
430
|
+
value = true;
|
|
431
|
+
else if (["false", "off", "0", "no"].includes(lowerValue))
|
|
432
|
+
value = false;
|
|
433
|
+
else
|
|
434
|
+
return { type: "reply", text: `\`${configId}\` 需要 true/false(或 on/off)。` };
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
const matched = matchBackendConfigValue(option, rawValue);
|
|
438
|
+
if (!matched)
|
|
439
|
+
return invalidLiveValue(`config ${configId}`, rawValue, option);
|
|
440
|
+
value = matched;
|
|
441
|
+
}
|
|
442
|
+
ctx.router.setBinding(ctx.chatId, { acpConfig: { ...overrides, [configId]: value } }, ctx.topicId);
|
|
443
|
+
return {
|
|
444
|
+
type: "reply",
|
|
445
|
+
text: `已设置 ACP config:\`${configId}\` = \`${String(value)}\`\n下一条消息生效。`,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
/** 上一次 /resume 展示给用户的列表(按聊天/话题缓存),供 /resume <N> 按原序号定位 */
|
|
449
|
+
const RESUME_LIST_CACHE_MAX = 500;
|
|
450
|
+
const resumeListCache = new Map();
|
|
451
|
+
function resumeCacheKey(ctx) {
|
|
452
|
+
return `${ctx.chatId}|${ctx.topicId ?? ""}`;
|
|
453
|
+
}
|
|
454
|
+
function setResumeListCache(ctx, sessions) {
|
|
455
|
+
const cacheKey = resumeCacheKey(ctx);
|
|
456
|
+
if (!resumeListCache.has(cacheKey) &&
|
|
457
|
+
resumeListCache.size >= RESUME_LIST_CACHE_MAX) {
|
|
458
|
+
const oldest = resumeListCache.keys().next().value;
|
|
459
|
+
if (oldest !== undefined)
|
|
460
|
+
resumeListCache.delete(oldest);
|
|
461
|
+
}
|
|
462
|
+
resumeListCache.set(cacheKey, sessions);
|
|
463
|
+
}
|
|
464
|
+
/** D6:把 Provider Session 绑定到当前槽位;槽位已绑他 Session 时 +1 代重试。 */
|
|
465
|
+
async function resumeBoundSession(ctx, providerSessionId) {
|
|
466
|
+
if (!ctx.resumeProviderSession) {
|
|
467
|
+
return { ok: false, text: "Runner 未就绪,无法 /resume。" };
|
|
468
|
+
}
|
|
469
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
470
|
+
const result = await ctx.resumeProviderSession(providerSessionId);
|
|
471
|
+
if (result.ok && result.sessionId) {
|
|
472
|
+
return { ok: true, sessionId: result.sessionId };
|
|
473
|
+
}
|
|
474
|
+
if (result.busy) {
|
|
475
|
+
return {
|
|
476
|
+
ok: false,
|
|
477
|
+
text: `Provider session \`${providerSessionId}\` 正被其他任务占用,请稍后再试。`,
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
if (result.conflict) {
|
|
481
|
+
// 当前槽位已绑别的 Session:+1 代后重试(保留旧绑定不被打断)。
|
|
482
|
+
ctx.router.incrementSlotGeneration(ctx.chatId, ctx.topicId);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
return { ok: false, text: `绑定失败:${result.error ?? "未知错误"}` };
|
|
486
|
+
}
|
|
487
|
+
return { ok: false, text: "绑定失败:槽位冲突。请先 /new 再试。" };
|
|
488
|
+
}
|
|
489
|
+
async function handleResume(ctx, arg) {
|
|
490
|
+
if (!ctx.listSessions || !ctx.resumeProviderSession) {
|
|
491
|
+
return {
|
|
492
|
+
type: "reply",
|
|
493
|
+
text: "Runner 未就绪,无法列出/绑定 ACP session。请先启动 codebridge-runner。",
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
const key = ctx.router.buildSessionKey(ctx.chatId, ctx.topicId);
|
|
497
|
+
const listAll = arg.toLowerCase() === "all";
|
|
498
|
+
if (/^\d+$/.test(arg)) {
|
|
499
|
+
const index = Number(arg);
|
|
500
|
+
const sessions = resumeListCache.get(resumeCacheKey(ctx)) ??
|
|
501
|
+
(await ctx.listSessions({ all: listAll }));
|
|
502
|
+
const picked = sessions[index - 1];
|
|
503
|
+
if (!picked) {
|
|
504
|
+
return {
|
|
505
|
+
type: "reply",
|
|
506
|
+
text: `无效序号 ${index}。先发送 \`/resume\` 查看列表(共 ${sessions.length} 条)。`,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
const resolved = canonicalDirectory(picked.cwd);
|
|
510
|
+
if ("error" in resolved) {
|
|
511
|
+
return { type: "reply", text: resolved.error };
|
|
512
|
+
}
|
|
513
|
+
ctx.router.setBinding(ctx.chatId, {
|
|
514
|
+
cwd: resolved.cwd,
|
|
515
|
+
additionalDirectories: picked.additionalDirectories ?? [],
|
|
516
|
+
}, ctx.topicId);
|
|
517
|
+
const resumed = await resumeBoundSession(ctx, picked.id);
|
|
518
|
+
if (!resumed.ok) {
|
|
519
|
+
return { type: "reply", text: resumed.text };
|
|
520
|
+
}
|
|
521
|
+
return {
|
|
522
|
+
type: "reply",
|
|
523
|
+
text: [
|
|
524
|
+
`已绑定 **${key.backendId}** provider session 到当前会话:`,
|
|
525
|
+
`- id: \`${picked.id}\``,
|
|
526
|
+
`- cwd: ${picked.cwd}`,
|
|
527
|
+
...(picked.additionalDirectories?.length
|
|
528
|
+
? [`- additionalDirectories: ${picked.additionalDirectories.join(", ")}`]
|
|
529
|
+
: []),
|
|
530
|
+
`- preview: ${picked.preview}`,
|
|
531
|
+
"",
|
|
532
|
+
"下一条消息将通过 ACP 继续该 session。",
|
|
533
|
+
].join("\n"),
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
if (arg.toLowerCase() === "last") {
|
|
537
|
+
const sessions = await ctx.listSessions();
|
|
538
|
+
const picked = sessions[0];
|
|
539
|
+
if (!picked) {
|
|
540
|
+
return {
|
|
541
|
+
type: "reply",
|
|
542
|
+
text: `当前目录 \`${key.cwd}\` 下没有找到 **${key.backendId}** 本地 session。`,
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
const resolved = canonicalDirectory(picked.cwd);
|
|
546
|
+
if ("error" in resolved) {
|
|
547
|
+
return { type: "reply", text: resolved.error };
|
|
548
|
+
}
|
|
549
|
+
ctx.router.setBinding(ctx.chatId, {
|
|
550
|
+
cwd: resolved.cwd,
|
|
551
|
+
additionalDirectories: picked.additionalDirectories ?? [],
|
|
552
|
+
}, ctx.topicId);
|
|
553
|
+
const resumed = await resumeBoundSession(ctx, picked.id);
|
|
554
|
+
if (!resumed.ok) {
|
|
555
|
+
return { type: "reply", text: resumed.text };
|
|
556
|
+
}
|
|
557
|
+
return {
|
|
558
|
+
type: "reply",
|
|
559
|
+
text: [
|
|
560
|
+
`已绑定最近一条 **${key.backendId}** provider session:`,
|
|
561
|
+
`- id: \`${picked.id}\``,
|
|
562
|
+
`- preview: ${picked.preview}`,
|
|
563
|
+
...(picked.additionalDirectories?.length
|
|
564
|
+
? [`- additionalDirectories: ${picked.additionalDirectories.join(", ")}`]
|
|
565
|
+
: []),
|
|
566
|
+
"",
|
|
567
|
+
"下一条消息将通过 ACP 继续该 session。",
|
|
568
|
+
].join("\n"),
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
if (arg && arg.toLowerCase() !== "all") {
|
|
572
|
+
return {
|
|
573
|
+
type: "reply",
|
|
574
|
+
text: "用法: `/resume` | `/resume <N>` | `/resume last` | `/resume all`",
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
const sessions = await ctx.listSessions({ all: listAll });
|
|
578
|
+
const boundSessionId = (await ctx.getSlotCommandContext?.())?.sessionId ?? null;
|
|
579
|
+
if (sessions.length === 0) {
|
|
580
|
+
const bound = boundSessionId
|
|
581
|
+
? `\n当前已绑定: \`${boundSessionId}\``
|
|
582
|
+
: "";
|
|
583
|
+
const scopeHint = listAll
|
|
584
|
+
? "本机"
|
|
585
|
+
: `\`${key.cwd}\` 及其子目录`;
|
|
586
|
+
return {
|
|
587
|
+
type: "reply",
|
|
588
|
+
text: `在 ${scopeHint} 下未找到 **${key.backendId}** 本地 session。${bound}\n\n可在终端直接用对应 CLI 开聊后,再回来 \`/resume\`;或 \`/resume all\` 查看全部。`,
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
const showCwd = listAll || new Set(sessions.map((s) => s.cwd)).size > 1;
|
|
592
|
+
const displayLimit = 15;
|
|
593
|
+
const visible = sessions.slice(0, displayLimit);
|
|
594
|
+
const lines = listAll
|
|
595
|
+
? formatGroupedSessionLines(visible)
|
|
596
|
+
: visible.map((s, i) => formatSessionLine(s, i, showCwd));
|
|
597
|
+
const boundLine = boundSessionId ?? undefined;
|
|
598
|
+
setResumeListCache(ctx, visible);
|
|
599
|
+
return {
|
|
600
|
+
type: "reply",
|
|
601
|
+
text: [
|
|
602
|
+
formatSessionListHeader({
|
|
603
|
+
backendId: key.backendId,
|
|
604
|
+
scopeCwd: key.cwd,
|
|
605
|
+
listAll,
|
|
606
|
+
total: sessions.length,
|
|
607
|
+
showCwd,
|
|
608
|
+
displayLimit: sessions.length > displayLimit ? displayLimit : undefined,
|
|
609
|
+
}),
|
|
610
|
+
"",
|
|
611
|
+
...lines,
|
|
612
|
+
"",
|
|
613
|
+
formatSessionListFooter(boundLine),
|
|
614
|
+
].join("\n"),
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
function formatGroupedSessionLines(sessions) {
|
|
618
|
+
const lines = [];
|
|
619
|
+
let currentCwd = "";
|
|
620
|
+
for (let i = 0; i < sessions.length; i++) {
|
|
621
|
+
const session = sessions[i];
|
|
622
|
+
if (session.cwd !== currentCwd) {
|
|
623
|
+
currentCwd = session.cwd;
|
|
624
|
+
if (lines.length)
|
|
625
|
+
lines.push("");
|
|
626
|
+
lines.push(`**目录:${compactProjectPath(currentCwd)}**`);
|
|
627
|
+
}
|
|
628
|
+
lines.push(formatSessionLine(session, i, false));
|
|
629
|
+
}
|
|
630
|
+
return lines;
|
|
631
|
+
}
|
|
632
|
+
async function handleModel(ctx, arg) {
|
|
633
|
+
const binding = ctx.router.getBinding(ctx.chatId, ctx.topicId);
|
|
634
|
+
const backendId = binding.backendId;
|
|
635
|
+
const profile = ctx.config.backends[backendId];
|
|
636
|
+
if (arg.toLowerCase() === "default") {
|
|
637
|
+
ctx.router.clearModel(ctx.chatId, ctx.topicId);
|
|
638
|
+
const fallback = profile?.model ?? "(ACP 默认)";
|
|
639
|
+
return {
|
|
640
|
+
type: "reply",
|
|
641
|
+
text: `已清除会话 model 覆盖,将使用: ${fallback}`,
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
const loaded = await loadConfigOption(ctx, "model", "model");
|
|
645
|
+
if ("reply" in loaded)
|
|
646
|
+
return loaded.reply;
|
|
647
|
+
const runOpts = ctx.router.resolveRunOptions(ctx.chatId, ctx.topicId, ctx.config);
|
|
648
|
+
if (!arg || arg.toLowerCase() === "list") {
|
|
649
|
+
return {
|
|
650
|
+
type: "reply",
|
|
651
|
+
text: formatDynamicModelHelp(backendId, loaded.option, runOpts.model),
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
const value = matchBackendConfigValue(loaded.option, arg);
|
|
655
|
+
if (!value)
|
|
656
|
+
return invalidLiveValue("model", arg, loaded.option);
|
|
657
|
+
ctx.router.setBinding(ctx.chatId, { model: value }, ctx.topicId);
|
|
658
|
+
return {
|
|
659
|
+
type: "reply",
|
|
660
|
+
text: `已设置 **${backendId}** model: \`${value}\`\n下一条消息生效。`,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
async function handleEffort(ctx, arg) {
|
|
664
|
+
const binding = ctx.router.getBinding(ctx.chatId, ctx.topicId);
|
|
665
|
+
const backendId = binding.backendId;
|
|
666
|
+
const profile = ctx.config.backends[backendId];
|
|
667
|
+
if (arg.toLowerCase() === "default") {
|
|
668
|
+
ctx.router.clearEffort(ctx.chatId, ctx.topicId);
|
|
669
|
+
const fallback = profile?.effort ?? "(ACP 默认)";
|
|
670
|
+
return {
|
|
671
|
+
type: "reply",
|
|
672
|
+
text: `已清除会话 effort 覆盖,将使用: ${fallback}`,
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
const loaded = await loadConfigOption(ctx, "thought_level", "effort");
|
|
676
|
+
if ("reply" in loaded)
|
|
677
|
+
return loaded.reply;
|
|
678
|
+
const runOpts = ctx.router.resolveRunOptions(ctx.chatId, ctx.topicId, ctx.config);
|
|
679
|
+
if (!arg || arg.toLowerCase() === "list") {
|
|
680
|
+
return {
|
|
681
|
+
type: "reply",
|
|
682
|
+
text: formatDynamicOptionHelp(backendId, "effort", "effort", loaded.option, runOpts.effort),
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
const value = matchBackendConfigValue(loaded.option, arg);
|
|
686
|
+
if (!value)
|
|
687
|
+
return invalidLiveValue("effort", arg, loaded.option);
|
|
688
|
+
ctx.router.setBinding(ctx.chatId, { effort: value }, ctx.topicId);
|
|
689
|
+
return {
|
|
690
|
+
type: "reply",
|
|
691
|
+
text: `已设置 **${backendId}** effort: \`${value}\`\n下一条消息生效。`,
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
async function handlePermission(ctx, arg) {
|
|
695
|
+
const binding = ctx.router.getBinding(ctx.chatId, ctx.topicId);
|
|
696
|
+
const backendId = binding.backendId;
|
|
697
|
+
const profile = ctx.config.backends[backendId];
|
|
698
|
+
if (arg.toLowerCase() === "default") {
|
|
699
|
+
ctx.router.clearMode(ctx.chatId, ctx.topicId);
|
|
700
|
+
ctx.router.clearClaudePermissionMode(ctx.chatId, ctx.topicId);
|
|
701
|
+
const policy = ctx.config.runnerHost?.acpPermissionPolicy ?? "auto_allow";
|
|
702
|
+
const fallback = profile?.claudePermissionMode ??
|
|
703
|
+
(backendId === "claude"
|
|
704
|
+
? policy === "auto_allow"
|
|
705
|
+
? "bypassPermissions(Runner auto_allow)"
|
|
706
|
+
: "default(由 Runner 处理权限请求)"
|
|
707
|
+
: "ACP 适配器默认 mode");
|
|
708
|
+
return {
|
|
709
|
+
type: "reply",
|
|
710
|
+
text: `已清除会话 permission 覆盖,将使用: ${fallback}`,
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
const loaded = await loadConfigOption(ctx, "mode", "mode/permission");
|
|
714
|
+
if ("reply" in loaded)
|
|
715
|
+
return loaded.reply;
|
|
716
|
+
const runOpts = ctx.router.resolveRunOptions(ctx.chatId, ctx.topicId, ctx.config);
|
|
717
|
+
if (!arg || arg.toLowerCase() === "list") {
|
|
718
|
+
const help = formatDynamicOptionHelp(backendId, "mode/permission", "permission", loaded.option, runOpts.mode);
|
|
719
|
+
const policy = ctx.config.runnerHost?.acpPermissionPolicy ?? "auto_allow";
|
|
720
|
+
return {
|
|
721
|
+
type: "reply",
|
|
722
|
+
text: `${help}\n\nRunner approval policy: \`${policy}\`(控制 ACP 权限请求如何批准;与 adapter mode 共同生效)`,
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
const value = matchBackendConfigValue(loaded.option, arg);
|
|
726
|
+
if (!value)
|
|
727
|
+
return invalidLiveValue("mode/permission", arg, loaded.option);
|
|
728
|
+
ctx.router.setBinding(ctx.chatId, { mode: value }, ctx.topicId);
|
|
729
|
+
return {
|
|
730
|
+
type: "reply",
|
|
731
|
+
text: `已设置 **${backendId}** mode/permission: \`${value}\`\n下一条消息生效。`,
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
async function loadConfigOption(ctx, category, label) {
|
|
735
|
+
const backendId = ctx.router.getBinding(ctx.chatId, ctx.topicId).backendId;
|
|
736
|
+
if (!ctx.listConfigOptions) {
|
|
737
|
+
return {
|
|
738
|
+
reply: { type: "reply", text: "Runner 未就绪,无法读取 ACP 实时能力。" },
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
try {
|
|
742
|
+
const options = await ctx.listConfigOptions();
|
|
743
|
+
const option = options.find((candidate) => candidate.category === category && candidate.values.length > 0);
|
|
744
|
+
if (!option) {
|
|
745
|
+
return {
|
|
746
|
+
reply: {
|
|
747
|
+
type: "reply",
|
|
748
|
+
text: `**${backendId}** ACP 适配器未提供 ${label} 配置项。`,
|
|
749
|
+
},
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
return { option };
|
|
753
|
+
}
|
|
754
|
+
catch (err) {
|
|
755
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
756
|
+
return {
|
|
757
|
+
reply: {
|
|
758
|
+
type: "reply",
|
|
759
|
+
text: `ACP 实时能力读取失败:${message}`,
|
|
760
|
+
},
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
function invalidLiveValue(label, input, option) {
|
|
765
|
+
const values = option.values.map((value) => value.name ?? value.value);
|
|
766
|
+
return {
|
|
767
|
+
type: "reply",
|
|
768
|
+
text: `${label} \`${input}\` 不在适配器实时列表中。\n可选: ${values.join(", ")}`,
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
function handleThinking(ctx, arg) {
|
|
772
|
+
const current = ctx.router.getBinding(ctx.chatId, ctx.topicId).showThinking ?? true;
|
|
773
|
+
const a = arg.trim().toLowerCase();
|
|
774
|
+
if (!a || a === "list" || a === "status") {
|
|
775
|
+
return {
|
|
776
|
+
type: "reply",
|
|
777
|
+
text: [
|
|
778
|
+
`思考过程展示: ${current ? "**on**(显示思考与工具调用过程)" : "**off**(隐藏内部思考/工具,保留进度与最终答案)"}`,
|
|
779
|
+
"",
|
|
780
|
+
"用法: `/thinking on|off`",
|
|
781
|
+
].join("\n"),
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
const on = ["on", "开", "show", "true", "1"].includes(a);
|
|
785
|
+
const off = ["off", "关", "hide", "false", "0"].includes(a);
|
|
786
|
+
if (!on && !off) {
|
|
787
|
+
return {
|
|
788
|
+
type: "reply",
|
|
789
|
+
text: `无效参数: ${arg}\n用法: \`/thinking on|off\`(当前: ${current ? "on" : "off"})`,
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
ctx.router.setBinding(ctx.chatId, { showThinking: on }, ctx.topicId);
|
|
793
|
+
return {
|
|
794
|
+
type: "reply",
|
|
795
|
+
text: on
|
|
796
|
+
? "已开启思考过程展示:卡片会显示思考与工具调用过程,`---` 分隔线之后是最终答案。"
|
|
797
|
+
: "已关闭思考过程展示:隐藏内部思考与工具过程,保留进度检查点和最终答案。下一条消息生效。",
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
function handleWs(ctx, rest) {
|
|
801
|
+
const sub = rest[0]?.toLowerCase();
|
|
802
|
+
const name = rest[1];
|
|
803
|
+
if (sub === "list") {
|
|
804
|
+
const map = ctx.router.listWorkspaceNames();
|
|
805
|
+
const lines = Object.entries(map).map(([k, v]) => `- **${k}**: ${v}`);
|
|
806
|
+
return {
|
|
807
|
+
type: "reply",
|
|
808
|
+
text: lines.length ? lines.join("\n") : "(暂无命名工作区)",
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
if (sub === "save" && name) {
|
|
812
|
+
const cwd = ctx.router.getBinding(ctx.chatId, ctx.topicId).cwd;
|
|
813
|
+
ctx.router.saveWorkspace(name, cwd);
|
|
814
|
+
return { type: "reply", text: `已保存工作区 \`${name}\` → ${cwd}` };
|
|
815
|
+
}
|
|
816
|
+
if (sub === "use" && name) {
|
|
817
|
+
const map = ctx.router.listWorkspaceNames();
|
|
818
|
+
const cwd = map[name];
|
|
819
|
+
if (!cwd)
|
|
820
|
+
return { type: "reply", text: `未找到工作区: ${name}` };
|
|
821
|
+
const resolved = canonicalDirectory(cwd);
|
|
822
|
+
if ("error" in resolved) {
|
|
823
|
+
return { type: "reply", text: resolved.error };
|
|
824
|
+
}
|
|
825
|
+
ctx.router.setBinding(ctx.chatId, { cwd: resolved.cwd }, ctx.topicId);
|
|
826
|
+
return { type: "reply", text: `已切换工作区: ${name} (${resolved.cwd})` };
|
|
827
|
+
}
|
|
828
|
+
if (sub === "remove" && name) {
|
|
829
|
+
ctx.router.removeWorkspace(name);
|
|
830
|
+
return { type: "reply", text: `已删除工作区: ${name}` };
|
|
831
|
+
}
|
|
832
|
+
return { type: "reply", text: "用法: `/ws list|save <名>|use <名>|remove <名>`" };
|
|
833
|
+
}
|
|
834
|
+
function handleClone(ctx, rest) {
|
|
835
|
+
const url = rest[0];
|
|
836
|
+
const name = rest[1];
|
|
837
|
+
if (!url)
|
|
838
|
+
return { type: "reply", text: "用法: `/clone <git-url> [name]`" };
|
|
839
|
+
const root = ctx.config.workspaces?.root ?? `${process.env.HOME}/Projects`;
|
|
840
|
+
const dirName = name ?? url.split("/").pop()?.replace(/\.git$/, "") ?? "repo";
|
|
841
|
+
const target = `${root}/${dirName}`;
|
|
842
|
+
try {
|
|
843
|
+
execSync(`git clone ${JSON.stringify(url)} ${JSON.stringify(target)}`, {
|
|
844
|
+
encoding: "utf8",
|
|
845
|
+
});
|
|
846
|
+
ctx.router.setBinding(ctx.chatId, { cwd: target }, ctx.topicId);
|
|
847
|
+
return { type: "reply", text: `已 clone 到 ${target}` };
|
|
848
|
+
}
|
|
849
|
+
catch (err) {
|
|
850
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
851
|
+
return { type: "reply", text: `clone 失败: ${msg}` };
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
export function checkAccess(config, chatId, senderId, isDm) {
|
|
855
|
+
const access = config.access;
|
|
856
|
+
if (!access)
|
|
857
|
+
return true;
|
|
858
|
+
if (access.allowedUsers?.length && !access.allowedUsers.includes(senderId)) {
|
|
859
|
+
return false;
|
|
860
|
+
}
|
|
861
|
+
if (!isDm &&
|
|
862
|
+
access.allowedChats?.length &&
|
|
863
|
+
!access.allowedChats.includes(chatId)) {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
return true;
|
|
867
|
+
}
|
|
868
|
+
export function isAdmin(config, senderId) {
|
|
869
|
+
const admins = config.access?.admins;
|
|
870
|
+
if (!admins?.length)
|
|
871
|
+
return true;
|
|
872
|
+
return admins.includes(senderId);
|
|
873
|
+
}
|
|
874
|
+
//# sourceMappingURL=slash-commands.js.map
|