@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,142 @@
|
|
|
1
|
+
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../../../utils/logger.js";
|
|
3
|
+
import { SceneConflictError, SceneInputError, SceneNotFoundError } from "../../../scenes/repository.js";
|
|
4
|
+
import { SceneSetupError } from "../../../scenes/service.js";
|
|
5
|
+
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { Hono } from "hono";
|
|
8
|
+
//#region src/gateway/hono/routes/scenes.ts
|
|
9
|
+
init_logger();
|
|
10
|
+
const log = createLogger("Hono:Scenes");
|
|
11
|
+
const requestIdentity = z.string().trim().min(1).max(200);
|
|
12
|
+
const pageSchema = z.strictObject({
|
|
13
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
14
|
+
afterId: z.string().max(200).default("")
|
|
15
|
+
});
|
|
16
|
+
function registerSceneRoutes(authenticated, deps) {
|
|
17
|
+
const app = new Hono();
|
|
18
|
+
app.onError((error, c) => {
|
|
19
|
+
if (error instanceof SceneNotFoundError) return c.json({ error: "scene_not_found" }, 404);
|
|
20
|
+
if (error instanceof SceneConflictError) return c.json({
|
|
21
|
+
error: "scene_changed",
|
|
22
|
+
message: error.message
|
|
23
|
+
}, 409);
|
|
24
|
+
if (error instanceof SceneSetupError) return c.json({
|
|
25
|
+
error: "scene_needs_setup",
|
|
26
|
+
message: error.message,
|
|
27
|
+
missing: error.missing
|
|
28
|
+
}, 422);
|
|
29
|
+
if (error instanceof z.ZodError || error instanceof SyntaxError || error instanceof SceneInputError) return c.json({ error: "invalid_scene_input" }, 400);
|
|
30
|
+
log.error({
|
|
31
|
+
err: error,
|
|
32
|
+
phase: "scene_request"
|
|
33
|
+
}, "Scene request failed");
|
|
34
|
+
return c.json({ error: "scene_request_failed" }, 500);
|
|
35
|
+
});
|
|
36
|
+
app.use("*", async (c, next) => {
|
|
37
|
+
if (!deps.scenes) return c.json({ error: "scene_runtime_not_installed" }, 503);
|
|
38
|
+
await next();
|
|
39
|
+
});
|
|
40
|
+
const principal = (c) => ({
|
|
41
|
+
ownerId: getGatewayPrincipal(c).scopes.includes("gateway.admin") ? "local-owner" : getGatewayPrincipal(c).principalId,
|
|
42
|
+
workspaceId: deps.service.currentWorkspacePath
|
|
43
|
+
});
|
|
44
|
+
app.post("/browser/prepare", deps.strictRateLimitMiddleware, (c) => c.json(deps.scenes.browser.prepare()));
|
|
45
|
+
app.post("/browser/subscriptions", deps.strictRateLimitMiddleware, async (c) => c.json(deps.scenes.browser.register(principal(c), await c.req.json()), 201));
|
|
46
|
+
app.delete("/browser/subscriptions/:id", deps.strictRateLimitMiddleware, (c) => {
|
|
47
|
+
deps.scenes.browser.remove(principal(c), c.req.param("id"));
|
|
48
|
+
return c.json({ ok: true });
|
|
49
|
+
});
|
|
50
|
+
app.get("/preferences", (c) => c.json(deps.scenes.preferences.get(principal(c))));
|
|
51
|
+
app.patch("/preferences", deps.strictRateLimitMiddleware, async (c) => c.json(deps.scenes.preferences.update(principal(c), await c.req.json())));
|
|
52
|
+
app.post("/presence", deps.strictRateLimitMiddleware, async (c) => {
|
|
53
|
+
deps.scenes.preferences.recordPresence(principal(c), await c.req.json());
|
|
54
|
+
return c.json({ ok: true });
|
|
55
|
+
});
|
|
56
|
+
app.get("/templates", (c) => c.json({ templates: deps.scenes.repository.listTemplates() }));
|
|
57
|
+
app.get("/diagnostics", (c) => c.json(deps.scenes.metrics.diagnostics(principal(c))));
|
|
58
|
+
app.get("/metrics", (c) => {
|
|
59
|
+
const { days } = z.strictObject({ days: z.coerce.number().int().min(1).max(90).default(7) }).parse(c.req.query());
|
|
60
|
+
return c.json(deps.scenes.metrics.forUser(principal(c), days));
|
|
61
|
+
});
|
|
62
|
+
app.get("/sources/mail/accounts", (c) => c.json({ accounts: deps.scenes.mailDiscovery?.listAccounts(principal(c)) ?? [] }));
|
|
63
|
+
app.post("/sources/mail/search", deps.strictRateLimitMiddleware, async (c) => {
|
|
64
|
+
if (!deps.scenes.mailDiscovery) return c.json({ error: "mail_search_unavailable" }, 503);
|
|
65
|
+
const signal = AbortSignal.any([c.req.raw.signal, AbortSignal.timeout(15e3)]);
|
|
66
|
+
return c.json({ sources: await deps.scenes.mailDiscovery.searchSources(principal(c), await c.req.json(), signal) });
|
|
67
|
+
});
|
|
68
|
+
app.get("/sources/mail", (c) => {
|
|
69
|
+
const { limit, afterId } = pageSchema.parse(c.req.query());
|
|
70
|
+
const sources = deps.scenes.mail.listSources(principal(c), limit, afterId);
|
|
71
|
+
return c.json({
|
|
72
|
+
sources,
|
|
73
|
+
nextCursor: sources.length === limit ? sources.at(-1).id : null
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
app.get("/templates/:key/versions/:version", (c) => c.json({ template: deps.scenes.repository.getTemplate(c.req.param("key"), c.req.param("version")) }));
|
|
77
|
+
app.post("/preflight", deps.strictRateLimitMiddleware, async (c) => c.json(await deps.scenes.application.preflight(principal(c), await c.req.json())));
|
|
78
|
+
app.get("/activations", (c) => {
|
|
79
|
+
const { limit, afterId } = pageSchema.parse(c.req.query());
|
|
80
|
+
const activations = deps.scenes.repository.listActivations(principal(c), limit, afterId);
|
|
81
|
+
return c.json({
|
|
82
|
+
activations,
|
|
83
|
+
nextCursor: activations.length === limit ? activations.at(-1).id : null
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
app.post("/activations", deps.strictRateLimitMiddleware, async (c) => {
|
|
87
|
+
const requestId = requestIdentity.parse(c.req.header("Idempotency-Key"));
|
|
88
|
+
return c.json({ activation: await deps.scenes.application.start(principal(c), await c.req.json(), requestId) }, 201);
|
|
89
|
+
});
|
|
90
|
+
app.get("/activations/:id", (c) => c.json({ activation: deps.scenes.repository.getActivation(principal(c), c.req.param("id")) }));
|
|
91
|
+
app.patch("/activations/:id", deps.strictRateLimitMiddleware, async (c) => {
|
|
92
|
+
const body = await c.req.json();
|
|
93
|
+
const activation = typeof body === "object" && body !== null && Object.hasOwn(body, "status") ? await deps.scenes.application.transition(principal(c), c.req.param("id"), body) : deps.scenes.application.configure(principal(c), c.req.param("id"), body);
|
|
94
|
+
return c.json({ activation });
|
|
95
|
+
});
|
|
96
|
+
app.post("/activations/:id/checks", deps.strictRateLimitMiddleware, (c) => c.json({ intentId: deps.scenes.application.check(principal(c), c.req.param("id"), requestIdentity.parse(c.req.header("Idempotency-Key"))) }, 202));
|
|
97
|
+
app.get("/activations/:id/runs", (c) => {
|
|
98
|
+
const { limit, afterId } = pageSchema.parse(c.req.query());
|
|
99
|
+
const runs = deps.scenes.repository.listRuns(principal(c), c.req.param("id"), limit, afterId);
|
|
100
|
+
return c.json({
|
|
101
|
+
runs,
|
|
102
|
+
nextCursor: runs.length === limit ? runs.at(-1).id : null
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
app.patch("/activations/:id/notes", deps.strictRateLimitMiddleware, async (c) => c.json({ revision: deps.scenes.application.writeNotes(principal(c), c.req.param("id"), await c.req.json()) }));
|
|
106
|
+
app.get("/activations/:id/notes", (c) => c.json({ notes: deps.scenes.repository.readNotes(principal(c), c.req.param("id")) }));
|
|
107
|
+
app.get("/activations/:id/work-items", (c) => {
|
|
108
|
+
const { limit, afterId } = pageSchema.parse(c.req.query());
|
|
109
|
+
const workItems = deps.scenes.repository.listWorkItems(principal(c), c.req.param("id"), limit, afterId);
|
|
110
|
+
return c.json({
|
|
111
|
+
workItems,
|
|
112
|
+
nextCursor: workItems.length === limit ? workItems.at(-1).id : null
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
app.post("/activations/:id/work-items", deps.strictRateLimitMiddleware, async (c) => c.json({ workItem: deps.scenes.application.createWorkItem(principal(c), c.req.param("id"), await c.req.json()) }, 201));
|
|
116
|
+
app.get("/activations/:id/schedules", (c) => c.json({ schedules: deps.scenes.repository.listSchedules(principal(c), c.req.param("id")) }));
|
|
117
|
+
app.patch("/activations/:id/schedules/:triggerKey", deps.strictRateLimitMiddleware, async (c) => c.json({ revision: deps.scenes.application.setSchedule(principal(c), c.req.param("id"), c.req.param("triggerKey"), await c.req.json()) }));
|
|
118
|
+
app.patch("/work-items/:id", deps.strictRateLimitMiddleware, async (c) => c.json({ workItem: deps.scenes.application.updateWorkItem(principal(c), c.req.param("id"), await c.req.json()) }));
|
|
119
|
+
app.get("/outcomes", (c) => {
|
|
120
|
+
const { limit, afterId, activationId } = pageSchema.extend({ activationId: requestIdentity.optional() }).parse(c.req.query());
|
|
121
|
+
const outcomes = deps.scenes.repository.listInbox(principal(c), limit, afterId, activationId ?? null);
|
|
122
|
+
return c.json({
|
|
123
|
+
outcomes,
|
|
124
|
+
nextCursor: outcomes.length === limit ? outcomes.at(-1).id : null
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
app.get("/digests/:id", (c) => {
|
|
128
|
+
const { limit, afterId } = pageSchema.parse(c.req.query());
|
|
129
|
+
return c.json(deps.scenes.repository.listDigestResults(principal(c), c.req.param("id"), limit, afterId));
|
|
130
|
+
});
|
|
131
|
+
app.get("/presentations/:id/feedback", (c) => c.json({ feedback: deps.scenes.inbox.getFeedback(principal(c), c.req.param("id")) }));
|
|
132
|
+
app.get("/presentations/:id", (c) => c.json({ outcome: deps.scenes.repository.getPresentation(principal(c), c.req.param("id")) }));
|
|
133
|
+
app.post("/presentations/:id/feedback", deps.strictRateLimitMiddleware, async (c) => c.json({ revision: deps.scenes.inbox.feedback(principal(c), c.req.param("id"), await c.req.json()) }));
|
|
134
|
+
app.patch("/presentations/:id", deps.strictRateLimitMiddleware, async (c) => {
|
|
135
|
+
const { read } = z.strictObject({ read: z.boolean() }).parse(await c.req.json());
|
|
136
|
+
deps.scenes.inbox.setRead(principal(c), c.req.param("id"), read);
|
|
137
|
+
return c.json({ ok: true });
|
|
138
|
+
});
|
|
139
|
+
authenticated.route("/api/scenes", app);
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
export { registerSceneRoutes };
|
|
@@ -2,7 +2,9 @@ import { deleteBrowserTabBinding } from "../../../storage/sqlite/browser-tab-bin
|
|
|
2
2
|
import { conversationIdSchema } from "../../../../packages/gateway-contract/src/conversation-identity.js";
|
|
3
3
|
import { SessionDiscoveryQuerySchema } from "../../../../packages/gateway-contract/src/session-identity.js";
|
|
4
4
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
5
|
+
import "../../../session/types.js";
|
|
5
6
|
import { deleteSessionRecord, init_session_repository } from "../../../storage/sqlite/session-repository.js";
|
|
7
|
+
import { SidebarLayoutConflictError, getSidebarLayout, replaceSidebarLayout, sortBySidebarLayout } from "../../../storage/sqlite/sidebar-layout-repository.js";
|
|
6
8
|
import { ConversationAlreadyExistsError, createConversation, init_conversation_repository } from "../../../storage/sqlite/conversation-repository.js";
|
|
7
9
|
import { resolveProjectAgentId } from "../../../projects/project-agent.js";
|
|
8
10
|
import "../../../projects/index.js";
|
|
@@ -48,6 +50,21 @@ function parseOffset(value) {
|
|
|
48
50
|
const parsed = value ? Number.parseInt(value, 10) : 0;
|
|
49
51
|
return Number.isFinite(parsed) ? Math.max(0, parsed) : 0;
|
|
50
52
|
}
|
|
53
|
+
function listAllSidebarProjects(service, options = {}) {
|
|
54
|
+
const items = [];
|
|
55
|
+
let offset = 0;
|
|
56
|
+
while (true) {
|
|
57
|
+
const page = service.projects.listWithSidebarSessions({
|
|
58
|
+
status: "active",
|
|
59
|
+
limit: 50,
|
|
60
|
+
offset,
|
|
61
|
+
...options
|
|
62
|
+
});
|
|
63
|
+
items.push(...page.items);
|
|
64
|
+
if (!page.hasMore || page.items.length === 0) return items;
|
|
65
|
+
offset += page.items.length;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
51
68
|
function isHistoryCursor(value) {
|
|
52
69
|
if (!/^(0|[1-9]\d*)$/.test(value)) return false;
|
|
53
70
|
return Number.isSafeInteger(Number(value));
|
|
@@ -101,18 +118,25 @@ function registerSessionsRoutes(authenticated, deps) {
|
|
|
101
118
|
const staleDays = parsePositiveInt(c.req.query("staleDays"), DEFAULT_SIDEBAR_STALE_DAYS, 3650);
|
|
102
119
|
const updatedAfter = Date.now() - staleDays * 24 * 60 * 60 * 1e3;
|
|
103
120
|
const includeConversationId = c.req.query("includeConversationId")?.trim() || void 0;
|
|
104
|
-
const
|
|
105
|
-
status: "active",
|
|
106
|
-
limit: projectLimit,
|
|
107
|
-
offset: projectOffset,
|
|
121
|
+
const allProjectItems = listAllSidebarProjects(service, {
|
|
108
122
|
updatedAfter,
|
|
109
123
|
includePinned: true,
|
|
110
124
|
includeConversationId
|
|
111
125
|
});
|
|
126
|
+
const projectLayout = getSidebarLayout("projects");
|
|
127
|
+
const orderedProjects = sortBySidebarLayout(allProjectItems, projectLayout, (project) => project.id);
|
|
128
|
+
const projects = {
|
|
129
|
+
items: orderedProjects.slice(projectOffset, projectOffset + projectLimit),
|
|
130
|
+
total: orderedProjects.length,
|
|
131
|
+
limit: projectLimit,
|
|
132
|
+
offset: projectOffset,
|
|
133
|
+
hasMore: projectOffset + projectLimit < orderedProjects.length
|
|
134
|
+
};
|
|
112
135
|
const projectItems = await Promise.all(projects.items.map(async (project) => {
|
|
113
|
-
const
|
|
136
|
+
const sessionLayout = getSidebarLayout(`project:${project.id}`);
|
|
137
|
+
const allSessions = await service.sessions.listSessions({
|
|
114
138
|
projectId: project.id,
|
|
115
|
-
limit:
|
|
139
|
+
limit: 5e3,
|
|
116
140
|
offset: 0,
|
|
117
141
|
updatedAfter,
|
|
118
142
|
includePinned: true,
|
|
@@ -122,21 +146,47 @@ function registerSessionsRoutes(authenticated, deps) {
|
|
|
122
146
|
});
|
|
123
147
|
return {
|
|
124
148
|
project,
|
|
125
|
-
sessions:
|
|
126
|
-
sessionTotal:
|
|
127
|
-
sessionHasMore:
|
|
149
|
+
sessions: sortBySidebarLayout(allSessions.items, sessionLayout, (session) => session.key).slice(0, sessionPreviewLimit),
|
|
150
|
+
sessionTotal: allSessions.total,
|
|
151
|
+
sessionHasMore: sessionPreviewLimit < allSessions.total
|
|
128
152
|
};
|
|
129
153
|
}));
|
|
130
|
-
const
|
|
154
|
+
const inboxLayout = getSidebarLayout("inbox");
|
|
155
|
+
const allInbox = await service.sessions.listSessions({
|
|
131
156
|
unassigned: true,
|
|
132
|
-
limit:
|
|
133
|
-
offset:
|
|
157
|
+
limit: 5e3,
|
|
158
|
+
offset: 0,
|
|
134
159
|
updatedAfter,
|
|
135
160
|
includePinned: true,
|
|
136
161
|
includeConversationId,
|
|
137
162
|
sortBy: "updatedAt",
|
|
138
163
|
sortOrder: "desc"
|
|
139
164
|
});
|
|
165
|
+
const orderedInbox = sortBySidebarLayout(allInbox.items, inboxLayout, (session) => session.key);
|
|
166
|
+
const inbox = {
|
|
167
|
+
...allInbox,
|
|
168
|
+
items: orderedInbox.slice(inboxOffset, inboxOffset + inboxLimit),
|
|
169
|
+
limit: inboxLimit,
|
|
170
|
+
offset: inboxOffset,
|
|
171
|
+
hasMore: inboxOffset + inboxLimit < allInbox.total
|
|
172
|
+
};
|
|
173
|
+
const pinnedLayout = getSidebarLayout("pinned");
|
|
174
|
+
const pinned = sortBySidebarLayout((await service.sessions.listSessions({
|
|
175
|
+
status: "pinned",
|
|
176
|
+
limit: 5e3,
|
|
177
|
+
offset: 0,
|
|
178
|
+
sortBy: "updatedAt",
|
|
179
|
+
sortOrder: "desc"
|
|
180
|
+
})).items, pinnedLayout, (session) => session.key);
|
|
181
|
+
const layouts = Object.fromEntries([
|
|
182
|
+
projectLayout,
|
|
183
|
+
inboxLayout,
|
|
184
|
+
pinnedLayout,
|
|
185
|
+
...projects.items.map((project) => getSidebarLayout(`project:${project.id}`))
|
|
186
|
+
].map((layout) => [layout.containerId, {
|
|
187
|
+
itemIds: layout.itemIds,
|
|
188
|
+
revision: layout.revision
|
|
189
|
+
}]));
|
|
140
190
|
return c.json({
|
|
141
191
|
ok: true,
|
|
142
192
|
projects: {
|
|
@@ -146,9 +196,87 @@ function registerSessionsRoutes(authenticated, deps) {
|
|
|
146
196
|
offset: projects.offset,
|
|
147
197
|
hasMore: projects.hasMore
|
|
148
198
|
},
|
|
149
|
-
inbox
|
|
199
|
+
inbox,
|
|
200
|
+
pinned,
|
|
201
|
+
layouts
|
|
150
202
|
});
|
|
151
203
|
});
|
|
204
|
+
authenticated.put("/api/sidebar/layouts/:containerId", async (c) => {
|
|
205
|
+
const blocked = ensureGatewayReadyForSessions(c, service, "sessions.list");
|
|
206
|
+
if (blocked) return blocked;
|
|
207
|
+
const containerId = decodeURIComponent(c.req.param("containerId"));
|
|
208
|
+
if (containerId !== "projects" && containerId !== "pinned" && containerId !== "inbox" && !containerId.startsWith("project:")) return c.json({
|
|
209
|
+
ok: false,
|
|
210
|
+
error: "Invalid sidebar container"
|
|
211
|
+
}, 400);
|
|
212
|
+
const body = await c.req.json().catch(() => ({}));
|
|
213
|
+
if (!Array.isArray(body.itemIds) || body.itemIds.length > 5e3 || body.itemIds.some((id) => typeof id !== "string" || !id.trim())) return c.json({
|
|
214
|
+
ok: false,
|
|
215
|
+
error: "itemIds must be an array of non-empty strings"
|
|
216
|
+
}, 400);
|
|
217
|
+
if (!Number.isInteger(body.expectedRevision) || body.expectedRevision < 0) return c.json({
|
|
218
|
+
ok: false,
|
|
219
|
+
error: "expectedRevision must be a non-negative integer"
|
|
220
|
+
}, 400);
|
|
221
|
+
const itemIds = [...new Set(body.itemIds)];
|
|
222
|
+
if (itemIds.length !== body.itemIds.length) return c.json({
|
|
223
|
+
ok: false,
|
|
224
|
+
error: "itemIds must be unique"
|
|
225
|
+
}, 400);
|
|
226
|
+
let completeItemIds = itemIds;
|
|
227
|
+
if (containerId === "projects") {
|
|
228
|
+
if (itemIds.some((id) => !service.projects.get(id))) return c.json({
|
|
229
|
+
ok: false,
|
|
230
|
+
error: "Project not found"
|
|
231
|
+
}, 404);
|
|
232
|
+
const allIds = listAllSidebarProjects(service).map((project) => project.id);
|
|
233
|
+
completeItemIds = [...itemIds, ...allIds.filter((id) => !itemIds.includes(id))];
|
|
234
|
+
} else {
|
|
235
|
+
const projectId = containerId.startsWith("project:") ? containerId.slice(8) : void 0;
|
|
236
|
+
if (projectId && !service.projects.get(projectId)) return c.json({
|
|
237
|
+
ok: false,
|
|
238
|
+
error: "Project not found"
|
|
239
|
+
}, 404);
|
|
240
|
+
if ((await Promise.all(itemIds.map((id) => service.sessions.getSession(id)))).some((session) => {
|
|
241
|
+
if (!session || session.status === "archived") return true;
|
|
242
|
+
if (containerId === "pinned") return session.status !== "pinned";
|
|
243
|
+
if (session.status === "pinned") return true;
|
|
244
|
+
if (containerId === "inbox") return Boolean(session.projectId);
|
|
245
|
+
return session.projectId !== projectId;
|
|
246
|
+
})) return c.json({
|
|
247
|
+
ok: false,
|
|
248
|
+
error: "Sidebar item does not belong to the container"
|
|
249
|
+
}, 409);
|
|
250
|
+
const eligibleIds = (await service.sessions.listSessions({
|
|
251
|
+
...containerId === "pinned" ? { status: "pinned" } : containerId === "inbox" ? {
|
|
252
|
+
unassigned: true,
|
|
253
|
+
excludeArchived: true
|
|
254
|
+
} : {
|
|
255
|
+
projectId,
|
|
256
|
+
excludeArchived: true
|
|
257
|
+
},
|
|
258
|
+
limit: 5e3,
|
|
259
|
+
offset: 0,
|
|
260
|
+
sortBy: "updatedAt",
|
|
261
|
+
sortOrder: "desc"
|
|
262
|
+
})).items.filter((session) => containerId === "pinned" || session.status !== "pinned").map((session) => session.key);
|
|
263
|
+
completeItemIds = [...itemIds, ...eligibleIds.filter((id) => !itemIds.includes(id))];
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
const layout = replaceSidebarLayout(containerId, completeItemIds, body.expectedRevision);
|
|
267
|
+
return c.json({
|
|
268
|
+
ok: true,
|
|
269
|
+
layout
|
|
270
|
+
});
|
|
271
|
+
} catch (error) {
|
|
272
|
+
if (error instanceof SidebarLayoutConflictError) return c.json({
|
|
273
|
+
ok: false,
|
|
274
|
+
error: error.message,
|
|
275
|
+
layout: error.current
|
|
276
|
+
}, 409);
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
152
280
|
authenticated.post("/api/sessions", async (c) => {
|
|
153
281
|
const body = await c.req.json().catch(() => ({}));
|
|
154
282
|
if (body.conversationId !== void 0 && !conversationIdSchema.safeParse(body.conversationId).success) return c.json({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { init_transaction, runSqliteWriteTransaction } from "../../../storage/sqlite/transaction.js";
|
|
2
2
|
import { TaskPhaseSchema } from "../../../../packages/gateway-contract/src/task-lifecycle.js";
|
|
3
3
|
import { TaskBoardPositionRequestSchema, TaskCommandRequestSchema, TaskContextInputSchema, TaskCreateRequestSchema, TaskDependencyUpdateRequestSchema, TaskHandoffRequestSchema, TaskPatchRequestSchema } from "../../../../packages/gateway-contract/src/tasks.js";
|
|
4
|
-
import { ProjectMonitoringUpdateSchema } from "../../../../packages/gateway-contract/src/project-monitoring.js";
|
|
5
4
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
6
5
|
import { enqueueTaskChangedEvent, init_task_change_events } from "../../../tasks/task-change-events.js";
|
|
7
6
|
import { TaskRunRepository, init_task_run_repository } from "../../../tasks/task-run-repository.js";
|
|
@@ -12,7 +11,6 @@ import { resolveProjectAgentId } from "../../../projects/project-agent.js";
|
|
|
12
11
|
import { TaskContextRepository } from "../../../tasks/task-context-repository.js";
|
|
13
12
|
import { TaskDependencyError, TaskDependencyService } from "../../../tasks/task-dependency-service.js";
|
|
14
13
|
import { TaskApplicationService } from "../../../tasks/task-application-service.js";
|
|
15
|
-
import { ProjectMonitoringService } from "../../../tasks/project-monitoring-service.js";
|
|
16
14
|
import { ProjectOperatingViewService } from "../../../tasks/project-operating-view-service.js";
|
|
17
15
|
import { TaskValueMetricsService } from "../../../tasks/task-value-metrics-service.js";
|
|
18
16
|
import { TaskHandoffService } from "../../../tasks/task-handoff-service.js";
|
|
@@ -30,7 +28,6 @@ function registerTaskRoutes(authenticated, deps) {
|
|
|
30
28
|
const taskRateLimit = deps.taskRateLimitMiddleware ?? deps.strictRateLimitMiddleware;
|
|
31
29
|
const application = new TaskApplicationService();
|
|
32
30
|
const operatingViews = new ProjectOperatingViewService(deps.service.projects);
|
|
33
|
-
const monitoring = new ProjectMonitoringService(deps.service.currentWorkspacePath);
|
|
34
31
|
const metrics = new TaskValueMetricsService();
|
|
35
32
|
const tasks = new TaskRepository();
|
|
36
33
|
const runs = new TaskRunRepository();
|
|
@@ -577,49 +574,6 @@ function registerTaskRoutes(authenticated, deps) {
|
|
|
577
574
|
error: "Project not found"
|
|
578
575
|
}, 404);
|
|
579
576
|
});
|
|
580
|
-
authenticated.get("/api/projects/:projectId/monitoring", (c) => {
|
|
581
|
-
const projectId = c.req.param("projectId");
|
|
582
|
-
if (!deps.service.projects.get(projectId)) return c.json({
|
|
583
|
-
ok: false,
|
|
584
|
-
error: "Project not found"
|
|
585
|
-
}, 404);
|
|
586
|
-
return c.json({
|
|
587
|
-
ok: true,
|
|
588
|
-
policy: monitoring.get(projectId)
|
|
589
|
-
});
|
|
590
|
-
});
|
|
591
|
-
authenticated.patch("/api/projects/:projectId/monitoring", taskRateLimit, async (c) => {
|
|
592
|
-
const projectId = c.req.param("projectId");
|
|
593
|
-
if (!deps.service.projects.get(projectId)) return c.json({
|
|
594
|
-
ok: false,
|
|
595
|
-
error: "Project not found"
|
|
596
|
-
}, 404);
|
|
597
|
-
const parsed = ProjectMonitoringUpdateSchema.safeParse(await c.req.json().catch(() => ({})));
|
|
598
|
-
if (!parsed.success) return c.json({
|
|
599
|
-
ok: false,
|
|
600
|
-
error: "Invalid monitoring policy"
|
|
601
|
-
}, 400);
|
|
602
|
-
const current = monitoring.get(projectId);
|
|
603
|
-
try {
|
|
604
|
-
const policy = monitoring.configure({
|
|
605
|
-
projectId,
|
|
606
|
-
mode: parsed.data.mode ?? current.mode,
|
|
607
|
-
quietHours: parsed.data.quietHours === null ? void 0 : parsed.data.quietHours ?? current.quietHours,
|
|
608
|
-
allowedActions: parsed.data.allowedActions ?? current.allowedActions,
|
|
609
|
-
confidenceThreshold: parsed.data.confidenceThreshold ?? current.confidenceThreshold,
|
|
610
|
-
scenarios: parsed.data.scenarios ?? (current.configured ? current.scenarios : void 0)
|
|
611
|
-
});
|
|
612
|
-
return c.json({
|
|
613
|
-
ok: true,
|
|
614
|
-
policy
|
|
615
|
-
});
|
|
616
|
-
} catch (error) {
|
|
617
|
-
return c.json({
|
|
618
|
-
ok: false,
|
|
619
|
-
error: error instanceof Error ? error.message : String(error)
|
|
620
|
-
}, 400);
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
577
|
}
|
|
624
578
|
//#endregion
|
|
625
579
|
export { registerTaskRoutes };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { init_transaction, runSqliteWriteTransaction } from "../../../storage/sqlite/transaction.js";
|
|
1
2
|
import { createCollaborationRule, getCollaborationRule, listCollaborationRules, setCollaborationRuleStatus } from "../../../storage/sqlite/collaboration-rule-repository.js";
|
|
2
3
|
import { KnowledgeReviewConflictError, deleteKnowledgeItem, getKnowledgeItem, listKnowledgeItems, reviewKnowledgeItem, searchKnowledgeItems } from "../../../knowledge-memory/repository.js";
|
|
3
4
|
import "../../../knowledge-memory/index.js";
|
|
4
|
-
import { createPriorityWindow, createUserGoal, listPriorityWindows, listUserGoals, setUserGoalStatus } from "../../../user-model/goals.js";
|
|
5
|
+
import { createPriorityWindow, createUserGoal, listPriorityWindows, listUserGoals, setUserGoalStatus, updatePriorityWindow, updateUserGoal } from "../../../user-model/goals.js";
|
|
5
6
|
import { deleteUserAssertion, getAssertionSlot, getUserAssertion, listUserAssertionSources, listUserAssertions, reconcileAssertion, setAssertionStatus } from "../../../user-model/repository.js";
|
|
6
7
|
import { applyUserProfilePatch, getUserProfileSnapshot } from "../../../user-model/profile.js";
|
|
7
8
|
import { bootstrapUserModel } from "../../../user-model/bootstrap.js";
|
|
@@ -13,6 +14,7 @@ import { getExecutionContextAudit, recordExecutionContextFeedback } from "../../
|
|
|
13
14
|
import { listUnderstandingSourceGrants } from "../../../user-context/sources/repository.js";
|
|
14
15
|
import { userInfo } from "node:os";
|
|
15
16
|
//#region src/gateway/hono/routes/user-model.ts
|
|
17
|
+
init_transaction();
|
|
16
18
|
function object(value) {
|
|
17
19
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
18
20
|
}
|
|
@@ -387,6 +389,57 @@ function registerUserModelRoutes(authenticated, deps) {
|
|
|
387
389
|
return c.json({ error: errorMessage(error) }, 400);
|
|
388
390
|
}
|
|
389
391
|
});
|
|
392
|
+
authenticated.patch("/api/user-model/priorities/:id", write, async (c) => {
|
|
393
|
+
const input = await body(c);
|
|
394
|
+
const priority = listPriorityWindows().find((item) => item.id === c.req.param("id"));
|
|
395
|
+
if (!priority) return c.json({ error: "Priority not found" }, 404);
|
|
396
|
+
if (!input) return c.json({ error: "A priority patch is required" }, 400);
|
|
397
|
+
if (![
|
|
398
|
+
"title",
|
|
399
|
+
"desiredOutcome",
|
|
400
|
+
"validTo",
|
|
401
|
+
"status"
|
|
402
|
+
].some((field) => Object.hasOwn(input, field))) return c.json({ error: "At least one editable priority field is required" }, 400);
|
|
403
|
+
if (Object.hasOwn(input, "title") && typeof input.title !== "string" || Object.hasOwn(input, "desiredOutcome") && typeof input.desiredOutcome !== "string" || Object.hasOwn(input, "validTo") && typeof input.validTo !== "number" || Object.hasOwn(input, "status") && typeof input.status !== "string") return c.json({ error: "Priority patch fields have invalid types" }, 400);
|
|
404
|
+
const title = typeof input.title === "string" ? input.title.trim() : void 0;
|
|
405
|
+
const desiredOutcome = typeof input.desiredOutcome === "string" ? input.desiredOutcome.trim() : void 0;
|
|
406
|
+
const validTo = typeof input.validTo === "number" ? input.validTo : void 0;
|
|
407
|
+
const status = typeof input.status === "string" ? input.status : void 0;
|
|
408
|
+
if (status && ![
|
|
409
|
+
"active",
|
|
410
|
+
"paused",
|
|
411
|
+
"completed",
|
|
412
|
+
"expired"
|
|
413
|
+
].includes(status)) return c.json({ error: "Invalid priority status" }, 400);
|
|
414
|
+
if (validTo !== void 0 && validTo < priority.validFrom) return c.json({ error: "Priority validTo must be after validFrom" }, 400);
|
|
415
|
+
if (title !== void 0 && !title) return c.json({ error: "Priority title is required" }, 400);
|
|
416
|
+
if (desiredOutcome !== void 0 && !desiredOutcome) return c.json({ error: "Priority outcome is required" }, 400);
|
|
417
|
+
try {
|
|
418
|
+
const result = runSqliteWriteTransaction(() => {
|
|
419
|
+
let goal;
|
|
420
|
+
if (priority.targetType === "goal" && (title !== void 0 || desiredOutcome !== void 0)) {
|
|
421
|
+
const currentGoal = listUserGoals().find((item) => item.id === priority.targetId);
|
|
422
|
+
if (!currentGoal) throw new Error("Priority goal not found");
|
|
423
|
+
goal = updateUserGoal(currentGoal.id, {
|
|
424
|
+
title: title ?? currentGoal.title,
|
|
425
|
+
desiredOutcome: desiredOutcome ?? currentGoal.desiredOutcome,
|
|
426
|
+
...currentGoal.targetAt === void 0 ? {} : { targetAt: currentGoal.targetAt }
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
return {
|
|
430
|
+
priority: updatePriorityWindow(priority.id, {
|
|
431
|
+
...priority.targetType === "goal" || title === void 0 ? {} : { targetId: title },
|
|
432
|
+
...validTo === void 0 ? {} : { validTo },
|
|
433
|
+
...status === void 0 ? {} : { status }
|
|
434
|
+
}),
|
|
435
|
+
...goal ? { goal } : {}
|
|
436
|
+
};
|
|
437
|
+
});
|
|
438
|
+
return c.json(result);
|
|
439
|
+
} catch (error) {
|
|
440
|
+
return c.json({ error: errorMessage(error) }, 400);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
390
443
|
authenticated.get("/api/knowledge-memory", (c) => {
|
|
391
444
|
const query = c.req.query("q")?.trim();
|
|
392
445
|
if (!query) return c.json({ items: listKnowledgeItems({
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { NotificationDispatcher } from '../../notifications/dispatch.js';
|
|
3
|
+
import { type SceneActivation, type ScenePermission } from '../../scenes/contracts.js';
|
|
4
|
+
export declare function createSceneBrowserDispatcher(db: DatabaseSync, authorize: (activation: SceneActivation) => ScenePermission, clock?: () => number): NotificationDispatcher;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { intersectPermissions, sceneContentHash } from "../../scenes/contracts.js";
|
|
2
|
+
import { SceneRepository } from "../../scenes/repository.js";
|
|
3
|
+
import { ScenePreferenceService, sceneChecksAllowed } from "../../scenes/preferences.js";
|
|
4
|
+
import { notificationQuietUntil } from "../../notifications/quietHours.js";
|
|
5
|
+
import { sceneNotificationEligibility } from "../../scenes/notificationEligibility.js";
|
|
6
|
+
import { createBrowserNotificationTransport } from "../../notifications/browserTransport.js";
|
|
7
|
+
import { NotificationDispatcher } from "../../notifications/dispatch.js";
|
|
8
|
+
//#region src/gateway/scenes/browserNotifications.ts
|
|
9
|
+
function createSceneBrowserDispatcher(db, authorize, clock = Date.now) {
|
|
10
|
+
const repository = new SceneRepository(db);
|
|
11
|
+
const members = (dispatch) => dispatch.subjectId ? [{
|
|
12
|
+
subject_id: dispatch.subjectId,
|
|
13
|
+
subject_revision: dispatch.subjectRevision
|
|
14
|
+
}] : db.prepare(`SELECT m.subject_id, m.subject_revision FROM notification_digest_members m
|
|
15
|
+
JOIN notification_digests d ON d.id = m.digest_id
|
|
16
|
+
WHERE d.notification_id = ? AND d.owner_id = ? AND d.workspace_id = ?`).all(dispatch.notificationId, dispatch.ownerId, dispatch.workspaceId);
|
|
17
|
+
const eligible = (dispatch, subject) => {
|
|
18
|
+
const result = sceneNotificationEligibility(db, {
|
|
19
|
+
...dispatch,
|
|
20
|
+
subjectId: String(subject.subject_id)
|
|
21
|
+
}, clock(), Number(subject.subject_revision));
|
|
22
|
+
if (result.action !== "eligible") return null;
|
|
23
|
+
const activation = repository.getActivation(dispatch, result.activationId);
|
|
24
|
+
if (sceneContentHash(intersectPermissions(activation.permissions, authorize(activation))) !== sceneContentHash(intersectPermissions(activation.permissions))) return null;
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
return new NotificationDispatcher(db, {
|
|
28
|
+
clock,
|
|
29
|
+
send: createBrowserNotificationTransport(db, {
|
|
30
|
+
clock,
|
|
31
|
+
route: (dispatch) => {
|
|
32
|
+
if (!dispatch.subjectId) return "/scenes/inbox";
|
|
33
|
+
const result = eligible(dispatch, {
|
|
34
|
+
subject_id: dispatch.subjectId,
|
|
35
|
+
subject_revision: dispatch.subjectRevision
|
|
36
|
+
});
|
|
37
|
+
return result ? `/scenes/${encodeURIComponent(result.activationId)}?result=${encodeURIComponent(result.presentationId)}` : null;
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
authorize: async (dispatch) => {
|
|
41
|
+
const policy = new ScenePreferenceService(db).get(dispatch);
|
|
42
|
+
if (!sceneChecksAllowed(policy, clock()) || policy.notificationsMuted || policy.level === "quiet" || policy.preferredChannel !== "browser") return { action: "cancel" };
|
|
43
|
+
if (!members(dispatch).filter((subject) => eligible(dispatch, subject)).filter((subject) => !policy.suppressWhileViewing || !db.prepare(`SELECT 1 FROM notification_presence WHERE owner_id = ? AND workspace_id = ?
|
|
44
|
+
AND subject_id = ? AND subject_revision = ? AND expires_at > ?`).get(dispatch.ownerId, dispatch.workspaceId, subject.subject_id, subject.subject_revision, clock())).length) return { action: "cancel" };
|
|
45
|
+
const until = notificationQuietUntil(policy, clock());
|
|
46
|
+
return until === null ? { action: "send" } : {
|
|
47
|
+
action: "defer",
|
|
48
|
+
until
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { createSceneBrowserDispatcher };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import type { ProductNotification } from '@xopcai/gateway-contract';
|
|
3
|
+
import type { Config } from '../../config/schema.js';
|
|
4
|
+
import type { ScenePrincipal } from '../../scenes/contracts.js';
|
|
5
|
+
import { type SceneReadOnlyExecutor } from '../../scenes/execution.js';
|
|
6
|
+
import type { SceneHttpServices } from '../../scenes/httpServices.js';
|
|
7
|
+
import type { SceneMailContextProvider } from '../../scenes/mailContext.js';
|
|
8
|
+
/** Composition root for the initialized database. Never creates tables or starts an old worker. */
|
|
9
|
+
export declare class GatewaySceneHost {
|
|
10
|
+
private readonly db;
|
|
11
|
+
readonly http: SceneHttpServices;
|
|
12
|
+
private readonly runtime;
|
|
13
|
+
private readonly notifications;
|
|
14
|
+
private readonly browserDispatcher;
|
|
15
|
+
private timer?;
|
|
16
|
+
private active?;
|
|
17
|
+
private stopped;
|
|
18
|
+
private nextMaintenanceAt;
|
|
19
|
+
private readonly clock;
|
|
20
|
+
constructor(db: DatabaseSync, input: {
|
|
21
|
+
principal: ScenePrincipal;
|
|
22
|
+
config: () => Config;
|
|
23
|
+
publish: (type: 'notification.created', notification: ProductNotification) => void;
|
|
24
|
+
executor?: SceneReadOnlyExecutor;
|
|
25
|
+
mail?: SceneMailContextProvider;
|
|
26
|
+
clock?: () => number;
|
|
27
|
+
intervalMs?: number;
|
|
28
|
+
});
|
|
29
|
+
private readonly intervalMs;
|
|
30
|
+
start(): void;
|
|
31
|
+
tick(): Promise<void>;
|
|
32
|
+
/** Must finish before the Gateway closes SQLite or its realtime broker. */
|
|
33
|
+
stop(): Promise<void>;
|
|
34
|
+
}
|