@xopcai/xopc 0.0.309 → 0.0.312
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/README.zh-CN.md +2 -1
- 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-XKNYlFUI.js → activity-store-DVUTs1fk.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-1S2TFECE.js → agent-avatar-dicebear-BVIJMP8w.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-K3hTmu9d.js +1 -0
- package/dist/gateway/static/root/assets/{agents-CPqUMtCL.js → agents-D6g_SeWI.js} +1 -1
- package/dist/gateway/static/root/assets/{api-BEUEE4f2.js → api-_aHQA8bd.js} +1 -1
- package/dist/gateway/static/root/assets/app-link-CKueEVbT.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CgVBSqzu.js → app-management-settings-panel-CLg_aXYG.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CoWdCokb.js → appearance-settings-CU52MfIT.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-ZpA1-6ad.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C3ZA6LRS.js → archive-plugin-CHO3heHX.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CdgS6_zy.js → attachment-load-BsmsBCI2.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BtHL2hpg.js → automations-page-CftigJlf.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-IEAxKRME.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CiDhtq_H.js → binary-plugins-CRCLWBo2.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Br00T83w.js → block-editor-D0LDiOTT.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-D2tILykA.js → browser-automation-inputs-C611KRBx.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BVuEmryB.js → browser-automations-page-Djyv3vy-.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-CU4VWsmX.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C9XQk3HL.js +8 -0
- package/dist/gateway/static/root/assets/channels-settings-Bqlhjooi.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-JsMtzDao.js → chat-terminal-dock-CIsKqdET.js} +2 -2
- package/dist/gateway/static/root/assets/{chunk-KS7C4IRE-Cq1tE_3b.js → chunk-KS7C4IRE-BMYIfy9x.js} +2 -2
- package/dist/gateway/static/root/assets/computer-settings-page-C0YL9J7m.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-DZFNUTiN.js → connector-service-page-BmH17JnO.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-zkx8Q-e6.js +2 -0
- package/dist/gateway/static/root/assets/date-picker-CDsfv8R0.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-B-BcuG1y.js → dependency-picker-DvhPj3CZ.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CdBBhhdY.js → desktop-pet-Cyg8XMpL.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-CE4GOlMM.js +1 -0
- package/dist/gateway/static/root/assets/device-pairing-wizard-CdKJqnnw.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BFp5eKtY.js → extension-debug-page-D-AVJU3q.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DL3vyyH6.js → extension-page-DrFoQ9xt.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BXtvdAsY.js → extension-settings-page-DxWjESC1.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-xAOGtenO.js → gateway-config-swr-DUDX42qY.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-BuaTsMSi.js → gateway-realtime-CGOW0-b4.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-D4um_sV7.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-CgXp2zq4.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BwDxKHd4.js → gateway-startup-retry-Cf8OxlvY.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-D6Idk732.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-wGMeI_yW.js → image-generation-api-D2YorS--.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-zexFT5Rq.js → imports-page-BKucJlXI.js} +1 -1
- package/dist/gateway/static/root/assets/index-1wIKA-kM.css +1 -0
- package/dist/gateway/static/root/assets/index-PFQHPGgi.js +79 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CutG9zLh.js → keyboard-shortcuts-settings-BxLXD-yU.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-BmAqTRb4.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CJy6I7Dt.js → local-apps-page-BAsQJQKJ.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DPZ79W1-.js → locale-store-DA0Z5jM_.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-egGcPHNi.js → logs-page-ZjVYXXyM.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-BQhIOELc.js → management-settings-CSTkYVOZ.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-DSjfHfaW.css +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-p2P5hP1U.js → markdown-view-DYGPxPee.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CsBylqlN.js → media-plugins-CQtQzLyg.js} +1 -1
- package/dist/gateway/static/root/assets/messages-4BtQKYlM.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-DuXCt-MM.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-BjOgBVq5.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-ChQ4jJFs.js → page-tabs-B6DjkyMM.js} +1 -1
- package/dist/gateway/static/root/assets/{popover-select-9i-ZtHXL.js → popover-select-B-GDnZO9.js} +1 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-Dn57uLhr.js +1 -0
- package/dist/gateway/static/root/assets/product-delivery-CrAI8ZEa.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-BADxWEdP.js → product-open-page-H2YMk8TY.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-0zi4-i9X.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-B18OxmJj.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-B_e_nZSN.js → registry-api-C0DCx3wv.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-z-DxbuaE.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D-pwiIyp.js → runtime-tools-settings-panel-DGsBTbo6.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-Bgba03B_.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-IWmb05DX.js → schema-form-CblI9WUA.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-B1t3bMsm.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CBX0Ezhf.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-B0veRBZs.js → settings-form-section-BAaVyxJH.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-CKNPbm5q.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-DqNCGKxQ.js +1 -0
- package/dist/gateway/static/root/assets/{settings-shell-layer-context-DCp6ykjQ.js → settings-shell-layer-context-BTQUDoJ2.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Bw71C2X3.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CirpgkfD.js → share-preview-page-BzMfp_HM.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BoVDQolc.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DtTptpAt.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DIht92q6.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-B42mpWKV.js → skills-page.utils-DLYRiEn3.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-yYs4YgYk.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-vgkiGo-D.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BFbj_2Tu.js → theme-store-CegIlB8d.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-BasDYxvx.js +1 -0
- package/dist/gateway/static/root/assets/use-autosave-CWAUHhcb.js +1 -0
- package/dist/gateway/static/root/assets/user-model-page-CAGafNfP.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BZbKQ8HT.js → voice-api-key-field-Kc4UlxZs.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-SKCeQLrH.js → voice-config-api-DTyMdGOR.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BRVTTXNG.js → work-discovery-overlay-BPC_c9dO.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D2kuwv5e.js → workflow-run-setup-panel-DBTciOrq.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CSxHVs1p.js +6 -0
- package/dist/gateway/static/root/connector-icons/SOURCES.md +0 -2
- package/dist/gateway/static/root/index.html +18 -21
- package/dist/gateway/static/root/notification-sw.js +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/notifications.js +12 -11
- package/dist/packages/gateway-contract/src/proactive.js +6 -6
- package/dist/packages/gateway-contract/src/product-delivery.js +1 -0
- package/dist/packages/gateway-contract/src/project-monitoring.js +4 -4
- package/dist/packages/gateway-contract/src/project-operating.js +1 -4
- package/dist/src/agent/agent-manager.d.ts +2 -6
- package/dist/src/agent/agent-manager.js +2 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/commands/command-registry.js +1 -1
- package/dist/src/agent/context/execution-scope.js +1 -1
- package/dist/src/agent/external-tools/cliProvider.d.ts +47 -0
- package/dist/src/agent/external-tools/cliProvider.js +317 -0
- package/dist/src/agent/external-tools/composio-provider.js +3 -3
- package/dist/src/agent/external-tools/gateway-tools.js +8 -2
- package/dist/src/agent/external-tools/index.js +6 -0
- package/dist/src/agent/external-tools/service.js +1 -1
- package/dist/src/agent/external-tools/types.d.ts +1 -1
- package/dist/src/agent/external-tools/types.js +1 -0
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +1 -1
- package/dist/src/agent/memory/turn-provenance.js +2 -1
- package/dist/src/agent/service/parse-outbound-session-key.js +1 -1
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +2 -0
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +43 -16
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +3 -2
- package/dist/src/agent/tools/search/providers/xopc-cloud.d.ts +20 -0
- package/dist/src/agent/tools/search/providers/xopc-cloud.js +56 -0
- package/dist/src/agent/tools/search/registry.d.ts +4 -2
- package/dist/src/agent/tools/search/registry.js +5 -3
- package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
- package/dist/src/agent/tools/xopc-use-tool.js +104 -44
- package/dist/src/automations/service/automation-service.d.ts +0 -4
- package/dist/src/automations/service/automation-service.js +0 -31
- package/dist/src/capabilities/store-connector.js +46 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/project.js +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/schema.d.ts +13 -4
- package/dist/src/config/schema.js +10 -14
- package/dist/src/config/web-patch.js +0 -5
- package/dist/src/connectors/account-selection.d.ts +14 -0
- package/dist/src/connectors/account-selection.js +26 -0
- package/dist/src/connectors/china-catalog.js +93 -226
- package/dist/src/connectors/cli/adapterRegistry.d.ts +4 -0
- package/dist/src/connectors/cli/adapterRegistry.js +26 -0
- package/dist/src/connectors/cli/adapters/lark.d.ts +2 -0
- package/dist/src/connectors/cli/adapters/lark.js +143 -0
- package/dist/src/connectors/cli/adapters/larkShortcuts.d.ts +3 -0
- package/dist/src/connectors/cli/adapters/larkShortcuts.js +64 -0
- package/dist/src/connectors/cli/adapters/wecom.d.ts +2 -0
- package/dist/src/connectors/cli/adapters/wecom.js +97 -0
- package/dist/src/connectors/cli/adapters/wps365/bundle.js +575 -0
- package/dist/src/connectors/cli/adapters/wps365.d.ts +2 -0
- package/dist/src/connectors/cli/adapters/wps365.js +115 -0
- package/dist/src/connectors/cli/assets.d.ts +3 -0
- package/dist/src/connectors/cli/assets.js +44 -0
- package/dist/src/connectors/cli/authorization.d.ts +16 -0
- package/dist/src/connectors/cli/authorization.js +184 -0
- package/dist/src/connectors/cli/distributions.d.ts +4 -0
- package/dist/src/connectors/cli/distributions.js +69 -0
- package/dist/src/connectors/cli/installer.d.ts +5 -0
- package/dist/src/connectors/cli/installer.js +102 -0
- package/dist/src/connectors/cli/lifecycle.d.ts +1 -0
- package/dist/src/connectors/cli/lifecycle.js +19 -0
- package/dist/src/connectors/cli/process.d.ts +18 -0
- package/dist/src/connectors/cli/process.js +100 -0
- package/dist/src/connectors/cli/protocol.d.ts +10 -0
- package/dist/src/connectors/cli/protocol.js +63 -0
- package/dist/src/connectors/cli/runtime.d.ts +10 -0
- package/dist/src/connectors/cli/runtime.js +93 -0
- package/dist/src/connectors/cli/store.d.ts +35 -0
- package/dist/src/connectors/cli/store.js +121 -0
- package/dist/src/connectors/cli/types.d.ts +73 -0
- package/dist/src/connectors/composio-backends.js +1 -1
- package/dist/src/connectors/composio-sessions.d.ts +1 -0
- package/dist/src/connectors/composio-sessions.js +8 -3
- package/dist/src/connectors/composio.js +1 -1
- package/dist/src/connectors/connection-candidates.js +22 -3
- package/dist/src/connectors/connection-recovery-service.d.ts +1 -0
- package/dist/src/connectors/connection-recovery-service.js +53 -8
- package/dist/src/connectors/health.js +52 -0
- package/dist/src/connectors/instances.js +5 -1
- package/dist/src/connectors/lifecycle.js +2 -0
- package/dist/src/connectors/principal.js +2 -1
- package/dist/src/connectors/runtime-adapter-registry.js +31 -0
- package/dist/src/connectors/types.d.ts +13 -1
- package/dist/src/connectors/usage.js +1 -1
- package/dist/src/connectors/workflow-preflight.js +8 -4
- package/dist/src/extensions/install.js +1 -1
- package/dist/src/gateway/hono/app.d.ts +2 -0
- package/dist/src/gateway/hono/app.js +4 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -15
- package/dist/src/gateway/hono/lib/config-payload.js +1 -11
- package/dist/src/gateway/hono/routes/cli-connectors.d.ts +3 -0
- package/dist/src/gateway/hono/routes/cli-connectors.js +219 -0
- package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +2 -2
- package/dist/src/gateway/hono/routes/config-patch/gateway.js +0 -59
- package/dist/src/gateway/hono/routes/config.js +0 -16
- package/dist/src/gateway/hono/routes/connectors.js +21 -22
- package/dist/src/gateway/hono/routes/deps.d.ts +2 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +4 -17
- package/dist/src/gateway/hono/routes/projects.js +1 -1
- package/dist/src/gateway/hono/routes/public-gateway.js +0 -1
- package/dist/src/gateway/hono/routes/scenes.d.ts +3 -0
- package/dist/src/gateway/hono/routes/scenes.js +142 -0
- package/dist/src/gateway/hono/routes/tasks.js +0 -46
- package/dist/src/gateway/hono/routes/user-model.js +54 -1
- package/dist/src/gateway/scenes/browserNotifications.d.ts +4 -0
- package/dist/src/gateway/scenes/browserNotifications.js +54 -0
- package/dist/src/gateway/scenes/host.d.ts +34 -0
- package/dist/src/gateway/scenes/host.js +130 -0
- package/dist/src/gateway/scenes/mailContext.d.ts +32 -0
- package/dist/src/gateway/scenes/mailContext.js +235 -0
- package/dist/src/gateway/security/gateway-scopes.js +0 -4
- package/dist/src/gateway/security/index.js +1 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -10
- package/dist/src/gateway/service/config-coordinator.js +0 -16
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service.d.ts +4 -25
- package/dist/src/gateway/service.js +44 -99
- package/dist/src/gateway/session-context-summary.js +2 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/unhandled-rejections.js +1 -1
- package/dist/src/migrations/runner.js +1 -4
- package/dist/src/notifications/browser-endpoint.d.ts +2 -0
- package/dist/src/notifications/browser-endpoint.js +13 -0
- package/dist/src/notifications/browserSubscriptions.d.ts +20 -0
- package/dist/src/notifications/browserSubscriptions.js +59 -0
- package/dist/src/notifications/browserTransport.d.ts +9 -0
- package/dist/src/notifications/browserTransport.js +64 -0
- package/dist/src/notifications/dispatch.d.ts +46 -0
- package/dist/src/notifications/dispatch.js +109 -0
- package/dist/src/notifications/domain-delivery.d.ts +21 -0
- package/dist/src/notifications/planner.js +0 -36
- package/dist/src/notifications/quietHours.d.ts +6 -0
- package/dist/src/notifications/quietHours.js +23 -0
- package/dist/src/notifications/resultOutbox.d.ts +23 -0
- package/dist/src/notifications/resultOutbox.js +49 -0
- package/dist/src/notifications/service.d.ts +18 -4
- package/dist/src/notifications/service.js +42 -61
- package/dist/src/notifications/store.d.ts +2 -1
- package/dist/src/notifications/store.js +7 -8
- package/dist/src/projects/project-service.d.ts +1 -4
- package/dist/src/projects/project-service.js +2 -30
- package/dist/src/projects/workspace.js +1 -1
- package/dist/src/providers/model-catalog-persistence.js +19 -1
- package/dist/src/providers/model-catalog-store.js +1 -0
- package/dist/src/providers/model-catalog-types.d.ts +17 -0
- package/dist/src/providers/xopc-cloud-model-source.js +27 -0
- package/dist/src/scenes/agentExecutor.d.ts +8 -0
- package/dist/src/scenes/agentExecutor.js +63 -0
- package/dist/src/scenes/contracts.d.ts +118 -0
- package/dist/src/scenes/contracts.js +145 -0
- package/dist/src/scenes/execution.d.ts +56 -0
- package/dist/src/scenes/execution.js +168 -0
- package/dist/src/scenes/httpServices.d.ts +34 -0
- package/dist/src/scenes/inbox.d.ts +16 -0
- package/dist/src/scenes/inbox.js +68 -0
- package/dist/src/scenes/mailContext.d.ts +20 -0
- package/dist/src/scenes/mailContext.js +106 -0
- package/dist/src/scenes/mailObservations.d.ts +20 -0
- package/dist/src/scenes/mailObservations.js +107 -0
- package/dist/src/scenes/maintenance.d.ts +3 -0
- package/dist/src/scenes/maintenance.js +24 -0
- package/dist/src/scenes/metrics.d.ts +37 -0
- package/dist/src/scenes/metrics.js +100 -0
- package/dist/src/scenes/model.d.ts +3 -0
- package/dist/src/scenes/model.js +10 -0
- package/dist/src/scenes/notificationEligibility.d.ts +17 -0
- package/dist/src/scenes/notificationEligibility.js +72 -0
- package/dist/src/scenes/notificationPublication.d.ts +7 -0
- package/dist/src/scenes/notificationPublication.js +43 -0
- package/dist/src/scenes/preferences.d.ts +40 -0
- package/dist/src/scenes/preferences.js +108 -0
- package/dist/src/scenes/readiness.d.ts +7 -0
- package/dist/src/scenes/readiness.js +20 -0
- package/dist/src/scenes/repository.d.ts +174 -0
- package/dist/src/scenes/repository.js +740 -0
- package/dist/src/scenes/resultNotifications.d.ts +17 -0
- package/dist/src/scenes/resultNotifications.js +204 -0
- package/dist/src/scenes/runtime.d.ts +25 -0
- package/dist/src/scenes/runtime.js +101 -0
- package/dist/src/scenes/schedule.d.ts +9 -0
- package/dist/src/scenes/schedule.js +45 -0
- package/dist/src/scenes/service.d.ts +29 -0
- package/dist/src/scenes/service.js +116 -0
- package/dist/src/scenes/templates.d.ts +64 -0
- package/dist/src/scenes/templates.js +76 -0
- package/dist/src/scenes/userNotes.d.ts +10 -0
- package/dist/src/scenes/userNotes.js +34 -0
- package/dist/src/session/resolve-session.js +2 -1
- package/dist/src/session/store.js +2 -1
- package/dist/src/share/share-config.js +0 -5
- package/dist/src/share/site-share-config.js +0 -5
- package/dist/src/storage/sqlite/connection-wait-repository.js +20 -7
- package/dist/src/storage/sqlite/connection.js +1 -1
- package/dist/src/storage/sqlite/connector-account-repository.js +1 -0
- package/dist/src/storage/sqlite/connector-sync-policy-repository.d.ts +0 -4
- package/dist/src/storage/sqlite/connector-sync-policy-repository.js +3 -17
- package/dist/src/storage/sqlite/conversation-repository.js +2 -1
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/migrations/187_cli_connectors.sql +34 -0
- package/dist/src/storage/sqlite/migrations/188_scene_storage.sql +2 -0
- package/dist/src/storage/sqlite/migrations/189_scene_source_health.sql +8 -0
- package/dist/src/storage/sqlite/migrations/conversation-backup.d.ts +2 -0
- package/dist/src/storage/sqlite/migrations/conversation-backup.js +7 -3
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +20 -44
- package/dist/src/storage/sqlite/migrations/scene-reset.d.ts +5 -0
- package/dist/src/storage/sqlite/migrations/scene-reset.js +40 -0
- package/dist/src/storage/sqlite/scenes-schema.d.ts +8 -0
- package/dist/src/storage/sqlite/scenes-schema.js +61 -0
- package/dist/src/storage/sqlite/schema.js +4 -10
- package/dist/src/storage/sqlite/schemas/notifications.sql +65 -0
- package/dist/src/storage/sqlite/schemas/scenes.sql +212 -0
- package/dist/src/storage/sqlite/session-read-repository.d.ts +8 -0
- package/dist/src/storage/sqlite/session-read-repository.js +35 -0
- package/dist/src/storage/sqlite/session-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-repository.js +2 -25
- package/dist/src/storage/sqlite/sql-assets.d.ts +2 -0
- package/dist/src/storage/sqlite/sql-assets.js +18 -0
- package/dist/src/storage/sqlite/transaction.d.ts +2 -0
- package/dist/src/storage/sqlite/transaction.js +20 -1
- package/dist/src/tasks/home-query-service.d.ts +0 -2
- package/dist/src/tasks/home-query-service.js +13 -43
- package/dist/src/tasks/index.d.ts +0 -1
- package/dist/src/tasks/index.js +4 -5
- package/dist/src/tasks/project-operating-view-service.js +1 -4
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/user-model/goals.d.ts +10 -0
- package/dist/src/user-model/goals.js +29 -1
- package/dist/src/user-model/index.js +2 -2
- package/dist/src/voice/realtime/memory-context.js +2 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +5 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-f0-YFMUz.js +0 -1
- package/dist/gateway/static/root/assets/api-CN4id43t.js +0 -1
- package/dist/gateway/static/root/assets/app-link-BiBXVEvp.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-CexHOcWg.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-onJPfmO6.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BgVTyPFY.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Dra8wj1S.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-CkxiMDJ4.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-Dtder4G_.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-DHerePwo.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-cl9ZrV4D.js +0 -2
- package/dist/gateway/static/root/assets/cron-expression-DAhdv_Xv.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-PacO1m3a.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-Gy03NgMI.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-aV25nKag.js +0 -1
- package/dist/gateway/static/root/assets/external-link-DjqjBmc3.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BG95uGVW.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Dcr2Ikeh.js +0 -1
- package/dist/gateway/static/root/assets/globe-DSSGFWFn.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DOy3alvT.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CDm3dGVy.js +0 -1
- package/dist/gateway/static/root/assets/index-D-vczw_0.css +0 -1
- package/dist/gateway/static/root/assets/index-DJo4DimT.js +0 -79
- package/dist/gateway/static/root/assets/loader-circle-CifKLtgG.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CwLvTwjn.js +0 -2
- package/dist/gateway/static/root/assets/markdown-view-Y68dCxuc.css +0 -1
- package/dist/gateway/static/root/assets/messages-BiYTyLJr.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-c2k5Uz6X.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BLQWJMhf.js +0 -8
- package/dist/gateway/static/root/assets/preview-open-alternatives-9B5W7nVE.js +0 -1
- package/dist/gateway/static/root/assets/proactive-page-iOjI0d_e.js +0 -1
- package/dist/gateway/static/root/assets/product-delivery-CCC4FJ3Y.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-BcxbQn2M.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BuSvld0O.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CFS8LQKW.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DZjc__ok.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C1SM5B93.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-CxRWyWYe.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-layout-X1x-2Cp9.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-D9Rl7Tec.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CwCThBs0.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DG6VGbOX.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BdRJ2vnL.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-DXIZpAvU.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-QXo9LJly.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-Db2guRdW.js +0 -1
- package/dist/gateway/static/root/assets/use-autosave-DDY9qoXZ.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-CzPmMkaO.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-CQXtiYtq.js +0 -6
- package/dist/gateway/static/root/connector-icons/wps-calendar.svg +0 -14
- package/dist/gateway/static/root/connector-icons/wps-mail.svg +0 -7
- package/dist/src/connectors/source-change-publisher.d.ts +0 -17
- package/dist/src/connectors/source-change-publisher.js +0 -151
- package/dist/src/gateway/heartbeat/check-store.d.ts +0 -18
- package/dist/src/gateway/heartbeat/check-store.js +0 -74
- package/dist/src/gateway/heartbeat/index.d.ts +0 -1
- package/dist/src/gateway/heartbeat/index.js +0 -2
- package/dist/src/gateway/heartbeat/service.d.ts +0 -55
- package/dist/src/gateway/heartbeat/service.js +0 -228
- package/dist/src/gateway/hono/routes/proactive-control.d.ts +0 -3
- package/dist/src/gateway/hono/routes/proactive-control.js +0 -135
- package/dist/src/gateway/hono/routes/proactive.d.ts +0 -4
- package/dist/src/gateway/hono/routes/proactive.js +0 -164
- package/dist/src/gateway/hono/routes/workspace.d.ts +0 -3
- package/dist/src/gateway/hono/routes/workspace.js +0 -62
- package/dist/src/gateway/workspace-heartbeat-path.d.ts +0 -3
- package/dist/src/gateway/workspace-heartbeat-path.js +0 -14
- package/dist/src/migrations/conversation-routing-config.d.ts +0 -2
- package/dist/src/migrations/conversation-routing-config.js +0 -42
- package/dist/src/notifications/proactive-channel.d.ts +0 -8
- package/dist/src/notifications/proactive-channel.js +0 -60
- package/dist/src/notifications/proactive-policy.d.ts +0 -3
- package/dist/src/notifications/proactive-policy.js +0 -35
- package/dist/src/notifications/web-push.d.ts +0 -19
- package/dist/src/notifications/web-push.js +0 -185
- package/dist/src/proactive/actions/service.d.ts +0 -1
- package/dist/src/proactive/actions/service.js +0 -82
- package/dist/src/proactive/events/envelope.d.ts +0 -2
- package/dist/src/proactive/events/envelope.js +0 -54
- package/dist/src/proactive/events/product-event-bridge.d.ts +0 -7
- package/dist/src/proactive/events/product-event-bridge.js +0 -87
- package/dist/src/proactive/events/publisher.d.ts +0 -4
- package/dist/src/proactive/events/repository.d.ts +0 -9
- package/dist/src/proactive/events/repository.js +0 -63
- package/dist/src/proactive/events/types.d.ts +0 -44
- package/dist/src/proactive/events/types.js +0 -15
- package/dist/src/proactive/execution/agent-executor.d.ts +0 -21
- package/dist/src/proactive/execution/agent-executor.js +0 -125
- package/dist/src/proactive/execution/authorization.d.ts +0 -7
- package/dist/src/proactive/execution/authorization.js +0 -71
- package/dist/src/proactive/execution/context.d.ts +0 -49
- package/dist/src/proactive/execution/context.js +0 -408
- package/dist/src/proactive/execution/insight.d.ts +0 -14
- package/dist/src/proactive/execution/insight.js +0 -132
- package/dist/src/proactive/execution/repository.d.ts +0 -28
- package/dist/src/proactive/execution/repository.js +0 -211
- package/dist/src/proactive/execution/types.d.ts +0 -80
- package/dist/src/proactive/execution/worker.d.ts +0 -15
- package/dist/src/proactive/execution/worker.js +0 -146
- package/dist/src/proactive/experience.d.ts +0 -89
- package/dist/src/proactive/experience.js +0 -195
- package/dist/src/proactive/follow-ups.d.ts +0 -128
- package/dist/src/proactive/follow-ups.js +0 -182
- package/dist/src/proactive/inbox/cards.d.ts +0 -21
- package/dist/src/proactive/inbox/cards.js +0 -276
- package/dist/src/proactive/inbox/delivery.d.ts +0 -6
- package/dist/src/proactive/inbox/delivery.js +0 -54
- package/dist/src/proactive/inbox/digest.d.ts +0 -8
- package/dist/src/proactive/inbox/digest.js +0 -123
- package/dist/src/proactive/inbox/lifecycle.d.ts +0 -4
- package/dist/src/proactive/inbox/lifecycle.js +0 -62
- package/dist/src/proactive/inbox/notification-policy.d.ts +0 -1
- package/dist/src/proactive/inbox/notification-policy.js +0 -25
- package/dist/src/proactive/inbox/repository.d.ts +0 -25
- package/dist/src/proactive/inbox/repository.js +0 -244
- package/dist/src/proactive/inbox/service.d.ts +0 -23
- package/dist/src/proactive/inbox/service.js +0 -46
- package/dist/src/proactive/inbox/types.d.ts +0 -64
- package/dist/src/proactive/inbox/worker.d.ts +0 -13
- package/dist/src/proactive/inbox/worker.js +0 -71
- package/dist/src/proactive/index.d.ts +0 -20
- package/dist/src/proactive/index.js +0 -14
- package/dist/src/proactive/mail-thread.d.ts +0 -13
- package/dist/src/proactive/mail-thread.js +0 -55
- package/dist/src/proactive/maintenance.d.ts +0 -4
- package/dist/src/proactive/maintenance.js +0 -28
- package/dist/src/proactive/metrics.d.ts +0 -10
- package/dist/src/proactive/metrics.js +0 -28
- package/dist/src/proactive/policy/presence.d.ts +0 -2
- package/dist/src/proactive/policy/presence.js +0 -30
- package/dist/src/proactive/policy/service.d.ts +0 -54
- package/dist/src/proactive/policy/service.js +0 -123
- package/dist/src/proactive/routing/batch-repository.d.ts +0 -27
- package/dist/src/proactive/routing/batch-repository.js +0 -57
- package/dist/src/proactive/routing/matcher.d.ts +0 -5
- package/dist/src/proactive/routing/matcher.js +0 -57
- package/dist/src/proactive/routing/types.d.ts +0 -44
- package/dist/src/proactive/routing/types.js +0 -1
- package/dist/src/proactive/scenarios/control.d.ts +0 -52
- package/dist/src/proactive/scenarios/control.js +0 -75
- package/dist/src/proactive/scenarios/prompt-composer.d.ts +0 -14
- package/dist/src/proactive/scenarios/prompt-composer.js +0 -26
- package/dist/src/proactive/scenarios/repository.d.ts +0 -23
- package/dist/src/proactive/scenarios/repository.js +0 -174
- package/dist/src/proactive/scenarios/service.d.ts +0 -15
- package/dist/src/proactive/scenarios/service.js +0 -26
- package/dist/src/proactive/scenarios/types.d.ts +0 -43
- package/dist/src/proactive/scenarios/types.js +0 -1
- package/dist/src/proactive/service.d.ts +0 -25
- package/dist/src/proactive/service.js +0 -78
- package/dist/src/proactive/source-freshness.d.ts +0 -8
- package/dist/src/proactive/source-freshness.js +0 -28
- package/dist/src/proactive/status.d.ts +0 -2
- package/dist/src/proactive/status.js +0 -22
- package/dist/src/proactive/temporal/schedule.d.ts +0 -3
- package/dist/src/proactive/temporal/schedule.js +0 -68
- package/dist/src/proactive/temporal/worker.d.ts +0 -17
- package/dist/src/proactive/temporal/worker.js +0 -129
- package/dist/src/tasks/project-monitoring-service.d.ts +0 -32
- package/dist/src/tasks/project-monitoring-service.js +0 -118
- /package/dist/src/{proactive/execution → connectors/cli}/types.js +0 -0
- /package/dist/src/{proactive/events/publisher.js → notifications/domain-delivery.js} +0 -0
- /package/dist/src/{proactive/inbox/types.js → scenes/httpServices.js} +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { CliProtocolError, actionRevision, closedSchema, object, parseJson } from "../protocol.js";
|
|
2
|
+
import { WPS365_DISTRIBUTIONS } from "../distributions.js";
|
|
3
|
+
import { actions, assets, version } from "./wps365/bundle.js";
|
|
4
|
+
//#region src/connectors/cli/adapters/wps365.ts
|
|
5
|
+
function decodeAuthorization(output) {
|
|
6
|
+
if (output.exitCode !== 0) decodeResult(output);
|
|
7
|
+
}
|
|
8
|
+
const contracts = new Map(actions.map((action) => [action.id, action]));
|
|
9
|
+
const staticActions = Object.fromEntries(actions.map((action) => [action.id, {
|
|
10
|
+
id: action.id,
|
|
11
|
+
description: `WPS 365: ${action.description}`,
|
|
12
|
+
scope: "read",
|
|
13
|
+
requiredScopes: [],
|
|
14
|
+
inputSchema: closedSchema(action.inputSchema),
|
|
15
|
+
revision: actionRevision({
|
|
16
|
+
action,
|
|
17
|
+
specs: assets.map((asset) => asset.sha256),
|
|
18
|
+
version
|
|
19
|
+
})
|
|
20
|
+
}]));
|
|
21
|
+
function decodeResult(output) {
|
|
22
|
+
if (output.exitCode !== 0) {
|
|
23
|
+
const diagnostic = `${output.stdout}\n${output.stderr}`;
|
|
24
|
+
if (/403000001|ErrPrivileges|interface_company_doc/.test(diagnostic)) throw new Error("WPS enterprise subscription does not include this capability. Contact the enterprise administrator; reconnecting will not resolve it.");
|
|
25
|
+
if (/not logged in|invalid_grant|expired|revoked/i.test(diagnostic)) throw new Error("WPS user authorization is unavailable or expired. Reconnect this account.");
|
|
26
|
+
if (/scope|permission|forbidden/i.test(diagnostic)) throw new Error("WPS permission is missing. Check application publication, administrator approval and data access scope.");
|
|
27
|
+
throw new Error(`WPS command failed (exit ${output.exitCode}). Check connection and enterprise permissions.`);
|
|
28
|
+
}
|
|
29
|
+
const row = object(parseJson(output.stdout));
|
|
30
|
+
if (typeof row.code !== "number") throw new CliProtocolError("Missing WPS response status.");
|
|
31
|
+
if (row.code !== 0) {
|
|
32
|
+
if (row.code === 403000001) throw new Error("WPS enterprise subscription does not include this capability. Contact the enterprise administrator.");
|
|
33
|
+
throw new Error(`WPS rejected the request (code ${row.code}). Check enterprise permissions.`);
|
|
34
|
+
}
|
|
35
|
+
if (!("data" in row)) throw new CliProtocolError("Missing WPS response data.");
|
|
36
|
+
return row.data;
|
|
37
|
+
}
|
|
38
|
+
const wps365Adapter = {
|
|
39
|
+
id: "wps365",
|
|
40
|
+
version: "1",
|
|
41
|
+
binaryVersion: version,
|
|
42
|
+
executable: "wps365-cli",
|
|
43
|
+
distributions: WPS365_DISTRIBUTIONS,
|
|
44
|
+
configEnvironment: "WPS365_CONFIG_DIR",
|
|
45
|
+
environment: { WPS365_KEYRING_BACKEND: "file" },
|
|
46
|
+
configAssets: assets,
|
|
47
|
+
staticActions,
|
|
48
|
+
curatedActions: Object.fromEntries(actions.map((action) => [action.id, "read"])),
|
|
49
|
+
schemaArgs: () => {
|
|
50
|
+
throw new Error("WPS uses packaged action contracts.");
|
|
51
|
+
},
|
|
52
|
+
decodeSchema: () => {
|
|
53
|
+
throw new Error("WPS uses packaged action contracts.");
|
|
54
|
+
},
|
|
55
|
+
actionArgs(action, input) {
|
|
56
|
+
const contract = contracts.get(action.id);
|
|
57
|
+
if (!contract) throw new Error("WPS action is not enabled.");
|
|
58
|
+
const args = [
|
|
59
|
+
...contract.command,
|
|
60
|
+
"--token-type",
|
|
61
|
+
"delegated",
|
|
62
|
+
"--output",
|
|
63
|
+
"json"
|
|
64
|
+
];
|
|
65
|
+
for (const [name, value] of Object.entries(input)) {
|
|
66
|
+
if (!(name in contract.inputSchema.properties) || name === "token_type") throw new Error("Unsupported WPS argument.");
|
|
67
|
+
if (!contract.positionals.includes(name)) args.push(`--${name}=${Array.isArray(value) ? value.join(",") : String(value)}`);
|
|
68
|
+
}
|
|
69
|
+
if (contract.positionals.length) args.push("--", ...contract.positionals.map((name) => String(input[name])));
|
|
70
|
+
return args;
|
|
71
|
+
},
|
|
72
|
+
decodeResult,
|
|
73
|
+
statusArgs: [
|
|
74
|
+
"user",
|
|
75
|
+
"me",
|
|
76
|
+
"--token-type",
|
|
77
|
+
"delegated",
|
|
78
|
+
"--output",
|
|
79
|
+
"json"
|
|
80
|
+
],
|
|
81
|
+
decodeIdentity(output) {
|
|
82
|
+
if (output.timedOut || output.aborted || output.outputTruncated) throw new Error("WPS identity verification did not complete.");
|
|
83
|
+
const user = object(decodeResult(output));
|
|
84
|
+
if (typeof user.id !== "string" || !user.id || typeof user.company_id !== "string" || !user.company_id) throw new CliProtocolError("Missing WPS user or enterprise identity.");
|
|
85
|
+
return {
|
|
86
|
+
key: `${user.company_id}:${user.id}`,
|
|
87
|
+
label: typeof user.user_name === "string" ? user.user_name : user.id,
|
|
88
|
+
scopes: [],
|
|
89
|
+
identity: {
|
|
90
|
+
userId: user.id,
|
|
91
|
+
companyId: user.company_id,
|
|
92
|
+
name: user.user_name,
|
|
93
|
+
kind: "user"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
authorizationSteps: [{
|
|
98
|
+
decodeResult: decodeAuthorization,
|
|
99
|
+
initialOnly: true,
|
|
100
|
+
args: ["config", "init"],
|
|
101
|
+
challenge: "url",
|
|
102
|
+
urlHosts: ["open.wps.cn", "openapi.wps.cn"]
|
|
103
|
+
}, {
|
|
104
|
+
decodeResult: decodeAuthorization,
|
|
105
|
+
args: [
|
|
106
|
+
"auth",
|
|
107
|
+
"login",
|
|
108
|
+
"--device"
|
|
109
|
+
],
|
|
110
|
+
challenge: "url",
|
|
111
|
+
urlHosts: ["open.wps.cn", "openapi.wps.cn"]
|
|
112
|
+
}]
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
export { wps365Adapter };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { link, lstat, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
//#region src/connectors/cli/assets.ts
|
|
5
|
+
const digest = (content) => createHash("sha256").update(content).digest("hex");
|
|
6
|
+
/** Install immutable, packaged provider specifications without touching credentials. */
|
|
7
|
+
async function prepareCliAssets(adapter, configPath) {
|
|
8
|
+
if (!adapter.configAssets?.length) return;
|
|
9
|
+
const root = await lstat(configPath);
|
|
10
|
+
if (!root.isDirectory() || root.isSymbolicLink()) throw new Error("Invalid CLI config directory.");
|
|
11
|
+
for (const asset of adapter.configAssets) {
|
|
12
|
+
const parts = asset.path.split("/");
|
|
13
|
+
if (!parts.length || parts.some((part) => !/^[a-zA-Z0-9_.-]+$/.test(part) || part === "." || part === "..") || digest(asset.content) !== asset.sha256) throw new Error("Invalid packaged CLI asset.");
|
|
14
|
+
let parent = configPath;
|
|
15
|
+
for (const part of parts.slice(0, -1)) {
|
|
16
|
+
parent = join(parent, part);
|
|
17
|
+
await mkdir(parent, {
|
|
18
|
+
recursive: true,
|
|
19
|
+
mode: 448
|
|
20
|
+
});
|
|
21
|
+
const info = await lstat(parent);
|
|
22
|
+
if (!info.isDirectory() || info.isSymbolicLink()) throw new Error("Invalid CLI asset directory.");
|
|
23
|
+
}
|
|
24
|
+
const path = join(configPath, asset.path);
|
|
25
|
+
const temporary = join(parent, `.asset-${randomUUID()}`);
|
|
26
|
+
try {
|
|
27
|
+
await writeFile(temporary, asset.content, {
|
|
28
|
+
flag: "wx",
|
|
29
|
+
mode: 384
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
await link(temporary, path);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (error.code !== "EEXIST") throw error;
|
|
35
|
+
}
|
|
36
|
+
} finally {
|
|
37
|
+
await rm(temporary, { force: true });
|
|
38
|
+
}
|
|
39
|
+
const info = await lstat(path);
|
|
40
|
+
if (!info.isFile() || info.isSymbolicLink() || info.size > Buffer.byteLength(asset.content) || digest(await readFile(path, "utf8")) !== asset.sha256) throw new Error("CLI specification integrity mismatch. Reconnect using a new account context.");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { prepareCliAssets };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Config } from '../../config/schema.js';
|
|
2
|
+
import type { CliAdapter } from './types.js';
|
|
3
|
+
export declare function requireCliInstance(config: Config, instanceId: string, options?: {
|
|
4
|
+
allowDisabled?: boolean;
|
|
5
|
+
}): CliAdapter;
|
|
6
|
+
export declare function extractAuthorizationUrl(text: string, allowedHosts: readonly string[], field?: string): string | undefined;
|
|
7
|
+
export declare function startCliAuthorization(config: Config, instanceId: string, expectedAccountId?: string): {
|
|
8
|
+
id: string;
|
|
9
|
+
status: "failed" | "succeeded" | "expired" | "cancelled" | "verifying" | "awaiting_user" | "preparing";
|
|
10
|
+
challenge: import("./types.js").CliChallenge;
|
|
11
|
+
error: string;
|
|
12
|
+
accountId: string;
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function cancelCliAuthorization(id: string): void;
|
|
16
|
+
export declare function cancelCliInstanceAuthorizations(instanceId: string): void;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { getConnectorAccount, init_connector_account_repository } from "../../storage/sqlite/connector-account-repository.js";
|
|
4
|
+
import { getConnectorConnection, getConnectorInstallation, init_connector_repository, upsertConnectorInstallation } from "../../storage/sqlite/connector-repository.js";
|
|
5
|
+
import { cliContextPath, startCliProcess } from "./process.js";
|
|
6
|
+
import { getCliAdapter } from "./adapterRegistry.js";
|
|
7
|
+
import { getConnectorInstance, getInstalledConnectorDefinition } from "../instances.js";
|
|
8
|
+
import { verifyInstalledCli } from "./installer.js";
|
|
9
|
+
import { cliAuthorizationView, commitCliIdentity, createCliAuthorization, readCliAuthorization, updateCliAuthorization } from "./store.js";
|
|
10
|
+
import { join, relative } from "node:path";
|
|
11
|
+
import { cp, rm, stat } from "node:fs/promises";
|
|
12
|
+
//#region src/connectors/cli/authorization.ts
|
|
13
|
+
init_connector_repository();
|
|
14
|
+
init_connector_account_repository();
|
|
15
|
+
init_logger();
|
|
16
|
+
const log = createLogger("CliConnectorAuth");
|
|
17
|
+
const controllers = /* @__PURE__ */ new Map();
|
|
18
|
+
function requireCliInstance(config, instanceId, options = {}) {
|
|
19
|
+
const instance = getConnectorInstance(config, instanceId);
|
|
20
|
+
const definition = getInstalledConnectorDefinition(config, instanceId);
|
|
21
|
+
if (!instance || !options.allowDisabled && !instance.enabled || definition?.runtime.type !== "cli") throw new Error("CLI connector is not installed or is disabled.");
|
|
22
|
+
const adapter = getCliAdapter(definition.runtime.adapterId);
|
|
23
|
+
if (definition.runtime.adapterVersion !== adapter.version || definition.runtime.binaryVersion !== adapter.binaryVersion) throw new Error("CLI connector version does not match its adapter. Reinstall the connector.");
|
|
24
|
+
return adapter;
|
|
25
|
+
}
|
|
26
|
+
function extractAuthorizationUrl(text, allowedHosts, field) {
|
|
27
|
+
const candidates = [];
|
|
28
|
+
if (field) for (const line of text.split("\n")) try {
|
|
29
|
+
const event = JSON.parse(line);
|
|
30
|
+
if (typeof event?.[field] === "string") candidates.push(event[field]);
|
|
31
|
+
} catch {}
|
|
32
|
+
else for (const match of text.matchAll(/https:\/\/[^\s"<>\\]+(?=[\s"<>])/g)) candidates.push(match[0]);
|
|
33
|
+
for (const candidate of candidates) try {
|
|
34
|
+
const url = new URL(candidate);
|
|
35
|
+
if (url.protocol === "https:" && !url.port && allowedHosts.includes(url.hostname) && !url.username && !url.password) return url.href;
|
|
36
|
+
} catch {}
|
|
37
|
+
}
|
|
38
|
+
async function authorize(adapter, attempt, signal) {
|
|
39
|
+
let committed = false;
|
|
40
|
+
try {
|
|
41
|
+
const executable = await verifyInstalledCli(adapter);
|
|
42
|
+
const previous = attempt.expected_account_id ? getConnectorAccount(attempt.expected_account_id) : void 0;
|
|
43
|
+
const previousConnection = previous?.currentConnectionId ? getConnectorConnection(previous.currentConnectionId) : void 0;
|
|
44
|
+
if (previousConnection) {
|
|
45
|
+
if (previousConnection.provider !== "cli" || previousConnection.metadata.runtimeInstanceId !== attempt.instance_id) throw new Error("Account belongs to another CLI instance.");
|
|
46
|
+
await cp(cliContextPath(String(previousConnection.metadata.contextId)), cliContextPath(attempt.context_id), {
|
|
47
|
+
recursive: true,
|
|
48
|
+
errorOnExist: true,
|
|
49
|
+
force: false,
|
|
50
|
+
filter: (source) => relative(cliContextPath(String(previousConnection.metadata.contextId)), source) !== "files"
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const steps = previousConnection ? adapter.authorizationSteps.filter((step) => !step.initialOnly) : adapter.authorizationSteps;
|
|
54
|
+
for (const [index, step] of steps.entries()) {
|
|
55
|
+
const progress = {
|
|
56
|
+
step: index + 1,
|
|
57
|
+
totalSteps: steps.length
|
|
58
|
+
};
|
|
59
|
+
signal.throwIfAborted();
|
|
60
|
+
updateCliAuthorization(attempt.id, { phase: "preparing" });
|
|
61
|
+
let output = "";
|
|
62
|
+
let challengePublished = false;
|
|
63
|
+
const handle = await startCliProcess({
|
|
64
|
+
adapter,
|
|
65
|
+
executable,
|
|
66
|
+
contextId: attempt.context_id,
|
|
67
|
+
args: step.args,
|
|
68
|
+
signal,
|
|
69
|
+
timeoutMs: Math.max(1, attempt.expires_at - Date.now()),
|
|
70
|
+
onOutput(_stream, chunk) {
|
|
71
|
+
if (step.challenge !== "url" || challengePublished) return;
|
|
72
|
+
output = (output + chunk.toString("utf8")).slice(-32768);
|
|
73
|
+
const url = extractAuthorizationUrl(output, step.urlHosts ?? [], step.urlField);
|
|
74
|
+
if (url) challengePublished = updateCliAuthorization(attempt.id, {
|
|
75
|
+
phase: "awaiting_user",
|
|
76
|
+
challenge: {
|
|
77
|
+
type: "open_url",
|
|
78
|
+
url,
|
|
79
|
+
...progress
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const qrTimer = step.challenge === "qr" ? setInterval(() => {
|
|
85
|
+
if (challengePublished) return;
|
|
86
|
+
stat(join(cliContextPath(attempt.context_id), "files", "authorization.png")).then((info) => {
|
|
87
|
+
if (info.isFile() && info.size > 0 && !signal.aborted) challengePublished = updateCliAuthorization(attempt.id, {
|
|
88
|
+
phase: "awaiting_user",
|
|
89
|
+
challenge: {
|
|
90
|
+
type: "qr_code",
|
|
91
|
+
artifactId: attempt.id,
|
|
92
|
+
...progress
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}).catch(() => void 0);
|
|
96
|
+
}, 300) : void 0;
|
|
97
|
+
let result;
|
|
98
|
+
try {
|
|
99
|
+
result = await handle.completion;
|
|
100
|
+
} finally {
|
|
101
|
+
if (qrTimer) clearInterval(qrTimer);
|
|
102
|
+
}
|
|
103
|
+
if (!step.decodeResult && result.exitCode !== 0 || result.timedOut || result.aborted || result.outputTruncated) {
|
|
104
|
+
log.warn({
|
|
105
|
+
attemptId: attempt.id,
|
|
106
|
+
step: index + 1,
|
|
107
|
+
exitCode: result.exitCode,
|
|
108
|
+
timedOut: result.timedOut,
|
|
109
|
+
aborted: result.aborted,
|
|
110
|
+
outputTruncated: result.outputTruncated
|
|
111
|
+
}, "CLI authorization step did not complete");
|
|
112
|
+
throw new Error(`Authorization step ${index + 1}/${steps.length} ${result.timedOut ? "timed out" : "failed"}. Retry authorization.`);
|
|
113
|
+
}
|
|
114
|
+
step.decodeResult?.(result);
|
|
115
|
+
}
|
|
116
|
+
signal.throwIfAborted();
|
|
117
|
+
if (!updateCliAuthorization(attempt.id, { phase: "verifying" })) throw new Error("Authorization was cancelled.");
|
|
118
|
+
const probe = await startCliProcess({
|
|
119
|
+
adapter,
|
|
120
|
+
executable,
|
|
121
|
+
contextId: attempt.context_id,
|
|
122
|
+
args: adapter.statusArgs,
|
|
123
|
+
signal
|
|
124
|
+
});
|
|
125
|
+
const identity = adapter.decodeIdentity(await probe.completion);
|
|
126
|
+
signal.throwIfAborted();
|
|
127
|
+
commitCliIdentity(attempt, identity);
|
|
128
|
+
committed = true;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
const message = error instanceof Error ? error.message : "Authorization failed.";
|
|
131
|
+
updateCliAuthorization(attempt.id, {
|
|
132
|
+
phase: signal.aborted ? "cancelled" : "failed",
|
|
133
|
+
error: message
|
|
134
|
+
});
|
|
135
|
+
log.warn({
|
|
136
|
+
attemptId: attempt.id,
|
|
137
|
+
connectorId: attempt.connector_id,
|
|
138
|
+
errorMessage: message
|
|
139
|
+
}, "CLI authorization did not complete");
|
|
140
|
+
} finally {
|
|
141
|
+
controllers.delete(attempt.id);
|
|
142
|
+
if (!committed) await rm(cliContextPath(attempt.context_id), {
|
|
143
|
+
recursive: true,
|
|
144
|
+
force: true
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function startCliAuthorization(config, instanceId, expectedAccountId) {
|
|
149
|
+
const adapter = requireCliInstance(config, instanceId);
|
|
150
|
+
const definition = getInstalledConnectorDefinition(config, instanceId);
|
|
151
|
+
if (expectedAccountId) {
|
|
152
|
+
const account = getConnectorAccount(expectedAccountId);
|
|
153
|
+
if (!account || account.connectorId !== definition.id) throw new Error("Invalid account.");
|
|
154
|
+
}
|
|
155
|
+
const installationId = `${definition.id}-local-owner`;
|
|
156
|
+
if (!getConnectorInstallation(installationId)) upsertConnectorInstallation({
|
|
157
|
+
id: installationId,
|
|
158
|
+
connectorId: definition.id,
|
|
159
|
+
principalId: "local-owner",
|
|
160
|
+
enabled: true,
|
|
161
|
+
allowedAgentIds: [],
|
|
162
|
+
maxScope: "read",
|
|
163
|
+
confirmationPolicy: "writes",
|
|
164
|
+
selectedAccountIds: null
|
|
165
|
+
});
|
|
166
|
+
const attempt = createCliAuthorization(instanceId, definition.id, expectedAccountId);
|
|
167
|
+
const controller = new AbortController();
|
|
168
|
+
controllers.set(attempt.id, controller);
|
|
169
|
+
authorize(adapter, attempt, controller.signal).catch((error) => log.error({
|
|
170
|
+
err: error,
|
|
171
|
+
attemptId: attempt.id
|
|
172
|
+
}, "CLI authorization cleanup failed"));
|
|
173
|
+
return cliAuthorizationView(attempt);
|
|
174
|
+
}
|
|
175
|
+
function cancelCliAuthorization(id) {
|
|
176
|
+
if (!readCliAuthorization(id)) throw new Error("Authorization not found.");
|
|
177
|
+
updateCliAuthorization(id, { phase: "cancelled" });
|
|
178
|
+
controllers.get(id)?.abort();
|
|
179
|
+
}
|
|
180
|
+
function cancelCliInstanceAuthorizations(instanceId) {
|
|
181
|
+
for (const id of controllers.keys()) if (readCliAuthorization(id)?.instance_id === instanceId) cancelCliAuthorization(id);
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
export { cancelCliAuthorization, cancelCliInstanceAuthorizations, extractAuthorizationUrl, requireCliInstance, startCliAuthorization };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CliDistribution } from './types.js';
|
|
2
|
+
export declare const LARK_DISTRIBUTIONS: Record<string, CliDistribution>;
|
|
3
|
+
export declare const WECOM_DISTRIBUTIONS: Record<string, CliDistribution>;
|
|
4
|
+
export declare const WPS365_DISTRIBUTIONS: Record<string, CliDistribution>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/connectors/cli/distributions.ts
|
|
2
|
+
const LARK_DISTRIBUTIONS = {
|
|
3
|
+
"darwin-x64": {
|
|
4
|
+
"url": "https://github.com/larksuite/cli/releases/download/v1.0.96/lark-cli-1.0.96-darwin-amd64.tar.gz",
|
|
5
|
+
"integrity": "sha256-f6bd28263dfc4a4d6c2581657efa6af8e8f92eba22394c9c4d840d4ad1fae65e",
|
|
6
|
+
"archiveEntry": "lark-cli"
|
|
7
|
+
},
|
|
8
|
+
"darwin-arm64": {
|
|
9
|
+
"url": "https://github.com/larksuite/cli/releases/download/v1.0.96/lark-cli-1.0.96-darwin-arm64.tar.gz",
|
|
10
|
+
"integrity": "sha256-124acdf380f72fa4b1b1e8307a0b00ee93217cf9558baca5bc40091304f2adcd",
|
|
11
|
+
"archiveEntry": "lark-cli"
|
|
12
|
+
},
|
|
13
|
+
"linux-x64": {
|
|
14
|
+
"url": "https://github.com/larksuite/cli/releases/download/v1.0.96/lark-cli-1.0.96-linux-amd64.tar.gz",
|
|
15
|
+
"integrity": "sha256-5d1fa96832307b13298fdb11c477ab3f31c3e98026fec585b4b2eb7f63960c36",
|
|
16
|
+
"archiveEntry": "lark-cli"
|
|
17
|
+
},
|
|
18
|
+
"linux-arm64": {
|
|
19
|
+
"url": "https://github.com/larksuite/cli/releases/download/v1.0.96/lark-cli-1.0.96-linux-arm64.tar.gz",
|
|
20
|
+
"integrity": "sha256-a83124bad70ddb5a42c8d10a80e8d52f49913b1cb397c7a0a835bd0ddb65f3e2",
|
|
21
|
+
"archiveEntry": "lark-cli"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const WECOM_DISTRIBUTIONS = {
|
|
25
|
+
"linux-x64": {
|
|
26
|
+
"url": "https://registry.npmjs.org/@wecom/cli-linux-x64/-/cli-linux-x64-1.3.0.tgz",
|
|
27
|
+
"integrity": "sha512-kJOub+Gg+wa+K4f21pDyrLtaZK/cPOSrYkm1iST/PfrK66urNKHv7GIEtRUcD4WvKL7yxfyl+QwxyNsMixLAAA==",
|
|
28
|
+
"archiveEntry": "package/bin/wecom-cli"
|
|
29
|
+
},
|
|
30
|
+
"darwin-arm64": {
|
|
31
|
+
"url": "https://registry.npmjs.org/@wecom/cli-darwin-arm64/-/cli-darwin-arm64-1.3.0.tgz",
|
|
32
|
+
"integrity": "sha512-DXMSKg3YOF+raHyFeTIFncq3njViWV2dpGltrFvC3Ao6inUFPAbw5mHtgEMFZLlCprmeKshhhOAetn5TqiugjQ==",
|
|
33
|
+
"archiveEntry": "package/bin/wecom-cli"
|
|
34
|
+
},
|
|
35
|
+
"darwin-x64": {
|
|
36
|
+
"url": "https://registry.npmjs.org/@wecom/cli-darwin-x64/-/cli-darwin-x64-1.3.0.tgz",
|
|
37
|
+
"integrity": "sha512-j4Uak8gVfT9/lwDCSwT6RqTKED5YLM818I/DL5U66U45gFds/ztMzWKjmpYbRs7uxE1NzQli/H2/WmD6G27OAg==",
|
|
38
|
+
"archiveEntry": "package/bin/wecom-cli"
|
|
39
|
+
},
|
|
40
|
+
"linux-arm64": {
|
|
41
|
+
"url": "https://registry.npmjs.org/@wecom/cli-linux-arm64/-/cli-linux-arm64-1.3.0.tgz",
|
|
42
|
+
"integrity": "sha512-t2Mww45xF9E2AEO7hWMKfsynLljfnn4ngVcDGljGIhm306wNBheMU7F6n/HNVwu8fNL76uPIH+eoYyL7EVxf+w==",
|
|
43
|
+
"archiveEntry": "package/bin/wecom-cli"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const WPS365_DISTRIBUTIONS = {
|
|
47
|
+
"darwin-arm64": {
|
|
48
|
+
url: "https://github.com/wps365-open/cli/releases/download/v0.3.6/wps365-cli-aarch64-apple-darwin.tar.gz",
|
|
49
|
+
integrity: "sha256-2605dab1a208327e3fc3b739d589c878ad17c7a22a133dd26171e76c6f81c08f",
|
|
50
|
+
archiveEntry: "wps365-cli"
|
|
51
|
+
},
|
|
52
|
+
"linux-arm64": {
|
|
53
|
+
url: "https://github.com/wps365-open/cli/releases/download/v0.3.6/wps365-cli-aarch64-unknown-linux-gnu.tar.gz",
|
|
54
|
+
integrity: "sha256-f9de5dc0a0e5a682bd53c9df8e21196a6090b308db2c339b516f6389ecea0ab3",
|
|
55
|
+
archiveEntry: "wps365-cli"
|
|
56
|
+
},
|
|
57
|
+
"darwin-x64": {
|
|
58
|
+
url: "https://github.com/wps365-open/cli/releases/download/v0.3.6/wps365-cli-x86_64-apple-darwin.tar.gz",
|
|
59
|
+
integrity: "sha256-d7c63d3e59446bf0a27361282a7751a818791752bcb8c9b478cb937ff8216f33",
|
|
60
|
+
archiveEntry: "wps365-cli"
|
|
61
|
+
},
|
|
62
|
+
"linux-x64": {
|
|
63
|
+
url: "https://github.com/wps365-open/cli/releases/download/v0.3.6/wps365-cli-x86_64-unknown-linux-gnu.tar.gz",
|
|
64
|
+
integrity: "sha256-68b955a8488edcb82ed5373752a937d9ec3588abfb550223dda3d6f0c1a27588",
|
|
65
|
+
archiveEntry: "wps365-cli"
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
export { LARK_DISTRIBUTIONS, WECOM_DISTRIBUTIONS, WPS365_DISTRIBUTIONS };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CliAdapter } from './types.js';
|
|
2
|
+
export declare function verifyIntegrity(bytes: Buffer, integrity: string): void;
|
|
3
|
+
export declare function cliExecutablePath(adapter: CliAdapter): string;
|
|
4
|
+
export declare function verifyInstalledCli(adapter: CliAdapter): Promise<string>;
|
|
5
|
+
export declare function installCli(adapter: CliAdapter): Promise<string>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { runProcess } from "../../process/run-process.js";
|
|
2
|
+
import { cliRoot } from "./process.js";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
5
|
+
import { chmod, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
6
|
+
//#region src/connectors/cli/installer.ts
|
|
7
|
+
const MAX_ARCHIVE_BYTES = 100 * 1024 * 1024;
|
|
8
|
+
const installs = /* @__PURE__ */ new Map();
|
|
9
|
+
function verifyIntegrity(bytes, integrity) {
|
|
10
|
+
const match = /^(sha256|sha512)-(.+)$/.exec(integrity);
|
|
11
|
+
if (!match) throw new Error("Unsupported CLI integrity format.");
|
|
12
|
+
const expected = match[2];
|
|
13
|
+
if (createHash(match[1]).update(bytes).digest(match[1] === "sha256" ? "hex" : "base64") !== expected) throw new Error("CLI distribution integrity mismatch.");
|
|
14
|
+
}
|
|
15
|
+
function cliExecutablePath(adapter) {
|
|
16
|
+
return join(cliRoot(), "runtimes", adapter.id, adapter.binaryVersion, `${process.platform}-${process.arch}`, adapter.executable);
|
|
17
|
+
}
|
|
18
|
+
async function verifyInstalledCli(adapter) {
|
|
19
|
+
const path = cliExecutablePath(adapter);
|
|
20
|
+
const [binary, digest] = await Promise.all([readFile(path), readFile(`${path}.sha256`, "utf8")]);
|
|
21
|
+
verifyIntegrity(binary, `sha256-${digest.trim()}`);
|
|
22
|
+
return path;
|
|
23
|
+
}
|
|
24
|
+
async function install(adapter) {
|
|
25
|
+
const distribution = adapter.distributions[`${process.platform}-${process.arch}`];
|
|
26
|
+
if (!distribution) throw new Error(`Unsupported CLI platform: ${process.platform}-${process.arch}.`);
|
|
27
|
+
const url = new URL(distribution.url);
|
|
28
|
+
if (url.protocol !== "https:" || !["github.com", "registry.npmjs.org"].includes(url.hostname)) throw new Error("Untrusted CLI distribution URL.");
|
|
29
|
+
try {
|
|
30
|
+
return await verifyInstalledCli(adapter);
|
|
31
|
+
} catch {}
|
|
32
|
+
const directory = join(cliRoot(), "runtimes", adapter.id, adapter.binaryVersion, `${process.platform}-${process.arch}`);
|
|
33
|
+
await mkdir(directory, {
|
|
34
|
+
recursive: true,
|
|
35
|
+
mode: 448
|
|
36
|
+
});
|
|
37
|
+
const staging = join(directory, `.install-${randomUUID()}`);
|
|
38
|
+
await mkdir(staging, { mode: 448 });
|
|
39
|
+
try {
|
|
40
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(9e4) });
|
|
41
|
+
if (!response.ok || !response.body) throw new Error(`CLI download failed (${response.status}).`);
|
|
42
|
+
const chunks = [];
|
|
43
|
+
let size = 0;
|
|
44
|
+
for await (const chunk of response.body) {
|
|
45
|
+
size += chunk.length;
|
|
46
|
+
if (size > MAX_ARCHIVE_BYTES) throw new Error("CLI distribution exceeds size limit.");
|
|
47
|
+
chunks.push(Buffer.from(chunk));
|
|
48
|
+
}
|
|
49
|
+
const bytes = Buffer.concat(chunks);
|
|
50
|
+
verifyIntegrity(bytes, distribution.integrity);
|
|
51
|
+
const archive = join(staging, "archive.tgz");
|
|
52
|
+
await writeFile(archive, bytes, { mode: 384 });
|
|
53
|
+
const binaryChunks = [];
|
|
54
|
+
let binaryBytes = 0;
|
|
55
|
+
const extracted = await runProcess({
|
|
56
|
+
program: "tar",
|
|
57
|
+
args: [
|
|
58
|
+
"-xOf",
|
|
59
|
+
archive,
|
|
60
|
+
distribution.archiveEntry
|
|
61
|
+
],
|
|
62
|
+
maxOutputBytes: MAX_ARCHIVE_BYTES,
|
|
63
|
+
timeoutMs: 3e4,
|
|
64
|
+
terminationPolicy: "tree",
|
|
65
|
+
onOutput(stream, chunk) {
|
|
66
|
+
if (stream !== "stdout") return;
|
|
67
|
+
binaryBytes += chunk.length;
|
|
68
|
+
if (binaryBytes <= MAX_ARCHIVE_BYTES) binaryChunks.push(Buffer.from(chunk));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
if (extracted.exitCode !== 0 || extracted.outputTruncated || binaryBytes > MAX_ARCHIVE_BYTES) throw new Error("CLI archive extraction failed.");
|
|
72
|
+
const binary = Buffer.concat(binaryChunks);
|
|
73
|
+
const executable = cliExecutablePath(adapter);
|
|
74
|
+
const temporary = join(staging, adapter.executable);
|
|
75
|
+
await writeFile(temporary, binary, { mode: 448 });
|
|
76
|
+
await chmod(temporary, 448);
|
|
77
|
+
const probe = await runProcess({
|
|
78
|
+
program: temporary,
|
|
79
|
+
args: ["--version"],
|
|
80
|
+
timeoutMs: 1e4
|
|
81
|
+
});
|
|
82
|
+
if (probe.exitCode !== 0 || !probe.stdout.includes(adapter.binaryVersion)) throw new Error("CLI version verification failed.");
|
|
83
|
+
await writeFile(`${executable}.sha256`, createHash("sha256").update(binary).digest("hex"), { mode: 384 });
|
|
84
|
+
await rename(temporary, executable);
|
|
85
|
+
return executable;
|
|
86
|
+
} finally {
|
|
87
|
+
await rm(staging, {
|
|
88
|
+
recursive: true,
|
|
89
|
+
force: true
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function installCli(adapter) {
|
|
94
|
+
const key = cliExecutablePath(adapter);
|
|
95
|
+
const pending = installs.get(key);
|
|
96
|
+
if (pending) return pending;
|
|
97
|
+
const operation = install(adapter).finally(() => installs.delete(key));
|
|
98
|
+
installs.set(key, operation);
|
|
99
|
+
return operation;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { cliExecutablePath, installCli, verifyInstalledCli, verifyIntegrity };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stopCliInstance(instanceId: string, disconnect?: boolean): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isXopcDatabaseOpen } from "../../storage/sqlite/connection.js";
|
|
2
|
+
import { listConnectorConnections, upsertConnectorConnection } from "../../storage/sqlite/connector-repository.js";
|
|
3
|
+
import "../../storage/sqlite/index.js";
|
|
4
|
+
import { cancelCliContext } from "./process.js";
|
|
5
|
+
import { cancelCliInstanceAuthorizations } from "./authorization.js";
|
|
6
|
+
//#region src/connectors/cli/lifecycle.ts
|
|
7
|
+
function stopCliInstance(instanceId, disconnect = false) {
|
|
8
|
+
cancelCliInstanceAuthorizations(instanceId);
|
|
9
|
+
if (!isXopcDatabaseOpen()) return;
|
|
10
|
+
for (const connection of listConnectorConnections().filter((item) => item.provider === "cli" && item.metadata.runtimeInstanceId === instanceId)) {
|
|
11
|
+
cancelCliContext(String(connection.metadata.contextId));
|
|
12
|
+
if (disconnect) upsertConnectorConnection({
|
|
13
|
+
...connection,
|
|
14
|
+
status: "disabled"
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { stopCliInstance };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ProcessHandle } from '../../process/process-spec.js';
|
|
2
|
+
import type { CliAdapter } from './types.js';
|
|
3
|
+
export declare function cancelCliContext(contextId: string): void;
|
|
4
|
+
export declare function cliRoot(): string;
|
|
5
|
+
export declare function cliContextPath(id: string): string;
|
|
6
|
+
export declare function cliEnvironment(adapter: CliAdapter, contextPath: string): NodeJS.ProcessEnv;
|
|
7
|
+
export declare function startCliProcess(options: {
|
|
8
|
+
adapter: CliAdapter;
|
|
9
|
+
executable: string;
|
|
10
|
+
contextId: string;
|
|
11
|
+
args: string[];
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
maxOutputBytes?: number;
|
|
15
|
+
beforeSpawn?: () => void;
|
|
16
|
+
onOutput?: (stream: 'stdout' | 'stderr', chunk: Buffer) => void;
|
|
17
|
+
}): Promise<ProcessHandle>;
|
|
18
|
+
export declare function resolveCliArtifact(contextId: string, filePath: string): Promise<string>;
|