@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,82 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import { insightSourcesAuthorized, insightSourcesChanged } from "../execution/authorization.js";
|
|
3
|
-
import { effectiveProactivePolicy } from "../policy/service.js";
|
|
4
|
-
import { insightCorrelation } from "../inbox/lifecycle.js";
|
|
5
|
-
import { TaskApplicationService } from "../../tasks/task-application-service.js";
|
|
6
|
-
//#region src/proactive/actions/service.ts
|
|
7
|
-
init_transaction();
|
|
8
|
-
function projectIdFromAggregationKey(value) {
|
|
9
|
-
if (!value.startsWith("project:") || value.length === 8) throw new Error("Proactive action has no project scope");
|
|
10
|
-
return value.slice(8);
|
|
11
|
-
}
|
|
12
|
-
function executeClaimedAction(row, now = /* @__PURE__ */ new Date()) {
|
|
13
|
-
const action = JSON.parse(row.proposed_action_json);
|
|
14
|
-
try {
|
|
15
|
-
if (getSqliteDatabase().prepare("SELECT 1 FROM proactive_inbox_items WHERE insight_id = ? AND withdrawn_at IS NOT NULL").get(row.insight_id)) throw new Error("Card was withdrawn");
|
|
16
|
-
if (!insightSourcesAuthorized(row.insight_id)) throw new Error("Source permission is no longer available");
|
|
17
|
-
if (insightSourcesChanged(row.insight_id)) throw new Error("Source changed; review updated work before acting");
|
|
18
|
-
if (!effectiveProactivePolicy(row.subscription_id).enabled) throw new Error("Proactive subscription paused");
|
|
19
|
-
const permission = getSqliteDatabase().prepare(`SELECT mode, allowed_actions_json FROM project_monitoring_policies WHERE project_id = ?`).get(projectIdFromAggregationKey(row.aggregation_key));
|
|
20
|
-
if (!getSqliteDatabase().prepare(`SELECT 1 FROM proactive_decisions d JOIN proactive_inbox_items i USING(inbox_item_id) WHERE i.insight_id = ? AND d.choice = 'approve'`).get(row.insight_id) && !(permission?.mode === "auto_low_risk" && JSON.parse(permission.allowed_actions_json).includes(action.id))) throw new Error("Action permission is no longer available");
|
|
21
|
-
if (action.id !== "create_project_task") throw new Error(`Unsupported proactive action: ${action.id}`);
|
|
22
|
-
const result = new TaskApplicationService().create({
|
|
23
|
-
idempotencyKey: `proactive:${insightCorrelation(row.insight_id)}:${action.id}`,
|
|
24
|
-
title: action.input.title,
|
|
25
|
-
projectId: projectIdFromAggregationKey(row.aggregation_key),
|
|
26
|
-
priority: "normal",
|
|
27
|
-
contract: {
|
|
28
|
-
objective: action.input.objective,
|
|
29
|
-
expectedOutputs: [],
|
|
30
|
-
acceptanceCriteria: [],
|
|
31
|
-
constraints: [],
|
|
32
|
-
approvalRequired: [],
|
|
33
|
-
assumptions: [],
|
|
34
|
-
risks: [],
|
|
35
|
-
acceptancePolicy: "manual",
|
|
36
|
-
outputDestinations: []
|
|
37
|
-
},
|
|
38
|
-
dependencies: [],
|
|
39
|
-
context: [],
|
|
40
|
-
authorityGrants: [],
|
|
41
|
-
activation: {
|
|
42
|
-
mode: "capture",
|
|
43
|
-
phase: "backlog"
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
kind: "system",
|
|
47
|
-
id: "proactive"
|
|
48
|
-
});
|
|
49
|
-
if (!result.ok) throw new Error(`Task creation failed: ${"reason" in result ? result.reason : "unknown"}`);
|
|
50
|
-
getSqliteDatabase().prepare(`UPDATE proactive_insights
|
|
51
|
-
SET action_status = 'completed', action_result_json = ?, action_error = NULL, action_updated_at = ?
|
|
52
|
-
WHERE insight_id = ? AND action_status = 'executing'`).run(JSON.stringify({ taskId: result.model.task.id }), now.toISOString(), row.insight_id);
|
|
53
|
-
getSqliteDatabase().prepare("UPDATE proactive_inbox_items SET status = 'read', resolution = NULL, updated_at = ? WHERE insight_id = ?").run(now.toISOString(), row.insight_id);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
getSqliteDatabase().prepare(`UPDATE proactive_insights
|
|
56
|
-
SET action_status = 'failed', action_error = ?, action_updated_at = ?
|
|
57
|
-
WHERE insight_id = ? AND action_status = 'executing'`).run(String(error instanceof Error ? error.message : error).slice(0, 2e3), now.toISOString(), row.insight_id);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function executePendingProactiveActions(now = /* @__PURE__ */ new Date()) {
|
|
61
|
-
const expired = (/* @__PURE__ */ new Date(now.getTime() - 5 * 6e4)).toISOString();
|
|
62
|
-
getSqliteDatabase().prepare(`UPDATE proactive_insights SET action_status = 'pending', action_updated_at = ?
|
|
63
|
-
WHERE action_status = 'executing' AND action_updated_at <= ?`).run(now.toISOString(), expired);
|
|
64
|
-
let executed = 0;
|
|
65
|
-
while (true) {
|
|
66
|
-
const row = runSqliteWriteTransaction((db) => {
|
|
67
|
-
const candidate = db.prepare(`SELECT x.insight_id, x.subscription_id, b.aggregation_key, x.proposed_action_json
|
|
68
|
-
FROM proactive_insights x
|
|
69
|
-
JOIN proactive_runs r ON r.run_id = x.run_id
|
|
70
|
-
JOIN proactive_signal_batches b ON b.batch_id = r.batch_id
|
|
71
|
-
WHERE x.action_status = 'pending' ORDER BY x.created_at LIMIT 1`).get();
|
|
72
|
-
if (!candidate) return void 0;
|
|
73
|
-
return db.prepare(`UPDATE proactive_insights SET action_status = 'executing', action_updated_at = ?
|
|
74
|
-
WHERE insight_id = ? AND action_status = 'pending'`).run(now.toISOString(), candidate.insight_id).changes === 1 ? candidate : void 0;
|
|
75
|
-
});
|
|
76
|
-
if (!row) return executed;
|
|
77
|
-
executeClaimedAction(row, now);
|
|
78
|
-
executed += 1;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
export { executePendingProactiveActions };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { EVENT_ACTOR_KINDS, EVENT_SENSITIVITIES } from "./types.js";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
//#region src/proactive/events/envelope.ts
|
|
4
|
-
const EVENT_TYPE_PATTERN = /^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+\.v[1-9][0-9]*$/;
|
|
5
|
-
function required(value, field) {
|
|
6
|
-
const normalized = value.trim();
|
|
7
|
-
if (!normalized) throw new Error(`${field} is required`);
|
|
8
|
-
if (normalized.length > 300) throw new Error(`${field} is too long`);
|
|
9
|
-
return normalized;
|
|
10
|
-
}
|
|
11
|
-
function timestamp(value, field) {
|
|
12
|
-
const time = Date.parse(value);
|
|
13
|
-
if (!Number.isFinite(time)) throw new Error(`${field} must be an ISO timestamp`);
|
|
14
|
-
return new Date(time).toISOString();
|
|
15
|
-
}
|
|
16
|
-
function normalizeEventEnvelope(input, now = /* @__PURE__ */ new Date()) {
|
|
17
|
-
if (!EVENT_TYPE_PATTERN.test(input.type)) throw new Error("type must use the domain.event.vN convention");
|
|
18
|
-
if (!Number.isInteger(input.schemaVersion) || input.schemaVersion < 1) throw new Error("schemaVersion must be a positive integer");
|
|
19
|
-
if (!EVENT_ACTOR_KINDS.includes(input.actor.kind)) throw new Error("actor.kind is invalid");
|
|
20
|
-
if (!EVENT_SENSITIVITIES.includes(input.sensitivity)) throw new Error("sensitivity is invalid");
|
|
21
|
-
if (!input.payload || Array.isArray(input.payload) || typeof input.payload !== "object") throw new Error("payload must be an object");
|
|
22
|
-
return {
|
|
23
|
-
id: required(input.id ?? randomUUID(), "id"),
|
|
24
|
-
type: input.type,
|
|
25
|
-
schemaVersion: input.schemaVersion,
|
|
26
|
-
source: {
|
|
27
|
-
kind: required(input.source.kind, "source.kind"),
|
|
28
|
-
id: required(input.source.id, "source.id"),
|
|
29
|
-
...input.source.deviceId ? { deviceId: required(input.source.deviceId, "source.deviceId") } : {}
|
|
30
|
-
},
|
|
31
|
-
subject: {
|
|
32
|
-
kind: required(input.subject.kind, "subject.kind"),
|
|
33
|
-
id: required(input.subject.id, "subject.id")
|
|
34
|
-
},
|
|
35
|
-
actor: {
|
|
36
|
-
kind: input.actor.kind,
|
|
37
|
-
...input.actor.id ? { id: required(input.actor.id, "actor.id") } : {}
|
|
38
|
-
},
|
|
39
|
-
scope: {
|
|
40
|
-
workspaceId: required(input.scope.workspaceId, "scope.workspaceId"),
|
|
41
|
-
...input.scope.projectId ? { projectId: required(input.scope.projectId, "scope.projectId") } : {},
|
|
42
|
-
...input.scope.agentId ? { agentId: required(input.scope.agentId, "scope.agentId") } : {}
|
|
43
|
-
},
|
|
44
|
-
occurredAt: timestamp(input.occurredAt, "occurredAt"),
|
|
45
|
-
observedAt: timestamp(input.observedAt ?? now.toISOString(), "observedAt"),
|
|
46
|
-
correlationId: required(input.correlationId ?? randomUUID(), "correlationId"),
|
|
47
|
-
...input.causationId ? { causationId: required(input.causationId, "causationId") } : {},
|
|
48
|
-
dedupeKey: required(input.dedupeKey, "dedupeKey"),
|
|
49
|
-
sensitivity: input.sensitivity,
|
|
50
|
-
payload: input.payload
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { normalizeEventEnvelope };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AutomationEvent } from '../../automations/domain/types.js';
|
|
2
|
-
import type { PublishEventInput } from './types.js';
|
|
3
|
-
export declare function mapProductEventToProactive(input: {
|
|
4
|
-
event: AutomationEvent;
|
|
5
|
-
workspaceId: string;
|
|
6
|
-
defaultAgentId: string;
|
|
7
|
-
}): PublishEventInput | null;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
//#region src/proactive/events/product-event-bridge.ts
|
|
2
|
-
const PROACTIVE_EVENT_TYPE_BY_PRODUCT_EVENT = new Map([
|
|
3
|
-
["task.created.v2", "task.created.v2"],
|
|
4
|
-
["task.commanded.v2", "task.commanded.v2"],
|
|
5
|
-
["task.phase_changed.v2", "task.phase_changed.v2"],
|
|
6
|
-
["task.attention_required.v2", "task.attention_required.v2"],
|
|
7
|
-
["note.created", "note.created.v1"],
|
|
8
|
-
["note.updated", "note.updated.v1"],
|
|
9
|
-
["workflow.run.completed", "workflow.run.completed.v1"],
|
|
10
|
-
["session.transcript.updated", "session.transcript.updated.v1"],
|
|
11
|
-
["discussion.completed", "discussion.completed.v1"]
|
|
12
|
-
]);
|
|
13
|
-
function stringValue(payload, key) {
|
|
14
|
-
const value = payload[key];
|
|
15
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
16
|
-
}
|
|
17
|
-
function subjectFor(event) {
|
|
18
|
-
const payload = event.payload ?? {};
|
|
19
|
-
if (event.type.startsWith("task.")) {
|
|
20
|
-
const id = stringValue(payload, "taskId");
|
|
21
|
-
return id ? {
|
|
22
|
-
kind: "task",
|
|
23
|
-
id
|
|
24
|
-
} : null;
|
|
25
|
-
}
|
|
26
|
-
if (event.type.startsWith("note.")) {
|
|
27
|
-
const id = stringValue(payload, "noteId");
|
|
28
|
-
return id ? {
|
|
29
|
-
kind: "note",
|
|
30
|
-
id
|
|
31
|
-
} : null;
|
|
32
|
-
}
|
|
33
|
-
if (event.type === "workflow.run.completed") {
|
|
34
|
-
const id = stringValue(payload, "runId");
|
|
35
|
-
return id ? {
|
|
36
|
-
kind: "workflow_run",
|
|
37
|
-
id
|
|
38
|
-
} : null;
|
|
39
|
-
}
|
|
40
|
-
if (event.type === "session.transcript.updated") {
|
|
41
|
-
const id = stringValue(payload, "conversationId");
|
|
42
|
-
return id ? {
|
|
43
|
-
kind: "session",
|
|
44
|
-
id
|
|
45
|
-
} : null;
|
|
46
|
-
}
|
|
47
|
-
if (event.type === "discussion.completed") {
|
|
48
|
-
const id = stringValue(payload, "discussionId");
|
|
49
|
-
return id ? {
|
|
50
|
-
kind: "discussion",
|
|
51
|
-
id
|
|
52
|
-
} : null;
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
function mapProductEventToProactive(input) {
|
|
57
|
-
const proactiveEventType = PROACTIVE_EVENT_TYPE_BY_PRODUCT_EVENT.get(input.event.type);
|
|
58
|
-
if (!proactiveEventType) return null;
|
|
59
|
-
const subject = subjectFor(input.event);
|
|
60
|
-
if (!subject) return null;
|
|
61
|
-
const payload = input.event.payload ?? {};
|
|
62
|
-
const occurredAtMs = Number.isFinite(input.event.occurredAtMs) ? input.event.occurredAtMs : Date.now();
|
|
63
|
-
const versionId = stringValue(payload, "messageId") ?? stringValue(payload, "runId") ?? String(occurredAtMs);
|
|
64
|
-
const agentId = stringValue(payload, "agentId") ?? input.defaultAgentId;
|
|
65
|
-
const projectId = stringValue(payload, "projectId");
|
|
66
|
-
return {
|
|
67
|
-
type: proactiveEventType,
|
|
68
|
-
schemaVersion: 1,
|
|
69
|
-
source: {
|
|
70
|
-
kind: "internal",
|
|
71
|
-
id: input.event.source ?? "xopc"
|
|
72
|
-
},
|
|
73
|
-
subject,
|
|
74
|
-
actor: { kind: "system" },
|
|
75
|
-
scope: {
|
|
76
|
-
workspaceId: input.workspaceId,
|
|
77
|
-
agentId,
|
|
78
|
-
...projectId ? { projectId } : {}
|
|
79
|
-
},
|
|
80
|
-
occurredAt: new Date(occurredAtMs).toISOString(),
|
|
81
|
-
dedupeKey: `product-event:${proactiveEventType}:${subject.id}:${versionId}`,
|
|
82
|
-
sensitivity: "personal",
|
|
83
|
-
payload
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
//#endregion
|
|
87
|
-
export { mapProductEventToProactive };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EventEnvelope } from './types.js';
|
|
2
|
-
export declare function getEventByDedupeKey(dedupeKey: string): EventEnvelope | null;
|
|
3
|
-
export declare function insertEvent(event: EventEnvelope): boolean;
|
|
4
|
-
export declare function isEventRouted(eventId: string): boolean;
|
|
5
|
-
export declare function markEventRouted(eventId: string, routedAt: string): void;
|
|
6
|
-
export declare function listEvents(input?: {
|
|
7
|
-
limit?: number;
|
|
8
|
-
type?: string;
|
|
9
|
-
}): EventEnvelope[];
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
//#region src/proactive/events/repository.ts
|
|
3
|
-
init_transaction();
|
|
4
|
-
function fromRow(row) {
|
|
5
|
-
return {
|
|
6
|
-
id: row.event_id,
|
|
7
|
-
type: row.type,
|
|
8
|
-
schemaVersion: row.schema_version,
|
|
9
|
-
source: {
|
|
10
|
-
kind: row.source_kind,
|
|
11
|
-
id: row.source_id,
|
|
12
|
-
...row.device_id ? { deviceId: row.device_id } : {}
|
|
13
|
-
},
|
|
14
|
-
subject: {
|
|
15
|
-
kind: row.subject_kind,
|
|
16
|
-
id: row.subject_id
|
|
17
|
-
},
|
|
18
|
-
actor: {
|
|
19
|
-
kind: row.actor_kind,
|
|
20
|
-
...row.actor_id ? { id: row.actor_id } : {}
|
|
21
|
-
},
|
|
22
|
-
scope: {
|
|
23
|
-
workspaceId: row.workspace_id,
|
|
24
|
-
...row.project_id ? { projectId: row.project_id } : {},
|
|
25
|
-
...row.agent_id ? { agentId: row.agent_id } : {}
|
|
26
|
-
},
|
|
27
|
-
occurredAt: row.occurred_at,
|
|
28
|
-
observedAt: row.observed_at,
|
|
29
|
-
correlationId: row.correlation_id,
|
|
30
|
-
...row.causation_id ? { causationId: row.causation_id } : {},
|
|
31
|
-
dedupeKey: row.dedupe_key,
|
|
32
|
-
sensitivity: row.sensitivity,
|
|
33
|
-
payload: JSON.parse(row.payload_json)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function getEventByDedupeKey(dedupeKey) {
|
|
37
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM proactive_events WHERE dedupe_key = ?").get(dedupeKey);
|
|
38
|
-
return row ? fromRow(row) : null;
|
|
39
|
-
}
|
|
40
|
-
function insertEvent(event) {
|
|
41
|
-
return runSqliteWriteTransaction((db) => {
|
|
42
|
-
return db.prepare(`INSERT OR IGNORE INTO proactive_events (
|
|
43
|
-
event_id, type, schema_version, source_kind, source_id, device_id,
|
|
44
|
-
subject_kind, subject_id, actor_kind, actor_id, workspace_id, project_id, agent_id,
|
|
45
|
-
occurred_at, observed_at, correlation_id, causation_id, dedupe_key, sensitivity, payload_json
|
|
46
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(event.id, event.type, event.schemaVersion, event.source.kind, event.source.id, event.source.deviceId ?? null, event.subject.kind, event.subject.id, event.actor.kind, event.actor.id ?? null, event.scope.workspaceId, event.scope.projectId ?? null, event.scope.agentId ?? null, event.occurredAt, event.observedAt, event.correlationId, event.causationId ?? null, event.dedupeKey, event.sensitivity, JSON.stringify(event.payload)).changes === 1;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function isEventRouted(eventId) {
|
|
50
|
-
const row = getSqliteDatabase().prepare("SELECT routed_at FROM proactive_events WHERE event_id = ?").get(eventId);
|
|
51
|
-
return Boolean(row?.routed_at);
|
|
52
|
-
}
|
|
53
|
-
function markEventRouted(eventId, routedAt) {
|
|
54
|
-
runSqliteWriteTransaction((db) => {
|
|
55
|
-
db.prepare("UPDATE proactive_events SET routed_at = COALESCE(routed_at, ?) WHERE event_id = ?").run(routedAt, eventId);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function listEvents(input = {}) {
|
|
59
|
-
const limit = Math.min(200, Math.max(1, input.limit ?? 50));
|
|
60
|
-
return (input.type ? getSqliteDatabase().prepare("SELECT * FROM proactive_events WHERE type = ? ORDER BY observed_at DESC LIMIT ?").all(input.type, limit) : getSqliteDatabase().prepare("SELECT * FROM proactive_events ORDER BY observed_at DESC LIMIT ?").all(limit)).map(fromRow);
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
export { getEventByDedupeKey, insertEvent, isEventRouted, listEvents, markEventRouted };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export declare const EVENT_SENSITIVITIES: readonly ["public", "personal", "confidential", "restricted"];
|
|
2
|
-
export type EventSensitivity = (typeof EVENT_SENSITIVITIES)[number];
|
|
3
|
-
export declare const EVENT_ACTOR_KINDS: readonly ["user", "agent", "system", "integration"];
|
|
4
|
-
export type EventActorKind = (typeof EVENT_ACTOR_KINDS)[number];
|
|
5
|
-
export interface EventEnvelope<TPayload extends Record<string, unknown> = Record<string, unknown>> {
|
|
6
|
-
id: string;
|
|
7
|
-
type: string;
|
|
8
|
-
schemaVersion: number;
|
|
9
|
-
source: {
|
|
10
|
-
kind: string;
|
|
11
|
-
id: string;
|
|
12
|
-
deviceId?: string;
|
|
13
|
-
};
|
|
14
|
-
subject: {
|
|
15
|
-
kind: string;
|
|
16
|
-
id: string;
|
|
17
|
-
};
|
|
18
|
-
actor: {
|
|
19
|
-
kind: EventActorKind;
|
|
20
|
-
id?: string;
|
|
21
|
-
};
|
|
22
|
-
scope: {
|
|
23
|
-
workspaceId: string;
|
|
24
|
-
projectId?: string;
|
|
25
|
-
agentId?: string;
|
|
26
|
-
};
|
|
27
|
-
occurredAt: string;
|
|
28
|
-
observedAt: string;
|
|
29
|
-
correlationId: string;
|
|
30
|
-
causationId?: string;
|
|
31
|
-
dedupeKey: string;
|
|
32
|
-
sensitivity: EventSensitivity;
|
|
33
|
-
payload: TPayload;
|
|
34
|
-
}
|
|
35
|
-
export type PublishEventInput<TPayload extends Record<string, unknown> = Record<string, unknown>> = Omit<EventEnvelope<TPayload>, 'id' | 'observedAt' | 'correlationId'> & {
|
|
36
|
-
id?: string;
|
|
37
|
-
observedAt?: string;
|
|
38
|
-
correlationId?: string;
|
|
39
|
-
};
|
|
40
|
-
export interface PublishedEvent {
|
|
41
|
-
event: EventEnvelope;
|
|
42
|
-
inserted: boolean;
|
|
43
|
-
batchIds: string[];
|
|
44
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/proactive/events/types.ts
|
|
2
|
-
const EVENT_SENSITIVITIES = [
|
|
3
|
-
"public",
|
|
4
|
-
"personal",
|
|
5
|
-
"confidential",
|
|
6
|
-
"restricted"
|
|
7
|
-
];
|
|
8
|
-
const EVENT_ACTOR_KINDS = [
|
|
9
|
-
"user",
|
|
10
|
-
"agent",
|
|
11
|
-
"system",
|
|
12
|
-
"integration"
|
|
13
|
-
];
|
|
14
|
-
//#endregion
|
|
15
|
-
export { EVENT_ACTOR_KINDS, EVENT_SENSITIVITIES };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../../config/schema.js';
|
|
2
|
-
import type { ProactiveAgentExecutor } from './types.js';
|
|
3
|
-
/** Runs an isolated, read-only agent over only the context authorized by the signal batch. */
|
|
4
|
-
export declare class ReadonlyProactiveAgentExecutor implements ProactiveAgentExecutor {
|
|
5
|
-
private readonly config;
|
|
6
|
-
constructor(config: () => Config | undefined);
|
|
7
|
-
execute(input: {
|
|
8
|
-
systemPrompt: string;
|
|
9
|
-
userPrompt: string;
|
|
10
|
-
authorizedContext: Record<string, unknown>;
|
|
11
|
-
signal?: AbortSignal;
|
|
12
|
-
}): Promise<{
|
|
13
|
-
text: string;
|
|
14
|
-
modelRef: string;
|
|
15
|
-
usage: {
|
|
16
|
-
inputTokens: number;
|
|
17
|
-
outputTokens: number;
|
|
18
|
-
estimatedCostUsd?: number;
|
|
19
|
-
};
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
|
|
2
|
-
import { getApiKeySync, getDefaultModelSync, init_providers, resolveModel } from "../../providers/index.js";
|
|
3
|
-
import { createExtensionAwareStreamFn } from "../../providers/extension-stream-bridge.js";
|
|
4
|
-
import { isAssistantTurnAborted, isAssistantTurnFailed } from "../../agent/orchestration/llm-turn-retry.js";
|
|
5
|
-
import { runAgentTurnWithTimeout } from "../../agent/orchestration/run-agent-turn-with-timeout.js";
|
|
6
|
-
import { Agent } from "@earendil-works/pi-agent-core";
|
|
7
|
-
import { Type } from "@sinclair/typebox";
|
|
8
|
-
//#region src/proactive/execution/agent-executor.ts
|
|
9
|
-
init_sync_provider_auth();
|
|
10
|
-
init_providers();
|
|
11
|
-
const MAX_TOOL_CALLS = 6;
|
|
12
|
-
const AGENT_TIMEOUT_MS = 9e4;
|
|
13
|
-
function assistantText(messages) {
|
|
14
|
-
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
15
|
-
const message = messages[index];
|
|
16
|
-
if (message.role !== "assistant") continue;
|
|
17
|
-
if (Array.isArray(message.content)) return message.content.flatMap((block) => block && typeof block === "object" && block.type === "text" ? [String(block.text ?? "")] : []).join("").trim();
|
|
18
|
-
}
|
|
19
|
-
return "";
|
|
20
|
-
}
|
|
21
|
-
function inspectionTool(context) {
|
|
22
|
-
return {
|
|
23
|
-
name: "inspect_authorized_context",
|
|
24
|
-
label: "Inspect authorized work context",
|
|
25
|
-
description: "Read one authorized evidence section. This tool cannot write or trigger any action.",
|
|
26
|
-
parameters: Type.Object({ section: Type.String({ description: "A top-level section name from the availableSections list." }) }),
|
|
27
|
-
async execute(_toolCallId, args) {
|
|
28
|
-
const values = args;
|
|
29
|
-
const section = typeof values.section === "string" ? values.section : "";
|
|
30
|
-
if (!Object.prototype.hasOwnProperty.call(context, section)) return {
|
|
31
|
-
content: [{
|
|
32
|
-
type: "text",
|
|
33
|
-
text: `Unknown section. Available: ${Object.keys(context).join(", ")}`
|
|
34
|
-
}],
|
|
35
|
-
details: { found: false }
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
content: [{
|
|
39
|
-
type: "text",
|
|
40
|
-
text: JSON.stringify({
|
|
41
|
-
section,
|
|
42
|
-
evidence: context[section]
|
|
43
|
-
}, null, 2).slice(0, 6e4)
|
|
44
|
-
}],
|
|
45
|
-
details: {
|
|
46
|
-
found: true,
|
|
47
|
-
section
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/** Runs an isolated, read-only agent over only the context authorized by the signal batch. */
|
|
54
|
-
var ReadonlyProactiveAgentExecutor = class {
|
|
55
|
-
constructor(config) {
|
|
56
|
-
this.config = config;
|
|
57
|
-
}
|
|
58
|
-
async execute(input) {
|
|
59
|
-
input.signal?.throwIfAborted();
|
|
60
|
-
const model = resolveModel(getDefaultModelSync(this.config()));
|
|
61
|
-
let toolCalls = 0;
|
|
62
|
-
const agent = new Agent({
|
|
63
|
-
initialState: {
|
|
64
|
-
systemPrompt: `${input.systemPrompt}\n\nYou are an autonomous background analysis agent. You MUST inspect relevant authorized context with the provided read-only tool before reaching a conclusion. You have no mutation, messaging, shell, network, or filesystem tools.`,
|
|
65
|
-
model,
|
|
66
|
-
thinkingLevel: "low",
|
|
67
|
-
tools: [inspectionTool(input.authorizedContext)],
|
|
68
|
-
messages: []
|
|
69
|
-
},
|
|
70
|
-
streamFn: createExtensionAwareStreamFn(),
|
|
71
|
-
getApiKey: (provider) => resolveProviderApiKeySync(provider) ?? getApiKeySync(provider) ?? "",
|
|
72
|
-
beforeToolCall: async () => {
|
|
73
|
-
if (toolCalls >= MAX_TOOL_CALLS) return {
|
|
74
|
-
block: true,
|
|
75
|
-
reason: `Maximum inspection calls reached (${MAX_TOOL_CALLS}).`
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
afterToolCall: async () => {
|
|
79
|
-
toolCalls += 1;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
const abort = () => agent.abort();
|
|
83
|
-
input.signal?.addEventListener("abort", abort, { once: true });
|
|
84
|
-
try {
|
|
85
|
-
const sections = Object.keys(input.authorizedContext);
|
|
86
|
-
await runAgentTurnWithTimeout(agent, async () => {
|
|
87
|
-
await agent.prompt(`${input.userPrompt}\n\nAvailable authorized evidence sections: ${sections.join(", ") || "(none)"}.`);
|
|
88
|
-
await agent.waitForIdle();
|
|
89
|
-
}, AGENT_TIMEOUT_MS);
|
|
90
|
-
if (isAssistantTurnAborted(agent)) throw new Error("Proactive agent execution aborted");
|
|
91
|
-
if (isAssistantTurnFailed(agent)) throw new Error("Proactive agent execution failed");
|
|
92
|
-
const text = assistantText(agent.state.messages);
|
|
93
|
-
if (!text) throw new Error("Proactive agent returned empty output");
|
|
94
|
-
if (toolCalls === 0) throw new Error("Proactive agent did not inspect authorized evidence");
|
|
95
|
-
const usage = {
|
|
96
|
-
inputTokens: 0,
|
|
97
|
-
outputTokens: 0,
|
|
98
|
-
estimatedCostUsd: 0
|
|
99
|
-
};
|
|
100
|
-
for (const message of agent.state.messages) {
|
|
101
|
-
if (message.role !== "assistant") continue;
|
|
102
|
-
const reported = message.usage;
|
|
103
|
-
if (reported) {
|
|
104
|
-
usage.inputTokens += reported.input ?? 0;
|
|
105
|
-
usage.outputTokens += reported.output ?? 0;
|
|
106
|
-
usage.estimatedCostUsd += reported.cost?.total ?? 0;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const priced = Object.values(model.cost).some((value) => value > 0);
|
|
110
|
-
return {
|
|
111
|
-
text,
|
|
112
|
-
usage: {
|
|
113
|
-
inputTokens: usage.inputTokens,
|
|
114
|
-
outputTokens: usage.outputTokens,
|
|
115
|
-
...priced ? { estimatedCostUsd: usage.estimatedCostUsd } : {}
|
|
116
|
-
},
|
|
117
|
-
modelRef: `${model.provider}/${model.id}`
|
|
118
|
-
};
|
|
119
|
-
} finally {
|
|
120
|
-
input.signal?.removeEventListener("abort", abort);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
//#endregion
|
|
125
|
-
export { ReadonlyProactiveAgentExecutor };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** Recheck connector consent for stored cards and actions, not just model input. */
|
|
2
|
-
export declare function insightSourcesAuthorized(insightId: string): boolean;
|
|
3
|
-
/** Compare versions, not generated prose, before showing or executing prepared work. */
|
|
4
|
-
export declare function insightSourcesChanged(insightId: string): boolean;
|
|
5
|
-
export declare function authorizedConnectedSource(itemId: string, workspaceId: string, scenarioKey: string, agentId?: string | null): import("../../knowledge/types.js").KnowledgeSourceItem;
|
|
6
|
-
/** Delivery eligibility is stricter than reading historical artifacts. */
|
|
7
|
-
export declare function insightSourcesFresh(insightId: string): boolean;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, init_transaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
-
import { getKnowledgeSourceItem } from "../../storage/sqlite/knowledge-repository.js";
|
|
3
|
-
import { getConnectorSyncPolicyForConnection } from "../../storage/sqlite/connector-sync-policy-repository.js";
|
|
4
|
-
import { sourceFreshness } from "../source-freshness.js";
|
|
5
|
-
import { readMailThread } from "../mail-thread.js";
|
|
6
|
-
//#region src/proactive/execution/authorization.ts
|
|
7
|
-
init_transaction();
|
|
8
|
-
/** Recheck connector consent for stored cards and actions, not just model input. */
|
|
9
|
-
function insightSourcesAuthorized(insightId) {
|
|
10
|
-
const snapshot = getSqliteDatabase().prepare(`SELECT s.workspace_id, x.scenario_key, c.evidence_ids_json
|
|
11
|
-
FROM proactive_insights x JOIN proactive_scenario_subscriptions s USING(subscription_id)
|
|
12
|
-
JOIN proactive_runs r USING(run_id) LEFT JOIN proactive_context_snapshots c ON c.snapshot_id = r.context_snapshot_id
|
|
13
|
-
WHERE x.insight_id = ?`).get(insightId);
|
|
14
|
-
if (snapshot?.evidence_ids_json) {
|
|
15
|
-
if (JSON.parse(snapshot.evidence_ids_json).some((id) => id.startsWith("source-item:") && !authorizedConnectedSource(id.slice(12), snapshot.workspace_id, snapshot.scenario_key))) return false;
|
|
16
|
-
}
|
|
17
|
-
return getSqliteDatabase().prepare(`SELECT e.subject_id, e.workspace_id, x.scenario_key
|
|
18
|
-
FROM proactive_insights x JOIN proactive_runs r USING(run_id)
|
|
19
|
-
JOIN proactive_batch_events be ON be.batch_id = r.batch_id JOIN proactive_events e USING(event_id)
|
|
20
|
-
WHERE x.insight_id = ? AND e.type LIKE 'connected_source.%'`).all(insightId).every((row) => Boolean(authorizedConnectedSource(row.subject_id, row.workspace_id, row.scenario_key)));
|
|
21
|
-
}
|
|
22
|
-
/** Compare versions, not generated prose, before showing or executing prepared work. */
|
|
23
|
-
function insightSourcesChanged(insightId) {
|
|
24
|
-
const db = getSqliteDatabase();
|
|
25
|
-
const row = db.prepare(`SELECT c.content_json FROM proactive_insights x JOIN proactive_runs r USING(run_id)
|
|
26
|
-
JOIN proactive_context_snapshots c ON c.snapshot_id = r.context_snapshot_id WHERE x.insight_id = ?`).get(insightId);
|
|
27
|
-
if (!row) return false;
|
|
28
|
-
const snapshot = JSON.parse(row.content_json);
|
|
29
|
-
if (snapshot.follow_up?.followUpId) {
|
|
30
|
-
const follow = db.prepare("SELECT source_item_id, revision, status, due_at FROM proactive_follow_ups WHERE id = ?").get(snapshot.follow_up.followUpId);
|
|
31
|
-
if (!follow || follow.status !== "watching" || follow.revision !== snapshot.follow_up.revision || Date.parse(follow.due_at) <= Date.now() !== snapshot.follow_up.deadlinePassed || readMailThread(follow.source_item_id)?.fingerprint !== snapshot.follow_up.fingerprint) return true;
|
|
32
|
-
}
|
|
33
|
-
for (const source of [...snapshot.connected_source?.items ?? [], ...snapshot.follow_up?.items ?? []]) {
|
|
34
|
-
const current = getKnowledgeSourceItem(source.sourceItemId);
|
|
35
|
-
if (!current || current.deletedAt || current.contentHash !== source.contentHash || current.occurredAt !== source.occurredAt) return true;
|
|
36
|
-
}
|
|
37
|
-
const project = snapshot.project_state?.project;
|
|
38
|
-
if (project) {
|
|
39
|
-
const current = db.prepare("SELECT updated_at FROM projects WHERE project_id = ?").get(project.project_id);
|
|
40
|
-
if (!current || current.updated_at !== project.updated_at) return true;
|
|
41
|
-
}
|
|
42
|
-
for (const task of [...snapshot.project_state?.activeTasks ?? [], ...snapshot.meeting_workspace?.activeTasks ?? []]) {
|
|
43
|
-
const current = db.prepare("SELECT updated_at FROM tasks WHERE task_id = ?").get(task.task_id);
|
|
44
|
-
if (!current || current.updated_at !== task.updated_at) return true;
|
|
45
|
-
}
|
|
46
|
-
for (const note of snapshot.meeting_workspace?.recentNotes ?? []) {
|
|
47
|
-
const current = db.prepare("SELECT updated_at FROM notes WHERE note_id = ?").get(note.note_id);
|
|
48
|
-
if (!current || current.updated_at !== note.updated_at) return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
function authorizedConnectedSource(itemId, workspaceId, scenarioKey, agentId) {
|
|
53
|
-
const item = getKnowledgeSourceItem(itemId);
|
|
54
|
-
if (!item || item.deletedAt || item.metadata.workspaceId !== workspaceId || item.sensitivity === "secret" || item.sensitivity === "regulated") return null;
|
|
55
|
-
if (agentId && item.metadata.agentId && item.metadata.agentId !== agentId) return null;
|
|
56
|
-
const connectionId = item.metadata.connectionId;
|
|
57
|
-
if (typeof connectionId !== "string") return null;
|
|
58
|
-
if (!getSqliteDatabase().prepare("SELECT 1 FROM connector_connections WHERE id = ? AND status = 'active'").get(connectionId)) return null;
|
|
59
|
-
const policy = getConnectorSyncPolicyForConnection(connectionId);
|
|
60
|
-
return policy?.scanEnabled && policy.proactiveEnabled && (!policy.allowedScenarioKeys.length || policy.allowedScenarioKeys.includes(scenarioKey)) ? item : null;
|
|
61
|
-
}
|
|
62
|
-
/** Delivery eligibility is stricter than reading historical artifacts. */
|
|
63
|
-
function insightSourcesFresh(insightId) {
|
|
64
|
-
const row = getSqliteDatabase().prepare(`SELECT c.evidence_ids_json, c.content_json FROM proactive_insights x JOIN proactive_runs r USING(run_id)
|
|
65
|
-
JOIN proactive_context_snapshots c ON c.snapshot_id = r.context_snapshot_id WHERE x.insight_id = ?`).get(insightId);
|
|
66
|
-
if (!row) return true;
|
|
67
|
-
const follow = JSON.parse(row.content_json).follow_up;
|
|
68
|
-
return JSON.parse(row.evidence_ids_json).every((id) => !id.startsWith("source-item:") || sourceFreshness(id.slice(12), follow?.deadlinePassed ? follow.dueAt : void 0).fresh);
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
export { authorizedConnectedSource, insightSourcesAuthorized, insightSourcesChanged, insightSourcesFresh };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { ContextProvider, ResolvedContext } from './types.js';
|
|
2
|
-
import type { ScenarioDefinition } from '../scenarios/types.js';
|
|
3
|
-
type ContextInput = Parameters<ContextProvider['collect']>[0];
|
|
4
|
-
export declare class EventBatchContextProvider implements ContextProvider {
|
|
5
|
-
readonly id = "event_batch";
|
|
6
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
7
|
-
}
|
|
8
|
-
export declare class ConnectedSourceContextProvider implements ContextProvider {
|
|
9
|
-
readonly id = "connected_source";
|
|
10
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
11
|
-
}
|
|
12
|
-
export declare class InternalObjectContextProvider implements ContextProvider {
|
|
13
|
-
readonly id = "internal_objects";
|
|
14
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
15
|
-
}
|
|
16
|
-
export declare class UserModelContextProvider implements ContextProvider {
|
|
17
|
-
readonly id = "user_model";
|
|
18
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
19
|
-
}
|
|
20
|
-
export declare class MeetingWorkspaceContextProvider implements ContextProvider {
|
|
21
|
-
readonly id = "meeting_workspace";
|
|
22
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
23
|
-
}
|
|
24
|
-
export declare class ProjectStateContextProvider implements ContextProvider {
|
|
25
|
-
readonly id = "project_state";
|
|
26
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
27
|
-
}
|
|
28
|
-
export declare class AutomationStateContextProvider implements ContextProvider {
|
|
29
|
-
readonly id = "automation_state";
|
|
30
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
31
|
-
}
|
|
32
|
-
export declare class DiscussionContextProvider implements ContextProvider {
|
|
33
|
-
readonly id = "discussion";
|
|
34
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
35
|
-
}
|
|
36
|
-
export declare class MailFollowUpContextProvider implements ContextProvider {
|
|
37
|
-
readonly id = "follow_up";
|
|
38
|
-
collect(input: ContextInput): Promise<ResolvedContext>;
|
|
39
|
-
}
|
|
40
|
-
export declare class ContextProviderRegistry {
|
|
41
|
-
private readonly providers;
|
|
42
|
-
constructor(providers?: ContextProvider[]);
|
|
43
|
-
collect(scenario: ScenarioDefinition, input: {
|
|
44
|
-
batchId: string;
|
|
45
|
-
eventIds: string[];
|
|
46
|
-
subscriptionId: string;
|
|
47
|
-
}): Promise<ResolvedContext>;
|
|
48
|
-
}
|
|
49
|
-
export {};
|