@xopcai/xopc 0.0.444 → 0.0.446
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/dist/assets/{auth-DAIwDtVp.js → auth-CQmxIyWw.js} +225 -8
- package/dist/browser-ext/dist/background.js +254 -16
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +3 -49
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CuPXAoLe.js → activity-store-Ddf-02Rf.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D92uHOFV.js → agent-avatar-dicebear-Dcu4ggpV.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-DINzeGs0.js → agent-avatar-display-CarpM_qc.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-rH1QpgiR.js → agent-defaults-settings-panel-B4GynTfH.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-B2vXlrDW.js → agent-plugin-dialog-BWQ_Diyv.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-lvQfOQPN.js → agents-DKaImiga.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-DPLtjJtX.js → agents-admin-api-BwoePPTG.js} +1 -1
- package/dist/gateway/static/root/assets/{api-snfMD8_Y.js → api-Cc72Y3ct.js} +1 -1
- package/dist/gateway/static/root/assets/{api-CEzBruRJ.js → api-MJxs2HLk.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CONwDpqL.js → app-management-settings-panel-Cy6szt9g.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Bu7K-_ri.js → appearance-settings-Dy75gAe7.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-C3iDd3ZQ.js → apps-page-DlwW9ClN.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CfLz9o-2.js → archive-plugin-_5jgYMZC.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-Dl9fi8t0.js → automation-api-DrxC4rCG.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-BjjZCxee.js → automation-result-state-Ba_q8_Jj.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-run-list-9IPHu_UC.js → automation-run-list-DuyMQwtf.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-task-card-CKbHMLSy.js → automation-task-card-D4Ojt-Q4.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-K3trjTZl.js → automations-page-D-Sl7Dhr.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-D7m3w_9B.js → automations-workspace-ND9J7xtt.js} +2 -2
- package/dist/gateway/static/root/assets/{binary-plugins-Bv4ixxo4.js → binary-plugins-BYHCUreq.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CtaJSB9U.js → block-editor-DI_JHx-P.js} +3 -2
- package/dist/gateway/static/root/assets/{browser-settings-page-CmBsnx24.js → browser-settings-page-DXBM5lpK.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-DDJJhQ40.js → capabilities-CUHCbQ5N.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-DJYgOjeq.js → capabilities-C_mZ4wUq.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-CBqvHAyp.js → capabilities-page-RJnyR_V9.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-wjezs0OE.js → capabilities-settings-panel-CxSrK6bJ.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-D4q8hiD0.js → channels-CBXmRfVR.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-BOB3dILf.js → chat-agents-api-D6sJpLeT.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-DsaCatBN.js → chat-chart-block-B2U7epTQ.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-U5hc4rIa.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-D9o0nUEV.js → chat-terminal-dock-XNPvQhNw.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-Cj0_7g9o.js → command-palette-api-DbL0oPXq.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-CoDWKzBm.js → composer-payload-handoff-CaxZicbL.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DJ9BIOHC.js → computer-settings-page-Velpw46s.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-C5-3MDIj.js → connected-providers-grid-Y79g354a.js} +1 -1
- package/dist/gateway/static/root/assets/{connection-usage-guide-bD1sKiAp.js → connection-usage-guide-BaDoesqn.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BEq3i3Vi.js → connector-service-page-C5mVM3zg.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-DEExP6a7.js → connectors-api-Cgiy3Dyn.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-QVWuoxuK.js → connectors-page-DDSTfe3M.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-D2whl8Ci.js → date-picker-BCxU-AEv.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-qnIdmNnH.js → desktop-pet-D1buh7JC.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-C54b1FY4.js → desktop-pet-settings-CVs5timB.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-bryv5YRw.js → dev-view-store-rdp0Stsh.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-Du-yOxZv.js → device-pairing-wizard-ZX1oup6S.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-GsMkjw59.js → directory-picker-path-field-BN57kiUt.js} +1 -1
- package/dist/gateway/static/root/assets/{discussion-annotation-sync-CrpDiC7J.js → discussion-annotation-sync-BG-sbtYu.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CDZfdMAR.js → extension-debug-page-DuuOhNRp.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-CG70QWPS.js → extension-iframe-host-DzzKhhvD.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-D7Av-sOf.js → extension-marketplace-api-5BBPFsmU.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DpJTL6-v.js → extension-page-DDmRVcIm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-BZTbdvCF.js → extension-provider-CFzHYMV0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CC4rmiFC.js → extension-settings-page-DGAD52bm.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-Dtla5oAW.js → file-preview-surface-DgG6OJyj.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-B5THNdYK.js → gateway-config-swr-D0yocd87.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-DpNC3Y7U.js +1 -0
- package/dist/gateway/static/root/assets/gateway-realtime-store-BQELP9Or.js +1 -0
- package/dist/gateway/static/root/assets/gateway-restart-C_8Z4DRU.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-CGlpz-Ft.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CqtCJzWJ.js → gateway-startup-retry-BPSM56sw.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-BQMdHLlp.js → global-defaults-api-BFsm77dC.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-Df3X6-Ko.js → home-page-UXS36f7M.js} +2 -2
- package/dist/gateway/static/root/assets/{image-generation-api-G3tQFhif.js → image-generation-api-wJi7zpES.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BmEqiunH.js → imports-page-iddP3PVx.js} +1 -1
- package/dist/gateway/static/root/assets/index-D0p4v0SG.js +11 -0
- package/dist/gateway/static/root/assets/index-Uxz0OdzD.css +1 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-BU4l6KJv.js → install-connector-dialog-DSIVSJRz.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CtNI6i7K.js → keyboard-shortcuts-settings-Cxdd0r3Z.js} +1 -1
- package/dist/gateway/static/root/assets/languages-kF11aUYU.js +2 -0
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CE46mHc0.js → local-app-workbench-page-jfkZZHHd.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-DqZT5hLH.js → local-apps-page-BwWuY0x2.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-Bt_e3A8f.js → local-session-drafts-cTAkoNSf.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Bld7_m-Q.js → locale-store-DJYUYPdV.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CzajqK40.js → logs-page-CuxC8O1E.js} +1 -1
- package/dist/gateway/static/root/assets/management-api-CmBUdfsn.js +1 -0
- package/dist/gateway/static/root/assets/management-settings-CYn1EOVo.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-editor-BuuGlcfG.js → markdown-editor-CjQJ-Nho.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-B3cFKCfO.js → markdown-view-DrcA6Cfr.js} +1 -1
- package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-ZcY1nqMO.js → mcp-conversation-setup-page-C5D5oueS.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DSOplRhW.js → media-plugins-CQZ0Jh_x.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-CGO1P4mz.js → messages-DziUGfxF.js} +2 -2
- package/dist/gateway/static/root/assets/{model-selector-yAKlOR3O.js → model-selector-CbKl8YPf.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-8V-ZpAIa.js → models-hub-cache-CwxnL3rY.js} +1 -1
- package/dist/gateway/static/root/assets/navigation-ByOzYT0t.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-uQO4kymH.js +7 -0
- package/dist/gateway/static/root/assets/note-image-lightbox-CaO_VuWl.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-CVQqqmGI.js → notes-api-DoCb3QlH.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-DIugUbkV.js → notes-page-DOl7cqLg.js} +2 -2
- package/dist/gateway/static/root/assets/{oauth-api-DGa6PTuq.js → oauth-api-3b_QtYeo.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-Bc-KLH1e.js → oauth-provider-connect-D1JQ4FBf.js} +1 -1
- package/dist/gateway/static/root/assets/page-context-capture-button-CVIVl1MQ.js +1 -0
- package/dist/gateway/static/root/assets/{page-context-draft-GveHK8e2.js → page-context-draft-Ky5J09qv.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-Jt0XBQxm.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-Cu8lGBXZ.js → personal-avatar-Dh4qjZYy.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-BZWJKyZ8.js → personal-page-edoGNvVa.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-awr10jTV.js → personal-settings-panel-BtTwDaw0.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-CAxn3usD.js → phone-dependencies-card-B6rA2lO_.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-BBG3LxRP.js → phone-model-connection-xqaXDOVF.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-CfPjKpnd.js → phone-model-picker-yuGXKCM9.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-C4dJdwRW.js → phone-settings-page-DhjuPpF4.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-BKltFHtG.js → phone-workspace-store-2xQhZsJr.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-BqcFfZFH.js → plugin-details-dialog-CIS3SUKM.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-QlyIA8ve.js → preference-select-fields-BAZSKhoi.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-CRsfuAXl.js → product-automation-feedback-Bh37tBpR.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CQ4dk-_l.js → product-open-page-BXcS7lCW.js} +1 -1
- package/dist/gateway/static/root/assets/product-preview-content-BNultFGN.js +1 -0
- package/dist/gateway/static/root/assets/product-preview-modal-BTlUoG48.js +2 -0
- package/dist/gateway/static/root/assets/project-detail-page-DNvQzRnU.js +7 -0
- package/dist/gateway/static/root/assets/project-overview-model-DrLXaO-t.js +1 -0
- package/dist/gateway/static/root/assets/{project-understanding-CU2af95r.js → project-understanding-CrYVzB8i.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-BsgZb6n9.js → projects-page-nEhOaONB.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-CspehmSU.js → providers-api-MimHCxo_.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-BOZAOdCI.js → recording-upload-BUe8jmx8.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-Bdp3UUyz.js → registry-api-CkrGCW-C.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-Bos3uwAT.js → remote-access-hub-QqFEiO0m.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-DJR3SCy6.js → resource-unavailable-CSc5SeHy.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-BTPpGwjV.js +2 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-DsbahxzE.js → runtime-tools-api-BzLDrYX8.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DW9_OFi2.js → runtime-tools-settings-panel-DST1lBFY.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-Bd1JDO5T.js → service-recommendation-list-DezuXPLs.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-DjnHJ-0n.js → session-api-QnBTnXGH.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-ChHnJOWW.js → session-manager-b2zxVzZI.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-BM-oqd22.js → sessions-page-uarYA2Xw.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Bq6eQ3It.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-CM44UlF8.js → settings-advanced-section-Crhl0mQp.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-Blc4C8aw.js → settings-mode-store-CrM7SFWJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-irv-JoTz.js → settings-page-BrogpvEd.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-BYFaTD8a.js → settings-page-header-DPKy790x.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CnUQSxT3.js → settings-page-layout-8kCWtU5m.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-DqaiLQ0I.js → setup-interaction-page-BVnMLwC-.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-iOYgfkoK.js → setup-status-panel--Fb7FwVG.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-C_uYNUlp.js → share-link-dialog-C45dGG9y.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CFebGqyB.js → share-preview-page-ConV6wRP.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-C2GDyqxP.js → shares-api-BsDhQwd3.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-B-7la3QN.js → shares-settings-DJz0p2PL.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-BnpTSZGc.js → skill-api-BrM5Ctxg.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-7MY9ewiu.js → skill-list-api-DWCkzC6W.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-DkDpu3Wd.js → skill-reload-api-C2jfZi01.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-sL2kGqHZ.js → skills-page-DbAc1Y4C.js} +1 -1
- package/dist/gateway/static/root/assets/{source-workspace-editor-kxosllTu.js → source-workspace-editor-BwYU5OEh.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BltKPJdb.js → system-settings-panel-BiswiIqg.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-6awKGnOr.js → task-detail-page-R0_AM-IE.js} +1 -1
- package/dist/gateway/static/root/assets/{task-result-evidence-Cy9txdqV.js → task-result-evidence-C1AEUu9S.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-DUEJoa1M.js → terminal-panel-store-qS6f2G-H.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DsvYj7Vy.js → theme-store-Docer0tD.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-B_Xdc2VF.js → tracing-settings-page-DiXHv8C3.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-B6BhWTh3.js → tunnel-api-UYBm3Hqd.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-B7rFXhDk.js → understanding-activity-store-CK6cQ0iJ.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-DCFASve5.js → understanding-refresh-store-DVNqbtHk.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DqzosTxy.js → usage-page-DmA7kQI2.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-DsqcLHV9.js → use-autosave-D1tFBLQO.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-ClakaDU1.js → use-composer-attachments-CwJslPRU.js} +1 -1
- package/dist/gateway/static/root/assets/use-file-preview-expanded-CK1OJENF.js +15 -0
- package/dist/gateway/static/root/assets/{use-personal-profile-T2e6P5Ed.js → use-personal-profile-CpsJdlEs.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-Dq0qgK3N.js → use-workspace-tree-CW9hcMwg.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-Ziz55hVM.js → user-model-page-BlYKXzCa.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-D7NPAc1E.js → voice-api-key-field-DD9V94Y7.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-UQDTh6hh.js → voice-config-api-Cr6IkfV2.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-SD2gZVg8.js → voice-input-shortcut-events-hsEdKDO6.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-transcribe-api-Bf9FaI-p.js → voice-transcribe-api-DKain9tL.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B41GOFXh.js → work-discovery-overlay-yYdAqtrO.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-NNhExALx.js → work-discovery-page-8hTykUqr.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-DeNWVFFK.js → working-directory-picker-modal-CXPSsy2J.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-DrVss2Fd.js → workspace-api-DNSoGsW8.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-ENv6zDBq.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-C2egBzza.js → workspace-file-preview-dialog-BVYsAXwp.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-XFUtwfLY.js → workspace-open-location-menu-DN7E_-eH.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BlhFT1q9.js → xopc-cloud-account-card-CGs77iKb.js} +1 -1
- package/dist/gateway/static/root/index.html +83 -82
- package/dist/package.js +1 -1
- package/dist/packages/endpoint-tools-client/src/index.js +309 -17
- package/dist/packages/endpoint-tools-protocol/src/index.js +62 -10
- package/dist/packages/endpoint-tools-protocol/src/provider-execution.js +32 -0
- package/dist/packages/endpoint-tools-protocol/src/providers.js +233 -0
- package/dist/packages/gateway-contract/src/clarifications.js +1 -1
- package/dist/packages/gateway-contract/src/device-pairing.js +2 -1
- package/dist/packages/gateway-contract/src/device-request-proof.js +32 -0
- package/dist/packages/gateway-contract/src/index.js +2 -2
- package/dist/packages/realtime-client/src/index.js +1 -0
- package/dist/packages/realtime-protocol/src/index.js +4 -1
- package/dist/src/agent/commands/command-registry.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/embedded/session-runner.js +7 -2
- package/dist/src/agent/embedded/tool-metadata.d.ts +1 -1
- package/dist/src/agent/embedded/tool-search-extension.d.ts +1 -0
- package/dist/src/agent/embedded/tool-search-extension.js +35 -2
- package/dist/src/agent/external-tools/endpoint-provider.d.ts +3 -0
- package/dist/src/agent/external-tools/endpoint-provider.js +94 -16
- package/dist/src/agent/external-tools/index.js +2 -2
- package/dist/src/agent/external-tools/personal-request-scope.js +6 -0
- package/dist/src/agent/external-tools/read-policy.js +15 -8
- package/dist/src/agent/external-tools/service.js +8 -0
- package/dist/src/agent/external-tools/types.d.ts +1 -0
- package/dist/src/agent/inbound/inbound-loop.js +2 -1
- package/dist/src/agent/mcp/continuation-guard.js +1 -1
- package/dist/src/agent/mcp/conversation-setup.js +1 -1
- package/dist/src/agent/mcp/discovery.js +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.d.ts +2 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +6 -5
- package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
- package/dist/src/agent/tool-manuals/computer.js +2 -0
- package/dist/src/agent/tools/clarify-tool.d.ts +1 -0
- package/dist/src/agent/tools/device-use-tool.d.ts +9 -0
- package/dist/src/agent/tools/device-use-tool.js +158 -0
- package/dist/src/agent/tools/factory.js +24 -3
- package/dist/src/automations/mcp-source.js +1 -1
- package/dist/src/automations/service/action-executor.js +10 -2
- package/dist/src/browser/remote/device-driver.js +7 -3
- package/dist/src/browser/remote/device-target.d.ts +1 -1
- package/dist/src/browser/remote/device-target.js +8 -6
- package/dist/src/channels/lifecycle-supervisor.js +2 -1
- package/dist/src/channels/verified-inbound.d.ts +13 -0
- package/dist/src/channels/verified-inbound.js +29 -0
- package/dist/src/cli/command-loaders.js +1 -0
- package/dist/src/cli/command-manifest.js +4 -0
- package/dist/src/cli/commands/device-host.d.ts +1 -0
- package/dist/src/cli/commands/device-host.js +52 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/cli/index.js +1 -1
- package/dist/src/computer/diagnostics.d.ts +3 -3
- package/dist/src/computer/errors.js +4 -0
- package/dist/src/computer/evaluation.d.ts +2 -2
- package/dist/src/computer/flows.js +1 -1
- package/dist/src/computer/runtime.d.ts +1 -0
- package/dist/src/computer/runtime.js +25 -3
- package/dist/src/config/schema.d.ts +2 -0
- package/dist/src/config/schema.js +1 -0
- package/dist/src/connectors/composio-triggers.js +1 -1
- package/dist/src/endpoint-tools/bridge-host.d.ts +5 -4
- package/dist/src/endpoint-tools/bridge-host.js +165 -30
- package/dist/src/endpoint-tools/bridge.d.ts +1 -1
- package/dist/src/endpoint-tools/bridge.js +39 -7
- package/dist/src/endpoint-tools/capability-catalog.d.ts +1 -1
- package/dist/src/endpoint-tools/capability-catalog.js +1 -1
- package/dist/src/endpoint-tools/delegation.d.ts +60 -0
- package/dist/src/endpoint-tools/delegation.js +130 -0
- package/dist/src/endpoint-tools/desktop-execution.js +1 -1
- package/dist/src/endpoint-tools/device-host.d.ts +98 -0
- package/dist/src/endpoint-tools/device-host.js +89 -0
- package/dist/src/endpoint-tools/execution-actor.d.ts +6 -0
- package/dist/src/endpoint-tools/execution-actor.js +53 -0
- package/dist/src/endpoint-tools/grant-service.d.ts +7 -4
- package/dist/src/endpoint-tools/grant-service.js +12 -4
- package/dist/src/endpoint-tools/host-credentials.d.ts +42 -0
- package/dist/src/endpoint-tools/host-credentials.js +144 -0
- package/dist/src/endpoint-tools/index.d.ts +1 -1
- package/dist/src/endpoint-tools/index.js +3 -3
- package/dist/src/endpoint-tools/invocation-service.d.ts +47 -4
- package/dist/src/endpoint-tools/invocation-service.js +328 -36
- package/dist/src/endpoint-tools/mcp-provider.d.ts +32 -0
- package/dist/src/endpoint-tools/mcp-provider.js +258 -0
- package/dist/src/endpoint-tools/policy.js +0 -3
- package/dist/src/endpoint-tools/provider-catalog.d.ts +45 -0
- package/dist/src/endpoint-tools/provider-catalog.js +202 -0
- package/dist/src/endpoint-tools/provider-operation-journal.d.ts +18 -0
- package/dist/src/endpoint-tools/provider-operation-journal.js +111 -0
- package/dist/src/endpoint-tools/provider-operation-status.d.ts +33 -0
- package/dist/src/endpoint-tools/provider-operation-status.js +80 -0
- package/dist/src/endpoint-tools/registry.d.ts +14 -1
- package/dist/src/endpoint-tools/registry.js +15 -1
- package/dist/src/endpoint-tools/result-projector.d.ts +1 -2
- package/dist/src/endpoint-tools/result-projector.js +3 -11
- package/dist/src/endpoint-tools/runtime.d.ts +10 -2
- package/dist/src/endpoint-tools/runtime.js +102 -11
- package/dist/src/endpoint-tools/target-resolver.d.ts +8 -3
- package/dist/src/endpoint-tools/target-resolver.js +24 -5
- package/dist/src/endpoint-tools/task-targets.d.ts +38 -0
- package/dist/src/endpoint-tools/task-targets.js +95 -0
- package/dist/src/endpoint-tools/upload-service.d.ts +34 -1
- package/dist/src/endpoint-tools/upload-service.js +88 -2
- package/dist/src/gateway/hono/routes/agent-stream.js +12 -1
- package/dist/src/gateway/hono/routes/device-authorizations.js +4 -10
- package/dist/src/gateway/hono/routes/device-hosts.d.ts +3 -0
- package/dist/src/gateway/hono/routes/device-hosts.js +82 -0
- package/dist/src/gateway/hono/routes/device-providers.d.ts +3 -0
- package/dist/src/gateway/hono/routes/device-providers.js +297 -0
- package/dist/src/gateway/hono/routes/device-targets.d.ts +3 -0
- package/dist/src/gateway/hono/routes/device-targets.js +117 -0
- package/dist/src/gateway/hono/routes/endpoint-compatibility.js +2 -1
- package/dist/src/gateway/hono/routes/endpoint-tools.js +2 -78
- package/dist/src/gateway/hono/routes/imports.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +24 -8
- package/dist/src/gateway/hono/routes/local-apps.js +1 -1
- package/dist/src/gateway/hono/routes/personal-agent.js +2 -2
- package/dist/src/gateway/hono/routes/session-command-handler.js +2 -0
- package/dist/src/gateway/hono/routes/session-input-handler.js +2 -0
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +2 -2
- package/dist/src/gateway/security/device-request-proof.js +8 -18
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/agent-runner.d.ts +3 -0
- package/dist/src/gateway/service/agent-runner.js +21 -5
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service.js +15 -10
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/mcp/capability-server.js +1 -1
- package/dist/src/notes/agent-context.d.ts +3 -0
- package/dist/src/notes/agent-context.js +32 -4
- package/dist/src/notifications/service.js +2 -2
- package/dist/src/personal-agent/proactivity/repository.js +1 -1
- package/dist/src/personal-agent/proactivity/service.js +1 -1
- package/dist/src/phone/assistance.js +1 -1
- package/dist/src/phone/location-environment.js +1 -1
- package/dist/src/phone/repository.js +1 -1
- package/dist/src/phone/setup/service.js +1 -1
- package/dist/src/realtime/runtime.js +5 -0
- package/dist/src/session/session-context-for-llm.js +9 -1
- package/dist/src/session/store.js +1 -1
- package/dist/src/share/hosted-session-share.js +1 -1
- package/dist/src/share/share-store.js +1 -1
- package/dist/src/storage/sqlite/clarification-wait-repository.d.ts +7 -1
- package/dist/src/storage/sqlite/clarification-wait-repository.js +40 -2
- package/dist/src/storage/sqlite/device-access-repository.d.ts +2 -8
- package/dist/src/storage/sqlite/device-access-repository.js +1 -3
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +2 -2
- package/dist/src/storage/sqlite/index.d.ts +0 -1
- package/dist/src/storage/sqlite/index.js +3 -3
- package/dist/src/storage/sqlite/schema.d.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +7 -7
- package/dist/src/storage/sqlite/schema.sql +2 -10
- package/dist/src/storage/sqlite/session-input-repository.js +8 -0
- package/dist/src/storage/sqlite/upgrades/270_device_bridge_kind.sql +30 -0
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/chat-page-CeHOmJqM.js +0 -72
- package/dist/gateway/static/root/assets/gateway-realtime-hnEaDFaA.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-ugwtyD4q.js +0 -1
- package/dist/gateway/static/root/assets/gateway-restart-kwv0njYq.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CxYPJTy8.js +0 -1
- package/dist/gateway/static/root/assets/index-Cg0AgHw1.js +0 -11
- package/dist/gateway/static/root/assets/index-DE2bG5EI.css +0 -1
- package/dist/gateway/static/root/assets/languages-zXtNocoy.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-BgdAP0kf.js +0 -1
- package/dist/gateway/static/root/assets/navigation-D62kPsA9.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-DWIWloib.js +0 -5
- package/dist/gateway/static/root/assets/note-image-lightbox-BbNYW2Rw.js +0 -1
- package/dist/gateway/static/root/assets/page-context-capture-button-B9L7V_n2.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-YZfSLNTg.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-content-CGbqoID0.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-modal-0wvIDcVr.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-Bkxs8knZ.js +0 -7
- package/dist/gateway/static/root/assets/route-preload-BVo8JPwW.js +0 -2
- package/dist/gateway/static/root/assets/settings-advanced-gate-DyGT3o1e.js +0 -1
- package/dist/gateway/static/root/assets/use-file-preview-expanded-9DED7ohY.js +0 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-CmSYxTmk.js +0 -1
- package/dist/packages/endpoint-tools-protocol/src/bridge.js +0 -105
- package/dist/packages/gateway-contract/src/desktop-chat.js +0 -29
- package/dist/src/endpoint-tools/binding-service.d.ts +0 -24
- package/dist/src/endpoint-tools/binding-service.js +0 -57
- package/dist/src/gateway/hono/routes/desktop-chat.d.ts +0 -3
- package/dist/src/gateway/hono/routes/desktop-chat.js +0 -30
- package/dist/src/storage/sqlite/endpoint-session-binding-repository.d.ts +0 -9
- package/dist/src/storage/sqlite/endpoint-session-binding-repository.js +0 -41
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { providerToolSchema } from "../../packages/endpoint-tools-protocol/src/providers.js";
|
|
2
|
+
import { init_src } from "../../packages/endpoint-tools-protocol/src/index.js";
|
|
3
|
+
import { EndpointToolClientError } from "../../packages/endpoint-tools-client/src/index.js";
|
|
4
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
6
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
7
|
+
import { ElicitRequestSchema, ElicitResultSchema, ToolListChangedNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
+
//#region src/endpoint-tools/mcp-provider.ts
|
|
9
|
+
init_src();
|
|
10
|
+
function resourceWithinScope(uri, prefix) {
|
|
11
|
+
try {
|
|
12
|
+
const resource = new URL(uri), scope = new URL(prefix);
|
|
13
|
+
if (resource.username || resource.password || resource.hash || scope.search || scope.hash) return false;
|
|
14
|
+
const path = decodeURIComponent(resource.pathname), root = decodeURIComponent(scope.pathname).replace(/\/$/, "");
|
|
15
|
+
if (path.includes("\\") || path.split("/").some((part) => part === ".." || part === ".")) return false;
|
|
16
|
+
return resource.protocol === scope.protocol && resource.host === scope.host && (path === root || path.startsWith(root + "/"));
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Runs on a device host. Gateway MCP configuration, credentials and runtime are never imported. */
|
|
22
|
+
async function connectDeviceMcpProvider(options) {
|
|
23
|
+
const client = new Client({
|
|
24
|
+
name: "xopc-device-host",
|
|
25
|
+
version: "1"
|
|
26
|
+
}, { capabilities: options.onElicitation || options.gatewayFormInput ? { elicitation: { form: {} } } : {} });
|
|
27
|
+
let closed = false, requested = false, refreshPending;
|
|
28
|
+
let active;
|
|
29
|
+
const fail = (error) => {
|
|
30
|
+
options.registry.removeProvider(options.localId);
|
|
31
|
+
options.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
32
|
+
};
|
|
33
|
+
client.onclose = () => {
|
|
34
|
+
closed = true;
|
|
35
|
+
options.registry.removeProvider(options.localId);
|
|
36
|
+
};
|
|
37
|
+
if (options.onElicitation || options.gatewayFormInput) client.setRequestHandler(ElicitRequestSchema, async (request) => {
|
|
38
|
+
const context = active;
|
|
39
|
+
if (!context || context.signal.aborted || request.params.mode === "url") return { action: "decline" };
|
|
40
|
+
const result = options.onElicitation ? await options.onElicitation(request.params, context) : context.requestInput ? ElicitResultSchema.parse(await context.requestInput(request.params.message, request.params.requestedSchema)) : { action: "decline" };
|
|
41
|
+
return active === context && !context.signal.aborted ? result : { action: "cancel" };
|
|
42
|
+
});
|
|
43
|
+
const content = async (result, context) => {
|
|
44
|
+
if (result.isError) throw new EndpointToolClientError("TOOL_EXECUTION_FAILED", "The MCP provider reported an execution error");
|
|
45
|
+
if (result.structuredContent !== void 0) return [{
|
|
46
|
+
type: "json",
|
|
47
|
+
value: result.structuredContent
|
|
48
|
+
}];
|
|
49
|
+
const blocks = [];
|
|
50
|
+
for (const block of result.content ?? []) if (block.type === "text" && typeof block.text === "string") blocks.push({
|
|
51
|
+
type: "text",
|
|
52
|
+
text: block.text
|
|
53
|
+
});
|
|
54
|
+
else if (block.type === "image" && typeof block.data === "string" && typeof block.mimeType === "string") {
|
|
55
|
+
if (block.data.length > 32 * 1024 * 1024) throw new Error("MCP image exceeds its byte budget");
|
|
56
|
+
blocks.push(await context.uploadFile({
|
|
57
|
+
name: "mcp-image",
|
|
58
|
+
mimeType: block.mimeType,
|
|
59
|
+
bytes: Buffer.from(block.data, "base64")
|
|
60
|
+
}));
|
|
61
|
+
} else if (block.type === "resource_link" && typeof block.uri === "string") blocks.push({
|
|
62
|
+
type: "json",
|
|
63
|
+
value: {
|
|
64
|
+
providerId: options.localId,
|
|
65
|
+
resourceUri: block.uri,
|
|
66
|
+
name: block.name
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
else if (block.type === "resource" && block.resource && typeof block.resource === "object") {
|
|
70
|
+
const resource = block.resource;
|
|
71
|
+
if (typeof resource.text === "string") blocks.push({
|
|
72
|
+
type: "text",
|
|
73
|
+
text: resource.text
|
|
74
|
+
});
|
|
75
|
+
else if (typeof resource.blob === "string") {
|
|
76
|
+
if (resource.blob.length > 32 * 1024 * 1024) throw new Error("MCP resource exceeds its byte budget");
|
|
77
|
+
blocks.push(await context.uploadFile({
|
|
78
|
+
name: "mcp-resource",
|
|
79
|
+
mimeType: resource.mimeType ?? "application/octet-stream",
|
|
80
|
+
bytes: Buffer.from(resource.blob, "base64")
|
|
81
|
+
}));
|
|
82
|
+
} else throw new Error("Unsupported MCP resource content");
|
|
83
|
+
} else throw new Error("Unsupported MCP content type");
|
|
84
|
+
return blocks.length ? blocks : [{
|
|
85
|
+
type: "text",
|
|
86
|
+
text: "Completed without content"
|
|
87
|
+
}];
|
|
88
|
+
};
|
|
89
|
+
const execute = async (context, operation) => {
|
|
90
|
+
if (closed) throw new Error("MCP provider is disconnected");
|
|
91
|
+
if (active) throw new EndpointToolClientError("TOOL_BUSY", "MCP provider already has an active invocation");
|
|
92
|
+
active = context;
|
|
93
|
+
try {
|
|
94
|
+
context.signal.throwIfAborted();
|
|
95
|
+
return { content: await operation() };
|
|
96
|
+
} finally {
|
|
97
|
+
active = void 0;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const refresh = () => {
|
|
101
|
+
requested = true;
|
|
102
|
+
if (refreshPending) return refreshPending;
|
|
103
|
+
refreshPending = (async () => {
|
|
104
|
+
do {
|
|
105
|
+
requested = false;
|
|
106
|
+
const discovered = [];
|
|
107
|
+
let cursor;
|
|
108
|
+
const seen = /* @__PURE__ */ new Set();
|
|
109
|
+
let pages = 0;
|
|
110
|
+
if (client.getServerCapabilities()?.tools) do {
|
|
111
|
+
if (++pages > 100 || cursor && seen.has(cursor)) throw new Error("MCP pagination exceeds its budget");
|
|
112
|
+
if (cursor) seen.add(cursor);
|
|
113
|
+
const page = await client.listTools(cursor ? { cursor } : void 0);
|
|
114
|
+
discovered.push(...page.tools);
|
|
115
|
+
if (discovered.length > 100) throw new Error("MCP tool catalog exceeds its budget");
|
|
116
|
+
cursor = page.nextCursor;
|
|
117
|
+
} while (cursor);
|
|
118
|
+
const tools = discovered.flatMap((tool) => {
|
|
119
|
+
const policy = options.policies[tool.name];
|
|
120
|
+
if (!policy) return [];
|
|
121
|
+
const descriptor = providerToolSchema.parse({
|
|
122
|
+
...policy,
|
|
123
|
+
name: tool.name,
|
|
124
|
+
title: tool.title ?? tool.name,
|
|
125
|
+
description: tool.description ?? tool.name,
|
|
126
|
+
inputSchema: tool.inputSchema,
|
|
127
|
+
outputSchema: tool.outputSchema,
|
|
128
|
+
maxConcurrency: 1
|
|
129
|
+
});
|
|
130
|
+
return [{
|
|
131
|
+
descriptor,
|
|
132
|
+
execute: (args, context) => execute(context, async () => {
|
|
133
|
+
let toolArguments = args;
|
|
134
|
+
if (descriptor.artifactInput) {
|
|
135
|
+
if (!context.readArtifact) throw new Error("An authorized artifact is required");
|
|
136
|
+
const bytes = await context.readArtifact();
|
|
137
|
+
try {
|
|
138
|
+
toolArguments = {
|
|
139
|
+
...args,
|
|
140
|
+
[descriptor.artifactInput]: Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64")
|
|
141
|
+
};
|
|
142
|
+
} finally {
|
|
143
|
+
bytes.fill(0);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return content(await client.callTool({
|
|
147
|
+
name: tool.name,
|
|
148
|
+
arguments: toolArguments
|
|
149
|
+
}, void 0, {
|
|
150
|
+
signal: context.signal,
|
|
151
|
+
timeout: descriptor.timeoutMs,
|
|
152
|
+
onprogress: (progress) => context.reportProgress({
|
|
153
|
+
...progress.message ? { message: progress.message } : {},
|
|
154
|
+
...progress.total && progress.total > 0 ? { percent: Math.min(100, 100 * progress.progress / progress.total) } : {}
|
|
155
|
+
})
|
|
156
|
+
}), context);
|
|
157
|
+
})
|
|
158
|
+
}];
|
|
159
|
+
});
|
|
160
|
+
const resourcePolicy = options.policies.xopc_resource_read;
|
|
161
|
+
if (resourcePolicy && options.resourcePrefixes?.length && client.getServerCapabilities()?.resources) {
|
|
162
|
+
if (tools.some((tool) => tool.descriptor.name === "xopc_resource_read")) throw new Error("MCP resource helper name conflicts with a tool");
|
|
163
|
+
tools.push({
|
|
164
|
+
descriptor: providerToolSchema.parse({
|
|
165
|
+
...resourcePolicy,
|
|
166
|
+
name: "xopc_resource_read",
|
|
167
|
+
title: "Read provider resource",
|
|
168
|
+
description: "Read a resource URI from this provider within the configured resource scope.",
|
|
169
|
+
inputSchema: {
|
|
170
|
+
type: "object",
|
|
171
|
+
properties: { uri: {
|
|
172
|
+
type: "string",
|
|
173
|
+
maxLength: 2e3
|
|
174
|
+
} },
|
|
175
|
+
required: ["uri"],
|
|
176
|
+
additionalProperties: false
|
|
177
|
+
},
|
|
178
|
+
maxConcurrency: 1
|
|
179
|
+
}),
|
|
180
|
+
execute: (args, context) => execute(context, async () => {
|
|
181
|
+
const uri = String(args.uri ?? "");
|
|
182
|
+
if (!options.resourcePrefixes.some((prefix) => resourceWithinScope(uri, prefix))) throw new EndpointToolClientError("PERMISSION_DENIED", "Resource is outside the installed scope");
|
|
183
|
+
return content({ content: (await client.readResource({ uri }, {
|
|
184
|
+
signal: context.signal,
|
|
185
|
+
timeout: resourcePolicy.timeoutMs
|
|
186
|
+
})).contents.map((resource) => ({
|
|
187
|
+
type: "resource",
|
|
188
|
+
resource
|
|
189
|
+
})) }, context);
|
|
190
|
+
})
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (closed) return;
|
|
194
|
+
options.registry.registerProvider({
|
|
195
|
+
localId: options.localId,
|
|
196
|
+
title: options.title,
|
|
197
|
+
summary: options.summary,
|
|
198
|
+
instructions: client.getInstructions()?.slice(0, 8e3),
|
|
199
|
+
durableOperations: options.durableOperations,
|
|
200
|
+
gatewayFormInput: options.gatewayFormInput,
|
|
201
|
+
tools
|
|
202
|
+
});
|
|
203
|
+
} while (requested && !closed);
|
|
204
|
+
})().catch((error) => {
|
|
205
|
+
fail(error);
|
|
206
|
+
throw error;
|
|
207
|
+
}).finally(() => {
|
|
208
|
+
refreshPending = void 0;
|
|
209
|
+
});
|
|
210
|
+
return refreshPending;
|
|
211
|
+
};
|
|
212
|
+
client.setNotificationHandler(ToolListChangedNotificationSchema, () => {
|
|
213
|
+
refresh().catch(() => {});
|
|
214
|
+
});
|
|
215
|
+
let transport;
|
|
216
|
+
if ("command" in options.server) transport = new StdioClientTransport({
|
|
217
|
+
...options.server,
|
|
218
|
+
stderr: "ignore"
|
|
219
|
+
});
|
|
220
|
+
else {
|
|
221
|
+
const url = new URL(options.server.url);
|
|
222
|
+
if (url.username || url.password || url.hash || url.protocol !== "https:" && !(url.protocol === "http:" && [
|
|
223
|
+
"127.0.0.1",
|
|
224
|
+
"localhost",
|
|
225
|
+
"[::1]"
|
|
226
|
+
].includes(url.hostname))) throw new Error("MCP HTTP providers require HTTPS or a loopback origin");
|
|
227
|
+
transport = new StreamableHTTPClientTransport(url, {
|
|
228
|
+
requestInit: {
|
|
229
|
+
headers: options.server.headers,
|
|
230
|
+
redirect: "error"
|
|
231
|
+
},
|
|
232
|
+
reconnectionOptions: {
|
|
233
|
+
maxRetries: 0,
|
|
234
|
+
initialReconnectionDelay: 1e3,
|
|
235
|
+
maxReconnectionDelay: 1e3,
|
|
236
|
+
reconnectionDelayGrowFactor: 1
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
transport.onerror = (error) => fail(error);
|
|
241
|
+
try {
|
|
242
|
+
await client.connect(transport);
|
|
243
|
+
await refresh();
|
|
244
|
+
} catch (error) {
|
|
245
|
+
await client.close();
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
refresh,
|
|
250
|
+
async close() {
|
|
251
|
+
closed = true;
|
|
252
|
+
options.registry.removeProvider(options.localId);
|
|
253
|
+
await client.close();
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
//#endregion
|
|
258
|
+
export { connectDeviceMcpProvider, resourceWithinScope };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DEVICE_EMPTY_INPUT_SCHEMA, ENDPOINT_CONTACT_LIST_OUTPUT_SCHEMA, ENDPOINT_CONTACT_OUTPUT_SCHEMA, ENDPOINT_FILE_OUTPUT_SCHEMA } from "../../packages/endpoint-tools-protocol/src/shared-schemas.js";
|
|
2
2
|
import { desktopCommandDescriptor } from "../../packages/endpoint-tools-protocol/src/command.js";
|
|
3
3
|
import { desktopTerminalDescriptors } from "../../packages/endpoint-tools-protocol/src/terminal.js";
|
|
4
|
-
import { BRIDGE_LIST_OUTPUT_SCHEMA, BRIDGE_READ_INPUT_SCHEMA, BRIDGE_READ_OUTPUT_SCHEMA } from "../../packages/endpoint-tools-protocol/src/bridge.js";
|
|
5
4
|
import { LOCATION_INPUT_SCHEMA, LOCATION_OUTPUT_SCHEMA } from "../../packages/endpoint-tools-protocol/src/location.js";
|
|
6
5
|
import { PERSONAL_TOOL_NAMES, personalDescriptor } from "../../packages/endpoint-tools-protocol/src/personal.js";
|
|
7
6
|
import { SCREEN_CAPTURE_OUTPUT_SCHEMA } from "../../packages/endpoint-tools-protocol/src/screen.js";
|
|
@@ -47,8 +46,6 @@ const POLICY_BY_TOOL = {
|
|
|
47
46
|
"desktop",
|
|
48
47
|
"web"
|
|
49
48
|
].map((kind) => [`${kind}.device.get_location`, contract("personal.foreground-read", LOCATION_OUTPUT_SCHEMA, ["json"], ["location-read-once"], LOCATION_INPUT_SCHEMA)])),
|
|
50
|
-
"desktop.bridge.list_resources": contract("public.background-read", BRIDGE_LIST_OUTPUT_SCHEMA, ["json"], [], DEVICE_EMPTY_INPUT_SCHEMA),
|
|
51
|
-
"desktop.bridge.read_sensor": contract("public.background-read", BRIDGE_READ_OUTPUT_SCHEMA, ["json"], [], BRIDGE_READ_INPUT_SCHEMA),
|
|
52
49
|
"desktop.computer.control": contract("computer.session-scoped", COMPUTER_OUTPUT_SCHEMA, ["json", "file"], ["computer-control"], COMPUTER_INPUT_SCHEMA),
|
|
53
50
|
[REMOTE_COMPUTER_CONTROL_TOOL]: contract("computer.remote-session-scoped", COMPUTER_OUTPUT_SCHEMA, ["json", "file"], ["computer-control"], COMPUTER_INPUT_SCHEMA),
|
|
54
51
|
"web.file.pick": contract("personal.foreground-read", ENDPOINT_FILE_OUTPUT_SCHEMA, ["file"], ["file-read"]),
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type CapabilityProvider, type ProviderCatalog, type ProviderState } from '@xopcai/endpoint-tools-protocol';
|
|
2
|
+
import type { EndpointRegistry, RegisteredEndpointTool } from './registry.js';
|
|
3
|
+
export interface ProviderRecord {
|
|
4
|
+
principalId: string;
|
|
5
|
+
provider: CapabilityProvider;
|
|
6
|
+
digest: string;
|
|
7
|
+
admittedDigest?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ProviderCatalogStore {
|
|
10
|
+
get(key: string): ProviderRecord | undefined;
|
|
11
|
+
set(key: string, value: ProviderRecord): void;
|
|
12
|
+
entries(): Array<[string, ProviderRecord]>;
|
|
13
|
+
setMany(records: Array<[string, ProviderRecord]>): void;
|
|
14
|
+
}
|
|
15
|
+
/** Device claims are retained offline; execution requires a live connection and exact owner admission. */
|
|
16
|
+
export declare class EndpointProviderCatalog {
|
|
17
|
+
private readonly registry;
|
|
18
|
+
private readonly store;
|
|
19
|
+
private readonly now;
|
|
20
|
+
private readonly publicationBudget;
|
|
21
|
+
private readonly live;
|
|
22
|
+
private readonly owners;
|
|
23
|
+
private readonly states;
|
|
24
|
+
private enabled;
|
|
25
|
+
constructor(registry: EndpointRegistry, store?: ProviderCatalogStore, now?: () => number);
|
|
26
|
+
setEnabled(enabled: boolean): void;
|
|
27
|
+
replace(endpointId: string, connectionId: string, raw: ProviderCatalog): void;
|
|
28
|
+
list(principalId?: string): {
|
|
29
|
+
status: string;
|
|
30
|
+
endpointId?: string;
|
|
31
|
+
connectionId?: string;
|
|
32
|
+
admitted: boolean;
|
|
33
|
+
principalId: string;
|
|
34
|
+
provider: CapabilityProvider;
|
|
35
|
+
digest: string;
|
|
36
|
+
admittedDigest?: string;
|
|
37
|
+
}[];
|
|
38
|
+
admit(principalId: string, localId: string, expectedDigest: string, allowed: boolean): void;
|
|
39
|
+
reportState(endpointId: string, connectionId: string, raw: ProviderState): void;
|
|
40
|
+
disconnect(endpointId: string, connectionId: string): void;
|
|
41
|
+
assertExecutable(endpointId: string, toolName: string): void;
|
|
42
|
+
isReady(provider: NonNullable<RegisteredEndpointTool['provider']>): boolean;
|
|
43
|
+
private sync;
|
|
44
|
+
private requireConnection;
|
|
45
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
import { assertProviderSchemaBudget, providerCatalogSchema, providerEndpointDescriptor, providerStateSchema } from "../../packages/endpoint-tools-protocol/src/providers.js";
|
|
3
|
+
import { canonicalJson, init_src } from "../../packages/endpoint-tools-protocol/src/index.js";
|
|
4
|
+
import { DurableState } from "../storage/sqlite/durable-state.js";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import Ajv2020 from "ajv/dist/2020.js";
|
|
7
|
+
//#region src/endpoint-tools/provider-catalog.ts
|
|
8
|
+
init_src();
|
|
9
|
+
init_transaction();
|
|
10
|
+
var SqliteProviderCatalogStore = class extends DurableState {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("device.providers");
|
|
13
|
+
}
|
|
14
|
+
setMany(records) {
|
|
15
|
+
runSqliteWriteTransaction(() => {
|
|
16
|
+
for (const [key, value] of records) this.set(key, value);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const keyOf = (principalId, localId) => JSON.stringify([principalId, localId]);
|
|
21
|
+
const hash = (value) => createHash("sha256").update(canonicalJson(value)).digest("hex");
|
|
22
|
+
/** Device claims are retained offline; execution requires a live connection and exact owner admission. */
|
|
23
|
+
var EndpointProviderCatalog = class {
|
|
24
|
+
publicationBudget = /* @__PURE__ */ new Map();
|
|
25
|
+
live = /* @__PURE__ */ new Map();
|
|
26
|
+
owners = /* @__PURE__ */ new Map();
|
|
27
|
+
states = /* @__PURE__ */ new Map();
|
|
28
|
+
enabled = true;
|
|
29
|
+
constructor(registry, store = new SqliteProviderCatalogStore(), now = Date.now) {
|
|
30
|
+
this.registry = registry;
|
|
31
|
+
this.store = store;
|
|
32
|
+
this.now = now;
|
|
33
|
+
}
|
|
34
|
+
setEnabled(enabled) {
|
|
35
|
+
if (enabled === this.enabled) return;
|
|
36
|
+
this.enabled = enabled;
|
|
37
|
+
for (const endpointId of this.live.keys()) this.sync(endpointId);
|
|
38
|
+
}
|
|
39
|
+
replace(endpointId, connectionId, raw) {
|
|
40
|
+
const endpoint = this.requireConnection(endpointId, connectionId);
|
|
41
|
+
const now = this.now();
|
|
42
|
+
for (const [id, window] of this.publicationBudget) if (window.start + 1e4 <= now) this.publicationBudget.delete(id);
|
|
43
|
+
const budget = this.publicationBudget.get(endpoint.principalId) ?? {
|
|
44
|
+
start: now,
|
|
45
|
+
count: 0
|
|
46
|
+
};
|
|
47
|
+
if (++budget.count > 8) throw new Error("PROVIDER_CATALOG_RATE_LIMITED");
|
|
48
|
+
this.publicationBudget.set(endpoint.principalId, budget);
|
|
49
|
+
const catalog = providerCatalogSchema.parse(raw);
|
|
50
|
+
const previous = this.live.get(endpointId);
|
|
51
|
+
if (previous?.connectionId === connectionId && catalog.revision <= previous.revision) throw new Error("PROVIDER_CATALOG_REVISION_CONFLICT");
|
|
52
|
+
const checkedSchemas = /* @__PURE__ */ new Set();
|
|
53
|
+
const compile = (schema) => {
|
|
54
|
+
const digest = hash(schema);
|
|
55
|
+
if (checkedSchemas.has(digest)) return;
|
|
56
|
+
new Ajv2020({
|
|
57
|
+
strict: false,
|
|
58
|
+
validateFormats: false,
|
|
59
|
+
inlineRefs: false
|
|
60
|
+
}).compile(schema);
|
|
61
|
+
checkedSchemas.add(digest);
|
|
62
|
+
};
|
|
63
|
+
const records = catalog.providers.map((provider) => {
|
|
64
|
+
const owner = this.live.get(this.owners.get(keyOf(endpoint.principalId, provider.localId)) ?? "");
|
|
65
|
+
if (owner && owner.endpointId !== endpointId && this.registry.isCurrentConnection(owner.endpointId, owner.connectionId)) throw new Error("PROVIDER_CONNECTION_CONFLICT");
|
|
66
|
+
for (const tool of provider.tools) {
|
|
67
|
+
assertProviderSchemaBudget(tool.inputSchema);
|
|
68
|
+
if (tool.outputSchema) assertProviderSchemaBudget(tool.outputSchema);
|
|
69
|
+
const descriptor = providerEndpointDescriptor(provider.localId, tool);
|
|
70
|
+
compile(descriptor.inputSchema);
|
|
71
|
+
compile(descriptor.outputSchema);
|
|
72
|
+
}
|
|
73
|
+
const key = keyOf(endpoint.principalId, provider.localId), existing = this.store.get(key);
|
|
74
|
+
return {
|
|
75
|
+
principalId: endpoint.principalId,
|
|
76
|
+
provider,
|
|
77
|
+
digest: hash(provider),
|
|
78
|
+
...existing?.admittedDigest ? { admittedDigest: existing.admittedDigest } : {}
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
this.store.setMany(records.map((record) => [keyOf(record.principalId, record.provider.localId), record]));
|
|
82
|
+
for (const localId of previous?.providerIds ?? []) {
|
|
83
|
+
const key = keyOf(endpoint.principalId, localId);
|
|
84
|
+
if (this.owners.get(key) === endpointId) this.owners.delete(key);
|
|
85
|
+
this.states.delete(key);
|
|
86
|
+
}
|
|
87
|
+
this.live.set(endpointId, {
|
|
88
|
+
principalId: endpoint.principalId,
|
|
89
|
+
endpointId,
|
|
90
|
+
connectionId,
|
|
91
|
+
revision: catalog.revision,
|
|
92
|
+
providerIds: records.map((r) => r.provider.localId)
|
|
93
|
+
});
|
|
94
|
+
for (const record of records) {
|
|
95
|
+
const key = keyOf(endpoint.principalId, record.provider.localId);
|
|
96
|
+
this.owners.set(key, endpointId);
|
|
97
|
+
this.states.delete(key);
|
|
98
|
+
}
|
|
99
|
+
this.sync(endpointId);
|
|
100
|
+
}
|
|
101
|
+
list(principalId) {
|
|
102
|
+
return this.store.entries().map(([, record]) => record).filter((record) => !principalId || record.principalId === principalId).map((record) => {
|
|
103
|
+
const live = this.live.get(this.owners.get(keyOf(record.principalId, record.provider.localId)) ?? "");
|
|
104
|
+
const connected = live && this.registry.isCurrentConnection(live.endpointId, live.connectionId) && live.providerIds.includes(record.provider.localId);
|
|
105
|
+
const state = this.states.get(keyOf(record.principalId, record.provider.localId));
|
|
106
|
+
return {
|
|
107
|
+
...record,
|
|
108
|
+
admitted: record.admittedDigest === record.digest,
|
|
109
|
+
...connected ? {
|
|
110
|
+
endpointId: live.endpointId,
|
|
111
|
+
connectionId: live.connectionId
|
|
112
|
+
} : {},
|
|
113
|
+
status: !connected ? "offline" : !this.enabled ? "unavailable" : record.admittedDigest !== record.digest ? "authorization_required" : state && state.expiresAt > this.now() ? state.reason : "unavailable"
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
admit(principalId, localId, expectedDigest, allowed) {
|
|
118
|
+
const key = keyOf(principalId, localId), record = this.store.get(key);
|
|
119
|
+
if (!record || record.digest !== expectedDigest) throw new Error("PROVIDER_CONTRACT_CHANGED");
|
|
120
|
+
this.store.set(key, {
|
|
121
|
+
...record,
|
|
122
|
+
admittedDigest: allowed ? expectedDigest : void 0
|
|
123
|
+
});
|
|
124
|
+
const endpointId = this.owners.get(key);
|
|
125
|
+
if (endpointId) this.sync(endpointId);
|
|
126
|
+
}
|
|
127
|
+
reportState(endpointId, connectionId, raw) {
|
|
128
|
+
const endpoint = this.requireConnection(endpointId, connectionId), state = providerStateSchema.parse(raw);
|
|
129
|
+
const live = this.live.get(endpointId);
|
|
130
|
+
if (live?.connectionId !== connectionId || live.revision !== state.catalogRevision || !live.providerIds.includes(state.localId)) throw new Error("PROVIDER_NOT_REGISTERED");
|
|
131
|
+
const key = keyOf(endpoint.principalId, state.localId), previous = this.states.get(key);
|
|
132
|
+
if (previous && state.sequence <= previous.sequence) throw new Error("PROVIDER_STATE_SEQUENCE_CONFLICT");
|
|
133
|
+
this.states.set(key, {
|
|
134
|
+
...state,
|
|
135
|
+
expiresAt: this.now() + state.validForMs
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
disconnect(endpointId, connectionId) {
|
|
139
|
+
const live = this.live.get(endpointId);
|
|
140
|
+
if (!live || live.connectionId !== connectionId) return;
|
|
141
|
+
this.live.delete(endpointId);
|
|
142
|
+
for (const localId of live.providerIds) {
|
|
143
|
+
const key = keyOf(live.principalId, localId);
|
|
144
|
+
if (this.owners.get(key) === endpointId) {
|
|
145
|
+
this.owners.delete(key);
|
|
146
|
+
this.states.delete(key);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
assertExecutable(endpointId, toolName) {
|
|
151
|
+
const tool = this.registry.getTool(endpointId, toolName);
|
|
152
|
+
if (!tool?.provider) return;
|
|
153
|
+
const key = keyOf(tool.provider.principalId, tool.provider.localId), record = this.store.get(key);
|
|
154
|
+
const live = this.live.get(endpointId);
|
|
155
|
+
if (!record || record.admittedDigest !== record.digest || this.owners.get(key) !== endpointId || live?.connectionId !== this.registry.get(endpointId)?.connectionId || !this.isReady(tool.provider)) throw new Error("PROVIDER_UNAVAILABLE");
|
|
156
|
+
}
|
|
157
|
+
isReady(provider) {
|
|
158
|
+
const state = this.states.get(keyOf(provider.principalId, provider.localId));
|
|
159
|
+
return this.enabled && state?.reason === "ready" && state.expiresAt > this.now();
|
|
160
|
+
}
|
|
161
|
+
sync(endpointId) {
|
|
162
|
+
const live = this.live.get(endpointId);
|
|
163
|
+
if (!live || !this.registry.isCurrentConnection(live.endpointId, live.connectionId)) return;
|
|
164
|
+
if (!this.enabled) {
|
|
165
|
+
this.registry.replaceProviderTools(live.endpointId, live.connectionId, []);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const principalId = live.principalId;
|
|
169
|
+
const tools = [];
|
|
170
|
+
for (const localId of live.providerIds) {
|
|
171
|
+
const record = this.store.get(keyOf(principalId, localId));
|
|
172
|
+
if (!record || record.digest !== record.admittedDigest) continue;
|
|
173
|
+
for (const tool of record.provider.tools) {
|
|
174
|
+
const descriptor = providerEndpointDescriptor(localId, tool);
|
|
175
|
+
tools.push({
|
|
176
|
+
descriptor,
|
|
177
|
+
revision: hash(descriptor),
|
|
178
|
+
provider: {
|
|
179
|
+
principalId,
|
|
180
|
+
localId,
|
|
181
|
+
name: tool.name,
|
|
182
|
+
summary: record.provider.summary,
|
|
183
|
+
instructions: record.provider.instructions,
|
|
184
|
+
digest: record.digest,
|
|
185
|
+
durableOperations: record.provider.durableOperations,
|
|
186
|
+
artifactInput: tool.artifactInput,
|
|
187
|
+
gatewayFormInput: record.provider.gatewayFormInput,
|
|
188
|
+
resourceId: tool.resourceId
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
this.registry.replaceProviderTools(live.endpointId, live.connectionId, tools);
|
|
194
|
+
}
|
|
195
|
+
requireConnection(endpointId, connectionId) {
|
|
196
|
+
const endpoint = this.registry.get(endpointId);
|
|
197
|
+
if (!endpoint || endpoint.connectionId !== connectionId) throw new Error("Endpoint connection is no longer active");
|
|
198
|
+
return endpoint;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
//#endregion
|
|
202
|
+
export { EndpointProviderCatalog };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ProviderOperationJournal } from '@xopcai/endpoint-tools-client';
|
|
2
|
+
import { type ProviderOperationIntent, type ProviderOperationReceipt } from '@xopcai/endpoint-tools-protocol';
|
|
3
|
+
/** Private per-host evidence. Store identity and digests, never arguments, results or credentials. */
|
|
4
|
+
export declare class FileProviderOperationJournal implements ProviderOperationJournal {
|
|
5
|
+
private readonly directory;
|
|
6
|
+
private readonly limit;
|
|
7
|
+
private readonly active;
|
|
8
|
+
private initialized?;
|
|
9
|
+
private count;
|
|
10
|
+
constructor(directory: string, limit?: number);
|
|
11
|
+
begin(raw: ProviderOperationIntent): Promise<'started' | 'exists'>;
|
|
12
|
+
finish(intent: ProviderOperationIntent, resultDigest?: string): Promise<ProviderOperationReceipt>;
|
|
13
|
+
status(operationId: string): Promise<ProviderOperationReceipt | undefined>;
|
|
14
|
+
private initialize;
|
|
15
|
+
private path;
|
|
16
|
+
private read;
|
|
17
|
+
private syncDirectory;
|
|
18
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { providerOperationIntentSchema, providerOperationReceiptSchema } from "../../packages/endpoint-tools-protocol/src/provider-execution.js";
|
|
2
|
+
import { canonicalJson, init_src } from "../../packages/endpoint-tools-protocol/src/index.js";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { mkdir, open, readFile, readdir, rename, unlink } from "node:fs/promises";
|
|
7
|
+
//#region src/endpoint-tools/provider-operation-journal.ts
|
|
8
|
+
init_src();
|
|
9
|
+
/** Private per-host evidence. Store identity and digests, never arguments, results or credentials. */
|
|
10
|
+
var FileProviderOperationJournal = class {
|
|
11
|
+
active = /* @__PURE__ */ new Map();
|
|
12
|
+
initialized;
|
|
13
|
+
count = 0;
|
|
14
|
+
constructor(directory, limit = 1e4) {
|
|
15
|
+
this.directory = directory;
|
|
16
|
+
this.limit = limit;
|
|
17
|
+
}
|
|
18
|
+
async begin(raw) {
|
|
19
|
+
const intent = providerOperationIntentSchema.parse(raw);
|
|
20
|
+
await this.initialize();
|
|
21
|
+
if (this.count >= this.limit) throw new Error("Device operation journal is full");
|
|
22
|
+
const path = this.path(intent.operationId);
|
|
23
|
+
let file;
|
|
24
|
+
this.count += 1;
|
|
25
|
+
try {
|
|
26
|
+
file = await open(path, "wx", 384);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
this.count -= 1;
|
|
29
|
+
if (error.code !== "EEXIST") throw error;
|
|
30
|
+
const recorded = await this.read(intent.operationId);
|
|
31
|
+
if (!recorded || canonicalJson(recorded.intent) !== canonicalJson(intent)) throw new Error("Device operation identity conflicts");
|
|
32
|
+
return "exists";
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
await file.writeFile(JSON.stringify({
|
|
36
|
+
intent,
|
|
37
|
+
state: "running",
|
|
38
|
+
updatedAt: Date.now()
|
|
39
|
+
}));
|
|
40
|
+
await file.sync();
|
|
41
|
+
} finally {
|
|
42
|
+
await file.close();
|
|
43
|
+
}
|
|
44
|
+
await this.syncDirectory();
|
|
45
|
+
this.active.set(intent.operationId, canonicalJson(intent));
|
|
46
|
+
return "started";
|
|
47
|
+
}
|
|
48
|
+
async finish(intent, resultDigest) {
|
|
49
|
+
if (this.active.get(intent.operationId) !== canonicalJson(intent)) throw new Error("Device operation is not running under this intent");
|
|
50
|
+
const receipt = providerOperationReceiptSchema.parse({
|
|
51
|
+
intent,
|
|
52
|
+
state: resultDigest ? "succeeded" : "unknown",
|
|
53
|
+
resultDigest,
|
|
54
|
+
updatedAt: Date.now()
|
|
55
|
+
});
|
|
56
|
+
const path = this.path(intent.operationId), temporary = join(this.directory, `${randomUUID()}.tmp`);
|
|
57
|
+
try {
|
|
58
|
+
const file = await open(temporary, "wx", 384);
|
|
59
|
+
try {
|
|
60
|
+
await file.writeFile(JSON.stringify(receipt));
|
|
61
|
+
await file.sync();
|
|
62
|
+
} finally {
|
|
63
|
+
await file.close();
|
|
64
|
+
}
|
|
65
|
+
await rename(temporary, path);
|
|
66
|
+
await this.syncDirectory();
|
|
67
|
+
return receipt;
|
|
68
|
+
} finally {
|
|
69
|
+
this.active.delete(intent.operationId);
|
|
70
|
+
await unlink(temporary).catch(() => {});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async status(operationId) {
|
|
74
|
+
const receipt = await this.read(operationId);
|
|
75
|
+
return receipt?.state === "running" && !this.active.has(operationId) ? {
|
|
76
|
+
...receipt,
|
|
77
|
+
state: "unknown"
|
|
78
|
+
} : receipt;
|
|
79
|
+
}
|
|
80
|
+
initialize() {
|
|
81
|
+
return this.initialized ??= (async () => {
|
|
82
|
+
await mkdir(this.directory, {
|
|
83
|
+
recursive: true,
|
|
84
|
+
mode: 448
|
|
85
|
+
});
|
|
86
|
+
this.count = (await readdir(this.directory)).filter((name) => name.endsWith(".json")).length;
|
|
87
|
+
})();
|
|
88
|
+
}
|
|
89
|
+
path(operationId) {
|
|
90
|
+
return join(this.directory, `${z.uuid().parse(operationId)}.json`);
|
|
91
|
+
}
|
|
92
|
+
async read(operationId) {
|
|
93
|
+
try {
|
|
94
|
+
return providerOperationReceiptSchema.parse(JSON.parse(await readFile(this.path(operationId), "utf8")));
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (error.code === "ENOENT") return;
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async syncDirectory() {
|
|
101
|
+
if (process.platform === "win32") return;
|
|
102
|
+
const directory = await open(this.directory, "r");
|
|
103
|
+
try {
|
|
104
|
+
await directory.sync();
|
|
105
|
+
} finally {
|
|
106
|
+
await directory.close();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
export { FileProviderOperationJournal };
|