@xopcai/xopc 0.0.308 → 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/_locales/en/messages.json +8 -0
- package/dist/browser-ext/_locales/zh_CN/messages.json +8 -0
- package/dist/browser-ext/dist/assets/{sidepanel-BbSQr-6P.css → sidepanel-DD6GEMvc.css} +16 -0
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +537 -96
- 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-wgSB2HYK.js → activity-store-DVUTs1fk.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-dUotwUO6.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-VPDIGRSS.js → agents-BiD9STyv.js} +1 -1
- package/dist/gateway/static/root/assets/{api-BKHmTb0w.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-zPz0rOND.js → app-management-settings-panel-C94LAxyt.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DhvhR43G.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-BQVZMreT.js → archive-plugin-SwWFt5MT.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CPE-TMPf.js → attachment-load-DdTFml9l.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-C4IAy_zF.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-DgTl7diZ.js → binary-plugins-47UTtDNq.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CcOVA-Gw.js → block-editor-DvzZkMG8.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BzkJog8e.js → browser-automation-inputs-C611KRBx.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page--zKAgj1k.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-BfLd2rIJ.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-BlC1OXX4.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-CF_zYzxX.js → dependency-picker-DCyyFLKp.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CDwtLR7Z.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-CX5OXxEU.js → extension-debug-page-DA8WJ3-E.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BytR1PaY.js → extension-page-C2BIB88m.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CkaMJA5F.js → extension-settings-page-kpYo979N.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-B6wHa6ZI.js → gateway-config-swr-DUDX42qY.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-B53R0CA4.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-DRzGnEV-.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-Ck_pyDom.js → image-generation-api-D2YorS--.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-DrtbjL8O.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-BlZh41Xq.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-DbP7wWuh.js → local-apps-page-DOZZBdqj.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-msTfRK8P.js → locale-store-DA0Z5jM_.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-C0n66FiO.js → logs-page-M8kz26yo.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-i6GhxpGV.js → management-settings-JLqHYQvY.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BInabSKf.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-CnWChQ3Y.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-BWitjb3e.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-gmi5LLwM.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-BSWtko7U.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-CtOjKGWg.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-DkyyDcl2.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-C0JDGN_V.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-Bt1K657Y.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-vq5Ujm03.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-1SZ-HFHX.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-B2pZCcxY.js → voice-api-key-field-D3urfd-n.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-DgJML_uM.js → voice-config-api-DTyMdGOR.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-Bptv7bEY.js → work-discovery-overlay-JzM3Ylbs.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BijCrNc4.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/packages/gateway-contract/src/sessions.js +6 -1
- package/dist/src/agent/agent-manager.d.ts +2 -6
- package/dist/src/agent/agent-manager.js +31 -5
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/child-agent-factory.d.ts +1 -0
- package/dist/src/agent/child-agent-factory.js +18 -4
- package/dist/src/agent/coding/repository-instructions.d.ts +4 -0
- package/dist/src/agent/coding/repository-instructions.js +46 -2
- package/dist/src/agent/commands/command-registry.js +1 -1
- package/dist/src/agent/context/execution-scope.js +1 -1
- package/dist/src/agent/data-acquisition/git.d.ts +17 -0
- package/dist/src/agent/data-acquisition/git.js +100 -0
- package/dist/src/agent/data-acquisition/render.d.ts +7 -0
- package/dist/src/agent/data-acquisition/render.js +79 -0
- package/dist/src/agent/data-acquisition/scheduler.d.ts +12 -0
- package/dist/src/agent/data-acquisition/scheduler.js +53 -0
- package/dist/src/agent/data-acquisition/schema.d.ts +75 -0
- package/dist/src/agent/data-acquisition/schema.js +206 -0
- package/dist/src/agent/data-acquisition/service.d.ts +10 -0
- package/dist/src/agent/data-acquisition/service.js +292 -0
- package/dist/src/agent/data-acquisition/types.d.ts +37 -0
- package/dist/src/agent/data-acquisition/types.js +5 -0
- package/dist/src/agent/embedded/run-turn.js +16 -4
- package/dist/src/agent/embedded/session-runner.d.ts +1 -0
- package/dist/src/agent/embedded/session-runner.js +3 -0
- package/dist/src/agent/embedded/tool-result-truncation.js +11 -0
- package/dist/src/agent/embedded/xopc-tools-bridge.js +2 -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 +15 -4
- package/dist/src/agent/external-tools/gateway-tools.js +10 -3
- package/dist/src/agent/external-tools/index.js +14 -1
- package/dist/src/agent/external-tools/read-policy.d.ts +6 -0
- package/dist/src/agent/external-tools/read-policy.js +21 -0
- package/dist/src/agent/external-tools/service.d.ts +1 -0
- package/dist/src/agent/external-tools/service.js +4 -1
- package/dist/src/agent/external-tools/types.d.ts +3 -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/orchestration/agent-turn-policy.js +25 -10
- package/dist/src/agent/orchestration/delegation-scope.d.ts +9 -0
- package/dist/src/agent/orchestration/delegation-scope.js +11 -0
- package/dist/src/agent/prompt/sections/tooling.js +3 -1
- package/dist/src/agent/prompt/subagent-context.js +4 -2
- package/dist/src/agent/sandbox/fileAccess.d.ts +2 -0
- package/dist/src/agent/sandbox/fileAccess.js +31 -2
- 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/dataBatch.d.ts +4 -0
- package/dist/src/agent/tools/dataBatch.js +50 -0
- package/dist/src/agent/tools/delegate-tool.d.ts +6 -3
- package/dist/src/agent/tools/delegate-tool.js +65 -48
- package/dist/src/agent/tools/delegation-parent-policy.d.ts +7 -0
- package/dist/src/agent/tools/delegation-parent-policy.js +41 -0
- package/dist/src/agent/tools/delegation-policy.d.ts +16 -0
- package/dist/src/agent/tools/delegation-policy.js +93 -0
- package/dist/src/agent/tools/factory.d.ts +4 -0
- package/dist/src/agent/tools/factory.js +45 -5
- package/dist/src/agent/tools/fetch-text.d.ts +7 -0
- package/dist/src/agent/tools/fetch-text.js +86 -0
- package/dist/src/agent/tools/find.js +1 -1
- package/dist/src/agent/tools/grep.js +11 -23
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/knowledge-memory-tool.js +10 -2
- package/dist/src/agent/tools/read.js +7 -5
- package/dist/src/agent/tools/repository-search.d.ts +12 -2
- package/dist/src/agent/tools/repository-search.js +127 -74
- 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/web.js +19 -28
- 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/agent/workflow/subagent-runner.js +25 -3
- package/dist/src/agent/workflow/workflow-child-tools.js +13 -8
- package/dist/src/agent-config/schema.d.ts +7 -0
- package/dist/src/agent-config/schema.js +2 -0
- 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 +8 -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/agent-builtin-tools.d.ts +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 +2 -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/sessions.js +141 -13
- 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/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.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +4 -2
- package/dist/src/storage/sqlite/migrations/186_sidebar_layout.sql +16 -0
- 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/sidebar-layout-repository.d.ts +12 -0
- package/dist/src/storage/sqlite/sidebar-layout-repository.js +53 -0
- package/dist/src/storage/sqlite/sql-assets.d.ts +2 -0
- package/dist/src/storage/sqlite/sql-assets.js +18 -0
- package/dist/src/storage/sqlite/transaction.d.ts +2 -0
- package/dist/src/storage/sqlite/transaction.js +20 -1
- package/dist/src/tasks/home-query-service.d.ts +0 -2
- package/dist/src/tasks/home-query-service.js +13 -43
- package/dist/src/tasks/index.d.ts +0 -1
- package/dist/src/tasks/index.js +4 -5
- package/dist/src/tasks/project-operating-view-service.js +1 -4
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/user-model/goals.d.ts +10 -0
- package/dist/src/user-model/goals.js +29 -1
- package/dist/src/user-model/index.js +2 -2
- package/dist/src/voice/realtime/memory-context.js +2 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +5 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C6LflMXr.js +0 -1
- package/dist/gateway/static/root/assets/api-DFOlahZv.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-Pmslbzzr.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-Fx5VUJRu.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-DBms6d35.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-epdDWIZy.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-B0bsDtmP.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-B2JwuTjG.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-Ckgc0Py-.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-By33-bF1.js +0 -2
- package/dist/gateway/static/root/assets/cron-expression-CqNE-nf6.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-BS9ZjzYJ.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-C0djIc1J.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-CDKj9LQj.js +0 -1
- package/dist/gateway/static/root/assets/external-link-DjqjBmc3.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BLDgrJ30.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-_YU-1p0z.js +0 -1
- package/dist/gateway/static/root/assets/globe-DSSGFWFn.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-CVIvvm4x.js +0 -1
- package/dist/gateway/static/root/assets/home-page-COCHelcL.js +0 -1
- package/dist/gateway/static/root/assets/index-CDfcPiPb.js +0 -79
- package/dist/gateway/static/root/assets/index-CRu1p38D.css +0 -1
- package/dist/gateway/static/root/assets/loader-circle-CifKLtgG.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-D7_Raxjw.js +0 -2
- package/dist/gateway/static/root/assets/markdown-view-Y68dCxuc.css +0 -1
- package/dist/gateway/static/root/assets/messages-F74LVAiU.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-C59d8vDW.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-C1GBPrVI.js +0 -8
- package/dist/gateway/static/root/assets/preview-open-alternatives-UaCWCxZv.js +0 -1
- package/dist/gateway/static/root/assets/proactive-page-CtSFJxoM.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-ILTmQ1YN.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-snl4rOQZ.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BbaAcEN3.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DrWL71O8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BG0kl4HT.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-DiIyMQ52.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-EPazhoZO.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-g2MdRXSZ.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B1DPzu98.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-Wd0uYSPG.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-Cz1P-HDH.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BG3A5gPZ.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-DQGoFuZO.js +0 -1
- package/dist/gateway/static/root/assets/use-autosave-DVDlBb95.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-qM5UiTGx.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-DRy1RAYH.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,195 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { ProactiveConflict, effectiveProactivePolicy } from "./policy/service.js";
|
|
3
|
-
import { controlledSubscriptions, createControlledSubscription, requireSubscription, updateControlledSubscription } from "./scenarios/control.js";
|
|
4
|
-
import { ProactiveScenarioService } from "./scenarios/service.js";
|
|
5
|
-
import { ProactiveEventService } from "./service.js";
|
|
6
|
-
import { listMailFollowUps } from "./follow-ups.js";
|
|
7
|
-
import { followUpCheckStatus } from "./status.js";
|
|
8
|
-
import { getCard } from "./inbox/cards.js";
|
|
9
|
-
import { scanDueProjects } from "./temporal/schedule.js";
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
//#region src/proactive/experience.ts
|
|
12
|
-
init_transaction();
|
|
13
|
-
const DelegateSchema = z.object({
|
|
14
|
-
scenarioKey: z.enum([
|
|
15
|
-
"project_delivery_risk",
|
|
16
|
-
"meeting_preparation",
|
|
17
|
-
"discussion_follow_up"
|
|
18
|
-
]),
|
|
19
|
-
projectId: z.string().min(1).optional(),
|
|
20
|
-
instructions: z.string().trim().min(1).max(12e3)
|
|
21
|
-
}).strict();
|
|
22
|
-
function startDelegation(workspace, value) {
|
|
23
|
-
const input = DelegateSchema.parse(value);
|
|
24
|
-
if (input.scenarioKey === "project_delivery_risk" && !input.projectId) throw new Error("Choose a project");
|
|
25
|
-
if (input.scenarioKey !== "project_delivery_risk" && input.projectId) throw new Error("This service uses workspace sources");
|
|
26
|
-
const subscription = createControlledSubscription(workspace, {
|
|
27
|
-
scenarioKey: input.scenarioKey,
|
|
28
|
-
scopeKind: input.projectId ? "project" : "workspace",
|
|
29
|
-
scopeId: input.projectId ?? workspace,
|
|
30
|
-
userInstructions: input.instructions
|
|
31
|
-
});
|
|
32
|
-
if (input.projectId && effectiveProactivePolicy(subscription.id).enabled) checkDelegation(workspace, subscription.id);
|
|
33
|
-
return subscription;
|
|
34
|
-
}
|
|
35
|
-
/** Queue work in the existing worker; HTTP and conversation requests do not own model runs. */
|
|
36
|
-
function checkDelegation(workspace, id) {
|
|
37
|
-
const sub = requireSubscription(id, workspace);
|
|
38
|
-
if (!effectiveProactivePolicy(id).enabled) throw new Error("Resume this service before checking");
|
|
39
|
-
if (sub.scopeKind !== "project") throw new Error("This service checks when connected sources change");
|
|
40
|
-
return runSqliteWriteTransaction((db) => {
|
|
41
|
-
const retry = db.prepare("SELECT run_id FROM proactive_runs WHERE subscription_id = ? AND status = 'retryable' ORDER BY started_at DESC LIMIT 1").get(id);
|
|
42
|
-
if (retry) {
|
|
43
|
-
db.prepare("UPDATE proactive_runs SET next_attempt_at = ? WHERE run_id = ? AND status = 'retryable'").run((/* @__PURE__ */ new Date()).toISOString(), retry.run_id);
|
|
44
|
-
return { status: "queued" };
|
|
45
|
-
}
|
|
46
|
-
if (db.prepare("SELECT 1 FROM proactive_signal_batches WHERE subscription_id = ? AND status IN ('collecting', 'ready', 'processing')").get(id)) return { status: "queued" };
|
|
47
|
-
const last = db.prepare("SELECT MAX(started_at) AS at FROM proactive_runs WHERE subscription_id = ?").get(id);
|
|
48
|
-
if (last.at && Date.parse(last.at) > Date.now() - 6e4) throw new ProactiveConflict("A check just finished; try again in a minute");
|
|
49
|
-
db.prepare(`INSERT INTO proactive_schedule_state(subscription_id, next_due_at) VALUES (?, ?)
|
|
50
|
-
ON CONFLICT(subscription_id) DO UPDATE SET next_due_at = excluded.next_due_at, last_fingerprint = NULL`).run(id, (/* @__PURE__ */ new Date()).toISOString());
|
|
51
|
-
scanDueProjects(new ProactiveEventService(() => new ProactiveScenarioService().routes()));
|
|
52
|
-
db.prepare("UPDATE proactive_signal_batches SET ready_at = ?, status = 'ready' WHERE subscription_id = ? AND status = 'collecting'").run((/* @__PURE__ */ new Date()).toISOString(), id);
|
|
53
|
-
return { status: "queued" };
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function delegationOverview(workspace) {
|
|
57
|
-
const db = getSqliteDatabase();
|
|
58
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
59
|
-
const cards = db.prepare(`SELECT i.inbox_item_id FROM proactive_inbox_items i
|
|
60
|
-
JOIN proactive_insights x USING(insight_id) JOIN proactive_scenario_subscriptions s USING(subscription_id)
|
|
61
|
-
WHERE s.workspace_id = ? AND i.withdrawn_at IS NULL AND i.status IN ('unread', 'read')
|
|
62
|
-
AND (i.expires_at IS NULL OR i.expires_at > ?)
|
|
63
|
-
ORDER BY CASE WHEN x.action_status = 'approval_required' THEN 0 WHEN x.artifact_json IS NOT NULL THEN 1 ELSE 2 END,
|
|
64
|
-
x.value_score DESC, i.updated_at DESC LIMIT 100`).all(workspace, now).map((row) => getCard(row.inbox_item_id, workspace)).filter((card) => !["withdrawn", "expired"].includes(card.status));
|
|
65
|
-
const followUps = listMailFollowUps(workspace);
|
|
66
|
-
const delegations = controlledSubscriptions(workspace).map((sub) => ({
|
|
67
|
-
id: sub.id,
|
|
68
|
-
scenarioKey: sub.scenarioKey,
|
|
69
|
-
scopeKind: sub.scopeKind,
|
|
70
|
-
scopeId: sub.scopeId,
|
|
71
|
-
enabled: sub.enabled,
|
|
72
|
-
revision: sub.revision,
|
|
73
|
-
delivery: sub.delivery,
|
|
74
|
-
scanIntervalMinutes: sub.scanIntervalMinutes ?? 120,
|
|
75
|
-
checkStatus: followUpCheckStatus(sub.id, sub.scopeKind === "project"),
|
|
76
|
-
completedAt: sub.completedAt,
|
|
77
|
-
userInstructions: sub.userInstructions,
|
|
78
|
-
updatedAt: sub.updatedAt,
|
|
79
|
-
effectiveEnabled: effectiveProactivePolicy(sub.id).enabled,
|
|
80
|
-
project: sub.scopeKind === "project" ? db.prepare("SELECT name, status FROM projects WHERE project_id = ?").get(sub.scopeId) ?? null : null,
|
|
81
|
-
projectMonitoring: sub.scopeKind === "project" ? projectMonitoring(sub.scopeId) : null,
|
|
82
|
-
checking: Boolean(db.prepare("SELECT 1 FROM proactive_signal_batches WHERE subscription_id = ? AND status IN ('collecting', 'ready', 'processing')").get(sub.id))
|
|
83
|
-
}));
|
|
84
|
-
return {
|
|
85
|
-
scenes: projectSceneMoments(cards, delegations, followUps),
|
|
86
|
-
followUps,
|
|
87
|
-
delegations
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function projectMonitoring(projectId) {
|
|
91
|
-
const row = getSqliteDatabase().prepare("SELECT mode, allowed_actions_json FROM project_monitoring_policies WHERE project_id = ?").get(projectId);
|
|
92
|
-
return row ? {
|
|
93
|
-
mode: row.mode,
|
|
94
|
-
allowedActions: JSON.parse(row.allowed_actions_json)
|
|
95
|
-
} : {
|
|
96
|
-
mode: "observe",
|
|
97
|
-
allowedActions: []
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function projectSceneMoments(cards, delegations, followUps) {
|
|
101
|
-
const latestCardBySubscription = /* @__PURE__ */ new Map();
|
|
102
|
-
for (const card of cards) {
|
|
103
|
-
const previous = latestCardBySubscription.get(card.subscriptionId);
|
|
104
|
-
if (!previous || previous.updatedAt < card.updatedAt) latestCardBySubscription.set(card.subscriptionId, card);
|
|
105
|
-
}
|
|
106
|
-
const moments = [];
|
|
107
|
-
for (const sub of delegations) {
|
|
108
|
-
if (!sub.effectiveEnabled || sub.completedAt || ![
|
|
109
|
-
"project_delivery_risk",
|
|
110
|
-
"meeting_preparation",
|
|
111
|
-
"discussion_follow_up"
|
|
112
|
-
].includes(sub.scenarioKey)) continue;
|
|
113
|
-
const card = latestCardBySubscription.get(sub.id) ?? null;
|
|
114
|
-
const project = sub.project;
|
|
115
|
-
const kind = sub.scenarioKey === "meeting_preparation" ? "meeting_preparation" : sub.scenarioKey === "discussion_follow_up" ? "communication_follow_up" : "project_momentum";
|
|
116
|
-
const object = project ? {
|
|
117
|
-
label: project.name,
|
|
118
|
-
route: `/projects/${encodeURIComponent(sub.scopeId)}`
|
|
119
|
-
} : card?.evidence.find((item) => item.route) ? (() => {
|
|
120
|
-
const item = card.evidence.find((value) => value.route);
|
|
121
|
-
return {
|
|
122
|
-
label: item.label,
|
|
123
|
-
route: item.route
|
|
124
|
-
};
|
|
125
|
-
})() : null;
|
|
126
|
-
moments.push({
|
|
127
|
-
id: `scene:${sub.id}`,
|
|
128
|
-
kind,
|
|
129
|
-
status: sceneStatus(card),
|
|
130
|
-
title: project?.name ?? card?.title ?? (kind === "meeting_preparation" ? "Meeting preparation" : kind === "communication_follow_up" ? "Conversation follow-up" : "Project follow-through"),
|
|
131
|
-
promise: sub.userInstructions,
|
|
132
|
-
moment: card?.whyNow ?? (kind === "meeting_preparation" ? "Waiting for the next relevant meeting" : kind === "communication_follow_up" ? "Watching for a meaningful follow-up" : "Watching the project for a meaningful change"),
|
|
133
|
-
relevance: card?.summary ?? sub.userInstructions,
|
|
134
|
-
help: card?.workDone || card?.recommendation || (kind === "meeting_preparation" ? "I will bring back a brief before the meeting." : kind === "communication_follow_up" ? "I will return when the discussion needs a next step." : "I will return when the goal, commitment, or delivery risk changes."),
|
|
135
|
-
arrangementId: sub.id,
|
|
136
|
-
manageRoute: `/assistant-work?delegation=${encodeURIComponent(sub.id)}`,
|
|
137
|
-
object,
|
|
138
|
-
card,
|
|
139
|
-
updatedAt: card?.updatedAt ?? sub.updatedAt
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
for (const follow of followUps) {
|
|
143
|
-
if (!follow.enabled || follow.status !== "watching") continue;
|
|
144
|
-
const card = cards.find((item) => item.communication?.id === follow.id) ?? null;
|
|
145
|
-
moments.push({
|
|
146
|
-
id: `scene:${follow.id}`,
|
|
147
|
-
kind: "communication_follow_up",
|
|
148
|
-
status: sceneStatus(card),
|
|
149
|
-
title: follow.subject ?? "Communication follow-up",
|
|
150
|
-
promise: follow.instructions,
|
|
151
|
-
moment: card?.whyNow ?? (follow.latestDirection === "received" ? "A reply arrived" : `Waiting until ${follow.dueAt}`),
|
|
152
|
-
relevance: card?.summary ?? follow.instructions,
|
|
153
|
-
help: card?.workDone || card?.recommendation || "I will watch the thread and prepare the next step when it matters.",
|
|
154
|
-
arrangementId: follow.subscriptionId,
|
|
155
|
-
manageRoute: `/assistant-work?follow-up=${encodeURIComponent(follow.id)}`,
|
|
156
|
-
object: follow.conversationId ? {
|
|
157
|
-
label: follow.subject ?? "Open conversation",
|
|
158
|
-
route: `/chat/${encodeURIComponent(follow.conversationId)}`
|
|
159
|
-
} : null,
|
|
160
|
-
card,
|
|
161
|
-
updatedAt: card?.updatedAt ?? follow.lastCheckedAt ?? follow.dueAt
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
const priority = {
|
|
165
|
-
needs_decision: 0,
|
|
166
|
-
prepared: 1,
|
|
167
|
-
changed: 2,
|
|
168
|
-
following: 3
|
|
169
|
-
};
|
|
170
|
-
return moments.sort((a, b) => priority[a.status] - priority[b.status] || b.updatedAt.localeCompare(a.updatedAt));
|
|
171
|
-
}
|
|
172
|
-
function sceneStatus(card) {
|
|
173
|
-
if (!card) return "following";
|
|
174
|
-
if (card.decision && card.actionStatus !== "completed") return "needs_decision";
|
|
175
|
-
if (card.artifact) return "prepared";
|
|
176
|
-
return "changed";
|
|
177
|
-
}
|
|
178
|
-
function completeDeliveredProjects(now = /* @__PURE__ */ new Date()) {
|
|
179
|
-
const db = getSqliteDatabase();
|
|
180
|
-
const rows = db.prepare(`SELECT s.subscription_id, s.workspace_id FROM proactive_scenario_subscriptions s
|
|
181
|
-
JOIN projects p ON p.project_id = s.scope_id WHERE s.scope_kind = 'project' AND s.enabled = 1
|
|
182
|
-
AND p.status IN ('completed', 'cancelled', 'archived')`).all();
|
|
183
|
-
for (const row of rows) {
|
|
184
|
-
const current = controlledSubscriptions(row.workspace_id).find((sub) => sub.id === row.subscription_id);
|
|
185
|
-
updateControlledSubscription(row.workspace_id, row.subscription_id, {
|
|
186
|
-
expectedRevision: current.revision,
|
|
187
|
-
enabled: false,
|
|
188
|
-
completedAt: now.toISOString()
|
|
189
|
-
});
|
|
190
|
-
db.prepare(`UPDATE proactive_inbox_items SET status = 'resolved', resolution = 'project_ended', updated_at = ?
|
|
191
|
-
WHERE insight_id IN (SELECT insight_id FROM proactive_insights WHERE subscription_id = ?) AND status <> 'resolved'`).run(now.toISOString(), row.subscription_id);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
//#endregion
|
|
195
|
-
export { checkDelegation, completeDeliveredProjects, delegationOverview, startDelegation };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { ProactiveEventService } from './service.js';
|
|
2
|
-
export declare const COMMUNICATION_SCENARIO = "communication_follow_up";
|
|
3
|
-
export type MailFollowUp = {
|
|
4
|
-
id: string;
|
|
5
|
-
subscription_id: string;
|
|
6
|
-
workspace_id: string;
|
|
7
|
-
source_item_id: string;
|
|
8
|
-
instructions: string;
|
|
9
|
-
due_at: string;
|
|
10
|
-
status: 'watching' | 'paused' | 'completed';
|
|
11
|
-
revision: number;
|
|
12
|
-
last_fingerprint: string | null;
|
|
13
|
-
last_checked_at: string | null;
|
|
14
|
-
conversation_id: string | null;
|
|
15
|
-
};
|
|
16
|
-
export declare function requireMailFollowUp(workspace: string, id: string): MailFollowUp;
|
|
17
|
-
export declare function authorizedMailThread(follow: MailFollowUp): {
|
|
18
|
-
origin: import("../knowledge/types.js").KnowledgeSourceItem;
|
|
19
|
-
items: import("../knowledge/types.js").KnowledgeSourceItem[];
|
|
20
|
-
threadKey: string;
|
|
21
|
-
fingerprint: string;
|
|
22
|
-
};
|
|
23
|
-
export declare function mailFollowUpView(follow: MailFollowUp): {
|
|
24
|
-
id: string;
|
|
25
|
-
subscriptionId: string;
|
|
26
|
-
instructions: string;
|
|
27
|
-
dueAt: string;
|
|
28
|
-
status: "completed" | "paused" | "watching";
|
|
29
|
-
revision: number;
|
|
30
|
-
lastCheckedAt: string;
|
|
31
|
-
conversationId: string;
|
|
32
|
-
sourceAvailable: boolean;
|
|
33
|
-
enabled: boolean;
|
|
34
|
-
subject: string;
|
|
35
|
-
latestMessageAt: string;
|
|
36
|
-
latestDirection: string;
|
|
37
|
-
lastSyncedAt: string;
|
|
38
|
-
syncFailed: boolean;
|
|
39
|
-
sourceFresh: boolean;
|
|
40
|
-
};
|
|
41
|
-
export declare function listMailFollowUps(workspace: string): {
|
|
42
|
-
id: string;
|
|
43
|
-
subscriptionId: string;
|
|
44
|
-
instructions: string;
|
|
45
|
-
dueAt: string;
|
|
46
|
-
status: "completed" | "paused" | "watching";
|
|
47
|
-
revision: number;
|
|
48
|
-
lastCheckedAt: string;
|
|
49
|
-
conversationId: string;
|
|
50
|
-
sourceAvailable: boolean;
|
|
51
|
-
enabled: boolean;
|
|
52
|
-
subject: string;
|
|
53
|
-
latestMessageAt: string;
|
|
54
|
-
latestDirection: string;
|
|
55
|
-
lastSyncedAt: string;
|
|
56
|
-
syncFailed: boolean;
|
|
57
|
-
sourceFresh: boolean;
|
|
58
|
-
}[];
|
|
59
|
-
export declare function mailFollowUpSources(workspace: string): {
|
|
60
|
-
id: string;
|
|
61
|
-
subject: string;
|
|
62
|
-
sender: string;
|
|
63
|
-
occurredAt: string;
|
|
64
|
-
accountLabel: string;
|
|
65
|
-
}[];
|
|
66
|
-
export declare function startMailFollowUp(workspace: string, value: unknown): {
|
|
67
|
-
id: string;
|
|
68
|
-
subscriptionId: string;
|
|
69
|
-
instructions: string;
|
|
70
|
-
dueAt: string;
|
|
71
|
-
status: "completed" | "paused" | "watching";
|
|
72
|
-
revision: number;
|
|
73
|
-
lastCheckedAt: string;
|
|
74
|
-
conversationId: string;
|
|
75
|
-
sourceAvailable: boolean;
|
|
76
|
-
enabled: boolean;
|
|
77
|
-
subject: string;
|
|
78
|
-
latestMessageAt: string;
|
|
79
|
-
latestDirection: string;
|
|
80
|
-
lastSyncedAt: string;
|
|
81
|
-
syncFailed: boolean;
|
|
82
|
-
sourceFresh: boolean;
|
|
83
|
-
};
|
|
84
|
-
export declare function updateMailFollowUp(workspace: string, id: string, value: unknown): {
|
|
85
|
-
id: string;
|
|
86
|
-
subscriptionId: string;
|
|
87
|
-
instructions: string;
|
|
88
|
-
dueAt: string;
|
|
89
|
-
status: "completed" | "paused" | "watching";
|
|
90
|
-
revision: number;
|
|
91
|
-
lastCheckedAt: string;
|
|
92
|
-
conversationId: string;
|
|
93
|
-
sourceAvailable: boolean;
|
|
94
|
-
enabled: boolean;
|
|
95
|
-
subject: string;
|
|
96
|
-
latestMessageAt: string;
|
|
97
|
-
latestDirection: string;
|
|
98
|
-
lastSyncedAt: string;
|
|
99
|
-
syncFailed: boolean;
|
|
100
|
-
sourceFresh: boolean;
|
|
101
|
-
};
|
|
102
|
-
/** Keep the existing chat and its exact connector confirmation flow as the write boundary. */
|
|
103
|
-
export declare function continueMailFollowUp(workspace: string, id: string, conversationId: string): {
|
|
104
|
-
followUp: {
|
|
105
|
-
id: string;
|
|
106
|
-
subscriptionId: string;
|
|
107
|
-
instructions: string;
|
|
108
|
-
dueAt: string;
|
|
109
|
-
status: "completed" | "paused" | "watching";
|
|
110
|
-
revision: number;
|
|
111
|
-
lastCheckedAt: string;
|
|
112
|
-
conversationId: string;
|
|
113
|
-
sourceAvailable: boolean;
|
|
114
|
-
enabled: boolean;
|
|
115
|
-
subject: string;
|
|
116
|
-
latestMessageAt: string;
|
|
117
|
-
latestDirection: string;
|
|
118
|
-
lastSyncedAt: string;
|
|
119
|
-
syncFailed: boolean;
|
|
120
|
-
sourceFresh: boolean;
|
|
121
|
-
};
|
|
122
|
-
connectionId: unknown;
|
|
123
|
-
sourceItemId: string;
|
|
124
|
-
threadId: string;
|
|
125
|
-
instruction: string;
|
|
126
|
-
};
|
|
127
|
-
/** Poll only delegated threads; unchanged threads and passed deadlines produce no repeat signals. */
|
|
128
|
-
export declare function scanMailFollowUps(events: ProactiveEventService, now?: Date): number;
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { getConnectorConnection, init_connector_repository } from "../storage/sqlite/connector-repository.js";
|
|
3
|
-
import { listKnowledgeSourceItems } from "../storage/sqlite/knowledge-repository.js";
|
|
4
|
-
import { sourceFreshness } from "./source-freshness.js";
|
|
5
|
-
import { emailFields, readMailThread } from "./mail-thread.js";
|
|
6
|
-
import { authorizedConnectedSource } from "./execution/authorization.js";
|
|
7
|
-
import { ProactiveConflict, effectiveProactivePolicy } from "./policy/service.js";
|
|
8
|
-
import { listSubscriptions } from "./scenarios/repository.js";
|
|
9
|
-
import { createControlledSubscription } from "./scenarios/control.js";
|
|
10
|
-
import { ProactiveScenarioService } from "./scenarios/service.js";
|
|
11
|
-
import { ProactiveEventService } from "./service.js";
|
|
12
|
-
import { randomUUID } from "node:crypto";
|
|
13
|
-
import { z } from "zod";
|
|
14
|
-
//#region src/proactive/follow-ups.ts
|
|
15
|
-
init_connector_repository();
|
|
16
|
-
init_transaction();
|
|
17
|
-
const COMMUNICATION_SCENARIO = "communication_follow_up";
|
|
18
|
-
const CreateSchema = z.object({
|
|
19
|
-
sourceItemId: z.string().min(1),
|
|
20
|
-
instructions: z.string().trim().min(1).max(12e3),
|
|
21
|
-
dueAt: z.string().datetime()
|
|
22
|
-
}).strict();
|
|
23
|
-
const UpdateSchema = z.object({
|
|
24
|
-
expectedRevision: z.number().int().positive(),
|
|
25
|
-
instructions: z.string().trim().min(1).max(12e3).optional(),
|
|
26
|
-
dueAt: z.string().datetime().optional(),
|
|
27
|
-
status: z.enum([
|
|
28
|
-
"watching",
|
|
29
|
-
"paused",
|
|
30
|
-
"completed"
|
|
31
|
-
]).optional()
|
|
32
|
-
}).strict();
|
|
33
|
-
function requireMailFollowUp(workspace, id) {
|
|
34
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM proactive_follow_ups WHERE id = ? AND workspace_id = ?").get(id, workspace);
|
|
35
|
-
if (!row) throw new Error("Follow-up not found");
|
|
36
|
-
return row;
|
|
37
|
-
}
|
|
38
|
-
function authorizedMailThread(follow) {
|
|
39
|
-
if (!authorizedConnectedSource(follow.source_item_id, follow.workspace_id, "communication_follow_up")) return null;
|
|
40
|
-
const thread = readMailThread(follow.source_item_id);
|
|
41
|
-
if (!thread || thread.items.some((item) => !authorizedConnectedSource(item.id, follow.workspace_id, "communication_follow_up") || item.metadata.connectionId !== thread.origin.metadata.connectionId)) return null;
|
|
42
|
-
return thread;
|
|
43
|
-
}
|
|
44
|
-
function mailFollowUpView(follow) {
|
|
45
|
-
const thread = authorizedMailThread(follow);
|
|
46
|
-
const latest = thread?.items.at(-1);
|
|
47
|
-
const sync = sourceFreshness(follow.source_item_id, Date.parse(follow.due_at) <= Date.now() ? follow.due_at : void 0);
|
|
48
|
-
return {
|
|
49
|
-
id: follow.id,
|
|
50
|
-
subscriptionId: follow.subscription_id,
|
|
51
|
-
instructions: follow.instructions,
|
|
52
|
-
dueAt: follow.due_at,
|
|
53
|
-
status: follow.status,
|
|
54
|
-
revision: follow.revision,
|
|
55
|
-
lastCheckedAt: follow.last_checked_at,
|
|
56
|
-
conversationId: follow.conversation_id,
|
|
57
|
-
sourceAvailable: Boolean(thread),
|
|
58
|
-
enabled: follow.status === "watching" && effectiveProactivePolicy(follow.subscription_id).enabled,
|
|
59
|
-
subject: thread ? emailFields(thread.origin.normalizedText).subject ?? "Email follow-up" : null,
|
|
60
|
-
latestMessageAt: latest?.occurredAt ?? null,
|
|
61
|
-
latestDirection: latest ? emailFields(latest.normalizedText).labels?.includes("SENT") ? "sent" : emailFields(latest.normalizedText).labels?.includes("INBOX") ? "received" : "unknown" : null,
|
|
62
|
-
lastSyncedAt: sync.lastSyncedAt,
|
|
63
|
-
syncFailed: sync.syncFailed,
|
|
64
|
-
sourceFresh: sync.fresh
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function listMailFollowUps(workspace) {
|
|
68
|
-
return getSqliteDatabase().prepare("SELECT * FROM proactive_follow_ups WHERE workspace_id = ? ORDER BY updated_at DESC").all(workspace).map(mailFollowUpView);
|
|
69
|
-
}
|
|
70
|
-
function mailFollowUpSources(workspace) {
|
|
71
|
-
const seen = /* @__PURE__ */ new Set();
|
|
72
|
-
return listKnowledgeSourceItems({
|
|
73
|
-
itemType: "email",
|
|
74
|
-
limit: 500
|
|
75
|
-
}).flatMap((item) => {
|
|
76
|
-
if (!authorizedConnectedSource(item.id, workspace, "communication_follow_up")) return [];
|
|
77
|
-
const thread = readMailThread(item.id);
|
|
78
|
-
if (!thread || seen.has(thread.threadKey)) return [];
|
|
79
|
-
seen.add(thread.threadKey);
|
|
80
|
-
const fields = emailFields(item.normalizedText);
|
|
81
|
-
const connection = getConnectorConnection(String(item.metadata.connectionId));
|
|
82
|
-
const account = connection?.alias ?? connection?.identity.email ?? connection?.identity.name;
|
|
83
|
-
return [{
|
|
84
|
-
id: item.id,
|
|
85
|
-
subject: fields.subject ?? "Email",
|
|
86
|
-
sender: fields.sender ?? "",
|
|
87
|
-
occurredAt: item.occurredAt,
|
|
88
|
-
accountLabel: typeof account === "string" ? account : "Connected email account"
|
|
89
|
-
}];
|
|
90
|
-
}).slice(0, 100);
|
|
91
|
-
}
|
|
92
|
-
function startMailFollowUp(workspace, value) {
|
|
93
|
-
const input = CreateSchema.parse(value);
|
|
94
|
-
if (Date.parse(input.dueAt) <= Date.now()) throw new Error("Choose a future follow-up time");
|
|
95
|
-
if (!authorizedConnectedSource(input.sourceItemId, workspace, "communication_follow_up")) throw new Error("Authorize this email account for proactive follow-up first");
|
|
96
|
-
const thread = readMailThread(input.sourceItemId);
|
|
97
|
-
if (!thread) throw new Error("This email has no available thread");
|
|
98
|
-
return runSqliteWriteTransaction((db) => {
|
|
99
|
-
if (db.prepare("SELECT 1 FROM proactive_follow_ups WHERE workspace_id = ? AND thread_key = ?").get(workspace, thread.threadKey)) throw new ProactiveConflict("This conversation is already delegated; update the existing follow-up");
|
|
100
|
-
const sub = listSubscriptions("communication_follow_up").find((item) => item.workspaceId === workspace) ?? createControlledSubscription(workspace, {
|
|
101
|
-
scenarioKey: "communication_follow_up",
|
|
102
|
-
scopeKind: "workspace",
|
|
103
|
-
scopeId: workspace
|
|
104
|
-
});
|
|
105
|
-
const id = randomUUID();
|
|
106
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
107
|
-
db.prepare(`INSERT INTO proactive_follow_ups(id, subscription_id, workspace_id, source_item_id, thread_key, instructions, due_at, created_at, updated_at)
|
|
108
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, sub.id, workspace, input.sourceItemId, thread.threadKey, input.instructions, input.dueAt, now, now);
|
|
109
|
-
scanMailFollowUps(new ProactiveEventService(() => new ProactiveScenarioService().routes()));
|
|
110
|
-
return mailFollowUpView(requireMailFollowUp(workspace, id));
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
function updateMailFollowUp(workspace, id, value) {
|
|
114
|
-
const input = UpdateSchema.parse(value);
|
|
115
|
-
return runSqliteWriteTransaction((db) => {
|
|
116
|
-
const row = requireMailFollowUp(workspace, id);
|
|
117
|
-
if (row.revision !== input.expectedRevision) throw new ProactiveConflict("Follow-up changed; refresh before editing");
|
|
118
|
-
if (input.dueAt && Date.parse(input.dueAt) <= Date.now()) throw new Error("Choose a future follow-up time");
|
|
119
|
-
db.prepare(`UPDATE proactive_follow_ups SET instructions = ?, due_at = ?, status = ?, revision = revision + 1,
|
|
120
|
-
last_fingerprint = NULL, updated_at = ? WHERE id = ?`).run(input.instructions ?? row.instructions, input.dueAt ?? row.due_at, input.status ?? row.status, (/* @__PURE__ */ new Date()).toISOString(), id);
|
|
121
|
-
scanMailFollowUps(new ProactiveEventService(() => new ProactiveScenarioService().routes()));
|
|
122
|
-
return mailFollowUpView(requireMailFollowUp(workspace, id));
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/** Keep the existing chat and its exact connector confirmation flow as the write boundary. */
|
|
126
|
-
function continueMailFollowUp(workspace, id, conversationId) {
|
|
127
|
-
const follow = requireMailFollowUp(workspace, id);
|
|
128
|
-
const thread = authorizedMailThread(follow);
|
|
129
|
-
if (!thread || follow.status !== "watching" || !effectiveProactivePolicy(follow.subscription_id).enabled) throw new Error("Resume and authorize this follow-up before continuing");
|
|
130
|
-
getSqliteDatabase().prepare("UPDATE proactive_follow_ups SET conversation_id = ? WHERE id = ?").run(conversationId, id);
|
|
131
|
-
return {
|
|
132
|
-
followUp: mailFollowUpView(requireMailFollowUp(workspace, id)),
|
|
133
|
-
connectionId: thread.origin.metadata.connectionId,
|
|
134
|
-
sourceItemId: thread.origin.id,
|
|
135
|
-
threadId: emailFields(thread.origin.normalizedText).threadId,
|
|
136
|
-
instruction: "Read the current card and latest thread using this exact connection. Review the recipients and complete draft with the user before sending through the connector approval flow. Never infer successful delivery from a draft or approval. Use provider results, then continue watching synchronized replies."
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
/** Poll only delegated threads; unchanged threads and passed deadlines produce no repeat signals. */
|
|
140
|
-
function scanMailFollowUps(events, now = /* @__PURE__ */ new Date()) {
|
|
141
|
-
const db = getSqliteDatabase();
|
|
142
|
-
let published = 0;
|
|
143
|
-
for (const follow of db.prepare("SELECT * FROM proactive_follow_ups WHERE status = 'watching'").all()) {
|
|
144
|
-
const policy = effectiveProactivePolicy(follow.subscription_id, now);
|
|
145
|
-
if (!policy.enabled) continue;
|
|
146
|
-
const thread = authorizedMailThread(follow);
|
|
147
|
-
if (!thread) continue;
|
|
148
|
-
const freshness = sourceFreshness(follow.source_item_id, Date.parse(follow.due_at) <= now.getTime() ? follow.due_at : void 0, now.getTime());
|
|
149
|
-
if (!freshness.fresh) {
|
|
150
|
-
db.prepare("UPDATE proactive_follow_ups SET last_fingerprint = NULL WHERE id = ?").run(follow.id);
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
const fingerprint = `${follow.revision}:${thread.fingerprint}:${Date.parse(follow.due_at) <= now.getTime() ? "due" : "waiting"}`;
|
|
154
|
-
const awaitingSource = db.prepare(`SELECT 1 FROM proactive_runs r JOIN proactive_batch_events be USING(batch_id)
|
|
155
|
-
JOIN proactive_events e USING(event_id) WHERE r.subscription_id = ? AND r.status = 'retryable'
|
|
156
|
-
AND r.outcome_reason = 'source_stale' AND e.subject_kind = 'mail_follow_up' AND e.subject_id = ? LIMIT 1`).get(follow.subscription_id, follow.id);
|
|
157
|
-
if (fingerprint !== follow.last_fingerprint && !awaitingSource) {
|
|
158
|
-
if (events.publish({
|
|
159
|
-
type: "proactive.follow_up.v1",
|
|
160
|
-
schemaVersion: 1,
|
|
161
|
-
source: {
|
|
162
|
-
kind: "connector",
|
|
163
|
-
id: String(thread.origin.metadata.connectionId)
|
|
164
|
-
},
|
|
165
|
-
subject: {
|
|
166
|
-
kind: "mail_follow_up",
|
|
167
|
-
id: follow.id
|
|
168
|
-
},
|
|
169
|
-
actor: { kind: "system" },
|
|
170
|
-
scope: { workspaceId: follow.workspace_id },
|
|
171
|
-
occurredAt: now.toISOString(),
|
|
172
|
-
dedupeKey: `mail-follow-up:${follow.id}:${fingerprint}:${freshness.version}:${policy.preferences.revision}`,
|
|
173
|
-
sensitivity: "personal",
|
|
174
|
-
payload: { followUpId: follow.id }
|
|
175
|
-
}, now).inserted) published++;
|
|
176
|
-
}
|
|
177
|
-
db.prepare("UPDATE proactive_follow_ups SET last_fingerprint = ?, last_checked_at = ? WHERE id = ?").run(fingerprint, now.toISOString(), follow.id);
|
|
178
|
-
}
|
|
179
|
-
return published;
|
|
180
|
-
}
|
|
181
|
-
//#endregion
|
|
182
|
-
export { COMMUNICATION_SCENARIO, authorizedMailThread, continueMailFollowUp, listMailFollowUps, mailFollowUpSources, mailFollowUpView, requireMailFollowUp, scanMailFollowUps, startMailFollowUp, updateMailFollowUp };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ProactiveCard } from '@xopcai/gateway-contract';
|
|
2
|
-
export declare function requireCardScope(id: string, workspaceId: string): void;
|
|
3
|
-
export declare function getCard(id: string, workspaceId: string): ProactiveCard;
|
|
4
|
-
export declare function listCards(workspaceId: string, input?: {
|
|
5
|
-
status?: string;
|
|
6
|
-
before?: string;
|
|
7
|
-
limit?: number;
|
|
8
|
-
}): {
|
|
9
|
-
cards: ProactiveCard[];
|
|
10
|
-
nextCursor: string;
|
|
11
|
-
};
|
|
12
|
-
export declare function cardChanges(workspaceId: string, cursor?: number): {
|
|
13
|
-
items: {
|
|
14
|
-
id: string;
|
|
15
|
-
deleted: boolean;
|
|
16
|
-
card?: ProactiveCard;
|
|
17
|
-
}[];
|
|
18
|
-
nextCursor: number;
|
|
19
|
-
hasMore: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare function performCardAction(id: string, workspaceId: string, value: unknown): ProactiveCard;
|