@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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
2
2
|
//#region src/gateway/service/task-conversation-query-service.ts
|
|
3
|
+
function displayMessageCount(items) {
|
|
4
|
+
return items.reduce((count, item) => item.displayIndex === void 0 ? count : Math.max(count, item.displayIndex + 1), 0);
|
|
5
|
+
}
|
|
3
6
|
var TaskConversationQueryService = class {
|
|
4
7
|
constructor(sessions, conversations = new TaskConversationRepository()) {
|
|
5
8
|
this.sessions = sessions;
|
|
@@ -53,8 +56,8 @@ var TaskConversationQueryService = class {
|
|
|
53
56
|
let displayOffset = 0;
|
|
54
57
|
let turnOffset = 0;
|
|
55
58
|
for (const [index, link] of links.entries()) {
|
|
56
|
-
const
|
|
57
|
-
if (!items
|
|
59
|
+
const items = await this.sessions.getTimeline(link.conversationId);
|
|
60
|
+
if (!items) return null;
|
|
58
61
|
if (index > 0) output.push({
|
|
59
62
|
id: `assignment:${link.id}`,
|
|
60
63
|
kind: "branch",
|
|
@@ -70,12 +73,38 @@ var TaskConversationQueryService = class {
|
|
|
70
73
|
turn: item.turn + turnOffset,
|
|
71
74
|
...item.displayIndex === void 0 ? {} : { displayIndex: item.displayIndex + displayOffset }
|
|
72
75
|
})));
|
|
73
|
-
displayOffset +=
|
|
76
|
+
displayOffset += displayMessageCount(items);
|
|
74
77
|
const highestTurn = items.reduce((max, item) => Math.max(max, item.turn), -1);
|
|
75
78
|
turnOffset += highestTurn + 1;
|
|
76
79
|
}
|
|
77
80
|
return output;
|
|
78
81
|
}
|
|
82
|
+
async findMessages(taskId, query, limit = 1e3) {
|
|
83
|
+
const links = this.#executionSessions(taskId);
|
|
84
|
+
if (links.length === 0) return null;
|
|
85
|
+
const matches = [];
|
|
86
|
+
let displayOffset = 0;
|
|
87
|
+
let total = 0;
|
|
88
|
+
for (const link of links) {
|
|
89
|
+
const [result, items] = await Promise.all([this.sessions.findMessages(link.conversationId, query, limit), this.sessions.getTimeline(link.conversationId)]);
|
|
90
|
+
if (!result || !items) return null;
|
|
91
|
+
total += result.total;
|
|
92
|
+
for (const match of result.matches) {
|
|
93
|
+
if (matches.length >= limit) break;
|
|
94
|
+
matches.push({
|
|
95
|
+
...match,
|
|
96
|
+
displayIndex: match.displayIndex + displayOffset
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
displayOffset += displayMessageCount(items);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
query: query.trim(),
|
|
103
|
+
total,
|
|
104
|
+
truncated: total > matches.length,
|
|
105
|
+
matches
|
|
106
|
+
};
|
|
107
|
+
}
|
|
79
108
|
#executionSessions(taskId) {
|
|
80
109
|
return this.conversations.listSessions(taskId).filter((link) => link.role === "execution").sort((a, b) => a.assignmentEpoch - b.assignmentEpoch || a.startedAt - b.startedAt);
|
|
81
110
|
}
|
|
@@ -25,6 +25,7 @@ import type { GatewayServiceConfig } from './service/types.js';
|
|
|
25
25
|
import { type GatewayReadinessSnapshot } from './startup-readiness.js';
|
|
26
26
|
import { type ConnectorLearningCoordinator } from '../connectors/learning-coordinator.js';
|
|
27
27
|
import type { SceneAccess } from '../scenes/httpServices.js';
|
|
28
|
+
import type { GatewayPrincipal } from './security/gateway-principal.js';
|
|
28
29
|
import { type ProductLanguage } from '../voice/language-profile.js';
|
|
29
30
|
import { EndpointToolRuntime } from '../endpoint-tools/index.js';
|
|
30
31
|
export type { GatewayChannelStartupPhase1Metrics, GatewayChannelStartupPhase2Metrics, GatewayServiceConfig, } from './service/types.js';
|
|
@@ -137,6 +138,8 @@ export declare class GatewayService {
|
|
|
137
138
|
ok: false;
|
|
138
139
|
code: "BAD_REQUEST" | "QUEUE_FULL" | "CONTEXT_UNAVAILABLE" | "SESSION_CHANGED";
|
|
139
140
|
}>;
|
|
141
|
+
private appContextDispatcher;
|
|
142
|
+
prepareSessionAppContext(input: unknown, principal: GatewayPrincipal, conversationId: string, clientMessageId: string): Promise<import("../agent/source-context/types.js").AgentSourceContext>;
|
|
140
143
|
replaceLatestSessionTurn(...args: Parameters<GatewayAgentRunner['replaceLatestSessionTurn']>): Promise<{
|
|
141
144
|
ok: true;
|
|
142
145
|
effectiveDelivery: "next";
|
|
@@ -8,6 +8,8 @@ import { init_logger } from "../utils/logger.js";
|
|
|
8
8
|
import { closeXopcDatabase, openXopcDatabase } from "../storage/sqlite/connection.js";
|
|
9
9
|
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
10
10
|
import { findSessionInput, init_session_input_repository, insertSessionInput } from "../storage/sqlite/session-input-repository.js";
|
|
11
|
+
import { TaskRepository } from "../tasks/task-repository.js";
|
|
12
|
+
import { TaskRunRepository, init_task_run_repository } from "../tasks/task-run-repository.js";
|
|
11
13
|
import { init_changes, notifyUserContextChange } from "../user-context/changes.js";
|
|
12
14
|
import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
|
|
13
15
|
import { init_session_repository, patchSessionMetadata } from "../storage/sqlite/session-repository.js";
|
|
@@ -26,22 +28,26 @@ import { buildChannelCatalogForConfig, buildChannelCatalogFromSnapshot, init_cha
|
|
|
26
28
|
import { loadConfig, saveConfig } from "../config/loader.js";
|
|
27
29
|
import { prewarmModelRegistry } from "../providers/model-registry.js";
|
|
28
30
|
import { init_providers, providers_exports } from "../providers/index.js";
|
|
29
|
-
import { TaskRepository } from "../tasks/task-repository.js";
|
|
30
31
|
import { TaskConversationRepository } from "../tasks/task-conversation-repository.js";
|
|
31
32
|
import { getEmbeddedExecutionSession } from "../agent/embedded/execution-context.js";
|
|
32
33
|
import { disposeAllSessionMcpRuntimes } from "../agent/mcp/bundle-mcp-runtime.js";
|
|
34
|
+
import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
|
|
35
|
+
import { onAutomationProductEvent, publishAutomationProductEvent } from "../automations/product-events.js";
|
|
33
36
|
import { ProjectService } from "../projects/project-service.js";
|
|
34
37
|
import { resolveProjectAgentId } from "../projects/project-agent.js";
|
|
35
38
|
import "../projects/index.js";
|
|
36
39
|
import { resolveEffectiveGatewayPort } from "./host.js";
|
|
37
40
|
import { onSessionTranscriptUpdate } from "../session/transcript-events.js";
|
|
41
|
+
import { buildNoteAgentContext } from "../notes/agent-context.js";
|
|
42
|
+
import { NotesStore } from "../notes/store.js";
|
|
43
|
+
import { NotesService } from "../notes/service.js";
|
|
44
|
+
import { LocalAppService } from "../local-apps/service.js";
|
|
45
|
+
import { TaskApplicationService } from "../tasks/task-application-service.js";
|
|
38
46
|
import { AutomationService } from "../automations/service/automation-service.js";
|
|
39
|
-
import {
|
|
47
|
+
import { TaskSignalService } from "../tasks/task-signal-service.js";
|
|
48
|
+
import { createProductDispatcher } from "../capabilities/runtime/product.js";
|
|
40
49
|
import "../automations/index.js";
|
|
41
|
-
import { TaskApplicationService } from "../tasks/task-application-service.js";
|
|
42
|
-
import { TaskOutboxDispatcher } from "../tasks/task-outbox-dispatcher.js";
|
|
43
50
|
import { TaskRunDispatcher } from "../tasks/task-run-dispatcher.js";
|
|
44
|
-
import { TaskSignalService } from "../tasks/task-signal-service.js";
|
|
45
51
|
import "../tasks/index.js";
|
|
46
52
|
import "../agent/mcp/bundle-mcp-tools.js";
|
|
47
53
|
import { SessionIndex } from "../session/manager.js";
|
|
@@ -53,9 +59,6 @@ import "../infra/bus/index.js";
|
|
|
53
59
|
import { collectMediaUrisFromMessages, deleteMediaUris } from "../media/session-references.js";
|
|
54
60
|
import { AgentService } from "../agent/service.js";
|
|
55
61
|
import { ensureStarterAgentsInitialized } from "../agent/starter-agents.js";
|
|
56
|
-
import { setPairingBroadcastSink } from "../channels/pairing/pairing-events.js";
|
|
57
|
-
import { registerClarificationChannelRuntime } from "./clarify-runtime.js";
|
|
58
|
-
import { ChannelManager } from "../channels/manager.js";
|
|
59
62
|
import { getWorkspacePath } from "../config/workspace-path-helpers.js";
|
|
60
63
|
import "../config/index.js";
|
|
61
64
|
import { ManagedComposioEventPoller } from "../connectors/composio-managed-events.js";
|
|
@@ -74,6 +77,7 @@ import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
|
74
77
|
import "../endpoint-tools/index.js";
|
|
75
78
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
76
79
|
import { prepareAutomationAgentSession } from "./automation-agent-session.js";
|
|
80
|
+
import { registerClarificationChannelRuntime } from "./clarify-runtime.js";
|
|
77
81
|
import { stopTailscaleExposure } from "./tailscale-lifecycle.js";
|
|
78
82
|
import { createBackgroundTask } from "../infra/background-task.js";
|
|
79
83
|
import { buildTaskAgentContext } from "../agent/source-context/task-context.js";
|
|
@@ -81,9 +85,8 @@ import { WorkDiscoveryService } from "../work-discovery/service.js";
|
|
|
81
85
|
import { buildVoiceMemoryContext } from "../voice/realtime/memory-context.js";
|
|
82
86
|
import { buildVoicePersonaContext } from "../voice/realtime/persona-context.js";
|
|
83
87
|
import { voiceMemoryBudget, voicePersonaBudget } from "../voice/realtime/conversation-context.js";
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import { NotesService } from "../notes/service.js";
|
|
88
|
+
import { setPairingBroadcastSink } from "../channels/pairing/pairing-events.js";
|
|
89
|
+
import { ChannelManager } from "../channels/manager.js";
|
|
87
90
|
import "../notes/index.js";
|
|
88
91
|
import { buildWorkflowChildTools } from "../agent/workflow/workflow-child-tools.js";
|
|
89
92
|
import { WorkflowRunService } from "../workflows/service/workflow-run-service.js";
|
|
@@ -104,7 +107,6 @@ import { getXopcCloudCatalogCoordinator } from "../providers/xopc-cloud-catalog-
|
|
|
104
107
|
import { ModelCatalogSyncService } from "../providers/model-catalog-sync-service.js";
|
|
105
108
|
import { runBootstrapMigrationsSync } from "../migrations/runner.js";
|
|
106
109
|
import { NotificationService } from "../notifications/service.js";
|
|
107
|
-
import { LocalAppService } from "../local-apps/service.js";
|
|
108
110
|
import "../local-apps/index.js";
|
|
109
111
|
import { createRuntimeBrowserAutomationService } from "../browser/automations/runtime-service.js";
|
|
110
112
|
import "../browser/automations/index.js";
|
|
@@ -123,6 +125,7 @@ import { reconcileMemoryMaintenanceAutomations } from "./memory-maintenance-auto
|
|
|
123
125
|
import { GatewayReadiness } from "./startup-readiness.js";
|
|
124
126
|
import { createGatewayStartupTrace } from "./startup-trace.js";
|
|
125
127
|
import { GatewaySceneHost } from "./scenes/host.js";
|
|
128
|
+
import { checkAppContextAccess, prepareAppContext } from "./service/app-context-access.js";
|
|
126
129
|
import { applyAutomaticVoiceLanguage, inferProductLanguageFromEnvironment, initializeVoiceDefaults } from "../voice/language-profile.js";
|
|
127
130
|
import crypto from "node:crypto";
|
|
128
131
|
//#region src/gateway/service.ts
|
|
@@ -140,6 +143,7 @@ init_paths();
|
|
|
140
143
|
init_package_version();
|
|
141
144
|
init_resolve_route();
|
|
142
145
|
init_session_key();
|
|
146
|
+
init_task_run_repository();
|
|
143
147
|
init_transaction();
|
|
144
148
|
const log = createLogger("Gateway:Service");
|
|
145
149
|
var GatewayService = class {
|
|
@@ -457,7 +461,10 @@ var GatewayService = class {
|
|
|
457
461
|
emit: (type, payload) => this.emit(type, payload)
|
|
458
462
|
});
|
|
459
463
|
this.agentRunner = new GatewayAgentRunner({
|
|
460
|
-
validateConnectionResume: (input) =>
|
|
464
|
+
validateConnectionResume: async (input) => {
|
|
465
|
+
for (const source of input.contextSnapshots ?? []) if (source.kind === "app_context") await checkAppContextAccess(source, this.appContextDispatcher(), this.auth);
|
|
466
|
+
return this.connectionRecovery.preflight(input);
|
|
467
|
+
},
|
|
461
468
|
bus: this.bus,
|
|
462
469
|
sessionIndex: this.sessionIndex,
|
|
463
470
|
getAgentService: () => this.ensureAgentService(),
|
|
@@ -581,6 +588,7 @@ var GatewayService = class {
|
|
|
581
588
|
emitBrowserEvent: (type, payload) => this.emit(type, payload),
|
|
582
589
|
getNotesService: () => this.notesService,
|
|
583
590
|
getProjectService: () => this.projects,
|
|
591
|
+
getWorkDiscovery: () => this._workDiscovery ?? void 0,
|
|
584
592
|
getLocalAppService: () => this.localApps,
|
|
585
593
|
dispatchTaskEvents: () => this.dispatchTaskEvents(),
|
|
586
594
|
dispatchTaskRuns: () => this.dispatchTaskRuns(),
|
|
@@ -661,6 +669,13 @@ var GatewayService = class {
|
|
|
661
669
|
})).conversationId;
|
|
662
670
|
},
|
|
663
671
|
runAgent: async (runId, conversationId, message) => {
|
|
672
|
+
const taskRun = new TaskRunRepository().require(runId);
|
|
673
|
+
if (getSqliteDatabase().prepare("SELECT 1 FROM scene_task_bindings WHERE task_id = ?").get(taskRun.taskId)) {
|
|
674
|
+
if (!this.sceneHost?.http.followUps) throw new Error("Task follow-up runtime is disabled");
|
|
675
|
+
this.ensureAgentService();
|
|
676
|
+
await this.sceneHost.http.followUps.executeTask(runId, conversationId);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
664
679
|
const clientMessageId = `task:${runId}`;
|
|
665
680
|
const session = await this.sessionIndex.getSessionMetadata(conversationId);
|
|
666
681
|
if (!session) throw new Error("Task session is unavailable");
|
|
@@ -686,11 +701,17 @@ var GatewayService = class {
|
|
|
686
701
|
return this.taskRunDispatcher;
|
|
687
702
|
}
|
|
688
703
|
createNotificationService() {
|
|
689
|
-
if (!this.notificationService) this.notificationService = new NotificationService({
|
|
704
|
+
if (!this.notificationService) this.notificationService = new NotificationService({
|
|
705
|
+
publish: (type, payload) => this.realtime.broker.publish("gateway", type, payload),
|
|
706
|
+
allowsNotification: (notification) => notification.target.kind !== "task" || this.sceneHost?.http.followUps?.allowsTaskNotification(notification.target.taskId) !== false
|
|
707
|
+
});
|
|
690
708
|
return this.notificationService;
|
|
691
709
|
}
|
|
692
710
|
taskRunDispatch = createBackgroundTask(async () => {
|
|
693
711
|
new TaskSignalService().tick();
|
|
712
|
+
this.notesService.flushCommittedEffects();
|
|
713
|
+
this.projects.flushCommittedEffects();
|
|
714
|
+
this._workDiscovery?.dispatchProjectUnderstanding();
|
|
694
715
|
this.dispatchTaskEvents();
|
|
695
716
|
this.createTaskRunDispatcher().dispatch();
|
|
696
717
|
await this.createWorkflowRunService().dispatchTaskRuns();
|
|
@@ -770,7 +791,10 @@ var GatewayService = class {
|
|
|
770
791
|
};
|
|
771
792
|
}
|
|
772
793
|
dispatchTaskEvents() {
|
|
773
|
-
new
|
|
794
|
+
new DomainOutboxDispatcher((event) => {
|
|
795
|
+
if (event.source === "local_apps") this.emit(event.type, event.payload);
|
|
796
|
+
else publishAutomationProductEvent(event);
|
|
797
|
+
}).drain();
|
|
774
798
|
}
|
|
775
799
|
runAgent(...args) {
|
|
776
800
|
return this.agentRunner.runAgent(...args);
|
|
@@ -785,6 +809,17 @@ var GatewayService = class {
|
|
|
785
809
|
submitSessionInput(...args) {
|
|
786
810
|
return this.agentRunner.submitSessionInput(...args);
|
|
787
811
|
}
|
|
812
|
+
appContextDispatcher() {
|
|
813
|
+
return createProductDispatcher(() => this.notesService, {
|
|
814
|
+
getProjects: () => this.projects,
|
|
815
|
+
getLocalApps: () => this.localApps,
|
|
816
|
+
getSceneAccess: () => this.sceneAccess
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
prepareSessionAppContext(input, principal, conversationId, clientMessageId) {
|
|
820
|
+
const previous = findSessionInput(conversationId, clientMessageId)?.contextSnapshots?.find((source) => source.kind === "app_context");
|
|
821
|
+
return prepareAppContext(input, principal, this.auth, this.appContextDispatcher(), previous);
|
|
822
|
+
}
|
|
788
823
|
replaceLatestSessionTurn(...args) {
|
|
789
824
|
return this.agentRunner.replaceLatestSessionTurn(...args);
|
|
790
825
|
}
|
|
@@ -949,6 +984,7 @@ var GatewayService = class {
|
|
|
949
984
|
});
|
|
950
985
|
log.debug("Starting gateway service...");
|
|
951
986
|
openXopcDatabase();
|
|
987
|
+
await this.localApps.recoverPendingReleases();
|
|
952
988
|
const { recoverCapabilityImports } = await import("../imports/runtime.js");
|
|
953
989
|
await recoverCapabilityImports();
|
|
954
990
|
this.createNotificationService().start();
|
|
@@ -1628,6 +1664,24 @@ var GatewayService = class {
|
|
|
1628
1664
|
this.stopAutomationProductEventBridge?.();
|
|
1629
1665
|
this.stopSessionTranscriptAutomationEvents?.();
|
|
1630
1666
|
this.stopAutomationProductEventBridge = onAutomationProductEvent((event) => {
|
|
1667
|
+
if (event.type === "project.deleted" && typeof event.payload.projectId === "string") {
|
|
1668
|
+
const runIds = event.payload.deletedUnderstandingRunIds;
|
|
1669
|
+
if (Array.isArray(runIds) && runIds.every((id) => typeof id === "string")) this._workDiscovery?.abortDeletedProjectRuns(event.payload.projectId, runIds);
|
|
1670
|
+
}
|
|
1671
|
+
if (event.type === "note.created" || event.type === "note.updated" || event.type === "note.deleted" || event.type === "task.changed.v2" || event.type === "task.deleted.v1" || event.type === "project.changed" || event.type === "project.created" || event.type === "project.deleted" || event.type === "scene.changed" || event.type === "scene.created" || event.type === "scene.deleted") {
|
|
1672
|
+
const note = event.type.startsWith("note.");
|
|
1673
|
+
const project = event.type.startsWith("project.");
|
|
1674
|
+
const scene = event.type.startsWith("scene.");
|
|
1675
|
+
const payload = event.payload;
|
|
1676
|
+
if (typeof payload.sourceEventId === "string") this.realtime.broker.publish(note ? "resources:notes" : project ? "resources:projects" : scene ? "resources:scenes" : "resources:tasks", "resource.changed", {
|
|
1677
|
+
eventId: payload.sourceEventId,
|
|
1678
|
+
kind: note ? "note" : project ? "project" : scene ? "scene" : "task",
|
|
1679
|
+
id: note ? payload.noteId : project ? payload.projectId : scene ? payload.sceneId : payload.taskId,
|
|
1680
|
+
revision: note || scene ? payload.revision : payload.version,
|
|
1681
|
+
operation: event.type === "task.deleted.v1" || event.type.endsWith(".deleted") ? "deleted" : event.type.endsWith(".created") ? "created" : "updated",
|
|
1682
|
+
...typeof payload.operationId === "string" ? { operationId: payload.operationId } : {}
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1631
1685
|
if (event.type.startsWith("task.")) this.emit(event.type, event.payload);
|
|
1632
1686
|
this.automationService.triggerEvent(event).catch((err) => {
|
|
1633
1687
|
const em = err instanceof Error ? err.message : String(err);
|
|
@@ -2,10 +2,10 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
4
4
|
import { hasGatewayScope } from "./security/gateway-scopes.js";
|
|
5
|
+
import { TaskRepository, init_task_repository } from "../tasks/task-repository.js";
|
|
5
6
|
import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
|
|
6
7
|
import { init_session_repository } from "../storage/sqlite/session-repository.js";
|
|
7
8
|
import { getSessionConfig } from "../storage/sqlite/config-repository.js";
|
|
8
|
-
import { TaskRepository } from "../tasks/task-repository.js";
|
|
9
9
|
import { TaskConversationRepository } from "../tasks/task-conversation-repository.js";
|
|
10
10
|
import { getExecutionEnvironmentForSession } from "../execution-environments/subject.js";
|
|
11
11
|
import { effectiveWorkspacePathForSession } from "../session/session-workspace.js";
|
|
@@ -16,6 +16,7 @@ import { realpath, stat } from "node:fs/promises";
|
|
|
16
16
|
//#region src/gateway/session-context-summary.ts
|
|
17
17
|
init_session_repository();
|
|
18
18
|
init_transaction();
|
|
19
|
+
init_task_repository();
|
|
19
20
|
init_logger();
|
|
20
21
|
const log = createLogger("SessionContextSummary");
|
|
21
22
|
const SOURCE_LIMIT = 20;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AutomationEvent } from '../automations/domain/types.js';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class DomainOutboxDispatcher {
|
|
3
3
|
private readonly publish;
|
|
4
4
|
constructor(publish: (event: AutomationEvent) => void);
|
|
5
|
-
drain(limit?: number): number;
|
|
5
|
+
drain(limit?: number, subjectKind?: string): number;
|
|
6
6
|
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/infra/domain-outbox-dispatcher.ts
|
|
3
3
|
init_transaction();
|
|
4
|
-
var
|
|
4
|
+
var DomainOutboxDispatcher = class {
|
|
5
5
|
constructor(publish) {
|
|
6
6
|
this.publish = publish;
|
|
7
7
|
}
|
|
8
|
-
drain(limit = 100) {
|
|
9
|
-
const rows = getSqliteDatabase().prepare(`SELECT event_id, event_type, payload_json, created_at
|
|
10
|
-
FROM domain_outbox WHERE published_at IS NULL
|
|
11
|
-
ORDER BY created_at, event_id LIMIT ?`).all(Math.max(1, Math.min(500, Math.floor(limit))));
|
|
8
|
+
drain(limit = 100, subjectKind) {
|
|
9
|
+
const rows = getSqliteDatabase().prepare(`SELECT event_id, event_type, payload_json, created_at, subject_kind, operation_id
|
|
10
|
+
FROM domain_outbox WHERE published_at IS NULL AND (? IS NULL OR subject_kind = ?)
|
|
11
|
+
ORDER BY created_at, event_id LIMIT ?`).all(subjectKind ?? null, subjectKind ?? null, Math.max(1, Math.min(500, Math.floor(limit))));
|
|
12
12
|
let published = 0;
|
|
13
13
|
for (const row of rows) try {
|
|
14
14
|
const payload = JSON.parse(row.payload_json);
|
|
15
15
|
this.publish({
|
|
16
16
|
type: row.event_type,
|
|
17
|
-
source: "tasks",
|
|
17
|
+
source: row.subject_kind === "note" ? "notes" : row.subject_kind === "project" ? "projects" : row.subject_kind === "scene" ? "scenes" : row.subject_kind === "local_app" ? "local_apps" : "tasks",
|
|
18
18
|
payload: {
|
|
19
19
|
...payload,
|
|
20
|
-
sourceEventId: row.event_id
|
|
20
|
+
sourceEventId: row.event_id,
|
|
21
|
+
...row.operation_id ? { operationId: row.operation_id } : {}
|
|
21
22
|
},
|
|
22
23
|
occurredAtMs: row.created_at
|
|
23
24
|
});
|
|
@@ -33,4 +34,4 @@ var TaskOutboxDispatcher = class {
|
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
//#endregion
|
|
36
|
-
export {
|
|
37
|
+
export { DomainOutboxDispatcher };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
//#region src/infra/operation-context.ts
|
|
4
|
+
function currentOperationId() {
|
|
5
|
+
return operations.getStore();
|
|
6
|
+
}
|
|
7
|
+
function withOperation(operationId, run) {
|
|
8
|
+
return operations.run(operationId, run);
|
|
9
|
+
}
|
|
10
|
+
var operations;
|
|
11
|
+
var init_operation_context = __esmMin((() => {
|
|
12
|
+
operations = new AsyncLocalStorage();
|
|
13
|
+
}));
|
|
14
|
+
//#endregion
|
|
15
|
+
init_operation_context();
|
|
16
|
+
export { currentOperationId, init_operation_context, withOperation };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ExtensionCapabilityBindingsSchema } from "../../../packages/gateway-contract/src/extension-capabilities.js";
|
|
2
|
+
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
3
|
+
import { CapabilityDispatcher } from "../../capabilities/runtime/dispatcher.js";
|
|
4
|
+
import { registerNoteReadCapabilities } from "../../notes/capabilities/read.js";
|
|
5
|
+
import { registerNoteWriteCapabilities } from "../../notes/capabilities/write.js";
|
|
6
|
+
import { registerTaskReadCapabilities } from "../../tasks/capabilities/read.js";
|
|
7
|
+
//#region src/local-apps/capabilities/contracts.ts
|
|
8
|
+
init_src();
|
|
9
|
+
/** Validate release bindings against the same production definitions without executing a domain service. */
|
|
10
|
+
function validateLocalAppCapabilityContracts(value) {
|
|
11
|
+
const bindings = ExtensionCapabilityBindingsSchema.parse(value ?? []);
|
|
12
|
+
if (!bindings.length) return;
|
|
13
|
+
const dispatcher = new CapabilityDispatcher();
|
|
14
|
+
const unavailable = () => {
|
|
15
|
+
throw new Error("Contract validation must not execute a domain service");
|
|
16
|
+
};
|
|
17
|
+
registerNoteReadCapabilities(dispatcher, unavailable);
|
|
18
|
+
registerNoteWriteCapabilities(dispatcher, { getNotes: unavailable });
|
|
19
|
+
registerTaskReadCapabilities(dispatcher);
|
|
20
|
+
const context = {
|
|
21
|
+
principalId: "release-validator",
|
|
22
|
+
surface: "extension",
|
|
23
|
+
scopes: ["gateway.admin"],
|
|
24
|
+
authorize: () => false
|
|
25
|
+
};
|
|
26
|
+
for (const binding of bindings) {
|
|
27
|
+
const descriptor = dispatcher.describe(binding.id, context);
|
|
28
|
+
if (descriptor.majorVersion !== binding.majorVersion || descriptor.descriptorDigest !== binding.descriptorDigest) throw new Error(`Capability contract changed: ${binding.id}; update the binding and rerun acceptance`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { validateLocalAppCapabilityContracts };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ProductReadContracts } from "../../../packages/gateway-contract/src/capabilities.js";
|
|
2
|
+
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
3
|
+
import { CapabilityError } from "../../capabilities/runtime/errors.js";
|
|
4
|
+
import { defineReadCapability } from "../../capabilities/runtime/dispatcher.js";
|
|
5
|
+
//#region src/local-apps/capabilities/read.ts
|
|
6
|
+
init_src();
|
|
7
|
+
function registerLocalAppReadCapabilities(dispatcher, service) {
|
|
8
|
+
const policy = {
|
|
9
|
+
majorVersion: 1,
|
|
10
|
+
effect: "read",
|
|
11
|
+
surfaces: ["http", "agent"],
|
|
12
|
+
scopes: ["gateway.admin"]
|
|
13
|
+
};
|
|
14
|
+
dispatcher.register(defineReadCapability({
|
|
15
|
+
...policy,
|
|
16
|
+
id: "xopc.local_apps.validate",
|
|
17
|
+
description: "Inspect local application files and validation issues without modifying the package or acceptance records.",
|
|
18
|
+
...ProductReadContracts["xopc.local_apps.validate"],
|
|
19
|
+
execute({ id }) {
|
|
20
|
+
if (!service.get(id)) throw new CapabilityError("NOT_FOUND", "Local app not found");
|
|
21
|
+
return { validation: service.validate(id) };
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
dispatcher.register(defineReadCapability({
|
|
25
|
+
...policy,
|
|
26
|
+
id: "xopc.local_apps.list",
|
|
27
|
+
description: "List managed local applications.",
|
|
28
|
+
...ProductReadContracts["xopc.local_apps.list"],
|
|
29
|
+
execute: () => ({ apps: service.list().map((app) => ({ ...app })) })
|
|
30
|
+
}));
|
|
31
|
+
dispatcher.register(defineReadCapability({
|
|
32
|
+
...policy,
|
|
33
|
+
id: "xopc.local_apps.get",
|
|
34
|
+
description: "Read a local application, its preview and release history.",
|
|
35
|
+
...ProductReadContracts["xopc.local_apps.get"],
|
|
36
|
+
execute({ id }) {
|
|
37
|
+
const app = service.get(id);
|
|
38
|
+
if (!app) throw new CapabilityError("NOT_FOUND", "Local app not found");
|
|
39
|
+
return { app: {
|
|
40
|
+
...app,
|
|
41
|
+
releases: app.releases.map((release) => ({ ...release })),
|
|
42
|
+
acceptanceRuns: app.acceptanceRuns.map((run) => ({ ...run }))
|
|
43
|
+
} };
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { registerLocalAppReadCapabilities };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CapabilityCall } from '@xopcai/gateway-contract';
|
|
2
|
+
import { type CapabilityContext, type CapabilityDispatcher } from '../../capabilities/runtime/dispatcher.js';
|
|
3
|
+
import type { LocalAppService } from '../service.js';
|
|
4
|
+
/** Shared UI/Agent execution boundary; callers cannot manufacture grants or release identity. */
|
|
5
|
+
export declare function localAppCapabilities(apps: Pick<LocalAppService, 'getCapabilityAccess'>, dispatcher: CapabilityDispatcher, extensionId: string, manifestDigest: string, caller: CapabilityContext): {
|
|
6
|
+
list(): {
|
|
7
|
+
releaseId: string;
|
|
8
|
+
manifestDigest: string;
|
|
9
|
+
capabilities: import("@xopcai/gateway-contract").CapabilityDescriptor[];
|
|
10
|
+
};
|
|
11
|
+
call(id: string, call: CapabilityCall): Promise<{
|
|
12
|
+
status: "succeeded";
|
|
13
|
+
releaseId: string;
|
|
14
|
+
data: unknown;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CapabilityError } from "../../capabilities/runtime/errors.js";
|
|
2
|
+
import "../../capabilities/runtime/dispatcher.js";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
//#region src/local-apps/capabilities/runtime.ts
|
|
5
|
+
/** Shared UI/Agent execution boundary; callers cannot manufacture grants or release identity. */
|
|
6
|
+
function localAppCapabilities(apps, dispatcher, extensionId, manifestDigest, caller) {
|
|
7
|
+
const access = apps.getCapabilityAccess(extensionId, manifestDigest);
|
|
8
|
+
const current = () => {
|
|
9
|
+
if (apps.getCapabilityAccess(extensionId, manifestDigest).releaseId !== access.releaseId) throw new CapabilityError("CONTRACT_CHANGED", "Local app release changed");
|
|
10
|
+
};
|
|
11
|
+
const context = {
|
|
12
|
+
...caller,
|
|
13
|
+
surface: "extension",
|
|
14
|
+
allowedCapabilities: access.bindings.map((binding) => binding.id).filter((id) => !caller.allowedCapabilities || caller.allowedCapabilities.includes(id)),
|
|
15
|
+
assertCurrent: () => {
|
|
16
|
+
caller.assertCurrent?.();
|
|
17
|
+
current();
|
|
18
|
+
},
|
|
19
|
+
authorize: async (id, input) => {
|
|
20
|
+
const allowed = await caller.authorize(id, input);
|
|
21
|
+
current();
|
|
22
|
+
return allowed;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
list() {
|
|
27
|
+
current();
|
|
28
|
+
return {
|
|
29
|
+
releaseId: access.releaseId,
|
|
30
|
+
manifestDigest,
|
|
31
|
+
capabilities: dispatcher.list(context).filter((item) => access.bindings.some((binding) => binding.id === item.id && binding.majorVersion === item.majorVersion && binding.descriptorDigest === item.descriptorDigest))
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
async call(id, call) {
|
|
35
|
+
current();
|
|
36
|
+
const binding = access.bindings.find((item) => item.id === id);
|
|
37
|
+
if (!binding) throw new CapabilityError("FORBIDDEN", "Capability is not declared by this release");
|
|
38
|
+
if (binding.majorVersion !== call.majorVersion || binding.descriptorDigest !== call.descriptorDigest) throw new CapabilityError("CONTRACT_CHANGED", "Capability differs from the installed binding");
|
|
39
|
+
const write = dispatcher.describe(id, context).effect !== "read";
|
|
40
|
+
if (write && !call.idempotencyKey?.trim()) throw new CapabilityError("INVALID_INPUT", "A stable idempotencyKey is required");
|
|
41
|
+
const key = call.idempotencyKey ? createHash("sha256").update(JSON.stringify([
|
|
42
|
+
caller.principalId,
|
|
43
|
+
extensionId,
|
|
44
|
+
access.releaseId,
|
|
45
|
+
call.idempotencyKey
|
|
46
|
+
])).digest("hex") : void 0;
|
|
47
|
+
const result = await dispatcher.call(id, call.input, context, {
|
|
48
|
+
...call,
|
|
49
|
+
idempotencyKey: key
|
|
50
|
+
});
|
|
51
|
+
try {
|
|
52
|
+
current();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (write) throw new CapabilityError("OUTCOME_UNKNOWN", "Write may have committed; retain the original idempotencyKey and reconcile after restoring access");
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
status: "succeeded",
|
|
59
|
+
releaseId: access.releaseId,
|
|
60
|
+
data: result
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { localAppCapabilities };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LocalAppAcceptanceInputSchema, LocalAppAcceptanceOutputSchema } from "../../../packages/gateway-contract/src/capabilities.js";
|
|
2
|
+
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
3
|
+
import { CapabilityError } from "../../capabilities/runtime/errors.js";
|
|
4
|
+
import { defineAtomicCapability } from "../../capabilities/runtime/dispatcher.js";
|
|
5
|
+
import { LocalAppAcceptanceValidationError, LocalAppRevisionConflictError } from "../service.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
//#region src/local-apps/capabilities/write.ts
|
|
8
|
+
init_src();
|
|
9
|
+
function registerLocalAppWriteCapabilities(dispatcher, service) {
|
|
10
|
+
dispatcher.register(defineAtomicCapability({
|
|
11
|
+
id: "xopc.local_apps.record_acceptance",
|
|
12
|
+
majorVersion: 1,
|
|
13
|
+
effect: "local-write",
|
|
14
|
+
description: "Record supplied acceptance checks against the exact local source digest; this does not execute the checks.",
|
|
15
|
+
surfaces: ["http", "agent"],
|
|
16
|
+
scopes: ["gateway.admin"],
|
|
17
|
+
input: LocalAppAcceptanceInputSchema.extend({ id: z.string().min(1).max(512) }),
|
|
18
|
+
output: z.object({ acceptance: LocalAppAcceptanceOutputSchema }),
|
|
19
|
+
execute({ id, ...input }) {
|
|
20
|
+
if (!service.get(id)) throw new CapabilityError("NOT_FOUND", "Local app not found");
|
|
21
|
+
try {
|
|
22
|
+
return { acceptance: service.recordAcceptance(id, input) };
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error instanceof LocalAppRevisionConflictError) throw new CapabilityError("REVISION_CONFLICT", error.message);
|
|
25
|
+
if (error instanceof LocalAppAcceptanceValidationError) throw new CapabilityError("INVALID_INPUT", error.message);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
afterCommit() {
|
|
30
|
+
service.flushAcceptanceEvents();
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { registerLocalAppWriteCapabilities };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/local-apps/release-lock.ts
|
|
2
|
+
const pending = /* @__PURE__ */ new Map();
|
|
3
|
+
/** Serialize release mutations sharing an extension directory, including across service instances. */
|
|
4
|
+
async function withLocalAppReleaseLock(root, action) {
|
|
5
|
+
const previous = pending.get(root) ?? Promise.resolve();
|
|
6
|
+
let release;
|
|
7
|
+
const next = new Promise((resolve) => {
|
|
8
|
+
release = resolve;
|
|
9
|
+
});
|
|
10
|
+
pending.set(root, next);
|
|
11
|
+
await previous;
|
|
12
|
+
try {
|
|
13
|
+
return await action();
|
|
14
|
+
} finally {
|
|
15
|
+
release();
|
|
16
|
+
if (pending.get(root) === next) pending.delete(root);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { withLocalAppReleaseLock };
|
|
@@ -4,5 +4,3 @@ export declare const LOCAL_APP_RUNTIME_ENTRY = ".xopc/runtime/local-ui.js";
|
|
|
4
4
|
* arbitrary Node.js in the gateway process through the extension `main` entry.
|
|
5
5
|
*/
|
|
6
6
|
export declare const LOCAL_APP_RUNTIME_SOURCE = "export default Object.freeze({});\n";
|
|
7
|
-
/** Exact legacy scaffold bytes accepted only to keep existing Phase 1 drafts upgradeable. */
|
|
8
|
-
export declare function legacyLocalAppRuntimeSource(extensionId: string, name: string): string;
|
|
@@ -6,18 +6,5 @@ const LOCAL_APP_RUNTIME_ENTRY = ".xopc/runtime/local-ui.js";
|
|
|
6
6
|
*/
|
|
7
7
|
const LOCAL_APP_RUNTIME_SOURCE = `export default Object.freeze({});
|
|
8
8
|
`;
|
|
9
|
-
/** Exact legacy scaffold bytes accepted only to keep existing Phase 1 drafts upgradeable. */
|
|
10
|
-
function legacyLocalAppRuntimeSource(extensionId, name) {
|
|
11
|
-
return `export default {
|
|
12
|
-
id: ${JSON.stringify(extensionId)},
|
|
13
|
-
name: ${JSON.stringify(name)},
|
|
14
|
-
version: '0.1.0',
|
|
15
|
-
kind: 'utility',
|
|
16
|
-
register(api) {
|
|
17
|
-
api.logger.info('Local app registered');
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
`;
|
|
21
|
-
}
|
|
22
9
|
//#endregion
|
|
23
|
-
export { LOCAL_APP_RUNTIME_ENTRY, LOCAL_APP_RUNTIME_SOURCE
|
|
10
|
+
export { LOCAL_APP_RUNTIME_ENTRY, LOCAL_APP_RUNTIME_SOURCE };
|