@xopcai/xopc 0.0.332 → 0.0.334
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-DocRzRlS.js → auth-Cjj5SuoT.js} +49 -39
- package/dist/browser-ext/dist/background.js +1 -1
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +240 -36
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C2wg3xC_.js → agent-avatar-dicebear-B73q7mlz.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-B9L2YIXz.js +1 -0
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BeNnu1Ts.js → agent-plugin-dialog-COOjsvea.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CCj1JnLu.js +70 -0
- package/dist/gateway/static/root/assets/agents-admin-api-Cuqi5xZn.js +2 -0
- package/dist/gateway/static/root/assets/{app-link-C6gA5Nck.js → app-link-DRL0YnPs.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-etFSkfzl.js → app-management-settings-panel-CckioKud.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DKmU2VAP.js → appearance-settings-DDiPIr_Q.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-Azqy8vfo.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-D0z_Fr2G.js → archive-plugin-Dtyr0RhX.js} +1 -1
- package/dist/gateway/static/root/assets/attachment-load-qjPpQzYY.js +1 -0
- package/dist/gateway/static/root/assets/attachment-utils-core-BIOUBrpT.js +1 -0
- package/dist/gateway/static/root/assets/{automations-page-B7_C-p66.js → automations-page-g3SrFkTC.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-B0nW2nZD.js +7 -0
- package/dist/gateway/static/root/assets/binary-plugins-BwKQVxsU.js +2 -0
- package/dist/gateway/static/root/assets/{block-editor-ChWW8Z9L.js → block-editor-DD9d5pCt.js} +29 -29
- package/dist/gateway/static/root/assets/{browser-automation-inputs-C5s1yHOu.js → browser-automation-inputs-D2gNdS3e.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BV00BXRb.js → browser-automations-page-BKqqJR7P.js} +2 -2
- package/dist/gateway/static/root/assets/{browser-settings-page-xwTmuZjS.js → browser-settings-page-BZH9bZbk.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-CHk4RZl4.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-page-CfWaVH-6.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C5FcWsSe.js +8 -0
- package/dist/gateway/static/root/assets/capability-header-actions-Bd66yEOa.js +1 -0
- package/dist/gateway/static/root/assets/channels-DIU5Gq4o.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C41mXCAi.js → chat-terminal-dock-B0nPDJyj.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-BJkqok2G.js → computer-settings-page-D7PxxaoG.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BKCZMmwm.js → connector-service-page-BZH4SeQg.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BC81R_fz.js +2 -0
- package/dist/gateway/static/root/assets/{turn-outcome-D0SnyZ3Z.js → constants-Co2_smKQ.js} +1 -1
- package/dist/gateway/static/root/assets/date-picker-CDEVYjXI.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-CqADAHZp.js → dependency-picker-AInmpSwC.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bab-iWED.js → desktop-pet-Sjgnlq8M.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BqgzLOdi.js → desktop-pet-settings-BWn0rrhr.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DFg7FDPf.js → device-pairing-wizard-BtW837_d.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-hqJ9sFCR.js → directory-picker-path-field-2CpmDx_D.js} +1 -1
- package/dist/gateway/static/root/assets/dist-CKkafhaS.js +1 -0
- package/dist/gateway/static/root/assets/dist-io9jFpN72.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DX3PFhRE.js → extension-debug-page-WWJFj9Z5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DkREdHLs.js → extension-page-DL00dFRr.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-wF-HNTM-.js → extension-settings-page-CN-agjPk.js} +1 -1
- package/dist/gateway/static/root/assets/{files-BK6enEvD.js → files-Bw4SBGdM.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-cR-tz7-Q.js → gateway-config-swr-CgIjCxM8.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-Ciq4c7KT.js +1 -0
- package/dist/gateway/static/root/assets/gateway-realtime-store-BHeHN26R.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-4oD6fhAm.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-6jLRcQsu.js → gateway-startup-retry-i-1lTrwY.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-nEpyJUBY.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-CSSkwsyC.js → image-generation-api-gilc-u7M.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-B80Cv043.js → imports-page-BivdeiQ5.js} +1 -1
- package/dist/gateway/static/root/assets/index-BioG1pRD.js +106 -0
- package/dist/gateway/static/root/assets/index-DbLEkdNg.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BgoFaTwv.js → keyboard-shortcuts-settings-B_8AJTFr.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CRtZQrmz.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-HO6OQlQT.js → local-apps-page-DclxpoqR.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-Bpja8nC6.js → local-apps-yys1VChX.js} +1 -1
- package/dist/gateway/static/root/assets/local-session-drafts-DkolHmyp.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-wNXWkWu5.js → locale-store-BY30D6tg.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DX8TxkRl.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-5WFufZ4g.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DlT9KqwF.js → markdown-view-DYJnwlDr.js} +1 -1
- package/dist/gateway/static/root/assets/media-plugins-DlJDvwLK.js +1 -0
- package/dist/gateway/static/root/assets/messages-_6IXbP2u.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-GF5Q9Fqy.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-E8o4_Ty9.js +8 -0
- package/dist/gateway/static/root/assets/page-context-capture-button-CiCmfRTw.js +1 -0
- package/dist/gateway/static/root/assets/{page-tabs-vqI30Yrg.js → page-tabs-Cwp3fGVM.js} +1 -1
- package/dist/gateway/static/root/assets/popover-select-0p9PIHRy.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-B-mwPBJW.js → preview-open-alternatives-DJ5xqGeu.js} +1 -1
- package/dist/gateway/static/root/assets/{product-delivery-bv3z8Xkh.js → product-delivery-BAks11S4.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-D--sj_uN.js → product-open-page-CcGwNePw.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-6hhRBkmC.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DUOzRaFI.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BIpltJ47.js → registry-api-BvVx0G1o.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BWpWUXiE.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CAnb0PNY.js → runtime-tools-settings-panel-C6eDCNHz.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-pF7Lmqnk.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-BKj6wIMb.js → schema-form-D8W8q_ez.js} +1 -1
- package/dist/gateway/static/root/assets/{schemas-88fK3zzl.js → schemas-CObaziC7.js} +3 -3
- package/dist/gateway/static/root/assets/session-api-BAyUr97V.js +1 -0
- package/dist/gateway/static/root/assets/session-manager-BAy2sR2Q.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-BDKDqqf9.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-C9cJWlAq.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-78ycUHfv.js → settings-form-section-B0cAj0nq.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BOdxIVzo.js → settings-page-DZVVTFxs.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DZCPVx9c.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-BkPNyV8c.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-Bqlv5JBi.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-CiBGQ0Jg.js → skill-api-C0dufzQC.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-3JF2OTBz.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DB4lR4om.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CyJUeREH.js → system-settings-panel-xjrlhdUz.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CB6M7wSs.js +1 -0
- package/dist/gateway/static/root/assets/{tasks-CDR_RVbQ.js → tasks-QQJXsiER.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Day9zhKi.js → tunnel-api--68MQEWM.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-OLZ00eqD.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-Bj9hC6ML.js → use-autosave-DsnHYpTv.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CoePFpHD.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-fWRD6B8r.js → voice-api-key-field-CvIXutQp.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-ujEySjyc.js → voice-config-api-Bwy3Al3J.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CnxdvIk8.js → work-discovery-overlay-By5_7MLR.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DlWNN1VA.js → workflow-run-setup-panel-HSMDxDXV.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DElQ47Da.js +6 -0
- package/dist/gateway/static/root/index.html +27 -21
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +44 -14
- package/dist/packages/gateway-contract/src/capabilities.js +120 -10
- package/dist/packages/gateway-contract/src/index.js +8 -2
- package/dist/packages/gateway-contract/src/scenes.js +7 -6
- package/dist/packages/gateway-contract/src/session-command-rejection.js +19 -0
- package/dist/packages/gateway-contract/src/session-input-command.js +109 -0
- package/dist/packages/gateway-contract/src/sessions.js +2 -7
- package/dist/packages/gateway-contract/src/usage.js +6 -0
- package/dist/src/agent/agent-manager.js +15 -9
- package/dist/src/agent/background-review/run-background-review.js +8 -3
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +7 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/external-tools/gateway-tools.d.ts +2 -1
- package/dist/src/agent/external-tools/gateway-tools.js +45 -11
- package/dist/src/agent/external-tools/index.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +2 -2
- package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
- package/dist/src/agent/memory/compaction.js +4 -0
- package/dist/src/agent/service/btw-query.js +8 -2
- package/dist/src/agent/service/process-direct-streaming.js +4 -2
- package/dist/src/agent/service.js +5 -5
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/filesystem-watcher.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +2 -2
- package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +7 -3
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +5 -4
- package/dist/src/agent/tools/automation-tool.d.ts +4 -1
- package/dist/src/agent/tools/automation-tool.js +42 -4
- package/dist/src/agent/tools/session-search-tool.js +1 -1
- package/dist/src/agent/tools/web-extract.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +50 -9
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/ai-assist/text-assist.js +6 -2
- package/dist/src/auth/credentials.js +1 -1
- package/dist/src/auth/oauth-provider-lock.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/automations/api/routes.js +65 -0
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/read.js +24 -0
- package/dist/src/automations/capabilities/write.d.ts +52 -14
- package/dist/src/automations/capabilities/write.js +52 -3
- package/dist/src/automations/delivery/delivery-router.d.ts +50 -0
- package/dist/src/automations/delivery/delivery-router.js +318 -0
- package/dist/src/automations/delivery/index.d.ts +1 -0
- package/dist/src/automations/delivery/index.js +2 -0
- package/dist/src/automations/domain/defaults.d.ts +0 -1
- package/dist/src/automations/domain/defaults.js +1 -1
- package/dist/src/automations/domain/index.js +2 -2
- package/dist/src/automations/domain/types.d.ts +158 -7
- package/dist/src/automations/domain/validation.d.ts +104 -22
- package/dist/src/automations/domain/validation.js +66 -13
- package/dist/src/automations/draft/automation-draft-prompt.js +3 -4
- package/dist/src/automations/draft/automation-draft-service.js +6 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +22 -3
- package/dist/src/automations/draft/automation-draft-validator.js +4 -4
- package/dist/src/automations/events/event-catalog.d.ts +14 -0
- package/dist/src/automations/events/event-catalog.js +117 -0
- package/dist/src/automations/events/event-dispatcher.d.ts +27 -0
- package/dist/src/automations/events/event-dispatcher.js +140 -0
- package/dist/src/automations/events/event-repository.d.ts +59 -0
- package/dist/src/automations/events/event-repository.js +361 -0
- package/dist/src/automations/events/index.d.ts +3 -0
- package/dist/src/automations/events/index.js +4 -0
- package/dist/src/automations/index.d.ts +3 -1
- package/dist/src/automations/index.js +9 -3
- package/dist/src/automations/service/action-executor.d.ts +20 -1
- package/dist/src/automations/service/action-executor.js +80 -40
- package/dist/src/automations/service/automation-service.d.ts +21 -4
- package/dist/src/automations/service/automation-service.js +150 -100
- package/dist/src/automations/storage/automation-repository.js +4 -5
- package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
- package/dist/src/automations/storage/automation-run-repository.js +26 -1
- package/dist/src/automations/storage/index.js +2 -2
- package/dist/src/automations/webhook-secrets.d.ts +1 -0
- package/dist/src/automations/webhook-secrets.js +16 -0
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/capabilities/store-connector.d.ts +17 -1
- package/dist/src/capabilities/store-connector.js +69 -3
- package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/connectors.js +4 -3
- package/dist/src/cli/commands/doctor/checks/automation-integrity.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/automation-integrity.js +55 -0
- package/dist/src/cli/commands/doctor/checks/database-relations.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/database-relations.js +81 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +2 -2
- package/dist/src/cli/commands/doctor/flow.js +5 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/computer/runtime.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.js +1 -1
- package/dist/src/connectors/approval-resume.js +1 -1
- package/dist/src/connectors/cli/authorization.d.ts +1 -1
- package/dist/src/connectors/cli/store.d.ts +1 -1
- package/dist/src/connectors/cli/store.js +1 -1
- package/dist/src/connectors/composio-backends.js +14 -4
- package/dist/src/connectors/composio-managed-events.d.ts +5 -2
- package/dist/src/connectors/composio-managed-events.js +4 -1
- package/dist/src/connectors/connection-candidates.js +53 -15
- package/dist/src/connectors/connection-capabilities.js +5 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +2 -1
- package/dist/src/connectors/connection-recovery-service.js +89 -4
- package/dist/src/discussions/analyzer.js +4 -4
- package/dist/src/execution-environments/local-worktree-manager.js +10 -1
- package/dist/src/execution-environments/session-environment-service.d.ts +3 -0
- package/dist/src/execution-environments/session-environment-service.js +28 -4
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/home-intelligence-automation-reconciler.js +4 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/agent-stream.js +6 -2
- package/dist/src/gateway/hono/routes/browser-session.js +4 -2
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +9 -2
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
- package/dist/src/gateway/hono/routes/files.js +3 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
- package/dist/src/gateway/hono/routes/models.js +17 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -4
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/public-gateway.js +93 -3
- package/dist/src/gateway/hono/routes/scenes.js +57 -41
- package/dist/src/gateway/hono/routes/session-command-handler.d.ts +5 -0
- package/dist/src/gateway/hono/routes/session-command-handler.js +189 -0
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +14 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +2 -2
- package/dist/src/gateway/hono/routes/sessions.js +15 -168
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/tui.js +2 -1
- package/dist/src/gateway/hono/routes/usage.d.ts +3 -0
- package/dist/src/gateway/hono/routes/usage.js +61 -0
- package/dist/src/gateway/hono/routes/voice.js +10 -1
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/memory-maintenance-automation-reconciler.js +5 -2
- package/dist/src/gateway/resolve-webchat-session-key.d.ts +1 -1
- package/dist/src/gateway/resolve-webchat-session-key.js +2 -2
- package/dist/src/gateway/scenes/host.js +27 -14
- package/dist/src/gateway/scenes/slackThreadSource.d.ts +2 -2
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/active-execution.d.ts +19 -0
- package/dist/src/gateway/service/active-execution.js +16 -0
- package/dist/src/gateway/service/agent-runner.d.ts +4 -0
- package/dist/src/gateway/service/agent-runner.js +19 -1
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
- package/dist/src/gateway/service/run-gateway-agent.js +10 -2
- package/dist/src/gateway/service/session-command-service.d.ts +34 -0
- package/dist/src/gateway/service/session-command-service.js +81 -0
- package/dist/src/gateway/service/session-input-coordinator.d.ts +21 -0
- package/dist/src/gateway/service/session-input-coordinator.js +41 -0
- package/dist/src/gateway/service/session-preparation-worker.d.ts +15 -0
- package/dist/src/gateway/service/session-preparation-worker.js +125 -0
- package/dist/src/gateway/service/sessions-api.d.ts +13 -0
- package/dist/src/gateway/service/sessions-api.js +23 -0
- package/dist/src/gateway/service.d.ts +30 -3
- package/dist/src/gateway/service.js +89 -79
- package/dist/src/gateway/side-chat/promotion-service.js +0 -1
- package/dist/src/gateway/side-chat/run-service.js +10 -7
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/generator.js +5 -2
- package/dist/src/infra/domain-outbox-dispatcher.d.ts +0 -3
- package/dist/src/infra/domain-outbox-dispatcher.js +15 -7
- package/dist/src/local-apps/service.js +2 -2
- package/dist/src/mcp/channel-bridge.js +12 -2
- package/dist/src/notes/capabilities/read.js +2 -2
- package/dist/src/notes/service.d.ts +4 -1
- package/dist/src/notes/service.js +13 -11
- package/dist/src/projects/project-service.js +1 -2
- package/dist/src/projects/project-skill-service.js +2 -2
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-call.d.ts +3 -2
- package/dist/src/providers/model-call.js +30 -5
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/scenes/activationAdapter.d.ts +19 -0
- package/dist/src/scenes/activationAdapter.js +1 -0
- package/dist/src/scenes/agentExecutor.js +3 -10
- package/dist/src/scenes/contracts.d.ts +3 -9
- package/dist/src/scenes/contracts.js +1 -0
- package/dist/src/scenes/execution.d.ts +9 -3
- package/dist/src/scenes/execution.js +12 -11
- package/dist/src/scenes/httpServices.d.ts +5 -2
- package/dist/src/scenes/mailContext.d.ts +4 -0
- package/dist/src/scenes/mailContext.js +9 -0
- package/dist/src/scenes/maintenance.js +1 -5
- package/dist/src/scenes/metrics.d.ts +0 -6
- package/dist/src/scenes/metrics.js +0 -11
- package/dist/src/scenes/registry.d.ts +11 -0
- package/dist/src/scenes/registry.js +28 -0
- package/dist/src/scenes/repository.d.ts +6 -3
- package/dist/src/scenes/repository.js +43 -5
- package/dist/src/scenes/service.d.ts +2 -1
- package/dist/src/scenes/service.js +9 -7
- package/dist/src/scenes/taskFollowUp/contracts.d.ts +37 -7
- package/dist/src/scenes/taskFollowUp/contracts.js +36 -17
- package/dist/src/scenes/taskFollowUp/service.d.ts +35 -7
- package/dist/src/scenes/taskFollowUp/service.js +86 -28
- package/dist/src/scenes/templates.d.ts +2 -2
- package/dist/src/scenes/userNotes.d.ts +3 -0
- package/dist/src/scenes/userNotes.js +6 -0
- package/dist/src/session/client-history.d.ts +3 -0
- package/dist/src/session/client-history.js +10 -5
- package/dist/src/session/manager.d.ts +1 -0
- package/dist/src/session/resolve-session.js +4 -3
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.d.ts +1 -0
- package/dist/src/session/store.js +3 -3
- package/dist/src/storage/sqlite/ai-usage-repository.d.ts +137 -0
- package/dist/src/storage/sqlite/ai-usage-repository.js +175 -0
- package/dist/src/storage/sqlite/connector-account-repository.js +7 -5
- package/dist/src/storage/sqlite/connector-repository.js +36 -34
- package/dist/src/storage/sqlite/index.d.ts +2 -2
- package/dist/src/storage/sqlite/index.js +3 -3
- package/dist/src/storage/sqlite/migrations/209_automation_event_hub.sql +48 -0
- package/dist/src/storage/sqlite/migrations/210_remove_legacy_automation_timeout.sql +14 -0
- package/dist/src/storage/sqlite/migrations/211_automation_result_deliveries.sql +16 -0
- package/dist/src/storage/sqlite/migrations/212_automation_delivery_policy.sql +30 -0
- package/dist/src/storage/sqlite/migrations/213_automation_reliability_contract.sql +188 -0
- package/dist/src/storage/sqlite/migrations/214_ai_usage_ledger.sql +41 -0
- package/dist/src/storage/sqlite/migrations/215_scene_execution_adapters.sql +6 -0
- package/dist/src/storage/sqlite/migrations/216_remove_scene_model_usage.sql +1 -0
- package/dist/src/storage/sqlite/migrations/217_remove_legacy_memory_tables.sql +4 -0
- package/dist/src/storage/sqlite/migrations/218_core_relation_indexes.sql +26 -0
- package/dist/src/storage/sqlite/migrations/219_json_contracts.sql +123 -0
- package/dist/src/storage/sqlite/migrations/220_normalize_timestamps.sql +339 -0
- package/dist/src/storage/sqlite/migrations/221_ai_usage_retention_index.sql +2 -0
- package/dist/src/storage/sqlite/migrations/222_session_config_authority.sql +13 -0
- package/dist/src/storage/sqlite/migrations/223_session_creation_receipts.sql +59 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +4 -4
- package/dist/src/storage/sqlite/row-mappers.d.ts +3 -7
- package/dist/src/storage/sqlite/row-mappers.js +6 -6
- package/dist/src/storage/sqlite/scenes-schema.d.ts +1 -1
- package/dist/src/storage/sqlite/scenes-schema.js +0 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +0 -52
- package/dist/src/storage/sqlite/schemas/scenes.sql +0 -7
- package/dist/src/storage/sqlite/session-creation-repository.d.ts +50 -0
- package/dist/src/storage/sqlite/session-creation-repository.js +166 -0
- package/dist/src/storage/sqlite/session-input-repository.d.ts +12 -2
- package/dist/src/storage/sqlite/session-input-repository.js +25 -2
- package/dist/src/storage/sqlite/session-read-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-read-repository.js +0 -1
- package/dist/src/storage/sqlite/session-repository.d.ts +0 -4
- package/dist/src/storage/sqlite/session-repository.js +8 -18
- package/dist/src/storage/sqlite/timestamps.d.ts +4 -0
- package/dist/src/storage/sqlite/timestamps.js +20 -0
- package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/transcript-repository.js +23 -15
- package/dist/src/storage/sqlite/user-trust-repository.js +4 -2
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.d.ts +1 -1
- package/dist/src/tasks/home-query-service.js +3 -3
- package/dist/src/tasks/task-contract-planner.js +1 -1
- package/dist/src/tui/backends/embedded-backend.d.ts +5 -0
- package/dist/src/tui/backends/embedded-backend.js +266 -20
- package/dist/src/tui/backends/embedded-drafts.d.ts +22 -0
- package/dist/src/tui/backends/embedded-drafts.js +53 -0
- package/dist/src/tui/backends/gateway-realtime-backend.d.ts +10 -0
- package/dist/src/tui/backends/gateway-realtime-backend.js +214 -33
- package/dist/src/tui/tui-backend.d.ts +1 -1
- package/dist/src/tui/tui-chat-input-state.d.ts +1 -0
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-session-format.js +0 -1
- package/dist/src/tui/tui-startup-resources.d.ts +1 -0
- package/dist/src/tui/tui-startup-resources.js +2 -2
- package/dist/src/tui/tui-types.d.ts +0 -1
- package/dist/src/tui/tui.js +69 -29
- package/dist/src/usage/cost.d.ts +4 -0
- package/dist/src/usage/cost.js +28 -0
- package/dist/src/usage/recorder.d.ts +13 -0
- package/dist/src/usage/recorder.js +117 -0
- package/dist/src/usage/scenario-registry.d.ts +8 -0
- package/dist/src/usage/scenario-registry.js +117 -0
- package/dist/src/usage/types.d.ts +55 -0
- package/dist/src/usage/types.js +1 -0
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/tts/summarize.js +1 -1
- package/dist/src/work-discovery/analyzer.js +2 -2
- package/dist/src/work-discovery/investigator.js +1 -1
- package/dist/src/work-discovery/service.js +3 -6
- package/dist/src/workflows/service/workflow-run-service.js +16 -3
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Se1Z72VG.js +0 -1
- package/dist/gateway/static/root/assets/agents-udIitwV8.js +0 -70
- package/dist/gateway/static/root/assets/apps-page-DVNySL58.js +0 -1
- package/dist/gateway/static/root/assets/attachment-load-DNCDbeOX.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BMgJvdcv.js +0 -7
- package/dist/gateway/static/root/assets/binary-plugins-BYn2hScX.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-CHA-sTAZ.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-v0WkhV5o.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DefBGjhV.js +0 -8
- package/dist/gateway/static/root/assets/capability-header-actions-vmx35sbu.js +0 -1
- package/dist/gateway/static/root/assets/channels-Eo4ONF5X.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DZYgogQw.js +0 -2
- package/dist/gateway/static/root/assets/conversation-identity-Cw0n9uzK.js +0 -1
- package/dist/gateway/static/root/assets/date-picker-CrOV4Ynd.js +0 -1
- package/dist/gateway/static/root/assets/dist-3h6cXXhT.js +0 -1
- package/dist/gateway/static/root/assets/dist-Che_jiQF.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Du-Dos9O.js +0 -1
- package/dist/gateway/static/root/assets/home-page-D7YoMHq4.js +0 -1
- package/dist/gateway/static/root/assets/index-BEw0xrde.css +0 -1
- package/dist/gateway/static/root/assets/index-DalslRUx.js +0 -121
- package/dist/gateway/static/root/assets/local-app-workbench-page-BKL5UZAj.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CjzR9Rpj.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-Dk_gTJb9.js +0 -1
- package/dist/gateway/static/root/assets/media-plugins-Dlj6TD3M.js +0 -1
- package/dist/gateway/static/root/assets/messages-fmf0dnr4.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-BebJPjjk.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-CmS_hvz8.js +0 -8
- package/dist/gateway/static/root/assets/page-context-capture-button-BArPtqp5.js +0 -1
- package/dist/gateway/static/root/assets/popover-select-DcsFzD_i.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-BFUdtWXF.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DBsBwAQ6.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BurdDY0m.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-Cj8xtr5t.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-BCsjgkCs.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BLL7csOJ.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CbKHBjrU.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-DyLfktib.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-BzvSNouj.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BHnru0F5.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-C35VKjhb.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-Bd1_Fguk.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-DuYzuR1T.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-B45YDiEw.js +0 -6
- package/dist/src/automations/product-events.d.ts +0 -5
- package/dist/src/automations/product-events.js +0 -19
- package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -9
- package/dist/src/tui/tui-empty-session-cleanup.js +0 -19
- /package/dist/gateway/static/root/assets/{dist-CI_fqRk-.js → dist-CI_fqRk-2.js} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//#region src/gateway/resolve-webchat-session-key.ts
|
|
2
2
|
/**
|
|
3
3
|
* Resolve the server-owned session key for webchat `/api/agent` requests.
|
|
4
|
-
*
|
|
4
|
+
* Ordinary creation is accepted atomically by a start input command.
|
|
5
5
|
*/
|
|
6
6
|
function resolveWebchatConversationId(input) {
|
|
7
7
|
const raw = input.conversationId?.trim() ?? "";
|
|
8
8
|
if (!raw) return {
|
|
9
9
|
ok: false,
|
|
10
|
-
error: "Missing conversationId
|
|
10
|
+
error: "Missing conversationId"
|
|
11
11
|
};
|
|
12
12
|
return {
|
|
13
13
|
ok: true,
|
|
@@ -13,6 +13,7 @@ import { SceneMailObservationService } from "../../scenes/mailObservations.js";
|
|
|
13
13
|
import { maintainSceneStorage } from "../../scenes/maintenance.js";
|
|
14
14
|
import { SceneMetrics } from "../../scenes/metrics.js";
|
|
15
15
|
import { resolveSceneModelRef } from "../../scenes/model.js";
|
|
16
|
+
import { SceneCapabilityRegistry } from "../../scenes/registry.js";
|
|
16
17
|
import { SceneResultNotifications } from "../../scenes/resultNotifications.js";
|
|
17
18
|
import { SceneRuntime } from "../../scenes/runtime.js";
|
|
18
19
|
import { familyPlanTemplate, mailFollowUpTemplate } from "../../scenes/templates.js";
|
|
@@ -20,8 +21,8 @@ import { SceneUserNotesProvider } from "../../scenes/userNotes.js";
|
|
|
20
21
|
import { createSceneBrowserDispatcher } from "./browserNotifications.js";
|
|
21
22
|
import { GatewaySceneMailContext } from "./mailContext.js";
|
|
22
23
|
import { SlackThreadSource } from "./slackThreadSource.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
24
|
+
import { SceneSourceRegistry, decisionLogTemplate, taskFollowUpTemplate } from "../../scenes/taskFollowUp/contracts.js";
|
|
25
|
+
import { SceneTaskExecutionService } from "../../scenes/taskFollowUp/service.js";
|
|
25
26
|
//#region src/gateway/scenes/host.ts
|
|
26
27
|
init_providers();
|
|
27
28
|
init_scenes_schema();
|
|
@@ -47,30 +48,39 @@ var GatewaySceneHost = class {
|
|
|
47
48
|
const repository = new SceneRepository(db);
|
|
48
49
|
repository.installTemplate(mailFollowUpTemplate);
|
|
49
50
|
repository.installTemplate(familyPlanTemplate);
|
|
51
|
+
repository.installTemplate(taskFollowUpTemplate);
|
|
52
|
+
repository.installTemplate(decisionLogTemplate);
|
|
50
53
|
const mail = input.mail ?? new GatewaySceneMailContext(db, clock);
|
|
51
|
-
const providers = [mail, new SceneUserNotesProvider(db, clock)];
|
|
54
|
+
const providers = new SceneCapabilityRegistry([mail, new SceneUserNotesProvider(db, clock)]);
|
|
52
55
|
const authorize = (activation) => {
|
|
53
56
|
if (activation.ownerId !== input.principal.ownerId || activation.workspaceId !== input.principal.workspaceId) return {
|
|
54
57
|
accountIds: [],
|
|
55
58
|
contextProviders: [],
|
|
56
59
|
effectHandlers: []
|
|
57
60
|
};
|
|
58
|
-
const
|
|
61
|
+
const grants = providers.list().flatMap((provider) => {
|
|
62
|
+
const accountIds = provider.authorization?.(activation) ?? null;
|
|
63
|
+
return accountIds === null ? [] : [{
|
|
64
|
+
id: provider.id,
|
|
65
|
+
accountIds
|
|
66
|
+
}];
|
|
67
|
+
});
|
|
59
68
|
return {
|
|
60
|
-
accountIds,
|
|
61
|
-
contextProviders:
|
|
69
|
+
accountIds: [...new Set(grants.flatMap((grant) => grant.accountIds))],
|
|
70
|
+
contextProviders: grants.map((grant) => grant.id),
|
|
62
71
|
effectHandlers: []
|
|
63
72
|
};
|
|
64
73
|
};
|
|
65
74
|
const grant = async (activation) => authorize(activation);
|
|
66
75
|
const executor = input.executor ?? new SceneAgentExecutor(() => resolveModel(resolveSceneModelRef(input.config())));
|
|
67
|
-
const
|
|
68
|
-
const
|
|
76
|
+
const sourceProviders = new SceneSourceRegistry([new SlackThreadSource(db)]);
|
|
77
|
+
const activationAdapters = new SceneCapabilityRegistry([new SceneTaskExecutionService(db, {
|
|
69
78
|
config: input.config,
|
|
70
|
-
sources:
|
|
71
|
-
});
|
|
79
|
+
sources: sourceProviders
|
|
80
|
+
})]);
|
|
72
81
|
this.http = {
|
|
73
|
-
|
|
82
|
+
activationAdapters,
|
|
83
|
+
sourceProviders,
|
|
74
84
|
repository,
|
|
75
85
|
mail,
|
|
76
86
|
mailDiscovery: mail instanceof GatewaySceneMailContext ? mail : void 0,
|
|
@@ -99,7 +109,10 @@ var GatewaySceneHost = class {
|
|
|
99
109
|
assertSceneStorageReady(this.db);
|
|
100
110
|
this.runtime.start();
|
|
101
111
|
const poll = () => {
|
|
102
|
-
this.http.
|
|
112
|
+
for (const adapter of this.http.activationAdapters.list()) adapter.tick().catch((err) => log.error({
|
|
113
|
+
err,
|
|
114
|
+
adapter: adapter.id
|
|
115
|
+
}, "Scene adapter check failed"));
|
|
103
116
|
try {
|
|
104
117
|
if (this.clock() >= this.nextMaintenanceAt) {
|
|
105
118
|
maintainSceneStorage(this.db, this.clock());
|
|
@@ -118,7 +131,7 @@ var GatewaySceneHost = class {
|
|
|
118
131
|
tick() {
|
|
119
132
|
if (this.stopped) return Promise.reject(/* @__PURE__ */ new Error("Scene host stopped"));
|
|
120
133
|
if (this.active) return this.active;
|
|
121
|
-
const work = Promise.all([this.runtime.tick(), this.http.
|
|
134
|
+
const work = Promise.all([this.runtime.tick(), ...this.http.activationAdapters.list().map((adapter) => adapter.tick())]).then(() => {
|
|
122
135
|
if (!this.stopped) this.notifications.drain();
|
|
123
136
|
});
|
|
124
137
|
this.active = work.finally(() => {
|
|
@@ -131,7 +144,7 @@ var GatewaySceneHost = class {
|
|
|
131
144
|
this.stopped = true;
|
|
132
145
|
if (this.timer) clearInterval(this.timer);
|
|
133
146
|
this.timer = void 0;
|
|
134
|
-
await this.http.
|
|
147
|
+
await Promise.all(this.http.activationAdapters.list().map((adapter) => adapter.stop()));
|
|
135
148
|
await this.runtime.stop();
|
|
136
149
|
await this.browserDispatcher.stop();
|
|
137
150
|
await this.active?.catch(() => void 0);
|
|
@@ -2,7 +2,7 @@ import type { DatabaseSync } from 'node:sqlite';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { ComposioSessionsAdapter } from '../../connectors/composio-sessions.js';
|
|
4
4
|
import { type ScenePrincipal } from '../../scenes/contracts.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { SceneSourceAdapter, SourceSnapshot } from '../../scenes/taskFollowUp/contracts.js';
|
|
6
6
|
export declare const slackThreadSchema: z.ZodObject<{
|
|
7
7
|
accountId: z.ZodString;
|
|
8
8
|
teamId: z.ZodString;
|
|
@@ -16,7 +16,7 @@ export declare function parseSlackThreadUrl(value: string): {
|
|
|
16
16
|
threadTs: string;
|
|
17
17
|
};
|
|
18
18
|
/** Read-only connector adapter. Account policy is rechecked before and after every page. */
|
|
19
|
-
export declare class SlackThreadSource implements
|
|
19
|
+
export declare class SlackThreadSource implements SceneSourceAdapter {
|
|
20
20
|
private readonly db;
|
|
21
21
|
private readonly adapter;
|
|
22
22
|
readonly id = "slack_thread";
|
|
@@ -22,6 +22,7 @@ function requiredGatewayScope(method, path) {
|
|
|
22
22
|
if (method === "GET" && path === "/api/connectors/approvals") return "sessions.read";
|
|
23
23
|
if (method === "POST" && path === "/api/connectors/approvals/respond") return "sessions.write";
|
|
24
24
|
if (path === "/api/agent" || path.startsWith("/api/agent/")) return "agents.run";
|
|
25
|
+
if (path.startsWith("/api/usage")) return "gateway.admin";
|
|
25
26
|
if (path.startsWith("/api/agents") || path.startsWith("/api/models")) return methodScope(method, "agents.read", "gateway.admin");
|
|
26
27
|
if (path.startsWith("/api/sessions") || path.startsWith("/api/side-chats")) return methodScope(method, "sessions.read", "sessions.write");
|
|
27
28
|
if (path.startsWith("/api/tasks")) return methodScope(method, "tasks.read", "tasks.write");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
|
|
2
|
+
export type ActiveExecutionKind = 'chat' | 'side-chat' | 'task' | 'workflow' | 'automation';
|
|
3
|
+
export type ActiveExecutionInitiator = 'user' | 'background';
|
|
4
|
+
export type ActiveExecution = {
|
|
5
|
+
conversationId: string;
|
|
6
|
+
runId: string;
|
|
7
|
+
kind: ActiveExecutionKind;
|
|
8
|
+
initiator: ActiveExecutionInitiator;
|
|
9
|
+
phase: 'running';
|
|
10
|
+
startedAt: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function describeActiveExecution(input: {
|
|
13
|
+
conversationId: string;
|
|
14
|
+
runId: string;
|
|
15
|
+
origin: TurnOrigin;
|
|
16
|
+
taskRunId?: string;
|
|
17
|
+
kind?: ActiveExecutionKind;
|
|
18
|
+
startedAt?: number;
|
|
19
|
+
}): ActiveExecution;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/gateway/service/active-execution.ts
|
|
2
|
+
function describeActiveExecution(input) {
|
|
3
|
+
const { origin } = input;
|
|
4
|
+
const background = origin.type === "system" && (origin.source === "automation" || origin.source === "heartbeat" || origin.source === "internal");
|
|
5
|
+
const kind = input.kind ?? (origin.type === "system" && origin.source === "automation" ? "automation" : origin.type === "system" && origin.source === "workflow" ? "workflow" : input.taskRunId ? "task" : "chat");
|
|
6
|
+
return {
|
|
7
|
+
conversationId: input.conversationId,
|
|
8
|
+
runId: input.runId,
|
|
9
|
+
kind,
|
|
10
|
+
initiator: background ? "background" : "user",
|
|
11
|
+
phase: "running",
|
|
12
|
+
startedAt: input.startedAt ?? Date.now()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { describeActiveExecution };
|
|
@@ -7,6 +7,7 @@ import type { ChannelManager } from '../../channels/manager.js';
|
|
|
7
7
|
import type { SessionIndex } from '../../session/index.js';
|
|
8
8
|
import { type ClarificationStreamEvent } from '../ephemeral-clarification-waiter.js';
|
|
9
9
|
import type { ClarifyRequestPayload, ClarifyRequestResult } from '../../agent/tools/clarify-tool.js';
|
|
10
|
+
import { type ActiveExecution, type ActiveExecutionKind } from './active-execution.js';
|
|
10
11
|
import type { UserTurnAttachment, UserTurnInput } from '../user-turn-input.js';
|
|
11
12
|
import type { AgentSourceContext, TurnContextRef } from '../../agent/source-context/types.js';
|
|
12
13
|
import { SessionInputCoordinator, type ReplaceLatestTurnInput, type SubmitSessionInput } from './session-input-coordinator.js';
|
|
@@ -33,6 +34,7 @@ export declare class GatewayAgentRunner {
|
|
|
33
34
|
private readonly ephemeralClarifications;
|
|
34
35
|
/** Maps webchat session key → active `runId` for `clarify` tool routing. */
|
|
35
36
|
private readonly activeWebchatRunBySession;
|
|
37
|
+
private readonly activeExecutionBySession;
|
|
36
38
|
private readonly externalStreamBySession;
|
|
37
39
|
private readonly externalClarificationResponses;
|
|
38
40
|
readonly inputs: SessionInputCoordinator;
|
|
@@ -45,9 +47,11 @@ export declare class GatewayAgentRunner {
|
|
|
45
47
|
conversationId: string;
|
|
46
48
|
runId: string;
|
|
47
49
|
}>;
|
|
50
|
+
listActiveExecutions(): ActiveExecution[];
|
|
48
51
|
disposeClarifications(): void;
|
|
49
52
|
registerExternalWebchatRun(conversationId: string, runId: string, publish: (event: ClarificationStreamEvent) => void, options?: {
|
|
50
53
|
beforeClarificationResponse?: () => boolean;
|
|
54
|
+
kind?: ActiveExecutionKind;
|
|
51
55
|
}): void;
|
|
52
56
|
unregisterExternalWebchatRun(conversationId: string, runId: string): void;
|
|
53
57
|
cancelClarificationForRun(runId: string): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { listActiveSessionInputRuns } from "../../storage/sqlite/session-input-repository.js";
|
|
3
|
+
import { listActiveSessionInputExecutions, listActiveSessionInputRuns } from "../../storage/sqlite/session-input-repository.js";
|
|
4
4
|
import { createClarificationWait, getClarification, getClarificationSnapshot, init_clarification_wait_repository, resolveClarification, supersedeActiveClarification } from "../../storage/sqlite/clarification-wait-repository.js";
|
|
5
5
|
import { init_connection_wait_repository, onConnectionWaitChanged } from "../../storage/sqlite/connection-wait-repository.js";
|
|
6
6
|
import { init_sqlite } from "../../storage/sqlite/index.js";
|
|
7
7
|
import { EphemeralClarificationWaiter } from "../ephemeral-clarification-waiter.js";
|
|
8
|
+
import { describeActiveExecution } from "./active-execution.js";
|
|
8
9
|
import { runGatewayAgent } from "./run-gateway-agent.js";
|
|
9
10
|
import { fitSourceContextsToBudget } from "../../agent/source-context/budget.js";
|
|
10
11
|
import { SessionInputCoordinator } from "./session-input-coordinator.js";
|
|
@@ -29,6 +30,7 @@ var GatewayAgentRunner = class {
|
|
|
29
30
|
ephemeralClarifications = new EphemeralClarificationWaiter();
|
|
30
31
|
/** Maps webchat session key → active `runId` for `clarify` tool routing. */
|
|
31
32
|
activeWebchatRunBySession = /* @__PURE__ */ new Map();
|
|
33
|
+
activeExecutionBySession = /* @__PURE__ */ new Map();
|
|
32
34
|
externalStreamBySession = /* @__PURE__ */ new Map();
|
|
33
35
|
externalClarificationResponses = /* @__PURE__ */ new Map();
|
|
34
36
|
inputs;
|
|
@@ -118,18 +120,33 @@ var GatewayAgentRunner = class {
|
|
|
118
120
|
runId
|
|
119
121
|
}));
|
|
120
122
|
}
|
|
123
|
+
listActiveExecutions() {
|
|
124
|
+
const executions = new Map(listActiveSessionInputExecutions().map((run) => [run.conversationId, describeActiveExecution(run)]));
|
|
125
|
+
for (const [conversationId, execution] of this.activeExecutionBySession) executions.set(conversationId, execution);
|
|
126
|
+
return [...executions.values()];
|
|
127
|
+
}
|
|
121
128
|
disposeClarifications() {
|
|
122
129
|
this.ephemeralClarifications.dispose();
|
|
123
130
|
this.unsubscribeConnectionWait();
|
|
124
131
|
}
|
|
125
132
|
registerExternalWebchatRun(conversationId, runId, publish, options) {
|
|
126
133
|
this.activeWebchatRunBySession.set(conversationId, runId);
|
|
134
|
+
this.activeExecutionBySession.set(conversationId, describeActiveExecution({
|
|
135
|
+
conversationId,
|
|
136
|
+
runId,
|
|
137
|
+
origin: {
|
|
138
|
+
type: "endpoint",
|
|
139
|
+
endpointId: "electron-side-chat"
|
|
140
|
+
},
|
|
141
|
+
kind: options?.kind
|
|
142
|
+
}));
|
|
127
143
|
this.externalStreamBySession.set(conversationId, publish);
|
|
128
144
|
if (options?.beforeClarificationResponse) this.externalClarificationResponses.set(conversationId, options.beforeClarificationResponse);
|
|
129
145
|
}
|
|
130
146
|
unregisterExternalWebchatRun(conversationId, runId) {
|
|
131
147
|
if (this.activeWebchatRunBySession.get(conversationId) === runId) {
|
|
132
148
|
this.activeWebchatRunBySession.delete(conversationId);
|
|
149
|
+
this.activeExecutionBySession.delete(conversationId);
|
|
133
150
|
this.externalStreamBySession.delete(conversationId);
|
|
134
151
|
this.externalClarificationResponses.delete(conversationId);
|
|
135
152
|
}
|
|
@@ -152,6 +169,7 @@ var GatewayAgentRunner = class {
|
|
|
152
169
|
bus: this.opts.bus,
|
|
153
170
|
runAbortControllers: this.runAbortControllers,
|
|
154
171
|
activeWebchatRunBySession: this.activeWebchatRunBySession,
|
|
172
|
+
activeExecutionBySession: this.activeExecutionBySession,
|
|
155
173
|
sessionIndex: this.opts.sessionIndex,
|
|
156
174
|
emit: this.opts.emit,
|
|
157
175
|
publishRealtime: this.opts.publishRealtime,
|
|
@@ -3,12 +3,12 @@ import { createLogger } from "../../utils/logger/index.js";
|
|
|
3
3
|
import { init_logger } from "../../utils/logger.js";
|
|
4
4
|
import { init_agent_scope, resolveDefaultAgentId } from "../../agent/agent-scope.js";
|
|
5
5
|
import { init_paths, resolveExtensionsDir } from "../../config/paths.js";
|
|
6
|
+
import { removeSkillsLockEntry } from "../../agent/skills/hub-lock.js";
|
|
7
|
+
import { deleteManagedSkill, installSkillFromZip, listManagedSkillDirs } from "../../agent/skills/managed-store.js";
|
|
6
8
|
import { getExtensionLockfileManager } from "../../extensions/lockfile.js";
|
|
7
9
|
import { AgentPluginStore } from "../../extensions/agent-plugins/store.js";
|
|
8
10
|
import { createSkillConfigManager } from "../../agent/skills/config.js";
|
|
9
11
|
import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "../../agent/skills/workspace-skills-dir.js";
|
|
10
|
-
import { removeSkillsLockEntry } from "../../agent/skills/hub-lock.js";
|
|
11
|
-
import { deleteManagedSkill, installSkillFromZip, listManagedSkillDirs } from "../../agent/skills/managed-store.js";
|
|
12
12
|
import { normalizeSkillInstallTarget } from "../../agent/skills/install-target.js";
|
|
13
13
|
import { isAgentPluginArchive, withAgentPluginArchive } from "../../extensions/agent-plugins/sources.js";
|
|
14
14
|
import { existsSync, rmSync } from "node:fs";
|
|
@@ -6,6 +6,7 @@ import type { SessionIndex } from '../../session/index.js';
|
|
|
6
6
|
import type { ChatStreamEvent } from '../chat-stream/protocol.js';
|
|
7
7
|
import type { UserTurnAttachment } from '../user-turn-input.js';
|
|
8
8
|
import type { AgentSourceContext } from '../../agent/source-context/types.js';
|
|
9
|
+
import { type ActiveExecution } from './active-execution.js';
|
|
9
10
|
export type RunGatewayAgentYield = ChatStreamEvent;
|
|
10
11
|
export type RunGatewayAgentDeps = {
|
|
11
12
|
config: Config;
|
|
@@ -13,6 +14,7 @@ export type RunGatewayAgentDeps = {
|
|
|
13
14
|
bus: MessageBus;
|
|
14
15
|
runAbortControllers: Map<string, AbortController>;
|
|
15
16
|
activeWebchatRunBySession: Map<string, string>;
|
|
17
|
+
activeExecutionBySession: Map<string, ActiveExecution>;
|
|
16
18
|
sessionIndex: SessionIndex;
|
|
17
19
|
emit: (type: string, payload: unknown) => void;
|
|
18
20
|
publishRealtime: (topic: string, event: string, data: unknown) => void;
|
|
@@ -17,6 +17,7 @@ import { markdownNotificationPreview } from "../../notifications/plain-text.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";
|
|
20
|
+
import { describeActiveExecution } from "./active-execution.js";
|
|
20
21
|
import crypto from "crypto";
|
|
21
22
|
//#region src/gateway/service/run-gateway-agent.ts
|
|
22
23
|
init_connection_wait_repository();
|
|
@@ -35,7 +36,7 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
35
36
|
max: 10
|
|
36
37
|
}, "Attachments capped for webchat");
|
|
37
38
|
const runId = runOptions?.runId ?? crypto.randomUUID();
|
|
38
|
-
const { agentService, bus, runAbortControllers, activeWebchatRunBySession, sessionIndex: sessionIndexFromDeps, emit, publishRealtime, completeRealtimeTopic } = deps;
|
|
39
|
+
const { agentService, bus, runAbortControllers, activeWebchatRunBySession, activeExecutionBySession, sessionIndex: sessionIndexFromDeps, emit, publishRealtime, completeRealtimeTopic } = deps;
|
|
39
40
|
const sessionIndex = sessionIndexFromDeps;
|
|
40
41
|
let taskRun;
|
|
41
42
|
let taskRunStatus = "failed";
|
|
@@ -50,7 +51,7 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
50
51
|
if (resolved.ok === false) throw new Error(resolved.error);
|
|
51
52
|
webchatConversationId = resolved.conversationId;
|
|
52
53
|
const meta = await sessionIndex.getSessionMetadata(webchatConversationId);
|
|
53
|
-
if (!meta) throw new Error("Session not found;
|
|
54
|
+
if (!meta) throw new Error("Session not found; submit a start input command first");
|
|
54
55
|
webchatTranscriptId = meta?.transcriptId;
|
|
55
56
|
webchatMetadata = meta;
|
|
56
57
|
runAbortControllers.set(runId, new AbortController());
|
|
@@ -132,6 +133,12 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
132
133
|
agentService.beginInboundTurn(conversationId);
|
|
133
134
|
if (!activeWebchatRunBySession.has(conversationId)) {
|
|
134
135
|
activeWebchatRunBySession.set(conversationId, runId);
|
|
136
|
+
activeExecutionBySession.set(conversationId, describeActiveExecution({
|
|
137
|
+
conversationId,
|
|
138
|
+
runId,
|
|
139
|
+
origin,
|
|
140
|
+
taskRunId: runOptions?.taskRunId
|
|
141
|
+
}));
|
|
135
142
|
registeredActiveWebchatRun = true;
|
|
136
143
|
publishRealtime("sessions", "run.started", {
|
|
137
144
|
conversationId,
|
|
@@ -217,6 +224,7 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
217
224
|
}
|
|
218
225
|
if (registeredActiveWebchatRun && activeWebchatRunBySession.get(conversationId) === runId) {
|
|
219
226
|
activeWebchatRunBySession.delete(conversationId);
|
|
227
|
+
activeExecutionBySession.delete(conversationId);
|
|
220
228
|
publishRealtime("sessions", "run.completed", {
|
|
221
229
|
conversationId,
|
|
222
230
|
runId,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SessionInputCommand, SessionMaterializeCommand } from '@xopcai/gateway-contract';
|
|
2
|
+
import type { AgentSourceContext } from '../../agent/source-context/types.js';
|
|
3
|
+
import { type SessionInputReceipt } from '../../storage/sqlite/session-creation-repository.js';
|
|
4
|
+
import type { GatewayService } from '../service.js';
|
|
5
|
+
export declare function receiveSessionCommand(service: GatewayService, conversationId: string, principalId: string, command: SessionInputCommand | SessionMaterializeCommand, prepareSourceContexts?: () => Promise<AgentSourceContext[]>): Promise<{
|
|
6
|
+
receipt: {
|
|
7
|
+
lifecycle: import("@xopcai/gateway-contract").SessionPreparationState;
|
|
8
|
+
conversationId: string;
|
|
9
|
+
clientMessageId: string;
|
|
10
|
+
inputId: string | null;
|
|
11
|
+
transcriptId: string;
|
|
12
|
+
acceptedAt: number;
|
|
13
|
+
};
|
|
14
|
+
session: import("../../session/types.js").SessionDetail;
|
|
15
|
+
agentConfig: import("../../agent/session/session-inspector.js").SessionAgentConfigView;
|
|
16
|
+
inputState: import("../../storage/sqlite/session-input-repository.js").SessionInputState;
|
|
17
|
+
effectiveDelivery: import("../../storage/sqlite/session-input-repository.js").SessionInputDelivery;
|
|
18
|
+
preparation: import("../../storage/sqlite/session-creation-repository.js").SessionPreparation;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function sessionCommandSnapshot(service: GatewayService, receipt: SessionInputReceipt): Promise<{
|
|
21
|
+
receipt: {
|
|
22
|
+
lifecycle: import("@xopcai/gateway-contract").SessionPreparationState;
|
|
23
|
+
conversationId: string;
|
|
24
|
+
clientMessageId: string;
|
|
25
|
+
inputId: string | null;
|
|
26
|
+
transcriptId: string;
|
|
27
|
+
acceptedAt: number;
|
|
28
|
+
};
|
|
29
|
+
session: import("../../session/types.js").SessionDetail;
|
|
30
|
+
agentConfig: import("../../agent/session/session-inspector.js").SessionAgentConfigView;
|
|
31
|
+
inputState: import("../../storage/sqlite/session-input-repository.js").SessionInputState;
|
|
32
|
+
effectiveDelivery: import("../../storage/sqlite/session-input-repository.js").SessionInputDelivery;
|
|
33
|
+
preparation: import("../../storage/sqlite/session-creation-repository.js").SessionPreparation;
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
2
|
+
import { init_session_repository } from "../../storage/sqlite/session-repository.js";
|
|
3
|
+
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
4
|
+
import { resolveProjectAgentId } from "../../projects/project-agent.js";
|
|
5
|
+
import "../../projects/index.js";
|
|
6
|
+
import { getModelThinking } from "../../providers/model-thinking.js";
|
|
7
|
+
import { withModelConfigLock } from "../../session/model-config-lock.js";
|
|
8
|
+
import { SessionCommandError, acceptSessionCommand, getSessionPreparation, matchSessionInputReceipt, sessionCommandHash } from "../../storage/sqlite/session-creation-repository.js";
|
|
9
|
+
//#region src/gateway/service/session-command-service.ts
|
|
10
|
+
init_providers();
|
|
11
|
+
init_session_repository();
|
|
12
|
+
function validateCreation(service, creation) {
|
|
13
|
+
const project = creation.projectId ? service.projects.get(creation.projectId) : null;
|
|
14
|
+
if (creation.projectId && !project) throw new Error("Project not found");
|
|
15
|
+
if (resolveProjectAgentId({
|
|
16
|
+
config: service.currentConfig,
|
|
17
|
+
projects: service.projects,
|
|
18
|
+
explicitAgentId: creation.agentId,
|
|
19
|
+
projectId: creation.projectId ?? void 0
|
|
20
|
+
}) !== creation.agentId) throw new Error("Invalid agent identity");
|
|
21
|
+
if (project?.workspaceRoot?.trim() && !creation.execution) throw new Error("Select an execution environment");
|
|
22
|
+
if (creation.execution && !project?.workspaceRoot?.trim()) throw new Error("Project requires a workspace");
|
|
23
|
+
if (!getModelThinking(resolveModel(creation.model)).options.includes(creation.thinkingLevel)) throw new Error("Unsupported model thinking level");
|
|
24
|
+
}
|
|
25
|
+
async function receiveSessionCommand(service, conversationId, principalId, command, prepareSourceContexts = async () => []) {
|
|
26
|
+
return withModelConfigLock(conversationId, async () => {
|
|
27
|
+
const clientMessageId = "commandId" in command ? command.commandId : command.clientMessageId;
|
|
28
|
+
const existing = matchSessionInputReceipt(conversationId, clientMessageId, principalId, sessionCommandHash(command));
|
|
29
|
+
if (existing) return sessionCommandSnapshot(service, existing);
|
|
30
|
+
if ("kind" in command && command.kind === "append") {
|
|
31
|
+
const session = getSessionMetadata(conversationId);
|
|
32
|
+
if (!session) throw new SessionCommandError("NOT_FOUND", "Conversation not found");
|
|
33
|
+
if (session.transcriptId !== command.expectedTranscriptId) throw new SessionCommandError("SESSION_CHANGED", "Conversation transcript changed");
|
|
34
|
+
}
|
|
35
|
+
if (service.voiceRealtime?.hasConversation(conversationId)) throw new SessionCommandError("SESSION_BUSY", "End the voice call before sending text");
|
|
36
|
+
if ("creation" in command) try {
|
|
37
|
+
validateCreation(service, command.creation);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw new SessionCommandError("BAD_REQUEST", error instanceof Error ? error.message : "Invalid creation configuration");
|
|
40
|
+
}
|
|
41
|
+
const receipt = acceptSessionCommand({
|
|
42
|
+
conversationId,
|
|
43
|
+
principalId,
|
|
44
|
+
command,
|
|
45
|
+
preparedInput: "input" in command ? await service.prepareSessionCommandInput({
|
|
46
|
+
conversationId,
|
|
47
|
+
clientMessageId,
|
|
48
|
+
delivery: command.kind === "start" ? "next" : command.delivery,
|
|
49
|
+
content: command.input.content,
|
|
50
|
+
attachments: command.input.attachments,
|
|
51
|
+
contextRefs: command.input.contextRefs,
|
|
52
|
+
sourceContexts: await prepareSourceContexts(),
|
|
53
|
+
thinking: command.kind === "start" ? command.creation.thinkingLevel : (await service.sessions.getAgentConfig(conversationId)).thinkingLevel,
|
|
54
|
+
origin: command.origin.type === "endpoint" ? {
|
|
55
|
+
type: "endpoint",
|
|
56
|
+
endpointId: command.origin.endpointId
|
|
57
|
+
} : command.origin
|
|
58
|
+
}) : void 0,
|
|
59
|
+
attachProject: (id, projectId) => service.projects.attachSession(id, projectId)
|
|
60
|
+
});
|
|
61
|
+
if ("kind" in command && command.kind === "append" && command.delivery === "steer" && receipt.inputId) await service.dispatchAcceptedSessionInput(conversationId, receipt.inputId);
|
|
62
|
+
return sessionCommandSnapshot(service, receipt);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async function sessionCommandSnapshot(service, receipt) {
|
|
66
|
+
const { principalId: _principal, requestHash: _hash, ...identity } = receipt;
|
|
67
|
+
const inputState = service.getSessionInputState(receipt.conversationId);
|
|
68
|
+
return {
|
|
69
|
+
receipt: {
|
|
70
|
+
...identity,
|
|
71
|
+
lifecycle: getSessionPreparation(receipt.conversationId)?.state ?? "ready"
|
|
72
|
+
},
|
|
73
|
+
session: await service.sessions.getSession(receipt.conversationId),
|
|
74
|
+
agentConfig: await service.sessions.getAgentConfig(receipt.conversationId),
|
|
75
|
+
inputState,
|
|
76
|
+
effectiveDelivery: inputState.inputs.find((input) => input.id === receipt.inputId)?.effectiveDelivery ?? "next",
|
|
77
|
+
preparation: getSessionPreparation(receipt.conversationId)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { receiveSessionCommand, sessionCommandSnapshot };
|
|
@@ -44,6 +44,27 @@ export declare class SessionInputCoordinator {
|
|
|
44
44
|
emit: (type: string, payload: unknown) => void;
|
|
45
45
|
});
|
|
46
46
|
snapshot(conversationId: string): SessionInputState;
|
|
47
|
+
prepareInput(input: SubmitSessionInput): Promise<{
|
|
48
|
+
status: "queued";
|
|
49
|
+
requestedDelivery: SessionInputDelivery;
|
|
50
|
+
effectiveDelivery: "next";
|
|
51
|
+
content: string;
|
|
52
|
+
attachments: UserTurnAttachment[];
|
|
53
|
+
contextRefs: import("../../agent/source-context/types.js").SourceContextRefSummary[];
|
|
54
|
+
contextSnapshots: AgentSourceContext[];
|
|
55
|
+
thinking: string;
|
|
56
|
+
origin: {
|
|
57
|
+
type: "endpoint";
|
|
58
|
+
endpointId: string;
|
|
59
|
+
} | {
|
|
60
|
+
type: "channel";
|
|
61
|
+
channel: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "system";
|
|
64
|
+
source: "automation" | "cli" | "workflow" | "heartbeat" | "internal";
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
dispatchAcceptedInput(conversationId: string, inputId: string): Promise<void>;
|
|
47
68
|
private publish;
|
|
48
69
|
private runSubmissionExclusive;
|
|
49
70
|
submit(input: SubmitSessionInput): Promise<{
|
|
@@ -42,6 +42,47 @@ var SessionInputCoordinator = class {
|
|
|
42
42
|
snapshot(conversationId) {
|
|
43
43
|
return getSessionInputState(conversationId);
|
|
44
44
|
}
|
|
45
|
+
async prepareInput(input) {
|
|
46
|
+
const attachments = await this.deps.prepareAttachments(input.conversationId, input.attachments);
|
|
47
|
+
const contexts = fitSourceContextsToBudget([...await this.deps.prepareContexts(input.conversationId, input.contextRefs) ?? [], ...input.sourceContexts ?? []]);
|
|
48
|
+
return {
|
|
49
|
+
status: "queued",
|
|
50
|
+
requestedDelivery: input.delivery,
|
|
51
|
+
effectiveDelivery: "next",
|
|
52
|
+
content: input.content.trim(),
|
|
53
|
+
attachments,
|
|
54
|
+
contextRefs: contexts.map(summarizeSourceContext),
|
|
55
|
+
contextSnapshots: contexts,
|
|
56
|
+
thinking: input.thinking,
|
|
57
|
+
origin: input.origin
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async dispatchAcceptedInput(conversationId, inputId) {
|
|
61
|
+
const input = getSessionInputById(conversationId, inputId);
|
|
62
|
+
if (!input) return;
|
|
63
|
+
await this.runSubmissionExclusive(input.conversationId, async () => {
|
|
64
|
+
const row = getSessionInputById(conversationId, inputId);
|
|
65
|
+
const state = this.snapshot(input.conversationId);
|
|
66
|
+
if (!row || row.status !== "queued" || row.origin.type === "endpoint" || row.requestedDelivery !== "steer" || !state.activeRunId || row.attachments?.length || row.contextSnapshots?.length || state.preparation && state.preparation.state !== "ready") return;
|
|
67
|
+
setSessionInputStatus(row.id, "injecting", {
|
|
68
|
+
effectiveDelivery: "steer",
|
|
69
|
+
targetRunId: state.activeRunId
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
if (!await this.deps.steer(row.conversationId, row.content)) setSessionInputStatus(row.id, "queued", {
|
|
73
|
+
effectiveDelivery: "next",
|
|
74
|
+
targetRunId: null
|
|
75
|
+
});
|
|
76
|
+
} catch (error) {
|
|
77
|
+
log.warn({
|
|
78
|
+
err: error,
|
|
79
|
+
conversationId: row.conversationId,
|
|
80
|
+
inputId
|
|
81
|
+
}, "Accepted steering input awaits execution recovery");
|
|
82
|
+
}
|
|
83
|
+
this.publish(row.conversationId);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
45
86
|
publish(conversationId) {
|
|
46
87
|
const state = this.snapshot(conversationId);
|
|
47
88
|
this.deps.emit("session.input-state", state);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GatewayService } from '../service.js';
|
|
2
|
+
export declare class SessionPreparationWorker {
|
|
3
|
+
private readonly service;
|
|
4
|
+
private timer?;
|
|
5
|
+
private readonly active;
|
|
6
|
+
private cleaning;
|
|
7
|
+
private cleanupTask?;
|
|
8
|
+
private readonly environments;
|
|
9
|
+
constructor(service: GatewayService);
|
|
10
|
+
start(): void;
|
|
11
|
+
stop(): Promise<void>;
|
|
12
|
+
wake(conversationId: string): void;
|
|
13
|
+
private cleanup;
|
|
14
|
+
private prepare;
|
|
15
|
+
}
|