@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,174 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import { effectiveProactivePolicy } from "../policy/service.js";
|
|
3
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
4
|
-
//#region src/proactive/scenarios/repository.ts
|
|
5
|
-
init_transaction();
|
|
6
|
-
const text = (row, key) => String(row[key]);
|
|
7
|
-
function scenarioFromRow(row) {
|
|
8
|
-
const condition = row.condition_json ? JSON.parse(String(row.condition_json)) : void 0;
|
|
9
|
-
return {
|
|
10
|
-
key: text(row, "scenario_key"),
|
|
11
|
-
version: Number(row.version),
|
|
12
|
-
title: text(row, "title"),
|
|
13
|
-
description: text(row, "description"),
|
|
14
|
-
basePrompt: text(row, "base_prompt"),
|
|
15
|
-
baseTemplateVersion: Number(row.base_template_version),
|
|
16
|
-
eventTypes: JSON.parse(text(row, "event_types_json")),
|
|
17
|
-
...condition ? { condition } : {},
|
|
18
|
-
aggregation: text(row, "aggregation"),
|
|
19
|
-
debounceSeconds: Number(row.debounce_seconds),
|
|
20
|
-
maxWindowSeconds: Number(row.max_window_seconds),
|
|
21
|
-
contextProviderIds: JSON.parse(text(row, "context_provider_ids_json")),
|
|
22
|
-
valuePolicy: {
|
|
23
|
-
minConfidence: Number(row.min_confidence),
|
|
24
|
-
minScore: Number(row.min_value_score),
|
|
25
|
-
cooldownSeconds: Number(row.cooldown_seconds),
|
|
26
|
-
maxRunsPerDay: Number(row.max_runs_per_day)
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function subscriptionFromRow(row) {
|
|
31
|
-
return {
|
|
32
|
-
id: text(row, "subscription_id"),
|
|
33
|
-
scenarioKey: text(row, "scenario_key"),
|
|
34
|
-
workspaceId: text(row, "workspace_id"),
|
|
35
|
-
scopeKind: text(row, "scope_kind"),
|
|
36
|
-
scopeId: text(row, "scope_id"),
|
|
37
|
-
enabled: Number(row.enabled) === 1,
|
|
38
|
-
...row.active_prompt_revision_id ? { activePromptRevisionId: text(row, "active_prompt_revision_id") } : {},
|
|
39
|
-
createdAt: text(row, "created_at"),
|
|
40
|
-
updatedAt: text(row, "updated_at")
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function revisionFromRow(row) {
|
|
44
|
-
return {
|
|
45
|
-
id: text(row, "revision_id"),
|
|
46
|
-
subscriptionId: text(row, "subscription_id"),
|
|
47
|
-
revision: Number(row.revision),
|
|
48
|
-
status: text(row, "status"),
|
|
49
|
-
baseTemplateVersion: Number(row.base_template_version),
|
|
50
|
-
userInstructions: text(row, "user_instructions"),
|
|
51
|
-
contentHash: text(row, "content_hash"),
|
|
52
|
-
createdAt: text(row, "created_at"),
|
|
53
|
-
...row.published_at ? { publishedAt: text(row, "published_at") } : {}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function listScenarios() {
|
|
57
|
-
return getSqliteDatabase().prepare("SELECT * FROM proactive_scenarios ORDER BY scenario_key").all().map(scenarioFromRow);
|
|
58
|
-
}
|
|
59
|
-
function getScenario(key, version) {
|
|
60
|
-
const row = version === void 0 ? getSqliteDatabase().prepare("SELECT * FROM proactive_scenarios WHERE scenario_key = ?").get(key) : getSqliteDatabase().prepare("SELECT * FROM proactive_scenario_versions WHERE scenario_key = ? AND version = ?").get(key, version);
|
|
61
|
-
return row ? scenarioFromRow(row) : null;
|
|
62
|
-
}
|
|
63
|
-
function upsertSubscription(input, now = /* @__PURE__ */ new Date()) {
|
|
64
|
-
if (!getScenario(input.scenarioKey)) throw new Error("Scenario not found");
|
|
65
|
-
const nowIso = now.toISOString();
|
|
66
|
-
runSqliteWriteTransaction((db) => db.prepare(`INSERT INTO proactive_scenario_subscriptions (
|
|
67
|
-
subscription_id, scenario_key, workspace_id, scope_kind, scope_id, enabled, created_at, updated_at
|
|
68
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
69
|
-
ON CONFLICT(scenario_key, workspace_id, scope_kind, scope_id) DO UPDATE SET enabled = excluded.enabled, updated_at = excluded.updated_at`).run(randomUUID(), input.scenarioKey, input.workspaceId, input.scopeKind, input.scopeId, input.enabled ? 1 : 0, nowIso, nowIso));
|
|
70
|
-
return subscriptionFromRow(getSqliteDatabase().prepare(`SELECT * FROM proactive_scenario_subscriptions
|
|
71
|
-
WHERE scenario_key = ? AND workspace_id = ? AND scope_kind = ? AND scope_id = ?`).get(input.scenarioKey, input.workspaceId, input.scopeKind, input.scopeId));
|
|
72
|
-
}
|
|
73
|
-
function listSubscriptions(scenarioKey) {
|
|
74
|
-
return (scenarioKey ? getSqliteDatabase().prepare("SELECT * FROM proactive_scenario_subscriptions WHERE scenario_key = ? ORDER BY updated_at DESC").all(scenarioKey) : getSqliteDatabase().prepare("SELECT * FROM proactive_scenario_subscriptions ORDER BY updated_at DESC").all()).map(subscriptionFromRow);
|
|
75
|
-
}
|
|
76
|
-
function listEnabledRoutes() {
|
|
77
|
-
return listSubscriptions().filter((item) => item.enabled && effectiveProactivePolicy(item.id).enabled).flatMap((subscription) => {
|
|
78
|
-
const scenario = getScenario(subscription.scenarioKey);
|
|
79
|
-
if (!scenario) return [];
|
|
80
|
-
return [{
|
|
81
|
-
subscriptionId: subscription.id,
|
|
82
|
-
key: scenario.key,
|
|
83
|
-
version: scenario.version,
|
|
84
|
-
enabled: true,
|
|
85
|
-
eventTypes: scenario.eventTypes,
|
|
86
|
-
...scenario.condition ? { condition: scenario.condition } : {},
|
|
87
|
-
aggregation: scenario.aggregation,
|
|
88
|
-
debounceSeconds: scenario.debounceSeconds,
|
|
89
|
-
maxWindowSeconds: scenario.maxWindowSeconds,
|
|
90
|
-
scope: {
|
|
91
|
-
workspaceId: subscription.workspaceId,
|
|
92
|
-
...subscription.scopeKind === "project" ? { projectId: subscription.scopeId } : {}
|
|
93
|
-
}
|
|
94
|
-
}];
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function createPromptDraft(subscriptionId, userInstructions, now = /* @__PURE__ */ new Date()) {
|
|
98
|
-
const instructions = userInstructions.trim();
|
|
99
|
-
if (instructions.length > 12e3) throw new Error("User instructions exceed 12000 characters");
|
|
100
|
-
return runSqliteWriteTransaction((db) => {
|
|
101
|
-
const subscription = db.prepare("SELECT * FROM proactive_scenario_subscriptions WHERE subscription_id = ?").get(subscriptionId);
|
|
102
|
-
if (!subscription) throw new Error("Subscription not found");
|
|
103
|
-
const scenario = db.prepare("SELECT * FROM proactive_scenarios WHERE scenario_key = ?").get(text(subscription, "scenario_key"));
|
|
104
|
-
const next = db.prepare("SELECT COALESCE(MAX(revision), 0) + 1 AS revision FROM proactive_prompt_revisions WHERE subscription_id = ?").get(subscriptionId);
|
|
105
|
-
const id = randomUUID();
|
|
106
|
-
const baseTemplateVersion = Number(scenario.base_template_version);
|
|
107
|
-
const hash = createHash("sha256").update(`${baseTemplateVersion}:${instructions}`).digest("hex");
|
|
108
|
-
db.prepare(`INSERT INTO proactive_prompt_revisions
|
|
109
|
-
(revision_id, subscription_id, revision, status, base_template_version, user_instructions, content_hash, created_at)
|
|
110
|
-
VALUES (?, ?, ?, 'draft', ?, ?, ?, ?)`).run(id, subscriptionId, next.revision, baseTemplateVersion, instructions, hash, now.toISOString());
|
|
111
|
-
return revisionFromRow(db.prepare("SELECT * FROM proactive_prompt_revisions WHERE revision_id = ?").get(id));
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
function getPromptRevision(id) {
|
|
115
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM proactive_prompt_revisions WHERE revision_id = ?").get(id);
|
|
116
|
-
return row ? revisionFromRow(row) : null;
|
|
117
|
-
}
|
|
118
|
-
function getSubscription(id) {
|
|
119
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM proactive_scenario_subscriptions WHERE subscription_id = ?").get(id);
|
|
120
|
-
return row ? subscriptionFromRow(row) : null;
|
|
121
|
-
}
|
|
122
|
-
function publishPromptRevision(id, now = /* @__PURE__ */ new Date()) {
|
|
123
|
-
return runSqliteWriteTransaction((db) => {
|
|
124
|
-
const draft = db.prepare("SELECT * FROM proactive_prompt_revisions WHERE revision_id = ?").get(id);
|
|
125
|
-
if (!draft || draft.status !== "draft") throw new Error("Prompt draft not found");
|
|
126
|
-
const nowIso = now.toISOString();
|
|
127
|
-
const subscriptionId = text(draft, "subscription_id");
|
|
128
|
-
db.prepare("UPDATE proactive_prompt_revisions SET status = 'retired' WHERE subscription_id = ? AND status = 'published'").run(subscriptionId);
|
|
129
|
-
db.prepare("UPDATE proactive_prompt_revisions SET status = 'published', published_at = ? WHERE revision_id = ?").run(nowIso, id);
|
|
130
|
-
db.prepare("UPDATE proactive_scenario_subscriptions SET active_prompt_revision_id = ?, updated_at = ? WHERE subscription_id = ?").run(id, nowIso, subscriptionId);
|
|
131
|
-
db.prepare("UPDATE proactive_subscription_settings SET settings_json = json_set(settings_json, '$.userInstructions', ?), revision = revision + 1 WHERE subscription_id = ?").run(text(draft, "user_instructions"), subscriptionId);
|
|
132
|
-
return revisionFromRow(db.prepare("SELECT * FROM proactive_prompt_revisions WHERE revision_id = ?").get(id));
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
function rollbackPromptRevision(id, now = /* @__PURE__ */ new Date()) {
|
|
136
|
-
return runSqliteWriteTransaction((db) => {
|
|
137
|
-
const target = db.prepare("SELECT * FROM proactive_prompt_revisions WHERE revision_id = ?").get(id);
|
|
138
|
-
if (!target || target.status === "draft") throw new Error("Published prompt revision not found");
|
|
139
|
-
const nowIso = now.toISOString();
|
|
140
|
-
const subscriptionId = text(target, "subscription_id");
|
|
141
|
-
db.prepare("UPDATE proactive_prompt_revisions SET status = 'retired' WHERE subscription_id = ? AND status = 'published'").run(subscriptionId);
|
|
142
|
-
db.prepare("UPDATE proactive_prompt_revisions SET status = 'published', published_at = ? WHERE revision_id = ?").run(nowIso, id);
|
|
143
|
-
db.prepare("UPDATE proactive_scenario_subscriptions SET active_prompt_revision_id = ?, updated_at = ? WHERE subscription_id = ?").run(id, nowIso, subscriptionId);
|
|
144
|
-
db.prepare("UPDATE proactive_subscription_settings SET settings_json = json_set(settings_json, '$.userInstructions', ?), revision = revision + 1 WHERE subscription_id = ?").run(text(target, "user_instructions"), subscriptionId);
|
|
145
|
-
return revisionFromRow(db.prepare("SELECT * FROM proactive_prompt_revisions WHERE revision_id = ?").get(id));
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function publishInstructionFeedback(input, now = /* @__PURE__ */ new Date()) {
|
|
149
|
-
const normalized = input.instruction.trim();
|
|
150
|
-
if (!normalized) throw new Error("instruction is required");
|
|
151
|
-
if (normalized.length > 2e3) throw new Error("instruction exceeds 2000 characters");
|
|
152
|
-
return runSqliteWriteTransaction((db) => {
|
|
153
|
-
const subscription = db.prepare("SELECT * FROM proactive_scenario_subscriptions WHERE subscription_id = ?").get(input.subscriptionId);
|
|
154
|
-
if (!subscription) throw new Error("Subscription not found");
|
|
155
|
-
const scenario = db.prepare("SELECT * FROM proactive_scenarios WHERE scenario_key = ?").get(text(subscription, "scenario_key"));
|
|
156
|
-
const instructions = [(subscription.active_prompt_revision_id ? db.prepare("SELECT user_instructions FROM proactive_prompt_revisions WHERE revision_id = ?").get(text(subscription, "active_prompt_revision_id")) : void 0)?.user_instructions?.trim() ?? "", `User feedback (${now.toISOString()}): ${normalized}`].filter(Boolean).join("\n").slice(-12e3);
|
|
157
|
-
const next = db.prepare("SELECT COALESCE(MAX(revision), 0) + 1 AS revision FROM proactive_prompt_revisions WHERE subscription_id = ?").get(input.subscriptionId);
|
|
158
|
-
const revisionId = randomUUID();
|
|
159
|
-
const baseTemplateVersion = Number(scenario.base_template_version);
|
|
160
|
-
const hash = createHash("sha256").update(`${baseTemplateVersion}:${instructions}`).digest("hex");
|
|
161
|
-
const nowIso = now.toISOString();
|
|
162
|
-
db.prepare("UPDATE proactive_prompt_revisions SET status = 'retired' WHERE subscription_id = ? AND status = 'published'").run(input.subscriptionId);
|
|
163
|
-
db.prepare(`INSERT INTO proactive_prompt_revisions
|
|
164
|
-
(revision_id, subscription_id, revision, status, base_template_version, user_instructions, content_hash, created_at, published_at)
|
|
165
|
-
VALUES (?, ?, ?, 'published', ?, ?, ?, ?, ?)`).run(revisionId, input.subscriptionId, next.revision, baseTemplateVersion, instructions, hash, nowIso, nowIso);
|
|
166
|
-
db.prepare("UPDATE proactive_scenario_subscriptions SET active_prompt_revision_id = ?, updated_at = ? WHERE subscription_id = ?").run(revisionId, nowIso, input.subscriptionId);
|
|
167
|
-
db.prepare(`INSERT INTO proactive_instruction_feedback
|
|
168
|
-
(instruction_id, inbox_item_id, prompt_revision_id, instruction, created_at) VALUES (?, ?, ?, ?, ?)`).run(randomUUID(), input.inboxItemId, revisionId, normalized, nowIso);
|
|
169
|
-
db.prepare("UPDATE proactive_subscription_settings SET settings_json = json_set(settings_json, '$.userInstructions', ?), revision = revision + 1 WHERE subscription_id = ?").run(instructions, input.subscriptionId);
|
|
170
|
-
return revisionFromRow(db.prepare("SELECT * FROM proactive_prompt_revisions WHERE revision_id = ?").get(revisionId));
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
//#endregion
|
|
174
|
-
export { createPromptDraft, getPromptRevision, getScenario, getSubscription, listEnabledRoutes, listScenarios, listSubscriptions, publishInstructionFeedback, publishPromptRevision, rollbackPromptRevision, upsertSubscription };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createPromptDraft, listEnabledRoutes, listScenarios, listSubscriptions, publishPromptRevision, rollbackPromptRevision, upsertSubscription } from './repository.js';
|
|
2
|
-
export declare class ProactiveScenarioService {
|
|
3
|
-
list: typeof listScenarios;
|
|
4
|
-
subscriptions: typeof listSubscriptions;
|
|
5
|
-
routes: typeof listEnabledRoutes;
|
|
6
|
-
subscribe: typeof upsertSubscription;
|
|
7
|
-
createDraft: typeof createPromptDraft;
|
|
8
|
-
publish: typeof publishPromptRevision;
|
|
9
|
-
rollback: typeof rollbackPromptRevision;
|
|
10
|
-
preview(input: {
|
|
11
|
-
scenarioKey: string;
|
|
12
|
-
revisionId?: string;
|
|
13
|
-
runtimeContext?: string;
|
|
14
|
-
}): import("./prompt-composer.js").ComposedPrompt;
|
|
15
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createPromptDraft, getPromptRevision, getScenario, getSubscription, listEnabledRoutes, listScenarios, listSubscriptions, publishPromptRevision, rollbackPromptRevision, upsertSubscription } from "./repository.js";
|
|
2
|
-
import { composeScenarioPrompt } from "./prompt-composer.js";
|
|
3
|
-
//#region src/proactive/scenarios/service.ts
|
|
4
|
-
var ProactiveScenarioService = class {
|
|
5
|
-
list = listScenarios;
|
|
6
|
-
subscriptions = listSubscriptions;
|
|
7
|
-
routes = listEnabledRoutes;
|
|
8
|
-
subscribe = upsertSubscription;
|
|
9
|
-
createDraft = createPromptDraft;
|
|
10
|
-
publish = publishPromptRevision;
|
|
11
|
-
rollback = rollbackPromptRevision;
|
|
12
|
-
preview(input) {
|
|
13
|
-
const scenario = getScenario(input.scenarioKey);
|
|
14
|
-
if (!scenario) throw new Error("Scenario not found");
|
|
15
|
-
const revision = input.revisionId ? getPromptRevision(input.revisionId) : void 0;
|
|
16
|
-
if (input.revisionId && !revision) throw new Error("Prompt revision not found");
|
|
17
|
-
if (revision && getSubscription(revision.subscriptionId)?.scenarioKey !== scenario.key) throw new Error("Prompt revision does not belong to this scenario");
|
|
18
|
-
return composeScenarioPrompt({
|
|
19
|
-
scenario,
|
|
20
|
-
...revision ? { revision } : {},
|
|
21
|
-
runtimeContext: input.runtimeContext ?? "[runtime context redacted]"
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
26
|
-
export { ProactiveScenarioService };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { EventCondition, ScenarioRoute } from '../routing/types.js';
|
|
2
|
-
export interface ScenarioDefinition {
|
|
3
|
-
key: string;
|
|
4
|
-
version: number;
|
|
5
|
-
title: string;
|
|
6
|
-
description: string;
|
|
7
|
-
basePrompt: string;
|
|
8
|
-
baseTemplateVersion: number;
|
|
9
|
-
eventTypes: string[];
|
|
10
|
-
condition?: EventCondition;
|
|
11
|
-
aggregation: ScenarioRoute['aggregation'];
|
|
12
|
-
debounceSeconds: number;
|
|
13
|
-
maxWindowSeconds: number;
|
|
14
|
-
contextProviderIds: string[];
|
|
15
|
-
valuePolicy: {
|
|
16
|
-
minConfidence: number;
|
|
17
|
-
minScore: number;
|
|
18
|
-
cooldownSeconds: number;
|
|
19
|
-
maxRunsPerDay: number;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface ScenarioSubscription {
|
|
23
|
-
id: string;
|
|
24
|
-
scenarioKey: string;
|
|
25
|
-
workspaceId: string;
|
|
26
|
-
scopeKind: 'workspace' | 'project';
|
|
27
|
-
scopeId: string;
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
activePromptRevisionId?: string;
|
|
30
|
-
createdAt: string;
|
|
31
|
-
updatedAt: string;
|
|
32
|
-
}
|
|
33
|
-
export interface PromptRevision {
|
|
34
|
-
id: string;
|
|
35
|
-
subscriptionId: string;
|
|
36
|
-
revision: number;
|
|
37
|
-
status: 'draft' | 'published' | 'retired';
|
|
38
|
-
baseTemplateVersion: number;
|
|
39
|
-
userInstructions: string;
|
|
40
|
-
contentHash: string;
|
|
41
|
-
createdAt: string;
|
|
42
|
-
publishedAt?: string;
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { listEvents } from './events/repository.js';
|
|
2
|
-
import type { PublishEventInput, PublishedEvent } from './events/types.js';
|
|
3
|
-
import { listBatches, markReadyBatches } from './routing/batch-repository.js';
|
|
4
|
-
import type { ScenarioRoute } from './routing/types.js';
|
|
5
|
-
export declare class ProactiveEventService {
|
|
6
|
-
private readonly routes;
|
|
7
|
-
constructor(routes?: () => readonly ScenarioRoute[]);
|
|
8
|
-
publish(input: PublishEventInput, now?: Date): PublishedEvent;
|
|
9
|
-
listEvents: typeof listEvents;
|
|
10
|
-
listBatches: typeof listBatches;
|
|
11
|
-
markReadyBatches: typeof markReadyBatches;
|
|
12
|
-
health(): {
|
|
13
|
-
events: number;
|
|
14
|
-
collecting: number;
|
|
15
|
-
ready: number;
|
|
16
|
-
oldestReadyAt: string | null;
|
|
17
|
-
last24Hours: {
|
|
18
|
-
runs: number;
|
|
19
|
-
insights: number;
|
|
20
|
-
discarded: number;
|
|
21
|
-
useful: number;
|
|
22
|
-
notUseful: number;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { normalizeEventEnvelope } from "./events/envelope.js";
|
|
3
|
-
import { getEventByDedupeKey, insertEvent, isEventRouted, listEvents, markEventRouted } from "./events/repository.js";
|
|
4
|
-
import { addEventToBatch, listBatches, markReadyBatches } from "./routing/batch-repository.js";
|
|
5
|
-
import { matchScenario } from "./routing/matcher.js";
|
|
6
|
-
//#region src/proactive/service.ts
|
|
7
|
-
init_transaction();
|
|
8
|
-
var ProactiveEventService = class {
|
|
9
|
-
constructor(routes = () => []) {
|
|
10
|
-
this.routes = routes;
|
|
11
|
-
}
|
|
12
|
-
publish(input, now = /* @__PURE__ */ new Date()) {
|
|
13
|
-
let event = normalizeEventEnvelope(input, now);
|
|
14
|
-
const inserted = insertEvent(event);
|
|
15
|
-
if (!inserted) {
|
|
16
|
-
const existing = getEventByDedupeKey(event.dedupeKey);
|
|
17
|
-
if (!existing) throw new Error(`Proactive event dedupe lookup failed: ${event.dedupeKey}`);
|
|
18
|
-
event = existing;
|
|
19
|
-
if (isEventRouted(event.id)) return {
|
|
20
|
-
event,
|
|
21
|
-
inserted: false,
|
|
22
|
-
batchIds: []
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
const batchIds = this.routes().flatMap((scenario) => {
|
|
26
|
-
const key = matchScenario(event, scenario);
|
|
27
|
-
if (!key) return [];
|
|
28
|
-
return [addEventToBatch({
|
|
29
|
-
event,
|
|
30
|
-
scenario,
|
|
31
|
-
aggregationKey: key,
|
|
32
|
-
now
|
|
33
|
-
}).id];
|
|
34
|
-
});
|
|
35
|
-
markEventRouted(event.id, now.toISOString());
|
|
36
|
-
return {
|
|
37
|
-
event,
|
|
38
|
-
inserted,
|
|
39
|
-
batchIds
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
listEvents = listEvents;
|
|
43
|
-
listBatches = listBatches;
|
|
44
|
-
markReadyBatches = markReadyBatches;
|
|
45
|
-
health() {
|
|
46
|
-
const db = getSqliteDatabase();
|
|
47
|
-
const events = db.prepare("SELECT COUNT(*) AS count FROM proactive_events").get();
|
|
48
|
-
const batches = db.prepare(`SELECT
|
|
49
|
-
SUM(CASE WHEN status = 'collecting' THEN 1 ELSE 0 END) AS collecting,
|
|
50
|
-
SUM(CASE WHEN status = 'ready' THEN 1 ELSE 0 END) AS ready,
|
|
51
|
-
MIN(CASE WHEN status = 'ready' THEN ready_at END) AS oldest_ready_at
|
|
52
|
-
FROM proactive_signal_batches`).get();
|
|
53
|
-
const since = (/* @__PURE__ */ new Date(Date.now() - 1440 * 6e4)).toISOString();
|
|
54
|
-
const runs = db.prepare(`SELECT COUNT(*) AS runs,
|
|
55
|
-
SUM(CASE WHEN status = 'discarded' THEN 1 ELSE 0 END) AS discarded
|
|
56
|
-
FROM proactive_runs WHERE started_at >= ?`).get(since);
|
|
57
|
-
const insights = db.prepare("SELECT COUNT(*) AS count FROM proactive_insights WHERE created_at >= ?").get(since);
|
|
58
|
-
const feedback = db.prepare(`SELECT
|
|
59
|
-
SUM(CASE WHEN rating = 'useful' THEN 1 ELSE 0 END) AS useful,
|
|
60
|
-
SUM(CASE WHEN rating = 'not_useful' THEN 1 ELSE 0 END) AS not_useful
|
|
61
|
-
FROM proactive_feedback WHERE created_at >= ?`).get(since);
|
|
62
|
-
return {
|
|
63
|
-
events: events.count,
|
|
64
|
-
collecting: batches.collecting ?? 0,
|
|
65
|
-
ready: batches.ready ?? 0,
|
|
66
|
-
oldestReadyAt: batches.oldest_ready_at,
|
|
67
|
-
last24Hours: {
|
|
68
|
-
runs: runs.runs,
|
|
69
|
-
insights: insights.count,
|
|
70
|
-
discarded: runs.discarded ?? 0,
|
|
71
|
-
useful: feedback.useful ?? 0,
|
|
72
|
-
notUseful: feedback.not_useful ?? 0
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
//#endregion
|
|
78
|
-
export { ProactiveEventService };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Only a successful pull of this collection proves its observed coverage. */
|
|
2
|
-
export declare function sourceFreshness(itemId: string, notBefore?: string, now?: number): {
|
|
3
|
-
fresh: boolean;
|
|
4
|
-
lastSyncedAt: string;
|
|
5
|
-
syncFailed: boolean;
|
|
6
|
-
version: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function evidenceSourcesFresh(ids: string[], context?: Record<string, unknown>): boolean;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { getKnowledgeSourceItem } from "../storage/sqlite/knowledge-repository.js";
|
|
3
|
-
//#region src/proactive/source-freshness.ts
|
|
4
|
-
init_transaction();
|
|
5
|
-
const MAX_SOURCE_AGE_MS = 30 * 6e4;
|
|
6
|
-
/** Only a successful pull of this collection proves its observed coverage. */
|
|
7
|
-
function sourceFreshness(itemId, notBefore, now = Date.now()) {
|
|
8
|
-
const item = getKnowledgeSourceItem(itemId);
|
|
9
|
-
const row = item ? getSqliteDatabase().prepare(`SELECT run_id, status, started_at, finished_at FROM knowledge_sync_runs
|
|
10
|
-
WHERE source_instance_id = ? AND collection_scope = ? ORDER BY started_at DESC, rowid DESC LIMIT 1`).get(item.sourceInstanceId, item.collectionScope) : void 0;
|
|
11
|
-
const lastSuccess = item ? getSqliteDatabase().prepare("SELECT MAX(finished_at) AS at FROM knowledge_sync_runs WHERE source_instance_id = ? AND collection_scope = ? AND status = 'succeeded'").get(item.sourceInstanceId, item.collectionScope) : void 0;
|
|
12
|
-
return {
|
|
13
|
-
fresh: Boolean(row?.status === "succeeded" && row.finished_at && row.started_at <= now && now - row.started_at <= MAX_SOURCE_AGE_MS && (!notBefore || row.started_at >= Date.parse(notBefore))),
|
|
14
|
-
lastSyncedAt: lastSuccess?.at ? new Date(lastSuccess.at).toISOString() : null,
|
|
15
|
-
syncFailed: Boolean(row && [
|
|
16
|
-
"failed",
|
|
17
|
-
"partial",
|
|
18
|
-
"cancelled"
|
|
19
|
-
].includes(row.status)),
|
|
20
|
-
version: row?.run_id ?? "unknown"
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function evidenceSourcesFresh(ids, context) {
|
|
24
|
-
const follow = context?.follow_up;
|
|
25
|
-
return ids.every((id) => !id.startsWith("source-item:") || sourceFreshness(id.slice(12), follow?.deadlinePassed ? follow.dueAt : void 0).fresh);
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { evidenceSourcesFresh, sourceFreshness };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { effectiveProactivePolicy } from "./policy/service.js";
|
|
3
|
-
//#region src/proactive/status.ts
|
|
4
|
-
init_transaction();
|
|
5
|
-
function followUpCheckStatus(subscriptionId, project) {
|
|
6
|
-
const db = getSqliteDatabase();
|
|
7
|
-
const recent = db.prepare(`SELECT run_id AS id, status, outcome_reason AS outcome, started_at AS startedAt,
|
|
8
|
-
completed_at AS completedAt, next_attempt_at AS retryAt, attempt FROM proactive_runs
|
|
9
|
-
WHERE subscription_id = ? ORDER BY started_at DESC LIMIT 5`).all(subscriptionId);
|
|
10
|
-
const schedule = project ? db.prepare("SELECT last_checked_at, next_due_at FROM proactive_schedule_state WHERE subscription_id = ?").get(subscriptionId) : void 0;
|
|
11
|
-
const pending = db.prepare("SELECT status FROM proactive_signal_batches WHERE subscription_id = ? AND status IN ('collecting', 'ready', 'processing') ORDER BY created_at DESC LIMIT 1").get(subscriptionId);
|
|
12
|
-
const latest = recent[0];
|
|
13
|
-
const enabled = effectiveProactivePolicy(subscriptionId).enabled;
|
|
14
|
-
return {
|
|
15
|
-
health: !enabled ? "waiting" : pending?.status === "processing" ? "running" : pending ? "queued" : latest?.status === "retryable" ? "retrying" : latest?.status === "failed" || latest?.outcome === "source_unavailable" || latest?.outcome === "source_stale" ? "blocked" : "waiting",
|
|
16
|
-
recent,
|
|
17
|
-
lastCheckedAt: schedule?.last_checked_at ?? recent.find((run) => run.status === "completed")?.completedAt ?? null,
|
|
18
|
-
nextCheckAt: !enabled ? null : latest?.status === "retryable" ? latest.retryAt : schedule?.next_due_at ?? null
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { followUpCheckStatus };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import { effectiveProactivePolicy, localProactiveDay } from "../policy/service.js";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
//#region src/proactive/temporal/schedule.ts
|
|
5
|
-
init_transaction();
|
|
6
|
-
/** Local scans publish through the same event pipeline; next_due_at survives restarts. */
|
|
7
|
-
function scanDueProjects(events, now = /* @__PURE__ */ new Date()) {
|
|
8
|
-
return runSqliteWriteTransaction((db) => {
|
|
9
|
-
const rows = db.prepare(`SELECT q.*, s.workspace_id, s.scope_id, s.scenario_key FROM proactive_schedule_state q
|
|
10
|
-
JOIN proactive_scenario_subscriptions s USING(subscription_id)
|
|
11
|
-
WHERE q.next_due_at <= ? AND s.enabled = 1 AND s.scope_kind = 'project'
|
|
12
|
-
AND s.scenario_key IN ('project_delivery_risk', 'blocked_work') ORDER BY q.next_due_at LIMIT 20`).all(now.toISOString());
|
|
13
|
-
let published = 0;
|
|
14
|
-
for (const row of rows) {
|
|
15
|
-
const policy = effectiveProactivePolicy(row.subscription_id, now);
|
|
16
|
-
if (!policy.enabled) {
|
|
17
|
-
db.prepare("UPDATE proactive_schedule_state SET next_due_at = ? WHERE subscription_id = ?").run(new Date(now.getTime() + 6e4).toISOString(), row.subscription_id);
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
const project = db.prepare("SELECT * FROM projects WHERE project_id = ?").get(row.scope_id);
|
|
21
|
-
const tasks = db.prepare(`SELECT task_id, phase, due_at, updated_at FROM tasks WHERE project_id = ? AND phase <> 'closed' ORDER BY task_id`).all(row.scope_id);
|
|
22
|
-
const deadlines = tasks.map((task) => {
|
|
23
|
-
const remaining = (typeof task.due_at === "number" ? task.due_at : task.due_at ? Date.parse(task.due_at) : NaN) - now.getTime();
|
|
24
|
-
return !Number.isFinite(remaining) ? null : remaining <= 0 ? "overdue" : remaining <= 72e5 ? "2h" : remaining <= 864e5 ? "24h" : "later";
|
|
25
|
-
});
|
|
26
|
-
const waits = db.prepare(`SELECT w.* FROM task_waits w JOIN tasks t ON t.task_id = w.task_id WHERE t.project_id = ? AND w.status = 'active' ORDER BY w.task_id, w.created_at`).all(row.scope_id);
|
|
27
|
-
const fingerprint = createHash("sha256").update(JSON.stringify([
|
|
28
|
-
project,
|
|
29
|
-
tasks,
|
|
30
|
-
waits,
|
|
31
|
-
deadlines,
|
|
32
|
-
localProactiveDay(now, policy.preferences.timezone)
|
|
33
|
-
])).digest("hex");
|
|
34
|
-
if (project && fingerprint !== row.last_fingerprint) {
|
|
35
|
-
events.publish({
|
|
36
|
-
type: "proactive.scan.v1",
|
|
37
|
-
schemaVersion: 1,
|
|
38
|
-
source: {
|
|
39
|
-
kind: "proactive_scheduler",
|
|
40
|
-
id: row.subscription_id
|
|
41
|
-
},
|
|
42
|
-
subject: {
|
|
43
|
-
kind: "project",
|
|
44
|
-
id: row.scope_id
|
|
45
|
-
},
|
|
46
|
-
actor: { kind: "system" },
|
|
47
|
-
scope: {
|
|
48
|
-
workspaceId: row.workspace_id,
|
|
49
|
-
projectId: row.scope_id
|
|
50
|
-
},
|
|
51
|
-
occurredAt: now.toISOString(),
|
|
52
|
-
dedupeKey: `scan:${row.subscription_id}:${row.next_due_at}`,
|
|
53
|
-
sensitivity: "personal",
|
|
54
|
-
payload: {
|
|
55
|
-
subscriptionId: row.subscription_id,
|
|
56
|
-
reason: "scheduled_check",
|
|
57
|
-
observedAt: now.toISOString()
|
|
58
|
-
}
|
|
59
|
-
}, now);
|
|
60
|
-
published++;
|
|
61
|
-
}
|
|
62
|
-
db.prepare(`UPDATE proactive_schedule_state SET next_due_at = ?, last_checked_at = ?, last_fingerprint = ? WHERE subscription_id = ?`).run(new Date(now.getTime() + policy.scanIntervalMinutes * 6e4).toISOString(), now.toISOString(), fingerprint, row.subscription_id);
|
|
63
|
-
}
|
|
64
|
-
return published;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
export { scanDueProjects };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ProactiveEventService } from '../service.js';
|
|
2
|
-
export declare function isMeetingWorthPreparing(content: string | undefined | null): boolean;
|
|
3
|
-
export type TemporalTickResult = {
|
|
4
|
-
scanned: number;
|
|
5
|
-
published: number;
|
|
6
|
-
skipped: number;
|
|
7
|
-
};
|
|
8
|
-
export declare class ProactiveTemporalWorker {
|
|
9
|
-
private readonly events;
|
|
10
|
-
private readonly intervalMs;
|
|
11
|
-
private timer;
|
|
12
|
-
private running;
|
|
13
|
-
constructor(events: ProactiveEventService, intervalMs?: number);
|
|
14
|
-
start(): void;
|
|
15
|
-
stop(): void;
|
|
16
|
-
tick(now?: Date): Promise<TemporalTickResult>;
|
|
17
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
-
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { listKnowledgeSourceItems } from "../../storage/sqlite/knowledge-repository.js";
|
|
4
|
-
import { sourceFreshness } from "../source-freshness.js";
|
|
5
|
-
import { authorizedConnectedSource } from "../execution/authorization.js";
|
|
6
|
-
import { effectiveProactivePolicy } from "../policy/service.js";
|
|
7
|
-
import { listSubscriptions } from "../scenarios/repository.js";
|
|
8
|
-
import { scanMailFollowUps } from "../follow-ups.js";
|
|
9
|
-
import { scanDueProjects } from "./schedule.js";
|
|
10
|
-
import { completeDeliveredProjects } from "../experience.js";
|
|
11
|
-
//#region src/proactive/temporal/worker.ts
|
|
12
|
-
init_logger();
|
|
13
|
-
const log = createLogger("Proactive:Temporal");
|
|
14
|
-
const MEETING_SCENARIO = "meeting_preparation";
|
|
15
|
-
function isMeetingWorthPreparing(content) {
|
|
16
|
-
if (!content) return false;
|
|
17
|
-
try {
|
|
18
|
-
const event = JSON.parse(content);
|
|
19
|
-
return Boolean(event.title?.trim()) && event.status !== "cancelled" && !event.allDay && !event.attendees?.some((attendee) => attendee.self && attendee.responseStatus === "declined");
|
|
20
|
-
} catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function metadataString(metadata, key) {
|
|
25
|
-
const value = metadata[key];
|
|
26
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
27
|
-
}
|
|
28
|
-
function meetingWindow(startMs, nowMs) {
|
|
29
|
-
const untilStart = startMs - nowMs;
|
|
30
|
-
if (untilStart <= 0) return null;
|
|
31
|
-
if (untilStart <= 120 * 6e4) return "2h";
|
|
32
|
-
if (untilStart <= 1440 * 6e4) return "24h";
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
var ProactiveTemporalWorker = class {
|
|
36
|
-
timer = null;
|
|
37
|
-
running = false;
|
|
38
|
-
constructor(events, intervalMs = 6e4) {
|
|
39
|
-
this.events = events;
|
|
40
|
-
this.intervalMs = intervalMs;
|
|
41
|
-
}
|
|
42
|
-
start() {
|
|
43
|
-
if (this.timer) return;
|
|
44
|
-
this.tick();
|
|
45
|
-
this.timer = setInterval(() => void this.tick(), Math.max(5e3, this.intervalMs));
|
|
46
|
-
this.timer.unref?.();
|
|
47
|
-
}
|
|
48
|
-
stop() {
|
|
49
|
-
if (this.timer) clearInterval(this.timer);
|
|
50
|
-
this.timer = null;
|
|
51
|
-
}
|
|
52
|
-
async tick(now = /* @__PURE__ */ new Date()) {
|
|
53
|
-
if (this.running) return {
|
|
54
|
-
scanned: 0,
|
|
55
|
-
published: 0,
|
|
56
|
-
skipped: 0
|
|
57
|
-
};
|
|
58
|
-
this.running = true;
|
|
59
|
-
const result = {
|
|
60
|
-
scanned: 0,
|
|
61
|
-
published: 0,
|
|
62
|
-
skipped: 0
|
|
63
|
-
};
|
|
64
|
-
try {
|
|
65
|
-
completeDeliveredProjects(now);
|
|
66
|
-
scanDueProjects(this.events, now);
|
|
67
|
-
result.published += scanMailFollowUps(this.events, now);
|
|
68
|
-
const activeWorkspaces = new Set(listSubscriptions(MEETING_SCENARIO).filter((sub) => effectiveProactivePolicy(sub.id, now).enabled).map((sub) => sub.workspaceId));
|
|
69
|
-
if (!activeWorkspaces.size) return result;
|
|
70
|
-
const nowMs = now.getTime();
|
|
71
|
-
const pageSize = 500;
|
|
72
|
-
for (let offset = 0;; offset += pageSize) {
|
|
73
|
-
const items = listKnowledgeSourceItems({
|
|
74
|
-
itemType: "calendar_event",
|
|
75
|
-
occurredAfterMs: nowMs,
|
|
76
|
-
occurredBeforeMs: nowMs + 1440 * 6e4,
|
|
77
|
-
orderBy: "occurred_asc",
|
|
78
|
-
limit: pageSize,
|
|
79
|
-
offset
|
|
80
|
-
});
|
|
81
|
-
for (const item of items) {
|
|
82
|
-
result.scanned += 1;
|
|
83
|
-
const connectionId = metadataString(item.metadata, "connectionId");
|
|
84
|
-
const workspaceId = metadataString(item.metadata, "workspaceId");
|
|
85
|
-
const connectorId = metadataString(item.metadata, "connectorId");
|
|
86
|
-
const agentId = metadataString(item.metadata, "agentId");
|
|
87
|
-
const window = meetingWindow(item.occurredAt ? Date.parse(item.occurredAt) : NaN, nowMs);
|
|
88
|
-
if (!connectionId || !workspaceId || !activeWorkspaces.has(workspaceId) || !connectorId || !window || !sourceFreshness(item.id, void 0, now.getTime()).fresh || !isMeetingWorthPreparing(item.normalizedText) || !authorizedConnectedSource(item.id, workspaceId, MEETING_SCENARIO, agentId) || item.sensitivity === "secret" || item.sensitivity === "regulated") {
|
|
89
|
-
result.skipped += 1;
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (this.events.publish({
|
|
93
|
-
type: "connected_source.calendar_window.v1",
|
|
94
|
-
schemaVersion: 1,
|
|
95
|
-
source: {
|
|
96
|
-
kind: "connector",
|
|
97
|
-
id: connectionId
|
|
98
|
-
},
|
|
99
|
-
subject: {
|
|
100
|
-
kind: "knowledge_source_item",
|
|
101
|
-
id: item.id
|
|
102
|
-
},
|
|
103
|
-
actor: { kind: "system" },
|
|
104
|
-
scope: {
|
|
105
|
-
workspaceId,
|
|
106
|
-
...agentId ? { agentId } : {}
|
|
107
|
-
},
|
|
108
|
-
occurredAt: now.toISOString(),
|
|
109
|
-
dedupeKey: `calendar-window:${item.id}:${item.occurredAt}:${item.contentHash}:${window}`,
|
|
110
|
-
sensitivity: item.sensitivity === "normal" ? "personal" : item.sensitivity,
|
|
111
|
-
payload: {
|
|
112
|
-
sourceItemId: item.id,
|
|
113
|
-
meetingStartsAt: item.occurredAt,
|
|
114
|
-
contentHash: item.contentHash,
|
|
115
|
-
window
|
|
116
|
-
}
|
|
117
|
-
}, now).inserted) result.published += 1;
|
|
118
|
-
}
|
|
119
|
-
if (items.length < pageSize) break;
|
|
120
|
-
}
|
|
121
|
-
if (result.published > 0) log.info(result, "Temporal meeting signals published");
|
|
122
|
-
return result;
|
|
123
|
-
} finally {
|
|
124
|
-
this.running = false;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
//#endregion
|
|
129
|
-
export { ProactiveTemporalWorker, isMeetingWorthPreparing };
|