@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,832 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { JsonArrayStore, JsonMapStore } from "@codebridge/core";
|
|
6
|
+
export const SKILL_AGENT_IDS = ["codex", "claude", "cursor", "opencode", "pi"];
|
|
7
|
+
export class SkillControlPlaneError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
status;
|
|
10
|
+
name = "SkillControlPlaneError";
|
|
11
|
+
constructor(code, message, status = 409) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.status = status;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const TARGET_NAMES = {
|
|
18
|
+
codex: "Codex",
|
|
19
|
+
claude: "Claude Code",
|
|
20
|
+
cursor: "Cursor",
|
|
21
|
+
opencode: "OpenCode",
|
|
22
|
+
pi: "Pi",
|
|
23
|
+
};
|
|
24
|
+
const SOURCE_PRIORITY = {
|
|
25
|
+
shared: 4,
|
|
26
|
+
disabled: 3,
|
|
27
|
+
adopted: 2,
|
|
28
|
+
agent_native: 1,
|
|
29
|
+
};
|
|
30
|
+
export class SkillControlPlane {
|
|
31
|
+
homeDirectory;
|
|
32
|
+
sharedRoot;
|
|
33
|
+
disabledRoot;
|
|
34
|
+
targetRoots;
|
|
35
|
+
sources;
|
|
36
|
+
ownership;
|
|
37
|
+
assignments;
|
|
38
|
+
plans;
|
|
39
|
+
transactions;
|
|
40
|
+
constructor(options) {
|
|
41
|
+
this.homeDirectory = path.resolve(options.homeDirectory ?? os.homedir());
|
|
42
|
+
this.sharedRoot = path.resolve(options.sharedRoot ?? path.join(this.homeDirectory, ".agents", "skills"));
|
|
43
|
+
this.disabledRoot = path.resolve(options.disabledRoot ?? path.join(this.homeDirectory, ".agents", "skills-disabled"));
|
|
44
|
+
this.targetRoots = options.targetRoots ?? {
|
|
45
|
+
codex: path.join(this.homeDirectory, ".codex", "skills"),
|
|
46
|
+
claude: path.join(this.homeDirectory, ".claude", "skills"),
|
|
47
|
+
cursor: path.join(this.homeDirectory, ".cursor", "skills"),
|
|
48
|
+
opencode: path.join(this.homeDirectory, ".config", "opencode", "skills"),
|
|
49
|
+
pi: path.join(this.homeDirectory, ".pi", "agent", "skills"),
|
|
50
|
+
};
|
|
51
|
+
const stateDirectory = path.join(options.dataDir, "state", "skills");
|
|
52
|
+
const sourcesPath = path.join(stateDirectory, "sources.json");
|
|
53
|
+
migrateLegacyStateFile(path.join(options.dataDir, "skill-sources.json"), sourcesPath);
|
|
54
|
+
this.sources = new JsonArrayStore(sourcesPath);
|
|
55
|
+
this.ownership = new JsonMapStore(path.join(stateDirectory, "ownership.json"));
|
|
56
|
+
this.assignments = new JsonMapStore(path.join(stateDirectory, "assignments.json"));
|
|
57
|
+
this.plans = new JsonMapStore(path.join(stateDirectory, "plans.json"));
|
|
58
|
+
this.transactions = new JsonMapStore(path.join(stateDirectory, "transactions.json"));
|
|
59
|
+
this.recoverPendingTransactions();
|
|
60
|
+
}
|
|
61
|
+
scan() {
|
|
62
|
+
const discovered = new Map();
|
|
63
|
+
this.collectRoot(this.sharedRoot, "shared", discovered);
|
|
64
|
+
this.collectRoot(this.disabledRoot, "disabled", discovered);
|
|
65
|
+
for (const source of this.sources.read()) {
|
|
66
|
+
this.collectRoot(source, "adopted", discovered);
|
|
67
|
+
}
|
|
68
|
+
for (const agentId of SKILL_AGENT_IDS) {
|
|
69
|
+
this.collectRoot(this.targetRoots[agentId], "agent_native", discovered);
|
|
70
|
+
}
|
|
71
|
+
const grouped = new Map();
|
|
72
|
+
for (const skill of discovered.values()) {
|
|
73
|
+
const id = path.basename(skill.sourcePath);
|
|
74
|
+
grouped.set(id, [...(grouped.get(id) ?? []), skill]);
|
|
75
|
+
}
|
|
76
|
+
const skills = [...grouped.entries()]
|
|
77
|
+
.map(([id, candidates]) => this.toCatalogEntry(id, candidates))
|
|
78
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
79
|
+
const targets = SKILL_AGENT_IDS.map((agentId) => ({
|
|
80
|
+
agent_id: agentId,
|
|
81
|
+
display_name: TARGET_NAMES[agentId],
|
|
82
|
+
root_path: agentId === "claude" ? this.targetRoots[agentId] : this.sharedRoot,
|
|
83
|
+
delivery_mode: deliveryMode(agentId),
|
|
84
|
+
}));
|
|
85
|
+
const recoveryRequired = Object.values(this.transactions.read())
|
|
86
|
+
.filter((transaction) => transaction.status === "failed").length;
|
|
87
|
+
return {
|
|
88
|
+
skills,
|
|
89
|
+
targets,
|
|
90
|
+
summary: {
|
|
91
|
+
total: skills.length,
|
|
92
|
+
sources: new Set(skills.map((skill) => skill.source_kind)).size,
|
|
93
|
+
linked: skills.flatMap((skill) => skill.targets)
|
|
94
|
+
.filter((target) => target.state === "linked" || target.state === "follows_global").length,
|
|
95
|
+
issues: skills.filter((skill) => !skill.can_apply).length
|
|
96
|
+
+ skills.flatMap((skill) => skill.targets)
|
|
97
|
+
.filter((target) => target.state === "conflict" || target.state === "broken").length
|
|
98
|
+
+ recoveryRequired,
|
|
99
|
+
recovery_required: recoveryRequired,
|
|
100
|
+
},
|
|
101
|
+
scanned_at: new Date().toISOString(),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
addSource(rawPath) {
|
|
105
|
+
if (!path.isAbsolute(rawPath)) {
|
|
106
|
+
throw new SkillControlPlaneError("skill_source_invalid", "Skill Source 必须使用绝对路径", 400);
|
|
107
|
+
}
|
|
108
|
+
let resolved;
|
|
109
|
+
try {
|
|
110
|
+
resolved = fs.realpathSync(rawPath);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
throw new SkillControlPlaneError("skill_source_invalid", `Skill Source 不存在或不可访问: ${rawPath}`, 400);
|
|
114
|
+
}
|
|
115
|
+
if (!this.skillDirectories(resolved).length) {
|
|
116
|
+
throw new SkillControlPlaneError("skill_source_invalid", "所选目录自身或直接子目录中没有 SKILL.md", 400);
|
|
117
|
+
}
|
|
118
|
+
this.sources.update((current) => (current.includes(resolved) ? current : [...current, resolved]));
|
|
119
|
+
return this.scan();
|
|
120
|
+
}
|
|
121
|
+
previewAdopt(input) {
|
|
122
|
+
const skill = this.findSkill(input.skill_id);
|
|
123
|
+
this.assertPackageCanMutate(skill);
|
|
124
|
+
if (skill.ownership === "native_managed") {
|
|
125
|
+
throw new SkillControlPlaneError("skill_adopt_forbidden", `Skill 由 Agent 或系统原生管理,不能 Adopt: ${skill.id}`);
|
|
126
|
+
}
|
|
127
|
+
const alreadyShared = isPathInside(this.sharedRoot, skill.source_path)
|
|
128
|
+
|| isPathInside(this.disabledRoot, skill.source_path);
|
|
129
|
+
const targetPath = alreadyShared ? skill.source_path : path.join(this.sharedRoot, skill.id);
|
|
130
|
+
const targetOccupied = !alreadyShared && pathExists(targetPath);
|
|
131
|
+
return this.createPlan({
|
|
132
|
+
actorId: input.actor_id,
|
|
133
|
+
kind: "adopt",
|
|
134
|
+
skill,
|
|
135
|
+
targetPath,
|
|
136
|
+
canApply: !targetOccupied,
|
|
137
|
+
detail: targetOccupied ? `共享目录已存在同名 Skill: ${targetPath}` : null,
|
|
138
|
+
request: {},
|
|
139
|
+
steps: alreadyShared
|
|
140
|
+
? [{ action: "set_ownership", detail: "原地登记为 CodeBridge 受管 Skill" }]
|
|
141
|
+
: [
|
|
142
|
+
{ action: "move", source_path: skill.source_path, target_path: targetPath, detail: "移动到共享启用目录" },
|
|
143
|
+
{ action: "create_link", source_path: targetPath, target_path: skill.source_path, detail: "在原位置创建兼容软链" },
|
|
144
|
+
{ action: "set_ownership", detail: "登记 ownership 与 provenance" },
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
previewAssignment(input) {
|
|
149
|
+
const skill = this.findSkill(input.skill_id);
|
|
150
|
+
this.assertPackageCanMutate(skill);
|
|
151
|
+
if (input.agent_id !== "claude") {
|
|
152
|
+
throw new SkillControlPlaneError("skill_target_unknown", `${TARGET_NAMES[input.agent_id] ?? input.agent_id} 直接读取共享目录,不支持独立分发开关`, 400);
|
|
153
|
+
}
|
|
154
|
+
const target = skill.targets.find((candidate) => candidate.agent_id === input.agent_id);
|
|
155
|
+
const assignment = this.assignments.read()[assignmentKey(skill.id, input.agent_id)];
|
|
156
|
+
if (!input.enabled && target.state !== "absent" && !this.ownsProjectedLink(skill, assignment)) {
|
|
157
|
+
throw new SkillControlPlaneError("skill_unlink_forbidden", `目标不是 CodeBridge 拥有的软链,禁止移除: ${target.target_path}`);
|
|
158
|
+
}
|
|
159
|
+
if (skill.ownership !== "codebridge_managed") {
|
|
160
|
+
throw new SkillControlPlaneError("skill_adopt_forbidden", `Skill 必须先 Adopt 才能分发: ${skill.id}`);
|
|
161
|
+
}
|
|
162
|
+
const canApply = input.enabled
|
|
163
|
+
? target.state === "absent" || target.state === "linked"
|
|
164
|
+
: target.state === "absent" || target.state === "linked";
|
|
165
|
+
const steps = [];
|
|
166
|
+
if (input.enabled && skill.global_state === "enabled" && target.state === "absent") {
|
|
167
|
+
steps.push({ action: "create_link", source_path: skill.source_path, target_path: target.target_path, detail: "创建 Claude 兼容软链" });
|
|
168
|
+
}
|
|
169
|
+
if (!input.enabled && target.state === "linked") {
|
|
170
|
+
steps.push({ action: "remove_link", source_path: skill.source_path, target_path: target.target_path, detail: "移除 CodeBridge-owned Claude 软链" });
|
|
171
|
+
}
|
|
172
|
+
steps.push({ action: "set_assignment", detail: `保存期望状态: ${input.enabled ? "linked" : "absent"}` });
|
|
173
|
+
return this.createPlan({
|
|
174
|
+
actorId: input.actor_id,
|
|
175
|
+
kind: "assignment",
|
|
176
|
+
skill,
|
|
177
|
+
targetPath: target.target_path,
|
|
178
|
+
canApply,
|
|
179
|
+
detail: canApply ? null : target.detail,
|
|
180
|
+
request: { enabled: input.enabled, agent_id: input.agent_id },
|
|
181
|
+
steps,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
previewGlobalState(input) {
|
|
185
|
+
const skill = this.findSkill(input.skill_id);
|
|
186
|
+
this.assertPackageCanMutate(skill);
|
|
187
|
+
if (skill.ownership !== "codebridge_managed") {
|
|
188
|
+
throw new SkillControlPlaneError("skill_adopt_forbidden", `Skill 必须先 Adopt 才能全局启停: ${skill.id}`);
|
|
189
|
+
}
|
|
190
|
+
const targetPath = path.join(input.enabled ? this.sharedRoot : this.disabledRoot, skill.id);
|
|
191
|
+
const alreadyDesired = input.enabled
|
|
192
|
+
? skill.global_state === "enabled"
|
|
193
|
+
: skill.global_state === "disabled";
|
|
194
|
+
const targetOccupied = !alreadyDesired && pathExists(targetPath);
|
|
195
|
+
const steps = [];
|
|
196
|
+
if (!alreadyDesired) {
|
|
197
|
+
if (!input.enabled) {
|
|
198
|
+
steps.push({ action: "remove_link", detail: "暂停所有 CodeBridge-owned 适配软链" });
|
|
199
|
+
}
|
|
200
|
+
steps.push({ action: "move", source_path: skill.source_path, target_path: targetPath, detail: input.enabled ? "移回共享启用目录" : "移入可恢复停用目录" });
|
|
201
|
+
if (input.enabled) {
|
|
202
|
+
steps.push({ action: "create_link", detail: "恢复期望为 linked 的适配软链" });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return this.createPlan({
|
|
206
|
+
actorId: input.actor_id,
|
|
207
|
+
kind: "global_state",
|
|
208
|
+
skill,
|
|
209
|
+
targetPath,
|
|
210
|
+
canApply: !targetOccupied,
|
|
211
|
+
detail: targetOccupied ? `目标目录已存在: ${targetPath}` : null,
|
|
212
|
+
request: { enabled: input.enabled },
|
|
213
|
+
steps,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
previewUnmanage(input) {
|
|
217
|
+
const skill = this.findSkill(input.skill_id);
|
|
218
|
+
this.assertPackageCanMutate(skill);
|
|
219
|
+
if (skill.ownership !== "codebridge_managed") {
|
|
220
|
+
throw new SkillControlPlaneError("skill_adopt_forbidden", `Skill 当前未由 CodeBridge 管理: ${skill.id}`);
|
|
221
|
+
}
|
|
222
|
+
return this.createPlan({
|
|
223
|
+
actorId: input.actor_id,
|
|
224
|
+
kind: "unmanage",
|
|
225
|
+
skill,
|
|
226
|
+
targetPath: skill.source_path,
|
|
227
|
+
canApply: true,
|
|
228
|
+
detail: null,
|
|
229
|
+
request: {},
|
|
230
|
+
steps: [{ action: "set_ownership", detail: "取消纳管但保留内容和现有软链" }],
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
applyPlan(input) {
|
|
234
|
+
const plan = this.plans.read()[input.plan_id];
|
|
235
|
+
if (!plan) {
|
|
236
|
+
throw new SkillControlPlaneError("skill_plan_not_found", `Skill plan 不存在: ${input.plan_id}`, 404);
|
|
237
|
+
}
|
|
238
|
+
if (plan.actor_id !== input.actor_id) {
|
|
239
|
+
throw new SkillControlPlaneError("skill_plan_actor_mismatch", "Skill plan 不属于当前 actor", 409);
|
|
240
|
+
}
|
|
241
|
+
if (Date.parse(plan.expires_at) <= Date.now()) {
|
|
242
|
+
throw new SkillControlPlaneError("skill_plan_expired", "Skill plan 已过期,请重新预览", 409);
|
|
243
|
+
}
|
|
244
|
+
if (!plan.can_apply) {
|
|
245
|
+
throw new SkillControlPlaneError("skill_target_conflict", plan.detail ?? "Skill plan 存在冲突", 409);
|
|
246
|
+
}
|
|
247
|
+
const skill = this.findSkill(plan.skill_id);
|
|
248
|
+
if (skill.package_revision !== plan.package_revision) {
|
|
249
|
+
throw new SkillControlPlaneError("skill_revision_mismatch", "Skill Package 在预览后发生变化", 409);
|
|
250
|
+
}
|
|
251
|
+
if (fingerprintPath(plan.source_path) !== plan.source_fingerprint) {
|
|
252
|
+
throw new SkillControlPlaneError("skill_revision_mismatch", "Skill Source 在预览后发生变化", 409);
|
|
253
|
+
}
|
|
254
|
+
if (fingerprintPath(plan.target_path) !== plan.target_fingerprint) {
|
|
255
|
+
throw new SkillControlPlaneError("skill_target_conflict", "Skill Target 在预览后发生变化", 409);
|
|
256
|
+
}
|
|
257
|
+
const transactionId = crypto.randomUUID();
|
|
258
|
+
const now = new Date().toISOString();
|
|
259
|
+
this.transactions.update((current) => ({
|
|
260
|
+
...current,
|
|
261
|
+
[transactionId]: {
|
|
262
|
+
transaction_id: transactionId,
|
|
263
|
+
plan_id: plan.plan_id,
|
|
264
|
+
kind: plan.kind,
|
|
265
|
+
status: "pending",
|
|
266
|
+
stage: "planned",
|
|
267
|
+
created_at: now,
|
|
268
|
+
updated_at: now,
|
|
269
|
+
},
|
|
270
|
+
}));
|
|
271
|
+
try {
|
|
272
|
+
this.executePlan(plan, transactionId);
|
|
273
|
+
const snapshot = this.scan();
|
|
274
|
+
this.updateTransaction(transactionId, { status: "completed", stage: "committed" });
|
|
275
|
+
this.plans.update((current) => {
|
|
276
|
+
const next = { ...current };
|
|
277
|
+
delete next[plan.plan_id];
|
|
278
|
+
return next;
|
|
279
|
+
});
|
|
280
|
+
return { plan_id: plan.plan_id, transaction_id: transactionId, snapshot };
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
this.updateTransaction(transactionId, {
|
|
284
|
+
status: "failed",
|
|
285
|
+
error: error instanceof Error ? error.message : String(error),
|
|
286
|
+
});
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
createPlan(input) {
|
|
291
|
+
const plan = {
|
|
292
|
+
plan_id: crypto.randomUUID(),
|
|
293
|
+
actor_id: input.actorId,
|
|
294
|
+
kind: input.kind,
|
|
295
|
+
skill_id: input.skill.id,
|
|
296
|
+
package_revision: input.skill.package_revision,
|
|
297
|
+
source_path: input.skill.source_path,
|
|
298
|
+
target_path: input.targetPath,
|
|
299
|
+
source_fingerprint: fingerprintPath(input.skill.source_path),
|
|
300
|
+
target_fingerprint: fingerprintPath(input.targetPath),
|
|
301
|
+
expires_at: new Date(Date.now() + 5 * 60_000).toISOString(),
|
|
302
|
+
steps: input.steps,
|
|
303
|
+
can_apply: input.canApply,
|
|
304
|
+
detail: input.detail,
|
|
305
|
+
request: input.request,
|
|
306
|
+
};
|
|
307
|
+
this.plans.update((current) => ({ ...current, [plan.plan_id]: plan }));
|
|
308
|
+
return plan;
|
|
309
|
+
}
|
|
310
|
+
assertPackageCanMutate(skill) {
|
|
311
|
+
if (skill.global_state === "split_brain") {
|
|
312
|
+
throw new SkillControlPlaneError("skill_split_brain", `Skill 同时存在于启用和停用目录: ${skill.id}`);
|
|
313
|
+
}
|
|
314
|
+
if (skill.global_state === "invalid") {
|
|
315
|
+
const code = skill.name === skill.id ? "skill_package_invalid" : "skill_identity_mismatch";
|
|
316
|
+
throw new SkillControlPlaneError(code, `Skill Package 身份或内容无效: ${skill.id}`, 422);
|
|
317
|
+
}
|
|
318
|
+
if (!skill.can_apply) {
|
|
319
|
+
throw new SkillControlPlaneError("skill_target_conflict", `Skill 存在同名不同内容的 Source: ${skill.id}`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
executePlan(plan, transactionId) {
|
|
323
|
+
if (plan.kind === "adopt") {
|
|
324
|
+
this.executeAdopt(plan, transactionId);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (plan.kind === "assignment") {
|
|
328
|
+
this.executeAssignment(plan, transactionId);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (plan.kind === "global_state") {
|
|
332
|
+
this.executeGlobalState(plan, transactionId);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
this.ownership.update((current) => {
|
|
336
|
+
const next = { ...current };
|
|
337
|
+
delete next[plan.skill_id];
|
|
338
|
+
return next;
|
|
339
|
+
});
|
|
340
|
+
this.assignments.update((current) => {
|
|
341
|
+
const next = { ...current };
|
|
342
|
+
for (const key of Object.keys(next)) {
|
|
343
|
+
if (next[key]?.skill_id === plan.skill_id)
|
|
344
|
+
delete next[key];
|
|
345
|
+
}
|
|
346
|
+
return next;
|
|
347
|
+
});
|
|
348
|
+
this.updateTransaction(transactionId, { stage: "verified" });
|
|
349
|
+
}
|
|
350
|
+
recoverPendingTransactions() {
|
|
351
|
+
const transactions = this.transactions.read();
|
|
352
|
+
const plans = this.plans.read();
|
|
353
|
+
for (const transaction of Object.values(transactions)) {
|
|
354
|
+
if (transaction.status !== "pending")
|
|
355
|
+
continue;
|
|
356
|
+
const plan = plans[transaction.plan_id];
|
|
357
|
+
if (!plan) {
|
|
358
|
+
this.updateTransaction(transaction.transaction_id, {
|
|
359
|
+
status: "failed",
|
|
360
|
+
error: "持久事务缺少原始 plan,必须人工恢复",
|
|
361
|
+
});
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
try {
|
|
365
|
+
this.executePlan(plan, transaction.transaction_id);
|
|
366
|
+
this.scan();
|
|
367
|
+
this.updateTransaction(transaction.transaction_id, {
|
|
368
|
+
status: "completed",
|
|
369
|
+
stage: "committed",
|
|
370
|
+
});
|
|
371
|
+
this.plans.update((current) => {
|
|
372
|
+
const next = { ...current };
|
|
373
|
+
delete next[plan.plan_id];
|
|
374
|
+
return next;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
this.updateTransaction(transaction.transaction_id, {
|
|
379
|
+
status: "failed",
|
|
380
|
+
error: error instanceof Error ? error.message : String(error),
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
executeAdopt(plan, transactionId) {
|
|
386
|
+
let managedPath = plan.source_path;
|
|
387
|
+
if (plan.source_path !== plan.target_path) {
|
|
388
|
+
fs.mkdirSync(path.dirname(plan.target_path), { recursive: true });
|
|
389
|
+
if (pathExists(plan.source_path) && !pathExistsLstat(plan.target_path)) {
|
|
390
|
+
fs.renameSync(plan.source_path, plan.target_path);
|
|
391
|
+
this.updateTransaction(transactionId, { stage: "source_switched" });
|
|
392
|
+
}
|
|
393
|
+
else if (!pathExistsLstat(plan.target_path)) {
|
|
394
|
+
throw new SkillControlPlaneError("skill_transaction_recovery_required", "Adopt Source 和 Target 都不存在");
|
|
395
|
+
}
|
|
396
|
+
if (!pathExistsLstat(plan.source_path)) {
|
|
397
|
+
fs.symlinkSync(plan.target_path, plan.source_path, "dir");
|
|
398
|
+
}
|
|
399
|
+
else if (!this.isManagedLink(plan.source_path, plan.target_path)) {
|
|
400
|
+
throw new SkillControlPlaneError("skill_transaction_recovery_required", "Adopt 原位置已被其他内容占用");
|
|
401
|
+
}
|
|
402
|
+
managedPath = plan.target_path;
|
|
403
|
+
this.updateTransaction(transactionId, { stage: "links_reconciled" });
|
|
404
|
+
}
|
|
405
|
+
const now = new Date().toISOString();
|
|
406
|
+
this.ownership.update((current) => ({
|
|
407
|
+
...current,
|
|
408
|
+
[plan.skill_id]: {
|
|
409
|
+
ownership: "codebridge_managed",
|
|
410
|
+
source_path: managedPath,
|
|
411
|
+
adopted_at: now,
|
|
412
|
+
last_observed_revision: plan.package_revision,
|
|
413
|
+
},
|
|
414
|
+
}));
|
|
415
|
+
this.updateTransaction(transactionId, { stage: "verified" });
|
|
416
|
+
}
|
|
417
|
+
executeAssignment(plan, transactionId) {
|
|
418
|
+
const enabled = plan.request.enabled === true;
|
|
419
|
+
const agentId = plan.request.agent_id;
|
|
420
|
+
if (agentId !== "claude") {
|
|
421
|
+
throw new SkillControlPlaneError("skill_target_unknown", "只有 symlink_projection Agent 可以保存 Assignment", 400);
|
|
422
|
+
}
|
|
423
|
+
const skill = this.findSkill(plan.skill_id);
|
|
424
|
+
const key = assignmentKey(skill.id, agentId);
|
|
425
|
+
const existing = this.assignments.read()[key];
|
|
426
|
+
if (enabled && skill.global_state === "enabled" && !pathExistsLstat(plan.target_path)) {
|
|
427
|
+
fs.mkdirSync(path.dirname(plan.target_path), { recursive: true });
|
|
428
|
+
fs.symlinkSync(skill.source_path, plan.target_path, "dir");
|
|
429
|
+
}
|
|
430
|
+
else if (enabled && skill.global_state === "enabled" && !this.isManagedLink(plan.target_path, skill.source_path)) {
|
|
431
|
+
throw new SkillControlPlaneError("skill_target_conflict", `Claude Target 已被其他内容占用: ${plan.target_path}`);
|
|
432
|
+
}
|
|
433
|
+
if (!enabled && pathExistsLstat(plan.target_path)) {
|
|
434
|
+
if (!this.ownsProjectedLink(skill, existing)) {
|
|
435
|
+
throw new SkillControlPlaneError("skill_unlink_forbidden", `禁止移除非受管软链: ${plan.target_path}`);
|
|
436
|
+
}
|
|
437
|
+
fs.unlinkSync(plan.target_path);
|
|
438
|
+
}
|
|
439
|
+
const now = new Date().toISOString();
|
|
440
|
+
this.assignments.update((current) => ({
|
|
441
|
+
...current,
|
|
442
|
+
[key]: {
|
|
443
|
+
skill_id: skill.id,
|
|
444
|
+
agent_id: agentId,
|
|
445
|
+
desired_state: enabled ? "linked" : "absent",
|
|
446
|
+
target_path: plan.target_path,
|
|
447
|
+
created_link_target: enabled ? skill.source_path : existing?.created_link_target,
|
|
448
|
+
last_applied_package_revision: skill.package_revision,
|
|
449
|
+
created_at: existing?.created_at ?? now,
|
|
450
|
+
updated_at: now,
|
|
451
|
+
},
|
|
452
|
+
}));
|
|
453
|
+
this.updateTransaction(transactionId, { stage: "links_reconciled" });
|
|
454
|
+
}
|
|
455
|
+
executeGlobalState(plan, transactionId) {
|
|
456
|
+
const enabled = plan.request.enabled === true;
|
|
457
|
+
const skill = this.findSkill(plan.skill_id);
|
|
458
|
+
const assignment = this.assignments.read()[assignmentKey(skill.id, "claude")];
|
|
459
|
+
const claudeTarget = path.join(this.targetRoots.claude, skill.id);
|
|
460
|
+
if (!enabled && assignment?.desired_state === "linked" && pathExistsLstat(claudeTarget)) {
|
|
461
|
+
if (!this.ownsProjectedLink(skill, assignment)) {
|
|
462
|
+
throw new SkillControlPlaneError("skill_unlink_forbidden", `Claude Target 已脱离 CodeBridge 管理: ${claudeTarget}`);
|
|
463
|
+
}
|
|
464
|
+
fs.unlinkSync(claudeTarget);
|
|
465
|
+
this.updateTransaction(transactionId, { stage: "links_reconciled" });
|
|
466
|
+
}
|
|
467
|
+
if (plan.source_path !== plan.target_path) {
|
|
468
|
+
fs.mkdirSync(path.dirname(plan.target_path), { recursive: true });
|
|
469
|
+
if (pathExists(plan.source_path) && !pathExistsLstat(plan.target_path)) {
|
|
470
|
+
fs.renameSync(plan.source_path, plan.target_path);
|
|
471
|
+
this.updateTransaction(transactionId, { stage: "source_switched" });
|
|
472
|
+
}
|
|
473
|
+
else if (!pathExists(plan.target_path)) {
|
|
474
|
+
throw new SkillControlPlaneError("skill_transaction_recovery_required", "全局状态 Source 和 Target 都不存在");
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (enabled && assignment?.desired_state === "linked") {
|
|
478
|
+
if (pathExistsLstat(claudeTarget)) {
|
|
479
|
+
throw new SkillControlPlaneError("skill_target_conflict", `Claude Target 已被占用: ${claudeTarget}`);
|
|
480
|
+
}
|
|
481
|
+
fs.mkdirSync(path.dirname(claudeTarget), { recursive: true });
|
|
482
|
+
fs.symlinkSync(plan.target_path, claudeTarget, "dir");
|
|
483
|
+
this.updateTransaction(transactionId, { stage: "links_reconciled" });
|
|
484
|
+
}
|
|
485
|
+
const ownership = this.ownership.read()[skill.id];
|
|
486
|
+
if (ownership) {
|
|
487
|
+
this.ownership.update((current) => ({
|
|
488
|
+
...current,
|
|
489
|
+
[skill.id]: { ...ownership, source_path: plan.target_path },
|
|
490
|
+
}));
|
|
491
|
+
}
|
|
492
|
+
this.updateTransaction(transactionId, { stage: "verified" });
|
|
493
|
+
}
|
|
494
|
+
ownsProjectedLink(skill, assignment) {
|
|
495
|
+
if (!assignment || assignment.desired_state !== "linked")
|
|
496
|
+
return false;
|
|
497
|
+
return assignment.target_path === path.join(this.targetRoots[assignment.agent_id], skill.id)
|
|
498
|
+
&& assignment.created_link_target === skill.source_path
|
|
499
|
+
&& this.isManagedLink(assignment.target_path, skill.source_path);
|
|
500
|
+
}
|
|
501
|
+
updateTransaction(transactionId, patch) {
|
|
502
|
+
this.transactions.update((current) => {
|
|
503
|
+
const transaction = current[transactionId];
|
|
504
|
+
if (!transaction)
|
|
505
|
+
return current;
|
|
506
|
+
return {
|
|
507
|
+
...current,
|
|
508
|
+
[transactionId]: {
|
|
509
|
+
...transaction,
|
|
510
|
+
...patch,
|
|
511
|
+
updated_at: new Date().toISOString(),
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
findSkill(id) {
|
|
517
|
+
const skill = this.scan().skills.find((candidate) => candidate.id === id);
|
|
518
|
+
if (!skill) {
|
|
519
|
+
throw new SkillControlPlaneError("skill_not_found", `Skill 不存在: ${id}`, 404);
|
|
520
|
+
}
|
|
521
|
+
return skill;
|
|
522
|
+
}
|
|
523
|
+
collectRoot(root, sourceKind, discovered) {
|
|
524
|
+
for (const sourcePath of this.skillDirectories(root)) {
|
|
525
|
+
const current = discovered.get(sourcePath);
|
|
526
|
+
if (!current || SOURCE_PRIORITY[sourceKind] > SOURCE_PRIORITY[current.sourceKind]) {
|
|
527
|
+
discovered.set(sourcePath, { sourcePath, sourceKind });
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
skillDirectories(root) {
|
|
532
|
+
let stat;
|
|
533
|
+
try {
|
|
534
|
+
stat = fs.statSync(root);
|
|
535
|
+
}
|
|
536
|
+
catch {
|
|
537
|
+
return [];
|
|
538
|
+
}
|
|
539
|
+
if (!stat.isDirectory())
|
|
540
|
+
return [];
|
|
541
|
+
const direct = this.resolveSkillDirectory(root);
|
|
542
|
+
if (direct)
|
|
543
|
+
return [direct];
|
|
544
|
+
const result = [];
|
|
545
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
|
|
546
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink())
|
|
547
|
+
continue;
|
|
548
|
+
const resolved = this.resolveSkillDirectory(path.join(root, entry.name));
|
|
549
|
+
if (resolved && !result.includes(resolved))
|
|
550
|
+
result.push(resolved);
|
|
551
|
+
}
|
|
552
|
+
return result;
|
|
553
|
+
}
|
|
554
|
+
resolveSkillDirectory(candidate) {
|
|
555
|
+
try {
|
|
556
|
+
const resolved = fs.realpathSync(candidate);
|
|
557
|
+
if (!fs.statSync(resolved).isDirectory())
|
|
558
|
+
return null;
|
|
559
|
+
if (!fs.statSync(path.join(resolved, "SKILL.md")).isFile())
|
|
560
|
+
return null;
|
|
561
|
+
return resolved;
|
|
562
|
+
}
|
|
563
|
+
catch {
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
toCatalogEntry(id, candidates) {
|
|
568
|
+
const sorted = [...candidates].sort((left, right) => SOURCE_PRIORITY[right.sourceKind] - SOURCE_PRIORITY[left.sourceKind]);
|
|
569
|
+
const discovered = sorted[0];
|
|
570
|
+
const skillFile = path.join(discovered.sourcePath, "SKILL.md");
|
|
571
|
+
const content = fs.readFileSync(skillFile, "utf8");
|
|
572
|
+
const metadata = parseSkillMetadata(content, id);
|
|
573
|
+
const packageFingerprint = fingerprintSkillPackage(discovered.sourcePath);
|
|
574
|
+
const candidateRevisions = new Set(candidates.map((candidate) => fingerprintSkillPackage(candidate.sourcePath).revision));
|
|
575
|
+
const hasSourceConflict = candidates.length > 1
|
|
576
|
+
&& candidateRevisions.size > 1
|
|
577
|
+
&& !(candidates.length === 2
|
|
578
|
+
&& candidates.some((candidate) => candidate.sourceKind === "shared")
|
|
579
|
+
&& candidates.some((candidate) => candidate.sourceKind === "disabled"));
|
|
580
|
+
const hasActive = candidates.some((candidate) => candidate.sourceKind === "shared");
|
|
581
|
+
const hasDisabled = candidates.some((candidate) => candidate.sourceKind === "disabled");
|
|
582
|
+
const identityValid = metadata.name === id;
|
|
583
|
+
const globalState = !identityValid || !packageFingerprint.valid
|
|
584
|
+
? "invalid"
|
|
585
|
+
: hasActive && hasDisabled
|
|
586
|
+
? "split_brain"
|
|
587
|
+
: hasActive
|
|
588
|
+
? "enabled"
|
|
589
|
+
: hasDisabled
|
|
590
|
+
? "disabled"
|
|
591
|
+
: "external";
|
|
592
|
+
const revision = packageFingerprint.revision;
|
|
593
|
+
const ownershipRecord = this.ownership.read()[id];
|
|
594
|
+
const ownership = ownershipRecord?.last_observed_revision === revision
|
|
595
|
+
|| ownershipRecord?.ownership === "codebridge_managed"
|
|
596
|
+
? ownershipRecord.ownership
|
|
597
|
+
: "external_observed";
|
|
598
|
+
return {
|
|
599
|
+
id,
|
|
600
|
+
name: metadata.name,
|
|
601
|
+
description: metadata.description,
|
|
602
|
+
source_path: discovered.sourcePath,
|
|
603
|
+
source_kind: discovered.sourceKind,
|
|
604
|
+
package_revision: revision,
|
|
605
|
+
revision,
|
|
606
|
+
global_state: globalState,
|
|
607
|
+
ownership,
|
|
608
|
+
can_apply: globalState !== "invalid" && globalState !== "split_brain" && !hasSourceConflict,
|
|
609
|
+
tags: metadata.tags,
|
|
610
|
+
updated_at: fs.statSync(skillFile).mtime.toISOString(),
|
|
611
|
+
targets: SKILL_AGENT_IDS.map((agentId) => (agentId === "claude"
|
|
612
|
+
? this.inspectTarget(discovered.sourcePath, agentId)
|
|
613
|
+
: {
|
|
614
|
+
agent_id: agentId,
|
|
615
|
+
delivery_mode: "shared_native",
|
|
616
|
+
target_path: path.join(this.sharedRoot, id),
|
|
617
|
+
state: "follows_global",
|
|
618
|
+
mutable: false,
|
|
619
|
+
detail: globalState === "enabled"
|
|
620
|
+
? "Agent 直接读取共享启用目录"
|
|
621
|
+
: "Agent 跟随 Skill 全局状态",
|
|
622
|
+
})),
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
inspectTarget(sourcePath, agentId) {
|
|
626
|
+
const targetPath = path.join(this.targetRoots[agentId], path.basename(sourcePath));
|
|
627
|
+
let stat;
|
|
628
|
+
try {
|
|
629
|
+
stat = fs.lstatSync(targetPath);
|
|
630
|
+
}
|
|
631
|
+
catch {
|
|
632
|
+
return {
|
|
633
|
+
agent_id: agentId,
|
|
634
|
+
delivery_mode: deliveryMode(agentId),
|
|
635
|
+
target_path: targetPath,
|
|
636
|
+
state: "absent",
|
|
637
|
+
mutable: agentId === "claude",
|
|
638
|
+
detail: null,
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
let resolvedTarget = null;
|
|
642
|
+
try {
|
|
643
|
+
resolvedTarget = fs.realpathSync(targetPath);
|
|
644
|
+
}
|
|
645
|
+
catch {
|
|
646
|
+
resolvedTarget = null;
|
|
647
|
+
}
|
|
648
|
+
if (stat.isSymbolicLink()) {
|
|
649
|
+
if (!resolvedTarget) {
|
|
650
|
+
return {
|
|
651
|
+
agent_id: agentId,
|
|
652
|
+
delivery_mode: deliveryMode(agentId),
|
|
653
|
+
target_path: targetPath,
|
|
654
|
+
state: "broken",
|
|
655
|
+
mutable: agentId === "claude",
|
|
656
|
+
detail: "Target 是无法解析的软链",
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
if (resolvedTarget === sourcePath && this.resolveSkillDirectory(targetPath)) {
|
|
660
|
+
return {
|
|
661
|
+
agent_id: agentId,
|
|
662
|
+
delivery_mode: deliveryMode(agentId),
|
|
663
|
+
target_path: targetPath,
|
|
664
|
+
state: "linked",
|
|
665
|
+
mutable: agentId === "claude",
|
|
666
|
+
detail: "目标目录可见且 SKILL.md 可读",
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
return {
|
|
670
|
+
agent_id: agentId,
|
|
671
|
+
delivery_mode: deliveryMode(agentId),
|
|
672
|
+
target_path: targetPath,
|
|
673
|
+
state: "conflict",
|
|
674
|
+
mutable: agentId === "claude",
|
|
675
|
+
detail: `Target 已指向其他 Source: ${resolvedTarget}`,
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
return {
|
|
679
|
+
agent_id: agentId,
|
|
680
|
+
delivery_mode: deliveryMode(agentId),
|
|
681
|
+
target_path: targetPath,
|
|
682
|
+
state: "conflict",
|
|
683
|
+
mutable: agentId === "claude",
|
|
684
|
+
detail: "Target 已存在且不是受管软链",
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
isManagedLink(targetPath, sourcePath) {
|
|
688
|
+
try {
|
|
689
|
+
return fs.lstatSync(targetPath).isSymbolicLink()
|
|
690
|
+
&& fs.realpathSync(targetPath) === sourcePath;
|
|
691
|
+
}
|
|
692
|
+
catch {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function deliveryMode(agentId) {
|
|
698
|
+
return agentId === "claude" ? "symlink_projection" : "shared_native";
|
|
699
|
+
}
|
|
700
|
+
function assignmentKey(skillId, agentId) {
|
|
701
|
+
return `${skillId}:${agentId}`;
|
|
702
|
+
}
|
|
703
|
+
function pathExists(candidate) {
|
|
704
|
+
try {
|
|
705
|
+
fs.statSync(candidate);
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
catch {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function pathExistsLstat(candidate) {
|
|
713
|
+
try {
|
|
714
|
+
fs.lstatSync(candidate);
|
|
715
|
+
return true;
|
|
716
|
+
}
|
|
717
|
+
catch {
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
function isPathInside(root, candidate) {
|
|
722
|
+
const normalizedRoot = canonicalPath(root);
|
|
723
|
+
const normalizedCandidate = canonicalPath(candidate);
|
|
724
|
+
const relative = path.relative(normalizedRoot, normalizedCandidate);
|
|
725
|
+
return relative === "" || (!relative.startsWith(`..${path.sep}`) && relative !== "..");
|
|
726
|
+
}
|
|
727
|
+
function canonicalPath(candidate) {
|
|
728
|
+
try {
|
|
729
|
+
return fs.realpathSync(candidate);
|
|
730
|
+
}
|
|
731
|
+
catch {
|
|
732
|
+
return path.resolve(candidate);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
function migrateLegacyStateFile(legacyPath, targetPath) {
|
|
736
|
+
if (pathExistsLstat(targetPath) || !pathExists(legacyPath))
|
|
737
|
+
return;
|
|
738
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
739
|
+
fs.copyFileSync(legacyPath, targetPath, fs.constants.COPYFILE_EXCL);
|
|
740
|
+
}
|
|
741
|
+
function fingerprintPath(candidate) {
|
|
742
|
+
try {
|
|
743
|
+
const stat = fs.lstatSync(candidate);
|
|
744
|
+
if (stat.isSymbolicLink()) {
|
|
745
|
+
let resolved = "broken";
|
|
746
|
+
try {
|
|
747
|
+
resolved = fs.realpathSync(candidate);
|
|
748
|
+
}
|
|
749
|
+
catch {
|
|
750
|
+
// Broken links must still have a stable fingerprint.
|
|
751
|
+
}
|
|
752
|
+
return `symlink:${fs.readlinkSync(candidate)}:${resolved}`;
|
|
753
|
+
}
|
|
754
|
+
if (stat.isDirectory()) {
|
|
755
|
+
const packageFingerprint = fingerprintSkillPackage(candidate);
|
|
756
|
+
return `directory:${packageFingerprint.valid}:${packageFingerprint.revision}`;
|
|
757
|
+
}
|
|
758
|
+
if (stat.isFile()) {
|
|
759
|
+
return `file:${stat.mode & 0o111}:${crypto.createHash("sha256").update(fs.readFileSync(candidate)).digest("hex")}`;
|
|
760
|
+
}
|
|
761
|
+
return `special:${stat.mode}`;
|
|
762
|
+
}
|
|
763
|
+
catch {
|
|
764
|
+
return "absent";
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function fingerprintSkillPackage(root) {
|
|
768
|
+
const hash = crypto.createHash("sha256");
|
|
769
|
+
let valid = true;
|
|
770
|
+
const visit = (directory) => {
|
|
771
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })
|
|
772
|
+
.sort((left, right) => left.name.localeCompare(right.name))) {
|
|
773
|
+
const absolute = path.join(directory, entry.name);
|
|
774
|
+
const relative = path.relative(root, absolute).split(path.sep).join("/");
|
|
775
|
+
const stat = fs.lstatSync(absolute);
|
|
776
|
+
if (stat.isDirectory()) {
|
|
777
|
+
hash.update(`directory\0${relative}\0${stat.mode & 0o111}\0`);
|
|
778
|
+
visit(absolute);
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
if (stat.isFile()) {
|
|
782
|
+
hash.update(`file\0${relative}\0${stat.mode & 0o111}\0`);
|
|
783
|
+
hash.update(fs.readFileSync(absolute));
|
|
784
|
+
hash.update("\0");
|
|
785
|
+
continue;
|
|
786
|
+
}
|
|
787
|
+
if (stat.isSymbolicLink()) {
|
|
788
|
+
const target = fs.readlinkSync(absolute);
|
|
789
|
+
const resolved = path.resolve(path.dirname(absolute), target);
|
|
790
|
+
const relativeTarget = path.relative(root, resolved);
|
|
791
|
+
if (path.isAbsolute(target) || relativeTarget === ".." || relativeTarget.startsWith(`..${path.sep}`)) {
|
|
792
|
+
valid = false;
|
|
793
|
+
}
|
|
794
|
+
hash.update(`symlink\0${relative}\0${target}\0`);
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
valid = false;
|
|
798
|
+
hash.update(`special\0${relative}\0`);
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
visit(root);
|
|
802
|
+
return { revision: hash.digest("hex"), valid };
|
|
803
|
+
}
|
|
804
|
+
function parseSkillMetadata(content, fallbackName) {
|
|
805
|
+
const frontmatter = content.startsWith("---\n")
|
|
806
|
+
? content.slice(4, content.indexOf("\n---", 4) >= 0 ? content.indexOf("\n---", 4) : 4)
|
|
807
|
+
: "";
|
|
808
|
+
const fields = new Map();
|
|
809
|
+
for (const line of frontmatter.split("\n")) {
|
|
810
|
+
const match = /^([a-zA-Z_][\w-]*):\s*(.*)$/.exec(line);
|
|
811
|
+
if (!match)
|
|
812
|
+
continue;
|
|
813
|
+
fields.set(match[1], unquote(match[2].trim()));
|
|
814
|
+
}
|
|
815
|
+
const rawTags = fields.get("tags") ?? "";
|
|
816
|
+
const tags = rawTags.replace(/^\[|\]$/g, "").split(",")
|
|
817
|
+
.map((tag) => unquote(tag.trim()))
|
|
818
|
+
.filter(Boolean);
|
|
819
|
+
return {
|
|
820
|
+
name: fields.get("name") || fallbackName,
|
|
821
|
+
description: fields.get("description") || null,
|
|
822
|
+
tags,
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
function unquote(value) {
|
|
826
|
+
if ((value.startsWith('"') && value.endsWith('"'))
|
|
827
|
+
|| (value.startsWith("'") && value.endsWith("'"))) {
|
|
828
|
+
return value.slice(1, -1);
|
|
829
|
+
}
|
|
830
|
+
return value;
|
|
831
|
+
}
|
|
832
|
+
//# sourceMappingURL=skill-control-plane.js.map
|