@xopcai/xopc 0.0.426 → 0.0.427
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/src/adapters/security-adapter.js +1 -1
- package/dist/extensions/telegram/src/pairing-config-resolver.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +2 -2
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.js +1 -1
- package/dist/extensions/weixin/src/auth/accounts.js +2 -2
- package/dist/extensions/weixin/src/auth/pairing.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/cli/gateway-qr-login.js +1 -1
- package/dist/extensions/weixin/src/cli/qr-login.js +1 -1
- package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
- package/dist/extensions/weixin/src/messaging/inbound.js +2 -2
- package/dist/extensions/weixin/src/messaging/process-message.js +3 -3
- package/dist/extensions/weixin/src/messaging/send.js +12 -3
- package/dist/extensions/weixin/src/monitor/monitor.js +1 -1
- package/dist/extensions/weixin/src/outbound-send.js +12 -3
- package/dist/extensions/weixin/src/pairing-config-resolver.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D4ClP_DJ.js +1 -0
- package/dist/gateway/static/root/assets/agent-plugin-dialog-m1A8wF9p.js +1 -0
- package/dist/gateway/static/root/assets/agents-B9slUA_1.js +77 -0
- package/dist/gateway/static/root/assets/app-link-DRy3-k7j.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C8yc3yHG.js → app-management-settings-panel-XqoIBF2H.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BELgtR3O.js → appearance-settings-9ZtqCASo.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DUeu_7iC.js +1 -0
- package/dist/gateway/static/root/assets/attachment-load-DrVGNxJm.js +1 -0
- package/dist/gateway/static/root/assets/automation-task-card-Bur78p68.js +3 -0
- package/dist/gateway/static/root/assets/{automations-page-CdIPdwF0.js → automations-page-DMIyWsP0.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-DEkDjxeU.js +9 -0
- package/dist/gateway/static/root/assets/{block-editor-BQtTLe6Q.js → block-editor-CXdlNAmZ.js} +2 -2
- package/dist/gateway/static/root/assets/{browser-automation-inputs-DeraGZ1y.js → browser-automation-inputs-Fxo7HbK6.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-SpPzRNqU.js → browser-automations-page-Dn3LN5wo.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-Cpm9fEPV.js +3 -0
- package/dist/gateway/static/root/assets/{button-CnRSIP6m.js → button-Cc4hUNTt.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-DLMuj21P.js → capabilities-BEvywfF9.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-Bo2qEJhH.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-page-BCzsIzvC.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Cr67ziwX.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-CTUCuBlW.js → capability-header-actions-BxMYfQ8y.js} +1 -1
- package/dist/gateway/static/root/assets/channels-CA5z5dGY.js +1 -0
- package/dist/gateway/static/root/assets/{chat-chart-block-DCzUECct.js → chat-chart-block-B39npsXj.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-D92AWJbh.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-Dl-OTkJI.js → chat-terminal-dock-DjFnElAM.js} +2 -2
- package/dist/gateway/static/root/assets/composer-payload-handoff-BQXlFKf4.js +1 -0
- package/dist/gateway/static/root/assets/{computer-settings-page-B-lGMimW.js → computer-settings-page-MkqyKyf3.js} +1 -1
- package/dist/gateway/static/root/assets/confirm-dialog-D7dQJytv.js +1 -0
- package/dist/gateway/static/root/assets/connected-providers-grid-BSvKP2u-.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-C8InhrMt.js → connector-service-page-DlIl9bLx.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-Vx8-MY0Y.js +1 -0
- package/dist/gateway/static/root/assets/{copy-text-row-CYIv7RfP.js → copy-text-row-CpiRzq4G.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-kqic8j73.js → date-picker-BIfjfOTM.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-XjPB8FJS.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BDS7_tQ_.js → desktop-pet-settings-BDjsFown.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-DH_uJ698.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Di0h3ws4.js → directory-picker-path-field-DiZXY7jF.js} +1 -1
- package/dist/gateway/static/root/assets/{discussion-annotation-sync-ClKEyXmN.js → discussion-annotation-sync-BXqNuZnx.js} +1 -1
- package/dist/gateway/static/root/assets/dist-BGTk37IG.js +1 -0
- package/dist/gateway/static/root/assets/dist-BuHnPloF.js +1 -0
- package/dist/gateway/static/root/assets/dist-GJ8-1PAx.js +1 -0
- package/dist/gateway/static/root/assets/dist-ZrL34Ps4.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DwB5KMGk.js → extension-debug-page-myQqsol2.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-Cqg1K70e.js → extension-iframe-host-DaL-OcTw.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DyrQtG82.js → extension-page-DvlGhZLa.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-C_uKqJxP.js → extension-provider-fOi6V6Cr.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BAMQHzkX.js → extension-settings-page-DOGlQpkx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-uAboiElC.js → gateway-settings-Di41peSM.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-B3sgqrl3.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-CQxZSTWA.js → image-generation-api-Ce-IY7Ug.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-C90644id.js → imports-page-W7_cDbxy.js} +1 -1
- package/dist/gateway/static/root/assets/index-D4B6O8B3.js +11 -0
- package/dist/gateway/static/root/assets/index-DGWBJDAM.css +1 -0
- package/dist/gateway/static/root/assets/install-connector-dialog-DWVl9ekV.js +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CbeubKe1.js → keyboard-shortcuts-settings-Doyu0Q9e.js} +1 -1
- package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-B3h3P6aI.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-C6zFgwkr.js → local-apps-page-D6D2bZGW.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CpVCvAWE.js → logs-page-qiXos_12.js} +2 -2
- package/dist/gateway/static/root/assets/management-settings-C0WcSdK7.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DrVAMlwc.js → markdown-view-Ck5s16p9.js} +2 -2
- package/dist/gateway/static/root/assets/mcp-conversation-setup-page-CENs3hGU.js +1 -0
- package/dist/gateway/static/root/assets/model-selector-DCBmsHzj.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-CnuxqWMd.js +5 -0
- package/dist/gateway/static/root/assets/note-image-lightbox-BFKZ7qJr.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-CUlhTRv0.js → notes-api-8kp0X1x6.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-eoKX85K5.js → notes-page-XMdy-H3H.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-C8BXow79.js → oauth-provider-connect-CfOK8mPM.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-CBFK41OS.js → page-context-capture-button-CKlKWSJ7.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-CIMMSI25.js +1 -0
- package/dist/gateway/static/root/assets/{personal-settings-panel-DnYapLo7.js → personal-settings-panel-wKdlrfPq.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-DBiKtzwz.js → phone-dependencies-card-CDhk5277.js} +1 -1
- package/dist/gateway/static/root/assets/phone-model-connection-DZ-ZunPz.js +1 -0
- package/dist/gateway/static/root/assets/{phone-model-picker-BmSxEr7M.js → phone-model-picker-DuZc5jYO.js} +1 -1
- package/dist/gateway/static/root/assets/phone-settings-page-0u0GQl_R.js +1 -0
- package/dist/gateway/static/root/assets/plugin-details-dialog-Bfc-Wmrd.js +1 -0
- package/dist/gateway/static/root/assets/{popover-select-DD8fmrxH.js → popover-select-CEMWIrtY.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-Cu_ZC9Up.js → preference-select-fields-BKeHZLXZ.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-Tn2dUJWM.js → product-automation-feedback-BPur0vyo.js} +2 -2
- package/dist/gateway/static/root/assets/{product-open-page-Nf-Oqf1h.js → product-open-page-Bfd7R483.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-D6NwUm3A.js → product-preview-content-Bnq68oVw.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-BfNcGgXA.js → product-preview-modal-BPmTeweh.js} +2 -2
- package/dist/gateway/static/root/assets/project-detail-page-D9nnyvrI.js +7 -0
- package/dist/gateway/static/root/assets/{project-understanding-B1BK7Ixi.js → project-understanding-DLvxAoTT.js} +1 -1
- package/dist/gateway/static/root/assets/projects-page-BGy1pw9a.js +1 -0
- package/dist/gateway/static/root/assets/{recording-upload-RAhaLUcQ.js → recording-upload-CHFJbqW1.js} +1 -1
- package/dist/gateway/static/root/assets/{refresh-button-bU_0NarN.js → refresh-button-DiWdGAaX.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-DWsOWetc.js → remote-access-hub-BVqwnOqO.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-DI43HQV_.js +2 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BGiXeHF5.js → runtime-tools-settings-panel-ccVBG-bZ.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BKeP5G7b.js → schema-form-C-jw6Hid.js} +1 -1
- package/dist/gateway/static/root/assets/{secret-input-BQvFXqzz.js → secret-input-Dryrns2s.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-BEnNx0u7.js → service-recommendation-list-CNghOavt.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-Bnq3qpqy.js +23 -0
- package/dist/gateway/static/root/assets/sessions-page-CyBj1Xw2.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-CURRjsLK.js → settings-advanced-section-DwpPPxT0.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-GtsbT6as.js → settings-page-Cd8Ermnn.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-DBL0_u0Z.js → settings-page-header-BZl4AMiN.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-IAvpbz4A.js → settings-page-layout-onhEgq-K.js} +1 -1
- package/dist/gateway/static/root/assets/setup-interaction-page-Cvvj6JyV.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-D4qgE7QM.js +1 -0
- package/dist/gateway/static/root/assets/share-link-dialog-DA0QuFOD.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-L9KYu8M7.js → share-preview-page-YDpIY4dC.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DUvjOMmA.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-ClyNSh-7.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CsvcFoaJ.js → system-settings-panel-BN6sUX0H.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CS9m7Ipo.js +2 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-B8xUiwW3.js → task-result-evidence-DKygspo2.js} +1 -1
- package/dist/gateway/static/root/assets/tracing-settings-page-Bs76WeoF.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-BB7u79ID.js → tunnel-api-B7nx0NQJ.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-Cv4Je5XJ.js → usage-page-anU5gslJ.js} +1 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-DYY3Yz4a.js +2 -0
- package/dist/gateway/static/root/assets/use-file-preview-expanded-CYgWzDnv.js +2 -0
- package/dist/gateway/static/root/assets/{use-workspace-tree-BQEiJzK7.js → use-workspace-tree-Dkg9tUr4.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-DIgPL3tN.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DCM69u8Y.js → voice-api-key-field-BUes-Jlp.js} +1 -1
- package/dist/gateway/static/root/assets/voice-transcribe-api-Dy4hfftb.js +1 -0
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CVe9UmFl.js → work-discovery-overlay-CFF4cRFl.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-CtqkRMN5.js → work-discovery-page-BnYaVH3V.js} +1 -1
- package/dist/gateway/static/root/assets/working-directory-picker-modal-GFwVefVA.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-api-tbifz2zY.js → workspace-api-BdB4NEOh.js} +2 -2
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BubQwQwU.js → workspace-file-preview-dialog-NRL3YRjg.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-DZk3MBSa.js → workspace-open-location-menu-Dcij7wvJ.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-CIavPUr3.js → xopc-cloud-account-card-DC9aG7Pl.js} +1 -1
- package/dist/gateway/static/root/index.html +66 -64
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +7 -0
- package/dist/packages/gateway-contract/src/capabilities.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/child-agent-factory.js +1 -1
- package/dist/src/agent/data-acquisition/service.js +1 -1
- package/dist/src/agent/embedded/configuration-capability-correction.d.ts +3 -0
- package/dist/src/agent/embedded/configuration-capability-correction.js +14 -0
- package/dist/src/agent/embedded/run-for-session.js +20 -5
- package/dist/src/agent/embedded/run-turn.js +13 -1
- package/dist/src/agent/embedded/session-runner.js +6 -3
- package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
- package/dist/src/agent/image/load-image-media.js +1 -1
- package/dist/src/agent/inbound/inbound-loop.js +4 -1
- package/dist/src/agent/independent-execution.js +1 -1
- package/dist/src/agent/mcp/config.js +1 -1
- package/dist/src/agent/mcp/connection-drafts.d.ts +3 -1
- package/dist/src/agent/mcp/connection-drafts.js +3 -2
- package/dist/src/agent/mcp/connection-setup.js +34 -2
- package/dist/src/agent/mcp/conversation-setup.d.ts +163 -0
- package/dist/src/agent/mcp/conversation-setup.js +621 -0
- package/dist/src/agent/mcp/native-mcp.d.ts +1 -0
- package/dist/src/agent/mcp/tool-catalog.d.ts +5 -0
- package/dist/src/agent/mcp/tool-catalog.js +19 -2
- package/dist/src/agent/mcp/weixin-setup-scope.d.ts +12 -0
- package/dist/src/agent/mcp/weixin-setup-scope.js +43 -0
- package/dist/src/agent/prompt/conversational-configuration-guide.js +2 -1
- package/dist/src/agent/prompt/sections/tooling.js +3 -2
- package/dist/src/agent/prompt/service-prompt-builder.js +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +2 -2
- package/dist/src/agent/service.d.ts +2 -0
- package/dist/src/agent/service.js +11 -1
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/tasks/task-judge-service.js +2 -2
- package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +6 -4
- package/dist/src/agent/tool-manuals/xopc-configuration.js +92 -8
- package/dist/src/agent/tools/automation-tool.d.ts +9 -1
- package/dist/src/agent/tools/automation-tool.js +34 -5
- package/dist/src/agent/tools/create-share-tool.js +1 -1
- package/dist/src/agent/tools/factory.d.ts +3 -0
- package/dist/src/agent/tools/factory.js +34 -23
- package/dist/src/agent/tools/image-generate-tool.js +3 -3
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +5 -4
- package/dist/src/agent/tools/mcp-setup-tool.d.ts +9 -0
- package/dist/src/agent/tools/mcp-setup-tool.js +32 -0
- package/dist/src/agent/tools/personal-task-tool.js +2 -2
- package/dist/src/agent/tools/publish-artifacts.js +1 -1
- package/dist/src/agent/tools/read.js +1 -1
- package/dist/src/agent/tools/skill-install-tool.js +56 -1
- package/dist/src/agent/tools/skill-manage-tool.d.ts +4 -0
- package/dist/src/agent/tools/skill-manage-tool.js +74 -2
- package/dist/src/agent/tools/skills-tools.js +1 -1
- package/dist/src/agent/tools/task-collaboration-tool.js +1 -1
- package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -1
- package/dist/src/agent/tools/tool-manual-tool.js +3 -1
- package/dist/src/agent/tools/toolExposure.js +2 -0
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
- package/dist/src/agent/tools/xopc-use-tool.js +60 -10
- package/dist/src/agent-catalog/service.d.ts +1 -1
- package/dist/src/agent-catalog/service.js +2 -1
- package/dist/src/automations/capabilities/drafts.js +5 -2
- package/dist/src/automations/capabilities/read.js +18 -7
- package/dist/src/automations/capabilities/write.d.ts +111 -52
- package/dist/src/automations/capabilities/write.js +44 -10
- package/dist/src/automations/delivery/delivery-router.d.ts +1 -0
- package/dist/src/automations/delivery/delivery-router.js +7 -1
- package/dist/src/automations/domain/types.d.ts +8 -0
- package/dist/src/automations/domain/validation.d.ts +24 -0
- package/dist/src/automations/domain/validation.js +7 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +6 -0
- package/dist/src/automations/index.js +2 -2
- package/dist/src/automations/mcp-source.d.ts +60 -0
- package/dist/src/automations/mcp-source.js +173 -0
- package/dist/src/automations/service/action-executor.js +15 -1
- package/dist/src/automations/service/automation-service.d.ts +5 -0
- package/dist/src/automations/service/automation-service.js +52 -2
- package/dist/src/automations/service/index.js +2 -2
- package/dist/src/browser/setup/repository.d.ts +1 -0
- package/dist/src/browser/setup/repository.js +7 -1
- package/dist/src/browser/setup/service.d.ts +3 -0
- package/dist/src/browser/setup/service.js +41 -18
- package/dist/src/browser/setup/types.d.ts +1 -0
- package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
- package/dist/src/channels/index.js +1 -1
- package/dist/src/channels/manager.d.ts +1 -0
- package/dist/src/channels/outbound-sender.d.ts +1 -0
- package/dist/src/channels/outbound-sender.js +3 -0
- package/dist/src/channels/pairing/pairing-service.js +1 -1
- package/dist/src/channels/weixin/account-identity.d.ts +2 -0
- package/dist/src/channels/weixin/account-identity.js +15 -0
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/cli/commands/channels.js +2 -2
- package/dist/src/cli/commands/doctor/checks/channel-pairing-pending.js +1 -1
- package/dist/src/cli/commands/mcp.js +1 -1
- package/dist/src/extensions/agent-plugins/credentials.js +1 -1
- package/dist/src/extensions/agent-plugins/setup.d.ts +1 -1
- package/dist/src/extensions/agent-plugins/setup.js +3 -3
- package/dist/src/extensions/api.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/device-routes.js +1 -1
- package/dist/src/gateway/hono/app.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/oauth-async.js +1 -1
- package/dist/src/gateway/hono/routes/channels.js +1 -1
- package/dist/src/gateway/hono/routes/config.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +39 -2
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/phone-setup.js +33 -9
- package/dist/src/gateway/hono/routes/projects.js +1 -1
- package/dist/src/gateway/hono/routes/provider-setup.js +1 -1
- package/dist/src/gateway/hono/routes/public-gateway.js +22 -0
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/site-shares.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/media-access.js +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +1 -0
- package/dist/src/gateway/service/agent-runner.js +3 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
- package/dist/src/gateway/service/config-coordinator.js +2 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service/sessions-api.js +2 -1
- package/dist/src/gateway/service.d.ts +5 -1
- package/dist/src/gateway/service.js +90 -16
- package/dist/src/gateway/session-context-summary.js +1 -1
- package/dist/src/gateway/session-reset-service.d.ts +1 -0
- package/dist/src/gateway/session-reset-service.js +15 -2
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/notes/service.js +1 -1
- package/dist/src/personal-agent/prompts.js +1 -1
- package/dist/src/personal-agent/reply-composer.js +2 -2
- package/dist/src/personal-agent/request-service.js +3 -3
- package/dist/src/personal-agent/service.js +1 -1
- package/dist/src/personal-agent/task-cancel.js +1 -1
- package/dist/src/phone/setup/service.d.ts +14 -4
- package/dist/src/phone/setup/service.js +106 -28
- package/dist/src/projects/index.js +1 -1
- package/dist/src/projects/project-service.js +1 -1
- package/dist/src/runtime-tools/phone-dependencies.d.ts +2 -0
- package/dist/src/runtime-tools/phone-dependencies.js +10 -0
- package/dist/src/share/note-share-service.js +1 -1
- package/dist/src/share/site-proxy.js +1 -1
- package/dist/src/tasks/capabilities/write.js +1 -1
- package/dist/src/tasks/index.js +1 -1
- package/dist/src/tasks/task-allocation-service.js +3 -3
- package/dist/src/tasks/task-application-service.js +2 -2
- package/dist/src/tasks/task-context-assembler.js +1 -1
- package/dist/src/tasks/task-contract-planner.js +1 -1
- package/dist/src/tasks/task-handoff.js +1 -1
- package/dist/src/tasks/task-research-result.js +1 -1
- package/dist/src/tasks/task-run-coordinator.js +2 -2
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/package.json +3 -1
- package/skills/tools/configure-xopc/SKILL.md +10 -3
- package/skills/tools/configure-xopc/references/browser/chrome-extension.md +4 -1
- package/skills/tools/configure-xopc/references/browser/overview.md +2 -2
- package/skills/tools/configure-xopc/references/phone/aliyun.md +3 -2
- package/skills/tools/configure-xopc/references/phone/overview.md +2 -2
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Dne9A10p.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-BoHL-b1o.js +0 -1
- package/dist/gateway/static/root/assets/agents-CIiIlVBp.js +0 -77
- package/dist/gateway/static/root/assets/app-link-1j40sJ-z.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-vgS1CHDj.js +0 -1
- package/dist/gateway/static/root/assets/attachment-load-qjPpQzYY.js +0 -1
- package/dist/gateway/static/root/assets/automation-task-card-MnzgyTVA.js +0 -3
- package/dist/gateway/static/root/assets/automations-workspace-C3xZLafX.js +0 -9
- package/dist/gateway/static/root/assets/browser-settings-page-BD1uF_Nb.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-BGE6hiUE.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-Bda4mSdf.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-B2B7no22.js +0 -8
- package/dist/gateway/static/root/assets/channels-NtsjZThx.js +0 -1
- package/dist/gateway/static/root/assets/chat-page-BnOCCAXG.js +0 -72
- package/dist/gateway/static/root/assets/composer-payload-handoff-CQc-VTaL.js +0 -1
- package/dist/gateway/static/root/assets/confirm-dialog-XGclfBqe.js +0 -1
- package/dist/gateway/static/root/assets/connected-providers-grid-CcXe9kz5.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-Ci0L2How.js +0 -1
- package/dist/gateway/static/root/assets/dependency-picker-cbC6-2Ya.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-_3BJFWVQ.js +0 -1
- package/dist/gateway/static/root/assets/dist-CaUuvp8-.js +0 -1
- package/dist/gateway/static/root/assets/dist-D3lWNSe7.js +0 -1
- package/dist/gateway/static/root/assets/dist-DfWfZ9iu.js +0 -1
- package/dist/gateway/static/root/assets/dist-DusecO_p.js +0 -1
- package/dist/gateway/static/root/assets/home-page-D6pCBY1V.js +0 -2
- package/dist/gateway/static/root/assets/index-Cc41XQid.css +0 -1
- package/dist/gateway/static/root/assets/index-CnOYR6jq.js +0 -11
- package/dist/gateway/static/root/assets/install-connector-dialog-BuNXON0P.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CP-BkbB6.js +0 -1
- package/dist/gateway/static/root/assets/management-settings-I-pXv4ML.js +0 -1
- package/dist/gateway/static/root/assets/model-selector-CXcxc30J.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-CbpLXAVh.js +0 -5
- package/dist/gateway/static/root/assets/note-image-lightbox-cLGiF8oU.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-CXR1Gy0x.js +0 -1
- package/dist/gateway/static/root/assets/phone-settings-page-vg65qilc.js +0 -1
- package/dist/gateway/static/root/assets/plugin-details-dialog-B3Hn2cbx.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-Ch-ZMyTu.js +0 -7
- package/dist/gateway/static/root/assets/projects-page-B7cetxao.js +0 -1
- package/dist/gateway/static/root/assets/route-preload-Zc5Z3fNv.js +0 -2
- package/dist/gateway/static/root/assets/session-manager-ChUtTAoG.js +0 -23
- package/dist/gateway/static/root/assets/sessions-page-Bt52kBvJ.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-A6uMpGRy.js +0 -1
- package/dist/gateway/static/root/assets/share-link-dialog-D1otGSXD.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Bmfadz8A.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BZklXTX9.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-SjZGW1Dx.js +0 -2
- package/dist/gateway/static/root/assets/tracing-settings-page-MvG4SH64.js +0 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-vDdxHtUb.js +0 -2
- package/dist/gateway/static/root/assets/use-file-preview-expanded-Ce2mgYme.js +0 -2
- package/dist/gateway/static/root/assets/user-model-page-DRSsn4EV.js +0 -2
- package/dist/gateway/static/root/assets/voice-transcribe-api-Bbyj0yGR.js +0 -1
- package/dist/gateway/static/root/assets/working-directory-picker-modal-CDZ1xh3o.js +0 -1
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { getActiveConnectionWait, init_connection_wait_repository } from "../../storage/sqlite/connection-wait-repository.js";
|
|
4
|
+
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
5
|
+
import { init_session_repository } from "../../storage/sqlite/session-repository.js";
|
|
6
|
+
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
7
|
+
import { connectorPrincipalForSession } from "../../connectors/principal.js";
|
|
8
|
+
import { DurableState } from "../../storage/sqlite/durable-state.js";
|
|
9
|
+
import { connectorSecretProviderId } from "../../connectors/secret-store.js";
|
|
10
|
+
import { isManagedConnectorServer } from "../../connectors/materialize.js";
|
|
11
|
+
import { classifyMcpConnectionError } from "./connection-errors.js";
|
|
12
|
+
import { McpConnectionDrafts, McpDraftError, mcpConfigRevision } from "./connection-drafts.js";
|
|
13
|
+
import { weixinSetupScope } from "./weixin-setup-scope.js";
|
|
14
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { setTimeout } from "node:timers/promises";
|
|
17
|
+
//#region src/agent/mcp/conversation-setup.ts
|
|
18
|
+
init_credentials();
|
|
19
|
+
init_session_repository();
|
|
20
|
+
init_connection_wait_repository();
|
|
21
|
+
init_logger();
|
|
22
|
+
const identity = z.string().min(1).max(200);
|
|
23
|
+
const log = createLogger("McpConversationSetup");
|
|
24
|
+
const targetSchema = z.object({
|
|
25
|
+
serverId: z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),
|
|
26
|
+
displayName: z.string().min(1).max(100).optional(),
|
|
27
|
+
url: z.string().url().max(2048),
|
|
28
|
+
purpose: z.string().min(1).max(1e3),
|
|
29
|
+
expectedRevision: z.string().optional()
|
|
30
|
+
}).strict();
|
|
31
|
+
const setupSchema = z.object({
|
|
32
|
+
setupId: identity,
|
|
33
|
+
expectedVersion: z.number().int().positive().optional()
|
|
34
|
+
}).strict();
|
|
35
|
+
const serverSchema = z.object({
|
|
36
|
+
serverId: identity,
|
|
37
|
+
expectedRevision: z.string(),
|
|
38
|
+
enabled: z.boolean().optional()
|
|
39
|
+
}).strict();
|
|
40
|
+
function configuredServer(config, id) {
|
|
41
|
+
const servers = config.mcp?.servers;
|
|
42
|
+
return servers && Object.hasOwn(servers, id) ? servers[id] : void 0;
|
|
43
|
+
}
|
|
44
|
+
/** Coordinates HTTP MCP setup; pi remains the sole MCP and OAuth implementation. */
|
|
45
|
+
var McpConversationSetup = class {
|
|
46
|
+
goals = new DurableState("mcp.conversation-setup");
|
|
47
|
+
drafts;
|
|
48
|
+
draftIds = /* @__PURE__ */ new Map();
|
|
49
|
+
busy = /* @__PURE__ */ new Set();
|
|
50
|
+
authorizations = /* @__PURE__ */ new Set();
|
|
51
|
+
disposed = false;
|
|
52
|
+
constructor(options) {
|
|
53
|
+
this.options = options;
|
|
54
|
+
this.drafts = new McpConnectionDrafts({
|
|
55
|
+
readConfig: options.readConfig,
|
|
56
|
+
saveConfig: options.saveConfig
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
notify(goal) {
|
|
60
|
+
try {
|
|
61
|
+
this.options.changed?.(goal.conversationId);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
log.warn({
|
|
64
|
+
err,
|
|
65
|
+
conversationId: goal.conversationId
|
|
66
|
+
}, "MCP setup state saved; notification failed");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
save(goal) {
|
|
70
|
+
goal.version++;
|
|
71
|
+
this.goals.set(goal.id, goal);
|
|
72
|
+
this.notify(goal);
|
|
73
|
+
}
|
|
74
|
+
current(goal) {
|
|
75
|
+
if (this.disposed) throw new McpDraftError(409, "Gateway is stopping. Recheck after restart.");
|
|
76
|
+
const stored = this.goals.get(goal.id);
|
|
77
|
+
const session = getSessionMetadata(goal.conversationId);
|
|
78
|
+
const channel = goal.channel ? weixinSetupScope(goal.conversationId, this.options.readConfig()) : void 0;
|
|
79
|
+
if (goal.channel && JSON.stringify(channel) !== JSON.stringify(goal.channel)) {
|
|
80
|
+
if (stored && stored.phase !== "cancelled") this.cancelGoal(stored);
|
|
81
|
+
throw new McpDraftError(409, "The Weixin identity, pairing or secure Gateway origin changed. Start a new request.");
|
|
82
|
+
}
|
|
83
|
+
if (!stored || stored.version !== goal.version || stored.phase === "cancelled" || session?.transcriptId !== goal.transcriptId || session.agentId !== goal.agentId) throw new McpDraftError(409, "The setup objective changed or was cancelled. Inspect the current conversation before continuing.");
|
|
84
|
+
}
|
|
85
|
+
get(id, conversationId) {
|
|
86
|
+
const goal = this.goals.get(id);
|
|
87
|
+
if (!goal || conversationId && goal.conversationId !== conversationId) throw new McpDraftError(404, "MCP setup not found.");
|
|
88
|
+
return goal;
|
|
89
|
+
}
|
|
90
|
+
view(goal) {
|
|
91
|
+
const expired = goal.expiresAt < Date.now() && goal.phase !== "ready";
|
|
92
|
+
return {
|
|
93
|
+
setupId: goal.id,
|
|
94
|
+
serverId: goal.serverId,
|
|
95
|
+
displayName: goal.displayName,
|
|
96
|
+
version: goal.version,
|
|
97
|
+
phase: goal.phase,
|
|
98
|
+
expired,
|
|
99
|
+
reloadRequired: goal.reloadRequired === true,
|
|
100
|
+
errorCode: goal.errorCode,
|
|
101
|
+
conversationId: goal.conversationId,
|
|
102
|
+
expiresAt: goal.expiresAt,
|
|
103
|
+
interactionPath: goal.channel ? `${goal.channel.origin}/#/mcp-setup/${goal.id}` : `/mcp-setup/${goal.id}`,
|
|
104
|
+
returnChannel: goal.channel ? "weixin" : void 0,
|
|
105
|
+
managementPath: goal.channel ? `${goal.channel.origin}/#/capabilities/connectors?tab=connected` : "/capabilities/connectors?tab=connected",
|
|
106
|
+
continuationQueued: goal.resumed === true,
|
|
107
|
+
replyDelivery: goal.reply?.status,
|
|
108
|
+
instruction: goal.phase === "cancelled" ? "This setup is cancelled. Do not continue or revive it. Cancellation does not undo configuration already saved." : expired ? "This request expired. Start a new objective instead of reusing authorization." : goal.phase === "approval_required" ? "Send the exact trusted interactionPath to the user. The paired Weixin user has requested this service; an authenticated Gateway owner must approve this exact request on that page before any probe, credential submission or configuration change. Never ask for keys, callback URLs or a continue reply in chat. The result returns to this original Weixin conversation automatically." : goal.phase === "blocked" ? "The connection check failed. Report the safe error code and the remaining blocker. Do not repeatedly retry without resolving the cause." : goal.reloadRequired ? "Configuration is saved but runtime reload failed. Report the partial result and require a Gateway restart; do not claim the tools are active or tested." : goal.phase === "ready" ? "Configuration is saved. The host continues the original objective in a fresh turn so native MCP tools can load. Stop this turn; do not repeat installation or invent a successful read." : goal.phase === "planned" ? "Continue automatic steps with advance and the returned version." : "Link the trusted interactionPath for authorization or Token input, then stop this turn. The host resumes automatically; never ask for credentials, callback URLs or a continue reply in chat."
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
cancelGoal(goal) {
|
|
112
|
+
goal.phase = "cancelled";
|
|
113
|
+
this.save(goal);
|
|
114
|
+
const draftId = this.draftIds.get(goal.id);
|
|
115
|
+
if (draftId) try {
|
|
116
|
+
this.drafts.remove("local-owner", draftId);
|
|
117
|
+
} catch {}
|
|
118
|
+
this.draftIds.delete(goal.id);
|
|
119
|
+
return this.view(goal);
|
|
120
|
+
}
|
|
121
|
+
revokeWeixinRequests(accountId, peerId) {
|
|
122
|
+
for (const goal of this.goals.values()) if (goal.channel?.accountId === accountId && goal.channel.peerId.toLowerCase() === peerId.toLowerCase() && goal.phase !== "cancelled") this.cancelGoal(goal);
|
|
123
|
+
}
|
|
124
|
+
reconcileWeixinScopes() {
|
|
125
|
+
for (const goal of this.goals.values().filter((item) => item.channel && item.phase !== "cancelled")) try {
|
|
126
|
+
this.current(goal);
|
|
127
|
+
} catch {}
|
|
128
|
+
}
|
|
129
|
+
inspect() {
|
|
130
|
+
return {
|
|
131
|
+
servers: Object.entries(this.options.readConfig().mcp?.servers ?? {}).map(([serverId, server]) => ({
|
|
132
|
+
serverId,
|
|
133
|
+
displayName: server.displayName,
|
|
134
|
+
enabled: server.enabled !== false,
|
|
135
|
+
transport: server.command ? "stdio" : "http",
|
|
136
|
+
managed: isManagedConnectorServer(server) || Boolean(server.xopcPlugin),
|
|
137
|
+
revision: mcpConfigRevision(server),
|
|
138
|
+
hasCredentialReference: Boolean(server.auth || server.headers || server.xopcOAuthCredentialId)
|
|
139
|
+
})),
|
|
140
|
+
managementPath: "/capabilities/connectors?tab=connected"
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
currentForConversation(conversationId) {
|
|
144
|
+
const session = getSessionMetadata(conversationId);
|
|
145
|
+
if (!session) return { setup: null };
|
|
146
|
+
const goal = this.goals.values(void 0, true).find((item) => item.conversationId === conversationId && item.transcriptId === session.transcriptId && item.agentId === session.agentId && item.phase !== "cancelled" && (item.phase !== "ready" || !item.resumed || item.reloadRequired));
|
|
147
|
+
return { setup: goal ? this.view(goal) : null };
|
|
148
|
+
}
|
|
149
|
+
async command(command, input, context, dryRun = false) {
|
|
150
|
+
const activeSession = getSessionMetadata(context.conversationId);
|
|
151
|
+
if (!activeSession || activeSession.agentId !== context.agentId) throw new McpDraftError(404, "Owner conversation required.");
|
|
152
|
+
const localOwner = connectorPrincipalForSession(context.conversationId).isLocalOwner;
|
|
153
|
+
const channel = context.canRequestWeixinSetup ? weixinSetupScope(context.conversationId, this.options.readConfig()) : void 0;
|
|
154
|
+
if (!localOwner && !channel) throw new McpDraftError(404, "A paired, account-isolated Weixin direct conversation and a secure Gateway public URL are required. Shared/merged routing is not eligible.");
|
|
155
|
+
if (channel && ![
|
|
156
|
+
"start",
|
|
157
|
+
"get",
|
|
158
|
+
"cancel",
|
|
159
|
+
"advance"
|
|
160
|
+
].includes(command)) throw new McpDraftError(409, "Weixin configuration requires approval for a specific new connection on the secure page.");
|
|
161
|
+
if (command === "inspect") {
|
|
162
|
+
z.object({}).strict().parse(input);
|
|
163
|
+
return this.inspect();
|
|
164
|
+
}
|
|
165
|
+
if (command === "get") {
|
|
166
|
+
const args = setupSchema.parse(input);
|
|
167
|
+
return this.view(this.get(args.setupId, context.conversationId));
|
|
168
|
+
}
|
|
169
|
+
if (!context.canConfigure && !channel) throw new McpDraftError(409, "An active owner App or local CLI turn is required for MCP configuration.");
|
|
170
|
+
if (command === "start") {
|
|
171
|
+
if (getActiveConnectionWait(context.conversationId)) throw new McpDraftError(409, "Another connection objective is waiting. Finish or cancel it before starting a separate MCP setup.");
|
|
172
|
+
const args = targetSchema.parse(input), url = new URL(args.url);
|
|
173
|
+
if ([
|
|
174
|
+
"__proto__",
|
|
175
|
+
"constructor",
|
|
176
|
+
"prototype"
|
|
177
|
+
].includes(args.serverId.toLowerCase())) throw new McpDraftError(400, "Use a non-reserved server name.");
|
|
178
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || [...url.searchParams.keys()].some((key) => /token|secret|password|api.?key|authorization/i.test(key))) throw new McpDraftError(400, "Use an HTTP MCP address without embedded credentials. Enter secrets only in the secure page.");
|
|
179
|
+
const session = getSessionMetadata(context.conversationId);
|
|
180
|
+
if (!session?.transcriptId || session.agentId !== context.agentId) throw new McpDraftError(409, "Conversation identity changed.");
|
|
181
|
+
if (channel) {
|
|
182
|
+
if (args.expectedRevision !== void 0) throw new McpDraftError(409, "Existing connection changes require owner management.");
|
|
183
|
+
args.displayName ??= args.serverId;
|
|
184
|
+
args.serverId = `weixin-${createHash("sha256").update(`${channel.principalId}\0${url.href}`).digest("hex").slice(0, 16)}`;
|
|
185
|
+
}
|
|
186
|
+
const server = configuredServer(this.options.readConfig(), args.serverId);
|
|
187
|
+
if (channel && server?.enabled !== false && server?.url === url.href && !isManagedConnectorServer(server) && !server.xopcPlugin) return {
|
|
188
|
+
alreadyConfigured: true,
|
|
189
|
+
serverId: args.serverId,
|
|
190
|
+
displayName: server.displayName,
|
|
191
|
+
instruction: "This exact service is already saved. Discover its actual native tools and complete the current read without another configuration. Runtime readiness and the business result still need an actual tool call."
|
|
192
|
+
};
|
|
193
|
+
if (channel && server) throw new McpDraftError(409, "Replacing an existing connection requires its owner management page.");
|
|
194
|
+
if (server && args.expectedRevision !== mcpConfigRevision(server)) throw new McpDraftError(409, "Read inspect and provide the current server revision before replacing it.");
|
|
195
|
+
if (server && (isManagedConnectorServer(server) || server.xopcPlugin)) throw new McpDraftError(409, "Manage this service through its owning connector or plugin.");
|
|
196
|
+
if (dryRun) return {
|
|
197
|
+
dryRun: true,
|
|
198
|
+
serverId: args.serverId,
|
|
199
|
+
authentication: "probe_required"
|
|
200
|
+
};
|
|
201
|
+
const existing = this.goals.values().find((goal) => goal.conversationId === context.conversationId && goal.transcriptId === session.transcriptId && goal.serverId === args.serverId && goal.url === url.href && goal.purpose === args.purpose && goal.displayName === args.displayName && goal.phase !== "cancelled" && goal.phase !== "ready" && goal.expiresAt > Date.now());
|
|
202
|
+
if (existing) return this.view(existing);
|
|
203
|
+
for (const previous of this.goals.values().filter((item) => item.conversationId === context.conversationId && (item.phase !== "ready" || !item.resumed) && item.phase !== "cancelled")) {
|
|
204
|
+
previous.phase = "cancelled";
|
|
205
|
+
this.save(previous);
|
|
206
|
+
}
|
|
207
|
+
const goal = {
|
|
208
|
+
id: randomUUID(),
|
|
209
|
+
conversationId: context.conversationId,
|
|
210
|
+
transcriptId: session.transcriptId,
|
|
211
|
+
agentId: context.agentId,
|
|
212
|
+
serverId: args.serverId,
|
|
213
|
+
displayName: args.displayName,
|
|
214
|
+
url: url.href,
|
|
215
|
+
purpose: args.purpose,
|
|
216
|
+
expectedRevision: mcpConfigRevision(server),
|
|
217
|
+
version: 1,
|
|
218
|
+
phase: channel ? "approval_required" : "planned",
|
|
219
|
+
...channel ? { channel } : {},
|
|
220
|
+
expiresAt: Date.now() + 15 * 6e4
|
|
221
|
+
};
|
|
222
|
+
this.goals.set(goal.id, goal);
|
|
223
|
+
this.notify(goal);
|
|
224
|
+
return this.view(goal);
|
|
225
|
+
}
|
|
226
|
+
if (command === "remove" || command === "set_enabled") {
|
|
227
|
+
const args = serverSchema.parse(input);
|
|
228
|
+
if (command === "set_enabled" && args.enabled === void 0) throw new McpDraftError(400, "enabled is required.");
|
|
229
|
+
if (dryRun) return {
|
|
230
|
+
dryRun: true,
|
|
231
|
+
serverId: args.serverId
|
|
232
|
+
};
|
|
233
|
+
return this.options.withConfigLock(async () => {
|
|
234
|
+
const config = this.options.readConfig(), server = configuredServer(config, args.serverId);
|
|
235
|
+
if (!server || isManagedConnectorServer(server) || server.xopcPlugin || mcpConfigRevision(server) !== args.expectedRevision) throw new McpDraftError(409, "The custom server changed or belongs to another owner. Inspect again.");
|
|
236
|
+
for (const goal of this.goals.values().filter((item) => item.serverId === args.serverId && item.phase !== "ready" && item.phase !== "cancelled")) {
|
|
237
|
+
goal.phase = "cancelled";
|
|
238
|
+
this.save(goal);
|
|
239
|
+
}
|
|
240
|
+
const next = structuredClone(config);
|
|
241
|
+
if (command === "remove") delete next.mcp.servers[args.serverId];
|
|
242
|
+
else next.mcp.servers[args.serverId].enabled = args.enabled;
|
|
243
|
+
const result = await this.options.saveConfig(next, structuredClone(config));
|
|
244
|
+
if (result.conflict || !result.saved && !result.persisted) throw new McpDraftError(409, "Configuration could not be applied. Inspect before retrying.");
|
|
245
|
+
return {
|
|
246
|
+
saved: true,
|
|
247
|
+
removed: command === "remove",
|
|
248
|
+
enabled: command === "set_enabled" ? args.enabled : void 0,
|
|
249
|
+
reloadRequired: !result.saved,
|
|
250
|
+
remoteAuthorizationRevoked: false,
|
|
251
|
+
instruction: "This changes local configuration only. Remote authorization and installed packages are not removed."
|
|
252
|
+
};
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const args = setupSchema.parse(input), goal = this.get(args.setupId, context.conversationId);
|
|
256
|
+
if (!["advance", "cancel"].includes(command)) throw new McpDraftError(400, "Supported MCP setup commands: inspect, start, get, advance, cancel, set_enabled, remove.");
|
|
257
|
+
if (args.expectedVersion !== goal.version) throw new McpDraftError(409, "Setup changed. Read get before retrying.");
|
|
258
|
+
if (dryRun) return {
|
|
259
|
+
dryRun: true,
|
|
260
|
+
...this.view(goal)
|
|
261
|
+
};
|
|
262
|
+
if (command === "cancel") return this.cancelGoal(goal);
|
|
263
|
+
return this.advance(goal);
|
|
264
|
+
}
|
|
265
|
+
async advance(goal) {
|
|
266
|
+
this.current(goal);
|
|
267
|
+
if (goal.phase === "approval_required") return this.view(goal);
|
|
268
|
+
if (goal.channel && !goal.approvedBy) throw new McpDraftError(409, "Owner approval is required.");
|
|
269
|
+
if (goal.phase === "ready") {
|
|
270
|
+
await this.resume(goal);
|
|
271
|
+
return this.view(goal);
|
|
272
|
+
}
|
|
273
|
+
if (goal.expiresAt < Date.now()) throw new McpDraftError(409, "Setup expired. Start a new goal; do not reuse an old authorization.");
|
|
274
|
+
if (this.busy.has(goal.id)) return {
|
|
275
|
+
...this.view(goal),
|
|
276
|
+
inProgress: true
|
|
277
|
+
};
|
|
278
|
+
this.busy.add(goal.id);
|
|
279
|
+
try {
|
|
280
|
+
const published = configuredServer(this.options.readConfig(), goal.serverId);
|
|
281
|
+
if (published?.xopcSetupId === goal.id) {
|
|
282
|
+
goal.phase = "ready";
|
|
283
|
+
goal.committedRevision = mcpConfigRevision(published);
|
|
284
|
+
this.save(goal);
|
|
285
|
+
await this.resume(goal);
|
|
286
|
+
return this.view(goal);
|
|
287
|
+
}
|
|
288
|
+
if (mcpConfigRevision(published) !== goal.expectedRevision) throw new McpDraftError(409, "Server changed. Start again from the current configuration.");
|
|
289
|
+
let draftId = this.draftIds.get(goal.id);
|
|
290
|
+
if (!draftId) {
|
|
291
|
+
const draft = await this.drafts.create("local-owner", {
|
|
292
|
+
serverId: goal.serverId,
|
|
293
|
+
...published ? {
|
|
294
|
+
sourceServerId: goal.serverId,
|
|
295
|
+
expectedServer: published
|
|
296
|
+
} : {},
|
|
297
|
+
server: {
|
|
298
|
+
url: goal.url,
|
|
299
|
+
displayName: goal.displayName,
|
|
300
|
+
type: "streamable-http",
|
|
301
|
+
enabled: true,
|
|
302
|
+
xopcSetupId: goal.id,
|
|
303
|
+
...goal.tokenProvider ? { headers: { Authorization: { xopcSecretRef: {
|
|
304
|
+
provider: goal.tokenProvider,
|
|
305
|
+
fieldKey: "token",
|
|
306
|
+
prefix: "Bearer "
|
|
307
|
+
} } } } : {}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
this.current(goal);
|
|
311
|
+
draftId = draft.id;
|
|
312
|
+
this.draftIds.set(goal.id, draftId);
|
|
313
|
+
if (goal.phase === "authorizing") {
|
|
314
|
+
goal.phase = "planned";
|
|
315
|
+
this.save(goal);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (goal.phase === "authorizing") {
|
|
319
|
+
const auth = this.drafts.authorization("local-owner", draftId);
|
|
320
|
+
if (auth.state === "error" || auth.state === "cancelled") {
|
|
321
|
+
goal.phase = "blocked";
|
|
322
|
+
goal.errorCode = "authorization_failed";
|
|
323
|
+
this.save(goal);
|
|
324
|
+
return this.view(goal);
|
|
325
|
+
}
|
|
326
|
+
if (auth.state !== "connected") return this.view(goal);
|
|
327
|
+
} else {
|
|
328
|
+
const probe = await this.drafts.probe("local-owner", draftId);
|
|
329
|
+
this.current(goal);
|
|
330
|
+
if (probe.state !== "connected") {
|
|
331
|
+
goal.phase = probe.state === "error" ? "blocked" : probe.state;
|
|
332
|
+
goal.errorCode = probe.state === "token_required" && goal.tokenProvider ? "credential_rejected" : probe.errorCode;
|
|
333
|
+
this.save(goal);
|
|
334
|
+
return this.view(goal);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const result = await this.options.withConfigLock(async () => {
|
|
338
|
+
this.current(goal);
|
|
339
|
+
return this.drafts.commit("local-owner", draftId, true);
|
|
340
|
+
});
|
|
341
|
+
goal.phase = "ready";
|
|
342
|
+
goal.errorCode = void 0;
|
|
343
|
+
goal.reloadRequired = result.reloadRequired === true;
|
|
344
|
+
goal.committedRevision = mcpConfigRevision(configuredServer(this.options.readConfig(), goal.serverId));
|
|
345
|
+
this.current(goal);
|
|
346
|
+
this.save(goal);
|
|
347
|
+
this.draftIds.delete(goal.id);
|
|
348
|
+
await this.resume(goal);
|
|
349
|
+
return this.view(goal);
|
|
350
|
+
} catch (error) {
|
|
351
|
+
this.current(goal);
|
|
352
|
+
if (error instanceof McpDraftError) {
|
|
353
|
+
if (error.status === 404) {
|
|
354
|
+
this.draftIds.delete(goal.id);
|
|
355
|
+
goal.phase = "planned";
|
|
356
|
+
this.save(goal);
|
|
357
|
+
return {
|
|
358
|
+
...this.view(goal),
|
|
359
|
+
requiresRecheck: true
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
throw error;
|
|
363
|
+
}
|
|
364
|
+
goal.phase = "blocked";
|
|
365
|
+
goal.errorCode = classifyMcpConnectionError(error);
|
|
366
|
+
this.save(goal);
|
|
367
|
+
return this.view(goal);
|
|
368
|
+
} finally {
|
|
369
|
+
this.busy.delete(goal.id);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/** Owner-only UI; secret values and OAuth URLs never pass through the model API. */
|
|
373
|
+
async interact(id, action, value, expectedVersion, ownerPrincipalId = "local-owner") {
|
|
374
|
+
const goal = this.get(id);
|
|
375
|
+
if (!goal.channel && !connectorPrincipalForSession(goal.conversationId).isLocalOwner) throw new McpDraftError(404, "Owner conversation required.");
|
|
376
|
+
if (action === "get") {
|
|
377
|
+
let authorizationUrl, authState;
|
|
378
|
+
const session = getSessionMetadata(goal.conversationId);
|
|
379
|
+
try {
|
|
380
|
+
this.current(goal);
|
|
381
|
+
} catch {
|
|
382
|
+
return {
|
|
383
|
+
...this.view(goal),
|
|
384
|
+
phase: "cancelled",
|
|
385
|
+
endpointOrigin: new URL(goal.url).origin
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
if (session?.transcriptId !== goal.transcriptId || session.agentId !== goal.agentId) return {
|
|
389
|
+
...this.view(goal),
|
|
390
|
+
phase: "cancelled",
|
|
391
|
+
endpointOrigin: new URL(goal.url).origin
|
|
392
|
+
};
|
|
393
|
+
const draftId = this.draftIds.get(id);
|
|
394
|
+
if (draftId && goal.phase === "authorizing" && goal.expiresAt > Date.now()) {
|
|
395
|
+
const auth = this.drafts.authorization("local-owner", draftId);
|
|
396
|
+
authorizationUrl = auth.authorizationUrl;
|
|
397
|
+
authState = auth.state;
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
...this.view(goal),
|
|
401
|
+
endpointOrigin: new URL(goal.url).origin,
|
|
402
|
+
approval: goal.channel ? {
|
|
403
|
+
...goal.channel,
|
|
404
|
+
endpoint: goal.url,
|
|
405
|
+
purpose: goal.purpose
|
|
406
|
+
} : void 0,
|
|
407
|
+
canReplaceToken: Boolean(goal.tokenProvider),
|
|
408
|
+
authorizationUrl,
|
|
409
|
+
authState,
|
|
410
|
+
requiresRecheck: !draftId && goal.phase !== "ready" && goal.phase !== "cancelled"
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
this.current(goal);
|
|
414
|
+
if (action === "retry_delivery" && goal.channel && goal.phase === "ready" && goal.reply?.status === "delivered") return this.view(goal);
|
|
415
|
+
if (expectedVersion !== goal.version) throw new McpDraftError(409, "The secure form changed. Refresh before submitting.");
|
|
416
|
+
if (action === "cancel") return this.cancelGoal(goal);
|
|
417
|
+
if (action === "retry_delivery") {
|
|
418
|
+
if (!goal.channel || goal.phase !== "ready" || goal.reply?.status !== "failed" || goal.expiresAt < Date.now()) throw new McpDraftError(409, "This result cannot be resent.");
|
|
419
|
+
await this.deliverReply(goal);
|
|
420
|
+
return this.view(this.get(id));
|
|
421
|
+
}
|
|
422
|
+
if (goal.expiresAt < Date.now() || goal.phase === "ready") throw new McpDraftError(409, "This setup no longer accepts input.");
|
|
423
|
+
if (action === "approve") {
|
|
424
|
+
if (!goal.channel || goal.phase !== "approval_required" || !ownerPrincipalId) throw new McpDraftError(409, "This request cannot be approved.");
|
|
425
|
+
goal.approvedBy = ownerPrincipalId;
|
|
426
|
+
goal.phase = "planned";
|
|
427
|
+
this.save(goal);
|
|
428
|
+
return this.advance(goal);
|
|
429
|
+
}
|
|
430
|
+
if (goal.phase === "approval_required") throw new McpDraftError(409, "Approve the exact Weixin request before continuing.");
|
|
431
|
+
if (action === "token") {
|
|
432
|
+
if (!(goal.phase === "token_required" || goal.phase === "blocked" && goal.tokenProvider) || !value?.trim() || value.length > 16384) throw new McpDraftError(400, "A token is required for this setup.");
|
|
433
|
+
if (this.busy.has(id)) throw new McpDraftError(409, "A check is in progress.");
|
|
434
|
+
const url = new URL(goal.url);
|
|
435
|
+
if (url.protocol !== "https:" && ![
|
|
436
|
+
"127.0.0.1",
|
|
437
|
+
"localhost",
|
|
438
|
+
"[::1]"
|
|
439
|
+
].includes(url.hostname)) throw new McpDraftError(400, "Token authentication requires HTTPS or a loopback server.");
|
|
440
|
+
this.busy.add(id);
|
|
441
|
+
this.save(goal);
|
|
442
|
+
const provider = connectorSecretProviderId(`mcp-setup-${id}-${goal.version}`, "token");
|
|
443
|
+
const credentials = new CredentialResolver();
|
|
444
|
+
try {
|
|
445
|
+
await credentials.saveApiKey(provider, value.trim());
|
|
446
|
+
this.current(goal);
|
|
447
|
+
const old = this.draftIds.get(id);
|
|
448
|
+
if (old) try {
|
|
449
|
+
this.drafts.remove("local-owner", old);
|
|
450
|
+
} catch (error) {
|
|
451
|
+
if (!(error instanceof McpDraftError) || error.status !== 404) throw error;
|
|
452
|
+
}
|
|
453
|
+
this.draftIds.delete(id);
|
|
454
|
+
goal.tokenProvider = provider;
|
|
455
|
+
goal.phase = "planned";
|
|
456
|
+
goal.errorCode = void 0;
|
|
457
|
+
this.save(goal);
|
|
458
|
+
} catch (error) {
|
|
459
|
+
await credentials.deleteProfile(`${provider}:default`);
|
|
460
|
+
throw error;
|
|
461
|
+
} finally {
|
|
462
|
+
this.busy.delete(id);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (action === "authorize") {
|
|
466
|
+
if (goal.phase !== "oauth_required") throw new McpDraftError(409, "Recheck the server before authorization.");
|
|
467
|
+
const draftId = this.draftIds.get(id);
|
|
468
|
+
if (!draftId) {
|
|
469
|
+
goal.phase = "planned";
|
|
470
|
+
this.save(goal);
|
|
471
|
+
return this.advance(goal);
|
|
472
|
+
}
|
|
473
|
+
this.drafts.authorize("local-owner", draftId, goal.channel ? { callbackRelayUrl: `${goal.channel.origin}/mcp-setup/callback/${goal.id}` } : void 0);
|
|
474
|
+
goal.phase = "authorizing";
|
|
475
|
+
this.save(goal);
|
|
476
|
+
this.settleAuthorization(goal.id);
|
|
477
|
+
return this.view(goal);
|
|
478
|
+
}
|
|
479
|
+
return this.advance(goal);
|
|
480
|
+
}
|
|
481
|
+
settleAuthorization(id) {
|
|
482
|
+
if (this.authorizations.has(id)) return;
|
|
483
|
+
this.authorizations.add(id);
|
|
484
|
+
(async () => {
|
|
485
|
+
for (;;) {
|
|
486
|
+
await setTimeout(250, void 0, { ref: false });
|
|
487
|
+
if (this.disposed) return;
|
|
488
|
+
const goal = this.goals.get(id);
|
|
489
|
+
if (!goal || goal.phase !== "authorizing" || goal.expiresAt < Date.now()) return;
|
|
490
|
+
this.current(goal);
|
|
491
|
+
const draftId = this.draftIds.get(id);
|
|
492
|
+
if (!draftId) return;
|
|
493
|
+
const auth = this.drafts.authorization("local-owner", draftId);
|
|
494
|
+
if (auth.state === "connected") await this.advance(goal);
|
|
495
|
+
else if (auth.state === "error" || auth.state === "cancelled") {
|
|
496
|
+
goal.phase = "blocked";
|
|
497
|
+
goal.errorCode = "authorization_failed";
|
|
498
|
+
this.save(goal);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
})().catch((error) => {
|
|
503
|
+
try {
|
|
504
|
+
if (this.disposed) return;
|
|
505
|
+
const goal = this.goals.get(id);
|
|
506
|
+
if (!goal || goal.phase !== "authorizing") return;
|
|
507
|
+
this.current(goal);
|
|
508
|
+
goal.phase = "blocked";
|
|
509
|
+
goal.errorCode = error instanceof McpDraftError ? "configuration_changed" : classifyMcpConnectionError(error);
|
|
510
|
+
this.save(goal);
|
|
511
|
+
} catch {}
|
|
512
|
+
}).finally(() => this.authorizations.delete(id));
|
|
513
|
+
}
|
|
514
|
+
dispose() {
|
|
515
|
+
this.disposed = true;
|
|
516
|
+
for (const draftId of this.draftIds.values()) try {
|
|
517
|
+
this.drafts.remove("local-owner", draftId);
|
|
518
|
+
} catch {}
|
|
519
|
+
this.draftIds.clear();
|
|
520
|
+
}
|
|
521
|
+
relayCallback(id, callbackUrl) {
|
|
522
|
+
const goal = this.get(id);
|
|
523
|
+
this.current(goal);
|
|
524
|
+
if (!goal.channel || !goal.approvedBy || goal.phase !== "authorizing" || goal.expiresAt < Date.now()) throw new McpDraftError(409, "Authorization is no longer active.");
|
|
525
|
+
const draftId = this.draftIds.get(id);
|
|
526
|
+
if (!draftId) throw new McpDraftError(409, "Sign in again after the Gateway restart.");
|
|
527
|
+
const auth = this.drafts.authorization("local-owner", draftId);
|
|
528
|
+
if (goal.callbackConsumedForAttempt === auth.id) throw new McpDraftError(409, "Authorization response already received.");
|
|
529
|
+
const actual = new URL(callbackUrl);
|
|
530
|
+
if (actual.origin !== goal.channel.origin || actual.pathname !== `/mcp-setup/callback/${id}`) throw new McpDraftError(400, "Invalid authorization callback.");
|
|
531
|
+
this.drafts.redirect("local-owner", draftId, actual.href);
|
|
532
|
+
goal.callbackConsumedForAttempt = auth.id;
|
|
533
|
+
this.save(goal);
|
|
534
|
+
return `/#/mcp-setup/${goal.id}`;
|
|
535
|
+
}
|
|
536
|
+
async completeContinuation(input, text) {
|
|
537
|
+
if (!input.runId || !this.permitsContinuation(input)) return;
|
|
538
|
+
const goal = this.get(input.clientMessageId.slice(10));
|
|
539
|
+
if (!goal.channel || goal.reply || !text.trim()) return;
|
|
540
|
+
goal.reply = {
|
|
541
|
+
runId: input.runId,
|
|
542
|
+
text,
|
|
543
|
+
status: "pending"
|
|
544
|
+
};
|
|
545
|
+
this.save(goal);
|
|
546
|
+
await this.deliverReply(goal);
|
|
547
|
+
}
|
|
548
|
+
async deliverReply(goal) {
|
|
549
|
+
if (!goal.channel || !goal.reply || goal.reply.status === "delivered" || !this.options.deliver || this.busy.has(`reply:${goal.id}`)) return;
|
|
550
|
+
this.current(goal);
|
|
551
|
+
if (goal.phase !== "ready" || goal.expiresAt < Date.now()) return;
|
|
552
|
+
this.busy.add(`reply:${goal.id}`);
|
|
553
|
+
try {
|
|
554
|
+
await this.options.deliver(goal.channel, goal.reply.text, goal.id);
|
|
555
|
+
const latest = this.get(goal.id);
|
|
556
|
+
this.current(latest);
|
|
557
|
+
if (latest.reply?.runId === goal.reply.runId) {
|
|
558
|
+
latest.reply.status = "delivered";
|
|
559
|
+
this.save(latest);
|
|
560
|
+
}
|
|
561
|
+
} catch {
|
|
562
|
+
const latest = this.get(goal.id);
|
|
563
|
+
if (latest.reply?.runId === goal.reply.runId && latest.phase === "ready") {
|
|
564
|
+
latest.reply.status = "failed";
|
|
565
|
+
this.save(latest);
|
|
566
|
+
}
|
|
567
|
+
} finally {
|
|
568
|
+
this.busy.delete(`reply:${goal.id}`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
async resume(goal) {
|
|
572
|
+
this.current(goal);
|
|
573
|
+
if (!goal.resumed && goal.expiresAt < Date.now()) {
|
|
574
|
+
goal.phase = "blocked";
|
|
575
|
+
goal.errorCode = "scope_expired";
|
|
576
|
+
this.save(goal);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (goal.resumed || goal.reloadRequired || mcpConfigRevision(configuredServer(this.options.readConfig(), goal.serverId)) !== goal.committedRevision) return;
|
|
580
|
+
const queued = await this.options.resume(goal);
|
|
581
|
+
const latest = this.goals.get(goal.id);
|
|
582
|
+
if (latest && latest.committedRevision === goal.committedRevision && latest.phase === "ready") {
|
|
583
|
+
this.current(latest);
|
|
584
|
+
Object.assign(goal, latest);
|
|
585
|
+
if (latest.resumed) return;
|
|
586
|
+
}
|
|
587
|
+
this.current(goal);
|
|
588
|
+
if (queued) {
|
|
589
|
+
goal.resumed = true;
|
|
590
|
+
this.save(goal);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
permitsContinuation(input) {
|
|
594
|
+
if (!input.clientMessageId.startsWith("mcp-setup:")) return true;
|
|
595
|
+
const goal = this.goals.get(input.clientMessageId.slice(10));
|
|
596
|
+
if (!goal || goal.phase !== "ready" || goal.reloadRequired || goal.expiresAt < Date.now() || goal.conversationId !== input.conversationId || goal.transcriptId !== input.expectedTranscriptId || input.origin.type !== "system" || input.origin.source !== "internal") return false;
|
|
597
|
+
try {
|
|
598
|
+
this.current(goal);
|
|
599
|
+
return mcpConfigRevision(configuredServer(this.options.readConfig(), goal.serverId)) === goal.committedRevision;
|
|
600
|
+
} catch {
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
async resumePending(runtimeReloaded = false) {
|
|
605
|
+
for (const goal of this.goals.values().filter((item) => item.phase === "ready" && item.reply && item.reply.status !== "delivered")) try {
|
|
606
|
+
await this.deliverReply(goal);
|
|
607
|
+
} catch {}
|
|
608
|
+
for (const goal of this.goals.values().filter((item) => item.phase === "ready" && !item.resumed)) {
|
|
609
|
+
if (goal.reloadRequired && runtimeReloaded && mcpConfigRevision(configuredServer(this.options.readConfig(), goal.serverId)) === goal.committedRevision) {
|
|
610
|
+
goal.reloadRequired = false;
|
|
611
|
+
this.save(goal);
|
|
612
|
+
}
|
|
613
|
+
if (goal.reloadRequired) continue;
|
|
614
|
+
try {
|
|
615
|
+
await this.resume(goal);
|
|
616
|
+
} catch {}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
//#endregion
|
|
621
|
+
export { McpConversationSetup };
|
|
@@ -6,6 +6,7 @@ export declare function getNativePiAgentDir(): string;
|
|
|
6
6
|
export type NativeMcpConfig = LoadedMcpConfig & {
|
|
7
7
|
credentials?: NativeMcpCredentials;
|
|
8
8
|
credentialAliases?: Record<string, string>;
|
|
9
|
+
automationSourceRunId?: string;
|
|
9
10
|
};
|
|
10
11
|
/** Only projects host configuration and secret references; all MCP execution belongs to pi. */
|
|
11
12
|
export declare function prepareNativeMcpConfig(config: Config, workspaceDir: string, agentId?: string): Promise<NativeMcpConfig>;
|
|
@@ -5,6 +5,10 @@ export type McpCatalogTool = {
|
|
|
5
5
|
description: string;
|
|
6
6
|
inputSchema: unknown;
|
|
7
7
|
exposure?: string;
|
|
8
|
+
annotations?: {
|
|
9
|
+
readOnlyHint?: boolean;
|
|
10
|
+
destructiveHint?: boolean;
|
|
11
|
+
};
|
|
8
12
|
};
|
|
9
13
|
export declare class McpAuthenticationRequiredError extends Error {
|
|
10
14
|
}
|
|
@@ -16,6 +20,7 @@ export type McpLoginInteraction = {
|
|
|
16
20
|
export type McpSessionOptions = {
|
|
17
21
|
credentials?: NativeMcpCredentials;
|
|
18
22
|
signal?: AbortSignal;
|
|
23
|
+
callbackRelayUrl?: string;
|
|
19
24
|
};
|
|
20
25
|
/** A short-lived native session discovers tools without making a model request. */
|
|
21
26
|
export declare function discoverMcpTools(config: Config, workspaceDir: string, serverId: string, options?: McpSessionOptions): Promise<McpCatalogTool[]>;
|