@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,581 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { AgentRegistry, projectSetupState, supportedAgentSetupManifests } from "@codebridge/agent-registry";
|
|
3
|
+
import { FeishuBridge, runDoctor } from "@codebridge/channel-feishu";
|
|
4
|
+
import { TelegramBridge } from "@codebridge/channel-telegram";
|
|
5
|
+
import { ConfigStore, DEFAULT_DATA_DIR, VERSION, migrateConfigSecrets, resolveDefaultAgentId, } from "@codebridge/core";
|
|
6
|
+
import { McpRuntime, McpServerRegistry, SdkMcpClientFactory } from "@codebridge/mcp-runtime";
|
|
7
|
+
import { FeishuAlertMonitor } from "./feishu-alert-monitor.js";
|
|
8
|
+
import { initDefaults, runInitWizard, terminalIo } from "./init-wizard.js";
|
|
9
|
+
import { ApprovalService, CapabilityRegistry, CapabilityRuntime, PolicyEngine, registerDemoCapabilities, registerEquityCapabilities, } from "@codebridge/policy";
|
|
10
|
+
import { ProjectCatalogGitRepository, ProjectCatalogStore, ProjectDiscovery } from "@codebridge/project-catalog";
|
|
11
|
+
import { RunExecutor } from "@codebridge/run-executor";
|
|
12
|
+
import { RunnerClient } from "@codebridge/runner-client";
|
|
13
|
+
import { SessionCatalogStore } from "@codebridge/session-catalog";
|
|
14
|
+
import { SessionCoordinator, SessionLeaseService, SessionRecoveryService, reclaimQueuedRuns } from "@codebridge/session-coordinator";
|
|
15
|
+
import { SqliteEventStore } from "@codebridge/work-items";
|
|
16
|
+
import { Command } from "commander";
|
|
17
|
+
import fs from "node:fs";
|
|
18
|
+
import { hostname } from "node:os";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import { createChannelIngressApi, createChannelSessionIngress } from "./channel-ingress.js";
|
|
22
|
+
import { createMcpApp } from "./mcp-api.js";
|
|
23
|
+
import { DEFAULT_ROUTES, OUTBOUND_ROUTES, OutboundPublisherStore, addPublisher, listPublishers, publishersPath, revokePublisher, } from "./outbound-publishers.js";
|
|
24
|
+
import { createProjectCatalogApp } from "./project-api.js";
|
|
25
|
+
import { createSessionApp } from "./session-api.js";
|
|
26
|
+
import { SessionRuntimeMigration } from "./session-runtime-migration.js";
|
|
27
|
+
import { createSkillApp } from "./skill-api.js";
|
|
28
|
+
import { resolveStartupSurfaces } from "./startup-surfaces.js";
|
|
29
|
+
import { createWebFrontendApp } from "./web-frontend.js";
|
|
30
|
+
import { DeploymentService, mountDeploymentRoutes } from "./deployment.js";
|
|
31
|
+
import { startEventLoopLagMonitor } from "./event-loop-lag.js";
|
|
32
|
+
const program = new Command();
|
|
33
|
+
program
|
|
34
|
+
.name("codebridge")
|
|
35
|
+
.description("CodeBridge — 从飞书或 Telegram 远程驱动本机写代码")
|
|
36
|
+
.version(VERSION);
|
|
37
|
+
program
|
|
38
|
+
.command("start")
|
|
39
|
+
.description("启动飞书桥接服务")
|
|
40
|
+
.option("-c, --config <path>", "配置文件路径")
|
|
41
|
+
.option("--data-dir <path>", "数据目录", DEFAULT_DATA_DIR)
|
|
42
|
+
.option("--web", "本次启动启用 Web,不修改配置文件")
|
|
43
|
+
.action(async (opts) => {
|
|
44
|
+
const dataDir = opts.dataDir;
|
|
45
|
+
if (opts.config) {
|
|
46
|
+
process.env.DATA_DIR = path.dirname(path.resolve(opts.config));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
process.env.DATA_DIR = dataDir;
|
|
50
|
+
}
|
|
51
|
+
const store = new ConfigStore({ dataDir });
|
|
52
|
+
const config = store.get();
|
|
53
|
+
const surfaces = resolveStartupSurfaces(config, { web: opts.web });
|
|
54
|
+
const deployment = new DeploymentService({
|
|
55
|
+
configPath: path.join(dataDir, "deployer", "config.json"),
|
|
56
|
+
feishuConnected: () => bridge?.isConnected ?? false,
|
|
57
|
+
activeRuns: () => workItemStore.listRunsByStatus(["running"]).length,
|
|
58
|
+
});
|
|
59
|
+
let alertMonitor;
|
|
60
|
+
const bridge = surfaces.feishu
|
|
61
|
+
? new FeishuBridge({
|
|
62
|
+
config,
|
|
63
|
+
dataDir,
|
|
64
|
+
onDeploymentMessage: (message) => deployment.handleFeishuMessage(message),
|
|
65
|
+
prepareAlertReply: (message, topicId) => alertMonitor?.prepareReply(message, topicId),
|
|
66
|
+
onAlertReaction: async (reaction) => { await alertMonitor?.prepareReaction(reaction); },
|
|
67
|
+
isAlertMessage: (chatId, messageId) => alertMonitor?.isAlertMessage(chatId, messageId) ?? false,
|
|
68
|
+
isAlertChat: (chatId) => store.get().feishu.alertMonitor?.groups.some((group) => group.chatId === chatId) ?? false,
|
|
69
|
+
isAlertSender: (chatId, ids) => store.get().feishu.alertMonitor?.groups.some((group) => group.chatId === chatId && ids.some((id) => group.senderAppIds.includes(id))) ?? false,
|
|
70
|
+
isMaintenance: () => deployment.isMaintenance(),
|
|
71
|
+
onLog: (m) => console.log(m),
|
|
72
|
+
})
|
|
73
|
+
: undefined;
|
|
74
|
+
const telegram = surfaces.telegram && config.telegram
|
|
75
|
+
? new TelegramBridge({
|
|
76
|
+
config,
|
|
77
|
+
dataDir,
|
|
78
|
+
onLog: (m) => console.log(m),
|
|
79
|
+
})
|
|
80
|
+
: undefined;
|
|
81
|
+
const orchestrationPath = path.join(dataDir, "orchestration.sqlite");
|
|
82
|
+
const workItemStore = new SqliteEventStore(orchestrationPath);
|
|
83
|
+
const sessionCatalog = new SessionCatalogStore(path.join(dataDir, "sessions.sqlite"), {
|
|
84
|
+
defaultCwd: config.workspaces?.default ?? config.workspaces?.root ?? process.cwd(),
|
|
85
|
+
});
|
|
86
|
+
const migration = new SessionRuntimeMigration(sessionCatalog, workItemStore);
|
|
87
|
+
try {
|
|
88
|
+
const migrationResult = migration.run({ batchSize: 1_000 });
|
|
89
|
+
console.log("session runtime migration complete", migrationResult);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (error instanceof Error
|
|
93
|
+
&& error.message === "session_runtime_migration_conflict") {
|
|
94
|
+
console.error("session runtime migration conflict", JSON.stringify({
|
|
95
|
+
conflicts: error.conflicts ?? [],
|
|
96
|
+
}, null, 2));
|
|
97
|
+
process.exitCode = 1;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
const approvalService = new ApprovalService(workItemStore, path.join(dataDir, "approvals.sqlite"));
|
|
103
|
+
const capabilityRegistry = new CapabilityRegistry([], {
|
|
104
|
+
databasePath: path.join(dataDir, "capabilities.sqlite"),
|
|
105
|
+
});
|
|
106
|
+
const capabilityRuntime = new CapabilityRuntime();
|
|
107
|
+
registerDemoCapabilities(capabilityRegistry, capabilityRuntime);
|
|
108
|
+
registerEquityCapabilities(capabilityRegistry, capabilityRuntime);
|
|
109
|
+
const policyEngine = new PolicyEngine(capabilityRegistry);
|
|
110
|
+
const mcpRegistry = new McpServerRegistry(path.join(dataDir, "mcp.sqlite"));
|
|
111
|
+
for (const [id, definition] of Object.entries(config.orchestration?.mcpServers ?? {})) {
|
|
112
|
+
mcpRegistry.registerServer({ id, ...definition });
|
|
113
|
+
}
|
|
114
|
+
const mcpRuntime = new McpRuntime(mcpRegistry, new SdkMcpClientFactory(), capabilityRegistry, capabilityRuntime);
|
|
115
|
+
const mcpApp = createMcpApp(mcpRegistry, mcpRuntime, config.runner.token);
|
|
116
|
+
for (const server of mcpRegistry.listServers().filter((candidate) => candidate.enabled !== false)) {
|
|
117
|
+
void mcpRuntime.discover(server.id).catch((error) => {
|
|
118
|
+
console.warn(`MCP discovery failed (${server.id}):`, error instanceof Error ? error.message : String(error));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const runnerClient = new RunnerClient({
|
|
122
|
+
baseUrl: config.runner.url,
|
|
123
|
+
token: config.runner.token,
|
|
124
|
+
});
|
|
125
|
+
const skillApp = createSkillApp(runnerClient, config.runner.token);
|
|
126
|
+
const sessionCoordinator = new SessionCoordinator(workItemStore, {
|
|
127
|
+
maxQueuedTurns: config.orchestration?.session?.maxQueuedTurns ?? 100,
|
|
128
|
+
});
|
|
129
|
+
const sessionLeaseService = new SessionLeaseService(workItemStore);
|
|
130
|
+
// hostname:pid 保证重启后的进程永远不会匹配到上一个进程留下的 lease_owner,
|
|
131
|
+
// 这样 startup 阶段的 scanExpired(此时 runExecutor 还没执行任何 Run)
|
|
132
|
+
// 仍然会把上个进程遗留的 stale Run 正常中断,而不会被误判为「自己还在执行」。
|
|
133
|
+
const executorOwner = `${hostname()}:${process.pid}`;
|
|
134
|
+
// runExecutor 在下面才构造,这里先用闭包延迟引用,供恢复扫描判断
|
|
135
|
+
// 「这个过期租约是不是我自己仍在执行的 Run」。
|
|
136
|
+
let runExecutor;
|
|
137
|
+
const sessionRecovery = new SessionRecoveryService(workItemStore, sessionCoordinator, sessionLeaseService, () => new Date(), {
|
|
138
|
+
owner: executorOwner,
|
|
139
|
+
isExecuting: (runId) => runExecutor.isExecuting(runId),
|
|
140
|
+
});
|
|
141
|
+
runExecutor = new RunExecutor(workItemStore, runnerClient, {
|
|
142
|
+
shouldPauseDispatch: () => deployment.isMaintenance(),
|
|
143
|
+
approvals: approvalService,
|
|
144
|
+
policy: policyEngine,
|
|
145
|
+
capabilities: capabilityRuntime,
|
|
146
|
+
sessionCoordinator,
|
|
147
|
+
sessionLeaseService,
|
|
148
|
+
executorOwner,
|
|
149
|
+
onEvent: (run, event) => {
|
|
150
|
+
if (event.type === "session") {
|
|
151
|
+
const workItem = workItemStore.getWorkItem(run.workItemId);
|
|
152
|
+
if (workItem?.conversationId.startsWith("conv_")) {
|
|
153
|
+
const session = sessionCatalog.getSession(`sess_${workItem.conversationId.slice("conv_".length)}`);
|
|
154
|
+
if (session) {
|
|
155
|
+
sessionCatalog.updateSession(session.id, {
|
|
156
|
+
providerSessionId: event.sessionId,
|
|
157
|
+
status: "active",
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
resolveRequest: (workItem, run) => {
|
|
164
|
+
const linkedSession = workItem.conversationId.startsWith("conv_")
|
|
165
|
+
? sessionCatalog.getSession(`sess_${workItem.conversationId.slice("conv_".length)}`)
|
|
166
|
+
: undefined;
|
|
167
|
+
const latestMessage = workItemStore
|
|
168
|
+
.listEvents(workItem.id)
|
|
169
|
+
.reverse()
|
|
170
|
+
.find((event) => event.type === "MESSAGE_RECEIVED")?.payload.message;
|
|
171
|
+
const scope = linkedSession?.cwd ?? workItem.workspaceScope[0];
|
|
172
|
+
const cwd = (scope && config.workspaces?.named?.[scope]) ??
|
|
173
|
+
(scope && path.isAbsolute(scope)
|
|
174
|
+
? scope
|
|
175
|
+
: scope && config.workspaces?.root
|
|
176
|
+
? path.join(config.workspaces.root, scope)
|
|
177
|
+
: undefined) ??
|
|
178
|
+
config.workspaces?.default ??
|
|
179
|
+
config.workspaces?.root ??
|
|
180
|
+
process.cwd();
|
|
181
|
+
const requestedBackend = linkedSession?.agentId ?? workItem.agentId;
|
|
182
|
+
const backendId = requestedBackend && config.backends[requestedBackend]
|
|
183
|
+
? requestedBackend
|
|
184
|
+
: resolveDefaultAgentId(config);
|
|
185
|
+
const basePrompt = typeof latestMessage === "string" ? latestMessage : workItem.title;
|
|
186
|
+
const deploymentGuidance = deployment.guidanceForRun(run.id, workItemStore);
|
|
187
|
+
const guidedPrompt = deploymentGuidance ? `${basePrompt}\n\n${deploymentGuidance}` : basePrompt;
|
|
188
|
+
const prompt = guidedPrompt;
|
|
189
|
+
return {
|
|
190
|
+
runId: run.id,
|
|
191
|
+
sessionKey: {
|
|
192
|
+
chatId: workItem.conversationId,
|
|
193
|
+
backendId,
|
|
194
|
+
cwd,
|
|
195
|
+
},
|
|
196
|
+
prompt,
|
|
197
|
+
model: linkedSession?.model ?? undefined,
|
|
198
|
+
effort: linkedSession?.effort ?? undefined,
|
|
199
|
+
acpConfig: linkedSession?.configOverrides,
|
|
200
|
+
mode: linkedSession?.permissionMode ?? undefined,
|
|
201
|
+
resumeSessionId: run.providerSessionId ?? undefined,
|
|
202
|
+
additionalDirectories: linkedSession?.additionalDirectories,
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
const eventLoopLagMonitor = startEventLoopLagMonitor();
|
|
207
|
+
sessionRecovery.scanExpired();
|
|
208
|
+
sessionRecovery.scanCancellationDeadlines();
|
|
209
|
+
const reclaimQueued = () => {
|
|
210
|
+
if (deployment.isMaintenance())
|
|
211
|
+
return;
|
|
212
|
+
try {
|
|
213
|
+
reclaimQueuedRuns({
|
|
214
|
+
store: workItemStore,
|
|
215
|
+
coordinator: sessionCoordinator,
|
|
216
|
+
execute: (runId) => {
|
|
217
|
+
void runExecutor.execute(runId).catch(() => { });
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
console.error("Queued run reclaim failed:", error instanceof Error ? error.message : String(error));
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const recoveryInterval = setInterval(() => {
|
|
226
|
+
try {
|
|
227
|
+
sessionRecovery.scanExpired();
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
console.error("Session recovery scan failed:", error instanceof Error ? error.message : String(error));
|
|
231
|
+
}
|
|
232
|
+
reclaimQueued();
|
|
233
|
+
}, 15_000);
|
|
234
|
+
const cancellationInterval = setInterval(() => {
|
|
235
|
+
try {
|
|
236
|
+
sessionRecovery.scanCancellationDeadlines();
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
console.error("Session cancellation scan failed:", error instanceof Error ? error.message : String(error));
|
|
240
|
+
}
|
|
241
|
+
}, 1_000);
|
|
242
|
+
reclaimQueued();
|
|
243
|
+
const projectCatalog = new ProjectCatalogStore(path.join(dataDir, "project-catalog.sqlite"));
|
|
244
|
+
const projectDiscovery = new ProjectDiscovery(projectCatalog, {
|
|
245
|
+
events: workItemStore,
|
|
246
|
+
});
|
|
247
|
+
const projectCatalogApp = createProjectCatalogApp(projectCatalog, projectDiscovery, config.runner.token, config.orchestration?.projectCatalog
|
|
248
|
+
? new ProjectCatalogGitRepository({
|
|
249
|
+
repositoryPath: config.orchestration.projectCatalog.repositoryPath,
|
|
250
|
+
baseRef: config.orchestration.projectCatalog.baseRef,
|
|
251
|
+
catalogPath: config.orchestration.projectCatalog.catalogPath,
|
|
252
|
+
})
|
|
253
|
+
: undefined);
|
|
254
|
+
const supportedSetupManifests = new Map(supportedAgentSetupManifests.map((manifest) => [manifest.agentId, manifest]));
|
|
255
|
+
const knownAgents = [...supportedSetupManifests.keys(), ...Object.keys(config.backends)];
|
|
256
|
+
const agentIds = [...new Set(knownAgents)];
|
|
257
|
+
const registry = new AgentRegistry({ databasePath: path.join(dataDir, "agents.sqlite") });
|
|
258
|
+
agentIds.forEach((agentId) => {
|
|
259
|
+
const profile = config.backends[agentId];
|
|
260
|
+
const manifest = supportedSetupManifests.get(agentId);
|
|
261
|
+
if (manifest) {
|
|
262
|
+
registry.register({
|
|
263
|
+
agentId,
|
|
264
|
+
displayName: manifest.displayName,
|
|
265
|
+
adapter: manifest.adapter,
|
|
266
|
+
status: "needs_setup",
|
|
267
|
+
capabilities: profile ? ["session", "workspace", "run"] : [],
|
|
268
|
+
models: profile?.model ? [profile.model] : [],
|
|
269
|
+
sessionFeatures: profile
|
|
270
|
+
? ["resume", "close", "delete", ...(profile.type === "pi-sdk" ? ["fork"] : [])]
|
|
271
|
+
: [],
|
|
272
|
+
setup: projectSetupState({
|
|
273
|
+
installation: "unknown",
|
|
274
|
+
configuration: "unknown",
|
|
275
|
+
runtime: "not_started",
|
|
276
|
+
}),
|
|
277
|
+
setupManifest: manifest,
|
|
278
|
+
});
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
registry.register({
|
|
282
|
+
agentId,
|
|
283
|
+
displayName: agentId,
|
|
284
|
+
adapter: agentId === "pi" ? "sdk" : profile?.type === "generic-spawn" ? "cli" : "acp",
|
|
285
|
+
status: profile ? "healthy" : "needs_setup",
|
|
286
|
+
capabilities: profile ? ["session", "workspace", "run"] : [],
|
|
287
|
+
models: profile?.model ? [profile.model] : [],
|
|
288
|
+
sessionFeatures: profile
|
|
289
|
+
? ["resume", "close", "delete", ...(profile.type === "pi-sdk" ? ["fork"] : [])]
|
|
290
|
+
: [],
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
// Runner may still be booting when the Bridge starts (launchd starts both
|
|
294
|
+
// concurrently), so retry in the background instead of a one-shot attempt
|
|
295
|
+
// that leaves every Agent stuck in needs_setup until restart.
|
|
296
|
+
const applyAgentSetup = async () => {
|
|
297
|
+
const setup = await runnerClient.listAgentSetup();
|
|
298
|
+
for (const agent of setup.agents) {
|
|
299
|
+
registry.updateSetup(agent.agentId, {
|
|
300
|
+
installation: agent.installation,
|
|
301
|
+
configuration: agent.configuration,
|
|
302
|
+
runtime: agent.runtime,
|
|
303
|
+
version: agent.version,
|
|
304
|
+
executablePath: agent.executablePath,
|
|
305
|
+
diagnostic: agent.diagnostic,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
return true;
|
|
309
|
+
};
|
|
310
|
+
void (async () => {
|
|
311
|
+
for (let attempt = 0; attempt < 150; attempt++) {
|
|
312
|
+
try {
|
|
313
|
+
await applyAgentSetup();
|
|
314
|
+
if (attempt > 0)
|
|
315
|
+
console.log(`Agent setup detection succeeded after ${attempt + 1} attempts`);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
if (attempt === 149) {
|
|
320
|
+
console.warn("Agent setup detection failed:", error instanceof Error ? error.message : String(error));
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
await new Promise((resolve) => setTimeout(resolve, attempt < 30 ? 1_000 : 15_000));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
})();
|
|
327
|
+
const agentHealthAdapters = agentIds
|
|
328
|
+
.filter((agentId) => Boolean(config.backends[agentId]))
|
|
329
|
+
.map((agentId) => ({
|
|
330
|
+
agentId,
|
|
331
|
+
kind: registry.get(agentId).adapter,
|
|
332
|
+
health: async () => (await runnerClient.health()).ok ? "healthy" : "unavailable",
|
|
333
|
+
}));
|
|
334
|
+
await Promise.all(agentHealthAdapters.map((adapter) => registry.refresh(adapter)));
|
|
335
|
+
const stopAgentHealthChecks = registry.startHealthChecks(agentHealthAdapters, 5_000);
|
|
336
|
+
const webFrontendApp = surfaces.web
|
|
337
|
+
? createWebFrontendApp({
|
|
338
|
+
staticDirectory: config.web.staticDirectory ??
|
|
339
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../web/dist"),
|
|
340
|
+
token: config.runner.token,
|
|
341
|
+
})
|
|
342
|
+
: undefined;
|
|
343
|
+
const sessionCatalogApp = createSessionApp({
|
|
344
|
+
catalog: sessionCatalog,
|
|
345
|
+
agents: () => registry.list(),
|
|
346
|
+
agentRegistry: registry,
|
|
347
|
+
configStore: store,
|
|
348
|
+
workItems: workItemStore,
|
|
349
|
+
executor: runExecutor,
|
|
350
|
+
runner: runnerClient,
|
|
351
|
+
discovery: projectDiscovery,
|
|
352
|
+
capabilities: capabilityRegistry,
|
|
353
|
+
approvals: approvalService,
|
|
354
|
+
coordinator: sessionCoordinator,
|
|
355
|
+
defaultCwd: config.workspaces?.default ?? config.workspaces?.root ?? process.cwd(),
|
|
356
|
+
}, config.runner.token);
|
|
357
|
+
const channelSessionIngress = createChannelSessionIngress(createChannelIngressApi(sessionCatalogApp), config.runner.token);
|
|
358
|
+
bridge?.setSessionIngress(channelSessionIngress);
|
|
359
|
+
telegram?.setSessionIngress(channelSessionIngress);
|
|
360
|
+
if (bridge)
|
|
361
|
+
alertMonitor = new FeishuAlertMonitor({
|
|
362
|
+
statePath: path.join(dataDir, "feishu-alert-monitor.json"),
|
|
363
|
+
config: () => store.get().feishu.alertMonitor,
|
|
364
|
+
transport: bridge,
|
|
365
|
+
isMaintenance: () => deployment.isMaintenance(),
|
|
366
|
+
log: (message) => console.log(message),
|
|
367
|
+
});
|
|
368
|
+
store.onChange((c) => {
|
|
369
|
+
bridge?.updateConfig(c);
|
|
370
|
+
telegram?.updateConfig(c);
|
|
371
|
+
});
|
|
372
|
+
const shutdown = async () => {
|
|
373
|
+
await alertMonitor?.stop();
|
|
374
|
+
await bridge?.disconnect();
|
|
375
|
+
await telegram?.disconnect();
|
|
376
|
+
approvalService.close();
|
|
377
|
+
await mcpRuntime.close();
|
|
378
|
+
mcpRegistry.close();
|
|
379
|
+
capabilityRegistry.close();
|
|
380
|
+
clearInterval(recoveryInterval);
|
|
381
|
+
clearInterval(cancellationInterval);
|
|
382
|
+
eventLoopLagMonitor.stop();
|
|
383
|
+
stopAgentHealthChecks();
|
|
384
|
+
registry.close();
|
|
385
|
+
projectDiscovery.close();
|
|
386
|
+
sessionCatalog.close();
|
|
387
|
+
workItemStore.close();
|
|
388
|
+
process.exit(0);
|
|
389
|
+
};
|
|
390
|
+
process.on("SIGINT", shutdown);
|
|
391
|
+
process.on("SIGTERM", shutdown);
|
|
392
|
+
await bridge?.connect();
|
|
393
|
+
alertMonitor?.start();
|
|
394
|
+
if (telegram)
|
|
395
|
+
await telegram.connect();
|
|
396
|
+
const apiPort = config.bridge?.apiPort ?? 19790;
|
|
397
|
+
const { serve } = await import("@hono/node-server");
|
|
398
|
+
const { createBridgeApp } = await import("./outbound-api.js");
|
|
399
|
+
// 凭据文件坏掉只该让定时任务发不出去,不该连带拖垮整个 Bridge。
|
|
400
|
+
const publisherStore = new OutboundPublisherStore(dataDir, config.runner.token, (error) => {
|
|
401
|
+
console.error(`出站发布者配置无效,沿用上一份可用凭据:${error.message}`);
|
|
402
|
+
});
|
|
403
|
+
const apiApp = createBridgeApp({
|
|
404
|
+
setOutboundAlertStatus: (chatId, topicId, status, summary) => alertMonitor
|
|
405
|
+
? alertMonitor.setStatus(chatId, topicId, status, summary)
|
|
406
|
+
: Promise.reject(new Error("告警监控未配置")),
|
|
407
|
+
sendOutboundFile: (chatId, rawPath, topicId) => chatId.startsWith("telegram:")
|
|
408
|
+
? telegram
|
|
409
|
+
? telegram.sendOutboundFile(chatId, rawPath, topicId)
|
|
410
|
+
: Promise.reject(new Error("Telegram 通道未配置"))
|
|
411
|
+
: bridge
|
|
412
|
+
? bridge.sendOutboundFile(chatId, rawPath, topicId)
|
|
413
|
+
: Promise.reject(new Error("飞书通道未配置")),
|
|
414
|
+
sendOutboundMarkdown: (chatId, markdown, topicId) => chatId.startsWith("telegram:")
|
|
415
|
+
? telegram
|
|
416
|
+
? telegram.sendOutboundMarkdown(chatId, markdown, topicId)
|
|
417
|
+
: Promise.reject(new Error("Telegram 通道未配置"))
|
|
418
|
+
: bridge
|
|
419
|
+
? bridge.sendOutboundMarkdown(chatId, markdown, topicId)
|
|
420
|
+
: Promise.reject(new Error("飞书通道未配置")),
|
|
421
|
+
sendOutboundMention: (chatId, ref, text, topicId) => chatId.startsWith("telegram:")
|
|
422
|
+
? telegram
|
|
423
|
+
? telegram.sendOutboundMention(chatId, ref, text, topicId)
|
|
424
|
+
: Promise.reject(new Error("Telegram 通道未配置"))
|
|
425
|
+
: bridge
|
|
426
|
+
? bridge.sendOutboundMention(chatId, ref, text, topicId)
|
|
427
|
+
: Promise.reject(new Error("飞书通道未配置")),
|
|
428
|
+
}, config.runner.token, workItemStore, approvalService, runExecutor, projectCatalogApp, webFrontendApp, sessionCatalogApp, mcpApp, skillApp, () => publisherStore.current());
|
|
429
|
+
mountDeploymentRoutes(apiApp, deployment, workItemStore);
|
|
430
|
+
serve({
|
|
431
|
+
fetch: apiApp.fetch,
|
|
432
|
+
hostname: "127.0.0.1",
|
|
433
|
+
port: apiPort,
|
|
434
|
+
});
|
|
435
|
+
console.log(`Core API 监听 http://127.0.0.1:${apiPort}`);
|
|
436
|
+
console.log(`Web: ${surfaces.web ? `enabled at http://127.0.0.1:${apiPort}/workbench/` : "disabled"}`);
|
|
437
|
+
console.log(`Feishu: ${surfaces.feishu ? "enabled" : "disabled"}`);
|
|
438
|
+
const loadedPublishers = publisherStore.current();
|
|
439
|
+
console.log(`出站发布者: ${loadedPublishers.length
|
|
440
|
+
? loadedPublishers.map((row) => `${row.label}[${row.routes.join("/")}]`).join(", ")
|
|
441
|
+
: "none"}`);
|
|
442
|
+
console.log(`Telegram: ${surfaces.telegram ? "enabled" : "disabled"}`);
|
|
443
|
+
});
|
|
444
|
+
program
|
|
445
|
+
.command("init")
|
|
446
|
+
.description("交互式初始化:只补缺失项、校验凭据、密钥存入系统钥匙串")
|
|
447
|
+
.option("--data-dir <path>", "数据目录", DEFAULT_DATA_DIR)
|
|
448
|
+
.option("--defaults", "非交互:仅在 config.yaml 不存在时写入默认配置")
|
|
449
|
+
.action(async (opts) => {
|
|
450
|
+
if (opts.defaults || !process.stdin.isTTY) {
|
|
451
|
+
const result = initDefaults(opts.dataDir);
|
|
452
|
+
console.log(result.written ? "已写入默认配置(随机 Runner token 或环境变量引用,文件权限 600):" : "config.yaml 已存在,未修改:", result.configPath);
|
|
453
|
+
if (result.written)
|
|
454
|
+
console.log("非交互模式未校验通道凭据;可运行 codebridge init 完成配置,secrets migrate 将明文密钥迁入钥匙串。");
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const io = terminalIo();
|
|
458
|
+
try {
|
|
459
|
+
const summary = await runInitWizard({ dataDir: opts.dataDir, io });
|
|
460
|
+
io.print(`\n✓ 已保存 ${summary.configPath}`);
|
|
461
|
+
io.print(` 通道:${summary.channels.join("、") || "无"};默认 Agent:${summary.defaultAgent ?? "未设置"}`);
|
|
462
|
+
io.print(` 密钥:${Object.entries(summary.secretStorage).map(([name, where]) => `${name}=${where}`).join(",")}`);
|
|
463
|
+
io.print("下一步:运行 codebridge-runner,另开终端运行 codebridge start;源码安装也可用 ./scripts/start.sh start。codebridge doctor 检查连接。");
|
|
464
|
+
}
|
|
465
|
+
finally {
|
|
466
|
+
io.close();
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
program
|
|
470
|
+
.command("doctor")
|
|
471
|
+
.description("诊断配置与 Runner 连接")
|
|
472
|
+
.option("--data-dir <path>", "数据目录", DEFAULT_DATA_DIR)
|
|
473
|
+
.action(async (opts) => {
|
|
474
|
+
// Inspect secrets first and without throwing: a broken ref is exactly what doctor must report.
|
|
475
|
+
const secretReport = ConfigStore.inspectSecrets(path.join(opts.dataDir, "config.yaml"));
|
|
476
|
+
const warnings = [
|
|
477
|
+
...Object.entries(secretReport).filter(([, item]) => item.source === "plaintext")
|
|
478
|
+
.map(([name]) => `config.yaml 中 ${name} 为明文,运行 codebridge secrets migrate 移入系统钥匙串`),
|
|
479
|
+
...Object.entries(secretReport).filter(([, item]) => item.error).map(([, item]) => item.error),
|
|
480
|
+
];
|
|
481
|
+
let report;
|
|
482
|
+
try {
|
|
483
|
+
report = await runDoctor(new ConfigStore({ dataDir: opts.dataDir }).get(), opts.dataDir);
|
|
484
|
+
}
|
|
485
|
+
catch (error) {
|
|
486
|
+
report = { ok: false, configError: error instanceof Error ? error.message : String(error) };
|
|
487
|
+
}
|
|
488
|
+
console.log(JSON.stringify({ ...report, secrets: secretReport, ...(warnings.length ? { warnings } : {}) }, null, 2));
|
|
489
|
+
});
|
|
490
|
+
const secrets = program
|
|
491
|
+
.command("secrets")
|
|
492
|
+
.description("管理 config.yaml 中的密钥(飞书 appSecret、Runner token、Telegram botToken)");
|
|
493
|
+
secrets
|
|
494
|
+
.command("status")
|
|
495
|
+
.description("显示每个密钥的来源(keychain / env / plaintext / missing),不输出值")
|
|
496
|
+
.option("--data-dir <path>", "数据目录", DEFAULT_DATA_DIR)
|
|
497
|
+
.action((opts) => {
|
|
498
|
+
console.log(JSON.stringify(ConfigStore.inspectSecrets(path.join(opts.dataDir, "config.yaml")), null, 2));
|
|
499
|
+
});
|
|
500
|
+
secrets
|
|
501
|
+
.command("migrate")
|
|
502
|
+
.description("把明文密钥移入系统钥匙串,并在 config.yaml 中改为 keychain: 引用")
|
|
503
|
+
.option("--data-dir <path>", "数据目录", DEFAULT_DATA_DIR)
|
|
504
|
+
.action((opts) => {
|
|
505
|
+
const configPath = path.join(opts.dataDir, "config.yaml");
|
|
506
|
+
if (!fs.existsSync(configPath))
|
|
507
|
+
throw new Error(`${configPath} 不存在`);
|
|
508
|
+
const result = migrateConfigSecrets(configPath);
|
|
509
|
+
console.log(JSON.stringify({ ...result, secrets: ConfigStore.inspectSecrets(configPath) }, null, 2));
|
|
510
|
+
if (result.migrated.length) {
|
|
511
|
+
// A running Bridge still holds the plaintext and would write it back on its next config save.
|
|
512
|
+
console.error("已改为钥匙串引用。请立即重启 Bridge 和 Runner;部署器需重新安装才会改用引用(scripts/install-host-deployer.mjs)。");
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
const publisher = program
|
|
516
|
+
.command("publisher")
|
|
517
|
+
.description("管理定时任务等非 Agent 发送方的出站凭据");
|
|
518
|
+
function runnerTokenOf(dataDir) {
|
|
519
|
+
const store = new ConfigStore({ dataDir });
|
|
520
|
+
// 没有 config.yaml 时 ConfigStore 会回落到占位 token,静默把凭据写进错的目录。
|
|
521
|
+
if (!fs.existsSync(store.path)) {
|
|
522
|
+
throw new Error(`${store.path} 不存在:--data-dir 指错了,或该目录尚未 codebridge init`);
|
|
523
|
+
}
|
|
524
|
+
return store.get().runner.token;
|
|
525
|
+
}
|
|
526
|
+
function parseRouteOption(value) {
|
|
527
|
+
const routes = value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
528
|
+
if (routes.length === 0) {
|
|
529
|
+
throw new Error(`--routes 不能为空,省略它即表示只授予 ${DEFAULT_ROUTES.join("、")}`);
|
|
530
|
+
}
|
|
531
|
+
for (const route of routes) {
|
|
532
|
+
if (!OUTBOUND_ROUTES.includes(route)) {
|
|
533
|
+
throw new Error(`未知路由 ${route},可选:${OUTBOUND_ROUTES.join("、")}`);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return routes;
|
|
537
|
+
}
|
|
538
|
+
publisher
|
|
539
|
+
.command("add")
|
|
540
|
+
.description("签发一条凭据;同名 label 视为轮换,旧 token 立即作废")
|
|
541
|
+
.requiredOption("--label <name>", "调用方名字,例如 stock-daily-trade")
|
|
542
|
+
.requiredOption("--chat <id>", "固定收件人:飞书 oc_ 开头,Telegram telegram: 开头")
|
|
543
|
+
.option("--topic <id>", "话题 ID")
|
|
544
|
+
.option("--routes <list>", `逗号分隔,默认 markdown,mention;可选 ${OUTBOUND_ROUTES.join("、")}`)
|
|
545
|
+
.option("--data-dir <path>", "数据目录", DEFAULT_DATA_DIR)
|
|
546
|
+
.action((opts) => {
|
|
547
|
+
const issued = addPublisher(opts.dataDir, runnerTokenOf(opts.dataDir), {
|
|
548
|
+
label: opts.label,
|
|
549
|
+
chatId: opts.chat,
|
|
550
|
+
topicId: opts.topic,
|
|
551
|
+
routes: opts.routes === undefined ? undefined : parseRouteOption(opts.routes),
|
|
552
|
+
});
|
|
553
|
+
console.log(JSON.stringify({
|
|
554
|
+
label: issued.label, token: issued.token, chatId: issued.chatId,
|
|
555
|
+
topicId: issued.topicId, routes: issued.routes, path: publishersPath(opts.dataDir),
|
|
556
|
+
}, null, 2));
|
|
557
|
+
console.error("token 只在此刻打印一次,请立刻写入调用方配置;Bridge 会自动热加载,无需重启。");
|
|
558
|
+
});
|
|
559
|
+
publisher
|
|
560
|
+
.command("list")
|
|
561
|
+
.description("列出已登记的发布者(不含 token)")
|
|
562
|
+
.option("--data-dir <path>", "数据目录", DEFAULT_DATA_DIR)
|
|
563
|
+
.action((opts) => {
|
|
564
|
+
console.log(JSON.stringify(listPublishers(opts.dataDir, runnerTokenOf(opts.dataDir)), null, 2));
|
|
565
|
+
});
|
|
566
|
+
publisher
|
|
567
|
+
.command("revoke")
|
|
568
|
+
.description("吊销一条凭据")
|
|
569
|
+
.requiredOption("--label <name>", "要吊销的 label")
|
|
570
|
+
.option("--data-dir <path>", "数据目录", DEFAULT_DATA_DIR)
|
|
571
|
+
.action((opts) => {
|
|
572
|
+
const removed = revokePublisher(opts.dataDir, runnerTokenOf(opts.dataDir), opts.label);
|
|
573
|
+
console.log(JSON.stringify({ label: opts.label, revoked: removed }, null, 2));
|
|
574
|
+
if (!removed)
|
|
575
|
+
process.exitCode = 1;
|
|
576
|
+
});
|
|
577
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
578
|
+
console.error(err);
|
|
579
|
+
process.exit(1);
|
|
580
|
+
});
|
|
581
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import type { FeishuMessage } from "@codebridge/channel-feishu";
|
|
3
|
+
import type { SqliteEventStore } from "@codebridge/work-items";
|
|
4
|
+
export type DeploymentAction = "prepare" | "publish" | "status" | "cancel" | "rollback";
|
|
5
|
+
export interface DeploymentCommand {
|
|
6
|
+
action: DeploymentAction;
|
|
7
|
+
releaseId?: string;
|
|
8
|
+
ref?: string;
|
|
9
|
+
publishAfterPrepare?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseDeploymentCommand(text: string): DeploymentCommand | undefined;
|
|
12
|
+
export declare function hasPublishIntent(text: string): boolean;
|
|
13
|
+
export declare class DeploymentService {
|
|
14
|
+
private readonly options;
|
|
15
|
+
private readonly nativeMessages;
|
|
16
|
+
constructor(options?: {
|
|
17
|
+
configPath?: string;
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
feishuConnected?: () => boolean;
|
|
20
|
+
activeRuns?: () => number;
|
|
21
|
+
});
|
|
22
|
+
private get configPath();
|
|
23
|
+
private readConfig;
|
|
24
|
+
isOwner(actorId: string): boolean;
|
|
25
|
+
isMaintenance(): boolean;
|
|
26
|
+
readiness(): {
|
|
27
|
+
ok: boolean;
|
|
28
|
+
releaseId: string;
|
|
29
|
+
commit: string;
|
|
30
|
+
feishuConnected: boolean;
|
|
31
|
+
activeRuns: number;
|
|
32
|
+
maintenance: boolean;
|
|
33
|
+
};
|
|
34
|
+
command(command: DeploymentCommand, context: {
|
|
35
|
+
actorId: string;
|
|
36
|
+
chatId: string;
|
|
37
|
+
messageId: string;
|
|
38
|
+
}): Promise<string>;
|
|
39
|
+
nativeContext(messageId: string): FeishuMessage | undefined;
|
|
40
|
+
guidance(actorId: string, text: string): string;
|
|
41
|
+
guidanceForRun(runId: string, store: SqliteEventStore): string;
|
|
42
|
+
handleFeishuMessage(message: FeishuMessage): Promise<string | undefined>;
|
|
43
|
+
}
|
|
44
|
+
/** Mount on the existing authenticated Bridge app; no new listening socket. */
|
|
45
|
+
export declare function mountDeploymentRoutes(app: Hono, service: DeploymentService, store: SqliteEventStore): void;
|
|
46
|
+
//# sourceMappingURL=deployment.d.ts.map
|