@xopcai/xopc 0.0.312 → 0.0.314
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/dist/assets/{auth-C3yV1y_l.js → auth-DKo-NMUY.js} +18 -1
- package/dist/browser-ext/dist/background.js +68 -2
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +1 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/telegram/src/inbound-processor.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +2 -2
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BVIJMP8w.js → agent-avatar-dicebear-BFkjfurL.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BdOZ6q8Z.js +1 -0
- package/dist/gateway/static/root/assets/{agents-D6g_SeWI.js → agents-CCcavsHq.js} +1 -1
- package/dist/gateway/static/root/assets/{api-_aHQA8bd.js → api-BYhRsTAc.js} +1 -1
- package/dist/gateway/static/root/assets/{app-link-CKueEVbT.js → app-link-nL8iPwEr.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CLg_aXYG.js → app-management-settings-panel-B4kihr-A.js} +1 -1
- package/dist/gateway/static/root/assets/appearance-settings-N9sYmNOx.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-BMcy10_s.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CHO3heHX.js → archive-plugin-k_SuYWyV.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BsmsBCI2.js → attachment-load-DRv5QWUK.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CftigJlf.js → automations-page-CkJV3DN0.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BEa2doeR.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CRCLWBo2.js → binary-plugins-Dg3h3TA7.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D0LDiOTT.js → block-editor-DVhdHntT.js} +29 -29
- package/dist/gateway/static/root/assets/{browser-automation-inputs-C611KRBx.js → browser-automation-inputs-BMRYUW8_.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-Djyv3vy-.js → browser-automations-page-Byv6-FY2.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-DRCHGFpO.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-D0S3DuAD.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-mxRP0gl0.js +8 -0
- package/dist/gateway/static/root/assets/channels-settings-DBt_6GsB.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CIsKqdET.js → chat-terminal-dock-D4AHa51o.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-C0YL9J7m.js → computer-settings-page-eXPe500D.js} +1 -1
- package/dist/gateway/static/root/assets/connector-service-page-BQTFlq_k.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-BKeBWwcI.js +2 -0
- package/dist/gateway/static/root/assets/conversation-identity-Cw0n9uzK.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-CDsfv8R0.js → date-picker-7MtovynY.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DvhPj3CZ.js → dependency-picker-Bj_xkXID.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Cyg8XMpL.js → desktop-pet-CTmba9zH.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DNM_BlWN.js +1 -0
- package/dist/gateway/static/root/assets/device-pairing-wizard-C2XE0QhT.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-D-AVJU3q.js → extension-debug-page-J_olaL7e.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DrFoQ9xt.js → extension-page-pK5RvqN8.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DxWjESC1.js → extension-settings-page-BwroEN08.js} +1 -1
- package/dist/gateway/static/root/assets/files-BK6enEvD.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-DUDX42qY.js → gateway-config-swr-FuJTIg_a.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-CLLDp23J.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Cf8OxlvY.js → gateway-startup-retry-CKg_gu8_.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-B5Epb1PH.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-D2YorS--.js → image-generation-api-Bo6NZ7zb.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BKucJlXI.js → imports-page-C8-hX8gS.js} +1 -1
- package/dist/gateway/static/root/assets/index-14F1yGJI.js +89 -0
- package/dist/gateway/static/root/assets/index-cB7rWIDY.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BxLXD-yU.js → keyboard-shortcuts-settings-BkBEjUZD.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-6jC3vQpY.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-BAsQJQKJ.js → local-apps-page-CrbKIixo.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DA0Z5jM_.js → locale-store-CvGwNbml.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DBHlZts9.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-DsUWLu5m.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DYGPxPee.js → markdown-view-nXo5nrsv.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CQtQzLyg.js → media-plugins-upxXJ-4l.js} +1 -1
- package/dist/gateway/static/root/assets/messages-B_AwRroN.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-0Q9TOtJG.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-D0NmcwNw.js +8 -0
- package/dist/gateway/static/root/assets/page-context-capture-button-DUyA-K4L.js +1 -0
- package/dist/gateway/static/root/assets/{page-tabs-B6DjkyMM.js → page-tabs-Cl-NFPNr.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Dn57uLhr.js → preview-open-alternatives-DX81PwJ3.js} +1 -1
- package/dist/gateway/static/root/assets/product-delivery-chCjIpvu.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-H2YMk8TY.js → product-open-page-CrfIGwm8.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BVfVrYmn.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-nM9a9XNS.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-C0DCx3wv.js → registry-api-CHxgohY0.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C8b_k88G.js +1 -0
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-D3dLOW04.js +5 -0
- package/dist/gateway/static/root/assets/scenes-page-DEowreZV.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-CblI9WUA.js → schema-form-ZxuIvD2_.js} +1 -1
- package/dist/gateway/static/root/assets/schemas-88fK3zzl.js +64 -0
- package/dist/gateway/static/root/assets/sessions-page-B_nPhera.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BqhIOuus.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BAaVyxJH.js → settings-form-section-TZRfg4yo.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CKNPbm5q.js → settings-page-a8qcJpdZ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DqNCGKxQ.js → settings-page-layout-BfvlRT9q.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CRj5Ruqn.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BzMfp_HM.js → share-preview-page-DCt1pTWB.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BNbXPk--.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CNMCLbav.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DIht92q6.js → skills-page-BIOcg44X.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DLYRiEn3.js → skills-page.utils-CgZdzT4I.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-yYs4YgYk.js → system-settings-panel-_YaRncA6.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CAcfAG-c.js +1 -0
- package/dist/gateway/static/root/assets/tasks-CDR_RVbQ.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-BasDYxvx.js → tunnel-api-uOupJOoS.js} +1 -1
- package/dist/gateway/static/root/assets/turn-outcome-D0SnyZ3Z.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-CWAUHhcb.js → use-autosave-BezzHBLE.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-BFFeneDq.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-Kc4UlxZs.js → voice-api-key-field-BmYifdwL.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-DTyMdGOR.js → voice-config-api-D_5Q2_A3.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BPC_c9dO.js → work-discovery-overlay-4DmyEckJ.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DBTciOrq.js → workflow-run-setup-panel-DeZe8bTZ.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Sv4hEc6W.js +6 -0
- package/dist/gateway/static/root/index.html +16 -16
- package/dist/package.js +1 -1
- package/dist/packages/computer-control-contract/src/index.js +10 -1
- package/dist/packages/gateway-contract/src/app-context.js +55 -0
- package/dist/packages/gateway-contract/src/automations.js +16 -17
- package/dist/packages/gateway-contract/src/capabilities.js +1078 -0
- package/dist/packages/gateway-contract/src/extension-capabilities.js +26 -0
- package/dist/packages/gateway-contract/src/home.js +3 -3
- package/dist/packages/gateway-contract/src/index.js +8 -0
- package/dist/packages/gateway-contract/src/product-delivery.js +19 -4
- package/dist/packages/gateway-contract/src/scenes.js +199 -0
- package/dist/packages/gateway-contract/src/task-runs.js +8 -4
- package/dist/packages/gateway-contract/src/tasks.js +5 -4
- package/dist/packages/realtime-client/src/index.js +17 -4
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/child-agent-factory.d.ts +2 -0
- package/dist/src/agent/child-agent-factory.js +5 -0
- package/dist/src/agent/commands/approved-verification.d.ts +14 -0
- package/dist/src/agent/commands/approved-verification.js +48 -0
- package/dist/src/agent/context/execution-scope.js +2 -1
- package/dist/src/agent/context/project-context.js +2 -1
- package/dist/src/agent/external-tools/cliProvider.js +123 -75
- package/dist/src/agent/external-tools/composio-provider.d.ts +1 -1
- package/dist/src/agent/external-tools/composio-provider.js +70 -12
- package/dist/src/agent/external-tools/endpoint-provider.js +14 -1
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
- package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
- package/dist/src/agent/memory/compaction-chunks.d.ts +6 -1
- package/dist/src/agent/memory/compaction-chunks.js +16 -3
- package/dist/src/agent/memory/compaction-ledger.d.ts +3 -1
- package/dist/src/agent/memory/compaction-ledger.js +31 -18
- package/dist/src/agent/memory/compaction-request.d.ts +2 -0
- package/dist/src/agent/memory/compaction-request.js +6 -1
- package/dist/src/agent/memory/compaction.d.ts +19 -1
- package/dist/src/agent/memory/compaction.js +112 -30
- package/dist/src/agent/service/process-direct-streaming.d.ts +3 -0
- package/dist/src/agent/service/process-direct-streaming.js +19 -10
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/skills/config.js +2 -0
- package/dist/src/agent/skills/format-skills-prompt.js +14 -1
- package/dist/src/agent/skills/index.js +16 -8
- package/dist/src/agent/skills/types.d.ts +1 -1
- package/dist/src/agent/source-context/app-context.d.ts +4 -0
- package/dist/src/agent/source-context/app-context.js +36 -0
- package/dist/src/agent/source-context/injector.js +1 -0
- package/dist/src/agent/source-context/types.d.ts +5 -1
- package/dist/src/agent/tasks/task-judge-service.js +2 -1
- package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
- package/dist/src/agent/tool-manuals/computer.js +1 -1
- package/dist/src/agent/tools/automation-tool.d.ts +12 -1
- package/dist/src/agent/tools/automation-tool.js +106 -32
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +6 -1
- package/dist/src/agent/tools/scoped-workspace-tools.d.ts +8 -0
- package/dist/src/agent/tools/scoped-workspace-tools.js +81 -0
- package/dist/src/agent/tools/xopc-use-tool.d.ts +6 -3
- package/dist/src/agent/tools/xopc-use-tool.js +997 -908
- package/dist/src/agent/workflow/subagent-runner.js +1 -0
- package/dist/src/agent-config/index.js +2 -2
- package/dist/src/agent-config/schema.d.ts +5 -0
- package/dist/src/agent-config/schema.js +14 -10
- package/dist/src/automations/api/routes.js +244 -164
- package/dist/src/automations/capabilities/drafts.d.ts +4 -0
- package/dist/src/automations/capabilities/drafts.js +95 -0
- package/dist/src/automations/capabilities/read.d.ts +4 -0
- package/dist/src/automations/capabilities/read.js +119 -0
- package/dist/src/automations/capabilities/write.d.ts +349 -0
- package/dist/src/automations/capabilities/write.js +172 -0
- package/dist/src/automations/domain/index.js +2 -2
- package/dist/src/automations/domain/validation.d.ts +77 -77
- package/dist/src/automations/domain/validation.js +9 -6
- package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -2
- package/dist/src/automations/index.js +6 -6
- package/dist/src/automations/service/automation-service.d.ts +31 -0
- package/dist/src/automations/service/automation-service.js +213 -75
- package/dist/src/automations/service/index.js +2 -2
- package/dist/src/automations/storage/automation-repository.d.ts +2 -0
- package/dist/src/automations/storage/automation-repository.js +9 -1
- package/dist/src/automations/storage/automation-run-repository.d.ts +4 -1
- package/dist/src/automations/storage/automation-run-repository.js +16 -3
- package/dist/src/automations/storage/index.js +3 -3
- package/dist/src/browser/automations/schema.d.ts +1 -1
- package/dist/src/browser/automations/service.d.ts +1 -1
- package/dist/src/browser/observation/format.js +4 -0
- package/dist/src/capabilities/adapters/http.d.ts +4 -0
- package/dist/src/capabilities/adapters/http.js +44 -0
- package/dist/src/capabilities/readiness/from-config.js +11 -7
- package/dist/src/capabilities/runtime/app-context.d.ts +3 -0
- package/dist/src/capabilities/runtime/app-context.js +72 -0
- package/dist/src/capabilities/runtime/atomic-operations.d.ts +11 -0
- package/dist/src/capabilities/runtime/atomic-operations.js +34 -0
- package/dist/src/capabilities/runtime/dispatcher.d.ts +67 -0
- package/dist/src/capabilities/runtime/dispatcher.js +170 -0
- package/dist/src/capabilities/runtime/errors.d.ts +6 -0
- package/dist/src/capabilities/runtime/errors.js +11 -0
- package/dist/src/capabilities/runtime/external-operations.d.ts +16 -0
- package/dist/src/capabilities/runtime/external-operations.js +92 -0
- package/dist/src/capabilities/runtime/product.d.ts +12 -0
- package/dist/src/capabilities/runtime/product.js +69 -0
- package/dist/src/capabilities/runtime/settings.d.ts +3 -0
- package/dist/src/capabilities/runtime/settings.js +27 -0
- package/dist/src/channels/index.js +2 -2
- package/dist/src/channels/manager.js +1 -1
- package/dist/src/cli/cli-log-level-preset.d.ts +2 -0
- package/dist/src/cli/cli-log-level-preset.js +4 -0
- package/dist/src/cli/command-catalog.js +4 -0
- package/dist/src/cli/command-loaders.js +1 -0
- package/dist/src/cli/command-manifest.js +4 -0
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/mcp.d.ts +1 -0
- package/dist/src/cli/commands/mcp.js +51 -0
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/project.js +1 -1
- package/dist/src/computer/broker.d.ts +0 -1
- package/dist/src/computer/broker.js +4 -6
- package/dist/src/computer/evaluation-harness.d.ts +45 -0
- package/dist/src/computer/evaluation-harness.js +108 -0
- package/dist/src/computer/model-adapter.d.ts +37 -2
- package/dist/src/computer/model-adapter.js +333 -42
- package/dist/src/computer/model-policy.d.ts +4 -1
- package/dist/src/computer/model-policy.js +11 -3
- package/dist/src/computer/release-gate.d.ts +22 -0
- package/dist/src/computer/release-gate.js +19 -0
- package/dist/src/computer/runtime.js +14 -10
- package/dist/src/computer/task-state.d.ts +1 -0
- package/dist/src/computer/task-state.js +1 -0
- package/dist/src/config/models-json.d.ts +14 -8
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.d.ts +4 -0
- package/dist/src/config/schema.js +3 -9
- package/dist/src/connectors/composio-sessions.d.ts +4 -2
- package/dist/src/connectors/composio-sessions.js +10 -9
- package/dist/src/connectors/composio.js +10 -8
- package/dist/src/discussions/action-tasks.js +2 -1
- package/dist/src/discussions/recording.js +1 -1
- package/dist/src/execution-environments/local-worktree-manager.d.ts +1 -0
- package/dist/src/execution-environments/local-worktree-manager.js +13 -2
- package/dist/src/extensions/activation-context.js +3 -3
- package/dist/src/extensions/api.js +1 -1
- package/dist/src/extensions/normalize-manifest.js +6 -1
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/extensions/sdk/media.js +1 -1
- package/dist/src/extensions/types/manifest.d.ts +3 -0
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
- package/dist/src/gateway/hono/middleware/scopes.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +5 -2
- package/dist/src/gateway/hono/routes/capability-operations.d.ts +3 -0
- package/dist/src/gateway/hono/routes/capability-operations.js +52 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +16 -0
- package/dist/src/gateway/hono/routes/local-app-capabilities.d.ts +4 -0
- package/dist/src/gateway/hono/routes/local-app-capabilities.js +41 -0
- package/dist/src/gateway/hono/routes/local-apps.js +41 -9
- package/dist/src/gateway/hono/routes/models.js +2 -2
- package/dist/src/gateway/hono/routes/notes.js +215 -146
- package/dist/src/gateway/hono/routes/projects.js +217 -374
- package/dist/src/gateway/hono/routes/scenes.js +188 -75
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +60 -16
- package/dist/src/gateway/hono/routes/session-input-handler.js +43 -1
- package/dist/src/gateway/hono/routes/sessions.js +17 -0
- package/dist/src/gateway/hono/routes/status.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +182 -326
- package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
- package/dist/src/gateway/hono/routes/voice.js +4 -4
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/media-access.js +2 -1
- package/dist/src/gateway/mobile-privacy.js +2 -2
- package/dist/src/gateway/scenes/host.js +14 -3
- package/dist/src/gateway/scenes/mailContext.js +1 -1
- package/dist/src/gateway/scenes/slackThreadSource.d.ts +41 -0
- package/dist/src/gateway/scenes/slackThreadSource.js +168 -0
- package/dist/src/gateway/security/gateway-scopes.d.ts +1 -1
- package/dist/src/gateway/security/gateway-scopes.js +5 -0
- package/dist/src/gateway/service/app-context-access.d.ts +11 -0
- package/dist/src/gateway/service/app-context-access.js +70 -0
- package/dist/src/gateway/service/run-gateway-agent.js +11 -2
- package/dist/src/gateway/service/session-input-coordinator.js +54 -15
- package/dist/src/gateway/service/sessions-api.d.ts +1 -0
- package/dist/src/gateway/service/sessions-api.js +3 -0
- package/dist/src/gateway/service/task-conversation-query-service.d.ts +3 -1
- package/dist/src/gateway/service/task-conversation-query-service.js +32 -3
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +69 -15
- package/dist/src/gateway/session-context-summary.js +2 -1
- package/dist/src/{tasks/task-outbox-dispatcher.d.ts → infra/domain-outbox-dispatcher.d.ts} +2 -2
- package/dist/src/{tasks/task-outbox-dispatcher.js → infra/domain-outbox-dispatcher.js} +10 -9
- package/dist/src/infra/operation-context.d.ts +2 -0
- package/dist/src/infra/operation-context.js +16 -0
- package/dist/src/local-apps/capabilities/contracts.d.ts +2 -0
- package/dist/src/local-apps/capabilities/contracts.js +32 -0
- package/dist/src/local-apps/capabilities/read.d.ts +3 -0
- package/dist/src/local-apps/capabilities/read.js +48 -0
- package/dist/src/local-apps/capabilities/runtime.d.ts +16 -0
- package/dist/src/local-apps/capabilities/runtime.js +66 -0
- package/dist/src/local-apps/capabilities/write.d.ts +3 -0
- package/dist/src/local-apps/capabilities/write.js +35 -0
- package/dist/src/local-apps/release-lock.d.ts +2 -0
- package/dist/src/local-apps/release-lock.js +20 -0
- package/dist/src/local-apps/runtime-entry.d.ts +0 -2
- package/dist/src/local-apps/runtime-entry.js +1 -14
- package/dist/src/local-apps/scaffold.js +4 -1
- package/dist/src/local-apps/service.d.ts +24 -1
- package/dist/src/local-apps/service.js +186 -43
- package/dist/src/local-apps/store.js +0 -2
- package/dist/src/mcp/capability-server.d.ts +4 -0
- package/dist/src/mcp/capability-server.js +96 -0
- package/dist/src/mcp/channel-bridge.js +1 -1
- package/dist/src/mcp/gateway-http-client.d.ts +7 -0
- package/dist/src/mcp/gateway-http-client.js +27 -5
- package/dist/src/media-understanding/openai-compatible-audio.js +1 -1
- package/dist/src/notes/agent-context.js +1 -1
- package/dist/src/notes/capabilities/read.d.ts +3 -0
- package/dist/src/notes/capabilities/read.js +96 -0
- package/dist/src/notes/capabilities/write.d.ts +7 -0
- package/dist/src/notes/capabilities/write.js +152 -0
- package/dist/src/notes/index.js +1 -1
- package/dist/src/notes/service.d.ts +12 -4
- package/dist/src/notes/service.js +188 -175
- package/dist/src/notes/store.d.ts +14 -9
- package/dist/src/notes/store.js +81 -21
- package/dist/src/notifications/service.d.ts +1 -0
- package/dist/src/notifications/service.js +5 -0
- package/dist/src/platform/client.d.ts +1 -1
- package/dist/src/platform/contracts.d.ts +1 -1
- package/dist/src/projects/capabilities/read.d.ts +3 -0
- package/dist/src/projects/capabilities/read.js +81 -0
- package/dist/src/projects/capabilities/write.d.ts +9 -0
- package/dist/src/projects/capabilities/write.js +260 -0
- package/dist/src/projects/index.js +2 -2
- package/dist/src/projects/project-change-events.d.ts +2 -0
- package/dist/src/projects/project-change-events.js +18 -0
- package/dist/src/projects/project-service.d.ts +11 -0
- package/dist/src/projects/project-service.js +121 -42
- package/dist/src/projects/project-store.js +12 -2
- package/dist/src/projects/project-workspace-creation.d.ts +3 -0
- package/dist/src/projects/project-workspace-creation.js +45 -0
- package/dist/src/projects/workspace-project.js +6 -0
- package/dist/src/providers/model-catalog-types.d.ts +2 -1
- package/dist/src/providers/model-reference-auditor.js +4 -4
- package/dist/src/providers/model-supplements.js +13 -3
- package/dist/src/providers/presentation.js +3 -3
- package/dist/src/providers/xopc-cloud-model-source.js +4 -2
- package/dist/src/realtime/runtime.js +4 -0
- package/dist/src/scenes/capabilities/read.d.ts +3 -0
- package/dist/src/scenes/capabilities/read.js +187 -0
- package/dist/src/scenes/capabilities/write.d.ts +3 -0
- package/dist/src/scenes/capabilities/write.js +151 -0
- package/dist/src/scenes/contracts.d.ts +2 -105
- package/dist/src/scenes/contracts.js +3 -88
- package/dist/src/scenes/execution.d.ts +1 -1
- package/dist/src/scenes/httpServices.d.ts +2 -0
- package/dist/src/scenes/inbox.d.ts +1 -0
- package/dist/src/scenes/inbox.js +7 -7
- package/dist/src/scenes/preferences.d.ts +3 -24
- package/dist/src/scenes/preferences.js +8 -30
- package/dist/src/scenes/repository.d.ts +1 -0
- package/dist/src/scenes/repository.js +7 -3
- package/dist/src/scenes/resultNotifications.js +2 -2
- package/dist/src/scenes/schedule.d.ts +1 -8
- package/dist/src/scenes/schedule.js +3 -15
- package/dist/src/scenes/service.d.ts +6 -0
- package/dist/src/scenes/service.js +29 -25
- package/dist/src/scenes/taskFollowUp/agentExecutor.d.ts +36 -0
- package/dist/src/scenes/taskFollowUp/agentExecutor.js +149 -0
- package/dist/src/scenes/taskFollowUp/branchInventory.d.ts +38 -0
- package/dist/src/scenes/taskFollowUp/branchInventory.js +70 -0
- package/dist/src/scenes/taskFollowUp/contracts.d.ts +91 -0
- package/dist/src/scenes/taskFollowUp/contracts.js +100 -0
- package/dist/src/scenes/taskFollowUp/resources.d.ts +19 -0
- package/dist/src/scenes/taskFollowUp/resources.js +97 -0
- package/dist/src/scenes/taskFollowUp/service.d.ts +810 -0
- package/dist/src/scenes/taskFollowUp/service.js +710 -0
- package/dist/src/scenes/taskFollowUp/workspaceFingerprint.d.ts +2 -0
- package/dist/src/scenes/taskFollowUp/workspaceFingerprint.js +46 -0
- package/dist/src/scenes/templates.d.ts +2 -2
- package/dist/src/scenes/templates.js +1 -1
- package/dist/src/session/session-find.d.ts +17 -0
- package/dist/src/session/session-find.js +56 -0
- package/dist/src/session/store.d.ts +4 -0
- package/dist/src/session/store.js +43 -7
- package/dist/src/share/note-share-revocation.d.ts +3 -0
- package/dist/src/share/note-share-revocation.js +26 -0
- package/dist/src/storage/sqlite/migrations/190_scene_development.sql +37 -0
- package/dist/src/storage/sqlite/migrations/191_scene_task_follow_up.sql +27 -0
- package/dist/src/storage/sqlite/migrations/192_capability_operations.sql +20 -0
- package/dist/src/storage/sqlite/migrations/193_note_file_cleanup.sql +8 -0
- package/dist/src/storage/sqlite/migrations/194_capability_external_outcomes.sql +11 -0
- package/dist/src/storage/sqlite/migrations/195_automation_deleted_revisions.sql +4 -0
- package/dist/src/storage/sqlite/migrations/196_automation_run_requests.sql +23 -0
- package/dist/src/storage/sqlite/migrations/197_note_deletion_cleanup.sql +8 -0
- package/dist/src/storage/sqlite/migrations/198_project_workspace_creation.sql +7 -0
- package/dist/src/storage/sqlite/migrations/199_scene_resource_events.sql +488 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +6 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/transaction.d.ts +5 -0
- package/dist/src/storage/sqlite/transaction.js +34 -3
- package/dist/src/tasks/capabilities/management.d.ts +195 -0
- package/dist/src/tasks/capabilities/management.js +111 -0
- package/dist/src/tasks/capabilities/read.d.ts +2 -0
- package/dist/src/tasks/capabilities/read.js +141 -0
- package/dist/src/tasks/capabilities/relations.d.ts +204 -0
- package/dist/src/tasks/capabilities/relations.js +140 -0
- package/dist/src/tasks/capabilities/runs.d.ts +2 -0
- package/dist/src/tasks/capabilities/runs.js +89 -0
- package/dist/src/tasks/capabilities/write.d.ts +207 -0
- package/dist/src/tasks/capabilities/write.js +107 -0
- package/dist/src/tasks/home-query-service.js +3 -2
- package/dist/src/tasks/index.d.ts +0 -1
- package/dist/src/tasks/index.js +9 -9
- package/dist/src/tasks/project-operating-view-service.js +2 -1
- package/dist/src/tasks/task-application-service.d.ts +1 -0
- package/dist/src/tasks/task-application-service.js +3 -2
- package/dist/src/tasks/task-change-events.js +5 -3
- package/dist/src/tasks/task-context-assembler.js +2 -1
- package/dist/src/tasks/task-deletion-service.js +2 -1
- package/dist/src/tasks/task-dependency-service.js +2 -1
- package/dist/src/tasks/task-handoff-service.js +2 -1
- package/dist/src/tasks/task-read-model-projector.js +2 -1
- package/dist/src/tasks/task-repository.d.ts +12 -7
- package/dist/src/tasks/task-repository.js +175 -154
- package/dist/src/tasks/task-run-coordinator.js +2 -1
- package/dist/src/tasks/task-run-dispatcher.js +2 -1
- package/dist/src/tasks/task-run-repository.d.ts +1 -0
- package/dist/src/tasks/task-run-repository.js +29 -14
- package/dist/src/tasks/task-signal-service.js +2 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/user-context/config.d.ts +13 -0
- package/dist/src/user-context/config.js +2 -0
- package/dist/src/voice/platform-catalog.d.ts +1 -1
- package/dist/src/voice/realtime/runtime.js +3 -3
- package/dist/src/voice/stt/providers/alibaba-transcription.js +1 -1
- package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +1 -1
- package/dist/src/voice/tts/providers/xopc-cloud-speech.js +1 -1
- package/dist/src/work-discovery/incremental-repository.js +1 -1
- package/dist/src/work-discovery/index.js +1 -1
- package/dist/src/work-discovery/repository.d.ts +1 -1
- package/dist/src/work-discovery/repository.js +3 -2
- package/dist/src/work-discovery/service.d.ts +4 -0
- package/dist/src/work-discovery/service.js +36 -11
- package/dist/src/workflows/context/workflow-context.js +3 -2
- package/dist/src/workflows/service/workflow-run-service.js +2 -1
- package/package.json +6 -2
- package/skills/THIRD_PARTY_NOTICES.md +2 -2
- package/skills/documents/xlsx/SKILL.md +5 -0
- package/skills/engineering/build-xopc-local-app/SKILL.md +2 -0
- package/skills/tools/find-skills/SKILL.md +3 -0
- package/dist/gateway/static/root/assets/activity-store-DVUTs1fk.js +0 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-K3hTmu9d.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-CU52MfIT.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-ZpA1-6ad.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-IEAxKRME.js +0 -7
- package/dist/gateway/static/root/assets/browser-settings-page-CU4VWsmX.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C9XQk3HL.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-Bqlhjooi.js +0 -1
- package/dist/gateway/static/root/assets/connector-service-page-BmH17JnO.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-zkx8Q-e6.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-settings-CE4GOlMM.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-CdKJqnnw.js +0 -1
- package/dist/gateway/static/root/assets/files-Be5viEFY.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-CGOW0-b4.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-D4um_sV7.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CgXp2zq4.js +0 -1
- package/dist/gateway/static/root/assets/home-page-D6Idk732.js +0 -1
- package/dist/gateway/static/root/assets/index-1wIKA-kM.css +0 -1
- package/dist/gateway/static/root/assets/index-PFQHPGgi.js +0 -79
- package/dist/gateway/static/root/assets/local-app-workbench-page-BmAqTRb4.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-ZjVYXXyM.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-CSTkYVOZ.js +0 -1
- package/dist/gateway/static/root/assets/messages-4BtQKYlM.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-DuXCt-MM.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BjOgBVq5.js +0 -8
- package/dist/gateway/static/root/assets/product-delivery-CrAI8ZEa.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-0zi4-i9X.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B18OxmJj.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-z-DxbuaE.js +0 -1
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DGsBTbo6.js +0 -5
- package/dist/gateway/static/root/assets/scenes-page-Bgba03B_.js +0 -1
- package/dist/gateway/static/root/assets/schemas-BaskVM5g.js +0 -64
- package/dist/gateway/static/root/assets/sessions-page-B1t3bMsm.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CBX0Ezhf.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Bw71C2X3.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BoVDQolc.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DtTptpAt.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-vgkiGo-D.js +0 -1
- package/dist/gateway/static/root/assets/theme-store-CegIlB8d.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-CAGafNfP.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-CSxHVs1p.js +0 -6
- package/skills/creative/algorithmic-art/SKILL.md +0 -44
- package/skills/creative/algorithmic-art/templates/generator-template.js +0 -27
- package/skills/creative/algorithmic-art/templates/viewer.html +0 -27
|
@@ -3,10 +3,10 @@ import { resolveProjectAgentId } from "../../../projects/project-agent.js";
|
|
|
3
3
|
import "../../../projects/index.js";
|
|
4
4
|
import { messagesToClientHistory } from "../../../session/client-history.js";
|
|
5
5
|
import { validateWorkflowDefinitionInput } from "../../../workflows/domain/validation.js";
|
|
6
|
+
import { WorkflowDraftService } from "../../../workflows/draft/workflow-draft-service.js";
|
|
6
7
|
import { WorkflowNameConflictError, WorkflowRevisionConflictError, createWorkflowCatalog } from "../../../agent/workflow/catalog.js";
|
|
7
8
|
import "../../../workflows/domain/index.js";
|
|
8
9
|
import { resolveWorkflowRunArtifactsDir } from "../../../workflows/store/paths.js";
|
|
9
|
-
import { WorkflowDraftService } from "../../../workflows/draft/workflow-draft-service.js";
|
|
10
10
|
import { WorkflowDraftConflictError, WorkflowDraftStore } from "../../../workflows/authoring/workflow-draft-store.js";
|
|
11
11
|
import "../../../workflows/authoring/index.js";
|
|
12
12
|
import "../../../workflows/draft/index.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { TaskRepository } from "../tasks/task-repository.js";
|
|
1
|
+
import { TaskRepository, init_task_repository } from "../tasks/task-repository.js";
|
|
2
2
|
import { FileServiceError } from "../files/file-service.js";
|
|
3
3
|
import { resolveMediaReference } from "../media/media-reference.js";
|
|
4
4
|
import { pendingTranscriptReferencesMediaUri } from "../agent/inbound/attachment-pipeline.js";
|
|
5
5
|
import { TaskContextRepository } from "../tasks/task-context-repository.js";
|
|
6
6
|
import { messagesReferenceMediaUri } from "../media/session-references.js";
|
|
7
7
|
//#region src/gateway/media-access.ts
|
|
8
|
+
init_task_repository();
|
|
8
9
|
/** Resolve media only when the supplied session or task references it. */
|
|
9
10
|
async function resolveScopedMediaReference(service, uri, scope) {
|
|
10
11
|
const { conversationId, taskId } = scope;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getProviderRegistry, init_plugin_registry } from "../providers/plugin-registry.js";
|
|
2
2
|
import { PROVIDER_META, getAvailableModels, init_providers } from "../providers/index.js";
|
|
3
|
-
import { resolveSpeechProviderChain } from "../voice/tts/factory.js";
|
|
4
|
-
import { mergeTtsConfigFromAppConfig } from "../voice/tts/merge-config.js";
|
|
5
3
|
import { resolveSTTProviderChain } from "../voice/stt/factory.js";
|
|
6
4
|
import { mergeSttConfigFromAppConfig } from "../voice/stt/config.js";
|
|
5
|
+
import { resolveSpeechProviderChain } from "../voice/tts/factory.js";
|
|
6
|
+
import { mergeTtsConfigFromAppConfig } from "../voice/tts/merge-config.js";
|
|
7
7
|
import { getVoiceProviderMetadata } from "../voice/metadata/registry.js";
|
|
8
8
|
import "../voice/metadata/index.js";
|
|
9
9
|
import { getImageGenerationCatalog } from "./image-generation-setup.js";
|
|
@@ -2,8 +2,9 @@ import { createLogger } from "../../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { assertSceneStorageReady, init_scenes_schema } from "../../storage/sqlite/scenes-schema.js";
|
|
4
4
|
import { init_providers, isProviderConfiguredSync, resolveModel } from "../../providers/index.js";
|
|
5
|
-
import { BrowserSubscriptionService } from "../../notifications/browserSubscriptions.js";
|
|
6
5
|
import { SceneRepository } from "../../scenes/repository.js";
|
|
6
|
+
import { SceneApplicationService } from "../../scenes/service.js";
|
|
7
|
+
import { BrowserSubscriptionService } from "../../notifications/browserSubscriptions.js";
|
|
7
8
|
import { ScenePreferenceService } from "../../scenes/preferences.js";
|
|
8
9
|
import { SceneExecutionService } from "../../scenes/execution.js";
|
|
9
10
|
import { SceneAgentExecutor } from "../../scenes/agentExecutor.js";
|
|
@@ -14,11 +15,13 @@ import { SceneMetrics } from "../../scenes/metrics.js";
|
|
|
14
15
|
import { resolveSceneModelRef } from "../../scenes/model.js";
|
|
15
16
|
import { SceneResultNotifications } from "../../scenes/resultNotifications.js";
|
|
16
17
|
import { SceneRuntime } from "../../scenes/runtime.js";
|
|
17
|
-
import { SceneApplicationService } from "../../scenes/service.js";
|
|
18
18
|
import { familyPlanTemplate, mailFollowUpTemplate } from "../../scenes/templates.js";
|
|
19
19
|
import { SceneUserNotesProvider } from "../../scenes/userNotes.js";
|
|
20
20
|
import { createSceneBrowserDispatcher } from "./browserNotifications.js";
|
|
21
21
|
import { GatewaySceneMailContext } from "./mailContext.js";
|
|
22
|
+
import { SlackThreadSource } from "./slackThreadSource.js";
|
|
23
|
+
import { TaskSourceRegistry } from "../../scenes/taskFollowUp/contracts.js";
|
|
24
|
+
import { TaskFollowUpService } from "../../scenes/taskFollowUp/service.js";
|
|
22
25
|
//#region src/gateway/scenes/host.ts
|
|
23
26
|
init_providers();
|
|
24
27
|
init_scenes_schema();
|
|
@@ -61,7 +64,13 @@ var GatewaySceneHost = class {
|
|
|
61
64
|
};
|
|
62
65
|
const grant = async (activation) => authorize(activation);
|
|
63
66
|
const executor = input.executor ?? new SceneAgentExecutor(() => resolveModel(resolveSceneModelRef(input.config())));
|
|
67
|
+
const slackThread = new SlackThreadSource(db);
|
|
68
|
+
const followUps = new TaskFollowUpService(db, {
|
|
69
|
+
config: input.config,
|
|
70
|
+
sources: new TaskSourceRegistry([slackThread])
|
|
71
|
+
});
|
|
64
72
|
this.http = {
|
|
73
|
+
followUps,
|
|
65
74
|
repository,
|
|
66
75
|
mail,
|
|
67
76
|
mailDiscovery: mail instanceof GatewaySceneMailContext ? mail : void 0,
|
|
@@ -90,6 +99,7 @@ var GatewaySceneHost = class {
|
|
|
90
99
|
assertSceneStorageReady(this.db);
|
|
91
100
|
this.runtime.start();
|
|
92
101
|
const poll = () => {
|
|
102
|
+
this.http.followUps?.tick().catch((err) => log.error({ err }, "Task follow-up check failed"));
|
|
93
103
|
try {
|
|
94
104
|
if (this.clock() >= this.nextMaintenanceAt) {
|
|
95
105
|
maintainSceneStorage(this.db, this.clock());
|
|
@@ -108,7 +118,7 @@ var GatewaySceneHost = class {
|
|
|
108
118
|
tick() {
|
|
109
119
|
if (this.stopped) return Promise.reject(/* @__PURE__ */ new Error("Scene host stopped"));
|
|
110
120
|
if (this.active) return this.active;
|
|
111
|
-
const work = this.runtime.tick().then(() => {
|
|
121
|
+
const work = Promise.all([this.runtime.tick(), this.http.followUps?.tick()]).then(() => {
|
|
112
122
|
if (!this.stopped) this.notifications.drain();
|
|
113
123
|
});
|
|
114
124
|
this.active = work.finally(() => {
|
|
@@ -121,6 +131,7 @@ var GatewaySceneHost = class {
|
|
|
121
131
|
this.stopped = true;
|
|
122
132
|
if (this.timer) clearInterval(this.timer);
|
|
123
133
|
this.timer = void 0;
|
|
134
|
+
await this.http.followUps?.stop();
|
|
124
135
|
await this.runtime.stop();
|
|
125
136
|
await this.browserDispatcher.stop();
|
|
126
137
|
await this.active?.catch(() => void 0);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getConnectorConnection, getConnectorInstallation, init_connector_repository } from "../../storage/sqlite/connector-repository.js";
|
|
2
2
|
import { ComposioSessionsAdapter } from "../../connectors/composio-sessions.js";
|
|
3
3
|
import { getConnectorDefinition } from "../../connectors/catalog.js";
|
|
4
|
+
import { sceneContentHash } from "../../scenes/contracts.js";
|
|
4
5
|
import { normalizeConnectedSourceResult } from "../../connectors/connected-source-normalizers.js";
|
|
5
6
|
import { sanitizeConnectedSourceValue } from "../../connectors/connected-source-sanitization.js";
|
|
6
|
-
import { sceneContentHash } from "../../scenes/contracts.js";
|
|
7
7
|
import { SceneSourceNotReady, sceneSourceFailureReason } from "../../scenes/readiness.js";
|
|
8
8
|
import { SceneMailContextProvider } from "../../scenes/mailContext.js";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { ComposioSessionsAdapter } from '../../connectors/composio-sessions.js';
|
|
4
|
+
import { type ScenePrincipal } from '../../scenes/contracts.js';
|
|
5
|
+
import type { TaskSourceAdapter, SourceSnapshot } from '../../scenes/taskFollowUp/contracts.js';
|
|
6
|
+
export declare const slackThreadSchema: z.ZodObject<{
|
|
7
|
+
accountId: z.ZodString;
|
|
8
|
+
teamId: z.ZodString;
|
|
9
|
+
channelId: z.ZodString;
|
|
10
|
+
threadTs: z.ZodString;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export type SlackThread = z.infer<typeof slackThreadSchema>;
|
|
13
|
+
/** Parse locally; never fetch a user-supplied URL. Reply links resolve to their root. */
|
|
14
|
+
export declare function parseSlackThreadUrl(value: string): {
|
|
15
|
+
channelId: string;
|
|
16
|
+
threadTs: string;
|
|
17
|
+
};
|
|
18
|
+
/** Read-only connector adapter. Account policy is rechecked before and after every page. */
|
|
19
|
+
export declare class SlackThreadSource implements TaskSourceAdapter {
|
|
20
|
+
private readonly db;
|
|
21
|
+
private readonly adapter;
|
|
22
|
+
readonly id = "slack_thread";
|
|
23
|
+
readonly label = "Slack thread";
|
|
24
|
+
normalize(reference: Record<string, string>): {
|
|
25
|
+
accountId: string;
|
|
26
|
+
teamId: string;
|
|
27
|
+
channelId: string;
|
|
28
|
+
threadTs: string;
|
|
29
|
+
};
|
|
30
|
+
accountIds(reference: Record<string, string>): string[];
|
|
31
|
+
authorized(principal: ScenePrincipal, reference: Record<string, string>): boolean;
|
|
32
|
+
constructor(db: DatabaseSync, adapter?: Pick<ComposioSessionsAdapter, 'executeWithPolicy'>);
|
|
33
|
+
listAccounts(principal: ScenePrincipal): Array<{
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
}>;
|
|
37
|
+
private connection;
|
|
38
|
+
private call;
|
|
39
|
+
resolveLink(principal: ScenePrincipal, accountId: string, url: string, signal: AbortSignal): Promise<SlackThread>;
|
|
40
|
+
read(principal: ScenePrincipal, reference: Record<string, string>, signal: AbortSignal): Promise<SourceSnapshot>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { getConnectorConnection, getConnectorInstallation, init_connector_repository } from "../../storage/sqlite/connector-repository.js";
|
|
2
|
+
import { ComposioSessionsAdapter } from "../../connectors/composio-sessions.js";
|
|
3
|
+
import { getConnectorDefinition } from "../../connectors/catalog.js";
|
|
4
|
+
import { sceneContentHash } from "../../scenes/contracts.js";
|
|
5
|
+
import { sanitizeConnectedSourceValue } from "../../connectors/connected-source-sanitization.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
//#region src/gateway/scenes/slackThreadSource.ts
|
|
8
|
+
init_connector_repository();
|
|
9
|
+
const slackThreadSchema = z.strictObject({
|
|
10
|
+
accountId: z.string().min(1).max(200),
|
|
11
|
+
teamId: z.string().regex(/^T[A-Z0-9]+$/),
|
|
12
|
+
channelId: z.string().regex(/^[CDG][A-Z0-9]+$/),
|
|
13
|
+
threadTs: z.string().regex(/^\d{10,}\.\d{6}$/)
|
|
14
|
+
});
|
|
15
|
+
/** Parse locally; never fetch a user-supplied URL. Reply links resolve to their root. */
|
|
16
|
+
function parseSlackThreadUrl(value) {
|
|
17
|
+
const url = new URL(value);
|
|
18
|
+
if (url.protocol !== "https:" || !/^[a-z0-9-]+\.slack\.com$/.test(url.hostname) || url.username || url.password || url.port) throw new Error("Expected a Slack message link");
|
|
19
|
+
const match = /^\/archives\/([CDG][A-Z0-9]+)\/p(\d{16,})$/.exec(url.pathname);
|
|
20
|
+
if (!match) throw new Error("Expected a Slack message link");
|
|
21
|
+
const threadTs = url.searchParams.get("thread_ts") ?? `${match[2].slice(0, -6)}.${match[2].slice(-6)}`;
|
|
22
|
+
if (!/^\d{10,}\.\d{6}$/.test(threadTs)) throw new Error("Invalid Slack thread timestamp");
|
|
23
|
+
return {
|
|
24
|
+
channelId: match[1],
|
|
25
|
+
threadTs
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
29
|
+
/** Read-only connector adapter. Account policy is rechecked before and after every page. */
|
|
30
|
+
var SlackThreadSource = class {
|
|
31
|
+
id = "slack_thread";
|
|
32
|
+
label = "Slack thread";
|
|
33
|
+
normalize(reference) {
|
|
34
|
+
return slackThreadSchema.parse(reference);
|
|
35
|
+
}
|
|
36
|
+
accountIds(reference) {
|
|
37
|
+
return [this.normalize(reference).accountId];
|
|
38
|
+
}
|
|
39
|
+
authorized(principal, reference) {
|
|
40
|
+
return this.listAccounts(principal).some((account) => account.id === this.normalize(reference).accountId);
|
|
41
|
+
}
|
|
42
|
+
constructor(db, adapter = new ComposioSessionsAdapter()) {
|
|
43
|
+
this.db = db;
|
|
44
|
+
this.adapter = adapter;
|
|
45
|
+
}
|
|
46
|
+
listAccounts(principal) {
|
|
47
|
+
return this.db.prepare(`SELECT a.id, a.label, c.connector_id FROM connector_accounts a
|
|
48
|
+
JOIN connector_connections c ON c.id = a.current_connection_id AND c.account_id = a.id
|
|
49
|
+
AND c.principal_id = a.principal_id AND c.connector_id = a.connector_id
|
|
50
|
+
JOIN connector_installations i ON i.id = c.installation_id AND i.principal_id = a.principal_id AND i.connector_id = a.connector_id
|
|
51
|
+
WHERE a.principal_id = ? AND a.enabled = 1 AND c.status = 'active' AND c.provider = 'composio'
|
|
52
|
+
AND i.enabled = 1 AND i.confirmation_policy <> 'always'
|
|
53
|
+
AND json_array_length(i.allowed_agent_ids_json) = 0 AND a.allowed_agent_ids_json IS NULL
|
|
54
|
+
AND (i.selected_account_ids_json = 'null' OR EXISTS (SELECT 1 FROM json_each(i.selected_account_ids_json) WHERE value = a.id))
|
|
55
|
+
AND (c.expires_at IS NULL OR julianday(c.expires_at) > julianday('now')) ORDER BY a.id LIMIT 100`).all(principal.ownerId).filter((row) => {
|
|
56
|
+
const definition = getConnectorDefinition(String(row.connector_id));
|
|
57
|
+
return definition?.runtime.type === "composio" && definition.runtime.toolkit === "slack";
|
|
58
|
+
}).map((row) => ({
|
|
59
|
+
id: String(row.id),
|
|
60
|
+
label: String(row.label || row.id).slice(0, 300)
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
connection(principal, accountId) {
|
|
64
|
+
if (!this.listAccounts(principal).some((account) => account.id === accountId)) throw new Error("Slack account permission unavailable");
|
|
65
|
+
const row = this.db.prepare("SELECT current_connection_id FROM connector_accounts WHERE id = ?").get(accountId);
|
|
66
|
+
return getConnectorConnection(String(row.current_connection_id));
|
|
67
|
+
}
|
|
68
|
+
async call(principal, accountId, actionId, args, signal) {
|
|
69
|
+
signal.throwIfAborted();
|
|
70
|
+
const connection = this.connection(principal, accountId);
|
|
71
|
+
const installation = getConnectorInstallation(connection.installationId);
|
|
72
|
+
const day = Math.floor(Date.now() / 864e5);
|
|
73
|
+
const usage = this.db.prepare("SELECT request_count FROM scene_connector_usage WHERE owner_id = ? AND workspace_id = ? AND account_id = ? AND utc_day = ?").get(principal.ownerId, principal.workspaceId, accountId, day);
|
|
74
|
+
if (Number(usage?.request_count ?? 0) >= 3e3) throw new Error("Slack daily request budget exhausted");
|
|
75
|
+
this.db.prepare(`INSERT INTO scene_connector_usage VALUES (?, ?, ?, ?, 1)
|
|
76
|
+
ON CONFLICT(owner_id, workspace_id, account_id, utc_day) DO UPDATE SET request_count = request_count + 1`).run(principal.ownerId, principal.workspaceId, accountId, day);
|
|
77
|
+
const result = await this.adapter.executeWithPolicy({
|
|
78
|
+
context: {
|
|
79
|
+
principalId: principal.ownerId,
|
|
80
|
+
toolkits: ["slack"]
|
|
81
|
+
},
|
|
82
|
+
connection,
|
|
83
|
+
installation,
|
|
84
|
+
signal,
|
|
85
|
+
args,
|
|
86
|
+
action: {
|
|
87
|
+
connectorId: connection.connectorId,
|
|
88
|
+
toolkit: "slack",
|
|
89
|
+
actionId,
|
|
90
|
+
scope: "read",
|
|
91
|
+
curated: true,
|
|
92
|
+
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
signal.throwIfAborted();
|
|
96
|
+
if (this.connection(principal, accountId).id !== connection.id) throw new Error("Slack connection changed");
|
|
97
|
+
if (result.decision !== "allowed") throw new Error("Slack read requires permission");
|
|
98
|
+
const envelope = object(result.result);
|
|
99
|
+
const data = object(envelope.data);
|
|
100
|
+
if (envelope.successful === false || envelope.error || data.ok === false || data.error || !Object.keys(data).length) throw new Error("Slack source unavailable; check connection permissions or rate limit");
|
|
101
|
+
return data;
|
|
102
|
+
}
|
|
103
|
+
async resolveLink(principal, accountId, url, signal) {
|
|
104
|
+
const parsed = parseSlackThreadUrl(url);
|
|
105
|
+
const auth = await this.call(principal, accountId, "SLACK_TEST_AUTH", {}, signal);
|
|
106
|
+
if (typeof auth.team_id !== "string" || !/^T[A-Z0-9]+$/.test(auth.team_id)) throw new Error("Slack workspace identity unavailable");
|
|
107
|
+
return {
|
|
108
|
+
accountId,
|
|
109
|
+
teamId: auth.team_id,
|
|
110
|
+
...parsed
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async read(principal, reference, signal) {
|
|
114
|
+
const thread = this.normalize(reference);
|
|
115
|
+
if ((await this.call(principal, thread.accountId, "SLACK_TEST_AUTH", {}, signal)).team_id !== thread.teamId) throw new Error("Slack workspace identity changed");
|
|
116
|
+
const messages = /* @__PURE__ */ new Map();
|
|
117
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
118
|
+
let cursor;
|
|
119
|
+
do {
|
|
120
|
+
const data = await this.call(principal, thread.accountId, "SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION", {
|
|
121
|
+
channel: thread.channelId,
|
|
122
|
+
ts: thread.threadTs,
|
|
123
|
+
limit: 100,
|
|
124
|
+
...cursor ? { cursor } : {}
|
|
125
|
+
}, signal);
|
|
126
|
+
if (!Array.isArray(data.messages) || !data.messages.length) throw new Error("Slack thread is missing or incomplete");
|
|
127
|
+
for (const item of data.messages) {
|
|
128
|
+
const message = object(item);
|
|
129
|
+
if (typeof message.ts !== "string" || typeof message.text !== "string" || message.ts !== thread.threadTs && message.thread_ts !== thread.threadTs) throw new Error("Unexpected Slack thread response");
|
|
130
|
+
messages.set(message.ts, {
|
|
131
|
+
ts: message.ts,
|
|
132
|
+
user: String(message.user ?? message.bot_id ?? "unknown"),
|
|
133
|
+
text: String(sanitizeConnectedSourceValue(message.text)),
|
|
134
|
+
...Array.isArray(message.files) && message.files.length || Array.isArray(message.attachments) && message.attachments.length ? { unreadAttachments: sanitizeConnectedSourceValue({
|
|
135
|
+
files: Array.isArray(message.files) ? message.files.slice(0, 20).map((value) => {
|
|
136
|
+
const file = object(value);
|
|
137
|
+
return {
|
|
138
|
+
id: file.id,
|
|
139
|
+
name: file.name,
|
|
140
|
+
mimetype: file.mimetype
|
|
141
|
+
};
|
|
142
|
+
}) : [],
|
|
143
|
+
richMessageCount: Array.isArray(message.attachments) ? message.attachments.length : 0,
|
|
144
|
+
contentFetched: false
|
|
145
|
+
}) } : {}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (messages.size > 200) throw new Error("Slack thread exceeds the 200-message context budget");
|
|
149
|
+
const next = object(data.response_metadata).next_cursor;
|
|
150
|
+
if (next != null && typeof next !== "string") throw new Error("Invalid Slack pagination");
|
|
151
|
+
cursor = typeof next === "string" && next.trim() ? next.trim() : void 0;
|
|
152
|
+
if (data.has_more === true && !cursor) throw new Error("Slack thread pagination is incomplete");
|
|
153
|
+
if (cursor && (cursors.has(cursor) || cursors.size >= 9)) throw new Error("Slack pagination budget exceeded");
|
|
154
|
+
if (cursor) cursors.add(cursor);
|
|
155
|
+
} while (cursor);
|
|
156
|
+
if (!messages.has(thread.threadTs)) throw new Error("Select the root of the Slack thread");
|
|
157
|
+
const ordered = [...messages.values()].sort((a, b) => a.ts.localeCompare(b.ts));
|
|
158
|
+
const text = JSON.stringify(ordered);
|
|
159
|
+
if (text.length > 32e3) throw new Error("Slack thread exceeds the 32,000-character context budget");
|
|
160
|
+
return {
|
|
161
|
+
revision: sceneContentHash(ordered),
|
|
162
|
+
text,
|
|
163
|
+
observedAt: Date.now()
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
export { SlackThreadSource, parseSlackThreadUrl, slackThreadSchema };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_BROWSER_EXTENSION_SCOPES, DEFAULT_MOBILE_SCOPES, GATEWAY_SCOPES, isGatewayScope, type GatewayScope } from '@xopcai/gateway-contract';
|
|
2
2
|
export { DEFAULT_BROWSER_EXTENSION_SCOPES, DEFAULT_MOBILE_SCOPES, GATEWAY_SCOPES, isGatewayScope, type GatewayScope, };
|
|
3
3
|
export declare function parseGatewayScopes(value: string): GatewayScope[];
|
|
4
|
-
export declare function requiredGatewayScope(method: string, path: string): GatewayScope;
|
|
4
|
+
export declare function requiredGatewayScope(method: string, path: string): GatewayScope | undefined;
|
|
5
5
|
export declare function hasGatewayScope(granted: readonly GatewayScope[], required: GatewayScope): boolean;
|
|
@@ -11,6 +11,8 @@ function methodScope(method, read, write) {
|
|
|
11
11
|
return method === "GET" ? read : write;
|
|
12
12
|
}
|
|
13
13
|
function requiredGatewayScope(method, path) {
|
|
14
|
+
if (/^\/api\/local-app-capabilities\/[^/]+(?:\/[^/]+\/invocations)?$/.test(path)) return void 0;
|
|
15
|
+
if (path === "/api/capabilities/operations" || path.startsWith("/api/capabilities/operations/")) return void 0;
|
|
14
16
|
if (method === "GET" && path === "/api/mobile/privacy") return "gateway.status";
|
|
15
17
|
if (path === "/api/realtime/tickets" || path.startsWith("/api/status")) return "gateway.status";
|
|
16
18
|
if (path === "/api/device-auth/refresh" || path === "/api/devices/me") return "device.self";
|
|
@@ -23,7 +25,10 @@ function requiredGatewayScope(method, path) {
|
|
|
23
25
|
if (path.startsWith("/api/agents") || path.startsWith("/api/models")) return methodScope(method, "agents.read", "gateway.admin");
|
|
24
26
|
if (path.startsWith("/api/sessions") || path.startsWith("/api/side-chats")) return methodScope(method, "sessions.read", "sessions.write");
|
|
25
27
|
if (path.startsWith("/api/tasks")) return methodScope(method, "tasks.read", "tasks.write");
|
|
28
|
+
if (path === "/api/task-runs" || path.startsWith("/api/task-runs/")) return methodScope(method, "tasks.read", "tasks.write");
|
|
26
29
|
if (path.startsWith("/api/home") || path.startsWith("/api/inbox")) return methodScope(method, "tasks.read", "tasks.write");
|
|
30
|
+
if (method === "POST" && path === "/api/automations/simulate") return "automations.read";
|
|
31
|
+
if (method === "POST" && /^\/api\/notes\/[^/]+\/ai\/edit$/.test(path)) return "workspace.read";
|
|
27
32
|
if (path.startsWith("/api/automations") || path.startsWith("/api/automation-runs")) return methodScope(method, "automations.read", "automations.write");
|
|
28
33
|
if (path.startsWith("/api/workflows")) return methodScope(method, "automations.read", "automations.write");
|
|
29
34
|
if (path === "/api/voice/selection" || path === "/api/voice/catalog/refresh") return "voice.configure";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentSourceContext } from '../../agent/source-context/types.js';
|
|
2
|
+
import { type CapabilityDispatcher } from '../../capabilities/runtime/dispatcher.js';
|
|
3
|
+
import type { ResolvedGatewayAuth } from '../auth.js';
|
|
4
|
+
import type { GatewayPrincipal } from '../security/gateway-principal.js';
|
|
5
|
+
export interface AppContextGrant {
|
|
6
|
+
principal: GatewayPrincipal;
|
|
7
|
+
authRevision: string;
|
|
8
|
+
}
|
|
9
|
+
/** A queued read retains its original scope ceiling, but never a revoked identity. */
|
|
10
|
+
export declare function checkAppContextAccess(source: AgentSourceContext, dispatcher: CapabilityDispatcher, auth: ResolvedGatewayAuth): Promise<void>;
|
|
11
|
+
export declare function prepareAppContext(input: unknown, principal: GatewayPrincipal, auth: ResolvedGatewayAuth, dispatcher: CapabilityDispatcher, previous?: AgentSourceContext): Promise<AgentSourceContext>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { parseAppContextEnvelope } from "../../../packages/gateway-contract/src/app-context.js";
|
|
2
|
+
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
3
|
+
import { getDevice } from "../../storage/sqlite/device-access-repository.js";
|
|
4
|
+
import { CapabilityError } from "../../capabilities/runtime/errors.js";
|
|
5
|
+
import { canonicalCapabilityJson } from "../../capabilities/runtime/dispatcher.js";
|
|
6
|
+
import { isBrowserSessionActive } from "../../storage/sqlite/browser-session-repository.js";
|
|
7
|
+
import { appContextToAgentContext } from "../../agent/source-context/app-context.js";
|
|
8
|
+
import { createHmac, randomBytes } from "node:crypto";
|
|
9
|
+
//#region src/gateway/service/app-context-access.ts
|
|
10
|
+
init_src();
|
|
11
|
+
const authorizationEpochKey = randomBytes(32);
|
|
12
|
+
function authRevision(auth) {
|
|
13
|
+
return createHmac("sha256", authorizationEpochKey).update(canonicalCapabilityJson(JSON.parse(JSON.stringify(auth)))).digest("hex");
|
|
14
|
+
}
|
|
15
|
+
/** A queued read retains its original scope ceiling, but never a revoked identity. */
|
|
16
|
+
async function checkAppContextAccess(source, dispatcher, auth) {
|
|
17
|
+
const grant = source.appContextGrant;
|
|
18
|
+
if (!grant || grant.authRevision !== authRevision(auth) || !source.appContext) throw new CapabilityError("FORBIDDEN", "Application context authorization changed");
|
|
19
|
+
const { principal } = grant;
|
|
20
|
+
let scopes = principal.scopes;
|
|
21
|
+
if (principal.kind === "device") {
|
|
22
|
+
const device = principal.deviceId ? getDevice(principal.deviceId) : void 0;
|
|
23
|
+
if (!device || device.revokedAt !== void 0 || device.id !== principal.principalId) throw new CapabilityError("FORBIDDEN", "Application context device access was revoked");
|
|
24
|
+
scopes = scopes.filter((scope) => device.scopes.includes(scope));
|
|
25
|
+
}
|
|
26
|
+
if (principal.browserSessionId && !isBrowserSessionActive(principal.browserSessionId, auth)) throw new CapabilityError("FORBIDDEN", "Application context browser session ended");
|
|
27
|
+
for (const ref of source.appContext.resourceRefs) {
|
|
28
|
+
const domain = ref.kind === "local_app" ? "local_apps" : `${ref.kind}s`;
|
|
29
|
+
await dispatcher.call(`xopc.${domain}.get`, { id: ref.id }, {
|
|
30
|
+
principalId: principal.principalId,
|
|
31
|
+
scopes,
|
|
32
|
+
surface: "http",
|
|
33
|
+
authorize: () => true
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function prepareAppContext(input, principal, auth, dispatcher, previous) {
|
|
38
|
+
let snapshot;
|
|
39
|
+
try {
|
|
40
|
+
snapshot = parseAppContextEnvelope(input);
|
|
41
|
+
} catch {
|
|
42
|
+
throw new CapabilityError("INVALID_INPUT", "Invalid application context envelope");
|
|
43
|
+
}
|
|
44
|
+
const grant = {
|
|
45
|
+
principal: structuredClone(principal),
|
|
46
|
+
authRevision: authRevision(auth)
|
|
47
|
+
};
|
|
48
|
+
if (previous) {
|
|
49
|
+
if (canonicalCapabilityJson(previous.appContext) !== canonicalCapabilityJson(snapshot) || previous.appContextGrant?.principal.principalId !== principal.principalId) throw new CapabilityError("REVISION_CONFLICT", "Submission identity already belongs to another context");
|
|
50
|
+
await checkAppContextAccess(previous, dispatcher, auth);
|
|
51
|
+
await checkAppContextAccess({
|
|
52
|
+
...previous,
|
|
53
|
+
appContextGrant: grant
|
|
54
|
+
}, dispatcher, auth);
|
|
55
|
+
return structuredClone(previous);
|
|
56
|
+
}
|
|
57
|
+
const source = {
|
|
58
|
+
...appContextToAgentContext(await dispatcher.call("xopc.context.resolve", snapshot, {
|
|
59
|
+
principalId: principal.principalId,
|
|
60
|
+
scopes: principal.scopes,
|
|
61
|
+
surface: "http",
|
|
62
|
+
authorize: () => true
|
|
63
|
+
})),
|
|
64
|
+
appContextGrant: grant
|
|
65
|
+
};
|
|
66
|
+
await checkAppContextAccess(source, dispatcher, auth);
|
|
67
|
+
return source;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { checkAppContextAccess, prepareAppContext };
|
|
@@ -11,9 +11,9 @@ import { resolveExecutionContext } from "../../tasks/execution-context.js";
|
|
|
11
11
|
import { TaskRunCoordinator } from "../../tasks/task-run-coordinator.js";
|
|
12
12
|
import { formatAgentRunErrorForClient } from "../../agent/client-error-format.js";
|
|
13
13
|
import "../chat-limits.js";
|
|
14
|
-
import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
|
|
15
14
|
import { ChatStreamMapper } from "../chat-stream/mapper.js";
|
|
16
15
|
import { markdownNotificationPreview } from "../../notifications/plain-text.js";
|
|
16
|
+
import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
|
|
17
17
|
import { resolveWebchatConversationId } from "../resolve-webchat-session-key.js";
|
|
18
18
|
import { recordExplicitRelationshipFollowUp } from "../../user-context/relationship-continuity.js";
|
|
19
19
|
import { coalesceThinkingDeltas } from "../chat-stream/thinking-delta-coalescer.js";
|
|
@@ -142,7 +142,16 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
142
142
|
signal: mergedSignal,
|
|
143
143
|
runId,
|
|
144
144
|
sourceContexts: runOptions?.sourceContexts,
|
|
145
|
-
presentation: runOptions?.presentation
|
|
145
|
+
presentation: runOptions?.presentation,
|
|
146
|
+
onDeferredAudio: (audio) => {
|
|
147
|
+
publishRealtime("sessions", "session.audio_ready", {
|
|
148
|
+
conversationId,
|
|
149
|
+
runId,
|
|
150
|
+
...audio,
|
|
151
|
+
createdAtMs: Date.now()
|
|
152
|
+
});
|
|
153
|
+
emit("session.transcript_updated", { key: conversationId });
|
|
154
|
+
}
|
|
146
155
|
});
|
|
147
156
|
const mappedEvents = (async function* () {
|
|
148
157
|
for await (const event of eventStream) yield* mapper.map(event);
|
|
@@ -9,16 +9,25 @@ import { summarizeSourceContext } from "../../agent/source-context/types.js";
|
|
|
9
9
|
import { deleteMediaUrisNoLongerReferenced } from "../../media/session-references.js";
|
|
10
10
|
import { fitSourceContextsToBudget } from "../../agent/source-context/budget.js";
|
|
11
11
|
import crypto from "node:crypto";
|
|
12
|
+
import { isDeepStrictEqual } from "node:util";
|
|
12
13
|
//#region src/gateway/service/session-input-coordinator.ts
|
|
13
14
|
init_connection_wait_repository();
|
|
14
15
|
init_session_input_repository();
|
|
15
16
|
init_logger();
|
|
16
17
|
const log = createLogger("SessionInputCoordinator");
|
|
17
18
|
const MAX_PENDING_INPUTS = 10;
|
|
19
|
+
function sameAppContext(input, existing) {
|
|
20
|
+
const identity = (sources) => sources?.filter((source) => source.kind === "app_context").map((source) => ({
|
|
21
|
+
snapshot: source.appContext,
|
|
22
|
+
principal: source.appContextGrant?.principal.principalId
|
|
23
|
+
})) ?? [];
|
|
24
|
+
return isDeepStrictEqual(identity(input.sourceContexts), identity(existing.contextSnapshots));
|
|
25
|
+
}
|
|
18
26
|
function contextRefsMatchFrozenSnapshot(requested, frozen) {
|
|
19
|
-
|
|
27
|
+
const editable = frozen?.filter((ref) => ref.kind === "note" || ref.kind === "task") ?? [];
|
|
28
|
+
if (requested.length !== editable.length) return false;
|
|
20
29
|
return requested.every((ref, index) => {
|
|
21
|
-
const snapshot =
|
|
30
|
+
const snapshot = editable[index];
|
|
22
31
|
return snapshot?.kind === ref.kind && snapshot.sourceId === ref.sourceId && ref.expectedVersion === snapshot.version;
|
|
23
32
|
});
|
|
24
33
|
}
|
|
@@ -53,6 +62,7 @@ var SessionInputCoordinator = class {
|
|
|
53
62
|
}
|
|
54
63
|
}
|
|
55
64
|
async submit(input) {
|
|
65
|
+
input = structuredClone(input);
|
|
56
66
|
const conversationId = input.conversationId.trim();
|
|
57
67
|
try {
|
|
58
68
|
return await this.runSubmissionExclusive(conversationId, () => this.submitLocked({
|
|
@@ -68,6 +78,7 @@ var SessionInputCoordinator = class {
|
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
async replaceLatestTurn(input, beforeReplace) {
|
|
81
|
+
input = structuredClone(input);
|
|
71
82
|
const conversationId = input.conversationId.trim();
|
|
72
83
|
return this.runSubmissionExclusive(conversationId, async () => {
|
|
73
84
|
const clientMessageId = input.clientMessageId.trim();
|
|
@@ -81,14 +92,20 @@ var SessionInputCoordinator = class {
|
|
|
81
92
|
ok: false,
|
|
82
93
|
code: "BAD_REQUEST"
|
|
83
94
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
const existing = findSessionInput(conversationId, clientMessageId);
|
|
96
|
+
if (existing) {
|
|
97
|
+
if (!sameAppContext(input, existing)) return {
|
|
98
|
+
ok: false,
|
|
99
|
+
code: "CONTEXT_UNAVAILABLE"
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
ok: true,
|
|
103
|
+
effectiveDelivery: "next",
|
|
104
|
+
state: this.snapshot(conversationId)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
89
107
|
const target = validateLatestSessionTurnTarget(conversationId, targetTurnId);
|
|
90
108
|
if (target.ok === false) return target;
|
|
91
|
-
await beforeReplace();
|
|
92
109
|
const attachments = await this.deps.prepareAttachments(conversationId, input.attachments);
|
|
93
110
|
let sourceContexts;
|
|
94
111
|
try {
|
|
@@ -103,6 +120,7 @@ var SessionInputCoordinator = class {
|
|
|
103
120
|
code: "CONTEXT_UNAVAILABLE"
|
|
104
121
|
};
|
|
105
122
|
}
|
|
123
|
+
await beforeReplace();
|
|
106
124
|
const result = replaceLatestSessionTurnAndQueueInput({
|
|
107
125
|
conversationId,
|
|
108
126
|
targetTurnId,
|
|
@@ -149,11 +167,17 @@ var SessionInputCoordinator = class {
|
|
|
149
167
|
code: "BAD_REQUEST"
|
|
150
168
|
};
|
|
151
169
|
const existing = findSessionInput(conversationId, clientMessageId);
|
|
152
|
-
if (existing)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
170
|
+
if (existing) {
|
|
171
|
+
if (!sameAppContext(input, existing)) return {
|
|
172
|
+
ok: false,
|
|
173
|
+
code: "CONTEXT_UNAVAILABLE"
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
ok: true,
|
|
177
|
+
effectiveDelivery: existing.effectiveDelivery,
|
|
178
|
+
state: this.snapshot(conversationId)
|
|
179
|
+
};
|
|
180
|
+
}
|
|
157
181
|
if (this.snapshot(conversationId).inputs.length >= MAX_PENDING_INPUTS) return {
|
|
158
182
|
ok: false,
|
|
159
183
|
code: "QUEUE_FULL"
|
|
@@ -227,7 +251,21 @@ var SessionInputCoordinator = class {
|
|
|
227
251
|
const runId = crypto.randomUUID();
|
|
228
252
|
const input = claimNextSessionInput(conversationId, runId);
|
|
229
253
|
if (!input) return;
|
|
230
|
-
|
|
254
|
+
let allowed;
|
|
255
|
+
try {
|
|
256
|
+
allowed = (!this.deps.beforeExecute || await this.deps.beforeExecute(input)) && consumeConnectionResume(input) && consumeClarificationResume(input);
|
|
257
|
+
} catch (err) {
|
|
258
|
+
log.warn({
|
|
259
|
+
err,
|
|
260
|
+
conversationId,
|
|
261
|
+
runId,
|
|
262
|
+
inputId: input.id
|
|
263
|
+
}, "Session input preflight failed");
|
|
264
|
+
finishSessionInputRun(conversationId, runId, "failed", "Input preflight failed");
|
|
265
|
+
this.publish(conversationId);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (!allowed) {
|
|
231
269
|
finishSessionInputRun(conversationId, runId, "cancelled");
|
|
232
270
|
this.publish(conversationId);
|
|
233
271
|
continue;
|
|
@@ -272,7 +310,8 @@ var SessionInputCoordinator = class {
|
|
|
272
310
|
if (body.contextRefs !== void 0) {
|
|
273
311
|
const existing = getSessionInputById(conversationId, id);
|
|
274
312
|
if (!contextRefsMatchFrozenSnapshot(body.contextRefs, existing?.contextRefs)) try {
|
|
275
|
-
|
|
313
|
+
const resolved = await this.deps.prepareContexts(body.contextRefs) ?? [];
|
|
314
|
+
sourceContexts = fitSourceContextsToBudget([...existing?.contextSnapshots?.filter((source) => source.kind !== "note" && source.kind !== "task") ?? [], ...resolved]);
|
|
276
315
|
} catch (err) {
|
|
277
316
|
log.warn({
|
|
278
317
|
err,
|
|
@@ -133,6 +133,7 @@ export declare class GatewaySessionsApi {
|
|
|
133
133
|
}>;
|
|
134
134
|
search(query: string): Promise<import("../../session/types.js").SessionMetadata[]>;
|
|
135
135
|
searchIn(key: string, keyword: string): Promise<import("../../session/types.js").Message[]>;
|
|
136
|
+
findMessages(key: string, query: string, limit?: number): Promise<import("../../session/session-find.js").SessionFindResult>;
|
|
136
137
|
export(key: string, format: ExportFormat): Promise<{
|
|
137
138
|
content: string;
|
|
138
139
|
}>;
|
|
@@ -201,6 +201,9 @@ var GatewaySessionsApi = class {
|
|
|
201
201
|
searchIn(key, keyword) {
|
|
202
202
|
return this.opts.sessionIndex.searchInSession(key, keyword);
|
|
203
203
|
}
|
|
204
|
+
findMessages(key, query, limit) {
|
|
205
|
+
return this.opts.sessionIndex.getStore().findInSession(key, query, limit);
|
|
206
|
+
}
|
|
204
207
|
async export(key, format) {
|
|
205
208
|
return { content: await this.opts.sessionIndex.exportSession(key, format) };
|
|
206
209
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SessionFindResult } from '../../session/session-find.js';
|
|
1
2
|
import type { SessionTimelineItem } from '../../session/transcript-outline.js';
|
|
2
3
|
import { TaskConversationRepository } from '../../tasks/task-conversation-repository.js';
|
|
3
4
|
import type { GatewaySessionsApi } from './sessions-api.js';
|
|
@@ -5,7 +6,7 @@ export declare class TaskConversationQueryService {
|
|
|
5
6
|
#private;
|
|
6
7
|
private readonly sessions;
|
|
7
8
|
private readonly conversations;
|
|
8
|
-
constructor(sessions: Pick<GatewaySessionsApi, 'getMessagePage' | 'getTimeline'>, conversations?: Pick<TaskConversationRepository, 'listSessions'>);
|
|
9
|
+
constructor(sessions: Pick<GatewaySessionsApi, 'findMessages' | 'getMessagePage' | 'getTimeline'>, conversations?: Pick<TaskConversationRepository, 'listSessions'>);
|
|
9
10
|
getMessagePage(taskId: string, options: {
|
|
10
11
|
limit: number;
|
|
11
12
|
offset: number;
|
|
@@ -56,4 +57,5 @@ export declare class TaskConversationQueryService {
|
|
|
56
57
|
};
|
|
57
58
|
}>;
|
|
58
59
|
getTimeline(taskId: string): Promise<SessionTimelineItem[] | null>;
|
|
60
|
+
findMessages(taskId: string, query: string, limit?: number): Promise<SessionFindResult | null>;
|
|
59
61
|
}
|