@xopcai/xopc 0.0.309 → 0.0.311
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/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-zKINl7UH.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D2ePZKdY.js +1 -0
- package/dist/gateway/static/root/assets/{agents-CPqUMtCL.js → agents-BiD9STyv.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-BiBXVEvp.js → app-link-wamYbNUl.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CgVBSqzu.js → app-management-settings-panel-C94LAxyt.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CoWdCokb.js → appearance-settings-CP01zHvC.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-B7DmSJQj.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C3ZA6LRS.js → archive-plugin-SwWFt5MT.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CdgS6_zy.js → attachment-load-DdTFml9l.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BtHL2hpg.js → automations-page-Kmr5WVFp.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-bkijiu-Y.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CiDhtq_H.js → binary-plugins-47UTtDNq.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Br00T83w.js → block-editor-DvzZkMG8.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-DrUKNL9X.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-Dhf_MWCf.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BCubrDf8.js +8 -0
- package/dist/gateway/static/root/assets/channels-settings-e4T1DEfN.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-JsMtzDao.js → chat-terminal-dock-Bg_m7HUE.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-CosCmVsT.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-DZFNUTiN.js → connector-service-page-BL-hSR7_.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-C0WWxnxJ.js +2 -0
- package/dist/gateway/static/root/assets/date-picker-DqYFVasF.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-B-BcuG1y.js → dependency-picker-DCyyFLKp.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CdBBhhdY.js → desktop-pet-CFnnpRA_.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-U5wWRH4c.js +1 -0
- package/dist/gateway/static/root/assets/device-pairing-wizard-BhHxvFO1.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BFp5eKtY.js → extension-debug-page-DA8WJ3-E.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DL3vyyH6.js → extension-page-C2BIB88m.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BXtvdAsY.js → extension-settings-page-kpYo979N.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-CE9t1yTa.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-C7Ezx8Du.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-NPk698vI.js} +1 -1
- package/dist/gateway/static/root/assets/index-1wIKA-kM.css +1 -0
- package/dist/gateway/static/root/assets/index-DxYitLp8.js +79 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CutG9zLh.js → keyboard-shortcuts-settings-BhreF0_O.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CPmynb3x.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CJy6I7Dt.js → local-apps-page-DOZZBdqj.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-M8kz26yo.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-BQhIOELc.js → management-settings-JLqHYQvY.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-p2P5hP1U.js → markdown-view-BDpcjR_Z.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-DSjfHfaW.css +1 -0
- package/dist/gateway/static/root/assets/{media-plugins-CsBylqlN.js → media-plugins-B75SWUJd.js} +1 -1
- package/dist/gateway/static/root/assets/messages-4BtQKYlM.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-B_Ft0M32.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-C32mxSD-.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-ChQ4jJFs.js → page-tabs-CMlQUzT6.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-cZ2hszQT.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-BADxWEdP.js → product-open-page-CPoSbglF.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DYttWua0.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-D46drWbl.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-C9n9Nuhi.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D-pwiIyp.js → runtime-tools-settings-panel-bMLWRApp.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-Dw3hmHAr.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-IWmb05DX.js → schema-form-UVJV_7AS.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-C8P6ff91.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-whpUsAy3.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-B0veRBZs.js → settings-form-section-BqzOqonM.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-DQ9RJ8-b.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-D3Spald3.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-C8u601m8.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CirpgkfD.js → share-preview-page-BcgYzA7y.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Bv-2rZ8e.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-LM-cgWUS.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-ggmb7rCW.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-B42mpWKV.js → skills-page.utils-ADABzrtk.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-DfkcW_Za.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-DC4yqDFd.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-CTuwTdMm.js +1 -0
- package/dist/gateway/static/root/assets/use-autosave-5ZDd9XKh.js +1 -0
- package/dist/gateway/static/root/assets/user-model-page-BFKFhdZ0.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BZbKQ8HT.js → voice-api-key-field-D3urfd-n.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-JzM3Ylbs.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D2kuwv5e.js → workflow-run-setup-panel-Bn2CtRdB.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-BiCmt98A.js +6 -0
- package/dist/gateway/static/root/connector-icons/SOURCES.md +0 -2
- package/dist/gateway/static/root/index.html +17 -20
- 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/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/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 +46 -43
- 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/schema.d.ts +4 -4
- package/dist/src/config/schema.js +2 -12
- 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 +0 -15
- package/dist/src/gateway/hono/lib/config-payload.js +0 -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 +129 -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 +35 -0
- package/dist/src/scenes/metrics.js +94 -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 +4 -2
- 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/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/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,76 @@
|
|
|
1
|
+
import { sceneTemplateSchema } from "./contracts.js";
|
|
2
|
+
//#region src/scenes/templates.ts
|
|
3
|
+
const mailFollowUpTemplate = sceneTemplateSchema.parse({
|
|
4
|
+
schemaVersion: 1,
|
|
5
|
+
key: "mail-follow-up",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
title: "跟进重要邮件",
|
|
8
|
+
description: "在约定时间检查指定邮件,准备需要你判断的下一步;不自动发送。",
|
|
9
|
+
goalMode: "ongoing",
|
|
10
|
+
contextProviders: ["mail"],
|
|
11
|
+
triggers: [
|
|
12
|
+
{
|
|
13
|
+
id: "check",
|
|
14
|
+
type: "manual"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "due",
|
|
18
|
+
type: "schedule"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "changed",
|
|
22
|
+
type: "event",
|
|
23
|
+
eventType: "mail.thread.changed"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
execution: {
|
|
27
|
+
kind: "agent",
|
|
28
|
+
instruction: "Review the authorized mail thread against the user goal. If a reply resolves the request or no useful next step exists, return no_change. Otherwise prepare a concise follow-up draft or a decision with evidence. Do not infer that a draft was sent. Do not infer missing messages or recipients.",
|
|
29
|
+
limits: {
|
|
30
|
+
timeoutSeconds: 90,
|
|
31
|
+
maxIterations: 1,
|
|
32
|
+
maxToolCalls: 0,
|
|
33
|
+
maxOutputTokens: 2e3
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
allowedOutcomeKinds: [
|
|
37
|
+
"no_change",
|
|
38
|
+
"artifact",
|
|
39
|
+
"decision"
|
|
40
|
+
],
|
|
41
|
+
allowedEffectHandlers: []
|
|
42
|
+
});
|
|
43
|
+
const familyPlanTemplate = sceneTemplateSchema.parse({
|
|
44
|
+
schemaVersion: 1,
|
|
45
|
+
key: "weekly-family-plan",
|
|
46
|
+
version: "1.0.0",
|
|
47
|
+
title: "提前准备下周家庭安排",
|
|
48
|
+
description: "根据你提供的安排整理冲突、准备事项和可选计划,不替你决定家庭活动。",
|
|
49
|
+
goalMode: "ongoing",
|
|
50
|
+
contextProviders: ["user_notes"],
|
|
51
|
+
triggers: [{
|
|
52
|
+
id: "check",
|
|
53
|
+
type: "manual"
|
|
54
|
+
}, {
|
|
55
|
+
id: "weekly-review",
|
|
56
|
+
type: "schedule"
|
|
57
|
+
}],
|
|
58
|
+
execution: {
|
|
59
|
+
kind: "agent",
|
|
60
|
+
instruction: "Use only the supplied family arrangements to prepare next week. Surface concrete conflicts and useful preparations. Preserve room for rest and changing plans. Do not infer access to other family members, medical advice, or obligations not provided by the user. No useful change means no_change.",
|
|
61
|
+
limits: {
|
|
62
|
+
timeoutSeconds: 90,
|
|
63
|
+
maxIterations: 1,
|
|
64
|
+
maxToolCalls: 0,
|
|
65
|
+
maxOutputTokens: 2e3
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
allowedOutcomeKinds: [
|
|
69
|
+
"no_change",
|
|
70
|
+
"artifact",
|
|
71
|
+
"decision"
|
|
72
|
+
],
|
|
73
|
+
allowedEffectHandlers: []
|
|
74
|
+
});
|
|
75
|
+
//#endregion
|
|
76
|
+
export { familyPlanTemplate, mailFollowUpTemplate };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import type { SceneContextProvider, SceneEvidence } from './execution.js';
|
|
3
|
+
/** Explicit notes belong to one delegation, not an implicit family-wide data grant. */
|
|
4
|
+
export declare class SceneUserNotesProvider implements SceneContextProvider {
|
|
5
|
+
private readonly db;
|
|
6
|
+
private readonly clock;
|
|
7
|
+
readonly id = "user_notes";
|
|
8
|
+
constructor(db: DatabaseSync, clock?: () => number);
|
|
9
|
+
read(input: Parameters<SceneContextProvider['read']>[0]): Promise<SceneEvidence[]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SceneSourceNotReady } from "./readiness.js";
|
|
2
|
+
//#region src/scenes/userNotes.ts
|
|
3
|
+
/** Explicit notes belong to one delegation, not an implicit family-wide data grant. */
|
|
4
|
+
var SceneUserNotesProvider = class {
|
|
5
|
+
id = "user_notes";
|
|
6
|
+
constructor(db, clock = Date.now) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
this.clock = clock;
|
|
9
|
+
}
|
|
10
|
+
async read(input) {
|
|
11
|
+
input.signal.throwIfAborted();
|
|
12
|
+
if (!input.permissions.contextProviders.includes(this.id) || input.activation.scope.kind !== "personal") throw new Error("Personal notes permission is required");
|
|
13
|
+
const row = this.db.prepare(`SELECT n.content, n.revision, n.valid_until, n.updated_at
|
|
14
|
+
FROM scene_activations a LEFT JOIN scene_notes n ON n.activation_id = a.id
|
|
15
|
+
WHERE a.id = ? AND a.owner_id = ? AND a.workspace_id = ? AND a.status = 'active'
|
|
16
|
+
AND json_extract(a.scope_json, '$.kind') = 'personal'`).get(input.activation.id, input.activation.ownerId, input.activation.workspaceId);
|
|
17
|
+
if (!row) throw new Error("Personal notes are unavailable");
|
|
18
|
+
if (row.content === null || row.content === "") return [];
|
|
19
|
+
const now = this.clock();
|
|
20
|
+
if (row.valid_until !== null && Number(row.valid_until) <= now) throw new SceneSourceNotReady();
|
|
21
|
+
return [{
|
|
22
|
+
id: `scene-notes:${input.activation.id}`,
|
|
23
|
+
subjectId: input.activation.id,
|
|
24
|
+
ownerId: input.activation.ownerId,
|
|
25
|
+
workspaceId: input.activation.workspaceId,
|
|
26
|
+
revision: String(row.revision),
|
|
27
|
+
occurredAt: Number(row.updated_at),
|
|
28
|
+
content: String(row.content),
|
|
29
|
+
freshUntil: Math.min(now + 6e4, row.valid_until === null ? Infinity : Number(row.valid_until))
|
|
30
|
+
}];
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { SceneUserNotesProvider };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { requireXopcDatabase } from "../storage/sqlite/connection.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
|
|
5
|
+
import { findConversationIdByTranscriptId, getSessionPersistedLevels } from "../storage/sqlite/session-repository.js";
|
|
5
6
|
import "../storage/sqlite/index.js";
|
|
6
7
|
import { SessionConfigSchema, init_schema } from "../config/schema.js";
|
|
7
8
|
import { normalizeThinkLevel, normalizeVerboseLevel } from "../agent/transcript/thinking-types.js";
|
|
@@ -6,7 +6,8 @@ import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
|
6
6
|
import { buildSessionContextForLlm, buildSessionDisplayMessages, init_session_context_for_llm, isRuntimeOnlyTranscriptMessage, isTranscriptCompactionEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
7
7
|
import "./types.js";
|
|
8
8
|
import { estimateTokensFromMessages } from "../storage/sqlite/row-mappers.js";
|
|
9
|
-
import {
|
|
9
|
+
import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
|
|
10
|
+
import { deleteSessionRecord, ensureSessionRecord, findConversationIdByTranscriptId, getGlobalSessionStats, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord } from "../storage/sqlite/session-repository.js";
|
|
10
11
|
import { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript } from "../storage/sqlite/transcript-repository.js";
|
|
11
12
|
import { getSessionConfig, setSessionConfig } from "../storage/sqlite/config-repository.js";
|
|
12
13
|
import "../storage/sqlite/index.js";
|
|
@@ -105,11 +105,6 @@ function mergeShareConfigPatch(config, patch) {
|
|
|
105
105
|
bind: "loopback",
|
|
106
106
|
port: 18790,
|
|
107
107
|
auth: { mode: "token" },
|
|
108
|
-
heartbeat: {
|
|
109
|
-
enabled: true,
|
|
110
|
-
intervalMs: 18e5,
|
|
111
|
-
includeSystemPromptSection: false
|
|
112
|
-
},
|
|
113
108
|
corsOrigins: []
|
|
114
109
|
};
|
|
115
110
|
const current = resolveShareConfig(config.gateway.share);
|
|
@@ -68,11 +68,6 @@ function mergeSiteShareConfigPatch(config, patch) {
|
|
|
68
68
|
bind: "loopback",
|
|
69
69
|
port: 18790,
|
|
70
70
|
auth: { mode: "token" },
|
|
71
|
-
heartbeat: {
|
|
72
|
-
enabled: true,
|
|
73
|
-
intervalMs: 18e5,
|
|
74
|
-
includeSystemPromptSection: false
|
|
75
|
-
},
|
|
76
71
|
corsOrigins: []
|
|
77
72
|
};
|
|
78
73
|
const cfg = config.gateway;
|
|
@@ -8,10 +8,24 @@ import { bumpSessionInputRevision, getSessionInputById, getSessionInputState, in
|
|
|
8
8
|
import { TaskRunRepository, init_task_run_repository } from "../../tasks/task-run-repository.js";
|
|
9
9
|
import { getConnectorAccount, init_connector_account_repository } from "./connector-account-repository.js";
|
|
10
10
|
import { getConnectorConnection, init_connector_repository } from "./connector-repository.js";
|
|
11
|
-
import { getSessionMetadata, init_session_repository } from "./session-repository.js";
|
|
12
11
|
import { randomUUID } from "node:crypto";
|
|
13
12
|
import { EventEmitter } from "node:events";
|
|
14
13
|
//#region src/storage/sqlite/connection-wait-repository.ts
|
|
14
|
+
function getConnectionSessionContext(conversationId) {
|
|
15
|
+
const row = getSqliteDatabase().prepare(`SELECT session_type, parent_conversation_id, custom_data_json
|
|
16
|
+
FROM sessions WHERE conversation_id = ?`).get(conversationId);
|
|
17
|
+
if (!row) return void 0;
|
|
18
|
+
let customData = {};
|
|
19
|
+
if (row.custom_data_json) try {
|
|
20
|
+
const parsed = JSON.parse(row.custom_data_json);
|
|
21
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) customData = parsed;
|
|
22
|
+
} catch {}
|
|
23
|
+
return {
|
|
24
|
+
sessionType: row.session_type,
|
|
25
|
+
parentConversationId: row.parent_conversation_id,
|
|
26
|
+
customData
|
|
27
|
+
};
|
|
28
|
+
}
|
|
15
29
|
function onConnectionWaitChanged(listener) {
|
|
16
30
|
events.on("changed", listener);
|
|
17
31
|
return () => {
|
|
@@ -225,9 +239,9 @@ function consumeConnectionResume(input) {
|
|
|
225
239
|
}
|
|
226
240
|
function connectionBindings(conversationId) {
|
|
227
241
|
if (!isXopcDatabaseOpen()) return [];
|
|
228
|
-
let
|
|
229
|
-
if (
|
|
230
|
-
const workflowAccounts =
|
|
242
|
+
let sessionContext = getConnectionSessionContext(conversationId);
|
|
243
|
+
if (sessionContext?.sessionType === "workflow-subagent" && sessionContext.parentConversationId) sessionContext = getConnectionSessionContext(sessionContext.parentConversationId);
|
|
244
|
+
const workflowAccounts = sessionContext?.sessionType === "workflow-run" ? sessionContext.customData.connectorAccounts : void 0;
|
|
231
245
|
if (workflowAccounts && typeof workflowAccounts === "object" && !Array.isArray(workflowAccounts)) return Object.entries(workflowAccounts).flatMap(([connectorId, ids]) => Array.isArray(ids) ? ids.flatMap((id) => {
|
|
232
246
|
if (typeof id !== "string") return [];
|
|
233
247
|
const account = getConnectorAccount(id);
|
|
@@ -392,14 +406,13 @@ function listConnectionWaitsToCheck() {
|
|
|
392
406
|
}
|
|
393
407
|
var log, events;
|
|
394
408
|
var init_connection_wait_repository = __esmMin((() => {
|
|
395
|
-
init_connector_account_repository();
|
|
396
|
-
init_connector_repository();
|
|
397
409
|
init_logger();
|
|
398
410
|
init_task_run_repository();
|
|
399
411
|
init_connection();
|
|
412
|
+
init_connector_account_repository();
|
|
413
|
+
init_connector_repository();
|
|
400
414
|
init_transaction();
|
|
401
415
|
init_session_instance_repository();
|
|
402
|
-
init_session_repository();
|
|
403
416
|
init_session_input_repository();
|
|
404
417
|
log = createLogger("Connectors:Wait");
|
|
405
418
|
events = new EventEmitter();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { resolveXopcDatabasePath } from "../../config/paths-state.js";
|
|
3
3
|
import { init_paths } from "./paths.js";
|
|
4
|
-
import { init_node_sqlite, requireNodeSqlite } from "../../infra/node-sqlite.js";
|
|
5
4
|
import { createLogger } from "../../utils/logger/index.js";
|
|
6
5
|
import { init_logger } from "../../utils/logger.js";
|
|
6
|
+
import { init_node_sqlite, requireNodeSqlite } from "../../infra/node-sqlite.js";
|
|
7
7
|
import { ensureXopcDatabaseSchema, init_schema } from "./schema.js";
|
|
8
8
|
import { init_unhandled_rejections, installSqliteTransientRejectionHandler } from "../../infra/unhandled-rejections.js";
|
|
9
9
|
import path from "node:path";
|
|
@@ -16,6 +16,7 @@ function fromRow(row) {
|
|
|
16
16
|
principalId: row.principal_id,
|
|
17
17
|
identityKey: row.identity_key ?? void 0,
|
|
18
18
|
backendId: row.backend_id ?? void 0,
|
|
19
|
+
runtimeInstanceId: row.runtime_instance_id ?? void 0,
|
|
19
20
|
identity: parseIdentity(row.identity_json),
|
|
20
21
|
currentConnectionId: row.current_connection_id ?? void 0,
|
|
21
22
|
label: row.label ?? void 0,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export type ConnectorSyncPolicy = {
|
|
2
2
|
accountId: string;
|
|
3
3
|
scanEnabled: boolean;
|
|
4
|
-
proactiveEnabled: boolean;
|
|
5
4
|
intervalMinutes?: number;
|
|
6
|
-
allowedScenarioKeys: string[];
|
|
7
5
|
revision: number;
|
|
8
6
|
updatedAt: string;
|
|
9
7
|
};
|
|
@@ -13,9 +11,7 @@ export declare function listConnectorSyncPolicies(): ConnectorSyncPolicy[];
|
|
|
13
11
|
export declare function upsertConnectorSyncPolicy(input: {
|
|
14
12
|
accountId: string;
|
|
15
13
|
scanEnabled?: boolean;
|
|
16
|
-
proactiveEnabled?: boolean;
|
|
17
14
|
intervalMinutes?: number | null;
|
|
18
15
|
defaultIntervalMinutes?: number;
|
|
19
|
-
allowedScenarioKeys?: string[];
|
|
20
16
|
nowMs?: number;
|
|
21
17
|
}): ConnectorSyncPolicy;
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
2
|
//#region src/storage/sqlite/connector-sync-policy-repository.ts
|
|
3
3
|
init_transaction();
|
|
4
|
-
function stringArray(value) {
|
|
5
|
-
try {
|
|
6
|
-
const parsed = JSON.parse(value);
|
|
7
|
-
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
8
|
-
} catch {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
4
|
function fromRow(row) {
|
|
13
5
|
return {
|
|
14
6
|
accountId: row.account_id,
|
|
15
7
|
scanEnabled: row.scan_enabled === 1,
|
|
16
|
-
proactiveEnabled: row.proactive_enabled === 1,
|
|
17
8
|
...row.interval_minutes == null ? {} : { intervalMinutes: row.interval_minutes },
|
|
18
|
-
allowedScenarioKeys: stringArray(row.allowed_scenario_keys_json),
|
|
19
9
|
revision: row.revision,
|
|
20
10
|
updatedAt: new Date(row.updated_at).toISOString()
|
|
21
11
|
};
|
|
@@ -41,19 +31,15 @@ function upsertConnectorSyncPolicy(input) {
|
|
|
41
31
|
const current = getConnectorSyncPolicy(input.accountId);
|
|
42
32
|
const now = input.nowMs ?? Date.now();
|
|
43
33
|
const intervalMinutes = input.intervalMinutes === null ? null : Math.max(5, Math.min(1440, input.intervalMinutes ?? current?.intervalMinutes ?? input.defaultIntervalMinutes ?? 30));
|
|
44
|
-
const allowedScenarioKeys = [...new Set((input.allowedScenarioKeys ?? current?.allowedScenarioKeys ?? []).map((key) => key.trim()).filter(Boolean))].sort();
|
|
45
34
|
runSqliteWriteTransaction((db) => {
|
|
46
35
|
db.prepare(`INSERT INTO connector_sync_policies (
|
|
47
|
-
account_id, scan_enabled,
|
|
48
|
-
|
|
49
|
-
) VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
36
|
+
account_id, scan_enabled, interval_minutes, revision, updated_at
|
|
37
|
+
) VALUES (?, ?, ?, 1, ?)
|
|
50
38
|
ON CONFLICT(account_id) DO UPDATE SET
|
|
51
39
|
scan_enabled = excluded.scan_enabled,
|
|
52
|
-
proactive_enabled = excluded.proactive_enabled,
|
|
53
40
|
interval_minutes = excluded.interval_minutes,
|
|
54
|
-
allowed_scenario_keys_json = excluded.allowed_scenario_keys_json,
|
|
55
41
|
revision = connector_sync_policies.revision + 1,
|
|
56
|
-
updated_at = excluded.updated_at`).run(input.accountId, input.scanEnabled ?? current?.scanEnabled ?? false ? 1 : 0,
|
|
42
|
+
updated_at = excluded.updated_at`).run(input.accountId, input.scanEnabled ?? current?.scanEnabled ?? false ? 1 : 0, intervalMinutes, now);
|
|
57
43
|
});
|
|
58
44
|
return getConnectorSyncPolicy(input.accountId);
|
|
59
45
|
}
|
|
@@ -4,7 +4,8 @@ import { init_connection, requireXopcDatabase } from "./connection.js";
|
|
|
4
4
|
import { init_transaction, runSqliteWriteTransaction } from "./transaction.js";
|
|
5
5
|
import { validateConversationId } from "../../../packages/gateway-contract/src/conversation-identity.js";
|
|
6
6
|
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getSessionMetadata } from "./session-read-repository.js";
|
|
8
|
+
import { ensureSessionInTransaction, init_session_repository } from "./session-repository.js";
|
|
8
9
|
import { randomUUID } from "node:crypto";
|
|
9
10
|
//#region src/storage/sqlite/conversation-repository.ts
|
|
10
11
|
function createConversation(input, cwd = "", conversationId = randomUUID()) {
|
|
@@ -30,7 +30,8 @@ import { finishEndpointToolInvocationAudit, listEndpointToolInvocationAudits, st
|
|
|
30
30
|
import { getInteractionState, setInteractionState, updateInteractionStateFromMessage } from "./interaction-state-repository.js";
|
|
31
31
|
import { getConnectorAccount, init_connector_account_repository, listConnectorAccounts, reconcileConnectorAccount, refreshConnectorAccountCurrent } from "./connector-account-repository.js";
|
|
32
32
|
import { appendConnectorExecutionAudit, claimConnectorWebhookDelivery, completeConnectorWebhookDelivery, consumeConnectorApproval, createConnectorApproval, decideConnectorApproval, deleteConnectorConnection, deleteConnectorInstallation, getCachedConnectorCatalogEntry, getConnectorApproval, getConnectorConnection, getConnectorInstallation, init_connector_repository, listCachedConnectorCatalogEntries, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation } from "./connector-repository.js";
|
|
33
|
-
import {
|
|
33
|
+
import { getSessionMetadata } from "./session-read-repository.js";
|
|
34
|
+
import { deleteSessionRecord, ensureSessionRecord, findConversationIdByTranscriptId, getCurrentTranscriptId, getGlobalSessionStats, getSessionPersistedLevels, incrementSessionStatsOnAppend, init_session_repository, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats } from "./session-repository.js";
|
|
34
35
|
import { getSessionTaskPlan, setSessionTaskPlan } from "./session-task-plan-repository.js";
|
|
35
36
|
import { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings } from "./relationship-settings-repository.js";
|
|
36
37
|
import { SidebarLayoutConflictError, getSidebarLayout, replaceSidebarLayout, sortBySidebarLayout } from "./sidebar-layout-repository.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
ALTER TABLE connector_accounts ADD COLUMN runtime_instance_id TEXT;
|
|
2
|
+
CREATE UNIQUE INDEX idx_cli_account_identity ON connector_accounts(principal_id, runtime_instance_id, identity_key)
|
|
3
|
+
WHERE runtime_instance_id IS NOT NULL AND identity_key IS NOT NULL;
|
|
4
|
+
CREATE TABLE connector_cli_authorizations (
|
|
5
|
+
id TEXT PRIMARY KEY,
|
|
6
|
+
instance_id TEXT NOT NULL,
|
|
7
|
+
connector_id TEXT NOT NULL,
|
|
8
|
+
principal_id TEXT NOT NULL,
|
|
9
|
+
expected_account_id TEXT,
|
|
10
|
+
context_id TEXT NOT NULL,
|
|
11
|
+
phase TEXT NOT NULL CHECK(phase IN ('preparing','awaiting_user','verifying','succeeded','failed','expired','cancelled')),
|
|
12
|
+
challenge_json TEXT,
|
|
13
|
+
error TEXT,
|
|
14
|
+
account_id TEXT,
|
|
15
|
+
owner_id TEXT NOT NULL,
|
|
16
|
+
expires_at INTEGER NOT NULL,
|
|
17
|
+
updated_at INTEGER NOT NULL
|
|
18
|
+
);
|
|
19
|
+
CREATE UNIQUE INDEX idx_cli_active_authorization ON connector_cli_authorizations(instance_id, principal_id)
|
|
20
|
+
WHERE phase IN ('preparing','awaiting_user','verifying');
|
|
21
|
+
CREATE TABLE connector_cli_executions (
|
|
22
|
+
id TEXT PRIMARY KEY,
|
|
23
|
+
instance_id TEXT NOT NULL,
|
|
24
|
+
account_id TEXT NOT NULL,
|
|
25
|
+
connection_id TEXT NOT NULL,
|
|
26
|
+
action_id TEXT NOT NULL,
|
|
27
|
+
revision TEXT NOT NULL,
|
|
28
|
+
arguments_hash TEXT NOT NULL,
|
|
29
|
+
status TEXT NOT NULL CHECK(status IN ('running','success','failed','unknown')),
|
|
30
|
+
owner_id TEXT NOT NULL,
|
|
31
|
+
error_kind TEXT,
|
|
32
|
+
started_at INTEGER NOT NULL,
|
|
33
|
+
finished_at INTEGER
|
|
34
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS scene_source_health (
|
|
2
|
+
activation_id TEXT PRIMARY KEY REFERENCES scene_activations(id) ON DELETE CASCADE,
|
|
3
|
+
last_attempt_at INTEGER NOT NULL,
|
|
4
|
+
last_success_at INTEGER,
|
|
5
|
+
reason TEXT,
|
|
6
|
+
consecutive_failures INTEGER NOT NULL DEFAULT 0,
|
|
7
|
+
retry_at INTEGER
|
|
8
|
+
);
|
|
@@ -6,6 +6,8 @@ type BackupFileSyncOperations = {
|
|
|
6
6
|
};
|
|
7
7
|
/** Windows requires write access on a file handle before FlushFileBuffers/fsync. */
|
|
8
8
|
export declare function flushBackupFile(backupPath: string, operations?: BackupFileSyncOperations): void;
|
|
9
|
+
/** Offline migrations must reject processes that still hold the database open. */
|
|
10
|
+
export declare function assertDatabaseOffline(databasePath: string): void;
|
|
9
11
|
/** The old release does not participate in an application lock, so check open handles. */
|
|
10
12
|
export declare function backupBeforeConversationCutover(db: DatabaseSync, databasePath: string): string;
|
|
11
13
|
export {};
|
|
@@ -65,10 +65,14 @@ function databaseOwners(databasePath) {
|
|
|
65
65
|
}
|
|
66
66
|
return [...new Set(owners.trim().split(/\s+/).filter((pid) => pid && pid !== String(process.pid)))];
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
69
|
-
function
|
|
68
|
+
/** Offline migrations must reject processes that still hold the database open. */
|
|
69
|
+
function assertDatabaseOffline(databasePath) {
|
|
70
70
|
const otherOwners = databaseOwners(databasePath);
|
|
71
71
|
if (otherOwners.length) throw new Error(`Stop other xopc database processes before upgrading: ${otherOwners.join(", ")}`);
|
|
72
|
+
}
|
|
73
|
+
/** The old release does not participate in an application lock, so check open handles. */
|
|
74
|
+
function backupBeforeConversationCutover(db, databasePath) {
|
|
75
|
+
assertDatabaseOffline(databasePath);
|
|
72
76
|
const backupPath = `${databasePath}.pre-v178-${Date.now()}.bak`;
|
|
73
77
|
db.exec(`VACUUM INTO '${backupPath.replaceAll("'", "''")}'`);
|
|
74
78
|
chmodSync(backupPath, 384);
|
|
@@ -95,4 +99,4 @@ var init_conversation_backup = __esmMin((() => {
|
|
|
95
99
|
}));
|
|
96
100
|
//#endregion
|
|
97
101
|
init_conversation_backup();
|
|
98
|
-
export { backupBeforeConversationCutover, flushBackupFile, init_conversation_backup };
|
|
102
|
+
export { assertDatabaseOffline, backupBeforeConversationCutover, flushBackupFile, init_conversation_backup };
|
|
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
|
|
|
3
3
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
4
4
|
export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 165;
|
|
5
5
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
6
|
-
export declare const XOPC_DB_SCHEMA_VERSION =
|
|
6
|
+
export declare const XOPC_DB_SCHEMA_VERSION = 189;
|
|
7
7
|
export declare function resolveMigrationsDir(override?: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
|
|
@@ -1,50 +1,42 @@
|
|
|
1
1
|
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { init_sql_assets, resolveSqliteAssetPath } from "../sql-assets.js";
|
|
3
3
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
4
4
|
import { init_logger } from "../../../utils/logger.js";
|
|
5
5
|
import { init_schema_version, readSchemaVersion, setSchemaVersion } from "../schema-version.js";
|
|
6
|
+
import { backupBeforeConversationCutover, init_conversation_backup } from "./conversation-backup.js";
|
|
6
7
|
import { init_conversation_uuid, migrateConversationUuids } from "./conversation-uuid.js";
|
|
8
|
+
import { discardExperimentalSceneData, init_scene_reset, resetExperimentalScenes } from "./scene-reset.js";
|
|
7
9
|
import { discoverSqlMigrations, init_discover } from "./discover.js";
|
|
8
10
|
import { DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, DatabaseSchemaTooOldError, init_errors } from "./errors.js";
|
|
9
|
-
import {
|
|
10
|
-
import { chmodSync, existsSync, writeFileSync } from "node:fs";
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { writeFileSync } from "node:fs";
|
|
12
12
|
//#region src/storage/sqlite/migrations/runner.ts
|
|
13
|
-
function backupBeforeTaskCutover(db, databasePath) {
|
|
14
|
-
db.exec("PRAGMA wal_checkpoint(FULL)");
|
|
15
|
-
const backupPath = `${databasePath}.pre-v100-${Date.now()}.bak`;
|
|
16
|
-
const quotedPath = backupPath.replaceAll("'", "''");
|
|
17
|
-
db.exec(`VACUUM INTO '${quotedPath}'`);
|
|
18
|
-
chmodSync(backupPath, 384);
|
|
19
|
-
return backupPath;
|
|
20
|
-
}
|
|
21
13
|
function writeMigrationReport(backupPath, report) {
|
|
22
14
|
writeFileSync(`${backupPath}.report.json`, `${JSON.stringify(report, null, 2)}\n`, { mode: 384 });
|
|
23
15
|
}
|
|
24
16
|
function resolveMigrationsDir(override) {
|
|
25
17
|
if (override) return override;
|
|
26
|
-
|
|
27
|
-
if (existsSync(siblingDir)) return siblingDir;
|
|
28
|
-
return MODULE_DIR;
|
|
18
|
+
return resolveSqliteAssetPath("migrations");
|
|
29
19
|
}
|
|
30
20
|
function migrationByTarget(migrations, targetVersion) {
|
|
31
21
|
return migrations.find((migration) => migration.targetVersion === targetVersion);
|
|
32
22
|
}
|
|
33
|
-
function applySingleMigration(db, migration) {
|
|
23
|
+
function applySingleMigration(db, migration, discardOldScenes = false) {
|
|
34
24
|
log.info({
|
|
35
25
|
targetVersion: migration.targetVersion,
|
|
36
26
|
file: migration.filename
|
|
37
27
|
}, "Applying SQLite migration");
|
|
38
|
-
const
|
|
28
|
+
const requiresForeignKeyPause = discardOldScenes || migration.targetVersion === 179 || migration.targetVersion === 182 || migration.targetVersion === 188;
|
|
39
29
|
const foreignKeysEnabled = Number(db.prepare("PRAGMA foreign_keys").get()?.foreign_keys) === 1;
|
|
40
|
-
if (
|
|
30
|
+
if (requiresForeignKeyPause) db.exec("PRAGMA foreign_keys = OFF");
|
|
41
31
|
let transactionStarted = false;
|
|
42
32
|
try {
|
|
43
33
|
db.exec("BEGIN IMMEDIATE");
|
|
44
34
|
transactionStarted = true;
|
|
35
|
+
if (discardOldScenes) discardExperimentalSceneData(db);
|
|
45
36
|
db.exec(migration.sql);
|
|
37
|
+
if (migration.targetVersion === 188) resetExperimentalScenes(db);
|
|
46
38
|
const summary = migration.targetVersion === 178 ? migrateConversationUuids(db) : void 0;
|
|
47
|
-
if (
|
|
39
|
+
if (requiresForeignKeyPause && db.prepare("PRAGMA foreign_key_check").all().length > 0) throw new Error("Schema migration would violate foreign key integrity");
|
|
48
40
|
setSchemaVersion(db, migration.targetVersion);
|
|
49
41
|
db.exec("COMMIT");
|
|
50
42
|
return summary;
|
|
@@ -55,7 +47,7 @@ function applySingleMigration(db, migration) {
|
|
|
55
47
|
const em = error instanceof Error ? error.message : String(error);
|
|
56
48
|
throw new Error(`SQLite migration to v${migration.targetVersion} (${migration.filename}) failed: ${em}`, { cause: error });
|
|
57
49
|
} finally {
|
|
58
|
-
if (
|
|
50
|
+
if (requiresForeignKeyPause && foreignKeysEnabled) db.exec("PRAGMA foreign_keys = ON");
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
53
|
/**
|
|
@@ -63,13 +55,12 @@ function applySingleMigration(db, migration) {
|
|
|
63
55
|
* Each step runs in its own transaction and updates schema_meta on success.
|
|
64
56
|
*/
|
|
65
57
|
function applyPendingMigrations(db, options = {}) {
|
|
66
|
-
const targetVersion = options.targetVersion ??
|
|
58
|
+
const targetVersion = options.targetVersion ?? 189;
|
|
67
59
|
let currentVersion = readSchemaVersion(db);
|
|
68
60
|
if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
|
|
69
61
|
if (!options.migrationsDir && currentVersion < 165) throw new DatabaseSchemaTooOldError(currentVersion, 165);
|
|
70
62
|
if (currentVersion >= targetVersion) return currentVersion;
|
|
71
63
|
const migrations = discoverSqlMigrations(resolveMigrationsDir(options.migrationsDir));
|
|
72
|
-
let cutoverBackupPath;
|
|
73
64
|
let conversationSummary;
|
|
74
65
|
const fromVersion = currentVersion;
|
|
75
66
|
const conversationBackup = currentVersion < 178 && targetVersion >= 178 && options.databasePath && options.databasePath !== ":memory:" ? backupBeforeConversationCutover(db, options.databasePath) : void 0;
|
|
@@ -77,18 +68,9 @@ function applyPendingMigrations(db, options = {}) {
|
|
|
77
68
|
const nextVersion = currentVersion + 1;
|
|
78
69
|
const migration = migrationByTarget(migrations, nextVersion);
|
|
79
70
|
if (!migration) throw new DatabaseSchemaMigrationGapError(currentVersion, targetVersion, nextVersion);
|
|
80
|
-
if (nextVersion === 100 && options.databasePath && options.databasePath !== ":memory:") cutoverBackupPath = backupBeforeTaskCutover(db, options.databasePath);
|
|
81
71
|
try {
|
|
82
|
-
conversationSummary = applySingleMigration(db, migration) ?? conversationSummary;
|
|
72
|
+
conversationSummary = applySingleMigration(db, migration, !options.migrationsDir && targetVersion >= 188 && fromVersion < 178 && currentVersion === fromVersion) ?? conversationSummary;
|
|
83
73
|
} catch (error) {
|
|
84
|
-
if (cutoverBackupPath && nextVersion === 100) writeMigrationReport(cutoverBackupPath, {
|
|
85
|
-
fromVersion: currentVersion,
|
|
86
|
-
targetVersion: nextVersion,
|
|
87
|
-
status: "failed",
|
|
88
|
-
rollback: "transaction",
|
|
89
|
-
error: error instanceof Error ? error.message : String(error),
|
|
90
|
-
occurredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
91
|
-
});
|
|
92
74
|
if (conversationBackup) writeMigrationReport(conversationBackup, {
|
|
93
75
|
fromVersion,
|
|
94
76
|
targetVersion,
|
|
@@ -99,13 +81,6 @@ function applyPendingMigrations(db, options = {}) {
|
|
|
99
81
|
throw error;
|
|
100
82
|
}
|
|
101
83
|
currentVersion = nextVersion;
|
|
102
|
-
if (cutoverBackupPath && currentVersion === 100) writeMigrationReport(cutoverBackupPath, {
|
|
103
|
-
fromVersion: 99,
|
|
104
|
-
targetVersion: 100,
|
|
105
|
-
status: "succeeded",
|
|
106
|
-
backupPath: cutoverBackupPath,
|
|
107
|
-
occurredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
108
|
-
});
|
|
109
84
|
}
|
|
110
85
|
if (conversationBackup) writeMigrationReport(conversationBackup, {
|
|
111
86
|
fromVersion,
|
|
@@ -118,7 +93,7 @@ function applyPendingMigrations(db, options = {}) {
|
|
|
118
93
|
}
|
|
119
94
|
/** Inspect schema version without mutating the database. */
|
|
120
95
|
function inspectSchemaMigrationStatus(db, options = {}) {
|
|
121
|
-
const appVersion = options.targetVersion ??
|
|
96
|
+
const appVersion = options.targetVersion ?? 189;
|
|
122
97
|
const dbVersion = readSchemaVersion(db);
|
|
123
98
|
if (dbVersion > appVersion) return {
|
|
124
99
|
dbVersion,
|
|
@@ -147,18 +122,19 @@ function inspectSchemaMigrationStatus(db, options = {}) {
|
|
|
147
122
|
missingVersion
|
|
148
123
|
};
|
|
149
124
|
}
|
|
150
|
-
var log, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_SCHEMA_VERSION
|
|
125
|
+
var log, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_SCHEMA_VERSION;
|
|
151
126
|
var init_runner = __esmMin((() => {
|
|
152
|
-
init_conversation_backup();
|
|
153
127
|
init_logger();
|
|
154
128
|
init_schema_version();
|
|
129
|
+
init_sql_assets();
|
|
130
|
+
init_conversation_backup();
|
|
155
131
|
init_conversation_uuid();
|
|
132
|
+
init_scene_reset();
|
|
156
133
|
init_discover();
|
|
157
134
|
init_errors();
|
|
158
135
|
log = createLogger("Sqlite:Migrations");
|
|
159
136
|
XOPC_DB_BASELINE_SCHEMA_VERSION = 165;
|
|
160
|
-
XOPC_DB_SCHEMA_VERSION =
|
|
161
|
-
MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
137
|
+
XOPC_DB_SCHEMA_VERSION = 189;
|
|
162
138
|
}));
|
|
163
139
|
//#endregion
|
|
164
140
|
init_runner();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
/** Discard obsolete payloads before historical migrations try to interpret them. */
|
|
3
|
+
export declare function discardExperimentalSceneData(db: DatabaseSync): void;
|
|
4
|
+
/** v188 installs current storage; the migration runner owns the transaction and FK checks. */
|
|
5
|
+
export declare function resetExperimentalScenes(db: DatabaseSync): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __esmMin } from "../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { NOTIFICATION_LEDGER_TABLES, init_scenes_schema, installSceneStorage } from "../scenes-schema.js";
|
|
3
|
+
//#region src/storage/sqlite/migrations/scene-reset.ts
|
|
4
|
+
/** Discard obsolete payloads before historical migrations try to interpret them. */
|
|
5
|
+
function discardExperimentalSceneData(db) {
|
|
6
|
+
const triggers = db.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name GLOB 'proactive_*'").all();
|
|
7
|
+
for (const trigger of triggers) db.exec(`DROP TRIGGER ${quote(String(trigger.name))}`);
|
|
8
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND (name GLOB 'proactive_*' OR name = 'heartbeat_checks') AND name NOT IN ('proactive_scenarios', 'proactive_scenario_versions')").all();
|
|
9
|
+
for (const table of tables) db.exec(`DELETE FROM ${quote(String(table.name))}`);
|
|
10
|
+
for (const trigger of triggers) db.exec(String(trigger.sql));
|
|
11
|
+
const discarded = "SELECT event_id FROM notification_events WHERE event_type IN ('proactive.insight', 'scene.result', 'scene.digest')";
|
|
12
|
+
for (const table of ["notification_deliveries", "notification_acknowledgements"]) db.exec(`DELETE FROM ${table} WHERE event_id IN (${discarded})`);
|
|
13
|
+
db.exec(`DELETE FROM notification_events WHERE event_id IN (${discarded})`);
|
|
14
|
+
}
|
|
15
|
+
/** v188 installs current storage; the migration runner owns the transaction and FK checks. */
|
|
16
|
+
function resetExperimentalScenes(db) {
|
|
17
|
+
const ledger = new Set(NOTIFICATION_LEDGER_TABLES);
|
|
18
|
+
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type = 'table'").all();
|
|
19
|
+
for (const table of tables) {
|
|
20
|
+
const name = String(table.name);
|
|
21
|
+
if (name.startsWith("scene_") || ledger.has(name)) db.exec(`DROP TABLE ${quote(name)}`);
|
|
22
|
+
}
|
|
23
|
+
discardExperimentalSceneData(db);
|
|
24
|
+
for (const table of tables) {
|
|
25
|
+
const name = String(table.name);
|
|
26
|
+
if (name.startsWith("proactive_") || name === "heartbeat_checks" || name === "project_monitoring_policies") db.exec(`DROP TABLE ${quote(name)}`);
|
|
27
|
+
}
|
|
28
|
+
db.exec(`DROP INDEX IF EXISTS idx_connector_sync_policies_proactive;
|
|
29
|
+
ALTER TABLE connector_sync_policies DROP COLUMN proactive_enabled;
|
|
30
|
+
ALTER TABLE connector_sync_policies DROP COLUMN allowed_scenario_keys_json;`);
|
|
31
|
+
installSceneStorage(db);
|
|
32
|
+
}
|
|
33
|
+
var quote;
|
|
34
|
+
var init_scene_reset = __esmMin((() => {
|
|
35
|
+
init_scenes_schema();
|
|
36
|
+
quote = (name) => `"${name.replaceAll("\"", "\"\"")}"`;
|
|
37
|
+
}));
|
|
38
|
+
//#endregion
|
|
39
|
+
init_scene_reset();
|
|
40
|
+
export { discardExperimentalSceneData, init_scene_reset, resetExperimentalScenes };
|