@xopcai/xopc 0.0.369 → 0.0.371
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/README.md +59 -174
- package/README.zh-CN.md +59 -174
- package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js +131 -0
- package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js +30 -0
- package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js +252 -0
- package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js +16 -0
- package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js +66 -0
- package/dist/browser-ext/dist/sidepanel.js +21 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Stj17S9u.js → agent-avatar-dicebear-C8MqXy6W.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BLaL4law.js +1 -0
- package/dist/gateway/static/root/assets/agent-plugin-dialog-BrysdA6F.js +1 -0
- package/dist/gateway/static/root/assets/agents-BJRyMNx2.js +66 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-pJFe6M6c.js → app-management-settings-panel-Bi02swpZ.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BrxSpBWa.js → appearance-settings-rr0qirDm.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DegSl5Lh.js → apps-page-Sz3wl3lV.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BZQ_VHjp.js → automations-page-DqdbP0hD.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CxgKlA5d.js +6 -0
- package/dist/gateway/static/root/assets/{block-editor-3XjFv3kK.js → block-editor-CfVR1zGa.js} +3 -3
- package/dist/gateway/static/root/assets/browser-automations-page-DeYnh3mY.js +3 -0
- package/dist/gateway/static/root/assets/{browser-settings-page-ch2_bQF0.js → browser-settings-page-DDZvlGCD.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-DO-vfNKI.js → capabilities-CY4SiHcP.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-B48r0DDa.js → capabilities-gjQtMhKu.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-Bl6PZqx3.js +2 -0
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-NckMsJ5N.js → capabilities-settings-panel-B-MM4LJA.js} +4 -4
- package/dist/gateway/static/root/assets/{capability-header-actions-CY8KCO9j.js → capability-header-actions-CAiY7HK1.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-CHOS2CGa.js → channels-D1_fDkhu.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-Bwknnb4c.js → chat-terminal-dock-D6slpF2a.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-B2xeFCSt.js → computer-settings-page-D1n_uQHN.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-C83DnAqK.js → connector-service-page-FvSCyJzn.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DroD-gQn.js +1 -0
- package/dist/gateway/static/root/assets/copy-text-row-C1gaJwlZ.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-Bq9GR-DU.js → date-picker-Bl-HqvGU.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-DY4nU-HL.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-BwsbQw8V.js → desktop-pet-_A89B2xw.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-sL9i44pP.js → desktop-pet-settings-BJWkGynu.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-DJ_ITvkI.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BFlDmsS5.js → directory-picker-path-field-Bj2Cpmxs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-7Z1Tp7-w.js → extension-debug-page-BfAtjhoK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-uGqvb8QX.js → extension-page-BFjc1zDp.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-xlSyz4Z6.js → extension-provider-Br6LXyIj.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CKHgrjOs.js → extension-settings-page-oAwllsMb.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-BwQg0G1D.js → fallback-models-KHd6tw_t.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-F6D4A7N5.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-BAQnSEMJ.js → gateway-settings-BIyhyiOq.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-CEjaIUTF.js +2 -0
- package/dist/gateway/static/root/assets/{imports-page-re1_Nh64.js → imports-page-ClFqRiGQ.js} +1 -1
- package/dist/gateway/static/root/assets/index-BGBkIIzM.css +1 -0
- package/dist/gateway/static/root/assets/index-GBFmI8im.js +106 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-B_xja9LN.js → keyboard-shortcuts-settings-Ca9_GJSQ.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CErdCrPX.js → local-app-workbench-page-BaK9zX1-.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BPL2RXdK.js → local-apps-page-1CjSftZ3.js} +1 -1
- package/dist/gateway/static/root/assets/local-session-drafts-pox8evDV.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-6joZBbcx.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-Cnubkklb.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-B6DHbMzT.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-CGZkIKdi.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-tf77xIz3.js → page-context-capture-button-y3QmhTu2.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-C_roXCJB.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-Dc3Y-Y7J.js → product-open-page-CSRYWt0f.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-MG_hmVA3.js → product-preview-content-DuOML6gs.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-v7xtnvha.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-MllfNLGA.js → projects-page-BuJCBT6n.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-Bs-C70el.js → remote-access-hub-DpHnyBnG.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DpJ5jNzR.js → runtime-tools-settings-panel-DTMTL0hy.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-Dpxamkw6.js → scenes-page-B0JqO_fM.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-DUeyQ1zh.js → schema-form-g4z7GH4W.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-Dgn4BRk_.js → send-session-input-BW40VHiL.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-BqlvrjPE.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-CftImbH7.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BkvbSieZ.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-DouHuBXt.js → settings-page-YD-U8BVw.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-q_X3kxw2.js +1 -0
- package/dist/gateway/static/root/assets/{share-link-dialog-DJTabLAM.js → share-link-dialog-HCHM8qnf.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-jw7h4t_B.js → share-preview-page-Ce6FNWt1.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-KHRg_-03.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-CfyX_0zN.js → skill-api-BpqDMkNB.js} +1 -1
- package/dist/gateway/static/root/assets/skills-page-Bnfn51ks.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-DWf256TE.js → system-settings-panel-CncvC2CI.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DE6N1ZQe.js → task-detail-page-BVJKdnMC.js} +2 -2
- package/dist/gateway/static/root/assets/{tunnel-api-BBm9esrY.js → tunnel-api-g7etuoaT.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-C93x89uW.js → usage-page-Dao1I-5F.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-C7Gaaai1.js → use-composer-attachments-DJya1hIL.js} +1 -1
- package/dist/gateway/static/root/assets/use-file-preview-expanded-C5ONO7sF.js +2 -0
- package/dist/gateway/static/root/assets/user-model-page-jr986ucl.js +2 -0
- package/dist/gateway/static/root/assets/{work-discovery-overlay-Bs2MKiTv.js → work-discovery-overlay-CC3mr7tX.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BR_U_snV.js → workflow-run-setup-panel-CqpXZJxs.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DOk6tBbK.js +6 -0
- package/dist/gateway/static/root/assets/{workspace-api-Si2o3inw.js → workspace-api-WhbMvdBE.js} +2 -2
- package/dist/gateway/static/root/index.html +18 -20
- package/dist/package.js +1 -1
- package/dist/packages/endpoint-tools-client/src/index.js +189 -0
- package/dist/packages/endpoint-tools-protocol/src/bridge.js +105 -0
- package/dist/packages/endpoint-tools-protocol/src/index.js +95 -2
- package/dist/packages/endpoint-tools-protocol/src/location.js +109 -0
- package/dist/packages/endpoint-tools-protocol/src/personal.js +149 -0
- package/dist/packages/gateway-contract/src/session-input-command.js +30 -5
- package/dist/src/agent/agent-manager.js +23 -27
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/codemode-extension.d.ts +7 -0
- package/dist/src/agent/embedded/codemode-extension.js +232 -0
- package/dist/src/agent/embedded/codemode-output.d.ts +2 -0
- package/dist/src/agent/embedded/codemode-output.js +34 -0
- package/dist/src/agent/embedded/external-tool-discovery.d.ts +6 -0
- package/dist/src/agent/embedded/external-tool-discovery.js +60 -0
- package/dist/src/agent/embedded/model-runtime.js +5 -2
- package/dist/src/agent/embedded/run-for-session.js +10 -1
- package/dist/src/agent/embedded/run-turn.js +10 -3
- package/dist/src/agent/embedded/session-runner.d.ts +9 -1
- package/dist/src/agent/embedded/session-runner.js +111 -23
- package/dist/src/agent/embedded/session-tool-result-guard.d.ts +2 -0
- package/dist/src/agent/embedded/session-tool-result-guard.js +17 -0
- package/dist/src/agent/embedded/subscribe-session.js +14 -4
- package/dist/src/agent/embedded/tool-metadata.d.ts +15 -0
- package/dist/src/agent/embedded/tool-metadata.js +38 -0
- package/dist/src/agent/embedded/tool-search-extension.d.ts +5 -0
- package/dist/src/agent/embedded/tool-search-extension.js +31 -0
- package/dist/src/agent/embedded/types.d.ts +7 -0
- package/dist/src/agent/embedded/xopc-tools-bridge.js +6 -0
- package/dist/src/agent/external-tools/endpoint-provider.d.ts +1 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +174 -53
- package/dist/src/agent/external-tools/extension-provider.js +8 -1
- package/dist/src/agent/external-tools/gateway-tools.d.ts +1 -1
- package/dist/src/agent/external-tools/gateway-tools.js +45 -22
- package/dist/src/agent/external-tools/index.js +46 -14
- package/dist/src/agent/external-tools/memory-provider.js +8 -1
- package/dist/src/agent/external-tools/read-policy.js +2 -1
- package/dist/src/agent/external-tools/service.d.ts +2 -0
- package/dist/src/agent/external-tools/service.js +25 -3
- package/dist/src/agent/external-tools/tool-registry.d.ts +14 -0
- package/dist/src/agent/external-tools/tool-registry.js +14 -0
- package/dist/src/agent/external-tools/types.d.ts +8 -1
- package/dist/src/agent/external-tools/types.js +0 -1
- package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
- package/dist/src/agent/mcp/config.d.ts +18 -0
- package/dist/src/agent/mcp/{bundle-mcp-config.js → config.js} +8 -25
- package/dist/src/agent/mcp/native-mcp.d.ts +6 -0
- package/dist/src/agent/mcp/native-mcp.js +73 -0
- package/dist/src/agent/service.js +3 -6
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/installer.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -1
- package/dist/src/agent/skills/skill-sources.js +1 -1
- package/dist/src/agent/source-context/index.d.ts +0 -1
- package/dist/src/agent/source-context/index.js +1 -2
- package/dist/src/agent/source-context/injector.js +1 -0
- package/dist/src/agent/source-context/types.d.ts +2 -2
- package/dist/src/agent/source-context/types.js +1 -1
- package/dist/src/agent/tools/cli-clarify.js +1 -1
- package/dist/src/agent/tools/codemode-permissions.d.ts +4 -0
- package/dist/src/agent/tools/codemode-permissions.js +23 -0
- package/dist/src/agent/tools/dataBatch.js +3 -1
- package/dist/src/agent/tools/delegation-parent-policy.js +1 -4
- package/dist/src/agent/tools/factory.js +4 -3
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent/transcript/provider-capabilities.js +0 -1
- package/dist/src/agent/transcript/transcript-policy.js +1 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +1 -1
- package/dist/src/agent-catalog/repository.js +1 -1
- package/dist/src/agent-config/schema.d.ts +28 -0
- package/dist/src/agent-config/schema.js +7 -0
- package/dist/src/auth/credentials.js +7 -20
- package/dist/src/auth/model-credential-store.js +11 -4
- package/dist/src/auth/oauth/index.d.ts +1 -1
- package/dist/src/auth/oauth/index.js +3 -3
- package/dist/src/auth/oauth/openai.d.ts +2 -0
- package/dist/src/auth/oauth/openai.js +90 -0
- package/dist/src/auth/oauth/registry.js +3 -3
- package/dist/src/auth/oauth/types.d.ts +1 -0
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +5 -0
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/chat-commands/builtins/model.js +2 -2
- package/dist/src/cli/command-manifest.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/extension-agent-plugin.js +0 -19
- package/dist/src/cli/commands/mcp.js +36 -2
- package/dist/src/cli/commands/models.js +2 -2
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/cli/utils/oauth-login.js +2 -2
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/index.js +3 -3
- package/dist/src/config/mcp-config-normalize.d.ts +0 -3
- package/dist/src/config/mcp-config-normalize.js +2 -22
- package/dist/src/config/models-json.d.ts +0 -5
- package/dist/src/config/models-json.js +13 -4
- package/dist/src/config/paths.d.ts +0 -1
- package/dist/src/config/paths.js +1 -4
- package/dist/src/config/schema.d.ts +130 -36
- package/dist/src/config/schema.js +52 -35
- package/dist/src/connectors/auth-provider-registry.d.ts +1 -1
- package/dist/src/connectors/auth-provider-registry.js +1 -21
- package/dist/src/connectors/china-catalog.js +5 -5
- package/dist/src/connectors/connection-recovery-service.d.ts +1 -6
- package/dist/src/connectors/connection-recovery-service.js +3 -105
- package/dist/src/connectors/health.d.ts +1 -2
- package/dist/src/connectors/health.js +2 -101
- package/dist/src/connectors/types.d.ts +1 -1
- package/dist/src/endpoint-tools/binding-service.d.ts +2 -0
- package/dist/src/endpoint-tools/binding-service.js +14 -2
- package/dist/src/endpoint-tools/bridge-host.d.ts +15 -0
- package/dist/src/endpoint-tools/bridge-host.js +166 -0
- package/dist/src/endpoint-tools/bridge.d.ts +27 -0
- package/dist/src/endpoint-tools/bridge.js +88 -0
- package/dist/src/endpoint-tools/capability-catalog.d.ts +2 -0
- package/dist/src/endpoint-tools/capability-catalog.js +8 -0
- package/dist/src/endpoint-tools/grant-service.d.ts +69 -0
- package/dist/src/endpoint-tools/grant-service.js +113 -0
- package/dist/src/endpoint-tools/index.js +1 -1
- package/dist/src/endpoint-tools/invocation-service.js +21 -4
- package/dist/src/endpoint-tools/location-task.d.ts +22 -0
- package/dist/src/endpoint-tools/location-task.js +114 -0
- package/dist/src/endpoint-tools/policy.js +21 -1
- package/dist/src/endpoint-tools/registry.d.ts +2 -0
- package/dist/src/endpoint-tools/registry.js +9 -0
- package/dist/src/endpoint-tools/result-projector.d.ts +15 -0
- package/dist/src/endpoint-tools/result-projector.js +31 -0
- package/dist/src/endpoint-tools/runtime.d.ts +2 -0
- package/dist/src/endpoint-tools/runtime.js +15 -2
- package/dist/src/endpoint-tools/target-resolver.d.ts +12 -0
- package/dist/src/endpoint-tools/target-resolver.js +27 -0
- package/dist/src/endpoint-tools/turn-context.d.ts +6 -0
- package/dist/src/endpoint-tools/turn-context.js +29 -0
- package/dist/src/endpoint-tools/upload-service.d.ts +4 -2
- package/dist/src/endpoint-tools/upload-service.js +29 -4
- package/dist/src/extensions/agent-plugins/auth.d.ts +0 -2
- package/dist/src/extensions/agent-plugins/auth.js +2 -19
- package/dist/src/extensions/agent-plugins/credentials.js +3 -19
- package/dist/src/extensions/agent-plugins/inventory.d.ts +2 -2
- package/dist/src/extensions/agent-plugins/mcp-adapter.js +1 -5
- package/dist/src/extensions/agent-plugins/source-http-fetch.d.ts +2 -0
- package/dist/src/{agent/mcp/plugin-http-fetch.js → extensions/agent-plugins/source-http-fetch.js} +7 -7
- package/dist/src/extensions/agent-plugins/sources.js +2 -2
- package/dist/src/extensions/agent-plugins/store.js +1 -3
- package/dist/src/extensions/agent-plugins/validation.d.ts +0 -4
- package/dist/src/extensions/agent-plugins/validation.js +14 -21
- package/dist/src/gateway/agents-admin.d.ts +5 -0
- package/dist/src/gateway/agents-admin.js +58 -3
- package/dist/src/gateway/chat-stream/mapper.js +9 -0
- package/dist/src/gateway/chat-stream/protocol.d.ts +4 -4
- package/dist/src/gateway/hono/lib/config-payload.d.ts +9 -4
- package/dist/src/gateway/hono/lib/config-payload.js +2 -5
- package/dist/src/gateway/hono/oauth-async.js +9 -2
- package/dist/src/gateway/hono/routes/agent-plugins.js +4 -9
- package/dist/src/gateway/hono/routes/agents.js +5 -4
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/connection-waits.js +2 -5
- package/dist/src/gateway/hono/routes/connectors.js +5 -60
- package/dist/src/gateway/hono/routes/device-authorizations.d.ts +3 -0
- package/dist/src/gateway/hono/routes/device-authorizations.js +74 -0
- package/dist/src/gateway/hono/routes/endpoint-compatibility.js +8 -0
- package/dist/src/gateway/hono/routes/endpoint-tools.d.ts +1 -0
- package/dist/src/gateway/hono/routes/endpoint-tools.js +70 -3
- package/dist/src/gateway/hono/routes/lazy-bundles.js +17 -1
- package/dist/src/gateway/hono/routes/mcp.d.ts +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +11 -237
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-command-handler.js +11 -1
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +8 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +26 -2
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +2 -5
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.js +13 -5
- package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -1
- package/dist/src/gateway/service/session-input-coordinator.js +29 -9
- package/dist/src/gateway/service/sessions-api.js +0 -6
- package/dist/src/gateway/service.js +7 -16
- package/dist/src/gateway/session-reset-service.js +0 -6
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/imports/compatibility.js +12 -10
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/mcp/channel-bridge.js +1 -1
- package/dist/src/notes/agent-context.js +1 -1
- package/dist/src/personal-agent/service.js +1 -1
- package/dist/src/providers/env-keys.js +1 -1
- package/dist/src/providers/index.js +26 -24
- package/dist/src/providers/model-call.d.ts +0 -2
- package/dist/src/providers/model-call.js +2 -6
- package/dist/src/providers/model-registry.js +4 -2
- package/dist/src/providers/model-supplements.d.ts +3 -3
- package/dist/src/providers/model-supplements.js +6 -27
- package/dist/src/providers/presentation.js +3 -8
- package/dist/src/providers/prompt-cache-plan.js +1 -1
- package/dist/src/providers/provider-auth-service.d.ts +1 -1
- package/dist/src/providers/provider-auth-service.js +7 -2
- package/dist/src/providers/provider-policy.d.ts +3 -0
- package/dist/src/providers/provider-policy.js +14 -0
- package/dist/src/providers/register-runtime-providers.js +6 -1
- package/dist/src/realtime/runtime.js +1 -1
- package/dist/src/session/store.js +7 -1
- package/dist/src/session/transcript-events.d.ts +5 -0
- package/dist/src/session/transcript-events.js +1 -0
- package/dist/src/session/types.d.ts +2 -0
- package/dist/src/storage/sqlite/device-grant-audit-repository.d.ts +11 -0
- package/dist/src/storage/sqlite/device-grant-audit-repository.js +10 -0
- package/dist/src/storage/sqlite/endpoint-device-settings-repository.d.ts +7 -0
- package/dist/src/storage/sqlite/endpoint-device-settings-repository.js +17 -0
- package/dist/src/storage/sqlite/migrations/240_device_settings.sql +5 -0
- package/dist/src/storage/sqlite/migrations/241_device_grant_audit.sql +13 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/session-input-repository.js +5 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
- package/dist/src/tui/xopc-tui-keybindings.d.ts +4 -4
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/package.json +20 -9
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CCRfvuov.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CRlzd8El.js +0 -1
- package/dist/gateway/static/root/assets/agents-_ug2LCQb.js +0 -66
- package/dist/gateway/static/root/assets/automations-workspace-BQywN6nG.js +0 -6
- package/dist/gateway/static/root/assets/browser-automations-page-yiEuG1v7.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-page-BEnFt_dj.js +0 -2
- package/dist/gateway/static/root/assets/connectors-page-D6wTmWA6.js +0 -2
- package/dist/gateway/static/root/assets/copy-text-row-BHDs3cBa.js +0 -1
- package/dist/gateway/static/root/assets/dependency-picker-BTERkA9X.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-DI2bqaKO.js +0 -1
- package/dist/gateway/static/root/assets/dist-Che_jiQF.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-DDWymi-o.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BZDjvwet.js +0 -2
- package/dist/gateway/static/root/assets/index-BB1z8QxA.js +0 -106
- package/dist/gateway/static/root/assets/index-D9R6tU7r.css +0 -1
- package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +0 -1
- package/dist/gateway/static/root/assets/local-session-drafts-DRPsDCj1.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-DL-BM0xq.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-BOVRHhXk.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-DJJK2yL4.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-oCxO7ZTv.js +0 -8
- package/dist/gateway/static/root/assets/personal-page-DOk9gUK5.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-3uAzbW4T.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-LInoZ_Yi.js +0 -16
- package/dist/gateway/static/root/assets/sessions-page-BCVlNHtq.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Bz-ue9fZ.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-B5BoZ-1y.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BlnlzGjH.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DjdTeYzm.js +0 -2
- package/dist/gateway/static/root/assets/use-file-preview-expanded-Db2VYg1b.js +0 -2
- package/dist/gateway/static/root/assets/user-model-page-B74LkVbp.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-Crk4SxtC.js +0 -6
- package/dist/src/agent/embedded/system-prompt-override.d.ts +0 -2
- package/dist/src/agent/embedded/system-prompt-override.js +0 -21
- package/dist/src/agent/external-tools/mcp-provider.d.ts +0 -32
- package/dist/src/agent/external-tools/mcp-provider.js +0 -208
- package/dist/src/agent/mcp/bundle-mcp-config.d.ts +0 -20
- package/dist/src/agent/mcp/bundle-mcp-gateway.d.ts +0 -79
- package/dist/src/agent/mcp/bundle-mcp-gateway.js +0 -93
- package/dist/src/agent/mcp/bundle-mcp-names.d.ts +0 -1
- package/dist/src/agent/mcp/bundle-mcp-names.js +0 -25
- package/dist/src/agent/mcp/bundle-mcp-policy.d.ts +0 -1
- package/dist/src/agent/mcp/bundle-mcp-policy.js +0 -6
- package/dist/src/agent/mcp/bundle-mcp-runtime.d.ts +0 -46
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +0 -571
- package/dist/src/agent/mcp/bundle-mcp-tools.d.ts +0 -2
- package/dist/src/agent/mcp/bundle-mcp-tools.js +0 -2
- package/dist/src/agent/mcp/bundle-mcp-types.d.ts +0 -76
- package/dist/src/agent/mcp/bundle-mcp-types.js +0 -1
- package/dist/src/agent/mcp/embedded-mcp.d.ts +0 -10
- package/dist/src/agent/mcp/embedded-mcp.js +0 -14
- package/dist/src/agent/mcp/index.d.ts +0 -5
- package/dist/src/agent/mcp/index.js +0 -12
- package/dist/src/agent/mcp/mcp-config-shared.d.ts +0 -8
- package/dist/src/agent/mcp/mcp-config-shared.js +0 -39
- package/dist/src/agent/mcp/mcp-http.d.ts +0 -23
- package/dist/src/agent/mcp/mcp-http.js +0 -67
- package/dist/src/agent/mcp/mcp-resource-id.d.ts +0 -6
- package/dist/src/agent/mcp/mcp-resource-id.js +0 -19
- package/dist/src/agent/mcp/mcp-stdio-transport.d.ts +0 -26
- package/dist/src/agent/mcp/mcp-stdio-transport.js +0 -120
- package/dist/src/agent/mcp/mcp-stdio.d.ts +0 -18
- package/dist/src/agent/mcp/mcp-stdio.js +0 -35
- package/dist/src/agent/mcp/mcp-transport-config.d.ts +0 -28
- package/dist/src/agent/mcp/mcp-transport-config.js +0 -91
- package/dist/src/agent/mcp/mcp-transport.d.ts +0 -17
- package/dist/src/agent/mcp/mcp-transport.js +0 -141
- package/dist/src/agent/mcp/oauth/index.d.ts +0 -6
- package/dist/src/agent/mcp/oauth/index.js +0 -6
- package/dist/src/agent/mcp/oauth/mcp-oauth-errors.d.ts +0 -5
- package/dist/src/agent/mcp/oauth/mcp-oauth-errors.js +0 -14
- package/dist/src/agent/mcp/oauth/mcp-oauth-manager.d.ts +0 -30
- package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +0 -276
- package/dist/src/agent/mcp/oauth/mcp-oauth-provider.d.ts +0 -33
- package/dist/src/agent/mcp/oauth/mcp-oauth-provider.js +0 -103
- package/dist/src/agent/mcp/oauth/mcp-oauth-session.d.ts +0 -31
- package/dist/src/agent/mcp/oauth/mcp-oauth-session.js +0 -181
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.d.ts +0 -12
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +0 -91
- package/dist/src/agent/mcp/oauth/mcp-oauth-types.d.ts +0 -22
- package/dist/src/agent/mcp/oauth/mcp-oauth-types.js +0 -1
- package/dist/src/agent/mcp/plugin-http-fetch.d.ts +0 -2
- package/dist/src/agent/source-context/mcp-resource-context.d.ts +0 -8
- package/dist/src/agent/source-context/mcp-resource-context.js +0 -30
- package/dist/src/auth/oauth/openai-codex.d.ts +0 -9
- package/dist/src/auth/oauth/openai-codex.js +0 -414
- package/dist/src/connectors/plugin-mcp-recovery.d.ts +0 -28
- package/dist/src/connectors/plugin-mcp-recovery.js +0 -90
- package/dist/src/extensions/agent-plugins/connection.d.ts +0 -8
- package/dist/src/extensions/agent-plugins/connection.js +0 -41
- package/dist/src/extensions/agent-plugins/health.d.ts +0 -4
- package/dist/src/extensions/agent-plugins/health.js +0 -48
- package/dist/src/extensions/agent-plugins/plugin-oauth-scope.d.ts +0 -1
- package/dist/src/extensions/agent-plugins/plugin-oauth-scope.js +0 -8
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { McpAuthorizationRequiredError, isMcpAuthorizationError } from "./mcp-oauth-errors.js";
|
|
2
|
-
import { McpOAuthStore, canonicalMcpServerUrl, mcpOAuthServerKey } from "./mcp-oauth-store.js";
|
|
3
|
-
import { XopcMcpOAuthClientProvider } from "./mcp-oauth-provider.js";
|
|
4
|
-
import { McpOAuthSession } from "./mcp-oauth-session.js";
|
|
5
|
-
import { McpOAuthManager, getMcpOAuthManager } from "./mcp-oauth-manager.js";
|
|
6
|
-
export { McpAuthorizationRequiredError, McpOAuthManager, McpOAuthSession, McpOAuthStore, XopcMcpOAuthClientProvider, canonicalMcpServerUrl, getMcpOAuthManager, isMcpAuthorizationError, mcpOAuthServerKey };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
|
-
//#region src/agent/mcp/oauth/mcp-oauth-errors.ts
|
|
3
|
-
var McpAuthorizationRequiredError = class extends Error {
|
|
4
|
-
code = "MCP_AUTHORIZATION_REQUIRED";
|
|
5
|
-
constructor(message = "MCP server authorization is required") {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "McpAuthorizationRequiredError";
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
function isMcpAuthorizationError(error) {
|
|
11
|
-
return error instanceof UnauthorizedError || error instanceof McpAuthorizationRequiredError;
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { McpAuthorizationRequiredError, isMcpAuthorizationError };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../../../config/schema.js';
|
|
2
|
-
import { McpOAuthStore } from './mcp-oauth-store.js';
|
|
3
|
-
import type { McpOAuthSessionSnapshot } from './mcp-oauth-types.js';
|
|
4
|
-
export type McpOAuthConnectionStatus = 'not_configured' | 'disconnected' | 'authorizing' | 'connected' | 'error';
|
|
5
|
-
export type McpOAuthStatus = {
|
|
6
|
-
configured: boolean;
|
|
7
|
-
status: McpOAuthConnectionStatus;
|
|
8
|
-
session?: McpOAuthSessionSnapshot;
|
|
9
|
-
};
|
|
10
|
-
type StartMcpOAuthParams = {
|
|
11
|
-
serverId: string;
|
|
12
|
-
rawServer: unknown;
|
|
13
|
-
cfg?: Config;
|
|
14
|
-
};
|
|
15
|
-
export declare class McpOAuthManager {
|
|
16
|
-
private readonly store;
|
|
17
|
-
private readonly sessionsByServerUrl;
|
|
18
|
-
private readonly pending;
|
|
19
|
-
private cancelling;
|
|
20
|
-
constructor(store?: McpOAuthStore);
|
|
21
|
-
status(serverId: string, rawServer: unknown): Promise<McpOAuthStatus>;
|
|
22
|
-
start(params: StartMcpOAuthParams): Promise<McpOAuthStatus>;
|
|
23
|
-
cancelPending(): Promise<void>;
|
|
24
|
-
private startSession;
|
|
25
|
-
disconnect(serverId: string, rawServer: unknown): Promise<McpOAuthStatus>;
|
|
26
|
-
submitCallback(serverId: string, rawServer: unknown, callbackUrl: string): Promise<McpOAuthStatus>;
|
|
27
|
-
private finishAuthorization;
|
|
28
|
-
}
|
|
29
|
-
export declare function getMcpOAuthManager(rawServer?: unknown): McpOAuthManager;
|
|
30
|
-
export {};
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
|
-
import { init_logger } from "../../../utils/logger.js";
|
|
3
|
-
import { init_global_singleton, resolveGlobalSingleton } from "../../../utils/global-singleton.js";
|
|
4
|
-
import { resolveConnectorSecretReferences } from "../../../connectors/secret-store.js";
|
|
5
|
-
import { recordPluginMcpHealth } from "../../../extensions/agent-plugins/health.js";
|
|
6
|
-
import { redactSensitiveUrlLikeString } from "../../../utils/redact-sensitive-url.js";
|
|
7
|
-
import { resolveMcpTransportConfig } from "../mcp-transport-config.js";
|
|
8
|
-
import { isMcpAuthorizationError } from "./mcp-oauth-errors.js";
|
|
9
|
-
import { McpOAuthStore, canonicalMcpServerUrl } from "./mcp-oauth-store.js";
|
|
10
|
-
import { XopcMcpOAuthClientProvider } from "./mcp-oauth-provider.js";
|
|
11
|
-
import { pluginOAuthScope } from "../../../extensions/agent-plugins/plugin-oauth-scope.js";
|
|
12
|
-
import { resolveMcpTransport } from "../mcp-transport.js";
|
|
13
|
-
import { disposeAllSessionMcpRuntimes } from "../bundle-mcp-runtime.js";
|
|
14
|
-
import { McpOAuthSession } from "./mcp-oauth-session.js";
|
|
15
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
16
|
-
//#region src/agent/mcp/oauth/mcp-oauth-manager.ts
|
|
17
|
-
init_logger();
|
|
18
|
-
init_global_singleton();
|
|
19
|
-
const log = createLogger("Mcp:OAuth");
|
|
20
|
-
const MCP_OAUTH_MANAGER_KEY = Symbol.for("xopc.mcpOAuthManager");
|
|
21
|
-
function createClient() {
|
|
22
|
-
return new Client({
|
|
23
|
-
name: "xopc-mcp-oauth",
|
|
24
|
-
version: "0.0.0"
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
async function connectClient(client, resolved) {
|
|
28
|
-
await new Promise((resolve, reject) => {
|
|
29
|
-
const timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`MCP server connection timed out after ${resolved.connectionTimeoutMs}ms`)), resolved.connectionTimeoutMs);
|
|
30
|
-
client.connect(resolved.transport).then(() => {
|
|
31
|
-
clearTimeout(timer);
|
|
32
|
-
resolve();
|
|
33
|
-
}, (error) => {
|
|
34
|
-
clearTimeout(timer);
|
|
35
|
-
reject(error);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
async function closeConnection(client, resolved) {
|
|
40
|
-
await client.close().catch(() => {});
|
|
41
|
-
await resolved.transport.close().catch(() => {});
|
|
42
|
-
resolved.detachStderr?.();
|
|
43
|
-
}
|
|
44
|
-
function isAuthorizing(snapshot) {
|
|
45
|
-
return [
|
|
46
|
-
"starting",
|
|
47
|
-
"waiting_browser",
|
|
48
|
-
"exchanging_code"
|
|
49
|
-
].includes(snapshot.status);
|
|
50
|
-
}
|
|
51
|
-
var McpOAuthManager = class {
|
|
52
|
-
store;
|
|
53
|
-
sessionsByServerUrl = /* @__PURE__ */ new Map();
|
|
54
|
-
pending = /* @__PURE__ */ new Set();
|
|
55
|
-
cancelling = false;
|
|
56
|
-
constructor(store = new McpOAuthStore()) {
|
|
57
|
-
this.store = store;
|
|
58
|
-
}
|
|
59
|
-
async status(serverId, rawServer) {
|
|
60
|
-
const resolved = resolveMcpTransportConfig(serverId, rawServer);
|
|
61
|
-
if (!resolved || resolved.kind !== "http" || !resolved.auth) return {
|
|
62
|
-
configured: false,
|
|
63
|
-
status: "not_configured"
|
|
64
|
-
};
|
|
65
|
-
const session = this.sessionsByServerUrl.get(canonicalMcpServerUrl(resolved.url))?.snapshot();
|
|
66
|
-
if (session) {
|
|
67
|
-
if (isAuthorizing(session)) return {
|
|
68
|
-
configured: true,
|
|
69
|
-
status: "authorizing",
|
|
70
|
-
session
|
|
71
|
-
};
|
|
72
|
-
if (session.status === "failed" || session.status === "expired") return {
|
|
73
|
-
configured: true,
|
|
74
|
-
status: "error",
|
|
75
|
-
session
|
|
76
|
-
};
|
|
77
|
-
if (session.status === "connected") return {
|
|
78
|
-
configured: true,
|
|
79
|
-
status: "connected",
|
|
80
|
-
session
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
configured: true,
|
|
85
|
-
status: (await this.store.load(resolved.url))?.tokens ? "connected" : "disconnected",
|
|
86
|
-
session
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
async start(params) {
|
|
90
|
-
if (this.cancelling) throw new Error("OAuth connections are being cleared");
|
|
91
|
-
const task = this.startSession(params);
|
|
92
|
-
this.pending.add(task);
|
|
93
|
-
try {
|
|
94
|
-
return await task;
|
|
95
|
-
} finally {
|
|
96
|
-
this.pending.delete(task);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async cancelPending() {
|
|
100
|
-
this.cancelling = true;
|
|
101
|
-
try {
|
|
102
|
-
await Promise.all([...this.sessionsByServerUrl.values()].map((session) => session.close()));
|
|
103
|
-
await Promise.allSettled([...this.pending]);
|
|
104
|
-
this.sessionsByServerUrl.clear();
|
|
105
|
-
} finally {
|
|
106
|
-
this.cancelling = false;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async startSession(params) {
|
|
110
|
-
const rawServer = await resolveConnectorSecretReferences(params.rawServer);
|
|
111
|
-
if (this.cancelling) throw new Error("OAuth connections are being cleared");
|
|
112
|
-
const resolvedConfig = resolveMcpTransportConfig(params.serverId, rawServer);
|
|
113
|
-
if (!resolvedConfig || resolvedConfig.kind !== "http" || !resolvedConfig.auth) throw new Error(`MCP server "${params.serverId}" is not configured for OAuth`);
|
|
114
|
-
const serverUrl = new URL(resolvedConfig.url);
|
|
115
|
-
const conversationId = canonicalMcpServerUrl(serverUrl);
|
|
116
|
-
const previous = this.sessionsByServerUrl.get(conversationId);
|
|
117
|
-
if (previous && isAuthorizing(previous.snapshot())) return this.status(params.serverId, params.rawServer);
|
|
118
|
-
if (previous) await previous.close();
|
|
119
|
-
const session = new McpOAuthSession(params.serverId, serverUrl);
|
|
120
|
-
this.sessionsByServerUrl.set(conversationId, session);
|
|
121
|
-
try {
|
|
122
|
-
await session.start();
|
|
123
|
-
} catch (error) {
|
|
124
|
-
this.sessionsByServerUrl.delete(conversationId);
|
|
125
|
-
throw error;
|
|
126
|
-
}
|
|
127
|
-
try {
|
|
128
|
-
await this.store.update(serverUrl, (current) => current ? {
|
|
129
|
-
...current,
|
|
130
|
-
clientInformation: void 0,
|
|
131
|
-
tokens: void 0,
|
|
132
|
-
tokensSavedAt: void 0
|
|
133
|
-
} : void 0);
|
|
134
|
-
} catch (error) {
|
|
135
|
-
session.fail(error);
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
let provider;
|
|
139
|
-
let resolved;
|
|
140
|
-
try {
|
|
141
|
-
provider = new XopcMcpOAuthClientProvider({
|
|
142
|
-
serverUrl,
|
|
143
|
-
clientId: resolvedConfig.auth.clientId,
|
|
144
|
-
store: this.store,
|
|
145
|
-
interaction: {
|
|
146
|
-
redirectUrl: session.redirectUrl,
|
|
147
|
-
state: session.state,
|
|
148
|
-
onRedirect: (authorizationUrl) => session.setAuthorizationUrl(authorizationUrl)
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
resolved = await resolveMcpTransport(params.serverId, rawServer, params.cfg, {
|
|
152
|
-
oauthProvider: provider,
|
|
153
|
-
oauthStore: this.store
|
|
154
|
-
});
|
|
155
|
-
} catch (error) {
|
|
156
|
-
session.fail(error);
|
|
157
|
-
return this.status(params.serverId, params.rawServer);
|
|
158
|
-
}
|
|
159
|
-
if (!resolved || resolved.transportType !== "streamable-http") {
|
|
160
|
-
session.fail(/* @__PURE__ */ new Error("MCP OAuth requires a streamable HTTP transport"));
|
|
161
|
-
await resolved?.transport.close().catch(() => {});
|
|
162
|
-
return this.status(params.serverId, params.rawServer);
|
|
163
|
-
}
|
|
164
|
-
const client = createClient();
|
|
165
|
-
try {
|
|
166
|
-
await connectClient(client, resolved);
|
|
167
|
-
if (session.snapshot().status === "cancelled") {
|
|
168
|
-
await this.store.delete(serverUrl);
|
|
169
|
-
await closeConnection(client, resolved);
|
|
170
|
-
return {
|
|
171
|
-
configured: true,
|
|
172
|
-
status: "disconnected"
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
session.complete();
|
|
176
|
-
recordPluginMcpHealth(rawServer, "ready");
|
|
177
|
-
await closeConnection(client, resolved);
|
|
178
|
-
await disposeAllSessionMcpRuntimes();
|
|
179
|
-
} catch (error) {
|
|
180
|
-
if (session.snapshot().status === "cancelled") {
|
|
181
|
-
await this.store.delete(serverUrl);
|
|
182
|
-
await closeConnection(client, resolved);
|
|
183
|
-
} else if (!isMcpAuthorizationError(error) || !session.snapshot().authorizationUrl) {
|
|
184
|
-
session.fail(error);
|
|
185
|
-
await closeConnection(client, resolved);
|
|
186
|
-
} else {
|
|
187
|
-
const task = this.finishAuthorization({
|
|
188
|
-
session,
|
|
189
|
-
provider,
|
|
190
|
-
client,
|
|
191
|
-
resolved,
|
|
192
|
-
params: {
|
|
193
|
-
...params,
|
|
194
|
-
rawServer
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
this.pending.add(task);
|
|
198
|
-
task.finally(() => this.pending.delete(task));
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return this.status(params.serverId, params.rawServer);
|
|
202
|
-
}
|
|
203
|
-
async disconnect(serverId, rawServer) {
|
|
204
|
-
const resolved = resolveMcpTransportConfig(serverId, rawServer);
|
|
205
|
-
if (!resolved || resolved.kind !== "http" || !resolved.auth) throw new Error(`MCP server "${serverId}" is not configured for OAuth`);
|
|
206
|
-
const conversationId = canonicalMcpServerUrl(resolved.url);
|
|
207
|
-
const session = this.sessionsByServerUrl.get(conversationId);
|
|
208
|
-
this.sessionsByServerUrl.delete(conversationId);
|
|
209
|
-
if (session) await session.close();
|
|
210
|
-
await this.store.delete(resolved.url);
|
|
211
|
-
recordPluginMcpHealth(rawServer, "authorization_required");
|
|
212
|
-
await disposeAllSessionMcpRuntimes();
|
|
213
|
-
return {
|
|
214
|
-
configured: true,
|
|
215
|
-
status: "disconnected"
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
async submitCallback(serverId, rawServer, callbackUrl) {
|
|
219
|
-
const resolved = resolveMcpTransportConfig(serverId, rawServer);
|
|
220
|
-
if (!resolved || resolved.kind !== "http") throw new Error("Unknown OAuth server");
|
|
221
|
-
const session = this.sessionsByServerUrl.get(canonicalMcpServerUrl(resolved.url));
|
|
222
|
-
if (!session) throw new Error("OAuth session not found");
|
|
223
|
-
session.submitCallback(callbackUrl);
|
|
224
|
-
return this.status(serverId, rawServer);
|
|
225
|
-
}
|
|
226
|
-
async finishAuthorization(context) {
|
|
227
|
-
const { session, provider, client, resolved, params } = context;
|
|
228
|
-
try {
|
|
229
|
-
const code = await session.waitForCode();
|
|
230
|
-
await resolved.transport.finishAuth(code);
|
|
231
|
-
if (session.snapshot().status === "cancelled") {
|
|
232
|
-
await this.store.delete(session.serverUrl);
|
|
233
|
-
await closeConnection(client, resolved);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
await closeConnection(client, resolved);
|
|
237
|
-
const authenticated = await resolveMcpTransport(params.serverId, params.rawServer, params.cfg, {
|
|
238
|
-
oauthProvider: provider,
|
|
239
|
-
oauthStore: this.store
|
|
240
|
-
});
|
|
241
|
-
if (!authenticated) throw new Error("MCP transport could not be created after authorization");
|
|
242
|
-
const authenticatedClient = createClient();
|
|
243
|
-
try {
|
|
244
|
-
await connectClient(authenticatedClient, authenticated);
|
|
245
|
-
} finally {
|
|
246
|
-
await closeConnection(authenticatedClient, authenticated);
|
|
247
|
-
}
|
|
248
|
-
if (session.snapshot().status === "cancelled") {
|
|
249
|
-
await this.store.delete(session.serverUrl);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
session.complete();
|
|
253
|
-
recordPluginMcpHealth(params.rawServer, "ready");
|
|
254
|
-
await disposeAllSessionMcpRuntimes();
|
|
255
|
-
} catch (error) {
|
|
256
|
-
if (session.snapshot().status === "cancelled") {
|
|
257
|
-
await this.store.delete(session.serverUrl);
|
|
258
|
-
await closeConnection(client, resolved);
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
session.fail(error);
|
|
262
|
-
await closeConnection(client, resolved);
|
|
263
|
-
log.warn({
|
|
264
|
-
err: error,
|
|
265
|
-
phase: "mcp.oauth_finish",
|
|
266
|
-
serverId: params.serverId
|
|
267
|
-
}, `MCP OAuth failed for server "${params.serverId}": ${redactSensitiveUrlLikeString(error instanceof Error ? error.message : String(error))}`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
function getMcpOAuthManager(rawServer) {
|
|
272
|
-
const scope = pluginOAuthScope(rawServer);
|
|
273
|
-
return resolveGlobalSingleton(scope ? Symbol.for(`xopc.mcpOAuthManager:${scope}`) : MCP_OAUTH_MANAGER_KEY, () => new McpOAuthManager(new McpOAuthStore(scope)));
|
|
274
|
-
}
|
|
275
|
-
//#endregion
|
|
276
|
-
export { McpOAuthManager, getMcpOAuthManager };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { OAuthClientProvider, OAuthDiscoveryState } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
2
|
-
import type { OAuthClientInformationMixed, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
3
|
-
import { McpOAuthStore } from './mcp-oauth-store.js';
|
|
4
|
-
export type McpOAuthInteraction = {
|
|
5
|
-
redirectUrl: URL;
|
|
6
|
-
state: string;
|
|
7
|
-
onRedirect: (authorizationUrl: URL) => void | Promise<void>;
|
|
8
|
-
};
|
|
9
|
-
export type McpOAuthClientProviderOptions = {
|
|
10
|
-
serverUrl: URL;
|
|
11
|
-
clientId?: string;
|
|
12
|
-
interaction?: McpOAuthInteraction;
|
|
13
|
-
store?: McpOAuthStore;
|
|
14
|
-
};
|
|
15
|
-
export declare class XopcMcpOAuthClientProvider implements OAuthClientProvider {
|
|
16
|
-
private readonly options;
|
|
17
|
-
private readonly store;
|
|
18
|
-
private codeVerifierValue?;
|
|
19
|
-
constructor(options: McpOAuthClientProviderOptions);
|
|
20
|
-
get redirectUrl(): URL;
|
|
21
|
-
get clientMetadata(): OAuthClientMetadata;
|
|
22
|
-
state(): string | undefined;
|
|
23
|
-
clientInformation(): Promise<OAuthClientInformationMixed | undefined>;
|
|
24
|
-
saveClientInformation(clientInformation: OAuthClientInformationMixed): Promise<void>;
|
|
25
|
-
tokens(): Promise<OAuthTokens | undefined>;
|
|
26
|
-
saveTokens(tokens: OAuthTokens): Promise<void>;
|
|
27
|
-
redirectToAuthorization(authorizationUrl: URL): Promise<void>;
|
|
28
|
-
saveCodeVerifier(codeVerifier: string): void;
|
|
29
|
-
codeVerifier(): string;
|
|
30
|
-
saveDiscoveryState(discoveryState: OAuthDiscoveryState): Promise<void>;
|
|
31
|
-
discoveryState(): Promise<OAuthDiscoveryState | undefined>;
|
|
32
|
-
invalidateCredentials(scope: 'all' | 'client' | 'tokens' | 'verifier' | 'discovery'): Promise<void>;
|
|
33
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { McpAuthorizationRequiredError } from "./mcp-oauth-errors.js";
|
|
2
|
-
import { McpOAuthStore } from "./mcp-oauth-store.js";
|
|
3
|
-
//#region src/agent/mcp/oauth/mcp-oauth-provider.ts
|
|
4
|
-
var XopcMcpOAuthClientProvider = class {
|
|
5
|
-
store;
|
|
6
|
-
codeVerifierValue;
|
|
7
|
-
constructor(options) {
|
|
8
|
-
this.options = options;
|
|
9
|
-
this.store = options.store ?? new McpOAuthStore();
|
|
10
|
-
}
|
|
11
|
-
get redirectUrl() {
|
|
12
|
-
return this.options.interaction?.redirectUrl ?? new URL("http://127.0.0.1/oauth/callback");
|
|
13
|
-
}
|
|
14
|
-
get clientMetadata() {
|
|
15
|
-
return {
|
|
16
|
-
client_name: "XOPC",
|
|
17
|
-
client_uri: "https://xopc.ai",
|
|
18
|
-
redirect_uris: [this.redirectUrl.toString()],
|
|
19
|
-
grant_types: ["authorization_code", "refresh_token"],
|
|
20
|
-
response_types: ["code"],
|
|
21
|
-
token_endpoint_auth_method: "none"
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
state() {
|
|
25
|
-
return this.options.interaction?.state;
|
|
26
|
-
}
|
|
27
|
-
async clientInformation() {
|
|
28
|
-
if (this.options.clientId) return { client_id: this.options.clientId };
|
|
29
|
-
return (await this.store.load(this.options.serverUrl))?.clientInformation;
|
|
30
|
-
}
|
|
31
|
-
async saveClientInformation(clientInformation) {
|
|
32
|
-
await this.store.update(this.options.serverUrl, (current) => ({
|
|
33
|
-
...current,
|
|
34
|
-
version: 1,
|
|
35
|
-
serverUrl: this.options.serverUrl.toString(),
|
|
36
|
-
clientInformation,
|
|
37
|
-
updatedAt: current?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
async tokens() {
|
|
41
|
-
return (await this.store.load(this.options.serverUrl))?.tokens;
|
|
42
|
-
}
|
|
43
|
-
async saveTokens(tokens) {
|
|
44
|
-
await this.store.update(this.options.serverUrl, (current) => ({
|
|
45
|
-
...current,
|
|
46
|
-
version: 1,
|
|
47
|
-
serverUrl: this.options.serverUrl.toString(),
|
|
48
|
-
tokens,
|
|
49
|
-
tokensSavedAt: Date.now(),
|
|
50
|
-
updatedAt: current?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
async redirectToAuthorization(authorizationUrl) {
|
|
54
|
-
if (!this.options.interaction) throw new McpAuthorizationRequiredError();
|
|
55
|
-
await this.options.interaction.onRedirect(authorizationUrl);
|
|
56
|
-
}
|
|
57
|
-
saveCodeVerifier(codeVerifier) {
|
|
58
|
-
this.codeVerifierValue = codeVerifier;
|
|
59
|
-
}
|
|
60
|
-
codeVerifier() {
|
|
61
|
-
if (!this.codeVerifierValue) throw new Error("MCP OAuth code verifier is unavailable");
|
|
62
|
-
return this.codeVerifierValue;
|
|
63
|
-
}
|
|
64
|
-
async saveDiscoveryState(discoveryState) {
|
|
65
|
-
await this.store.update(this.options.serverUrl, (current) => {
|
|
66
|
-
const authorizationServerChanged = Boolean(current?.discoveryState?.authorizationServerUrl && current.discoveryState.authorizationServerUrl !== discoveryState.authorizationServerUrl);
|
|
67
|
-
return {
|
|
68
|
-
...current,
|
|
69
|
-
version: 1,
|
|
70
|
-
serverUrl: this.options.serverUrl.toString(),
|
|
71
|
-
discoveryState,
|
|
72
|
-
clientInformation: authorizationServerChanged ? void 0 : current?.clientInformation,
|
|
73
|
-
tokens: authorizationServerChanged ? void 0 : current?.tokens,
|
|
74
|
-
tokensSavedAt: authorizationServerChanged ? void 0 : current?.tokensSavedAt,
|
|
75
|
-
updatedAt: current?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
async discoveryState() {
|
|
80
|
-
return (await this.store.load(this.options.serverUrl))?.discoveryState;
|
|
81
|
-
}
|
|
82
|
-
async invalidateCredentials(scope) {
|
|
83
|
-
if (scope === "verifier") {
|
|
84
|
-
this.codeVerifierValue = void 0;
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
await this.store.update(this.options.serverUrl, (current) => {
|
|
88
|
-
if (!current) return void 0;
|
|
89
|
-
if (scope === "all") return void 0;
|
|
90
|
-
return {
|
|
91
|
-
...current,
|
|
92
|
-
...scope === "client" ? { clientInformation: void 0 } : {},
|
|
93
|
-
...scope === "tokens" ? {
|
|
94
|
-
tokens: void 0,
|
|
95
|
-
tokensSavedAt: void 0
|
|
96
|
-
} : {},
|
|
97
|
-
...scope === "discovery" ? { discoveryState: void 0 } : {}
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
//#endregion
|
|
103
|
-
export { XopcMcpOAuthClientProvider };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { McpOAuthSessionSnapshot } from './mcp-oauth-types.js';
|
|
2
|
-
export declare class McpOAuthSession {
|
|
3
|
-
readonly serverId: string;
|
|
4
|
-
readonly serverUrl: URL;
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly state: string;
|
|
7
|
-
readonly createdAt: number;
|
|
8
|
-
readonly expiresAt: number;
|
|
9
|
-
private statusValue;
|
|
10
|
-
private authorizationUrlValue?;
|
|
11
|
-
private errorValue?;
|
|
12
|
-
private callbackServer?;
|
|
13
|
-
private redirectUrlValue?;
|
|
14
|
-
private settleCode?;
|
|
15
|
-
private callbackConsumed;
|
|
16
|
-
private readonly codePromise;
|
|
17
|
-
private timeout?;
|
|
18
|
-
constructor(serverId: string, serverUrl: URL, ttlMs?: number);
|
|
19
|
-
get redirectUrl(): URL;
|
|
20
|
-
start(): Promise<void>;
|
|
21
|
-
setAuthorizationUrl(url: URL): void;
|
|
22
|
-
/** Remote Gateway users can submit the browser's loopback callback URL over the authenticated API. */
|
|
23
|
-
submitCallback(url: string): void;
|
|
24
|
-
waitForCode(): Promise<string>;
|
|
25
|
-
complete(): void;
|
|
26
|
-
fail(error: unknown): void;
|
|
27
|
-
cancel(): void;
|
|
28
|
-
snapshot(): McpOAuthSessionSnapshot;
|
|
29
|
-
close(): Promise<void>;
|
|
30
|
-
private closeServer;
|
|
31
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { randomBytes, randomUUID } from "node:crypto";
|
|
2
|
-
import { createServer } from "node:http";
|
|
3
|
-
//#region src/agent/mcp/oauth/mcp-oauth-session.ts
|
|
4
|
-
const CALLBACK_PATH = "/oauth/callback";
|
|
5
|
-
const DEFAULT_SESSION_TTL_MS = 600 * 1e3;
|
|
6
|
-
function callbackPage(title, message) {
|
|
7
|
-
return `<!doctype html><html><head><meta charset="utf-8"><title>${title}</title></head><body><h1>${title}</h1><p>${message}</p></body></html>`;
|
|
8
|
-
}
|
|
9
|
-
var McpOAuthSession = class {
|
|
10
|
-
id = `mcp_oauth_${randomUUID()}`;
|
|
11
|
-
state = randomBytes(24).toString("base64url");
|
|
12
|
-
createdAt = Date.now();
|
|
13
|
-
expiresAt;
|
|
14
|
-
statusValue = "starting";
|
|
15
|
-
authorizationUrlValue;
|
|
16
|
-
errorValue;
|
|
17
|
-
callbackServer;
|
|
18
|
-
redirectUrlValue;
|
|
19
|
-
settleCode;
|
|
20
|
-
callbackConsumed = false;
|
|
21
|
-
codePromise;
|
|
22
|
-
timeout;
|
|
23
|
-
constructor(serverId, serverUrl, ttlMs = DEFAULT_SESSION_TTL_MS) {
|
|
24
|
-
this.serverId = serverId;
|
|
25
|
-
this.serverUrl = serverUrl;
|
|
26
|
-
this.expiresAt = this.createdAt + ttlMs;
|
|
27
|
-
this.codePromise = new Promise((resolve) => {
|
|
28
|
-
this.settleCode = resolve;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
get redirectUrl() {
|
|
32
|
-
if (!this.redirectUrlValue) throw new Error("MCP OAuth callback server has not started");
|
|
33
|
-
return this.redirectUrlValue;
|
|
34
|
-
}
|
|
35
|
-
async start() {
|
|
36
|
-
if (this.callbackServer) return;
|
|
37
|
-
const server = createServer((request, response) => {
|
|
38
|
-
response.setHeader("content-type", "text/html; charset=utf-8");
|
|
39
|
-
response.setHeader("cache-control", "no-store");
|
|
40
|
-
response.setHeader("referrer-policy", "no-referrer");
|
|
41
|
-
response.setHeader("x-content-type-options", "nosniff");
|
|
42
|
-
try {
|
|
43
|
-
const callback = new URL(request.url ?? "", "http://127.0.0.1");
|
|
44
|
-
if (callback.pathname !== CALLBACK_PATH) {
|
|
45
|
-
response.statusCode = 404;
|
|
46
|
-
response.end(callbackPage("Not found", "This is not an XOPC OAuth callback."));
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (callback.searchParams.get("state") !== this.state) {
|
|
50
|
-
response.statusCode = 400;
|
|
51
|
-
response.end(callbackPage("Authorization failed", "MCP OAuth state mismatch"));
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (this.callbackConsumed) {
|
|
55
|
-
response.statusCode = 409;
|
|
56
|
-
response.end(callbackPage("Authorization already handled", "Return to XOPC to continue."));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const oauthError = callback.searchParams.get("error");
|
|
60
|
-
const code = callback.searchParams.get("code");
|
|
61
|
-
if (oauthError || !code) {
|
|
62
|
-
const error = /* @__PURE__ */ new Error(oauthError === "access_denied" ? "Authorization was denied" : "Authorization code is missing");
|
|
63
|
-
response.statusCode = 400;
|
|
64
|
-
response.end(callbackPage("Authorization failed", error.message));
|
|
65
|
-
this.fail(error);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this.callbackConsumed = true;
|
|
69
|
-
this.statusValue = "exchanging_code";
|
|
70
|
-
response.statusCode = 200;
|
|
71
|
-
response.end(callbackPage("Authorization complete", "Return to XOPC to finish connecting the MCP server."));
|
|
72
|
-
this.settleCode?.({ code });
|
|
73
|
-
this.settleCode = void 0;
|
|
74
|
-
} catch {
|
|
75
|
-
const error = /* @__PURE__ */ new Error("MCP OAuth callback could not be processed");
|
|
76
|
-
response.statusCode = 500;
|
|
77
|
-
response.end(callbackPage("Authorization failed", error.message));
|
|
78
|
-
this.fail(error);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
this.callbackServer = server;
|
|
82
|
-
try {
|
|
83
|
-
this.redirectUrlValue = await new Promise((resolve, reject) => {
|
|
84
|
-
server.once("error", reject);
|
|
85
|
-
server.listen(0, "127.0.0.1", () => {
|
|
86
|
-
server.removeListener("error", reject);
|
|
87
|
-
const address = server.address();
|
|
88
|
-
if (!address || typeof address === "string") {
|
|
89
|
-
reject(/* @__PURE__ */ new Error("MCP OAuth callback server did not expose a TCP port"));
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
resolve(new URL(`http://127.0.0.1:${address.port}${CALLBACK_PATH}`));
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
} catch (error) {
|
|
96
|
-
this.callbackServer = void 0;
|
|
97
|
-
server.close();
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
this.timeout = setTimeout(() => {
|
|
101
|
-
this.statusValue = "expired";
|
|
102
|
-
this.errorValue = "MCP OAuth session expired";
|
|
103
|
-
this.settleCode?.({ error: new Error(this.errorValue) });
|
|
104
|
-
this.settleCode = void 0;
|
|
105
|
-
this.closeServer();
|
|
106
|
-
}, Math.max(1, this.expiresAt - Date.now()));
|
|
107
|
-
this.timeout.unref?.();
|
|
108
|
-
}
|
|
109
|
-
setAuthorizationUrl(url) {
|
|
110
|
-
this.authorizationUrlValue = url.toString();
|
|
111
|
-
this.statusValue = "waiting_browser";
|
|
112
|
-
}
|
|
113
|
-
/** Remote Gateway users can submit the browser's loopback callback URL over the authenticated API. */
|
|
114
|
-
submitCallback(url) {
|
|
115
|
-
const callback = new URL(url);
|
|
116
|
-
if (callback.origin !== this.redirectUrl.origin || callback.pathname !== CALLBACK_PATH || callback.searchParams.get("state") !== this.state) throw new Error("MCP OAuth callback mismatch");
|
|
117
|
-
if (this.statusValue !== "waiting_browser" || this.callbackConsumed || Date.now() >= this.expiresAt) throw new Error("MCP OAuth session is not waiting for a callback");
|
|
118
|
-
const code = callback.searchParams.get("code");
|
|
119
|
-
if (!code || callback.searchParams.has("error")) throw new Error("MCP OAuth authorization code is missing or denied");
|
|
120
|
-
this.callbackConsumed = true;
|
|
121
|
-
this.statusValue = "exchanging_code";
|
|
122
|
-
this.settleCode?.({ code });
|
|
123
|
-
this.settleCode = void 0;
|
|
124
|
-
}
|
|
125
|
-
async waitForCode() {
|
|
126
|
-
const result = await this.codePromise;
|
|
127
|
-
if (result.error) throw result.error;
|
|
128
|
-
if (!result.code) throw new Error("MCP OAuth authorization code is unavailable");
|
|
129
|
-
return result.code;
|
|
130
|
-
}
|
|
131
|
-
complete() {
|
|
132
|
-
this.statusValue = "connected";
|
|
133
|
-
this.errorValue = void 0;
|
|
134
|
-
this.closeServer();
|
|
135
|
-
}
|
|
136
|
-
fail(error) {
|
|
137
|
-
this.statusValue = "failed";
|
|
138
|
-
this.errorValue = error instanceof Error ? error.message : String(error);
|
|
139
|
-
this.settleCode?.({ error: error instanceof Error ? error : new Error(String(error)) });
|
|
140
|
-
this.settleCode = void 0;
|
|
141
|
-
this.closeServer();
|
|
142
|
-
}
|
|
143
|
-
cancel() {
|
|
144
|
-
if ([
|
|
145
|
-
"connected",
|
|
146
|
-
"failed",
|
|
147
|
-
"expired",
|
|
148
|
-
"cancelled"
|
|
149
|
-
].includes(this.statusValue)) return;
|
|
150
|
-
this.statusValue = "cancelled";
|
|
151
|
-
this.settleCode?.({ error: /* @__PURE__ */ new Error("MCP OAuth session cancelled") });
|
|
152
|
-
this.settleCode = void 0;
|
|
153
|
-
this.closeServer();
|
|
154
|
-
}
|
|
155
|
-
snapshot() {
|
|
156
|
-
return {
|
|
157
|
-
id: this.id,
|
|
158
|
-
serverId: this.serverId,
|
|
159
|
-
serverUrl: this.serverUrl.toString(),
|
|
160
|
-
status: this.statusValue,
|
|
161
|
-
authorizationUrl: this.authorizationUrlValue,
|
|
162
|
-
error: this.errorValue,
|
|
163
|
-
createdAt: this.createdAt,
|
|
164
|
-
expiresAt: this.expiresAt
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
async close() {
|
|
168
|
-
this.cancel();
|
|
169
|
-
await this.closeServer();
|
|
170
|
-
}
|
|
171
|
-
async closeServer() {
|
|
172
|
-
if (this.timeout) clearTimeout(this.timeout);
|
|
173
|
-
this.timeout = void 0;
|
|
174
|
-
const server = this.callbackServer;
|
|
175
|
-
this.callbackServer = void 0;
|
|
176
|
-
if (!server) return;
|
|
177
|
-
await new Promise((resolve) => server.close(() => resolve()));
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
//#endregion
|
|
181
|
-
export { McpOAuthSession };
|