@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,408 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import { getAssertionSlot, listUserAssertions } from "../../user-model/repository.js";
|
|
3
|
-
import "../../user-model/index.js";
|
|
4
|
-
import { authorizedConnectedSource } from "./authorization.js";
|
|
5
|
-
import { authorizedMailThread, requireMailFollowUp } from "../follow-ups.js";
|
|
6
|
-
import { getDiscussionCapture, getLatestDiscussionOrganization } from "../../discussions/repository.js";
|
|
7
|
-
import { wrapExternalContent } from "../../gateway/security/external-content.js";
|
|
8
|
-
//#region src/proactive/execution/context.ts
|
|
9
|
-
init_transaction();
|
|
10
|
-
const MAX_EVENT_COUNT = 50;
|
|
11
|
-
function boundedText(value, limit) {
|
|
12
|
-
if (typeof value !== "string") return void 0;
|
|
13
|
-
const normalized = value.trim();
|
|
14
|
-
if (!normalized) return void 0;
|
|
15
|
-
return normalized.length > limit ? `${normalized.slice(0, limit)}…` : normalized;
|
|
16
|
-
}
|
|
17
|
-
function eventRows(eventIds) {
|
|
18
|
-
const ids = [...new Set(eventIds)].slice(0, MAX_EVENT_COUNT);
|
|
19
|
-
if (ids.length === 0) return [];
|
|
20
|
-
return getSqliteDatabase().prepare(`SELECT event_id, type, subject_kind, subject_id, payload_json,
|
|
21
|
-
workspace_id, project_id, agent_id, occurred_at FROM proactive_events
|
|
22
|
-
WHERE event_id IN (${ids.map(() => "?").join(",")}) ORDER BY occurred_at`).all(...ids);
|
|
23
|
-
}
|
|
24
|
-
function emptyContext() {
|
|
25
|
-
return {
|
|
26
|
-
content: {},
|
|
27
|
-
snapshotContent: {},
|
|
28
|
-
evidenceIds: []
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function authorizedConnectedSourceItem(event, scenarioKey) {
|
|
32
|
-
const item = authorizedConnectedSource(event.subject_id, event.workspace_id, scenarioKey, event.agent_id);
|
|
33
|
-
if (item && event.type === "connected_source.calendar_window.v1") {
|
|
34
|
-
const payload = JSON.parse(event.payload_json);
|
|
35
|
-
if (!item.occurredAt || Date.parse(item.occurredAt) <= Date.now()) return null;
|
|
36
|
-
if (payload.meetingStartsAt !== item.occurredAt || payload.contentHash && payload.contentHash !== item.contentHash) return null;
|
|
37
|
-
}
|
|
38
|
-
return item;
|
|
39
|
-
}
|
|
40
|
-
var EventBatchContextProvider = class {
|
|
41
|
-
id = "event_batch";
|
|
42
|
-
async collect(input) {
|
|
43
|
-
const rows = eventRows(input.eventIds).filter((row) => !row.type.startsWith("connected_source.") || Boolean(authorizedConnectedSourceItem(row, input.scenarioKey)));
|
|
44
|
-
return {
|
|
45
|
-
content: { events: rows.map((row) => ({
|
|
46
|
-
evidenceId: row.event_id,
|
|
47
|
-
type: row.type,
|
|
48
|
-
subject: {
|
|
49
|
-
kind: row.subject_kind,
|
|
50
|
-
id: row.subject_id
|
|
51
|
-
},
|
|
52
|
-
payload: JSON.parse(row.payload_json),
|
|
53
|
-
occurredAt: row.occurred_at
|
|
54
|
-
})) },
|
|
55
|
-
evidenceIds: rows.map((row) => row.event_id)
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
var ConnectedSourceContextProvider = class {
|
|
60
|
-
id = "connected_source";
|
|
61
|
-
async collect(input) {
|
|
62
|
-
const items = [];
|
|
63
|
-
const snapshotItems = [];
|
|
64
|
-
const seen = /* @__PURE__ */ new Set();
|
|
65
|
-
const evidenceIds = [];
|
|
66
|
-
for (const event of eventRows(input.eventIds)) {
|
|
67
|
-
if (!event.type.startsWith("connected_source.") || event.type.includes("_deleted.")) continue;
|
|
68
|
-
const item = authorizedConnectedSourceItem(event, input.scenarioKey);
|
|
69
|
-
if (!item || seen.has(item.id)) continue;
|
|
70
|
-
seen.add(item.id);
|
|
71
|
-
const evidenceId = `source-item:${item.id}`;
|
|
72
|
-
const common = {
|
|
73
|
-
evidenceId,
|
|
74
|
-
sourceItemId: item.id,
|
|
75
|
-
sourceInstanceId: item.sourceInstanceId,
|
|
76
|
-
collectionScope: item.collectionScope,
|
|
77
|
-
itemType: item.itemType,
|
|
78
|
-
occurredAt: item.occurredAt,
|
|
79
|
-
sourceUpdatedAt: item.sourceUpdatedAt
|
|
80
|
-
};
|
|
81
|
-
const content = boundedText(item.normalizedText, 6e3);
|
|
82
|
-
items.push({
|
|
83
|
-
...common,
|
|
84
|
-
...content ? { content: wrapExternalContent(content, { source: item.itemType === "email" || item.itemType === "message" ? "email" : "api" }) } : {}
|
|
85
|
-
});
|
|
86
|
-
snapshotItems.push({
|
|
87
|
-
...common,
|
|
88
|
-
contentHash: item.contentHash,
|
|
89
|
-
sensitivity: item.sensitivity
|
|
90
|
-
});
|
|
91
|
-
evidenceIds.push(evidenceId);
|
|
92
|
-
if (items.length >= 20) break;
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
content: { items },
|
|
96
|
-
snapshotContent: { items: snapshotItems },
|
|
97
|
-
evidenceIds
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var InternalObjectContextProvider = class {
|
|
102
|
-
id = "internal_objects";
|
|
103
|
-
async collect(input) {
|
|
104
|
-
const db = getSqliteDatabase();
|
|
105
|
-
const objects = [];
|
|
106
|
-
const evidenceIds = [];
|
|
107
|
-
for (const event of eventRows(input.eventIds)) {
|
|
108
|
-
if (event.subject_kind === "task") {
|
|
109
|
-
const task = db.prepare(`SELECT tasks.task_id, tasks.title, tasks.body,
|
|
110
|
-
tasks.phase, tasks.resolution, tasks.priority,
|
|
111
|
-
tasks.due_at, tasks.updated_at, tasks.delegate_agent_id,
|
|
112
|
-
(SELECT kind FROM task_waits
|
|
113
|
-
WHERE task_waits.task_id = tasks.task_id AND task_waits.status = 'active'
|
|
114
|
-
ORDER BY task_waits.created_at DESC LIMIT 1) AS wait_kind,
|
|
115
|
-
(SELECT reason FROM task_waits
|
|
116
|
-
WHERE task_waits.task_id = tasks.task_id AND task_waits.status = 'active'
|
|
117
|
-
ORDER BY task_waits.created_at DESC LIMIT 1) AS wait_reason
|
|
118
|
-
FROM tasks
|
|
119
|
-
WHERE tasks.task_id = ?`).get(event.subject_id);
|
|
120
|
-
if (task) {
|
|
121
|
-
const evidenceId = `task:${event.subject_id}`;
|
|
122
|
-
objects.push({
|
|
123
|
-
evidenceId,
|
|
124
|
-
kind: "task",
|
|
125
|
-
...task
|
|
126
|
-
});
|
|
127
|
-
evidenceIds.push(evidenceId);
|
|
128
|
-
}
|
|
129
|
-
} else if (event.subject_kind === "note") {
|
|
130
|
-
const note = db.prepare(`SELECT note_id, title, kind, status, snippet, pinned, tags_json,
|
|
131
|
-
task_done, task_due_at, unchecked_task_count, updated_at FROM notes WHERE note_id = ?`).get(event.subject_id);
|
|
132
|
-
if (note) {
|
|
133
|
-
const evidenceId = `note:${event.subject_id}`;
|
|
134
|
-
objects.push({
|
|
135
|
-
...note,
|
|
136
|
-
evidenceId,
|
|
137
|
-
kind: "note",
|
|
138
|
-
snippet: boundedText(note.snippet, 1500)
|
|
139
|
-
});
|
|
140
|
-
evidenceIds.push(evidenceId);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (objects.length >= 20) break;
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
content: { objects },
|
|
147
|
-
evidenceIds
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
var UserModelContextProvider = class {
|
|
152
|
-
id = "user_model";
|
|
153
|
-
async collect(input) {
|
|
154
|
-
const scope = eventRows(input.eventIds).at(-1);
|
|
155
|
-
if (!scope) return emptyContext();
|
|
156
|
-
const records = listUserAssertions({
|
|
157
|
-
statuses: ["active"],
|
|
158
|
-
limit: 500
|
|
159
|
-
}).filter((record) => {
|
|
160
|
-
const now = Date.now();
|
|
161
|
-
const assertionScope = getAssertionSlot(record.slotId)?.scope;
|
|
162
|
-
const scopeMatches = assertionScope?.type === "global" || assertionScope?.type === "workspace" && assertionScope.id === scope.workspace_id || assertionScope?.type === "project" && assertionScope.id === scope.project_id || assertionScope?.type === "agent" && assertionScope.id === scope.agent_id;
|
|
163
|
-
return record.disclosurePolicy === "referenceable" && record.sensitivity !== "secret" && record.sensitivity !== "regulated" && scopeMatches && (!record.validFrom || record.validFrom <= now) && (!record.validTo || record.validTo >= now) && (record.authority === "user_explicit" || record.confidence >= .7);
|
|
164
|
-
}).slice(0, 20);
|
|
165
|
-
return {
|
|
166
|
-
content: { records: records.map((record) => ({
|
|
167
|
-
evidenceId: `assertion:${record.id}`,
|
|
168
|
-
kind: record.kind,
|
|
169
|
-
content: boundedText(record.statement, 1e3),
|
|
170
|
-
confidence: record.confidence,
|
|
171
|
-
recordedAt: record.recordedAt
|
|
172
|
-
})) },
|
|
173
|
-
evidenceIds: records.map((record) => `assertion:${record.id}`)
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
var MeetingWorkspaceContextProvider = class {
|
|
178
|
-
id = "meeting_workspace";
|
|
179
|
-
async collect(input) {
|
|
180
|
-
const scope = eventRows(input.eventIds).at(-1);
|
|
181
|
-
if (!scope) return emptyContext();
|
|
182
|
-
const calendarItem = authorizedConnectedSourceItem(scope, input.scenarioKey);
|
|
183
|
-
if (!calendarItem?.normalizedText) return emptyContext();
|
|
184
|
-
let title = "";
|
|
185
|
-
try {
|
|
186
|
-
const parsed = JSON.parse(calendarItem.normalizedText);
|
|
187
|
-
title = typeof parsed.title === "string" ? parsed.title : "";
|
|
188
|
-
} catch {
|
|
189
|
-
return emptyContext();
|
|
190
|
-
}
|
|
191
|
-
const terms = [...new Set(title.toLocaleLowerCase().match(/[\p{L}\p{N}]{2,}/gu) ?? [])].slice(0, 6);
|
|
192
|
-
if (terms.length === 0) return emptyContext();
|
|
193
|
-
const db = getSqliteDatabase();
|
|
194
|
-
const taskMatches = terms.map(() => `LOWER(COALESCE(tasks.title, '') || ' '
|
|
195
|
-
|| COALESCE(tasks.body, '')) LIKE ?`).join(" OR ");
|
|
196
|
-
const tasks = db.prepare(`SELECT tasks.task_id, tasks.title, tasks.body,
|
|
197
|
-
tasks.phase, tasks.resolution, tasks.priority, tasks.due_at,
|
|
198
|
-
tasks.updated_at, tasks.project_id
|
|
199
|
-
FROM tasks
|
|
200
|
-
WHERE tasks.phase <> 'closed'
|
|
201
|
-
AND COALESCE(tasks.delegate_agent_id, ?) = ? AND (${taskMatches})
|
|
202
|
-
ORDER BY tasks.updated_at DESC LIMIT 10`).all(scope.agent_id ?? "main", scope.agent_id ?? "main", ...terms.map((term) => `%${term}%`));
|
|
203
|
-
const noteMatches = terms.map(() => `LOWER(COALESCE(title, '') || ' ' || COALESCE(snippet, '')) LIKE ?`).join(" OR ");
|
|
204
|
-
const notes = db.prepare(`SELECT note_id, title, kind, status, snippet, tags_json, task_due_at,
|
|
205
|
-
unchecked_task_count, updated_at FROM notes WHERE status NOT IN ('archived', 'trashed')
|
|
206
|
-
AND (${noteMatches}) ORDER BY updated_at DESC LIMIT 10`).all(...terms.map((term) => `%${term}%`));
|
|
207
|
-
const taskEvidenceIds = tasks.map((task) => `task:${String(task.task_id)}`);
|
|
208
|
-
const noteEvidenceIds = notes.map((note) => `note:${String(note.note_id)}`);
|
|
209
|
-
return {
|
|
210
|
-
content: {
|
|
211
|
-
activeTasks: tasks.map((task, index) => ({
|
|
212
|
-
evidenceId: taskEvidenceIds[index],
|
|
213
|
-
...task
|
|
214
|
-
})),
|
|
215
|
-
recentNotes: notes.map((note, index) => ({
|
|
216
|
-
evidenceId: noteEvidenceIds[index],
|
|
217
|
-
...note,
|
|
218
|
-
snippet: boundedText(note.snippet, 1500)
|
|
219
|
-
}))
|
|
220
|
-
},
|
|
221
|
-
evidenceIds: [...taskEvidenceIds, ...noteEvidenceIds]
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
var ProjectStateContextProvider = class {
|
|
226
|
-
id = "project_state";
|
|
227
|
-
async collect(input) {
|
|
228
|
-
if (!input.eventIds.length) return emptyContext();
|
|
229
|
-
const project = getSqliteDatabase().prepare(`SELECT p.* FROM proactive_events e JOIN projects p ON p.project_id = e.project_id
|
|
230
|
-
WHERE e.event_id IN (${input.eventIds.map(() => "?").join(",")}) AND e.project_id IS NOT NULL ORDER BY e.occurred_at DESC LIMIT 1`).get(...input.eventIds);
|
|
231
|
-
if (!project) return emptyContext();
|
|
232
|
-
const tasks = getSqliteDatabase().prepare(`SELECT task.task_id, task.title, task.body,
|
|
233
|
-
task.phase, task.resolution, task.priority, task.due_at, task.updated_at,
|
|
234
|
-
(SELECT wait.kind FROM task_waits wait
|
|
235
|
-
WHERE wait.task_id = task.task_id AND wait.status = 'active'
|
|
236
|
-
ORDER BY wait.created_at DESC LIMIT 1) AS wait_kind,
|
|
237
|
-
(SELECT wait.reason FROM task_waits wait
|
|
238
|
-
WHERE wait.task_id = task.task_id AND wait.status = 'active'
|
|
239
|
-
ORDER BY wait.created_at DESC LIMIT 1) AS wait_reason,
|
|
240
|
-
(SELECT json_group_array(json_object(
|
|
241
|
-
'taskId', dependency.depends_on_task_id,
|
|
242
|
-
'title', upstream.title,
|
|
243
|
-
'phase', upstream.phase,
|
|
244
|
-
'resolution', upstream.resolution
|
|
245
|
-
)) FROM task_dependencies dependency
|
|
246
|
-
JOIN tasks upstream ON upstream.task_id = dependency.depends_on_task_id
|
|
247
|
-
WHERE dependency.task_id = task.task_id) AS dependencies_json
|
|
248
|
-
FROM tasks task
|
|
249
|
-
WHERE task.project_id = ? AND task.phase <> 'closed'
|
|
250
|
-
ORDER BY CASE WHEN EXISTS (
|
|
251
|
-
SELECT 1 FROM task_waits wait WHERE wait.task_id = task.task_id AND wait.status = 'active'
|
|
252
|
-
) THEN 0 ELSE 1 END,
|
|
253
|
-
task.updated_at DESC LIMIT 100`).all(String(project.project_id));
|
|
254
|
-
const projectEvidenceId = `project:${String(project.project_id)}`;
|
|
255
|
-
const taskEvidenceIds = tasks.map((task) => `task:${String(task.task_id)}`);
|
|
256
|
-
return {
|
|
257
|
-
content: {
|
|
258
|
-
project: {
|
|
259
|
-
evidenceId: projectEvidenceId,
|
|
260
|
-
...project
|
|
261
|
-
},
|
|
262
|
-
activeTasks: tasks.map((task, index) => {
|
|
263
|
-
const { dependencies_json: dependenciesJson, ...fields } = task;
|
|
264
|
-
return {
|
|
265
|
-
evidenceId: taskEvidenceIds[index],
|
|
266
|
-
...fields,
|
|
267
|
-
dependencies: dependenciesJson ? JSON.parse(String(dependenciesJson)) : []
|
|
268
|
-
};
|
|
269
|
-
})
|
|
270
|
-
},
|
|
271
|
-
evidenceIds: [projectEvidenceId, ...taskEvidenceIds]
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
var AutomationStateContextProvider = class {
|
|
276
|
-
id = "automation_state";
|
|
277
|
-
async collect(input) {
|
|
278
|
-
if (!input.eventIds.length) return emptyContext();
|
|
279
|
-
const run = getSqliteDatabase().prepare(`SELECT r.* FROM proactive_events e JOIN automation_runs r ON r.run_id = e.subject_id
|
|
280
|
-
WHERE e.event_id IN (${input.eventIds.map(() => "?").join(",")}) ORDER BY e.occurred_at DESC LIMIT 1`).get(...input.eventIds);
|
|
281
|
-
if (!run) return emptyContext();
|
|
282
|
-
const automation = getSqliteDatabase().prepare(`SELECT automation_id, name, description, enabled, reliability_json, state_json, project_id
|
|
283
|
-
FROM automations WHERE automation_id = ?`).get(String(run.automation_id));
|
|
284
|
-
const recentRuns = getSqliteDatabase().prepare(`SELECT run_id, status, summary, error, duration_ms, started_at, ended_at
|
|
285
|
-
FROM automation_runs WHERE automation_id = ? AND run_id <> ?
|
|
286
|
-
ORDER BY started_at DESC LIMIT 5`).all(String(run.automation_id), String(run.run_id));
|
|
287
|
-
const runEvidenceId = `automation-run:${String(run.run_id)}`;
|
|
288
|
-
return {
|
|
289
|
-
content: {
|
|
290
|
-
automation,
|
|
291
|
-
failedRun: {
|
|
292
|
-
evidenceId: runEvidenceId,
|
|
293
|
-
...run
|
|
294
|
-
},
|
|
295
|
-
recentRuns
|
|
296
|
-
},
|
|
297
|
-
evidenceIds: [runEvidenceId]
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
var DiscussionContextProvider = class {
|
|
302
|
-
id = "discussion";
|
|
303
|
-
async collect(input) {
|
|
304
|
-
const event = eventRows(input.eventIds).findLast((row) => row.subject_kind === "discussion");
|
|
305
|
-
if (!event) return emptyContext();
|
|
306
|
-
const discussion = getDiscussionCapture(event.subject_id);
|
|
307
|
-
if (!discussion || discussion.status !== "completed") return emptyContext();
|
|
308
|
-
const organization = getLatestDiscussionOrganization(discussion.id);
|
|
309
|
-
const discussionEvidenceId = `discussion:${discussion.id}`;
|
|
310
|
-
const noteEvidenceId = `note:${discussion.noteId}`;
|
|
311
|
-
return {
|
|
312
|
-
content: { discussion: {
|
|
313
|
-
evidenceId: discussionEvidenceId,
|
|
314
|
-
id: discussion.id,
|
|
315
|
-
noteId: discussion.noteId,
|
|
316
|
-
noteEvidenceId,
|
|
317
|
-
projectId: discussion.projectId,
|
|
318
|
-
title: discussion.generatedTitle,
|
|
319
|
-
transcript: boundedText(discussion.canonicalTranscript, 6e3),
|
|
320
|
-
organization: organization?.organization,
|
|
321
|
-
completedAt: discussion.completedAt
|
|
322
|
-
} },
|
|
323
|
-
snapshotContent: { discussion: {
|
|
324
|
-
evidenceId: discussionEvidenceId,
|
|
325
|
-
id: discussion.id,
|
|
326
|
-
noteId: discussion.noteId,
|
|
327
|
-
noteEvidenceId,
|
|
328
|
-
projectId: discussion.projectId,
|
|
329
|
-
transcriptSha256: discussion.canonicalTranscriptSha256,
|
|
330
|
-
organizationRevision: organization?.revision,
|
|
331
|
-
organization: organization?.organization,
|
|
332
|
-
completedAt: discussion.completedAt
|
|
333
|
-
} },
|
|
334
|
-
evidenceIds: [discussionEvidenceId, noteEvidenceId]
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
var MailFollowUpContextProvider = class {
|
|
339
|
-
id = "follow_up";
|
|
340
|
-
async collect(input) {
|
|
341
|
-
const event = eventRows(input.eventIds).findLast((row) => row.subject_kind === "mail_follow_up");
|
|
342
|
-
if (!event) return emptyContext();
|
|
343
|
-
const follow = requireMailFollowUp(event.workspace_id, event.subject_id);
|
|
344
|
-
const thread = authorizedMailThread(follow);
|
|
345
|
-
if (!thread || follow.status !== "watching") return emptyContext();
|
|
346
|
-
const common = {
|
|
347
|
-
followUpId: follow.id,
|
|
348
|
-
revision: follow.revision,
|
|
349
|
-
fingerprint: thread.fingerprint,
|
|
350
|
-
dueAt: follow.due_at,
|
|
351
|
-
deadlinePassed: Date.parse(follow.due_at) <= Date.now()
|
|
352
|
-
};
|
|
353
|
-
return {
|
|
354
|
-
content: {
|
|
355
|
-
...common,
|
|
356
|
-
instructions: follow.instructions,
|
|
357
|
-
items: thread.items.map((item) => ({
|
|
358
|
-
evidenceId: `source-item:${item.id}`,
|
|
359
|
-
occurredAt: item.occurredAt,
|
|
360
|
-
content: wrapExternalContent(item.normalizedText?.slice(0, 4e3) ?? "", { source: "email" })
|
|
361
|
-
}))
|
|
362
|
-
},
|
|
363
|
-
snapshotContent: {
|
|
364
|
-
...common,
|
|
365
|
-
items: thread.items.map((item) => ({
|
|
366
|
-
sourceItemId: item.id,
|
|
367
|
-
contentHash: item.contentHash,
|
|
368
|
-
occurredAt: item.occurredAt
|
|
369
|
-
}))
|
|
370
|
-
},
|
|
371
|
-
evidenceIds: thread.items.map((item) => `source-item:${item.id}`)
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
var ContextProviderRegistry = class {
|
|
376
|
-
constructor(providers = [
|
|
377
|
-
new EventBatchContextProvider(),
|
|
378
|
-
new ConnectedSourceContextProvider(),
|
|
379
|
-
new InternalObjectContextProvider(),
|
|
380
|
-
new UserModelContextProvider(),
|
|
381
|
-
new MeetingWorkspaceContextProvider(),
|
|
382
|
-
new ProjectStateContextProvider(),
|
|
383
|
-
new AutomationStateContextProvider(),
|
|
384
|
-
new DiscussionContextProvider(),
|
|
385
|
-
new MailFollowUpContextProvider()
|
|
386
|
-
]) {
|
|
387
|
-
this.providers = providers;
|
|
388
|
-
}
|
|
389
|
-
async collect(scenario, input) {
|
|
390
|
-
const providers = new Map(this.providers.map((provider) => [provider.id, provider]));
|
|
391
|
-
const selected = scenario.contextProviderIds.map((id) => {
|
|
392
|
-
const provider = providers.get(id);
|
|
393
|
-
if (!provider) throw new Error(`Unknown context provider: ${id}`);
|
|
394
|
-
return provider;
|
|
395
|
-
});
|
|
396
|
-
const entries = await Promise.all(selected.map(async (provider) => [provider.id, await provider.collect({
|
|
397
|
-
...input,
|
|
398
|
-
scenarioKey: scenario.key
|
|
399
|
-
})]));
|
|
400
|
-
return {
|
|
401
|
-
content: Object.fromEntries(entries.map(([id, result]) => [id, result.content])),
|
|
402
|
-
snapshotContent: Object.fromEntries(entries.map(([id, result]) => [id, result.snapshotContent ?? result.content])),
|
|
403
|
-
evidenceIds: [...new Set(entries.flatMap(([, result]) => result.evidenceIds))]
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
//#endregion
|
|
408
|
-
export { AutomationStateContextProvider, ConnectedSourceContextProvider, ContextProviderRegistry, DiscussionContextProvider, EventBatchContextProvider, InternalObjectContextProvider, MailFollowUpContextProvider, MeetingWorkspaceContextProvider, ProjectStateContextProvider, UserModelContextProvider };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { InsightCandidate } from './types.js';
|
|
2
|
-
export declare function parseInsightCandidate(raw: string, allowedEvidenceIds: Set<string>): InsightCandidate;
|
|
3
|
-
export declare function scoreInsight(candidate: InsightCandidate): number;
|
|
4
|
-
export declare function isValuableInsight(candidate: InsightCandidate, policy?: {
|
|
5
|
-
minConfidence: number;
|
|
6
|
-
minScore: number;
|
|
7
|
-
}): boolean;
|
|
8
|
-
export declare function parseAnalysisResult(raw: string, allowedEvidenceIds: Set<string>): {
|
|
9
|
-
result: 'no_insight';
|
|
10
|
-
reason: string;
|
|
11
|
-
} | {
|
|
12
|
-
result: 'insight';
|
|
13
|
-
candidate: InsightCandidate;
|
|
14
|
-
};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { ProactiveArtifactSchema } from "../../../packages/gateway-contract/src/proactive.js";
|
|
2
|
-
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
3
|
-
import { stripCodeFences } from "../../providers/model-response.js";
|
|
4
|
-
//#region src/proactive/execution/insight.ts
|
|
5
|
-
init_src();
|
|
6
|
-
const URGENCY = new Set([
|
|
7
|
-
"low",
|
|
8
|
-
"medium",
|
|
9
|
-
"high",
|
|
10
|
-
"critical"
|
|
11
|
-
]);
|
|
12
|
-
const boundedText = (value, field, max) => {
|
|
13
|
-
if (typeof value !== "string" || !value.trim()) throw new Error(`Insight ${field} is required`);
|
|
14
|
-
return value.trim().slice(0, max);
|
|
15
|
-
};
|
|
16
|
-
function parseDecision(value) {
|
|
17
|
-
if (value == null) return void 0;
|
|
18
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Insight decision is invalid");
|
|
19
|
-
const row = value;
|
|
20
|
-
if (!Array.isArray(row.options) || row.options.length < 2 || row.options.length > 3) throw new Error("Insight decision options are invalid");
|
|
21
|
-
const options = row.options.map((option) => {
|
|
22
|
-
if (!option || typeof option !== "object" || Array.isArray(option)) throw new Error("Insight decision option is invalid");
|
|
23
|
-
const item = option;
|
|
24
|
-
return {
|
|
25
|
-
id: boundedText(item.id, "decision option id", 80),
|
|
26
|
-
label: boundedText(item.label, "decision option label", 120),
|
|
27
|
-
consequence: boundedText(item.consequence, "decision option consequence", 400)
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
if (new Set(options.map((option) => option.id)).size !== options.length) throw new Error("Insight decision option ids must be unique");
|
|
31
|
-
return {
|
|
32
|
-
question: boundedText(row.question, "decision question", 400),
|
|
33
|
-
options
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function parseProposedAction(value) {
|
|
37
|
-
if (value == null) return void 0;
|
|
38
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Insight proposedAction is invalid");
|
|
39
|
-
const row = value;
|
|
40
|
-
if (row.id !== "create_project_task" || row.risk !== "low") throw new Error("Insight proposedAction is not supported");
|
|
41
|
-
if (!row.input || typeof row.input !== "object" || Array.isArray(row.input)) throw new Error("Insight proposedAction input is invalid");
|
|
42
|
-
const input = row.input;
|
|
43
|
-
return {
|
|
44
|
-
id: "create_project_task",
|
|
45
|
-
risk: "low",
|
|
46
|
-
rationale: boundedText(row.rationale, "proposedAction rationale", 600),
|
|
47
|
-
input: {
|
|
48
|
-
title: boundedText(input.title, "proposedAction title", 160),
|
|
49
|
-
objective: boundedText(input.objective, "proposedAction objective", 1200)
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function parseInsightCandidate(raw, allowedEvidenceIds) {
|
|
54
|
-
let value;
|
|
55
|
-
try {
|
|
56
|
-
value = JSON.parse(stripCodeFences(raw));
|
|
57
|
-
} catch {
|
|
58
|
-
throw new Error("Model output is not valid JSON");
|
|
59
|
-
}
|
|
60
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Insight must be a JSON object");
|
|
61
|
-
const row = value;
|
|
62
|
-
if (!URGENCY.has(String(row.urgency))) throw new Error("Insight urgency is invalid");
|
|
63
|
-
if (typeof row.confidence !== "number" || !Number.isFinite(row.confidence) || row.confidence < 0 || row.confidence > 1) throw new Error("Insight confidence is invalid");
|
|
64
|
-
if (!Array.isArray(row.evidenceIds) || row.evidenceIds.length === 0 || row.evidenceIds.length > 20) throw new Error("Insight evidenceIds are invalid");
|
|
65
|
-
const evidenceIds = [...new Set(row.evidenceIds.map(String))];
|
|
66
|
-
if (evidenceIds.some((id) => !allowedEvidenceIds.has(id))) throw new Error("Insight cites unknown evidence");
|
|
67
|
-
const decision = parseDecision(row.decision);
|
|
68
|
-
const proposedAction = parseProposedAction(row.proposedAction);
|
|
69
|
-
if (proposedAction && (!decision || decision.options.length !== 2 || decision.options[0]?.id !== "approve" || decision.options[1]?.id !== "reject")) throw new Error("Insight proposedAction requires approve and reject decision options");
|
|
70
|
-
return {
|
|
71
|
-
...row.artifact != null ? { artifact: ProactiveArtifactSchema.parse(row.artifact) } : {},
|
|
72
|
-
title: boundedText(row.title, "title", 160),
|
|
73
|
-
summary: boundedText(row.summary, "summary", 1200),
|
|
74
|
-
whyNow: boundedText(row.whyNow, "whyNow", 800),
|
|
75
|
-
impact: boundedText(row.impact, "impact", 800),
|
|
76
|
-
recommendation: boundedText(row.recommendation, "recommendation", 800),
|
|
77
|
-
workDone: boundedText(row.workDone, "workDone", 800),
|
|
78
|
-
...decision ? { decision } : {},
|
|
79
|
-
...proposedAction ? { proposedAction } : {},
|
|
80
|
-
urgency: String(row.urgency),
|
|
81
|
-
confidence: row.confidence,
|
|
82
|
-
evidenceIds
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function scoreInsight(candidate) {
|
|
86
|
-
const urgencyWeight = {
|
|
87
|
-
low: .15,
|
|
88
|
-
medium: .45,
|
|
89
|
-
high: .75,
|
|
90
|
-
critical: 1
|
|
91
|
-
}[candidate.urgency];
|
|
92
|
-
return Math.round((candidate.confidence * .7 + urgencyWeight * .3) * 1e3) / 1e3;
|
|
93
|
-
}
|
|
94
|
-
function isValuableInsight(candidate, policy = {
|
|
95
|
-
minConfidence: .65,
|
|
96
|
-
minScore: .6
|
|
97
|
-
}) {
|
|
98
|
-
return candidate.confidence >= policy.minConfidence && (candidate.urgency !== "low" || Boolean(candidate.artifact)) && scoreInsight(candidate) >= policy.minScore;
|
|
99
|
-
}
|
|
100
|
-
function parseAnalysisResult(raw, allowedEvidenceIds) {
|
|
101
|
-
let value;
|
|
102
|
-
try {
|
|
103
|
-
value = JSON.parse(stripCodeFences(raw));
|
|
104
|
-
} catch {
|
|
105
|
-
throw new Error("Model output is not valid JSON");
|
|
106
|
-
}
|
|
107
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
108
|
-
const row = value;
|
|
109
|
-
if (row.result === "no_insight") {
|
|
110
|
-
if (![
|
|
111
|
-
"unchanged",
|
|
112
|
-
"routine",
|
|
113
|
-
"insufficient_evidence",
|
|
114
|
-
"duplicate"
|
|
115
|
-
].includes(String(row.reason)) || Object.keys(row).some((key) => key !== "result" && key !== "reason")) throw new Error("Invalid no_insight result");
|
|
116
|
-
return {
|
|
117
|
-
result: "no_insight",
|
|
118
|
-
reason: String(row.reason)
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
if (row.result === "insight") return {
|
|
122
|
-
result: "insight",
|
|
123
|
-
candidate: parseInsightCandidate(JSON.stringify(row.candidate), allowedEvidenceIds)
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
result: "insight",
|
|
128
|
-
candidate: parseInsightCandidate(raw, allowedEvidenceIds)
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
export { isValuableInsight, parseAnalysisResult, parseInsightCandidate, scoreInsight };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ContextSnapshot, InsightCandidate, ProactiveInsight } from './types.js';
|
|
2
|
-
export interface ClaimedRun {
|
|
3
|
-
id: string;
|
|
4
|
-
batchId: string;
|
|
5
|
-
subscriptionId: string;
|
|
6
|
-
scenarioKey: string;
|
|
7
|
-
scenarioVersion: number;
|
|
8
|
-
promptRevisionId?: string;
|
|
9
|
-
attempt: number;
|
|
10
|
-
subscriptionRevision?: number;
|
|
11
|
-
}
|
|
12
|
-
export declare function claimNextRun(owner: string, now?: Date, leaseSeconds?: number): ClaimedRun | null;
|
|
13
|
-
export declare function eventIdsForBatch(batchId: string): string[];
|
|
14
|
-
export declare function saveSnapshot(batchId: string, content: Record<string, unknown>, evidenceIds: string[], now?: Date): ContextSnapshot;
|
|
15
|
-
export declare function attachSnapshot(runId: string, snapshotId: string): void;
|
|
16
|
-
export declare function finishRun(input: {
|
|
17
|
-
run: ClaimedRun;
|
|
18
|
-
candidate?: InsightCandidate;
|
|
19
|
-
valueScore?: number;
|
|
20
|
-
cooldownSeconds?: number;
|
|
21
|
-
rawOutput: string;
|
|
22
|
-
outcomeReason?: string;
|
|
23
|
-
modelRef?: string;
|
|
24
|
-
}, now?: Date): ProactiveInsight | null;
|
|
25
|
-
/** Stale evidence waits without spending model attempts; never retain work indefinitely. */
|
|
26
|
-
export declare function deferRunForSource(run: ClaimedRun, now?: Date): void;
|
|
27
|
-
export declare function failRun(run: ClaimedRun, error: unknown, retryable: boolean, now?: Date): void;
|
|
28
|
-
export declare function listInsights(limit?: number): ProactiveInsight[];
|