@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
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//#region src/scenes/metrics.ts
|
|
2
|
+
/** Explicit feedback is a usefulness signal, not proof of adoption or saved time. */
|
|
3
|
+
var SceneMetrics = class {
|
|
4
|
+
constructor(db, clock = Date.now) {
|
|
5
|
+
this.db = db;
|
|
6
|
+
this.clock = clock;
|
|
7
|
+
}
|
|
8
|
+
diagnostics(principal) {
|
|
9
|
+
if (!principal.ownerId.trim() || !principal.workspaceId.trim()) throw new Error("Scene principal is required");
|
|
10
|
+
const now = this.clock();
|
|
11
|
+
const queue = this.db.prepare(`SELECT COUNT(*) AS depth, MIN(i.due_at) AS oldest
|
|
12
|
+
FROM scene_trigger_intents i JOIN scene_activations a ON a.id = i.activation_id
|
|
13
|
+
WHERE a.owner_id = ? AND a.workspace_id = ? AND i.status = 'pending'`).get(principal.ownerId, principal.workspaceId);
|
|
14
|
+
const usage = this.db.prepare(`SELECT COUNT(*) AS calls, COALESCE(SUM(u.total_tokens), 0) AS tokens,
|
|
15
|
+
COALESCE(SUM(u.estimated_cost), 0) AS cost FROM scene_model_usage u JOIN scene_runs r ON r.id = u.run_id
|
|
16
|
+
JOIN scene_activations a ON a.id = r.activation_id WHERE a.owner_id = ? AND a.workspace_id = ? AND u.recorded_at >= ?`).get(principal.ownerId, principal.workspaceId, now - 7 * 864e5);
|
|
17
|
+
const connectorReads = Number(this.db.prepare(`SELECT COALESCE(SUM(request_count), 0) AS count FROM scene_connector_usage
|
|
18
|
+
WHERE owner_id = ? AND workspace_id = ? AND utc_day >= ?`).get(principal.ownerId, principal.workspaceId, Math.floor(now / 864e5) - 6)?.count);
|
|
19
|
+
const notifications = this.db.prepare(`SELECT status, COUNT(*) AS count FROM notification_dispatches
|
|
20
|
+
WHERE owner_id = ? AND workspace_id = ? GROUP BY status`).all(principal.ownerId, principal.workspaceId);
|
|
21
|
+
const activations = this.db.prepare(`SELECT a.id, a.status,
|
|
22
|
+
(SELECT MAX(created_at) FROM scene_runs WHERE activation_id = a.id) AS last_check_at,
|
|
23
|
+
(SELECT reason FROM scene_runs WHERE activation_id = a.id ORDER BY created_at DESC, id DESC LIMIT 1) AS last_reason,
|
|
24
|
+
CASE WHEN a.status = 'active' THEN (SELECT MIN(next_due_at) FROM scene_schedule_cursors WHERE activation_id = a.id) END AS next_schedule_at,
|
|
25
|
+
(SELECT MIN(due_at) FROM scene_work_items WHERE activation_id = a.id AND status = 'watching') AS deadline_at,
|
|
26
|
+
CASE WHEN a.status = 'active' THEN (SELECT MIN(due_at) FROM scene_work_items WHERE activation_id = a.id AND status = 'watching' AND (last_triggered_revision IS NULL OR last_triggered_revision <> revision)) END AS next_deadline_check_at,
|
|
27
|
+
(SELECT MIN(retry_at) FROM scene_runs WHERE activation_id = a.id AND status = 'retry_wait') AS retry_at,
|
|
28
|
+
(SELECT reason FROM scene_source_health WHERE activation_id = a.id) AS source_reason,
|
|
29
|
+
(SELECT last_attempt_at FROM scene_source_health WHERE activation_id = a.id) AS source_attempt_at,
|
|
30
|
+
(SELECT consecutive_failures FROM scene_source_health WHERE activation_id = a.id) AS source_failures,
|
|
31
|
+
(SELECT last_success_at FROM scene_source_health WHERE activation_id = a.id) AS source_success_at,
|
|
32
|
+
(SELECT retry_at FROM scene_source_health WHERE activation_id = a.id) AS source_retry_at
|
|
33
|
+
FROM scene_activations a WHERE a.owner_id = ? AND a.workspace_id = ? ORDER BY a.id LIMIT 100`).all(principal.ownerId, principal.workspaceId);
|
|
34
|
+
const policyRow = this.db.prepare("SELECT preferences_json FROM scene_preferences WHERE owner_id = ? AND workspace_id = ?").get(principal.ownerId, principal.workspaceId);
|
|
35
|
+
const policy = policyRow ? JSON.parse(String(policyRow.preferences_json)) : {};
|
|
36
|
+
const checksPaused = policy.checksPaused === true || Date.parse(policy.checksPausedUntil ?? "") > now;
|
|
37
|
+
if (checksPaused) for (const activation of activations) {
|
|
38
|
+
activation.next_schedule_at = null;
|
|
39
|
+
activation.next_deadline_check_at = null;
|
|
40
|
+
activation.retry_at = null;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
checksPaused,
|
|
44
|
+
pendingChecks: Number(queue.depth),
|
|
45
|
+
oldestDueWaitMs: queue.oldest == null ? 0 : Math.max(0, now - Number(queue.oldest)),
|
|
46
|
+
lastSevenDays: {
|
|
47
|
+
modelCalls: Number(usage.calls),
|
|
48
|
+
connectorReads,
|
|
49
|
+
tokens: Number(usage.tokens),
|
|
50
|
+
estimatedCost: Number(usage.cost)
|
|
51
|
+
},
|
|
52
|
+
notifications,
|
|
53
|
+
activations
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
forUser(principal, days = 7) {
|
|
57
|
+
if (!principal.ownerId?.trim() || !principal.workspaceId?.trim()) throw new Error("Scene principal is required");
|
|
58
|
+
if (!Number.isInteger(days) || days < 1 || days > 90) throw new Error("Scene metric window must be 1–90 days");
|
|
59
|
+
const until = this.clock();
|
|
60
|
+
const since = until - days * 864e5;
|
|
61
|
+
const feedback = this.db.prepare(`SELECT
|
|
62
|
+
COUNT(*) AS ratedOutcomes,
|
|
63
|
+
COALESCE(SUM(CASE WHEN f.rating = 'useful' THEN 1 ELSE 0 END), 0) AS usefulOutcomes,
|
|
64
|
+
COALESCE(SUM(CASE WHEN f.rating = 'not_useful' THEN 1 ELSE 0 END), 0) AS unhelpfulOutcomes,
|
|
65
|
+
COUNT(DISTINCT CASE WHEN f.rating = 'useful' THEN a.id END) AS scenesWithUsefulOutcomes
|
|
66
|
+
FROM scene_feedback_history f JOIN scene_feedback latest
|
|
67
|
+
ON latest.presentation_id = f.presentation_id AND latest.revision = f.revision
|
|
68
|
+
JOIN scene_presentations p ON p.id = f.presentation_id JOIN scene_outcomes o ON o.id = p.outcome_id
|
|
69
|
+
JOIN scene_runs r ON r.id = o.run_id JOIN scene_activations a ON a.id = r.activation_id
|
|
70
|
+
WHERE a.owner_id = ? AND a.workspace_id = ?
|
|
71
|
+
AND f.recorded_at >= ? AND f.recorded_at < ?`).get(principal.ownerId, principal.workspaceId, since, until);
|
|
72
|
+
const work = this.db.prepare(`SELECT COUNT(*) AS checks,
|
|
73
|
+
COALESCE(SUM(CASE WHEN r.status = 'failed' THEN 1 ELSE 0 END), 0) AS failedChecks,
|
|
74
|
+
COALESCE(SUM(CASE WHEN r.status = 'skipped' THEN 1 ELSE 0 END), 0) AS skippedChecks
|
|
75
|
+
FROM scene_runs r JOIN scene_activations a ON a.id = r.activation_id
|
|
76
|
+
WHERE a.owner_id = ? AND a.workspace_id = ? AND r.created_at >= ? AND r.created_at < ?`).get(principal.ownerId, principal.workspaceId, since, until);
|
|
77
|
+
return {
|
|
78
|
+
window: {
|
|
79
|
+
since,
|
|
80
|
+
until,
|
|
81
|
+
days
|
|
82
|
+
},
|
|
83
|
+
ratedOutcomes: Number(feedback.ratedOutcomes),
|
|
84
|
+
usefulOutcomes: Number(feedback.usefulOutcomes),
|
|
85
|
+
unhelpfulOutcomes: Number(feedback.unhelpfulOutcomes),
|
|
86
|
+
scenesWithUsefulOutcomes: Number(feedback.scenesWithUsefulOutcomes),
|
|
87
|
+
checks: Number(work.checks),
|
|
88
|
+
failedChecks: Number(work.failedChecks),
|
|
89
|
+
skippedChecks: Number(work.skippedChecks)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
94
|
+
export { SceneMetrics };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import type { NotificationResult } from '../notifications/resultOutbox.js';
|
|
3
|
+
export type SceneNotificationEligibility = {
|
|
4
|
+
action: 'cancel';
|
|
5
|
+
reason: string;
|
|
6
|
+
} | {
|
|
7
|
+
action: 'defer';
|
|
8
|
+
until: number;
|
|
9
|
+
} | {
|
|
10
|
+
action: 'eligible';
|
|
11
|
+
activationId: string;
|
|
12
|
+
presentationId: string;
|
|
13
|
+
revision: number;
|
|
14
|
+
kind: string;
|
|
15
|
+
};
|
|
16
|
+
/** Local result eligibility only. The host must still recheck connector authorization and attention policy. */
|
|
17
|
+
export declare function sceneNotificationEligibility(db: DatabaseSync, result: NotificationResult, now: number, expectedRevision?: number): SceneNotificationEligibility;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/scenes/notificationEligibility.ts
|
|
2
|
+
/** Local result eligibility only. The host must still recheck connector authorization and attention policy. */
|
|
3
|
+
function sceneNotificationEligibility(db, result, now, expectedRevision) {
|
|
4
|
+
if (!result.ownerId.trim() || !result.workspaceId.trim() || !result.subjectId.trim()) return {
|
|
5
|
+
action: "cancel",
|
|
6
|
+
reason: "invalid_scope"
|
|
7
|
+
};
|
|
8
|
+
const row = db.prepare(`SELECT p.id, p.status, p.notification_revision, p.withdrawn_at, p.expires_at, p.snoozed_until,
|
|
9
|
+
r.activation_id, r.activation_revision, a.revision, a.status AS activation_status, o.kind
|
|
10
|
+
FROM scene_presentations p JOIN scene_outcomes o ON o.id = p.outcome_id
|
|
11
|
+
JOIN scene_runs r ON r.id = o.run_id JOIN scene_activations a ON a.id = r.activation_id
|
|
12
|
+
WHERE p.id = ? AND p.destination = 'inbox' AND a.owner_id = ? AND a.workspace_id = ?`).get(result.subjectId, result.ownerId, result.workspaceId);
|
|
13
|
+
if (!row) return {
|
|
14
|
+
action: "cancel",
|
|
15
|
+
reason: "result_unavailable"
|
|
16
|
+
};
|
|
17
|
+
if (row.activation_status !== "active") return {
|
|
18
|
+
action: "cancel",
|
|
19
|
+
reason: "activation_inactive"
|
|
20
|
+
};
|
|
21
|
+
if (row.activation_revision !== row.revision) return {
|
|
22
|
+
action: "cancel",
|
|
23
|
+
reason: "activation_changed"
|
|
24
|
+
};
|
|
25
|
+
if (row.kind === "no_change") return {
|
|
26
|
+
action: "cancel",
|
|
27
|
+
reason: "no_change"
|
|
28
|
+
};
|
|
29
|
+
if (expectedRevision !== void 0 && row.notification_revision !== expectedRevision) return {
|
|
30
|
+
action: "cancel",
|
|
31
|
+
reason: "result_changed"
|
|
32
|
+
};
|
|
33
|
+
if (row.withdrawn_at !== null || row.status === "withdrawn") return {
|
|
34
|
+
action: "cancel",
|
|
35
|
+
reason: "result_withdrawn"
|
|
36
|
+
};
|
|
37
|
+
if (row.expires_at !== null && Number(row.expires_at) <= now) return {
|
|
38
|
+
action: "cancel",
|
|
39
|
+
reason: "result_expired"
|
|
40
|
+
};
|
|
41
|
+
if (row.status === "read" || row.status === "resolved") return {
|
|
42
|
+
action: "cancel",
|
|
43
|
+
reason: "result_reviewed"
|
|
44
|
+
};
|
|
45
|
+
if (row.status === "snoozed") {
|
|
46
|
+
if (row.snoozed_until === null) return {
|
|
47
|
+
action: "cancel",
|
|
48
|
+
reason: "invalid_snooze"
|
|
49
|
+
};
|
|
50
|
+
if (Number(row.snoozed_until) > now) return {
|
|
51
|
+
action: "defer",
|
|
52
|
+
until: Number(row.snoozed_until)
|
|
53
|
+
};
|
|
54
|
+
} else if (row.status !== "unread") return {
|
|
55
|
+
action: "cancel",
|
|
56
|
+
reason: "result_unavailable"
|
|
57
|
+
};
|
|
58
|
+
const health = db.prepare("SELECT reason, retry_at FROM scene_source_health WHERE activation_id = ?").get(row.activation_id);
|
|
59
|
+
if (health?.reason) return {
|
|
60
|
+
action: "defer",
|
|
61
|
+
until: Math.max(now + 6e4, Number(health.retry_at ?? 0))
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
action: "eligible",
|
|
65
|
+
activationId: String(row.activation_id),
|
|
66
|
+
presentationId: String(row.id),
|
|
67
|
+
revision: Number(row.notification_revision),
|
|
68
|
+
kind: String(row.kind)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { sceneNotificationEligibility };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { NotificationResultOutbox, type NotificationResult, type PublicationDecision } from '../notifications/resultOutbox.js';
|
|
3
|
+
import { type SceneNotificationEligibility } from './notificationEligibility.js';
|
|
4
|
+
/** The required host callback applies attention policy and persists notification/dispatch records, without sending. */
|
|
5
|
+
export declare function createSceneNotificationOutbox(db: DatabaseSync, publish: (result: NotificationResult, eligible: Extract<SceneNotificationEligibility, {
|
|
6
|
+
action: 'eligible';
|
|
7
|
+
}>) => PublicationDecision, clock?: () => number): NotificationResultOutbox;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ScenePreferenceService, sceneChecksAllowed } from "./preferences.js";
|
|
2
|
+
import { notificationQuietUntil } from "../notifications/quietHours.js";
|
|
3
|
+
import { NotificationResultOutbox } from "../notifications/resultOutbox.js";
|
|
4
|
+
import { sceneNotificationEligibility } from "./notificationEligibility.js";
|
|
5
|
+
//#region src/scenes/notificationPublication.ts
|
|
6
|
+
/** The required host callback applies attention policy and persists notification/dispatch records, without sending. */
|
|
7
|
+
function createSceneNotificationOutbox(db, publish, clock = Date.now) {
|
|
8
|
+
return new NotificationResultOutbox(db, (result) => {
|
|
9
|
+
const now = clock();
|
|
10
|
+
const eligibility = sceneNotificationEligibility(db, result, now);
|
|
11
|
+
if (eligibility.action === "cancel") return {
|
|
12
|
+
action: "settle",
|
|
13
|
+
reason: eligibility.reason
|
|
14
|
+
};
|
|
15
|
+
if (eligibility.action === "defer") return {
|
|
16
|
+
...eligibility,
|
|
17
|
+
reason: "result_snoozed"
|
|
18
|
+
};
|
|
19
|
+
const preferences = new ScenePreferenceService(db).get(result);
|
|
20
|
+
if (!sceneChecksAllowed(preferences, now)) return {
|
|
21
|
+
action: "settle",
|
|
22
|
+
reason: "checks_paused"
|
|
23
|
+
};
|
|
24
|
+
if (preferences.notificationsMuted || preferences.level === "quiet") return {
|
|
25
|
+
action: "settle",
|
|
26
|
+
reason: "notifications_muted"
|
|
27
|
+
};
|
|
28
|
+
if (preferences.suppressWhileViewing && db.prepare(`SELECT 1 FROM notification_presence
|
|
29
|
+
WHERE owner_id = ? AND workspace_id = ? AND subject_id = ? AND subject_revision = ? AND expires_at > ?`).get(result.ownerId, result.workspaceId, result.subjectId, eligibility.revision, now)) return {
|
|
30
|
+
action: "settle",
|
|
31
|
+
reason: "result_viewed"
|
|
32
|
+
};
|
|
33
|
+
const quietUntil = notificationQuietUntil(preferences, now);
|
|
34
|
+
if (quietUntil !== null) return {
|
|
35
|
+
action: "defer",
|
|
36
|
+
until: quietUntil,
|
|
37
|
+
reason: "quiet_hours"
|
|
38
|
+
};
|
|
39
|
+
return publish(result, eligibility);
|
|
40
|
+
}, clock);
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { createSceneNotificationOutbox };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { ScenePrincipal } from './contracts.js';
|
|
4
|
+
export declare const scenePreferencesSchema: z.ZodObject<{
|
|
5
|
+
level: z.ZodDefault<z.ZodEnum<{
|
|
6
|
+
active: "active";
|
|
7
|
+
quiet: "quiet";
|
|
8
|
+
balanced: "balanced";
|
|
9
|
+
}>>;
|
|
10
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
11
|
+
quietStartHour: z.ZodDefault<z.ZodNumber>;
|
|
12
|
+
quietEndHour: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
dailyNotificationLimit: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
digestEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
digestHour: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
digestMinute: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
preferredChannel: z.ZodDefault<z.ZodEnum<{
|
|
18
|
+
browser: "browser";
|
|
19
|
+
in_app: "in_app";
|
|
20
|
+
}>>;
|
|
21
|
+
suppressWhileViewing: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
checksPaused: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
+
checksPausedUntil: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
24
|
+
notificationsMuted: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type ScenePreferences = z.infer<typeof scenePreferencesSchema>;
|
|
27
|
+
/** Owner-scoped choices. Muting presentation never changes check permissions or deletes work. */
|
|
28
|
+
export declare class ScenePreferenceService {
|
|
29
|
+
private readonly db;
|
|
30
|
+
constructor(db: DatabaseSync);
|
|
31
|
+
get(principal: ScenePrincipal): ScenePreferences & {
|
|
32
|
+
revision: number;
|
|
33
|
+
};
|
|
34
|
+
update(principal: ScenePrincipal, value: unknown): ScenePreferences & {
|
|
35
|
+
revision: number;
|
|
36
|
+
};
|
|
37
|
+
recordPresence(principal: ScenePrincipal, value: unknown, now?: number): void;
|
|
38
|
+
private assertPrincipal;
|
|
39
|
+
}
|
|
40
|
+
export declare function sceneChecksAllowed(preferences: ScenePreferences, now: number): boolean;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { SceneConflictError, SceneNotFoundError } from "./repository.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/scenes/preferences.ts
|
|
4
|
+
const hour = z.number().int().min(0).max(23);
|
|
5
|
+
const scenePreferencesSchema = z.strictObject({
|
|
6
|
+
level: z.enum([
|
|
7
|
+
"quiet",
|
|
8
|
+
"balanced",
|
|
9
|
+
"active"
|
|
10
|
+
]).default("balanced"),
|
|
11
|
+
timezone: z.string().min(1).max(100).refine((value) => {
|
|
12
|
+
try {
|
|
13
|
+
new Intl.DateTimeFormat("en", { timeZone: value });
|
|
14
|
+
return true;
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}).default("Asia/Shanghai"),
|
|
19
|
+
quietStartHour: hour.default(22),
|
|
20
|
+
quietEndHour: hour.default(8),
|
|
21
|
+
dailyNotificationLimit: z.number().int().min(0).max(30).default(3),
|
|
22
|
+
digestEnabled: z.boolean().default(false),
|
|
23
|
+
digestHour: hour.default(18),
|
|
24
|
+
digestMinute: z.number().int().min(0).max(59).default(0),
|
|
25
|
+
preferredChannel: z.enum(["in_app", "browser"]).default("browser"),
|
|
26
|
+
suppressWhileViewing: z.boolean().default(true),
|
|
27
|
+
checksPaused: z.boolean().default(false),
|
|
28
|
+
checksPausedUntil: z.string().datetime({ offset: true }).nullable().default(null),
|
|
29
|
+
notificationsMuted: z.boolean().default(false)
|
|
30
|
+
});
|
|
31
|
+
/** Owner-scoped choices. Muting presentation never changes check permissions or deletes work. */
|
|
32
|
+
var ScenePreferenceService = class {
|
|
33
|
+
constructor(db) {
|
|
34
|
+
this.db = db;
|
|
35
|
+
}
|
|
36
|
+
get(principal) {
|
|
37
|
+
this.assertPrincipal(principal);
|
|
38
|
+
const row = this.db.prepare("SELECT preferences_json, revision FROM scene_preferences WHERE owner_id = ? AND workspace_id = ?").get(principal.ownerId, principal.workspaceId);
|
|
39
|
+
return {
|
|
40
|
+
...scenePreferencesSchema.parse(row ? JSON.parse(String(row.preferences_json)) : {}),
|
|
41
|
+
revision: row ? Number(row.revision) : 0
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
update(principal, value) {
|
|
45
|
+
this.assertPrincipal(principal);
|
|
46
|
+
const supplied = z.record(z.string(), z.unknown()).parse(value);
|
|
47
|
+
const { expectedRevision, ...parsed } = scenePreferencesSchema.partial().extend({ expectedRevision: z.number().int().nonnegative() }).parse(value);
|
|
48
|
+
const patch = Object.fromEntries(Object.entries(parsed).filter(([key]) => Object.hasOwn(supplied, key) && supplied[key] !== void 0));
|
|
49
|
+
this.db.exec("SAVEPOINT scene_preferences_write");
|
|
50
|
+
try {
|
|
51
|
+
const { revision, ...current } = this.get(principal);
|
|
52
|
+
if (revision !== expectedRevision) throw new SceneConflictError("Scene preferences changed");
|
|
53
|
+
const next = scenePreferencesSchema.parse({
|
|
54
|
+
...current,
|
|
55
|
+
...patch
|
|
56
|
+
});
|
|
57
|
+
this.db.prepare(`INSERT INTO scene_preferences(owner_id, workspace_id, preferences_json, revision) VALUES (?, ?, ?, ?)
|
|
58
|
+
ON CONFLICT(owner_id, workspace_id) DO UPDATE SET preferences_json = excluded.preferences_json, revision = excluded.revision`).run(principal.ownerId, principal.workspaceId, JSON.stringify(next), revision + 1);
|
|
59
|
+
if (next.checksPaused !== current.checksPaused || next.checksPausedUntil !== current.checksPausedUntil) {
|
|
60
|
+
this.db.prepare("UPDATE scene_activations SET revision = revision + 1 WHERE owner_id = ? AND workspace_id = ? AND status = 'active'").run(principal.ownerId, principal.workspaceId);
|
|
61
|
+
this.db.prepare(`UPDATE scene_runs SET status = 'cancelled', reason = 'check_policy_changed', lease_epoch = lease_epoch + 1,
|
|
62
|
+
lease_owner = NULL, lease_until = NULL WHERE status IN ('running', 'retry_wait') AND activation_id IN
|
|
63
|
+
(SELECT id FROM scene_activations WHERE owner_id = ? AND workspace_id = ?)`).run(principal.ownerId, principal.workspaceId);
|
|
64
|
+
this.db.prepare(`UPDATE scene_trigger_intents SET status = 'cancelled' WHERE status IN ('pending', 'claimed') AND activation_id IN
|
|
65
|
+
(SELECT id FROM scene_activations WHERE owner_id = ? AND workspace_id = ?)`).run(principal.ownerId, principal.workspaceId);
|
|
66
|
+
}
|
|
67
|
+
this.db.exec("RELEASE scene_preferences_write");
|
|
68
|
+
return {
|
|
69
|
+
...next,
|
|
70
|
+
revision: revision + 1
|
|
71
|
+
};
|
|
72
|
+
} catch (error) {
|
|
73
|
+
this.db.exec("ROLLBACK TO scene_preferences_write");
|
|
74
|
+
this.db.exec("RELEASE scene_preferences_write");
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
recordPresence(principal, value, now = Date.now()) {
|
|
79
|
+
this.assertPrincipal(principal);
|
|
80
|
+
const input = z.strictObject({
|
|
81
|
+
clientId: z.string().trim().min(1).max(100),
|
|
82
|
+
surface: z.enum(["web", "electron"]),
|
|
83
|
+
presentationId: z.string().min(1).max(200),
|
|
84
|
+
visible: z.boolean()
|
|
85
|
+
}).parse(value);
|
|
86
|
+
if (!input.visible) {
|
|
87
|
+
this.db.prepare("DELETE FROM notification_presence WHERE owner_id = ? AND workspace_id = ? AND client_id = ?").run(principal.ownerId, principal.workspaceId, input.clientId);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const row = this.db.prepare(`SELECT p.notification_revision FROM scene_presentations p
|
|
91
|
+
JOIN scene_outcomes o ON o.id = p.outcome_id JOIN scene_runs r ON r.id = o.run_id
|
|
92
|
+
JOIN scene_activations a ON a.id = r.activation_id
|
|
93
|
+
WHERE p.id = ? AND a.owner_id = ? AND a.workspace_id = ? AND p.withdrawn_at IS NULL`).get(input.presentationId, principal.ownerId, principal.workspaceId);
|
|
94
|
+
if (!row) throw new SceneNotFoundError("Scene result not found");
|
|
95
|
+
this.db.prepare(`INSERT INTO notification_presence VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
96
|
+
ON CONFLICT(owner_id, workspace_id, client_id) DO UPDATE SET surface = excluded.surface,
|
|
97
|
+
expires_at = excluded.expires_at, subject_id = excluded.subject_id, subject_revision = excluded.subject_revision`).run(principal.ownerId, principal.workspaceId, input.clientId, input.surface, now + 45e3, input.presentationId, row.notification_revision);
|
|
98
|
+
this.db.prepare("DELETE FROM notification_presence WHERE expires_at <= ?").run(now);
|
|
99
|
+
}
|
|
100
|
+
assertPrincipal(principal) {
|
|
101
|
+
if (!principal.ownerId.trim() || !principal.workspaceId.trim()) throw new Error("Scene principal is required");
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function sceneChecksAllowed(preferences, now) {
|
|
105
|
+
return !preferences.checksPaused && !(preferences.checksPausedUntil && Date.parse(preferences.checksPausedUntil) > now);
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { ScenePreferenceService, sceneChecksAllowed, scenePreferencesSchema };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type SceneSourceFailure = 'source_not_ready' | 'needs_permission' | 'source_rate_limited' | 'source_timeout';
|
|
2
|
+
/** A source failure is separate from a model execution failure. */
|
|
3
|
+
export declare class SceneSourceNotReady extends Error {
|
|
4
|
+
readonly reason: SceneSourceFailure;
|
|
5
|
+
constructor(reason?: SceneSourceFailure);
|
|
6
|
+
}
|
|
7
|
+
export declare function sceneSourceFailureReason(error: unknown): SceneSourceFailure;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/scenes/readiness.ts
|
|
2
|
+
/** A source failure is separate from a model execution failure. */
|
|
3
|
+
var SceneSourceNotReady = class extends Error {
|
|
4
|
+
constructor(reason = "source_not_ready") {
|
|
5
|
+
super("Scene source is stale or not synchronized yet");
|
|
6
|
+
this.reason = reason;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
function sceneSourceFailureReason(error) {
|
|
10
|
+
if (error instanceof SceneSourceNotReady) return error.reason;
|
|
11
|
+
const value = error;
|
|
12
|
+
const status = Number(value?.statusCode ?? value?.status);
|
|
13
|
+
const message = typeof error === "string" ? error : value?.message ?? "";
|
|
14
|
+
if (status === 429 || /\b429\b|rate.?limit|too many requests/i.test(message)) return "source_rate_limited";
|
|
15
|
+
if (status === 401 || status === 403 || /\b401\b|\b403\b|permission|authorization|authorized|access|token.*expired|invalid.grant/i.test(message)) return "needs_permission";
|
|
16
|
+
if (value?.name === "AbortError" || value?.name === "TimeoutError" || /timed out|timeout/i.test(message)) return "source_timeout";
|
|
17
|
+
return "source_not_ready";
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SceneSourceNotReady, sceneSourceFailureReason };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { SceneModelUsage } from './contracts.js';
|
|
2
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
3
|
+
import { type ActivationStatus, type SceneActivation, type ScenePrincipal, type SceneTemplate } from './contracts.js';
|
|
4
|
+
export interface SceneEventInput {
|
|
5
|
+
source: string;
|
|
6
|
+
sourceEventId: string;
|
|
7
|
+
eventType: string;
|
|
8
|
+
subjectId: string;
|
|
9
|
+
occurredAt: number;
|
|
10
|
+
accountId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SceneRunClaim {
|
|
13
|
+
id: string;
|
|
14
|
+
intentId: string;
|
|
15
|
+
activationId: string;
|
|
16
|
+
activationRevision: number;
|
|
17
|
+
leaseOwner: string;
|
|
18
|
+
leaseEpoch: number;
|
|
19
|
+
attempt: number;
|
|
20
|
+
}
|
|
21
|
+
export interface SceneWorkItem {
|
|
22
|
+
id: string;
|
|
23
|
+
activationId: string;
|
|
24
|
+
subjectId: string;
|
|
25
|
+
accountId: string;
|
|
26
|
+
dueAt: number;
|
|
27
|
+
revision: number;
|
|
28
|
+
status: 'watching' | 'paused' | 'completed';
|
|
29
|
+
}
|
|
30
|
+
export declare class SceneConflictError extends Error {
|
|
31
|
+
}
|
|
32
|
+
export declare class SceneNotFoundError extends Error {
|
|
33
|
+
}
|
|
34
|
+
export declare class SceneInputError extends Error {
|
|
35
|
+
}
|
|
36
|
+
/** The caller supplies the database; storage is initialized by the normal database upgrade. */
|
|
37
|
+
export declare class SceneRepository {
|
|
38
|
+
private readonly db;
|
|
39
|
+
constructor(db: DatabaseSync);
|
|
40
|
+
private transaction;
|
|
41
|
+
installTemplate(value: unknown): SceneTemplate;
|
|
42
|
+
getTemplate(key: string, version: string): SceneTemplate;
|
|
43
|
+
listTemplates(): SceneTemplate[];
|
|
44
|
+
listRuns(principal: ScenePrincipal, activationId: string, limit?: number, afterId?: string): Record<string, import("node:sqlite").SQLOutputValue>[];
|
|
45
|
+
createActivation(principal: ScenePrincipal, value: unknown, requestId?: string): SceneActivation;
|
|
46
|
+
listActivations(principal: ScenePrincipal, limit?: number, afterId?: string): SceneActivation[];
|
|
47
|
+
getActivation(principal: ScenePrincipal, id: string): SceneActivation;
|
|
48
|
+
recordSourceHealth(activation: SceneActivation, reason: string | null, now: number, retryAt?: number | null): void;
|
|
49
|
+
getSourceHealth(activationId: string): Record<string, import("node:sqlite").SQLOutputValue>;
|
|
50
|
+
reuseUnchangedResult(claim: SceneRunClaim, hash: string, now: number, inspectOnly?: boolean): boolean;
|
|
51
|
+
/** Configuration edits require a fresh preflight before any execution resumes. */
|
|
52
|
+
configureActivation(principal: ScenePrincipal, id: string, revision: number, value: unknown): SceneActivation;
|
|
53
|
+
writeNotes(principal: ScenePrincipal, id: string, value: unknown, now: number): number;
|
|
54
|
+
readNotes(principal: ScenePrincipal, id: string): Record<string, import("node:sqlite").SQLOutputValue>;
|
|
55
|
+
listWorkItems(principal: ScenePrincipal, activationId: string, limit?: number, afterId?: string): Record<string, import("node:sqlite").SQLOutputValue>[];
|
|
56
|
+
listSchedules(principal: ScenePrincipal, activationId: string): {
|
|
57
|
+
triggerKey: string;
|
|
58
|
+
schedule: {
|
|
59
|
+
weekdays: number[];
|
|
60
|
+
hour: number;
|
|
61
|
+
minute: number;
|
|
62
|
+
timeZone: string;
|
|
63
|
+
};
|
|
64
|
+
revision: number;
|
|
65
|
+
nextDueAt: number;
|
|
66
|
+
}[];
|
|
67
|
+
createWorkItem(principal: ScenePrincipal, activationId: string, input: {
|
|
68
|
+
subjectId: string;
|
|
69
|
+
accountId: string;
|
|
70
|
+
dueAt: number;
|
|
71
|
+
}, now: number): SceneWorkItem;
|
|
72
|
+
/** Internal worker scan; identity comes from persisted ownership, never an event payload. */
|
|
73
|
+
recordModelUsage(claim: SceneRunClaim, usage: SceneModelUsage, now: number): void;
|
|
74
|
+
listMailObservationItems(afterId?: string, now?: number): Array<{
|
|
75
|
+
principal: ScenePrincipal;
|
|
76
|
+
item: SceneWorkItem;
|
|
77
|
+
}>;
|
|
78
|
+
isMailObservationCurrent(activation: SceneActivation, item: SceneWorkItem, now?: number): boolean;
|
|
79
|
+
observeMailWorkItem(principal: ScenePrincipal, item: SceneWorkItem, fingerprint: string, now: number): boolean;
|
|
80
|
+
/** Revision changes invalidate only this item's pending work and visible results. */
|
|
81
|
+
updateWorkItem(principal: ScenePrincipal, id: string, input: {
|
|
82
|
+
expectedRevision: number;
|
|
83
|
+
status?: SceneWorkItem['status'];
|
|
84
|
+
dueAt?: number;
|
|
85
|
+
}, now: number): SceneWorkItem;
|
|
86
|
+
/** Due dates are durable; restarting cannot generate a second occurrence. */
|
|
87
|
+
enqueueDueWorkItems(now: number): number;
|
|
88
|
+
transitionActivation(principal: ScenePrincipal, id: string, revision: number, status: ActivationStatus, now?: number): SceneActivation;
|
|
89
|
+
setSchedule(principal: ScenePrincipal, activationId: string, triggerKey: string, expectedRevision: number, value: unknown, now: number): number;
|
|
90
|
+
/** Coalesces missed occurrences into at most one bounded catch-up per schedule. */
|
|
91
|
+
enqueueDueSchedules(now: number): number;
|
|
92
|
+
/** Called by an authorized producer inside its domain transaction when applicable. */
|
|
93
|
+
acceptTrigger(principal: ScenePrincipal, activationId: string, input: {
|
|
94
|
+
event: SceneEventInput;
|
|
95
|
+
triggerKey: string;
|
|
96
|
+
occurrenceKey: string;
|
|
97
|
+
dueAt: number;
|
|
98
|
+
}, now: number): string;
|
|
99
|
+
acceptManualCheck(principal: ScenePrincipal, activationId: string, triggerKey: string, requestId: string, now: number): string;
|
|
100
|
+
claimNext(worker: string, now: number, leaseMs?: number): SceneRunClaim | null;
|
|
101
|
+
renewLease(claim: SceneRunClaim, now: number, leaseMs: number): boolean;
|
|
102
|
+
reserveModelCall(claim: SceneRunClaim, now: number, limits?: {
|
|
103
|
+
activation: number;
|
|
104
|
+
owner: number;
|
|
105
|
+
}): boolean;
|
|
106
|
+
deferRun(claim: SceneRunClaim, now: number, reason: 'source_not_ready' | 'daily_budget', retryAt: number): 'deferred' | 'failed' | 'discarded';
|
|
107
|
+
getRunInput(claim: SceneRunClaim, now: number): {
|
|
108
|
+
activation: SceneActivation;
|
|
109
|
+
subjectId: string;
|
|
110
|
+
accountId?: string;
|
|
111
|
+
notBefore?: number;
|
|
112
|
+
} | null;
|
|
113
|
+
saveSnapshot(claim: SceneRunClaim, hash: string, evidenceIds: string[], now: number): boolean;
|
|
114
|
+
finishReadOnlyRun(claim: SceneRunClaim, result: {
|
|
115
|
+
kind: 'no_change' | 'observation' | 'artifact' | 'decision';
|
|
116
|
+
summary: string;
|
|
117
|
+
evidenceIds: string[];
|
|
118
|
+
}, now: number): boolean;
|
|
119
|
+
listInbox(principal: ScenePrincipal, limit?: number, afterId?: string, activationId?: string | null): {
|
|
120
|
+
createdAt: number;
|
|
121
|
+
sources: {
|
|
122
|
+
kind: string;
|
|
123
|
+
title: string;
|
|
124
|
+
sender: string;
|
|
125
|
+
href: string;
|
|
126
|
+
}[];
|
|
127
|
+
sourceHealth: Record<string, import("node:sqlite").SQLOutputValue>;
|
|
128
|
+
id: string;
|
|
129
|
+
activationId: string;
|
|
130
|
+
outcomeId: string;
|
|
131
|
+
content: unknown;
|
|
132
|
+
status: string;
|
|
133
|
+
readOnly: boolean;
|
|
134
|
+
}[];
|
|
135
|
+
getPresentation(principal: ScenePrincipal, id: string): {
|
|
136
|
+
createdAt: number;
|
|
137
|
+
sources: {
|
|
138
|
+
kind: string;
|
|
139
|
+
title: string;
|
|
140
|
+
sender: string;
|
|
141
|
+
href: string;
|
|
142
|
+
}[];
|
|
143
|
+
sourceHealth: Record<string, import("node:sqlite").SQLOutputValue>;
|
|
144
|
+
id: string;
|
|
145
|
+
activationId: string;
|
|
146
|
+
outcomeId: string;
|
|
147
|
+
content: unknown;
|
|
148
|
+
status: string;
|
|
149
|
+
readOnly: boolean;
|
|
150
|
+
};
|
|
151
|
+
listDigestResults(principal: ScenePrincipal, digestId: string, limit?: number, afterId?: string): {
|
|
152
|
+
outcomes: {
|
|
153
|
+
createdAt: number;
|
|
154
|
+
sources: {
|
|
155
|
+
kind: string;
|
|
156
|
+
title: string;
|
|
157
|
+
sender: string;
|
|
158
|
+
href: string;
|
|
159
|
+
}[];
|
|
160
|
+
sourceHealth: Record<string, import("node:sqlite").SQLOutputValue>;
|
|
161
|
+
id: string;
|
|
162
|
+
activationId: string;
|
|
163
|
+
outcomeId: string;
|
|
164
|
+
content: unknown;
|
|
165
|
+
status: string;
|
|
166
|
+
readOnly: boolean;
|
|
167
|
+
}[];
|
|
168
|
+
nextCursor: string;
|
|
169
|
+
};
|
|
170
|
+
failRun(claim: SceneRunClaim, now: number, reason: string, retryAt?: number): boolean;
|
|
171
|
+
private isCurrentClaim;
|
|
172
|
+
private readClaim;
|
|
173
|
+
private assertPrincipal;
|
|
174
|
+
}
|