@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
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { getInboxItem } from "../../../proactive/inbox/repository.js";
|
|
2
|
-
import { listCards } from "../../../proactive/inbox/cards.js";
|
|
3
|
-
import { registerProactiveControlRoutes } from "./proactive-control.js";
|
|
4
|
-
//#region src/gateway/hono/routes/proactive.ts
|
|
5
|
-
function positiveInt(value, fallback) {
|
|
6
|
-
const parsed = Number(value);
|
|
7
|
-
return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;
|
|
8
|
-
}
|
|
9
|
-
/** Proactive controls, cards and internal diagnostics. */
|
|
10
|
-
function registerProactiveRoutes(authenticated, deps) {
|
|
11
|
-
registerProactiveControlRoutes(authenticated, deps);
|
|
12
|
-
authenticated.get("/api/inbox/judgments", (c) => {
|
|
13
|
-
const status = c.req.query("status");
|
|
14
|
-
if (status && ![
|
|
15
|
-
"unread",
|
|
16
|
-
"read",
|
|
17
|
-
"snoozed",
|
|
18
|
-
"resolved"
|
|
19
|
-
].includes(status)) return c.json({
|
|
20
|
-
ok: false,
|
|
21
|
-
error: "Invalid inbox status"
|
|
22
|
-
}, 400);
|
|
23
|
-
const page = listCards(deps.service.currentWorkspacePath, {
|
|
24
|
-
status,
|
|
25
|
-
limit: positiveInt(c.req.query("limit"), 50),
|
|
26
|
-
before: c.req.query("before")
|
|
27
|
-
});
|
|
28
|
-
return c.json({
|
|
29
|
-
ok: true,
|
|
30
|
-
...page,
|
|
31
|
-
items: page.cards.map((card) => getInboxItem(card.id))
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
authenticated.post("/api/inbox/judgments/:itemId/transition", deps.strictRateLimitMiddleware, async (c) => {
|
|
35
|
-
const body = await c.req.json().catch(() => null);
|
|
36
|
-
if (!body || ![
|
|
37
|
-
"unread",
|
|
38
|
-
"read",
|
|
39
|
-
"snoozed",
|
|
40
|
-
"resolved"
|
|
41
|
-
].includes(String(body.status))) return c.json({
|
|
42
|
-
ok: false,
|
|
43
|
-
error: "Valid status is required"
|
|
44
|
-
}, 400);
|
|
45
|
-
try {
|
|
46
|
-
return c.json({
|
|
47
|
-
ok: true,
|
|
48
|
-
item: deps.service.proactiveInbox.transition(c.req.param("itemId"), {
|
|
49
|
-
status: body.status,
|
|
50
|
-
...typeof body.snoozedUntil === "string" ? { snoozedUntil: body.snoozedUntil } : {},
|
|
51
|
-
...typeof body.resolution === "string" ? { resolution: body.resolution } : {}
|
|
52
|
-
})
|
|
53
|
-
});
|
|
54
|
-
} catch (error) {
|
|
55
|
-
return c.json({
|
|
56
|
-
ok: false,
|
|
57
|
-
error: error instanceof Error ? error.message : String(error)
|
|
58
|
-
}, 400);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
authenticated.post("/api/inbox/judgments/:itemId/decisions", deps.strictRateLimitMiddleware, async (c) => {
|
|
62
|
-
const body = await c.req.json().catch(() => null);
|
|
63
|
-
if (!body || typeof body.choice !== "string") return c.json({
|
|
64
|
-
ok: false,
|
|
65
|
-
error: "choice is required"
|
|
66
|
-
}, 400);
|
|
67
|
-
try {
|
|
68
|
-
return c.json({
|
|
69
|
-
ok: true,
|
|
70
|
-
item: deps.service.proactiveInbox.decide(c.req.param("itemId"), body.choice, typeof body.note === "string" ? body.note : "")
|
|
71
|
-
}, 201);
|
|
72
|
-
} catch (error) {
|
|
73
|
-
return c.json({
|
|
74
|
-
ok: false,
|
|
75
|
-
error: error instanceof Error ? error.message : String(error)
|
|
76
|
-
}, 400);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
authenticated.post("/api/inbox/judgments/:itemId/feedback", deps.strictRateLimitMiddleware, async (c) => {
|
|
80
|
-
const body = await c.req.json().catch(() => null);
|
|
81
|
-
if (!body || body.rating !== "useful" && body.rating !== "not_useful") return c.json({
|
|
82
|
-
ok: false,
|
|
83
|
-
error: "Valid rating is required"
|
|
84
|
-
}, 400);
|
|
85
|
-
try {
|
|
86
|
-
deps.service.proactiveInbox.feedback(c.req.param("itemId"), body.rating, typeof body.note === "string" ? body.note : "");
|
|
87
|
-
return c.json({ ok: true }, 201);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
return c.json({
|
|
90
|
-
ok: false,
|
|
91
|
-
error: error instanceof Error ? error.message : String(error)
|
|
92
|
-
}, 400);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
authenticated.post("/api/inbox/judgments/:itemId/instructions", deps.strictRateLimitMiddleware, async (c) => {
|
|
96
|
-
const body = await c.req.json().catch(() => null);
|
|
97
|
-
if (!body || typeof body.instruction !== "string" || !body.instruction.trim()) return c.json({
|
|
98
|
-
ok: false,
|
|
99
|
-
error: "instruction is required"
|
|
100
|
-
}, 400);
|
|
101
|
-
try {
|
|
102
|
-
return c.json({
|
|
103
|
-
ok: true,
|
|
104
|
-
...deps.service.proactiveInbox.instruct(c.req.param("itemId"), body.instruction)
|
|
105
|
-
}, 201);
|
|
106
|
-
} catch (error) {
|
|
107
|
-
return c.json({
|
|
108
|
-
ok: false,
|
|
109
|
-
error: error instanceof Error ? error.message : String(error)
|
|
110
|
-
}, 400);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
authenticated.get("/api/internal/proactive/insights", (c) => c.json({
|
|
114
|
-
ok: true,
|
|
115
|
-
insights: deps.service.proactiveInsights()
|
|
116
|
-
}));
|
|
117
|
-
authenticated.get("/api/internal/proactive/scenarios", (c) => c.json({
|
|
118
|
-
ok: true,
|
|
119
|
-
scenarios: deps.service.proactiveScenarios.list(),
|
|
120
|
-
subscriptions: deps.service.proactiveScenarios.subscriptions()
|
|
121
|
-
}));
|
|
122
|
-
authenticated.post("/api/internal/proactive/events", deps.strictRateLimitMiddleware, async (c) => {
|
|
123
|
-
const body = await c.req.json().catch(() => null);
|
|
124
|
-
if (!body || typeof body !== "object" || Array.isArray(body)) return c.json({
|
|
125
|
-
ok: false,
|
|
126
|
-
error: "Event body must be an object"
|
|
127
|
-
}, 400);
|
|
128
|
-
try {
|
|
129
|
-
const result = deps.service.proactive.publish(body);
|
|
130
|
-
return c.json({
|
|
131
|
-
ok: true,
|
|
132
|
-
...result
|
|
133
|
-
}, result.inserted ? 201 : 200);
|
|
134
|
-
} catch (error) {
|
|
135
|
-
return c.json({
|
|
136
|
-
ok: false,
|
|
137
|
-
error: error instanceof Error ? error.message : String(error)
|
|
138
|
-
}, 400);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
authenticated.get("/api/internal/proactive/events", (c) => {
|
|
142
|
-
const events = deps.service.proactive.listEvents({
|
|
143
|
-
limit: positiveInt(c.req.query("limit"), 50),
|
|
144
|
-
...c.req.query("type") ? { type: c.req.query("type") } : {}
|
|
145
|
-
}).map((event) => event.sensitivity === "public" || event.sensitivity === "personal" ? event : {
|
|
146
|
-
...event,
|
|
147
|
-
payload: { redacted: true }
|
|
148
|
-
});
|
|
149
|
-
return c.json({
|
|
150
|
-
ok: true,
|
|
151
|
-
events
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
authenticated.get("/api/internal/proactive/batches", (c) => c.json({
|
|
155
|
-
ok: true,
|
|
156
|
-
batches: deps.service.proactive.listBatches({ limit: positiveInt(c.req.query("limit"), 50) })
|
|
157
|
-
}));
|
|
158
|
-
authenticated.get("/api/internal/proactive/health", (c) => c.json({
|
|
159
|
-
ok: true,
|
|
160
|
-
health: deps.service.proactive.health()
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
//#endregion
|
|
164
|
-
export { registerProactiveRoutes };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { resolveHeartbeatMdPath } from "../../workspace-heartbeat-path.js";
|
|
2
|
-
import { createGatewayRouteLogger } from "../lib/route-logger.js";
|
|
3
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
4
|
-
//#region src/gateway/hono/routes/workspace.ts
|
|
5
|
-
const log = createGatewayRouteLogger("Workspace");
|
|
6
|
-
function registerWorkspaceRoutes(authenticated, deps) {
|
|
7
|
-
const { service } = deps;
|
|
8
|
-
authenticated.get("/api/workspace/heartbeat-md", async (c) => {
|
|
9
|
-
const path = resolveHeartbeatMdPath(service.currentConfig);
|
|
10
|
-
if (!path) return c.json({
|
|
11
|
-
ok: false,
|
|
12
|
-
error: { message: "Workspace not configured" }
|
|
13
|
-
}, 400);
|
|
14
|
-
try {
|
|
15
|
-
return c.json({
|
|
16
|
-
ok: true,
|
|
17
|
-
payload: {
|
|
18
|
-
content: await readFile(path, "utf8"),
|
|
19
|
-
file: "HEARTBEAT.md"
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
} catch {
|
|
23
|
-
return c.json({
|
|
24
|
-
ok: true,
|
|
25
|
-
payload: {
|
|
26
|
-
content: "",
|
|
27
|
-
file: "HEARTBEAT.md"
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
authenticated.put("/api/workspace/heartbeat-md", async (c) => {
|
|
33
|
-
const path = resolveHeartbeatMdPath(service.currentConfig);
|
|
34
|
-
if (!path) return c.json({
|
|
35
|
-
ok: false,
|
|
36
|
-
error: { message: "Workspace not configured" }
|
|
37
|
-
}, 400);
|
|
38
|
-
const body = await c.req.json().catch(() => null);
|
|
39
|
-
if (!body || typeof body.content !== "string") return c.json({
|
|
40
|
-
ok: false,
|
|
41
|
-
error: { message: "content is required" }
|
|
42
|
-
}, 400);
|
|
43
|
-
try {
|
|
44
|
-
await writeFile(path, body.content, "utf8");
|
|
45
|
-
return c.json({
|
|
46
|
-
ok: true,
|
|
47
|
-
payload: { file: "HEARTBEAT.md" }
|
|
48
|
-
});
|
|
49
|
-
} catch (error) {
|
|
50
|
-
log.error({
|
|
51
|
-
err: error,
|
|
52
|
-
path
|
|
53
|
-
}, "Failed to write HEARTBEAT.md");
|
|
54
|
-
return c.json({
|
|
55
|
-
ok: false,
|
|
56
|
-
error: { message: "Write failed" }
|
|
57
|
-
}, 500);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
export { registerWorkspaceRoutes };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { init_agent_scope, resolveAgentProfileDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
2
|
-
import { WORKSPACE_FILES, init_paths } from "../config/paths.js";
|
|
3
|
-
import { getWorkspacePath } from "../config/workspace-path-helpers.js";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
//#region src/gateway/workspace-heartbeat-path.ts
|
|
6
|
-
init_agent_scope();
|
|
7
|
-
init_paths();
|
|
8
|
-
/** Resolved absolute path to `HEARTBEAT.md` under the default agent's `profile/` directory. */
|
|
9
|
-
function resolveHeartbeatMdPath(config) {
|
|
10
|
-
if (!getWorkspacePath(config)) return null;
|
|
11
|
-
return join(resolveAgentProfileDir(config, resolveDefaultAgentId(config)), WORKSPACE_FILES.HEARTBEAT);
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { resolveHeartbeatMdPath };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { decodeStoredConversationKey, init_conversation_key_decoder } from "../storage/sqlite/migrations/conversation-key-decoder.js";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
//#region src/migrations/conversation-routing-config.ts
|
|
4
|
-
init_conversation_key_decoder();
|
|
5
|
-
const id = "conversation-uuid-delivery-config";
|
|
6
|
-
function convertedConfig(ctx) {
|
|
7
|
-
if (!existsSync(ctx.configPath)) return null;
|
|
8
|
-
const config = JSON.parse(readFileSync(ctx.configPath, "utf8"));
|
|
9
|
-
const heartbeat = config.gateway?.heartbeat;
|
|
10
|
-
const target = heartbeat?.targetChatId;
|
|
11
|
-
if (typeof target !== "string" || !target.trim().startsWith("agent:")) return null;
|
|
12
|
-
const key = target.trim();
|
|
13
|
-
const route = decodeStoredConversationKey(key, key.split(":")[1]);
|
|
14
|
-
if (!["telegram", "weixin"].includes(route.channel) || route.channel !== heartbeat.target) throw new Error("Cannot migrate heartbeat delivery: channel and stored conversation route disagree");
|
|
15
|
-
heartbeat.targetChatId = route.channel === "weixin" ? `${route.accountId || "default"}:direct:${route.peerId}` : route.peerId;
|
|
16
|
-
return config;
|
|
17
|
-
}
|
|
18
|
-
function item(status) {
|
|
19
|
-
return {
|
|
20
|
-
id,
|
|
21
|
-
title: "Conversation UUID delivery configuration",
|
|
22
|
-
kind: "config",
|
|
23
|
-
safety: "auto",
|
|
24
|
-
status,
|
|
25
|
-
message: "Store the native channel delivery address independently of conversation identity."
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const conversationRoutingConfigMigration = {
|
|
29
|
-
id,
|
|
30
|
-
kind: "config",
|
|
31
|
-
safety: "auto",
|
|
32
|
-
detect: (ctx) => convertedConfig(ctx) ? item("planned") : null,
|
|
33
|
-
apply: (ctx) => {
|
|
34
|
-
const config = convertedConfig(ctx);
|
|
35
|
-
return config ? {
|
|
36
|
-
...item("applied"),
|
|
37
|
-
details: { config }
|
|
38
|
-
} : item("not_needed");
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
42
|
-
export { conversationRoutingConfigMigration };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ProductNotification, ProactivePreferences } from '@xopcai/gateway-contract';
|
|
2
|
-
type Target = NonNullable<ProactivePreferences['telegram']>;
|
|
3
|
-
export type ProactiveChannelSender = (target: Target, text: string) => Promise<{
|
|
4
|
-
messageId: string;
|
|
5
|
-
}>;
|
|
6
|
-
export declare function enqueueChannelNotification(notification: ProductNotification, workspace: string): void;
|
|
7
|
-
export declare function drainChannelNotifications(send: ProactiveChannelSender): Promise<void>;
|
|
8
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { notificationTargetRoute } from "../../packages/gateway-contract/src/notifications.js";
|
|
3
|
-
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
4
|
-
import { proactivePreferences } from "../proactive/policy/service.js";
|
|
5
|
-
import { recheckNotificationDelivery } from "./proactive-policy.js";
|
|
6
|
-
import { getNotificationEvent } from "./store.js";
|
|
7
|
-
//#region src/notifications/proactive-channel.ts
|
|
8
|
-
init_src();
|
|
9
|
-
init_transaction();
|
|
10
|
-
function enqueueChannelNotification(notification, workspace) {
|
|
11
|
-
const target = proactivePreferences(workspace).telegram;
|
|
12
|
-
if (!target) throw new Error("Configure a Telegram destination before selecting it");
|
|
13
|
-
getSqliteDatabase().prepare("INSERT OR IGNORE INTO proactive_channel_deliveries(notification_id, workspace_id, target_json, next_attempt_at) VALUES (?, ?, ?, ?)").run(notification.id, workspace, JSON.stringify(target), Date.now());
|
|
14
|
-
}
|
|
15
|
-
async function drainChannelNotifications(send) {
|
|
16
|
-
const db = getSqliteDatabase();
|
|
17
|
-
const claim = runSqliteWriteTransaction((tx) => {
|
|
18
|
-
tx.prepare("UPDATE proactive_channel_deliveries SET status = 'failed', last_error = 'Lease exhausted' WHERE status = 'sending' AND lease_until <= ? AND attempt >= 5").run(Date.now());
|
|
19
|
-
const row = tx.prepare(`SELECT * FROM proactive_channel_deliveries WHERE (status = 'pending' AND next_attempt_at <= ?) OR (status = 'sending' AND lease_until <= ?) ORDER BY next_attempt_at LIMIT 1`).get(Date.now(), Date.now());
|
|
20
|
-
if (!row) return null;
|
|
21
|
-
tx.prepare("UPDATE proactive_channel_deliveries SET status = 'sending', attempt = attempt + 1, lease_until = ? WHERE notification_id = ?").run(Date.now() + 12e4, row.notification_id);
|
|
22
|
-
return {
|
|
23
|
-
...row,
|
|
24
|
-
attempt: row.attempt + 1
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
if (!claim) return;
|
|
28
|
-
const finish = (status, nextAt, messageId = null, error = null) => {
|
|
29
|
-
db.prepare(`UPDATE proactive_channel_deliveries SET status = ?, next_attempt_at = ?, provider_message_id = ?, last_error = ?, lease_until = NULL
|
|
30
|
-
WHERE notification_id = ? AND status = 'sending' AND attempt = ?`).run(status, nextAt, messageId, error, claim.notification_id, claim.attempt);
|
|
31
|
-
};
|
|
32
|
-
try {
|
|
33
|
-
const notification = getNotificationEvent(claim.notification_id);
|
|
34
|
-
const current = proactivePreferences(claim.workspace_id);
|
|
35
|
-
if (!notification || current.preferredChannel !== "telegram" || JSON.stringify(current.telegram) !== claim.target_json) {
|
|
36
|
-
finish("cancelled", Date.now());
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const policy = recheckNotificationDelivery(notification, "telegram");
|
|
40
|
-
if (policy === "cancel") {
|
|
41
|
-
finish("cancelled", Date.now());
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (policy instanceof Date) {
|
|
45
|
-
finish("pending", policy.getTime());
|
|
46
|
-
db.prepare("UPDATE proactive_channel_deliveries SET attempt = attempt - 1 WHERE notification_id = ? AND attempt = ?").run(claim.notification_id, claim.attempt);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const target = JSON.parse(claim.target_json);
|
|
50
|
-
const url = new URL(target.publicUrl);
|
|
51
|
-
url.hash = notificationTargetRoute(notification.target, "web");
|
|
52
|
-
const result = await send(target, `${notification.target.kind === "proactive_digest" ? "你的工作摘要已就绪 / Your work digest is ready." : "有一项工作需要查看 / A work update is ready."}\n${url.toString()}`);
|
|
53
|
-
if (!result.messageId) throw new Error("No delivery receipt");
|
|
54
|
-
finish("sent", Date.now(), result.messageId);
|
|
55
|
-
} catch {
|
|
56
|
-
finish(claim.attempt >= 5 ? "failed" : "pending", Date.now() + Math.min(36e5, 3e4 * 2 ** claim.attempt), null, "Telegram delivery failed");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
export { drainChannelNotifications, enqueueChannelNotification };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ProductNotification } from '@xopcai/gateway-contract';
|
|
2
|
-
export declare function proactiveNotificationWorkspace(notification: Pick<ProductNotification, 'target'>): string | null;
|
|
3
|
-
export declare function recheckNotificationDelivery(notification: ProductNotification, channel: 'browser' | 'mobile' | 'telegram', now?: Date): 'send' | 'cancel' | Date;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { proactiveChecksAllowed, proactivePreferences, quietHoursEnd } from "../proactive/policy/service.js";
|
|
3
|
-
import { viewingProactiveCard } from "../proactive/policy/presence.js";
|
|
4
|
-
import { digestCards } from "../proactive/inbox/digest.js";
|
|
5
|
-
import { recheckProactiveNotification } from "../proactive/inbox/notification-policy.js";
|
|
6
|
-
//#region src/notifications/proactive-policy.ts
|
|
7
|
-
init_transaction();
|
|
8
|
-
function proactiveNotificationWorkspace(notification) {
|
|
9
|
-
const target = notification.target;
|
|
10
|
-
const db = getSqliteDatabase();
|
|
11
|
-
return (target.kind === "insight" ? db.prepare(`SELECT s.workspace_id FROM proactive_inbox_items i JOIN proactive_insights x USING(insight_id) JOIN proactive_scenario_subscriptions s USING(subscription_id) WHERE i.inbox_item_id = ?`).get(target.inboxItemId) : target.kind === "proactive_digest" ? db.prepare("SELECT workspace_id FROM proactive_digests WHERE digest_id = ?").get(target.digestId) : null)?.workspace_id ?? null;
|
|
12
|
-
}
|
|
13
|
-
function recheckNotificationDelivery(notification, channel, now = /* @__PURE__ */ new Date()) {
|
|
14
|
-
if (notification.type !== "proactive.insight") return "send";
|
|
15
|
-
const workspace = proactiveNotificationWorkspace(notification);
|
|
16
|
-
if (!workspace) return "cancel";
|
|
17
|
-
const preferences = proactivePreferences(workspace);
|
|
18
|
-
if (![
|
|
19
|
-
"all",
|
|
20
|
-
"auto",
|
|
21
|
-
channel
|
|
22
|
-
].includes(preferences.preferredChannel)) return "cancel";
|
|
23
|
-
if (!proactiveChecksAllowed(preferences, now) || preferences.notificationsMuted) return "cancel";
|
|
24
|
-
if (preferences.suppressWhileViewing && notification.target.kind === "insight" && viewingProactiveCard(workspace, notification.target.inboxItemId, Number(notification.payload.notificationRevision ?? 1), now.getTime())) return new Date(now.getTime() + 6e4);
|
|
25
|
-
if (notification.target.kind === "insight") return recheckProactiveNotification(notification.target.inboxItemId, now, notification.payload.notificationRevision);
|
|
26
|
-
if (notification.target.kind === "proactive_digest") {
|
|
27
|
-
const decisions = digestCards(notification.target.digestId, workspace, true).map((card) => recheckProactiveNotification(card.id, now, card.notificationRevision, true));
|
|
28
|
-
if (!decisions.length || decisions.every((value) => value === "cancel")) return "cancel";
|
|
29
|
-
if (!decisions.includes("send")) return decisions.find((value) => value instanceof Date) ?? "cancel";
|
|
30
|
-
return quietHoursEnd(preferences, now) ?? "send";
|
|
31
|
-
}
|
|
32
|
-
return "cancel";
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { proactiveNotificationWorkspace, recheckNotificationDelivery };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type ProductNotification } from '@xopcai/gateway-contract';
|
|
2
|
-
import webPush from 'web-push';
|
|
3
|
-
export declare function allowedPushEndpoint(value: string): boolean;
|
|
4
|
-
export declare function prepareBrowserPush(): {
|
|
5
|
-
publicKey: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function registerBrowserPush(workspaceId: string, value: unknown): {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function unregisterBrowserPush(workspaceId: string, id: string): void;
|
|
11
|
-
export declare function enqueueBrowserPush(notification: ProductNotification, selectedIds?: string[]): void;
|
|
12
|
-
export declare function drainBrowserPush(send?: typeof webPush.sendNotification): Promise<void>;
|
|
13
|
-
/** A user-triggered probe to this browser only; provider acceptance is not user delivery. */
|
|
14
|
-
export declare function testBrowserPush(workspaceId: string, subscriptionId: string, send?: typeof webPush.sendNotification): Promise<{
|
|
15
|
-
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
16
|
-
status: string;
|
|
17
|
-
}>;
|
|
18
|
-
export declare function acknowledgeBrowserProbe(workspaceId: string, id: string): void;
|
|
19
|
-
export declare function listBrowserProbes(workspaceId: string): Record<string, import("node:sqlite").SQLOutputValue>[];
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { ProductNotificationSchema, notificationTargetRoute } from "../../packages/gateway-contract/src/notifications.js";
|
|
3
|
-
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
4
|
-
import { proactiveNotificationWorkspace, recheckNotificationDelivery } from "./proactive-policy.js";
|
|
5
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import webPush from "web-push";
|
|
8
|
-
//#region src/notifications/web-push.ts
|
|
9
|
-
init_src();
|
|
10
|
-
init_transaction();
|
|
11
|
-
function allowedPushEndpoint(value) {
|
|
12
|
-
try {
|
|
13
|
-
const url = new URL(value);
|
|
14
|
-
const host = url.hostname;
|
|
15
|
-
return url.protocol === "https:" && !url.username && !url.password && (!url.port || url.port === "443") && (host === "fcm.googleapis.com" || host === "updates.push.services.mozilla.com" || host.endsWith(".push.services.mozilla.com") || host === "web.push.apple.com" || host.endsWith(".notify.windows.com"));
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const BrowserPushSchema = z.object({
|
|
21
|
-
subscription: z.object({
|
|
22
|
-
endpoint: z.string().max(4096).refine(allowedPushEndpoint, "Unsupported push service"),
|
|
23
|
-
expirationTime: z.number().nullable().optional(),
|
|
24
|
-
keys: z.object({
|
|
25
|
-
auth: z.string().regex(/^[A-Za-z0-9_-]{22}$/),
|
|
26
|
-
p256dh: z.string().regex(/^[A-Za-z0-9_-]{87}$/)
|
|
27
|
-
}).strict()
|
|
28
|
-
}).strict(),
|
|
29
|
-
language: z.enum(["en", "zh"]).default("en")
|
|
30
|
-
}).strict();
|
|
31
|
-
function prepareBrowserPush() {
|
|
32
|
-
return runSqliteWriteTransaction((db) => {
|
|
33
|
-
let keys = db.prepare("SELECT public_key, private_key FROM proactive_web_push_keys WHERE id = 1").get();
|
|
34
|
-
if (!keys) {
|
|
35
|
-
const generated = webPush.generateVAPIDKeys();
|
|
36
|
-
db.prepare("INSERT INTO proactive_web_push_keys(id, public_key, private_key) VALUES (1, ?, ?)").run(generated.publicKey, generated.privateKey);
|
|
37
|
-
keys = {
|
|
38
|
-
public_key: generated.publicKey,
|
|
39
|
-
private_key: generated.privateKey
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return { publicKey: keys.public_key };
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function registerBrowserPush(workspaceId, value) {
|
|
46
|
-
const input = BrowserPushSchema.parse(value);
|
|
47
|
-
return runSqliteWriteTransaction((db) => {
|
|
48
|
-
const existing = db.prepare("SELECT id, workspace_id FROM proactive_web_push_subscriptions WHERE endpoint = ?").get(input.subscription.endpoint);
|
|
49
|
-
if (existing && existing.workspace_id !== workspaceId) throw new Error("Push subscription belongs to another workspace");
|
|
50
|
-
const id = existing?.id ?? randomUUID();
|
|
51
|
-
db.prepare(`INSERT INTO proactive_web_push_subscriptions(id, workspace_id, endpoint, subscription_json, language, created_at) VALUES (?, ?, ?, ?, ?, ?)
|
|
52
|
-
ON CONFLICT(endpoint) DO UPDATE SET subscription_json = excluded.subscription_json, language = excluded.language`).run(id, workspaceId, input.subscription.endpoint, JSON.stringify(input.subscription), input.language, (/* @__PURE__ */ new Date()).toISOString());
|
|
53
|
-
return { id };
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function unregisterBrowserPush(workspaceId, id) {
|
|
57
|
-
getSqliteDatabase().prepare("DELETE FROM proactive_web_push_subscriptions WHERE workspace_id = ? AND id = ?").run(workspaceId, id);
|
|
58
|
-
}
|
|
59
|
-
function enqueueBrowserPush(notification, selectedIds) {
|
|
60
|
-
const workspace = proactiveNotificationWorkspace(notification);
|
|
61
|
-
if (!workspace) return;
|
|
62
|
-
const targetId = notification.target.kind === "insight" ? notification.target.inboxItemId : "";
|
|
63
|
-
const subscriptions = getSqliteDatabase().prepare("SELECT id FROM proactive_web_push_subscriptions WHERE workspace_id = ?").all(workspace);
|
|
64
|
-
for (const subscription of subscriptions) {
|
|
65
|
-
if (selectedIds && !selectedIds.includes(subscription.id)) continue;
|
|
66
|
-
getSqliteDatabase().prepare(`INSERT OR IGNORE INTO proactive_web_push_deliveries(notification_id, subscription_id, inbox_item_id, notification_revision, next_attempt_at) VALUES (?, ?, ?, ?, ?)`).run(notification.id, subscription.id, targetId, typeof notification.payload.notificationRevision === "number" ? notification.payload.notificationRevision : 1, Date.now());
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async function drainBrowserPush(send = webPush.sendNotification) {
|
|
70
|
-
const db = getSqliteDatabase();
|
|
71
|
-
const keys = db.prepare("SELECT public_key, private_key FROM proactive_web_push_keys WHERE id = 1").get();
|
|
72
|
-
if (!keys) return;
|
|
73
|
-
const claim = runSqliteWriteTransaction((tx) => {
|
|
74
|
-
tx.prepare("UPDATE proactive_web_push_deliveries SET status = 'failed', last_error = 'Delivery lease exhausted' WHERE status = 'sending' AND lease_until <= ? AND attempt >= 5").run(Date.now());
|
|
75
|
-
const row = tx.prepare(`SELECT d.*, s.subscription_json, s.language FROM proactive_web_push_deliveries d
|
|
76
|
-
JOIN proactive_web_push_subscriptions s ON s.id = d.subscription_id
|
|
77
|
-
WHERE (d.status = 'pending' AND d.next_attempt_at <= ?) OR (d.status = 'sending' AND d.lease_until <= ?)
|
|
78
|
-
ORDER BY d.next_attempt_at LIMIT 1`).get(Date.now(), Date.now());
|
|
79
|
-
if (!row) return null;
|
|
80
|
-
tx.prepare("UPDATE proactive_web_push_deliveries SET status = 'sending', attempt = attempt + 1, lease_until = ? WHERE notification_id = ? AND subscription_id = ?").run(Date.now() + 6e4, row.notification_id, row.subscription_id);
|
|
81
|
-
return {
|
|
82
|
-
...row,
|
|
83
|
-
attempt: row.attempt + 1
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
if (!claim) return;
|
|
87
|
-
const finish = (status, nextAt, error = null) => db.prepare(`UPDATE proactive_web_push_deliveries SET status = ?, next_attempt_at = ?, last_error = ?, lease_until = NULL
|
|
88
|
-
WHERE notification_id = ? AND subscription_id = ? AND attempt = ? AND status = 'sending'`).run(status, nextAt, error, claim.notification_id, claim.subscription_id, claim.attempt);
|
|
89
|
-
try {
|
|
90
|
-
const row = db.prepare("SELECT * FROM notification_events WHERE event_id = ?").get(claim.notification_id);
|
|
91
|
-
const notification = ProductNotificationSchema.parse({
|
|
92
|
-
schemaVersion: 1,
|
|
93
|
-
id: row.event_id,
|
|
94
|
-
type: row.event_type,
|
|
95
|
-
target: JSON.parse(String(row.target_json)),
|
|
96
|
-
priority: row.priority,
|
|
97
|
-
title: {
|
|
98
|
-
en: row.title_en,
|
|
99
|
-
zh: row.title_zh
|
|
100
|
-
},
|
|
101
|
-
payload: JSON.parse(String(row.payload_json)),
|
|
102
|
-
createdAt: row.created_at
|
|
103
|
-
});
|
|
104
|
-
const policy = recheckNotificationDelivery(notification, "browser");
|
|
105
|
-
if (policy === "cancel") {
|
|
106
|
-
finish("failed", Date.now(), "Policy changed or card expired");
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (policy instanceof Date) {
|
|
110
|
-
finish("pending", policy.getTime());
|
|
111
|
-
db.prepare("UPDATE proactive_web_push_deliveries SET attempt = attempt - 1 WHERE notification_id = ? AND subscription_id = ? AND attempt = ?").run(claim.notification_id, claim.subscription_id, claim.attempt);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const subscription = JSON.parse(claim.subscription_json);
|
|
115
|
-
if (!allowedPushEndpoint(subscription.endpoint)) throw new Error("Unsupported push service");
|
|
116
|
-
await send(subscription, JSON.stringify({
|
|
117
|
-
id: claim.notification_id,
|
|
118
|
-
title: claim.language === "zh" ? "有一项工作需要查看" : "A work update is ready",
|
|
119
|
-
body: claim.language === "zh" ? "打开 xopc 查看详情。" : "Open xopc to review it.",
|
|
120
|
-
route: notificationTargetRoute(notification.target, "web")
|
|
121
|
-
}), {
|
|
122
|
-
vapidDetails: {
|
|
123
|
-
subject: "https://xopc.ai",
|
|
124
|
-
publicKey: keys.public_key,
|
|
125
|
-
privateKey: keys.private_key
|
|
126
|
-
},
|
|
127
|
-
TTL: 3600,
|
|
128
|
-
timeout: 1e4,
|
|
129
|
-
topic: createHash("sha256").update(claim.inbox_item_id || claim.notification_id).digest("base64url").slice(0, 32)
|
|
130
|
-
});
|
|
131
|
-
finish("sent", Date.now());
|
|
132
|
-
} catch (error) {
|
|
133
|
-
const status = error.statusCode;
|
|
134
|
-
if (status === 404 || status === 410) {
|
|
135
|
-
db.prepare("DELETE FROM proactive_web_push_subscriptions WHERE id = ?").run(claim.subscription_id);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
finish(claim.attempt >= 5 ? "failed" : "pending", Date.now() + Math.min(36e5, 3e4 * 2 ** claim.attempt), status ? `Push service HTTP ${status}` : "Push delivery failed");
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/** A user-triggered probe to this browser only; provider acceptance is not user delivery. */
|
|
142
|
-
async function testBrowserPush(workspaceId, subscriptionId, send = webPush.sendNotification) {
|
|
143
|
-
const id = randomUUID();
|
|
144
|
-
const claimed = runSqliteWriteTransaction((db) => {
|
|
145
|
-
const row = db.prepare("SELECT subscription_json FROM proactive_web_push_subscriptions WHERE id = ? AND workspace_id = ?").get(subscriptionId, workspaceId);
|
|
146
|
-
if (!row) throw new Error("Browser subscription not found");
|
|
147
|
-
if (db.prepare("SELECT 1 FROM proactive_push_probes WHERE workspace_id = ? AND created_at > ?").get(workspaceId, Date.now() - 6e4)) throw new Error("Wait one minute before another push test");
|
|
148
|
-
db.prepare("INSERT INTO proactive_push_probes(id, workspace_id, subscription_id, status, created_at) VALUES (?, ?, ?, ?, ?)").run(id, workspaceId, subscriptionId, "sending", Date.now());
|
|
149
|
-
return JSON.parse(row.subscription_json);
|
|
150
|
-
});
|
|
151
|
-
const keys = getSqliteDatabase().prepare("SELECT public_key, private_key FROM proactive_web_push_keys WHERE id = 1").get();
|
|
152
|
-
try {
|
|
153
|
-
if (!allowedPushEndpoint(claimed.endpoint)) throw new Error("Unsupported push service");
|
|
154
|
-
await send(claimed, JSON.stringify({
|
|
155
|
-
id,
|
|
156
|
-
title: "xopc 推送测试 / Push test",
|
|
157
|
-
body: "点击此通知确认打开 / Tap to confirm opening",
|
|
158
|
-
route: `/assistant-work?probe=${encodeURIComponent(id)}`
|
|
159
|
-
}), {
|
|
160
|
-
vapidDetails: {
|
|
161
|
-
subject: "https://xopc.ai",
|
|
162
|
-
publicKey: keys.public_key,
|
|
163
|
-
privateKey: keys.private_key
|
|
164
|
-
},
|
|
165
|
-
TTL: 300,
|
|
166
|
-
timeout: 1e4
|
|
167
|
-
});
|
|
168
|
-
getSqliteDatabase().prepare("UPDATE proactive_push_probes SET status = CASE WHEN opened_at IS NULL THEN 'accepted' ELSE 'opened' END WHERE id = ?").run(id);
|
|
169
|
-
return {
|
|
170
|
-
id,
|
|
171
|
-
status: "accepted"
|
|
172
|
-
};
|
|
173
|
-
} catch {
|
|
174
|
-
getSqliteDatabase().prepare("UPDATE proactive_push_probes SET status = 'failed', error = 'Push service did not accept the test' WHERE id = ?").run(id);
|
|
175
|
-
throw new Error("Push test failed; verify browser subscription and network connectivity");
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
function acknowledgeBrowserProbe(workspaceId, id) {
|
|
179
|
-
getSqliteDatabase().prepare("UPDATE proactive_push_probes SET status = 'opened', opened_at = ? WHERE id = ? AND workspace_id = ?").run(Date.now(), id, workspaceId);
|
|
180
|
-
}
|
|
181
|
-
function listBrowserProbes(workspaceId) {
|
|
182
|
-
return getSqliteDatabase().prepare("SELECT id, status, created_at AS createdAt, opened_at AS openedAt, error FROM proactive_push_probes WHERE workspace_id = ? ORDER BY created_at DESC LIMIT 10").all(workspaceId);
|
|
183
|
-
}
|
|
184
|
-
//#endregion
|
|
185
|
-
export { acknowledgeBrowserProbe, allowedPushEndpoint, drainBrowserPush, enqueueBrowserPush, listBrowserProbes, prepareBrowserPush, registerBrowserPush, testBrowserPush, unregisterBrowserPush };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function executePendingProactiveActions(now?: Date): number;
|