@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,151 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../utils/logger/index.js";
|
|
2
|
-
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import { getConnectorAccount, init_connector_account_repository } from "../storage/sqlite/connector-account-repository.js";
|
|
4
|
-
import { init_connector_repository, listConnectorConnections } from "../storage/sqlite/connector-repository.js";
|
|
5
|
-
import { getKnowledgeConsumerWatermark, getKnowledgeSourceItem, listKnowledgeSourceChanges, setKnowledgeConsumerWatermark } from "../storage/sqlite/knowledge-repository.js";
|
|
6
|
-
import { getConnectorSyncPolicyForConnection } from "../storage/sqlite/connector-sync-policy-repository.js";
|
|
7
|
-
//#region src/connectors/source-change-publisher.ts
|
|
8
|
-
init_connector_account_repository();
|
|
9
|
-
init_connector_repository();
|
|
10
|
-
init_logger();
|
|
11
|
-
const log = createLogger("Connector:SourceChanges");
|
|
12
|
-
const CONSUMER_ID = "proactive-connected-source-v1";
|
|
13
|
-
function sensitivity(value) {
|
|
14
|
-
if (value === "regulated") return "restricted";
|
|
15
|
-
if (value === "secret") return "confidential";
|
|
16
|
-
return "personal";
|
|
17
|
-
}
|
|
18
|
-
function metadataString(metadata, key) {
|
|
19
|
-
const value = metadata[key];
|
|
20
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
21
|
-
}
|
|
22
|
-
var ConnectedSourceChangePublisher = class {
|
|
23
|
-
timer = null;
|
|
24
|
-
running = false;
|
|
25
|
-
constructor(eventService, intervalMs = 1e4) {
|
|
26
|
-
this.eventService = eventService;
|
|
27
|
-
this.intervalMs = intervalMs;
|
|
28
|
-
}
|
|
29
|
-
start() {
|
|
30
|
-
if (this.timer) return;
|
|
31
|
-
this.runNow();
|
|
32
|
-
this.timer = setInterval(() => void this.runNow(), Math.max(2e3, this.intervalMs));
|
|
33
|
-
this.timer.unref?.();
|
|
34
|
-
}
|
|
35
|
-
stop() {
|
|
36
|
-
if (this.timer) clearInterval(this.timer);
|
|
37
|
-
this.timer = null;
|
|
38
|
-
}
|
|
39
|
-
async runNow() {
|
|
40
|
-
if (this.running) return {
|
|
41
|
-
published: 0,
|
|
42
|
-
skipped: 0,
|
|
43
|
-
sources: 0
|
|
44
|
-
};
|
|
45
|
-
this.running = true;
|
|
46
|
-
const total = {
|
|
47
|
-
published: 0,
|
|
48
|
-
skipped: 0,
|
|
49
|
-
sources: 0
|
|
50
|
-
};
|
|
51
|
-
try {
|
|
52
|
-
const connections = listConnectorConnections({ principalId: "local-owner" }).filter((connection) => connection.status === "active" && connection.accountId && getConnectorAccount(connection.accountId)?.currentConnectionId === connection.id);
|
|
53
|
-
for (const connection of connections) {
|
|
54
|
-
const sourceInstanceId = `composio:${connection.connectorId}:${connection.accountId}`;
|
|
55
|
-
try {
|
|
56
|
-
const result = this.publishSource(sourceInstanceId, connection.id);
|
|
57
|
-
total.published += result.published;
|
|
58
|
-
total.skipped += result.skipped;
|
|
59
|
-
total.sources += 1;
|
|
60
|
-
} catch (err) {
|
|
61
|
-
const em = err instanceof Error ? err.message : String(err);
|
|
62
|
-
log.warn({
|
|
63
|
-
err,
|
|
64
|
-
connectionId: connection.id,
|
|
65
|
-
sourceInstanceId
|
|
66
|
-
}, `Connected source change publication failed: ${em}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return total;
|
|
70
|
-
} finally {
|
|
71
|
-
this.running = false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
publishSource(sourceInstanceId, connectionId) {
|
|
75
|
-
const policy = getConnectorSyncPolicyForConnection(connectionId);
|
|
76
|
-
let watermark = getKnowledgeConsumerWatermark(CONSUMER_ID, sourceInstanceId);
|
|
77
|
-
const changes = listKnowledgeSourceChanges({
|
|
78
|
-
sourceInstanceId,
|
|
79
|
-
afterSequence: watermark,
|
|
80
|
-
limit: 250
|
|
81
|
-
});
|
|
82
|
-
let published = 0;
|
|
83
|
-
let skipped = 0;
|
|
84
|
-
for (const change of changes) {
|
|
85
|
-
const item = getKnowledgeSourceItem(change.sourceItemId);
|
|
86
|
-
if (!policy?.scanEnabled || !policy.proactiveEnabled || !item || item.sensitivity === "secret" || item.sensitivity === "regulated") {
|
|
87
|
-
skipped += 1;
|
|
88
|
-
watermark = change.sequence;
|
|
89
|
-
setKnowledgeConsumerWatermark(CONSUMER_ID, sourceInstanceId, watermark);
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
const workspaceId = metadataString(item.metadata, "workspaceId");
|
|
93
|
-
const connectorId = metadataString(item.metadata, "connectorId");
|
|
94
|
-
if (!workspaceId || !connectorId) {
|
|
95
|
-
skipped += 1;
|
|
96
|
-
watermark = change.sequence;
|
|
97
|
-
setKnowledgeConsumerWatermark(CONSUMER_ID, sourceInstanceId, watermark);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const eventType = change.kind === "added" ? "connected_source.item_created.v1" : change.kind === "deleted" ? "connected_source.item_deleted.v1" : "connected_source.item_updated.v1";
|
|
101
|
-
const agentId = metadataString(item.metadata, "agentId");
|
|
102
|
-
this.eventService.publish({
|
|
103
|
-
type: eventType,
|
|
104
|
-
schemaVersion: 1,
|
|
105
|
-
source: {
|
|
106
|
-
kind: "connector",
|
|
107
|
-
id: connectionId
|
|
108
|
-
},
|
|
109
|
-
subject: {
|
|
110
|
-
kind: "knowledge_source_item",
|
|
111
|
-
id: item.id
|
|
112
|
-
},
|
|
113
|
-
actor: {
|
|
114
|
-
kind: "integration",
|
|
115
|
-
id: connectorId
|
|
116
|
-
},
|
|
117
|
-
scope: {
|
|
118
|
-
workspaceId,
|
|
119
|
-
...agentId ? { agentId } : {}
|
|
120
|
-
},
|
|
121
|
-
occurredAt: item.sourceUpdatedAt ?? item.occurredAt ?? change.changedAt,
|
|
122
|
-
dedupeKey: `knowledge-change:${change.sequence}`,
|
|
123
|
-
sensitivity: sensitivity(item.sensitivity),
|
|
124
|
-
payload: {
|
|
125
|
-
sourceInstanceId,
|
|
126
|
-
sourceItemId: item.id,
|
|
127
|
-
collectionScope: item.collectionScope,
|
|
128
|
-
itemType: item.itemType,
|
|
129
|
-
changeKind: change.kind,
|
|
130
|
-
contentHash: item.contentHash
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
published += 1;
|
|
134
|
-
watermark = change.sequence;
|
|
135
|
-
setKnowledgeConsumerWatermark(CONSUMER_ID, sourceInstanceId, watermark);
|
|
136
|
-
}
|
|
137
|
-
if (published > 0) log.info({
|
|
138
|
-
connectionId,
|
|
139
|
-
sourceInstanceId,
|
|
140
|
-
published,
|
|
141
|
-
skipped
|
|
142
|
-
}, "Connected source changes published");
|
|
143
|
-
return {
|
|
144
|
-
published,
|
|
145
|
-
skipped,
|
|
146
|
-
sources: 1
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
//#endregion
|
|
151
|
-
export { ConnectedSourceChangePublisher };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { MessageBus } from '../../infra/bus/index.js';
|
|
2
|
-
export interface HeartbeatCheck {
|
|
3
|
-
id: string;
|
|
4
|
-
startedAt: string;
|
|
5
|
-
completedAt: string | null;
|
|
6
|
-
status: string;
|
|
7
|
-
detail: string | null;
|
|
8
|
-
content: string | null;
|
|
9
|
-
deliveryStatus: string;
|
|
10
|
-
target: string | null;
|
|
11
|
-
chatId: string | null;
|
|
12
|
-
}
|
|
13
|
-
export declare function beginHeartbeatCheck(workspace: string): string;
|
|
14
|
-
export declare function completeHeartbeatCheck(id: string, status: string, detail?: string, content?: string, target?: string, chatId?: string): void;
|
|
15
|
-
export declare function recentHeartbeatChecks(workspace: string): HeartbeatCheck[];
|
|
16
|
-
export declare function recoverHeartbeatChecks(workspace: string): void;
|
|
17
|
-
/** Claim before publishing: an ambiguous bus handoff is never blindly replayed. */
|
|
18
|
-
export declare function deliverHeartbeatChecks(workspace: string, bus: Pick<MessageBus, 'publishOutbound'>, target?: string, chatId?: string): Promise<void>;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import { proactiveChecksAllowed, proactivePreferences, quietHoursEnd } from "../../proactive/policy/service.js";
|
|
3
|
-
import { reserveWorkspaceAttention } from "../../proactive/inbox/digest.js";
|
|
4
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
5
|
-
//#region src/gateway/heartbeat/check-store.ts
|
|
6
|
-
init_transaction();
|
|
7
|
-
function beginHeartbeatCheck(workspace) {
|
|
8
|
-
const id = randomUUID();
|
|
9
|
-
const now = /* @__PURE__ */ new Date();
|
|
10
|
-
const db = getSqliteDatabase();
|
|
11
|
-
db.prepare("DELETE FROM heartbeat_checks WHERE workspace_id = ? AND started_at < ?").run(workspace, (/* @__PURE__ */ new Date(now.getTime() - 30 * 864e5)).toISOString());
|
|
12
|
-
db.prepare("INSERT INTO heartbeat_checks(id, workspace_id, started_at, status, expires_at) VALUES (?, ?, ?, ?, ?)").run(id, workspace, now.toISOString(), "running", new Date(now.getTime() + 864e5).toISOString());
|
|
13
|
-
return id;
|
|
14
|
-
}
|
|
15
|
-
function completeHeartbeatCheck(id, status, detail, content, target, chatId) {
|
|
16
|
-
runSqliteWriteTransaction((db) => {
|
|
17
|
-
const row = db.prepare("SELECT workspace_id FROM heartbeat_checks WHERE id = ?").get(id);
|
|
18
|
-
const fingerprint = content ? createHash("sha256").update(JSON.stringify([
|
|
19
|
-
target,
|
|
20
|
-
chatId,
|
|
21
|
-
content.trim()
|
|
22
|
-
])).digest("hex") : null;
|
|
23
|
-
const delivery = fingerprint && db.prepare(`SELECT 1 FROM heartbeat_checks WHERE workspace_id = ? AND fingerprint = ?
|
|
24
|
-
AND delivery_status IN ('pending', 'sending', 'queued', 'unknown') AND expires_at > ? AND id <> ?`).get(row.workspace_id, fingerprint, (/* @__PURE__ */ new Date()).toISOString(), id) ? "duplicate" : status === "prepared" ? target && chatId ? "pending" : "no_target" : "none";
|
|
25
|
-
db.prepare(`UPDATE heartbeat_checks SET status = ?, detail = ?, content = ?, target = ?, chat_id = ?, fingerprint = ?,
|
|
26
|
-
delivery_status = ?, completed_at = ?, next_attempt_at = ? WHERE id = ? AND status = 'running'`).run(status, detail?.slice(0, 500) ?? null, content?.slice(0, 2e4) ?? null, target ?? null, chatId ?? null, fingerprint, delivery, (/* @__PURE__ */ new Date()).toISOString(), (/* @__PURE__ */ new Date()).toISOString(), id);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function recentHeartbeatChecks(workspace) {
|
|
30
|
-
return getSqliteDatabase().prepare(`SELECT id, started_at AS startedAt, completed_at AS completedAt, status, detail, content,
|
|
31
|
-
delivery_status AS deliveryStatus, target, chat_id AS chatId FROM heartbeat_checks WHERE workspace_id = ? ORDER BY started_at DESC, rowid DESC LIMIT 10`).all(workspace);
|
|
32
|
-
}
|
|
33
|
-
function recoverHeartbeatChecks(workspace) {
|
|
34
|
-
const db = getSqliteDatabase();
|
|
35
|
-
db.prepare("UPDATE heartbeat_checks SET delivery_status = 'unknown', detail = 'Delivery interrupted; verify before sending again' WHERE workspace_id = ? AND delivery_status = 'sending'").run(workspace);
|
|
36
|
-
db.prepare("UPDATE heartbeat_checks SET status = 'interrupted', completed_at = ? WHERE workspace_id = ? AND status = 'running'").run((/* @__PURE__ */ new Date()).toISOString(), workspace);
|
|
37
|
-
}
|
|
38
|
-
/** Claim before publishing: an ambiguous bus handoff is never blindly replayed. */
|
|
39
|
-
async function deliverHeartbeatChecks(workspace, bus, target, chatId) {
|
|
40
|
-
const claim = runSqliteWriteTransaction((db) => {
|
|
41
|
-
const now = /* @__PURE__ */ new Date();
|
|
42
|
-
db.prepare("UPDATE heartbeat_checks SET delivery_status = 'expired' WHERE workspace_id = ? AND delivery_status = 'pending' AND expires_at <= ?").run(workspace, now.toISOString());
|
|
43
|
-
const row = db.prepare("SELECT * FROM heartbeat_checks WHERE workspace_id = ? AND delivery_status = 'pending' AND next_attempt_at <= ? ORDER BY started_at LIMIT 1").get(workspace, now.toISOString());
|
|
44
|
-
if (!row) return null;
|
|
45
|
-
if (row.target !== target || row.chat_id !== chatId) {
|
|
46
|
-
db.prepare("UPDATE heartbeat_checks SET delivery_status = 'cancelled', detail = 'Delivery target changed' WHERE id = ?").run(row.id);
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
const preferences = proactivePreferences(workspace);
|
|
50
|
-
if (!proactiveChecksAllowed(preferences, now) || preferences.notificationsMuted || preferences.level === "quiet") return null;
|
|
51
|
-
const quietEnd = quietHoursEnd(preferences, now);
|
|
52
|
-
if (quietEnd) {
|
|
53
|
-
db.prepare("UPDATE heartbeat_checks SET next_attempt_at = ? WHERE id = ?").run(quietEnd.toISOString(), row.id);
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
if (!reserveWorkspaceAttention(workspace, `heartbeat:${row.id}`, now)) return null;
|
|
57
|
-
db.prepare("UPDATE heartbeat_checks SET delivery_status = 'sending' WHERE id = ? AND delivery_status = 'pending'").run(row.id);
|
|
58
|
-
return row;
|
|
59
|
-
});
|
|
60
|
-
if (!claim) return;
|
|
61
|
-
try {
|
|
62
|
-
await bus.publishOutbound({
|
|
63
|
-
channel: claim.target,
|
|
64
|
-
chat_id: claim.chat_id,
|
|
65
|
-
content: claim.content,
|
|
66
|
-
type: "message"
|
|
67
|
-
});
|
|
68
|
-
getSqliteDatabase().prepare("UPDATE heartbeat_checks SET delivery_status = 'queued' WHERE id = ? AND delivery_status = 'sending'").run(claim.id);
|
|
69
|
-
} catch {
|
|
70
|
-
getSqliteDatabase().prepare("UPDATE heartbeat_checks SET delivery_status = 'unknown', detail = 'Outbound handoff failed; verify before sending again' WHERE id = ?").run(claim.id);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
//#endregion
|
|
74
|
-
export { beginHeartbeatCheck, completeHeartbeatCheck, deliverHeartbeatChecks, recentHeartbeatChecks, recoverHeartbeatChecks };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { HeartbeatService, type HeartbeatRunnerConfig, type HeartbeatServiceDeps, heartbeatRunnerConfigFromConfig, } from './service.js';
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { AgentService } from '../../agent/service.js';
|
|
2
|
-
import type { Config } from '../../config/schema.js';
|
|
3
|
-
import type { MessageBus } from '../../infra/bus/index.js';
|
|
4
|
-
import type { SessionStore } from '../../session/store.js';
|
|
5
|
-
export interface HeartbeatRunnerConfig {
|
|
6
|
-
enabled: boolean;
|
|
7
|
-
intervalMs: number;
|
|
8
|
-
target?: string;
|
|
9
|
-
targetChatId?: string;
|
|
10
|
-
prompt?: string;
|
|
11
|
-
ackMaxChars?: number;
|
|
12
|
-
isolatedSession?: boolean;
|
|
13
|
-
activeHours?: {
|
|
14
|
-
start: string;
|
|
15
|
-
end: string;
|
|
16
|
-
timezone?: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/** Map persisted gateway config to runner options (gateway start / reload). */
|
|
20
|
-
export declare function heartbeatRunnerConfigFromConfig(cfg: Config): HeartbeatRunnerConfig;
|
|
21
|
-
export interface HeartbeatServiceDeps {
|
|
22
|
-
agentService: AgentService;
|
|
23
|
-
messageBus: MessageBus;
|
|
24
|
-
sessionStore: SessionStore;
|
|
25
|
-
/** Current app config (for HEARTBEAT.md path under the default agent `profile/` directory). */
|
|
26
|
-
getConfig: () => Config;
|
|
27
|
-
getWorkspace: () => string;
|
|
28
|
-
}
|
|
29
|
-
export declare class HeartbeatService {
|
|
30
|
-
private deps;
|
|
31
|
-
private intervalId;
|
|
32
|
-
private wake;
|
|
33
|
-
private nextCheckAt;
|
|
34
|
-
private deliveryTimer;
|
|
35
|
-
private delivering;
|
|
36
|
-
private recovered;
|
|
37
|
-
private runnerConfig;
|
|
38
|
-
constructor(deps: HeartbeatServiceDeps);
|
|
39
|
-
start(config: HeartbeatRunnerConfig): void;
|
|
40
|
-
/** Cron, exec completion, manual triggers, etc. */
|
|
41
|
-
requestNow(opts?: {
|
|
42
|
-
reason?: string;
|
|
43
|
-
}): void;
|
|
44
|
-
stop(): void;
|
|
45
|
-
updateConfig(config: Config): void;
|
|
46
|
-
isRunning(): boolean;
|
|
47
|
-
status(): {
|
|
48
|
-
enabled: boolean;
|
|
49
|
-
checksAllowed: boolean;
|
|
50
|
-
nextCheckAt: string;
|
|
51
|
-
recent: import("./check-store.js").HeartbeatCheck[];
|
|
52
|
-
};
|
|
53
|
-
private drainDeliveries;
|
|
54
|
-
private runHeartbeatOnce;
|
|
55
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
-
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { init_agent_scope, resolveDefaultAgentId } from "../../agent/agent-scope.js";
|
|
4
|
-
import { createConversation, init_conversation_repository, resolveRoutedConversation } from "../../storage/sqlite/conversation-repository.js";
|
|
5
|
-
import { shouldSilence, stripHeartbeatToken } from "../../heartbeat/tokens.js";
|
|
6
|
-
import { proactiveChecksAllowed, proactivePreferences } from "../../proactive/policy/service.js";
|
|
7
|
-
import { isWithinActiveHours } from "../../heartbeat/active-hours.js";
|
|
8
|
-
import { isHeartbeatContentEmpty } from "../../heartbeat/content-check.js";
|
|
9
|
-
import { appendCronEventLines } from "../../heartbeat/event-prompt.js";
|
|
10
|
-
import { createHeartbeatWake } from "../../heartbeat/wake.js";
|
|
11
|
-
import { beginHeartbeatCheck, completeHeartbeatCheck, deliverHeartbeatChecks, recentHeartbeatChecks, recoverHeartbeatChecks } from "./check-store.js";
|
|
12
|
-
import { resolveHeartbeatMdPath } from "../workspace-heartbeat-path.js";
|
|
13
|
-
import { readFile } from "fs/promises";
|
|
14
|
-
//#region src/gateway/heartbeat/service.ts
|
|
15
|
-
init_conversation_repository();
|
|
16
|
-
init_agent_scope();
|
|
17
|
-
init_logger();
|
|
18
|
-
const log = createLogger("HeartbeatService");
|
|
19
|
-
const DEFAULT_PROMPT = "Read HEARTBEAT.md if it exists. Follow it strictly. If nothing needs attention, reply HEARTBEAT_OK.";
|
|
20
|
-
function mapConfigToRunner(cfg) {
|
|
21
|
-
const h = cfg?.gateway?.heartbeat;
|
|
22
|
-
return {
|
|
23
|
-
enabled: h?.enabled ?? true,
|
|
24
|
-
intervalMs: h?.intervalMs ?? 18e5,
|
|
25
|
-
target: h?.target,
|
|
26
|
-
targetChatId: h?.targetChatId,
|
|
27
|
-
prompt: h?.prompt,
|
|
28
|
-
ackMaxChars: h?.ackMaxChars,
|
|
29
|
-
isolatedSession: h?.isolatedSession,
|
|
30
|
-
activeHours: h?.activeHours
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/** Map persisted gateway config to runner options (gateway start / reload). */
|
|
34
|
-
function heartbeatRunnerConfigFromConfig(cfg) {
|
|
35
|
-
return mapConfigToRunner(cfg);
|
|
36
|
-
}
|
|
37
|
-
var HeartbeatService = class {
|
|
38
|
-
intervalId = null;
|
|
39
|
-
wake;
|
|
40
|
-
nextCheckAt = null;
|
|
41
|
-
deliveryTimer = null;
|
|
42
|
-
delivering = false;
|
|
43
|
-
recovered = false;
|
|
44
|
-
runnerConfig = null;
|
|
45
|
-
constructor(deps) {
|
|
46
|
-
this.deps = deps;
|
|
47
|
-
this.wake = createHeartbeatWake(async (reasons) => {
|
|
48
|
-
try {
|
|
49
|
-
await this.runHeartbeatOnce(reasons);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
log.error({ err }, "Heartbeat check failed unexpectedly");
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
start(config) {
|
|
56
|
-
if (this.runnerConfig) this.stop();
|
|
57
|
-
if (!config.enabled) {
|
|
58
|
-
log.info("Heartbeat disabled");
|
|
59
|
-
this.runnerConfig = null;
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
this.runnerConfig = config;
|
|
63
|
-
if (!this.recovered) {
|
|
64
|
-
recoverHeartbeatChecks(this.deps.getWorkspace());
|
|
65
|
-
this.recovered = true;
|
|
66
|
-
}
|
|
67
|
-
this.deliveryTimer = setInterval(() => {
|
|
68
|
-
this.drainDeliveries().catch((err) => log.warn({ err }, "Heartbeat delivery check failed"));
|
|
69
|
-
}, 1e4);
|
|
70
|
-
this.deliveryTimer.unref?.();
|
|
71
|
-
this.nextCheckAt = new Date(Date.now() + config.intervalMs).toISOString();
|
|
72
|
-
log.info({ intervalMs: config.intervalMs }, "Heartbeat timer started (interval wake)");
|
|
73
|
-
this.intervalId = setInterval(() => {
|
|
74
|
-
this.nextCheckAt = new Date(Date.now() + config.intervalMs).toISOString();
|
|
75
|
-
this.wake.request({ reason: "interval" });
|
|
76
|
-
}, config.intervalMs);
|
|
77
|
-
this.intervalId.unref?.();
|
|
78
|
-
}
|
|
79
|
-
/** Cron, exec completion, manual triggers, etc. */
|
|
80
|
-
requestNow(opts) {
|
|
81
|
-
this.wake.request({ reason: opts?.reason ?? "manual" });
|
|
82
|
-
}
|
|
83
|
-
stop() {
|
|
84
|
-
if (this.deliveryTimer) clearInterval(this.deliveryTimer);
|
|
85
|
-
this.deliveryTimer = null;
|
|
86
|
-
this.nextCheckAt = null;
|
|
87
|
-
if (this.intervalId) {
|
|
88
|
-
clearInterval(this.intervalId);
|
|
89
|
-
this.intervalId = null;
|
|
90
|
-
}
|
|
91
|
-
this.wake.stop();
|
|
92
|
-
this.runnerConfig = null;
|
|
93
|
-
log.info("Heartbeat stopped");
|
|
94
|
-
}
|
|
95
|
-
updateConfig(config) {
|
|
96
|
-
const mapped = mapConfigToRunner(config);
|
|
97
|
-
this.stop();
|
|
98
|
-
if (mapped.enabled) this.start(mapped);
|
|
99
|
-
log.info("Heartbeat config updated");
|
|
100
|
-
}
|
|
101
|
-
isRunning() {
|
|
102
|
-
return this.intervalId !== null;
|
|
103
|
-
}
|
|
104
|
-
status() {
|
|
105
|
-
const preferences = proactivePreferences(this.deps.getWorkspace());
|
|
106
|
-
return {
|
|
107
|
-
enabled: Boolean(this.runnerConfig?.enabled),
|
|
108
|
-
checksAllowed: proactiveChecksAllowed(preferences),
|
|
109
|
-
nextCheckAt: proactiveChecksAllowed(preferences) ? this.nextCheckAt : null,
|
|
110
|
-
recent: recentHeartbeatChecks(this.deps.getWorkspace())
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
async drainDeliveries() {
|
|
114
|
-
if (this.delivering || !this.runnerConfig?.enabled) return;
|
|
115
|
-
this.delivering = true;
|
|
116
|
-
try {
|
|
117
|
-
await deliverHeartbeatChecks(this.deps.getWorkspace(), this.deps.messageBus, this.runnerConfig.target?.trim(), this.runnerConfig.targetChatId?.trim());
|
|
118
|
-
} finally {
|
|
119
|
-
this.delivering = false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
async runHeartbeatOnce(reasons) {
|
|
123
|
-
const reasonSummary = [...new Set(reasons)].join(", ") || "unknown";
|
|
124
|
-
const cfg = this.runnerConfig;
|
|
125
|
-
if (!cfg?.enabled) {
|
|
126
|
-
log.debug({ reasons: reasonSummary }, "Heartbeat: skip (disabled)");
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (!proactiveChecksAllowed(proactivePreferences(this.deps.getWorkspace()))) return;
|
|
130
|
-
if (cfg.activeHours && !isWithinActiveHours(cfg.activeHours)) {
|
|
131
|
-
log.debug({ reasons: reasonSummary }, "Heartbeat: skip (outside active hours)");
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const checkId = beginHeartbeatCheck(this.deps.getWorkspace());
|
|
135
|
-
const heartbeatPath = resolveHeartbeatMdPath(this.deps.getConfig());
|
|
136
|
-
if (!heartbeatPath) {
|
|
137
|
-
completeHeartbeatCheck(checkId, "blocked", "No workspace checklist path");
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
let heartbeatContent;
|
|
141
|
-
try {
|
|
142
|
-
const raw = await readFile(heartbeatPath, "utf-8");
|
|
143
|
-
if (isHeartbeatContentEmpty(raw)) {
|
|
144
|
-
completeHeartbeatCheck(checkId, "empty_checklist");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
heartbeatContent = raw.trim();
|
|
148
|
-
} catch {
|
|
149
|
-
completeHeartbeatCheck(checkId, "blocked", "Checklist could not be read");
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
const agentId = resolveDefaultAgentId(this.deps.getConfig());
|
|
153
|
-
const conversationId = cfg.isolatedSession ? createConversation({
|
|
154
|
-
agentId,
|
|
155
|
-
sourceChannel: "heartbeat",
|
|
156
|
-
sessionType: "heartbeat"
|
|
157
|
-
}).key : resolveRoutedConversation({
|
|
158
|
-
agentId,
|
|
159
|
-
source: "heartbeat",
|
|
160
|
-
peerKind: "direct",
|
|
161
|
-
peerId: "main"
|
|
162
|
-
}, { sessionType: "heartbeat" });
|
|
163
|
-
let basePrompt = (cfg.prompt?.trim() || DEFAULT_PROMPT).trim();
|
|
164
|
-
if (heartbeatContent) basePrompt = `${basePrompt}\n\n---\nHEARTBEAT.md:\n${heartbeatContent}\n---`;
|
|
165
|
-
basePrompt = appendCronEventLines(basePrompt, reasons);
|
|
166
|
-
basePrompt += "\nReturn notifications in your final response. Do not send messages, media or voice directly; delivery follows the user notification policy.";
|
|
167
|
-
const prompt = `${basePrompt}\n\nCurrent time: ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
168
|
-
const ackMax = cfg.ackMaxChars ?? 300;
|
|
169
|
-
log.debug({
|
|
170
|
-
conversationId,
|
|
171
|
-
reasons: reasonSummary
|
|
172
|
-
}, "Heartbeat: invoking agent");
|
|
173
|
-
if (!cfg.isolatedSession) try {
|
|
174
|
-
await this.deps.sessionStore.saveMessages(conversationId, [], { metadata: {
|
|
175
|
-
sourceChannel: "heartbeat",
|
|
176
|
-
sourceChatId: "main",
|
|
177
|
-
sessionType: "heartbeat",
|
|
178
|
-
customData: { heartbeatTarget: "main" },
|
|
179
|
-
routing: {
|
|
180
|
-
agentId,
|
|
181
|
-
source: "heartbeat",
|
|
182
|
-
accountId: "default",
|
|
183
|
-
peerKind: "direct",
|
|
184
|
-
peerId: "main"
|
|
185
|
-
}
|
|
186
|
-
} });
|
|
187
|
-
} catch (err) {
|
|
188
|
-
log.warn({
|
|
189
|
-
err,
|
|
190
|
-
conversationId
|
|
191
|
-
}, "Heartbeat: failed to reset main session transcript");
|
|
192
|
-
}
|
|
193
|
-
let reply;
|
|
194
|
-
try {
|
|
195
|
-
reply = await this.deps.agentService.turnDispatcher.processDirect(prompt, conversationId, {
|
|
196
|
-
type: "system",
|
|
197
|
-
source: "heartbeat"
|
|
198
|
-
});
|
|
199
|
-
} catch (error) {
|
|
200
|
-
completeHeartbeatCheck(checkId, "failed", "Agent check failed; see gateway logs");
|
|
201
|
-
log.error({ err: error }, "Heartbeat: agent call failed");
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (cfg !== this.runnerConfig || !proactiveChecksAllowed(proactivePreferences(this.deps.getWorkspace()))) {
|
|
205
|
-
completeHeartbeatCheck(checkId, "cancelled", "Checks paused or configuration changed");
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
if (!reply?.trim()) {
|
|
209
|
-
completeHeartbeatCheck(checkId, "no_change");
|
|
210
|
-
log.debug({ reasons: reasonSummary }, "Heartbeat: skip (empty model reply)");
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (shouldSilence(reply, ackMax)) {
|
|
214
|
-
completeHeartbeatCheck(checkId, "no_change");
|
|
215
|
-
log.info({
|
|
216
|
-
ackMax,
|
|
217
|
-
replyChars: reply.length,
|
|
218
|
-
reasons: reasonSummary
|
|
219
|
-
}, "Heartbeat: not sent — silent (HEARTBEAT_OK / short ack)");
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
const { stripped } = stripHeartbeatToken(reply);
|
|
223
|
-
completeHeartbeatCheck(checkId, "prepared", void 0, stripped || reply.trim(), cfg.target?.trim(), cfg.targetChatId?.trim());
|
|
224
|
-
await this.drainDeliveries();
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
//#endregion
|
|
228
|
-
export { HeartbeatService, heartbeatRunnerConfigFromConfig };
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { ProactiveConflict, proactivePreferences, updateProactivePreferences } from "../../../proactive/policy/service.js";
|
|
2
|
-
import { updateControlledSubscription } from "../../../proactive/scenarios/control.js";
|
|
3
|
-
import { listMailFollowUps, mailFollowUpSources, startMailFollowUp, updateMailFollowUp } from "../../../proactive/follow-ups.js";
|
|
4
|
-
import { cardChanges, getCard, performCardAction } from "../../../proactive/inbox/cards.js";
|
|
5
|
-
import { checkDelegation, delegationOverview, startDelegation } from "../../../proactive/experience.js";
|
|
6
|
-
import { recordProactivePresence } from "../../../proactive/policy/presence.js";
|
|
7
|
-
import { digestCards } from "../../../proactive/inbox/digest.js";
|
|
8
|
-
import { acknowledgeBrowserProbe, listBrowserProbes, prepareBrowserPush, registerBrowserPush, testBrowserPush, unregisterBrowserPush } from "../../../notifications/web-push.js";
|
|
9
|
-
import { proactiveMetrics } from "../../../proactive/metrics.js";
|
|
10
|
-
import { ZodError } from "zod";
|
|
11
|
-
//#region src/gateway/hono/routes/proactive-control.ts
|
|
12
|
-
function registerProactiveControlRoutes(app, deps) {
|
|
13
|
-
app.onError((error, c) => c.json({
|
|
14
|
-
ok: false,
|
|
15
|
-
error: error instanceof ZodError ? "Invalid request" : error.message
|
|
16
|
-
}, error instanceof ProactiveConflict ? 409 : 400));
|
|
17
|
-
const workspace = () => deps.service.currentWorkspacePath;
|
|
18
|
-
app.get("/api/proactive/follow-ups/sources", (c) => c.json({
|
|
19
|
-
ok: true,
|
|
20
|
-
sources: mailFollowUpSources(workspace())
|
|
21
|
-
}));
|
|
22
|
-
app.get("/api/proactive/follow-ups", (c) => c.json({
|
|
23
|
-
ok: true,
|
|
24
|
-
followUps: listMailFollowUps(workspace())
|
|
25
|
-
}));
|
|
26
|
-
app.post("/api/proactive/follow-ups", deps.strictRateLimitMiddleware, async (c) => c.json({
|
|
27
|
-
ok: true,
|
|
28
|
-
followUp: startMailFollowUp(workspace(), await c.req.json())
|
|
29
|
-
}, 201));
|
|
30
|
-
app.patch("/api/proactive/follow-ups/:id", deps.strictRateLimitMiddleware, async (c) => c.json({
|
|
31
|
-
ok: true,
|
|
32
|
-
followUp: updateMailFollowUp(workspace(), c.req.param("id"), await c.req.json())
|
|
33
|
-
}));
|
|
34
|
-
app.get("/api/proactive/overview", (c) => c.json({
|
|
35
|
-
ok: true,
|
|
36
|
-
...delegationOverview(workspace()),
|
|
37
|
-
heartbeat: deps.service.heartbeatStatus()
|
|
38
|
-
}));
|
|
39
|
-
app.post("/api/proactive/delegations", deps.strictRateLimitMiddleware, async (c) => c.json({
|
|
40
|
-
ok: true,
|
|
41
|
-
subscription: startDelegation(workspace(), await c.req.json())
|
|
42
|
-
}, 201));
|
|
43
|
-
app.post("/api/proactive/subscriptions/:id/check", deps.strictRateLimitMiddleware, (c) => c.json({
|
|
44
|
-
ok: true,
|
|
45
|
-
...checkDelegation(workspace(), c.req.param("id"))
|
|
46
|
-
}, 202));
|
|
47
|
-
for (const path of ["/api/proactive/*", "/api/inbox/judgments/*"]) app.use(path, async (c, next) => {
|
|
48
|
-
try {
|
|
49
|
-
const id = c.req.path.match(/^\/api\/inbox\/judgments\/([^/]+)/)?.[1];
|
|
50
|
-
if (id && id !== "changes") getCard(decodeURIComponent(id), workspace());
|
|
51
|
-
await next();
|
|
52
|
-
} catch (error) {
|
|
53
|
-
return c.json({
|
|
54
|
-
ok: false,
|
|
55
|
-
error: error instanceof ZodError ? "Invalid request" : error instanceof Error ? error.message : "Request failed"
|
|
56
|
-
}, error instanceof ProactiveConflict ? 409 : 400);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
app.get("/api/proactive/web-push/probes", (c) => c.json({
|
|
60
|
-
ok: true,
|
|
61
|
-
probes: listBrowserProbes(workspace())
|
|
62
|
-
}));
|
|
63
|
-
app.post("/api/proactive/web-push/subscriptions/:id/test", deps.strictRateLimitMiddleware, async (c) => c.json({
|
|
64
|
-
ok: true,
|
|
65
|
-
...await testBrowserPush(workspace(), c.req.param("id"))
|
|
66
|
-
}));
|
|
67
|
-
app.post("/api/proactive/web-push/probes/:id/opened", deps.strictRateLimitMiddleware, (c) => {
|
|
68
|
-
acknowledgeBrowserProbe(workspace(), c.req.param("id"));
|
|
69
|
-
return c.json({ ok: true });
|
|
70
|
-
});
|
|
71
|
-
app.post("/api/proactive/web-push/prepare", deps.strictRateLimitMiddleware, (c) => c.json({
|
|
72
|
-
ok: true,
|
|
73
|
-
...prepareBrowserPush()
|
|
74
|
-
}));
|
|
75
|
-
app.post("/api/proactive/web-push/subscriptions", deps.strictRateLimitMiddleware, async (c) => c.json({
|
|
76
|
-
ok: true,
|
|
77
|
-
...registerBrowserPush(workspace(), await c.req.json())
|
|
78
|
-
}, 201));
|
|
79
|
-
app.delete("/api/proactive/web-push/subscriptions/:id", deps.strictRateLimitMiddleware, (c) => {
|
|
80
|
-
unregisterBrowserPush(workspace(), c.req.param("id"));
|
|
81
|
-
return c.json({ ok: true });
|
|
82
|
-
});
|
|
83
|
-
app.post("/api/proactive/presence", deps.strictRateLimitMiddleware, async (c) => {
|
|
84
|
-
recordProactivePresence(workspace(), await c.req.json());
|
|
85
|
-
return c.json({ ok: true });
|
|
86
|
-
});
|
|
87
|
-
app.get("/api/proactive/metrics", (c) => c.json({
|
|
88
|
-
ok: true,
|
|
89
|
-
metrics: proactiveMetrics(workspace())
|
|
90
|
-
}));
|
|
91
|
-
app.get("/api/proactive/digests/:id", (c) => c.json({
|
|
92
|
-
ok: true,
|
|
93
|
-
cards: digestCards(c.req.param("id"), workspace())
|
|
94
|
-
}));
|
|
95
|
-
app.get("/api/proactive/preferences", (c) => c.json({
|
|
96
|
-
ok: true,
|
|
97
|
-
preferences: proactivePreferences(workspace())
|
|
98
|
-
}));
|
|
99
|
-
app.patch("/api/proactive/preferences", deps.strictRateLimitMiddleware, async (c) => c.json({
|
|
100
|
-
ok: true,
|
|
101
|
-
preferences: updateProactivePreferences(workspace(), await c.req.json())
|
|
102
|
-
}));
|
|
103
|
-
app.patch("/api/proactive/subscriptions/:id", deps.strictRateLimitMiddleware, async (c) => c.json({
|
|
104
|
-
ok: true,
|
|
105
|
-
subscription: updateControlledSubscription(workspace(), c.req.param("id"), await c.req.json())
|
|
106
|
-
}));
|
|
107
|
-
app.get("/api/inbox/judgments/changes", (c) => {
|
|
108
|
-
const cursor = Number(c.req.query("cursor") ?? 0);
|
|
109
|
-
if (!Number.isSafeInteger(cursor) || cursor < 0) return c.json({
|
|
110
|
-
ok: false,
|
|
111
|
-
error: "Invalid cursor"
|
|
112
|
-
}, 400);
|
|
113
|
-
return c.json({
|
|
114
|
-
ok: true,
|
|
115
|
-
...cardChanges(workspace(), cursor)
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
app.get("/api/inbox/judgments/:itemId", (c) => c.json({
|
|
119
|
-
ok: true,
|
|
120
|
-
card: getCard(c.req.param("itemId"), workspace())
|
|
121
|
-
}));
|
|
122
|
-
app.post("/api/inbox/judgments/:itemId/actions", deps.strictRateLimitMiddleware, async (c) => {
|
|
123
|
-
const card = performCardAction(c.req.param("itemId"), workspace(), await c.req.json());
|
|
124
|
-
deps.service.emit("proactive.card.changed", {
|
|
125
|
-
cardId: card.id,
|
|
126
|
-
revision: card.revision
|
|
127
|
-
});
|
|
128
|
-
return c.json({
|
|
129
|
-
ok: true,
|
|
130
|
-
card
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
export { registerProactiveControlRoutes };
|