@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,109 @@
|
|
|
1
|
+
//#region src/notifications/dispatch.ts
|
|
2
|
+
/** Owns durable delivery only. The host supplies policy and transports; neither may widen the saved scope. */
|
|
3
|
+
var NotificationDispatcher = class {
|
|
4
|
+
active = null;
|
|
5
|
+
stopped = false;
|
|
6
|
+
constructor(db, dependencies) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
this.dependencies = dependencies;
|
|
9
|
+
const timeout = dependencies.timeoutMs ?? 15e3;
|
|
10
|
+
if (!Number.isInteger(timeout) || timeout < 1 || timeout > 6e4) throw new Error("Invalid dispatch timeout");
|
|
11
|
+
}
|
|
12
|
+
/** Called by the host notification pump; overlapping passes never make a second claim. */
|
|
13
|
+
drainOne() {
|
|
14
|
+
if (this.stopped || this.active) return Promise.resolve(false);
|
|
15
|
+
const controller = new AbortController();
|
|
16
|
+
const work = Promise.resolve().then(() => this.deliver(controller)).finally(() => {
|
|
17
|
+
this.active = null;
|
|
18
|
+
});
|
|
19
|
+
this.active = {
|
|
20
|
+
controller,
|
|
21
|
+
work
|
|
22
|
+
};
|
|
23
|
+
return work;
|
|
24
|
+
}
|
|
25
|
+
async stop() {
|
|
26
|
+
this.stopped = true;
|
|
27
|
+
const active = this.active;
|
|
28
|
+
active?.controller.abort();
|
|
29
|
+
await active?.work;
|
|
30
|
+
}
|
|
31
|
+
now() {
|
|
32
|
+
return (this.dependencies.clock ?? Date.now)();
|
|
33
|
+
}
|
|
34
|
+
async deliver(controller) {
|
|
35
|
+
if (controller.signal.aborted) return false;
|
|
36
|
+
const now = this.now();
|
|
37
|
+
this.db.prepare(`UPDATE notification_dispatches SET status = 'unknown', lease_until = NULL, last_error = 'lease_expired'
|
|
38
|
+
WHERE status = 'sending' AND (lease_until IS NULL OR lease_until <= ?)`).run(now);
|
|
39
|
+
const row = this.db.prepare(`UPDATE notification_dispatches SET status = 'sending', attempt = attempt + 1, lease_until = ?
|
|
40
|
+
WHERE id = (SELECT id FROM notification_dispatches WHERE status = 'pending' AND next_attempt_at <= ?
|
|
41
|
+
ORDER BY next_attempt_at, id LIMIT 1) AND status = 'pending' RETURNING *`).get(now + (this.dependencies.timeoutMs ?? 15e3) + 1e3, now);
|
|
42
|
+
if (!row) return false;
|
|
43
|
+
const id = String(row.id);
|
|
44
|
+
const attempt = Number(row.attempt);
|
|
45
|
+
const failures = Number(row.failure_count);
|
|
46
|
+
const finish = (status, reason, retryAt = this.now(), receipt = null, failed = false) => this.db.prepare(`UPDATE notification_dispatches SET status = ?, last_error = ?, next_attempt_at = ?,
|
|
47
|
+
provider_message_id = ?, failure_count = failure_count + ?, lease_until = NULL
|
|
48
|
+
WHERE id = ? AND attempt = ? AND status = 'sending' AND lease_until > ?`).run(status, reason, retryAt, receipt, failed ? 1 : 0, id, attempt, this.now());
|
|
49
|
+
let sending = false;
|
|
50
|
+
let onAbort = () => {};
|
|
51
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
52
|
+
onAbort = () => reject(/* @__PURE__ */ new Error("Dispatch cancelled"));
|
|
53
|
+
});
|
|
54
|
+
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
55
|
+
const timer = setTimeout(() => controller.abort(), this.dependencies.timeoutMs ?? 15e3);
|
|
56
|
+
try {
|
|
57
|
+
const dispatch = {
|
|
58
|
+
id,
|
|
59
|
+
notificationId: String(row.notification_id),
|
|
60
|
+
ownerId: String(row.owner_id),
|
|
61
|
+
workspaceId: String(row.workspace_id),
|
|
62
|
+
channel: row.channel,
|
|
63
|
+
destinationId: String(row.destination_id),
|
|
64
|
+
destination: row.destination_json === null ? null : JSON.parse(String(row.destination_json)),
|
|
65
|
+
subjectId: row.subject_id === null ? null : String(row.subject_id),
|
|
66
|
+
subjectRevision: Number(row.subject_revision),
|
|
67
|
+
attempt
|
|
68
|
+
};
|
|
69
|
+
const policy = await Promise.race([this.dependencies.authorize(dispatch, controller.signal), cancelled]);
|
|
70
|
+
if (controller.signal.aborted) throw new Error("Dispatch cancelled");
|
|
71
|
+
if (policy.action === "cancel") {
|
|
72
|
+
finish("cancelled", "policy_cancelled");
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (policy.action === "defer") {
|
|
76
|
+
if (!Number.isSafeInteger(policy.until) || policy.until <= this.now()) throw new Error("Invalid notification deferral");
|
|
77
|
+
finish("pending", "policy_deferred", policy.until);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (policy.action !== "send") throw new Error("Invalid dispatch policy");
|
|
81
|
+
if (!this.db.prepare("SELECT 1 FROM notification_dispatches WHERE id = ? AND attempt = ? AND status = 'sending' AND lease_until > ?").get(id, attempt, this.now())) return true;
|
|
82
|
+
sending = true;
|
|
83
|
+
const receipt = await Promise.race([this.dependencies.send(dispatch, controller.signal), cancelled]);
|
|
84
|
+
if (controller.signal.aborted) throw new Error("Dispatch cancelled");
|
|
85
|
+
if (receipt.status === "accepted") {
|
|
86
|
+
if (dispatch.channel === "telegram" && !receipt.providerMessageId?.trim()) {
|
|
87
|
+
finish("unknown", "missing_provider_receipt");
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
finish("accepted", null, this.now(), receipt.providerMessageId);
|
|
91
|
+
} else if (receipt.status === "rejected") {
|
|
92
|
+
const retryAt = receipt.retryAt;
|
|
93
|
+
if (retryAt !== void 0 && (!Number.isSafeInteger(retryAt) || retryAt <= this.now())) {
|
|
94
|
+
finish("failed", "invalid_retry_time");
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
finish(retryAt !== void 0 && failures + 1 < 5 ? "pending" : "failed", "provider_rejected", retryAt ?? this.now(), null, true);
|
|
98
|
+
} else finish("unknown", "invalid_provider_receipt");
|
|
99
|
+
} catch {
|
|
100
|
+
finish(sending ? "unknown" : failures + 1 < 5 ? "pending" : "failed", sending ? "transport_unconfirmed" : "policy_unavailable", this.now() + 3e4, null, true);
|
|
101
|
+
} finally {
|
|
102
|
+
clearTimeout(timer);
|
|
103
|
+
controller.signal.removeEventListener("abort", onAbort);
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { NotificationDispatcher };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ProductNotification, ProductNotificationType } from '@xopcai/gateway-contract';
|
|
2
|
+
import type { NotificationPlan } from './planner.js';
|
|
3
|
+
import type { NotificationDevice, NotificationPreferences } from './types.js';
|
|
4
|
+
/** Domain decisions are injected by the host; transports never load domain runtimes. */
|
|
5
|
+
export interface NotificationDomainDelivery {
|
|
6
|
+
owns(type: ProductNotificationType): boolean;
|
|
7
|
+
allowsDevice(preferences: NotificationPreferences): boolean;
|
|
8
|
+
planEvent(type: string, payload: unknown): NotificationPlan | null;
|
|
9
|
+
prepare(plan: NotificationPlan, devices: NotificationDevice[]): {
|
|
10
|
+
plan: NotificationPlan;
|
|
11
|
+
deviceIds: string[];
|
|
12
|
+
enqueue(notification: ProductNotification): void;
|
|
13
|
+
};
|
|
14
|
+
flush(persist: (plan: NotificationPlan) => ProductNotification | null): ProductNotification[];
|
|
15
|
+
drain(): Promise<void>;
|
|
16
|
+
recheckMobile(notification: ProductNotification): 'send' | 'cancel' | Date;
|
|
17
|
+
mobilePreview(notification: ProductNotification, locale: string): {
|
|
18
|
+
title: string;
|
|
19
|
+
body: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -122,41 +122,6 @@ function automationPlan(payload) {
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
function proactivePlan(payload) {
|
|
126
|
-
if (!payload || typeof payload !== "object") return null;
|
|
127
|
-
const item = payload;
|
|
128
|
-
if (typeof item.id !== "string" || typeof item.insightId !== "string" || typeof item.insight?.title !== "string") return null;
|
|
129
|
-
const requiresDecision = item.insight.attentionKind === "decision";
|
|
130
|
-
const highUrgency = item.insight.urgency === "high" || item.insight.urgency === "critical";
|
|
131
|
-
if (item.insight.attentionKind === "receipt") return null;
|
|
132
|
-
if (!requiresDecision && !highUrgency) return null;
|
|
133
|
-
const title = item.insight.title.trim().slice(0, 120);
|
|
134
|
-
const summary = typeof item.insight.summary === "string" ? item.insight.summary.trim().slice(0, 180) : "";
|
|
135
|
-
return {
|
|
136
|
-
dedupeKey: `proactive.insight:${item.id}${item.notificationRevision && item.notificationRevision > 1 ? `:${item.notificationRevision}` : ""}`,
|
|
137
|
-
notification: {
|
|
138
|
-
type: "proactive.insight",
|
|
139
|
-
target: {
|
|
140
|
-
kind: "insight",
|
|
141
|
-
inboxItemId: item.id
|
|
142
|
-
},
|
|
143
|
-
priority: requiresDecision || highUrgency ? "high" : "normal",
|
|
144
|
-
title: {
|
|
145
|
-
en: title,
|
|
146
|
-
zh: title
|
|
147
|
-
},
|
|
148
|
-
...summary ? { body: {
|
|
149
|
-
en: summary,
|
|
150
|
-
zh: summary
|
|
151
|
-
} } : {},
|
|
152
|
-
payload: {
|
|
153
|
-
inboxItemId: item.id,
|
|
154
|
-
insightId: item.insightId,
|
|
155
|
-
notificationRevision: item.notificationRevision ?? 1
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
125
|
function workDiscoveryPlan(eventType, payload) {
|
|
161
126
|
if (!payload || typeof payload !== "object") return null;
|
|
162
127
|
const event = payload;
|
|
@@ -195,7 +160,6 @@ function notificationPlanFromGatewayEvent(type, payload) {
|
|
|
195
160
|
if (type === "agent.run.ended") return chatPlan(payload);
|
|
196
161
|
if (type === "task.attention_required.v2" || type === "task.phase_changed.v2") return taskPlan(payload);
|
|
197
162
|
if (type === "automation.run.completed") return automationPlan(payload);
|
|
198
|
-
if (type === "proactive.inbox.created") return proactivePlan(payload);
|
|
199
163
|
if (type === "work-discovery.completed" || type === "work-discovery.failed") return workDiscoveryPlan(type, payload);
|
|
200
164
|
return null;
|
|
201
165
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/notifications/quietHours.ts
|
|
2
|
+
/** Resolves a local-hour quiet window on the UTC timeline, including DST gaps and repeated hours. */
|
|
3
|
+
function notificationQuietUntil(input, now) {
|
|
4
|
+
if (!Number.isSafeInteger(now) || now < 0 || ![input.quietStartHour, input.quietEndHour].every((hour) => Number.isInteger(hour) && hour >= 0 && hour < 24)) throw new Error("Invalid quiet hours");
|
|
5
|
+
if (input.quietStartHour === input.quietEndHour) return null;
|
|
6
|
+
const formatter = new Intl.DateTimeFormat("en", {
|
|
7
|
+
timeZone: input.timezone,
|
|
8
|
+
hour: "2-digit",
|
|
9
|
+
hourCycle: "h23"
|
|
10
|
+
});
|
|
11
|
+
const quiet = (at) => {
|
|
12
|
+
const hour = Number(formatter.format(at));
|
|
13
|
+
return input.quietStartHour < input.quietEndHour ? hour >= input.quietStartHour && hour < input.quietEndHour : hour >= input.quietStartHour || hour < input.quietEndHour;
|
|
14
|
+
};
|
|
15
|
+
if (!quiet(now)) return null;
|
|
16
|
+
for (let minute = 1; minute <= 2880; minute++) {
|
|
17
|
+
const candidate = Math.floor(now / 6e4) * 6e4 + minute * 6e4;
|
|
18
|
+
if (!quiet(candidate)) return candidate;
|
|
19
|
+
}
|
|
20
|
+
throw new Error("Quiet hours did not resolve within two days");
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { notificationQuietUntil };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
export interface NotificationResult {
|
|
3
|
+
id: string;
|
|
4
|
+
ownerId: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
subjectId: string;
|
|
7
|
+
}
|
|
8
|
+
export type PublicationDecision = ({
|
|
9
|
+
action: 'settle';
|
|
10
|
+
} | {
|
|
11
|
+
action: 'defer';
|
|
12
|
+
until: number;
|
|
13
|
+
}) & {
|
|
14
|
+
reason?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Publishes only database work. Transport calls belong to NotificationDispatcher, outside this transaction. */
|
|
17
|
+
export declare class NotificationResultOutbox {
|
|
18
|
+
private readonly db;
|
|
19
|
+
private readonly publish;
|
|
20
|
+
private readonly clock;
|
|
21
|
+
constructor(db: DatabaseSync, publish: (result: NotificationResult) => PublicationDecision, clock?: () => number);
|
|
22
|
+
drainOne(): boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/notifications/resultOutbox.ts
|
|
2
|
+
/** Publishes only database work. Transport calls belong to NotificationDispatcher, outside this transaction. */
|
|
3
|
+
var NotificationResultOutbox = class {
|
|
4
|
+
constructor(db, publish, clock = Date.now) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
this.publish = publish;
|
|
7
|
+
this.clock = clock;
|
|
8
|
+
}
|
|
9
|
+
drainOne() {
|
|
10
|
+
const now = this.clock();
|
|
11
|
+
this.db.exec("SAVEPOINT notification_result_publication");
|
|
12
|
+
let id;
|
|
13
|
+
let attempt = 0;
|
|
14
|
+
try {
|
|
15
|
+
const row = this.db.prepare(`SELECT * FROM notification_result_outbox
|
|
16
|
+
WHERE (status = 'pending' AND next_attempt_at <= ?)
|
|
17
|
+
OR (status = 'processing' AND (lease_until IS NULL OR lease_until <= ?))
|
|
18
|
+
ORDER BY next_attempt_at, id LIMIT 1`).get(now, now);
|
|
19
|
+
if (!row) {
|
|
20
|
+
this.db.exec("RELEASE notification_result_publication");
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
id = String(row.id);
|
|
24
|
+
attempt = Number(row.attempt);
|
|
25
|
+
this.db.prepare(`UPDATE notification_result_outbox SET status = 'processing', lease_until = ?, updated_at = ? WHERE id = ?`).run(now + 3e4, now, id);
|
|
26
|
+
const decision = this.publish({
|
|
27
|
+
id,
|
|
28
|
+
ownerId: String(row.owner_id),
|
|
29
|
+
workspaceId: String(row.workspace_id),
|
|
30
|
+
subjectId: String(row.subject_id)
|
|
31
|
+
});
|
|
32
|
+
if (!decision || !["settle", "defer"].includes(decision.action) || decision.reason !== void 0 && !/^[a-z][a-z0-9_]{0,79}$/.test(decision.reason) || decision.action === "defer" && (!Number.isSafeInteger(decision.until) || decision.until <= now)) throw new Error("Notification publication must return a synchronous decision");
|
|
33
|
+
this.db.prepare(`UPDATE notification_result_outbox SET status = ?, next_attempt_at = ?, lease_until = NULL,
|
|
34
|
+
last_error = NULL, decision_reason = ?, settled_at = ?, updated_at = ? WHERE id = ?`).run(decision.action === "settle" ? "settled" : "pending", decision.action === "defer" ? decision.until : now, decision.reason ?? null, decision.action === "settle" ? now : null, now, id);
|
|
35
|
+
this.db.exec("RELEASE notification_result_publication");
|
|
36
|
+
return true;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
this.db.exec("ROLLBACK TO notification_result_publication");
|
|
39
|
+
this.db.exec("RELEASE notification_result_publication");
|
|
40
|
+
if (!id) throw error;
|
|
41
|
+
this.db.prepare(`UPDATE notification_result_outbox SET status = ?, attempt = attempt + 1, next_attempt_at = ?,
|
|
42
|
+
lease_until = NULL, last_error = 'publication_failed', updated_at = ?
|
|
43
|
+
WHERE id = ? AND attempt = ? AND (status = 'pending' OR (status = 'processing' AND (lease_until IS NULL OR lease_until <= ?)))`).run(attempt + 1 >= 5 ? "failed" : "pending", now + 3e4, now, id, attempt, now);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { NotificationResultOutbox };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ProactiveChannelSender } from './proactive-channel.js';
|
|
2
1
|
import { type NotificationPlan } from './planner.js';
|
|
2
|
+
import type { NotificationDomainDelivery } from './domain-delivery.js';
|
|
3
3
|
import { sendHarmonyPush } from './harmony-push.js';
|
|
4
4
|
export declare class NotificationService {
|
|
5
5
|
private readonly options;
|
|
@@ -9,7 +9,7 @@ export declare class NotificationService {
|
|
|
9
9
|
constructor(options: {
|
|
10
10
|
publish: (type: string, payload: unknown) => void;
|
|
11
11
|
fetch?: typeof fetch;
|
|
12
|
-
|
|
12
|
+
domainDelivery?: NotificationDomainDelivery;
|
|
13
13
|
sendHarmony?: typeof sendHarmonyPush;
|
|
14
14
|
});
|
|
15
15
|
start(): void;
|
|
@@ -19,7 +19,7 @@ export declare class NotificationService {
|
|
|
19
19
|
persistGatewayEvent(type: string, payload: unknown): {
|
|
20
20
|
schemaVersion: 1;
|
|
21
21
|
id: string;
|
|
22
|
-
type: "work_discovery.completed" | "work_discovery.failed" | "chat.completed" | "chat.failed" | "task.needs_input" | "task.blocked" | "task.failed" | "task.completed" | "automation.completed" | "automation.failed" | "proactive.insight";
|
|
22
|
+
type: "work_discovery.completed" | "work_discovery.failed" | "scene.result" | "scene.digest" | "chat.completed" | "chat.failed" | "task.needs_input" | "task.blocked" | "task.failed" | "task.completed" | "automation.completed" | "automation.failed" | "proactive.insight";
|
|
23
23
|
priority: "normal" | "high";
|
|
24
24
|
title: {
|
|
25
25
|
en: string;
|
|
@@ -28,6 +28,13 @@ export declare class NotificationService {
|
|
|
28
28
|
payload: Record<string, unknown>;
|
|
29
29
|
createdAt: number;
|
|
30
30
|
target?: {
|
|
31
|
+
kind: "scene_result";
|
|
32
|
+
activationId: string;
|
|
33
|
+
presentationId: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "scene_digest";
|
|
36
|
+
digestId: string;
|
|
37
|
+
} | {
|
|
31
38
|
kind: "chat";
|
|
32
39
|
conversationId: string;
|
|
33
40
|
} | {
|
|
@@ -56,7 +63,7 @@ export declare class NotificationService {
|
|
|
56
63
|
persistPlan(plan: NotificationPlan): {
|
|
57
64
|
schemaVersion: 1;
|
|
58
65
|
id: string;
|
|
59
|
-
type: "work_discovery.completed" | "work_discovery.failed" | "chat.completed" | "chat.failed" | "task.needs_input" | "task.blocked" | "task.failed" | "task.completed" | "automation.completed" | "automation.failed" | "proactive.insight";
|
|
66
|
+
type: "work_discovery.completed" | "work_discovery.failed" | "scene.result" | "scene.digest" | "chat.completed" | "chat.failed" | "task.needs_input" | "task.blocked" | "task.failed" | "task.completed" | "automation.completed" | "automation.failed" | "proactive.insight";
|
|
60
67
|
priority: "normal" | "high";
|
|
61
68
|
title: {
|
|
62
69
|
en: string;
|
|
@@ -65,6 +72,13 @@ export declare class NotificationService {
|
|
|
65
72
|
payload: Record<string, unknown>;
|
|
66
73
|
createdAt: number;
|
|
67
74
|
target?: {
|
|
75
|
+
kind: "scene_result";
|
|
76
|
+
activationId: string;
|
|
77
|
+
presentationId: string;
|
|
78
|
+
} | {
|
|
79
|
+
kind: "scene_digest";
|
|
80
|
+
digestId: string;
|
|
81
|
+
} | {
|
|
68
82
|
kind: "chat";
|
|
69
83
|
conversationId: string;
|
|
70
84
|
} | {
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import {
|
|
3
|
+
import { init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
4
4
|
import { localizeNotification } from "../../packages/gateway-contract/src/notifications.js";
|
|
5
5
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
6
6
|
import { getOrCreateGatewayIdentity } from "../storage/sqlite/gateway-identity-repository.js";
|
|
7
|
-
import {
|
|
8
|
-
import { flushDueDigests } from "../proactive/inbox/digest.js";
|
|
7
|
+
import { disableNotificationDeviceForPushToken, listDeliverableNotificationDevices } from "./device-store.js";
|
|
9
8
|
import { notificationPlanFromGatewayEvent } from "./planner.js";
|
|
10
|
-
import { proactiveNotificationWorkspace, recheckNotificationDelivery } from "./proactive-policy.js";
|
|
11
9
|
import { createNotificationEvent, deferNotificationDelivery, expireUndeliverableNotificationDeliveries, listDueNotificationDeliveries, markNotificationDeliveryAccepted, markNotificationDeliveryDead, markNotificationDeliveryDelivered, pruneNotificationEvents, rescheduleNotificationDelivery } from "./store.js";
|
|
12
|
-
import { drainChannelNotifications, enqueueChannelNotification } from "./proactive-channel.js";
|
|
13
|
-
import { drainBrowserPush, enqueueBrowserPush } from "./web-push.js";
|
|
14
|
-
import { disableNotificationDeviceForPushToken, listDeliverableNotificationDevices } from "./device-store.js";
|
|
15
10
|
import { sendHarmonyPush } from "./harmony-push.js";
|
|
16
11
|
//#region src/notifications/service.ts
|
|
17
12
|
init_transaction();
|
|
@@ -29,20 +24,21 @@ const RETRY_DELAYS_MS = [
|
|
|
29
24
|
216e5
|
|
30
25
|
];
|
|
31
26
|
const RECEIPT_DELAY_MS = 15 * 6e4;
|
|
27
|
+
const STANDARD_PREFERENCES = {
|
|
28
|
+
"chat.completed": "chatCompleted",
|
|
29
|
+
"chat.failed": "chatFailed",
|
|
30
|
+
"task.needs_input": "taskNeedsInput",
|
|
31
|
+
"task.blocked": "taskBlocked",
|
|
32
|
+
"task.failed": "taskFailed",
|
|
33
|
+
"task.completed": "taskCompleted",
|
|
34
|
+
"automation.completed": "automationCompleted",
|
|
35
|
+
"automation.failed": "automationFailed",
|
|
36
|
+
"work_discovery.completed": true,
|
|
37
|
+
"work_discovery.failed": true
|
|
38
|
+
};
|
|
32
39
|
function preferenceAllows(type, preferences) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
case "chat.failed": return preferences.chatFailed;
|
|
36
|
-
case "task.needs_input": return preferences.taskNeedsInput;
|
|
37
|
-
case "task.blocked": return preferences.taskBlocked;
|
|
38
|
-
case "task.failed": return preferences.taskFailed;
|
|
39
|
-
case "task.completed": return preferences.taskCompleted;
|
|
40
|
-
case "automation.completed": return preferences.automationCompleted;
|
|
41
|
-
case "automation.failed": return preferences.automationFailed;
|
|
42
|
-
case "proactive.insight": return preferences.proactiveInsight;
|
|
43
|
-
case "work_discovery.completed":
|
|
44
|
-
case "work_discovery.failed": return true;
|
|
45
|
-
}
|
|
40
|
+
const key = STANDARD_PREFERENCES[type];
|
|
41
|
+
return key === true || key !== void 0 && preferences[key];
|
|
46
42
|
}
|
|
47
43
|
function retryAt(attempts, now) {
|
|
48
44
|
return now + RETRY_DELAYS_MS[Math.min(attempts, RETRY_DELAYS_MS.length - 1)];
|
|
@@ -82,44 +78,21 @@ var NotificationService = class {
|
|
|
82
78
|
}
|
|
83
79
|
/** Throws on persistence failure so durable producers can retry the handoff. */
|
|
84
80
|
persistGatewayEvent(type, payload) {
|
|
85
|
-
const plan = notificationPlanFromGatewayEvent(type, payload);
|
|
81
|
+
const plan = notificationPlanFromGatewayEvent(type, payload) ?? this.options.domainDelivery?.planEvent(type, payload);
|
|
86
82
|
if (!plan) return null;
|
|
87
83
|
return this.persistPlan(plan);
|
|
88
84
|
}
|
|
89
85
|
persistPlan(plan) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
let selectedChannel = "all";
|
|
94
|
-
if (workspace) {
|
|
95
|
-
const preferences = proactivePreferences(workspace);
|
|
96
|
-
const browsers = getSqliteDatabase().prepare("SELECT id FROM proactive_web_push_subscriptions WHERE workspace_id = ? ORDER BY created_at DESC, id").all(workspace);
|
|
97
|
-
selectedChannel = preferences.preferredChannel === "auto" ? browsers.length ? "browser" : devices.length ? "mobile" : "browser" : preferences.preferredChannel;
|
|
98
|
-
if (!["all", "mobile"].includes(selectedChannel)) devices = [];
|
|
99
|
-
else if (preferences.preferredChannel === "auto") devices = devices.slice(0, 1);
|
|
100
|
-
browserIds = ["all", "browser"].includes(selectedChannel) ? browsers.map((row) => row.id) : [];
|
|
101
|
-
if (preferences.preferredChannel === "auto") browserIds = browserIds.slice(0, 1);
|
|
102
|
-
plan = {
|
|
103
|
-
...plan,
|
|
104
|
-
notification: {
|
|
105
|
-
...plan.notification,
|
|
106
|
-
payload: {
|
|
107
|
-
...plan.notification.payload,
|
|
108
|
-
deliveryChannel: selectedChannel,
|
|
109
|
-
deliveryMode: preferences.preferredChannel
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
86
|
+
const domain = this.options.domainDelivery?.owns(plan.notification.type) ? this.options.domainDelivery : void 0;
|
|
87
|
+
if (!domain && !Object.hasOwn(STANDARD_PREFERENCES, plan.notification.type)) throw new Error("Notification domain delivery is not installed");
|
|
88
|
+
const devices = listDeliverableNotificationDevices().filter((device) => domain ? domain.allowsDevice(device.preferences) : preferenceAllows(plan.notification.type, device.preferences));
|
|
114
89
|
const result = runSqliteWriteTransaction(() => {
|
|
90
|
+
const selection = domain?.prepare(plan, devices);
|
|
115
91
|
const created = createNotificationEvent({
|
|
116
|
-
...plan,
|
|
117
|
-
deviceIds: devices.map((device) => device.id)
|
|
92
|
+
...selection?.plan ?? plan,
|
|
93
|
+
deviceIds: selection?.deviceIds ?? devices.map((device) => device.id)
|
|
118
94
|
});
|
|
119
|
-
if (created.created)
|
|
120
|
-
enqueueBrowserPush(created.notification, browserIds);
|
|
121
|
-
if (workspace && selectedChannel === "telegram") enqueueChannelNotification(created.notification, workspace);
|
|
122
|
-
}
|
|
95
|
+
if (created.created) selection?.enqueue(created.notification);
|
|
123
96
|
return created;
|
|
124
97
|
});
|
|
125
98
|
return result.created ? result.notification : null;
|
|
@@ -134,11 +107,10 @@ var NotificationService = class {
|
|
|
134
107
|
pruneNotificationEvents(now - 720 * 60 * 60 * 1e3);
|
|
135
108
|
this.lastMaintenanceAt = now;
|
|
136
109
|
}
|
|
137
|
-
for (const notification of
|
|
110
|
+
for (const notification of this.options.domainDelivery?.flush((plan) => this.persistPlan(plan)) ?? []) this.options.publish("notification.created", notification);
|
|
138
111
|
await this.deliverPending();
|
|
139
112
|
await this.checkReceipts();
|
|
140
|
-
await
|
|
141
|
-
if (this.options.sendChannel) await drainChannelNotifications(this.options.sendChannel);
|
|
113
|
+
await this.options.domainDelivery?.drain();
|
|
142
114
|
} catch (err) {
|
|
143
115
|
log.warn({ err }, "Notification delivery pass failed");
|
|
144
116
|
} finally {
|
|
@@ -150,10 +122,15 @@ var NotificationService = class {
|
|
|
150
122
|
await Promise.all(deliveries.map((delivery) => this.send(delivery)));
|
|
151
123
|
}
|
|
152
124
|
async send(delivery) {
|
|
153
|
-
|
|
154
|
-
|
|
125
|
+
const domain = this.options.domainDelivery?.owns(delivery.event.type) ? this.options.domainDelivery : void 0;
|
|
126
|
+
if (!domain && !Object.hasOwn(STANDARD_PREFERENCES, delivery.event.type)) {
|
|
127
|
+
markNotificationDeliveryDead(delivery.event.id, delivery.deviceId, "Notification domain delivery is not installed");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (domain) {
|
|
131
|
+
const policy = domain.recheckMobile(delivery.event);
|
|
155
132
|
if (policy === "cancel") {
|
|
156
|
-
markNotificationDeliveryDead(delivery.event.id, delivery.deviceId, "
|
|
133
|
+
markNotificationDeliveryDead(delivery.event.id, delivery.deviceId, "Notification policy changed");
|
|
157
134
|
return;
|
|
158
135
|
}
|
|
159
136
|
if (policy instanceof Date) {
|
|
@@ -163,6 +140,10 @@ var NotificationService = class {
|
|
|
163
140
|
}
|
|
164
141
|
const fetchImpl = this.options.fetch ?? fetch;
|
|
165
142
|
const localized = localizeNotification(delivery.event, delivery.locale);
|
|
143
|
+
const preview = domain?.mobilePreview(delivery.event, delivery.locale) ?? {
|
|
144
|
+
title: localized.localizedTitle,
|
|
145
|
+
body: localized.localizedBody
|
|
146
|
+
};
|
|
166
147
|
try {
|
|
167
148
|
if (delivery.platform === "harmonyos") {
|
|
168
149
|
const ticket = await (this.options.sendHarmony ?? sendHarmonyPush)({
|
|
@@ -170,8 +151,8 @@ var NotificationService = class {
|
|
|
170
151
|
eventId: delivery.event.id,
|
|
171
152
|
gatewayId: getOrCreateGatewayIdentity().id,
|
|
172
153
|
target: delivery.event.target,
|
|
173
|
-
title:
|
|
174
|
-
body:
|
|
154
|
+
title: preview.title,
|
|
155
|
+
body: preview.body
|
|
175
156
|
}, fetchImpl);
|
|
176
157
|
markNotificationDeliveryAccepted(delivery.event.id, delivery.deviceId, ticket, Number.MAX_SAFE_INTEGER);
|
|
177
158
|
return;
|
|
@@ -185,8 +166,8 @@ var NotificationService = class {
|
|
|
185
166
|
signal: AbortSignal.timeout(1e4),
|
|
186
167
|
body: JSON.stringify({
|
|
187
168
|
to: delivery.pushToken,
|
|
188
|
-
title:
|
|
189
|
-
body:
|
|
169
|
+
title: preview.title,
|
|
170
|
+
body: preview.body,
|
|
190
171
|
sound: delivery.event.priority === "high" ? "default" : void 0,
|
|
191
172
|
priority: delivery.event.priority,
|
|
192
173
|
data: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
1
2
|
import { type ProductNotification } from '@xopcai/gateway-contract';
|
|
2
3
|
import type { NotificationDevicePlatform } from './types.js';
|
|
3
4
|
export type NotificationDelivery = {
|
|
@@ -14,7 +15,7 @@ export declare function createNotificationEvent(input: {
|
|
|
14
15
|
notification: Omit<ProductNotification, 'id' | 'createdAt' | 'schemaVersion'>;
|
|
15
16
|
deviceIds: string[];
|
|
16
17
|
createdAt?: number;
|
|
17
|
-
}): {
|
|
18
|
+
}, db?: DatabaseSync): {
|
|
18
19
|
notification: ProductNotification;
|
|
19
20
|
created: boolean;
|
|
20
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
1
|
+
import { getSqliteDatabase, init_transaction, runSqliteSavepoint, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
2
|
import { ProductNotificationSchema } from "../../packages/gateway-contract/src/notifications.js";
|
|
3
3
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -42,10 +42,10 @@ function deliveryFromRow(row) {
|
|
|
42
42
|
...row.provider_ticket_id ? { providerTicketId: row.provider_ticket_id } : {}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
function createNotificationEvent(input) {
|
|
45
|
+
function createNotificationEvent(input, db = getSqliteDatabase()) {
|
|
46
46
|
const id = randomUUID();
|
|
47
47
|
const createdAt = input.createdAt ?? Date.now();
|
|
48
|
-
|
|
48
|
+
return runSqliteSavepoint(db, () => {
|
|
49
49
|
const inserted = db.prepare(`INSERT OR IGNORE INTO notification_events (
|
|
50
50
|
event_id, dedupe_key, event_type, target_json, priority,
|
|
51
51
|
title_en, title_zh, body_en, body_zh, payload_json, created_at
|
|
@@ -56,12 +56,11 @@ function createNotificationEvent(input) {
|
|
|
56
56
|
) VALUES (?, ?, 'pending', ?, ?)`);
|
|
57
57
|
for (const deviceId of input.deviceIds) enqueue.run(id, deviceId, createdAt, createdAt);
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return {
|
|
60
|
+
notification: eventFromRow(db.prepare("SELECT * FROM notification_events WHERE dedupe_key = ?").get(input.dedupeKey)),
|
|
61
|
+
created: inserted
|
|
62
|
+
};
|
|
60
63
|
});
|
|
61
|
-
return {
|
|
62
|
-
notification: eventFromRow(getSqliteDatabase().prepare("SELECT * FROM notification_events WHERE dedupe_key = ?").get(input.dedupeKey)),
|
|
63
|
-
created
|
|
64
|
-
};
|
|
65
64
|
}
|
|
66
65
|
function listNotificationEvents(options = {}) {
|
|
67
66
|
const limit = Math.max(1, Math.min(100, options.limit ?? 50));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ProactiveSignalPublisher } from '../proactive/events/publisher.js';
|
|
2
1
|
import { ProjectStore } from './project-store.js';
|
|
3
2
|
import type { CreateProjectInput, Project, ProjectHealth, ProjectListQuery, ProjectListResult, ProjectMilestone, ProjectUpdate, ProjectWithDetails, SidebarProjectListQuery, UpdateProjectInput } from './types.js';
|
|
4
3
|
import { type WorkspaceProjectMatch } from './workspace-project.js';
|
|
@@ -10,9 +9,7 @@ export type ProjectSuggestion = {
|
|
|
10
9
|
};
|
|
11
10
|
export declare class ProjectService {
|
|
12
11
|
private readonly store;
|
|
13
|
-
|
|
14
|
-
private readonly workspaceId;
|
|
15
|
-
constructor(store?: ProjectStore, signals?: ProactiveSignalPublisher, workspaceId?: string);
|
|
12
|
+
constructor(store?: ProjectStore);
|
|
16
13
|
private listAllProjects;
|
|
17
14
|
create(input: CreateProjectInput): Project;
|
|
18
15
|
get(id: string): Project | null;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { getSessionMetadata } from "../storage/sqlite/session-repository.js";
|
|
2
|
+
import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
|
|
3
3
|
import "../storage/sqlite/index.js";
|
|
4
4
|
import { changedFieldsFromPatch, emitActivity, systemActivityActor, systemActivitySource } from "../activity/emitter.js";
|
|
5
5
|
import { ProjectStore } from "./project-store.js";
|
|
6
6
|
import { ProjectWorkspaceConflictError, ProjectWorkspaceMissingError, canonicalWorkspacePath, ensureWorkspaceDirectory, inferProjectNameFromWorkspaceRoot, isPathSameOrInsideWorkspace, isSafeAutoCreateWorkspaceRoot, resolveWorkspaceProjectRoot, workspaceDirectoryExists } from "./workspace-project.js";
|
|
7
7
|
import { inferProjectExecutionMode } from "./project-kind.js";
|
|
8
8
|
import { bindSessionToProject, listProjectConversationIds, unbindSessionFromProject } from "./session-bind.js";
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
9
|
//#region src/projects/project-service.ts
|
|
11
10
|
init_transaction();
|
|
12
11
|
var ProjectService = class {
|
|
13
|
-
constructor(store = new ProjectStore()
|
|
12
|
+
constructor(store = new ProjectStore()) {
|
|
14
13
|
this.store = store;
|
|
15
|
-
this.signals = signals;
|
|
16
|
-
this.workspaceId = workspaceId;
|
|
17
14
|
}
|
|
18
15
|
listAllProjects() {
|
|
19
16
|
const items = [];
|
|
@@ -188,31 +185,6 @@ var ProjectService = class {
|
|
|
188
185
|
}],
|
|
189
186
|
nowMs: project.updatedAt
|
|
190
187
|
});
|
|
191
|
-
this.signals?.publish({
|
|
192
|
-
type: "project.updated.v1",
|
|
193
|
-
schemaVersion: 1,
|
|
194
|
-
source: {
|
|
195
|
-
kind: "projects",
|
|
196
|
-
id: "local"
|
|
197
|
-
},
|
|
198
|
-
subject: {
|
|
199
|
-
kind: "project",
|
|
200
|
-
id: project.id
|
|
201
|
-
},
|
|
202
|
-
actor: { kind: "system" },
|
|
203
|
-
scope: {
|
|
204
|
-
workspaceId: this.workspaceId,
|
|
205
|
-
projectId: project.id
|
|
206
|
-
},
|
|
207
|
-
occurredAt: new Date(project.updatedAt).toISOString(),
|
|
208
|
-
dedupeKey: `project:${project.id}:${project.updatedAt}:${createHash("sha256").update(JSON.stringify(patch)).digest("hex")}`,
|
|
209
|
-
sensitivity: "personal",
|
|
210
|
-
payload: {
|
|
211
|
-
before,
|
|
212
|
-
after: project,
|
|
213
|
-
changes
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
188
|
return project;
|
|
217
189
|
});
|
|
218
190
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isXopcDatabaseOpen } from "../storage/sqlite/connection.js";
|
|
2
|
-
import { getSessionMetadata } from "../storage/sqlite/session-repository.js";
|
|
2
|
+
import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
|
|
3
3
|
import "../storage/sqlite/index.js";
|
|
4
4
|
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
5
5
|
import { projectWorkspacePath } from "../session/session-workspace.js";
|