@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,460 @@
|
|
|
1
|
+
import { createAgentSession, createBashToolDefinition, DefaultResourceLoader, getAgentDir, ModelRuntime, SessionManager, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { fileAttachmentPromptSuffix, partitionAttachments } from "./attachment-prompt.js";
|
|
4
|
+
/** Match ACP's SIGKILL upgrade delay: abort() waits for idle and can hang on live bash. */
|
|
5
|
+
const PI_ABORT_SETTLE_MS = 2_000;
|
|
6
|
+
function abortPiSession(session) {
|
|
7
|
+
session.abortBash?.();
|
|
8
|
+
return Promise.race([
|
|
9
|
+
session.abort().then(() => undefined, () => undefined),
|
|
10
|
+
new Promise((resolve) => {
|
|
11
|
+
setTimeout(resolve, PI_ABORT_SETTLE_MS).unref();
|
|
12
|
+
}),
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
/** Map Pi's event stream to CodeBridge's provider-neutral event contract. */
|
|
16
|
+
export function mapPiEvent(event) {
|
|
17
|
+
const value = event;
|
|
18
|
+
if (value.type === "message_update") {
|
|
19
|
+
const update = value.assistantMessageEvent;
|
|
20
|
+
if (update?.type === "text_delta" && update.delta) {
|
|
21
|
+
return [{ type: "text_delta", text: update.delta }];
|
|
22
|
+
}
|
|
23
|
+
if (update?.type === "thinking_delta" && update.delta) {
|
|
24
|
+
return [{ type: "thought_delta", text: update.delta }];
|
|
25
|
+
}
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
if (value.type === "tool_execution_start") {
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
type: "tool_start",
|
|
32
|
+
toolCallId: value.toolCallId,
|
|
33
|
+
name: value.toolName ?? "tool",
|
|
34
|
+
input: value.args,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
if (value.type === "tool_execution_update") {
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
type: "tool_update",
|
|
42
|
+
toolCallId: value.toolCallId ?? "unknown-tool-call",
|
|
43
|
+
name: value.toolName,
|
|
44
|
+
status: "running",
|
|
45
|
+
output: value.partialResult,
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
if (value.type === "tool_execution_end") {
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
type: "tool_end",
|
|
53
|
+
toolCallId: value.toolCallId,
|
|
54
|
+
name: value.toolName,
|
|
55
|
+
status: value.isError ? "failed" : "completed",
|
|
56
|
+
output: value.result,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
if (value.type === "agent_end" && value.willRetry === false) {
|
|
61
|
+
const assistant = [...(value.messages ?? [])]
|
|
62
|
+
.reverse()
|
|
63
|
+
.find((message) => message.role === "assistant");
|
|
64
|
+
if (assistant?.stopReason === "error") {
|
|
65
|
+
return [{
|
|
66
|
+
type: "error",
|
|
67
|
+
message: assistant.errorMessage || "Pi model request failed without an error message",
|
|
68
|
+
fatal: true,
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Provider/transport failures must surface as real error events instead of
|
|
73
|
+
// silently ending the run (auto-retry exhaustion carries the final error).
|
|
74
|
+
if (value.type === "auto_retry_end") {
|
|
75
|
+
const retry = value;
|
|
76
|
+
if (retry.success === false && retry.finalError) {
|
|
77
|
+
return [{ type: "error", message: retry.finalError, fatal: true }];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
/** Execute one prompt on a native Pi AgentSession. */
|
|
83
|
+
export async function* runPiSession(ctx, options) {
|
|
84
|
+
const session = await (options.createSession?.(ctx) ?? createNativePiSession(ctx));
|
|
85
|
+
const handleRef = options.handleRef;
|
|
86
|
+
let wake;
|
|
87
|
+
let finished = false;
|
|
88
|
+
let promptError;
|
|
89
|
+
const pending = [];
|
|
90
|
+
const seenErrors = new Set();
|
|
91
|
+
let sawOutput = false;
|
|
92
|
+
let sawError = false;
|
|
93
|
+
const notify = () => {
|
|
94
|
+
const current = wake;
|
|
95
|
+
wake = undefined;
|
|
96
|
+
current?.();
|
|
97
|
+
};
|
|
98
|
+
const unsubscribe = session.subscribe((event) => {
|
|
99
|
+
for (const mapped of mapPiEvent(event)) {
|
|
100
|
+
if (mapped.type === "error") {
|
|
101
|
+
if (seenErrors.has(mapped.message))
|
|
102
|
+
continue;
|
|
103
|
+
seenErrors.add(mapped.message);
|
|
104
|
+
sawError = true;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
sawOutput = true;
|
|
108
|
+
}
|
|
109
|
+
pending.push(mapped);
|
|
110
|
+
}
|
|
111
|
+
notify();
|
|
112
|
+
});
|
|
113
|
+
let aborting;
|
|
114
|
+
const handle = {
|
|
115
|
+
cancel: () => {
|
|
116
|
+
aborting ??= abortPiSession(session);
|
|
117
|
+
return aborting;
|
|
118
|
+
},
|
|
119
|
+
steer: (prompt) => session.steer(prompt),
|
|
120
|
+
};
|
|
121
|
+
if (handleRef)
|
|
122
|
+
handleRef.current = handle;
|
|
123
|
+
try {
|
|
124
|
+
const prompt = await buildPrompt(ctx);
|
|
125
|
+
const promptPromise = session
|
|
126
|
+
.prompt(prompt.text, prompt.options)
|
|
127
|
+
.catch((error) => {
|
|
128
|
+
promptError = error;
|
|
129
|
+
})
|
|
130
|
+
.finally(() => {
|
|
131
|
+
finished = true;
|
|
132
|
+
notify();
|
|
133
|
+
});
|
|
134
|
+
while (!finished || pending.length > 0) {
|
|
135
|
+
if (pending.length > 0) {
|
|
136
|
+
yield pending.shift();
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (options.isAborted())
|
|
140
|
+
break;
|
|
141
|
+
await new Promise((resolve) => {
|
|
142
|
+
wake = resolve;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (!options.isAborted())
|
|
146
|
+
await promptPromise;
|
|
147
|
+
if (promptError !== undefined && !options.isAborted()) {
|
|
148
|
+
yield {
|
|
149
|
+
type: "error",
|
|
150
|
+
message: promptError instanceof Error ? promptError.message : String(promptError),
|
|
151
|
+
fatal: true,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
else if (!options.isAborted()) {
|
|
155
|
+
if (!sawOutput && !sawError) {
|
|
156
|
+
yield {
|
|
157
|
+
type: "error",
|
|
158
|
+
message: "Pi run completed without assistant output or a provider error",
|
|
159
|
+
fatal: true,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
yield { type: "session", sessionId: session.sessionId };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
unsubscribe();
|
|
169
|
+
if (options.isAborted() && !finished) {
|
|
170
|
+
await (aborting ?? abortPiSession(session));
|
|
171
|
+
}
|
|
172
|
+
session.dispose();
|
|
173
|
+
if (handleRef?.current === handle)
|
|
174
|
+
handleRef.current = undefined;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
export async function listPiSessions(backendId, cwd, options) {
|
|
178
|
+
const sessions = await SessionManager.list(cwd);
|
|
179
|
+
return sessions
|
|
180
|
+
.map((session) => ({
|
|
181
|
+
id: session.id,
|
|
182
|
+
backend: backendId,
|
|
183
|
+
cwd: session.cwd || cwd,
|
|
184
|
+
preview: session.firstMessage || "(no preview)",
|
|
185
|
+
updatedAt: session.modified.toISOString(),
|
|
186
|
+
}))
|
|
187
|
+
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
|
|
188
|
+
.slice(0, options?.limit ?? 20);
|
|
189
|
+
}
|
|
190
|
+
export async function loadPiSessionHistory(cwd, sessionId) {
|
|
191
|
+
const match = await findPiSession(cwd, sessionId);
|
|
192
|
+
if (!match)
|
|
193
|
+
throw new Error(`Pi session not found in ${cwd}: ${sessionId}`);
|
|
194
|
+
const manager = SessionManager.open(match.path, undefined, cwd);
|
|
195
|
+
return collectPiSessionHistory(manager.getBranch());
|
|
196
|
+
}
|
|
197
|
+
export function collectPiSessionHistory(entries) {
|
|
198
|
+
const result = [];
|
|
199
|
+
for (const entry of entries) {
|
|
200
|
+
if (!entry || typeof entry !== "object" || entry.type !== "message")
|
|
201
|
+
continue;
|
|
202
|
+
const value = entry;
|
|
203
|
+
const message = value.message;
|
|
204
|
+
if (!message)
|
|
205
|
+
continue;
|
|
206
|
+
if (message.role === "user") {
|
|
207
|
+
const text = textFromPiContent(message.content);
|
|
208
|
+
if (text)
|
|
209
|
+
result.push({ kind: "message", text });
|
|
210
|
+
}
|
|
211
|
+
else if (message.role === "assistant") {
|
|
212
|
+
const blocks = Array.isArray(message.content) ? message.content : [message.content];
|
|
213
|
+
for (const block of blocks) {
|
|
214
|
+
if (typeof block === "string" && block) {
|
|
215
|
+
result.push({
|
|
216
|
+
kind: "agent_event",
|
|
217
|
+
event: { type: "text_delta", text: block, ...(typeof value.id === "string" ? { messageId: value.id } : {}) },
|
|
218
|
+
});
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (!block || typeof block !== "object")
|
|
222
|
+
continue;
|
|
223
|
+
const content = block;
|
|
224
|
+
if (content.type === "thinking" && content.thinking) {
|
|
225
|
+
result.push({ kind: "agent_event", event: { type: "thought_delta", text: content.thinking } });
|
|
226
|
+
}
|
|
227
|
+
else if (content.type === "text" && content.text) {
|
|
228
|
+
result.push({
|
|
229
|
+
kind: "agent_event",
|
|
230
|
+
event: { type: "text_delta", text: content.text, ...(typeof value.id === "string" ? { messageId: value.id } : {}) },
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else if (message.role === "toolResult") {
|
|
236
|
+
const text = textFromPiContent(message.content);
|
|
237
|
+
if (!text)
|
|
238
|
+
continue;
|
|
239
|
+
result.push({
|
|
240
|
+
kind: "agent_event",
|
|
241
|
+
event: {
|
|
242
|
+
type: "tool_end",
|
|
243
|
+
toolCallId: message.toolCallId,
|
|
244
|
+
status: message.isError ? "failed" : "completed",
|
|
245
|
+
output: text,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
function textFromPiContent(content) {
|
|
253
|
+
if (typeof content === "string")
|
|
254
|
+
return content;
|
|
255
|
+
if (!Array.isArray(content))
|
|
256
|
+
return "";
|
|
257
|
+
return content
|
|
258
|
+
.map((block) => {
|
|
259
|
+
if (!block || typeof block !== "object")
|
|
260
|
+
return "";
|
|
261
|
+
const value = block;
|
|
262
|
+
if (value.type === "text" && typeof value.text === "string")
|
|
263
|
+
return value.text;
|
|
264
|
+
if (value.type === "thinking" && typeof value.thinking === "string")
|
|
265
|
+
return value.thinking;
|
|
266
|
+
return "";
|
|
267
|
+
})
|
|
268
|
+
.join("");
|
|
269
|
+
}
|
|
270
|
+
export async function probePiSdk(cwd) {
|
|
271
|
+
try {
|
|
272
|
+
await SessionManager.list(cwd);
|
|
273
|
+
return { ok: true, message: "Pi SDK available" };
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
return {
|
|
277
|
+
ok: false,
|
|
278
|
+
message: error instanceof Error ? error.message : String(error),
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const ALL_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
283
|
+
const LEVEL_LABEL = {
|
|
284
|
+
off: "Off", minimal: "Minimal", low: "Low", medium: "Medium", high: "High", xhigh: "Extra high", max: "Max",
|
|
285
|
+
};
|
|
286
|
+
/** Thinking levels supported by a specific model: keys of thinkingLevelMap
|
|
287
|
+
* with a non-null mapping, in canonical order. Falls back to all levels for
|
|
288
|
+
* reasoning models without a map; empty for non-reasoning models. */
|
|
289
|
+
export function piThinkingLevelsForModel(model) {
|
|
290
|
+
if (model && model.reasoning === false)
|
|
291
|
+
return [];
|
|
292
|
+
const map = model?.thinkingLevelMap;
|
|
293
|
+
if (!map)
|
|
294
|
+
return [...ALL_THINKING_LEVELS];
|
|
295
|
+
const levels = ALL_THINKING_LEVELS.filter((level) => typeof map[level] === "string" && map[level]);
|
|
296
|
+
return levels.length ? levels : [...ALL_THINKING_LEVELS];
|
|
297
|
+
}
|
|
298
|
+
export async function listPiConfigOptions(runtime, currentModel) {
|
|
299
|
+
const activeRuntime = runtime ?? await createPiModelRuntime();
|
|
300
|
+
const values = activeRuntime.getModels()
|
|
301
|
+
.filter((model) => activeRuntime.hasConfiguredAuth(model.provider))
|
|
302
|
+
.map((model) => ({
|
|
303
|
+
value: `${model.provider}/${model.id}`,
|
|
304
|
+
name: model.name,
|
|
305
|
+
description: model.api,
|
|
306
|
+
}));
|
|
307
|
+
// Derive the thinking-level control from the *selected* model's declared
|
|
308
|
+
// capabilities: hidden for non-reasoning models, restricted to the mapped
|
|
309
|
+
// levels otherwise (docs/orchestration/agent-providers.md §2.6).
|
|
310
|
+
let selected;
|
|
311
|
+
if (currentModel && activeRuntime.getModel) {
|
|
312
|
+
const separator = currentModel.includes("/") ? "/" : ":";
|
|
313
|
+
const [provider, ...rest] = currentModel.split(separator);
|
|
314
|
+
if (provider && rest.length)
|
|
315
|
+
selected = activeRuntime.getModel(provider, rest.join(separator));
|
|
316
|
+
}
|
|
317
|
+
const levels = piThinkingLevelsForModel(selected);
|
|
318
|
+
// Surface Pi's configured defaults so "Agent 默认" shows what it resolves to
|
|
319
|
+
// (settings.json defaultProvider/defaultModel/defaultThinkingLevel).
|
|
320
|
+
let defaultModelValue;
|
|
321
|
+
let defaultThinkingLevel;
|
|
322
|
+
if (!runtime) {
|
|
323
|
+
const settings = SettingsManager.create(process.cwd(), getAgentDir());
|
|
324
|
+
const provider = settings.getDefaultProvider();
|
|
325
|
+
const modelId = settings.getDefaultModel();
|
|
326
|
+
if (provider && modelId && values.some((v) => v.value === `${provider}/${modelId}`)) {
|
|
327
|
+
defaultModelValue = `${provider}/${modelId}`;
|
|
328
|
+
}
|
|
329
|
+
const thinking = settings.getDefaultThinkingLevel();
|
|
330
|
+
if (thinking && levels.includes(thinking))
|
|
331
|
+
defaultThinkingLevel = thinking;
|
|
332
|
+
}
|
|
333
|
+
return [
|
|
334
|
+
...(values.length ? [{
|
|
335
|
+
id: "model",
|
|
336
|
+
name: "Model",
|
|
337
|
+
type: "select",
|
|
338
|
+
category: "model",
|
|
339
|
+
values,
|
|
340
|
+
currentValue: defaultModelValue,
|
|
341
|
+
}] : []),
|
|
342
|
+
...(levels.length ? [{
|
|
343
|
+
id: "thinking_level",
|
|
344
|
+
name: "Reasoning",
|
|
345
|
+
type: "select",
|
|
346
|
+
category: "thought_level",
|
|
347
|
+
values: levels.map((value) => ({ value, name: LEVEL_LABEL[value] ?? value })),
|
|
348
|
+
currentValue: defaultThinkingLevel,
|
|
349
|
+
}] : []),
|
|
350
|
+
];
|
|
351
|
+
}
|
|
352
|
+
export async function listPiCommands(cwd) {
|
|
353
|
+
const agentDir = getAgentDir();
|
|
354
|
+
const loader = new DefaultResourceLoader({
|
|
355
|
+
cwd,
|
|
356
|
+
agentDir,
|
|
357
|
+
settingsManager: SettingsManager.create(cwd, agentDir),
|
|
358
|
+
});
|
|
359
|
+
await loader.reload();
|
|
360
|
+
const result = loader.getSkills();
|
|
361
|
+
return result.skills.map((skill) => ({
|
|
362
|
+
name: `skill:${skill.name}`,
|
|
363
|
+
description: skill.description,
|
|
364
|
+
}));
|
|
365
|
+
}
|
|
366
|
+
export async function closePiSession(cwd, sessionId) {
|
|
367
|
+
const session = await findPiSession(cwd, sessionId);
|
|
368
|
+
return session ? { ok: true } : { ok: false, error: "Pi session not found" };
|
|
369
|
+
}
|
|
370
|
+
export async function forkPiSession(sourceCwd, sessionId, targetCwd) {
|
|
371
|
+
const source = await findPiSession(sourceCwd, sessionId);
|
|
372
|
+
if (!source)
|
|
373
|
+
return { ok: false, error: "Pi session not found" };
|
|
374
|
+
const fork = SessionManager.forkFrom(source.path, targetCwd);
|
|
375
|
+
return {
|
|
376
|
+
ok: true,
|
|
377
|
+
sessionId: fork.getSessionId(),
|
|
378
|
+
cwd: targetCwd,
|
|
379
|
+
title: source.name ?? (source.firstMessage || null),
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
export async function deletePiSession(cwd, sessionId) {
|
|
383
|
+
const session = await findPiSession(cwd, sessionId);
|
|
384
|
+
if (!session)
|
|
385
|
+
return { ok: false, error: "Pi session not found" };
|
|
386
|
+
await fs.rm(session.path, { force: true });
|
|
387
|
+
return { ok: true };
|
|
388
|
+
}
|
|
389
|
+
export async function createNativePiSession(ctx, dependencies = {}) {
|
|
390
|
+
const modelRuntime = await (dependencies.createModelRuntime ?? createPiModelRuntime)();
|
|
391
|
+
const sessionManager = await (dependencies.resolveSessionManager ?? resolvePiSessionManager)(ctx);
|
|
392
|
+
const model = resolveModel(modelRuntime, ctx.backendConfig.model ?? ctx.model);
|
|
393
|
+
const createSession = dependencies.createAgentSession ?? createAgentSession;
|
|
394
|
+
const runEnv = { ...ctx.extraEnv };
|
|
395
|
+
const { session } = await createSession({
|
|
396
|
+
cwd: ctx.cwd,
|
|
397
|
+
sessionManager,
|
|
398
|
+
model,
|
|
399
|
+
thinkingLevel: resolveThinkingLevel(ctx.effort),
|
|
400
|
+
modelRuntime,
|
|
401
|
+
customTools: [
|
|
402
|
+
...(ctx.extraEnv ? [createBashToolDefinition(ctx.cwd, {
|
|
403
|
+
spawnHook: (spawn) => ({ ...spawn, env: { ...spawn.env, ...runEnv } }),
|
|
404
|
+
})] : []),
|
|
405
|
+
],
|
|
406
|
+
});
|
|
407
|
+
return session;
|
|
408
|
+
}
|
|
409
|
+
export async function resolvePiSessionManager(ctx) {
|
|
410
|
+
if (!ctx.resumeSessionId)
|
|
411
|
+
return SessionManager.create(ctx.cwd);
|
|
412
|
+
const sessions = await SessionManager.list(ctx.cwd);
|
|
413
|
+
const match = sessions.find((session) => session.id === ctx.resumeSessionId);
|
|
414
|
+
if (!match)
|
|
415
|
+
return SessionManager.create(ctx.cwd);
|
|
416
|
+
return SessionManager.open(match.path, undefined, ctx.cwd);
|
|
417
|
+
}
|
|
418
|
+
export function createPiModelRuntime(options = {}) {
|
|
419
|
+
return ModelRuntime.create({ ...options, allowModelNetwork: false });
|
|
420
|
+
}
|
|
421
|
+
function resolveModel(runtime, raw) {
|
|
422
|
+
if (!raw)
|
|
423
|
+
return undefined;
|
|
424
|
+
const separator = raw.includes("/") ? "/" : ":";
|
|
425
|
+
const [provider, ...modelParts] = raw.split(separator);
|
|
426
|
+
const modelId = modelParts.join(separator);
|
|
427
|
+
if (!provider || !modelId) {
|
|
428
|
+
throw new Error(`Pi model must use provider/model format: ${raw}`);
|
|
429
|
+
}
|
|
430
|
+
const model = runtime.getModel(provider, modelId);
|
|
431
|
+
if (!model)
|
|
432
|
+
throw new Error(`Pi model is not available: ${raw}`);
|
|
433
|
+
return model;
|
|
434
|
+
}
|
|
435
|
+
async function findPiSession(cwd, sessionId) {
|
|
436
|
+
const sessions = await SessionManager.list(cwd);
|
|
437
|
+
return sessions.find((session) => session.id === sessionId);
|
|
438
|
+
}
|
|
439
|
+
function resolveThinkingLevel(raw) {
|
|
440
|
+
const levels = new Set(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
441
|
+
return raw && levels.has(raw)
|
|
442
|
+
? raw
|
|
443
|
+
: undefined;
|
|
444
|
+
}
|
|
445
|
+
async function buildPrompt(ctx) {
|
|
446
|
+
if (!ctx.attachments?.length)
|
|
447
|
+
return { text: ctx.prompt };
|
|
448
|
+
const { images, files } = partitionAttachments(ctx.attachments);
|
|
449
|
+
const text = ctx.prompt + fileAttachmentPromptSuffix(files);
|
|
450
|
+
if (!images.length)
|
|
451
|
+
return { text };
|
|
452
|
+
// Pi 的 ImageContent 把 mimeType/data 放在顶层,不是 Anthropic 的 source 嵌套结构。
|
|
453
|
+
const imageBlocks = await Promise.all(images.map(async (attachment) => ({
|
|
454
|
+
type: "image",
|
|
455
|
+
mimeType: attachment.mimeType ?? "image/png",
|
|
456
|
+
data: await fs.readFile(attachment.path, "base64"),
|
|
457
|
+
})));
|
|
458
|
+
return { text, options: { images: imageBlocks } };
|
|
459
|
+
}
|
|
460
|
+
//# sourceMappingURL=pi-session-runner.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Generic third-party model endpoint probe (OpenAI-compatible HTTP APIs).
|
|
2
|
+
* Used by Pi provider settings today; reusable by any agent's custom provider config. */
|
|
3
|
+
export interface ProviderConnectionProbe {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
authHeader?: boolean;
|
|
7
|
+
/** Wire protocol, e.g. "openai-completions" / "openai-responses". */
|
|
8
|
+
api?: string;
|
|
9
|
+
/** A concrete model id enables real protocol verification. */
|
|
10
|
+
model?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function testProviderConnection(provider: ProviderConnectionProbe): Promise<{
|
|
13
|
+
ok: boolean;
|
|
14
|
+
detail: string;
|
|
15
|
+
compatSuggestion?: Record<string, unknown>;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=provider-connection.d.ts.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** Minimal real request per wire protocol; returns a failure result, or undefined on success. */
|
|
2
|
+
const PROTOCOL_PROBE = {
|
|
3
|
+
"openai-completions": async (baseUrl, headers, model) => {
|
|
4
|
+
const post = (messages) => fetch(`${baseUrl}/chat/completions`, {
|
|
5
|
+
method: "POST",
|
|
6
|
+
headers: { ...headers, "content-type": "application/json" },
|
|
7
|
+
// Some reasoning-model gateways reject max_tokens <= 2.
|
|
8
|
+
body: JSON.stringify({ model, messages, max_tokens: 16 }),
|
|
9
|
+
signal: AbortSignal.timeout(30_000),
|
|
10
|
+
});
|
|
11
|
+
// Pi sends the system prompt as a `developer` role message; probe that first.
|
|
12
|
+
const response = await post([{ role: "developer", content: "ping" }]);
|
|
13
|
+
if (response.ok)
|
|
14
|
+
return { ok: true, detail: `连接成功,模型 ${model} 的 Chat Completions API 可用` };
|
|
15
|
+
const body = await response.text().catch(() => "");
|
|
16
|
+
if (/developer/.test(body) && /unknown variant|unsupported|not supported|invalid/i.test(body)) {
|
|
17
|
+
const retry = await post([{ role: "system", content: "ping" }]);
|
|
18
|
+
if (retry.ok) {
|
|
19
|
+
return {
|
|
20
|
+
ok: true,
|
|
21
|
+
detail: `连接成功,但端点不支持 developer 角色;已建议写入 compat.supportsDeveloperRole=false`,
|
|
22
|
+
compatSuggestion: { supportsDeveloperRole: false },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const retryBody = await retry.text().catch(() => "");
|
|
26
|
+
return { ok: false, detail: `Chat Completions API 不可用(HTTP ${retry.status}): ${retryBody.slice(0, 200) || "无错误详情"}` };
|
|
27
|
+
}
|
|
28
|
+
return { ok: false, detail: `Chat Completions API 不可用(HTTP ${response.status}): ${body.slice(0, 200) || "无错误详情"}` };
|
|
29
|
+
},
|
|
30
|
+
"openai-responses": async (baseUrl, headers, model) => {
|
|
31
|
+
const response = await fetch(`${baseUrl}/responses`, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: { ...headers, "content-type": "application/json" },
|
|
34
|
+
body: JSON.stringify({ model, input: "ping", max_output_tokens: 16 }),
|
|
35
|
+
signal: AbortSignal.timeout(30_000),
|
|
36
|
+
});
|
|
37
|
+
if (response.ok)
|
|
38
|
+
return { ok: true, detail: `连接成功,模型 ${model} 的 Responses API 可用` };
|
|
39
|
+
const body = await response.text().catch(() => "");
|
|
40
|
+
return { ok: false, detail: `Responses API 不可用(HTTP ${response.status}): ${body.slice(0, 200) || "无错误详情"}` };
|
|
41
|
+
},
|
|
42
|
+
"anthropic-messages": async (baseUrl, headers, model) => {
|
|
43
|
+
const response = await fetch(`${baseUrl}/messages`, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { ...headers, "content-type": "application/json", "anthropic-version": "2023-06-01" },
|
|
46
|
+
body: JSON.stringify({ model, max_tokens: 1, messages: [{ role: "user", content: "ping" }] }),
|
|
47
|
+
signal: AbortSignal.timeout(30_000),
|
|
48
|
+
});
|
|
49
|
+
if (response.ok)
|
|
50
|
+
return { ok: true, detail: `连接成功,模型 ${model} 的 Messages API 可用` };
|
|
51
|
+
const body = await response.text().catch(() => "");
|
|
52
|
+
return { ok: false, detail: `Messages API 不可用(HTTP ${response.status}): ${body.slice(0, 200) || "无错误详情"}` };
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
export async function testProviderConnection(provider) {
|
|
56
|
+
const baseUrl = provider.baseUrl.replace(/\/+$/, "");
|
|
57
|
+
const headers = {};
|
|
58
|
+
if (provider.apiKey) {
|
|
59
|
+
if (provider.authHeader)
|
|
60
|
+
headers["authorization"] = `Bearer ${provider.apiKey}`;
|
|
61
|
+
else
|
|
62
|
+
headers["x-api-key"] = provider.apiKey;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const response = await fetch(`${baseUrl}/models`, { headers, signal: AbortSignal.timeout(5_000) });
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
const hint = response.status === 401 || response.status === 403 ? "API key 无效或无权限" : `HTTP ${response.status}`;
|
|
68
|
+
return { ok: false, detail: hint };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
return { ok: false, detail: networkHint(error) };
|
|
73
|
+
}
|
|
74
|
+
// /models only proves reachability; verify the selected wire protocol with a real call.
|
|
75
|
+
if (provider.model) {
|
|
76
|
+
const probe = PROTOCOL_PROBE[provider.api ?? "openai-completions"];
|
|
77
|
+
if (probe) {
|
|
78
|
+
try {
|
|
79
|
+
const result = await probe(baseUrl, headers, provider.model);
|
|
80
|
+
if (result)
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return { ok: false, detail: networkHint(error) };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const protocol = provider.api ?? "openai-completions";
|
|
89
|
+
return { ok: true, detail: "连接成功(HTTP 200)" + (PROTOCOL_PROBE[protocol] && !provider.model ? ",但未配置模型,协议未验证" : "") };
|
|
90
|
+
}
|
|
91
|
+
function networkHint(error) {
|
|
92
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
93
|
+
if (message.includes("ENOTFOUND"))
|
|
94
|
+
return "域名无法解析,检查 baseUrl";
|
|
95
|
+
if (message.includes("TimeoutError") || message.includes("timed out"))
|
|
96
|
+
return "连接超时";
|
|
97
|
+
return message;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=provider-connection.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AgentEvent } from "@codebridge/core";
|
|
2
|
+
export interface CliSessionSummary {
|
|
3
|
+
id: string;
|
|
4
|
+
backend: string;
|
|
5
|
+
cwd: string;
|
|
6
|
+
additionalDirectories?: string[];
|
|
7
|
+
preview: string;
|
|
8
|
+
updatedAt: string;
|
|
9
|
+
}
|
|
10
|
+
export type ProviderSessionHistoryEvent = {
|
|
11
|
+
kind: "message";
|
|
12
|
+
text: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "agent_event";
|
|
15
|
+
event: AgentEvent;
|
|
16
|
+
};
|
|
17
|
+
/** Claude Code: ~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl */
|
|
18
|
+
export declare function encodeClaudeProjectDir(cwd: string): string;
|
|
19
|
+
export declare function collectClaudeSessionHistory(entries: unknown[]): ProviderSessionHistoryEvent[];
|
|
20
|
+
export declare function loadClaudeSessionHistory(cwd: string, sessionId: string): Promise<ProviderSessionHistoryEvent[]>;
|
|
21
|
+
export declare function collectCodexSessionHistory(entries: unknown[]): ProviderSessionHistoryEvent[];
|
|
22
|
+
export declare function loadCodexSessionHistory(sessionId: string): Promise<ProviderSessionHistoryEvent[]>;
|
|
23
|
+
//# sourceMappingURL=session-discovery.d.ts.map
|