@xopcai/xopc 0.0.333 → 0.0.335
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-DiI2O7lC.js → agent-avatar-dicebear-DtmNsTNI.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-CVp3J969.js → agent-defaults-settings-panel-AvGo9fao.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-CacyndrS.js → agent-plugin-dialog-DZCh4_E1.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Drt1vHf6.js +70 -0
- package/dist/gateway/static/root/assets/agents-admin-api-C82B1W9Z.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-BcszTlqr.js → app-management-settings-panel-IKZm5_s2.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-B1XPe8qz.js → appearance-settings-DKWGkrVW.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DY6Q7TMZ.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-MjUsJcNb.js → archive-plugin-DXGAt0G7.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-Dsjivdxs.js → automations-page-DzqfYcqe.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-qMpqvBz1.js +7 -0
- package/dist/gateway/static/root/assets/binary-plugins-Cy2FLsPv.js +2 -0
- package/dist/gateway/static/root/assets/{block-editor-Bx0uXbJP.js → block-editor-BqSpSNnv.js} +29 -29
- package/dist/gateway/static/root/assets/{browser-automation-inputs-1ZIPGDeq.js → browser-automation-inputs-CLOq1KtH.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-CCjYipHc.js → browser-automations-page-BEeyiVEw.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-D6SygxnY.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-BfHgt4uk.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-page-C9Od0WN-.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-6HAVkNE4.js +8 -0
- package/dist/gateway/static/root/assets/capability-header-actions-CwcT7mjE.js +1 -0
- package/dist/gateway/static/root/assets/channels-D5HNBMLS.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-Fnum_IEm.js → chat-terminal-dock-BsxTfU1T.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-DI1zfCTA.js → computer-settings-page-CH01h8yI.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-CiGDAubm.js → connector-service-page-CTi8iaOn.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-C3GhbPPg.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-DTEOeiC4.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-DpD3xaEB.js → dependency-picker-DFA0RZ02.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CCoDxKqh.js → desktop-pet-Txr49_Zi.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-GxndKfCx.js → desktop-pet-settings-Coi0DUai.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-B71w3ptm.js → device-pairing-wizard-OPY8ujCN.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-CUzjJvjs.js → directory-picker-path-field-B1ckH4hn.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-BtDY8ntX.js → extension-debug-page-6e8BCEb6.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D9_XF-XC.js → extension-page-DgaFykYf.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CjhUFAaC.js → extension-settings-page-B-TyR9GM.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-CgIjCxM8.js → gateway-config-swr-Hn1vj6uI.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-CGjSxzj6.js +1 -0
- package/dist/gateway/static/root/assets/gateway-realtime-store-DytaaEu8.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-CtjGyqB2.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-i-1lTrwY.js → gateway-startup-retry-CtTVgB7_.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-Cs5fPXcJ.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-gilc-u7M.js → image-generation-api-DBA-bdEM.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BEtq5BRU.js → imports-page-C72wCY44.js} +1 -1
- package/dist/gateway/static/root/assets/index-BkSp_1Il.js +106 -0
- package/dist/gateway/static/root/assets/index-DbLEkdNg.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-JUYY_18v.js → keyboard-shortcuts-settings-D1nzw6zI.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DqB0hGrZ.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-BlYESNqz.js → local-apps-page-D4FX0Ptx.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-Byxxogdc.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-BY30D6tg.js → locale-store-7F4l6DRV.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CcWD_-zy.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-c4krhYU7.js → management-settings-L9YGzLaz.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BEeXMfDw.js → markdown-view-bxpOryax.js} +1 -1
- package/dist/gateway/static/root/assets/media-plugins-DqsiYyAz.js +1 -0
- package/dist/gateway/static/root/assets/{messages-_6IXbP2u.js → messages-DsUnS7rn.js} +2 -2
- package/dist/gateway/static/root/assets/note-detail-panel-DwK9Ndw1.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-D2FvAV9x.js +8 -0
- package/dist/gateway/static/root/assets/page-context-capture-button-CeWnFomm.js +1 -0
- package/dist/gateway/static/root/assets/{page-tabs-BhYBCqls.js → page-tabs-B90ywILw.js} +1 -1
- package/dist/gateway/static/root/assets/popover-select-0p9PIHRy.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CP8agNlc.js → preview-open-alternatives-CwuY-FIE.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-CU7fRhfT.js → product-open-page-CUcJOCAz.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-Blo9-zcq.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-C9rh1U9Z.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BvVx0G1o.js → registry-api-DU915Prn.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Cw2Beq7s.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Czvzsuj_.js → runtime-tools-settings-panel-Cj8LnZRV.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-BZd4VZBP.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-B9Ni5O93.js → schema-form-CNbrdYAu.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-C7i3UFhq.js +1 -0
- package/dist/gateway/static/root/assets/session-manager-DAck_U0C.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-BKt3Cd0a.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BToasX5M.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-jquf1P7n.js → settings-form-section-u6ZXo3oJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DPomsvba.js → settings-page-gXacaOIv.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-qKaz5drv.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-DdkQ-B5M.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-BwFn5CYE.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-Bu7-3w-L.js → skill-api-Cf3_ZQOb.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CdNp1N-Y.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-fKPvwSpa.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-BwFR0Uci.js → system-settings-panel-CO3l1jdd.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-zClWGuT5.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-PfucxMP3.js → tunnel-api-Dw6DW1j5.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-t_zdQHcy.js → usage-page-QP_8nuHU.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-DLyy2wHz.js → use-autosave-ZwnXUpG4.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-B72PRFAI.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CQDY5EBK.js → voice-api-key-field-CbIxN5SC.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-Bwy3Al3J.js → voice-config-api-LKFent6f.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CJzqJ47I.js → work-discovery-overlay-WIGHfEL3.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-sCOk-esV.js → workflow-run-setup-panel-Bk0Jhdeq.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-BC385JPr.js +6 -0
- package/dist/gateway/static/root/index.html +27 -21
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/capabilities.js +14 -2
- package/dist/packages/gateway-contract/src/index.js +6 -2
- 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 +11 -6
- package/dist/src/agent/agent-instance-gateway.d.ts +0 -2
- package/dist/src/agent/agent-manager.d.ts +0 -2
- package/dist/src/agent/agent-manager.js +5 -36
- package/dist/src/agent/background-review/run-background-review.d.ts +0 -7
- package/dist/src/agent/background-review/run-background-review.js +3 -23
- 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/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/external-tools/gateway-tools.js +2 -1
- package/dist/src/agent/image/tool-model-config.js +2 -2
- package/dist/src/agent/orchestration/agent-orchestrator.js +0 -3
- package/dist/src/agent/service/direct-turn-helpers.js +0 -3
- package/dist/src/agent/service/process-direct-streaming.js +4 -2
- package/dist/src/agent/service.js +4 -4
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/ai-assist/text-assist.js +1 -1
- 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/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/write.d.ts +11 -11
- package/dist/src/automations/domain/validation.d.ts +11 -11
- package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
- package/dist/src/automations/events/event-dispatcher.d.ts +10 -3
- package/dist/src/automations/service/automation-service.js +0 -1
- 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/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/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +2 -2
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- 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/cli/authorization.d.ts +1 -1
- package/dist/src/connectors/cli/store.d.ts +1 -1
- package/dist/src/connectors/connection-candidates.js +53 -15
- package/dist/src/connectors/connection-capabilities.js +5 -1
- 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/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -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/commands-skills.js +9 -2
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/files.js +3 -0
- 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/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 -169
- 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/voice.js +9 -0
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- 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/service/run-gateway-agent.js +1 -1
- 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 +22 -0
- package/dist/src/gateway/service/session-preparation-worker.js +125 -0
- package/dist/src/gateway/service.d.ts +24 -0
- package/dist/src/gateway/service.js +29 -16
- package/dist/src/gateway/side-chat/promotion-service.js +0 -1
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/generator.d.ts +8 -1
- package/dist/src/home-intelligence/generator.js +26 -15
- package/dist/src/home-intelligence/host.d.ts +8 -1
- package/dist/src/home-intelligence/host.js +82 -8
- package/dist/src/home-intelligence/repository.d.ts +5 -1
- package/dist/src/home-intelligence/repository.js +16 -9
- package/dist/src/home-intelligence/snapshot.js +4 -4
- package/dist/src/local-apps/service.js +1 -1
- 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 +11 -8
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/session/store.js +0 -1
- package/dist/src/storage/sqlite/ai-usage-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/ai-usage-repository.js +25 -1
- 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 +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- 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 +4 -2
- package/dist/src/storage/sqlite/session-input-repository.js +7 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- 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/voice/realtime/persona-context.js +1 -1
- package/dist/src/work-discovery/service.js +3 -6
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/agents-DXYZSuUV.js +0 -70
- package/dist/gateway/static/root/assets/apps-page-ZqANbUZv.js +0 -1
- package/dist/gateway/static/root/assets/attachment-load-DHa-BI9a.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-B37vs5tk.js +0 -7
- package/dist/gateway/static/root/assets/binary-plugins-DQYcuBHP.js +0 -2
- package/dist/gateway/static/root/assets/browser-settings-page-CSv4rvmx.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-BnO9LV7U.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-BfvDvIY1.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CoW7-ESq.js +0 -8
- package/dist/gateway/static/root/assets/capability-header-actions-D_hbWRRF.js +0 -1
- package/dist/gateway/static/root/assets/channels-BhMaRh1x.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-Ono0Pha1.js +0 -2
- package/dist/gateway/static/root/assets/conversation-identity-Cw0n9uzK.js +0 -1
- package/dist/gateway/static/root/assets/date-picker-D-JhzZyW.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-BWaCnwT1.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BTjGLngn.js +0 -1
- package/dist/gateway/static/root/assets/index-DHL16aYZ.js +0 -121
- package/dist/gateway/static/root/assets/index-N1e6PDwx.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-uI7mtoVz.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-BbLQreeN.js +0 -2
- package/dist/gateway/static/root/assets/media-plugins-DEFN1I73.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel--09xGxyE.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-DsxcVBXF.js +0 -8
- package/dist/gateway/static/root/assets/page-context-capture-button-D43aVpCj.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-U-EdDfAW.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DUOKZLt7.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-fVPQe5YS.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-C0-WHOY3.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-DdXvW09N.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BtF83fBY.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BvVlqpHf.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-b9DI0N1J.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-R_qwc4DN.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CNJAQ_e-.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-D7XPEQu_.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-PFjGW2g1.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-OyfPVfB9.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-DYBGjN7C.js +0 -6
- 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,9 @@
|
|
|
1
1
|
import { deleteBrowserTabBinding, init_browser_tab_binding_repository } from "../../../storage/sqlite/browser-tab-binding-repository.js";
|
|
2
|
-
import { conversationIdSchema } from "../../../../packages/gateway-contract/src/conversation-identity.js";
|
|
3
2
|
import { SessionDiscoveryQuerySchema } from "../../../../packages/gateway-contract/src/session-identity.js";
|
|
4
3
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
5
4
|
import "../../../session/types.js";
|
|
6
|
-
import { deleteSessionRecord, init_session_repository } from "../../../storage/sqlite/session-repository.js";
|
|
7
5
|
import { SidebarLayoutConflictError, getSidebarLayout, init_sidebar_layout_repository, replaceSidebarLayout, sortBySidebarLayout } from "../../../storage/sqlite/sidebar-layout-repository.js";
|
|
8
|
-
import {
|
|
9
|
-
import { resolveProjectAgentId } from "../../../projects/project-agent.js";
|
|
10
|
-
import "../../../projects/index.js";
|
|
6
|
+
import { summarizeAiUsageByConversations } from "../../../storage/sqlite/ai-usage-repository.js";
|
|
11
7
|
import { messagesToClientHistory } from "../../../session/client-history.js";
|
|
12
8
|
import { evictEmbeddedSessionRunner } from "../../../agent/embedded/session-runner.js";
|
|
13
9
|
import { SessionEnvironmentService } from "../../../execution-environments/session-environment-service.js";
|
|
@@ -17,11 +13,8 @@ import { createGatewayRouteLogger, logRouteError } from "../lib/route-logger.js"
|
|
|
17
13
|
import { patchChatModelConfig } from "./chat-model-config.js";
|
|
18
14
|
import { getSessionContextSummary } from "../../session-context-summary.js";
|
|
19
15
|
import { respondStartupUnavailable } from "../lib/startup-unavailable.js";
|
|
20
|
-
import { randomUUID } from "node:crypto";
|
|
21
16
|
//#region src/gateway/hono/routes/sessions.ts
|
|
22
17
|
init_src();
|
|
23
|
-
init_conversation_repository();
|
|
24
|
-
init_session_repository();
|
|
25
18
|
init_browser_tab_binding_repository();
|
|
26
19
|
init_sidebar_layout_repository();
|
|
27
20
|
const log = createGatewayRouteLogger("Sessions");
|
|
@@ -36,9 +29,6 @@ const DEFAULT_SIDEBAR_STALE_DAYS = 60;
|
|
|
36
29
|
function isSessionType(value) {
|
|
37
30
|
return SESSION_TYPES.has(value);
|
|
38
31
|
}
|
|
39
|
-
function parseExecutionMode(value) {
|
|
40
|
-
return value === "local_checkout" || value === "managed_worktree" ? value : void 0;
|
|
41
|
-
}
|
|
42
32
|
function ensureGatewayReadyForSessions(c, service, method) {
|
|
43
33
|
if (service.isGatewayReady()) return null;
|
|
44
34
|
return respondStartupUnavailable(c, method);
|
|
@@ -71,26 +61,6 @@ function isHistoryCursor(value) {
|
|
|
71
61
|
if (!/^(0|[1-9]\d*)$/.test(value)) return false;
|
|
72
62
|
return Number.isSafeInteger(Number(value));
|
|
73
63
|
}
|
|
74
|
-
function buildDirectSessionMetadata(params) {
|
|
75
|
-
return {
|
|
76
|
-
sourceChannel: params.source,
|
|
77
|
-
sourceChatId: [
|
|
78
|
-
params.accountId,
|
|
79
|
-
"direct",
|
|
80
|
-
params.peerId
|
|
81
|
-
].join(":"),
|
|
82
|
-
sessionType: "chat",
|
|
83
|
-
hiddenFromSessionList: true,
|
|
84
|
-
routing: {
|
|
85
|
-
agentId: params.agentId,
|
|
86
|
-
source: params.source,
|
|
87
|
-
accountId: params.accountId,
|
|
88
|
-
peerKind: "direct",
|
|
89
|
-
peerId: params.peerId
|
|
90
|
-
},
|
|
91
|
-
customData: { genericNewChatShell: params.source === "webchat" && params.peerId.startsWith("chat_") }
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
64
|
function registerSessionsRoutes(authenticated, deps) {
|
|
95
65
|
const { service } = deps;
|
|
96
66
|
const environments = new SessionEnvironmentService();
|
|
@@ -288,143 +258,6 @@ function registerSessionsRoutes(authenticated, deps) {
|
|
|
288
258
|
throw error;
|
|
289
259
|
}
|
|
290
260
|
});
|
|
291
|
-
authenticated.post("/api/sessions", async (c) => {
|
|
292
|
-
const body = await c.req.json().catch(() => ({}));
|
|
293
|
-
if (body.conversationId !== void 0 && !conversationIdSchema.safeParse(body.conversationId).success) return c.json({
|
|
294
|
-
ok: false,
|
|
295
|
-
error: "conversationId must be a UUID"
|
|
296
|
-
}, 400);
|
|
297
|
-
const channel = typeof body.channel === "string" && body.channel.trim() ? body.channel.trim() : "webchat";
|
|
298
|
-
const projectId = typeof body.projectId === "string" && body.projectId.trim() ? body.projectId.trim() : void 0;
|
|
299
|
-
const routingCfg = service.currentConfig;
|
|
300
|
-
const project = projectId ? service.projects.get(projectId) : null;
|
|
301
|
-
if (projectId && !project) return c.json({
|
|
302
|
-
ok: false,
|
|
303
|
-
error: "Project not found"
|
|
304
|
-
}, 404);
|
|
305
|
-
const requestedExecutionMode = parseExecutionMode(body.executionMode);
|
|
306
|
-
if (body.executionMode !== void 0 && !requestedExecutionMode) return c.json({
|
|
307
|
-
ok: false,
|
|
308
|
-
error: "Invalid execution mode"
|
|
309
|
-
}, 400);
|
|
310
|
-
if (requestedExecutionMode && !project) return c.json({
|
|
311
|
-
ok: false,
|
|
312
|
-
error: "An execution mode requires a project"
|
|
313
|
-
}, 400);
|
|
314
|
-
let agentId;
|
|
315
|
-
try {
|
|
316
|
-
agentId = resolveProjectAgentId({
|
|
317
|
-
config: routingCfg,
|
|
318
|
-
projects: service.projects,
|
|
319
|
-
explicitAgentId: typeof body.agentId === "string" ? body.agentId : void 0,
|
|
320
|
-
projectId
|
|
321
|
-
});
|
|
322
|
-
} catch (error) {
|
|
323
|
-
return c.json({
|
|
324
|
-
ok: false,
|
|
325
|
-
error: error instanceof Error ? error.message : String(error)
|
|
326
|
-
}, 400);
|
|
327
|
-
}
|
|
328
|
-
const chatId = (typeof body.chat_id === "string" && body.chat_id.trim() ? body.chat_id.trim() : void 0) ?? `chat_${randomUUID()}`;
|
|
329
|
-
const metadata = {
|
|
330
|
-
agentId,
|
|
331
|
-
...buildDirectSessionMetadata({
|
|
332
|
-
agentId,
|
|
333
|
-
source: channel,
|
|
334
|
-
accountId: "default",
|
|
335
|
-
peerId: chatId
|
|
336
|
-
}),
|
|
337
|
-
...channel === "tui" ? {
|
|
338
|
-
hiddenFromSessionList: true,
|
|
339
|
-
customData: { genericNewChatShell: true }
|
|
340
|
-
} : {}
|
|
341
|
-
};
|
|
342
|
-
let conversationId;
|
|
343
|
-
try {
|
|
344
|
-
conversationId = createConversation(metadata, "", body.conversationId).key;
|
|
345
|
-
} catch (error) {
|
|
346
|
-
if (error instanceof ConversationAlreadyExistsError) return c.json({
|
|
347
|
-
ok: false,
|
|
348
|
-
error: error.message
|
|
349
|
-
}, 409);
|
|
350
|
-
throw error;
|
|
351
|
-
}
|
|
352
|
-
let environment;
|
|
353
|
-
if (project && (project.workspaceRoot?.trim() || requestedExecutionMode)) try {
|
|
354
|
-
environment = await environments.attach({
|
|
355
|
-
conversationId,
|
|
356
|
-
project,
|
|
357
|
-
mode: requestedExecutionMode,
|
|
358
|
-
baseRef: typeof body.baseRef === "string" ? body.baseRef : void 0
|
|
359
|
-
});
|
|
360
|
-
} catch (error) {
|
|
361
|
-
deleteSessionRecord(conversationId);
|
|
362
|
-
return c.json({
|
|
363
|
-
ok: false,
|
|
364
|
-
code: "execution_environment_unavailable",
|
|
365
|
-
error: error instanceof Error ? error.message : String(error)
|
|
366
|
-
}, 409);
|
|
367
|
-
}
|
|
368
|
-
try {
|
|
369
|
-
await service.sessionIndexInstance.saveMessages(conversationId, [], { metadata });
|
|
370
|
-
if (projectId) service.projects.attachSession(conversationId, projectId);
|
|
371
|
-
} catch (error) {
|
|
372
|
-
await service.sessions.delete(conversationId).catch(() => void 0);
|
|
373
|
-
await environments.release(conversationId).catch(() => void 0);
|
|
374
|
-
throw error;
|
|
375
|
-
}
|
|
376
|
-
const rawInitialConfig = body.initialAgentConfig && typeof body.initialAgentConfig === "object" ? body.initialAgentConfig : {};
|
|
377
|
-
const model = typeof rawInitialConfig.model === "string" && rawInitialConfig.model.trim() ? rawInitialConfig.model.trim() : void 0;
|
|
378
|
-
const thinkingLevel = typeof rawInitialConfig.thinkingLevel === "string" && rawInitialConfig.thinkingLevel.trim() ? rawInitialConfig.thinkingLevel.trim() : void 0;
|
|
379
|
-
const initialAgentConfig = {
|
|
380
|
-
...model ? { model } : {},
|
|
381
|
-
...thinkingLevel ? { thinkingLevel } : {},
|
|
382
|
-
...body.temporary === true ? { userContextMode: "temporary" } : {}
|
|
383
|
-
};
|
|
384
|
-
if (channel === "webchat" && model) {
|
|
385
|
-
const result = await service.sessions.initializeChatModel(conversationId, model, thinkingLevel);
|
|
386
|
-
if (!result.ok) {
|
|
387
|
-
await service.sessions.delete(conversationId).catch(() => void 0);
|
|
388
|
-
await environments.release(conversationId).catch((error) => {
|
|
389
|
-
log.warn({
|
|
390
|
-
err: error,
|
|
391
|
-
conversationId
|
|
392
|
-
}, "Invalid new session model and execution environment cleanup failed");
|
|
393
|
-
});
|
|
394
|
-
return c.json({
|
|
395
|
-
ok: false,
|
|
396
|
-
error: result.error
|
|
397
|
-
}, 400);
|
|
398
|
-
}
|
|
399
|
-
delete initialAgentConfig.model;
|
|
400
|
-
delete initialAgentConfig.thinkingLevel;
|
|
401
|
-
}
|
|
402
|
-
if (Object.keys(initialAgentConfig).length > 0) {
|
|
403
|
-
const result = await service.sessions.patchAgentConfig(conversationId, initialAgentConfig);
|
|
404
|
-
if (!result.ok) {
|
|
405
|
-
await service.sessions.delete(conversationId).catch(() => void 0);
|
|
406
|
-
await environments.release(conversationId).catch((error) => {
|
|
407
|
-
log.warn({
|
|
408
|
-
err: error,
|
|
409
|
-
conversationId
|
|
410
|
-
}, "Invalid new session config and execution environment cleanup failed");
|
|
411
|
-
});
|
|
412
|
-
return c.json({
|
|
413
|
-
ok: false,
|
|
414
|
-
error: result.error
|
|
415
|
-
}, 400);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
if (body.createdSurface === "browser_extension") await service.sessions.patch(conversationId, { customData: { createdSurface: "browser_extension" } });
|
|
419
|
-
const session = await service.sessions.getSession(conversationId);
|
|
420
|
-
const agentConfig = channel === "webchat" ? await service.sessions.getFixedAgentConfig(conversationId) : void 0;
|
|
421
|
-
return c.json({
|
|
422
|
-
conversationId,
|
|
423
|
-
session,
|
|
424
|
-
agentConfig,
|
|
425
|
-
...environment ? { environment } : {}
|
|
426
|
-
}, 201);
|
|
427
|
-
});
|
|
428
261
|
authenticated.get("/api/sessions", async (c) => {
|
|
429
262
|
const blocked = ensureGatewayReadyForSessions(c, service, "sessions.list");
|
|
430
263
|
if (blocked) return blocked;
|
|
@@ -454,7 +287,20 @@ function registerSessionsRoutes(authenticated, deps) {
|
|
|
454
287
|
limit: query.limit ? parseInt(query.limit) : void 0,
|
|
455
288
|
offset: query.offset ? parseInt(query.offset) : void 0
|
|
456
289
|
});
|
|
457
|
-
|
|
290
|
+
const usageByConversation = summarizeAiUsageByConversations(result.items.map((item) => item.key));
|
|
291
|
+
return c.json({
|
|
292
|
+
...result,
|
|
293
|
+
items: result.items.map((item) => ({
|
|
294
|
+
...item,
|
|
295
|
+
usage: usageByConversation.get(item.key) ?? {
|
|
296
|
+
calls: 0,
|
|
297
|
+
unknownCostCalls: 0,
|
|
298
|
+
totalTokens: 0,
|
|
299
|
+
knownCostUsd: "0",
|
|
300
|
+
costCompleteness: "unknown"
|
|
301
|
+
}
|
|
302
|
+
}))
|
|
303
|
+
});
|
|
458
304
|
});
|
|
459
305
|
authenticated.get("/api/sessions/stats", async (c) => {
|
|
460
306
|
const result = await service.sessions.stats();
|
|
@@ -5,9 +5,9 @@ import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
|
5
5
|
import { enqueueTaskChangedEvent, init_task_change_events } from "../../../tasks/task-change-events.js";
|
|
6
6
|
import { TaskRepository, init_task_repository } from "../../../tasks/task-repository.js";
|
|
7
7
|
import { TaskRunRepository, init_task_run_repository } from "../../../tasks/task-run-repository.js";
|
|
8
|
-
import { TaskConversationRepository } from "../../../tasks/task-conversation-repository.js";
|
|
9
8
|
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
10
9
|
import "../../../capabilities/runtime/dispatcher.js";
|
|
10
|
+
import { TaskConversationRepository } from "../../../tasks/task-conversation-repository.js";
|
|
11
11
|
import { TaskContextMutationOutputSchema } from "../../../tasks/capabilities/relations.js";
|
|
12
12
|
import { TaskDeleteOutputSchema } from "../../../tasks/capabilities/management.js";
|
|
13
13
|
import { TaskMutationOutputSchema } from "../../../tasks/capabilities/write.js";
|
|
@@ -3,7 +3,8 @@ import { collectTuiStartupResources } from "../../../tui/tui-startup-resources.j
|
|
|
3
3
|
function registerTuiRoutes(authenticated, deps) {
|
|
4
4
|
authenticated.get("/api/tui/startup-resources", (c) => {
|
|
5
5
|
const conversationId = c.req.query("conversationId")?.trim() || void 0;
|
|
6
|
-
const
|
|
6
|
+
const agentId = conversationId ? void 0 : c.req.query("agentId")?.trim();
|
|
7
|
+
const payload = collectTuiStartupResources(deps.service.currentConfig, conversationId, { agentId });
|
|
7
8
|
return c.json({
|
|
8
9
|
ok: true,
|
|
9
10
|
payload
|
|
@@ -14,6 +14,7 @@ import { mergeTtsConfigFromAppConfig } from "../../../voice/tts/merge-config.js"
|
|
|
14
14
|
import { listSttProvidersForApi } from "../../../voice/stt/list-providers.js";
|
|
15
15
|
import "../../../voice/tts/index.js";
|
|
16
16
|
import { withModelConfigLock } from "../../../session/model-config-lock.js";
|
|
17
|
+
import { getSessionPreparation } from "../../../storage/sqlite/session-creation-repository.js";
|
|
17
18
|
import { resolveOmniRoute } from "../../../voice/realtime/omniRoute.js";
|
|
18
19
|
import { VoiceSessionCreationError, resolveStreamingStt, resolveStreamingTts } from "../../../voice/realtime/runtime.js";
|
|
19
20
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
@@ -268,6 +269,14 @@ function registerVoiceRoutes(authenticated, deps) {
|
|
|
268
269
|
}
|
|
269
270
|
}, 400);
|
|
270
271
|
try {
|
|
272
|
+
const preparation = parsed.data.conversationId ? getSessionPreparation(parsed.data.conversationId) : void 0;
|
|
273
|
+
if (preparation && preparation.state !== "ready") return c.json({
|
|
274
|
+
ok: false,
|
|
275
|
+
error: {
|
|
276
|
+
code: "SESSION_PREPARING",
|
|
277
|
+
message: "Session environment is not ready"
|
|
278
|
+
}
|
|
279
|
+
}, 409);
|
|
271
280
|
if (action === "preflight") {
|
|
272
281
|
await service.voiceRealtime.preflight(parsed.data);
|
|
273
282
|
return c.json({ ok: true });
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { normalizeAgentId } from "../agent-catalog/id.js";
|
|
2
2
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
3
|
-
import { ConfigSchema, init_schema } from "../config/schema.js";
|
|
4
3
|
import { init_agent_scope } from "../agent/agent-scope.js";
|
|
4
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
5
|
+
import { ConfigSchema, init_schema } from "../config/schema.js";
|
|
5
6
|
import { resolveEffectiveAgentConfigForAgent } from "../config/agent-profile.js";
|
|
6
7
|
import { fetchWithTimeoutGuarded } from "../media-shared/http/provider-http.js";
|
|
7
8
|
import "../media-shared/http/index.js";
|
|
8
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
9
9
|
import { getImageGenerationProvider, listImageGenerationProvidersSummary } from "../agent/image/generation/provider-registry.js";
|
|
10
10
|
//#region src/gateway/image-generation-setup.ts
|
|
11
11
|
init_repository();
|
package/dist/src/gateway/lock.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
-
import net from "node:net";
|
|
5
4
|
import fs$1 from "node:fs/promises";
|
|
5
|
+
import net from "node:net";
|
|
6
6
|
import { homedir } from "os";
|
|
7
7
|
//#region src/gateway/lock.ts
|
|
8
8
|
/**
|
|
@@ -10,6 +10,6 @@ export type ResolveWebchatConversationIdResult = {
|
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* Resolve the server-owned session key for webchat `/api/agent` requests.
|
|
13
|
-
*
|
|
13
|
+
* Ordinary creation is accepted atomically by a start input command.
|
|
14
14
|
*/
|
|
15
15
|
export declare function resolveWebchatConversationId(input: ResolveWebchatConversationIdInput): ResolveWebchatConversationIdResult;
|
|
@@ -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,
|
|
@@ -51,7 +51,7 @@ async function* runGatewayAgent(deps, message, channel, chatId, origin, attachme
|
|
|
51
51
|
if (resolved.ok === false) throw new Error(resolved.error);
|
|
52
52
|
webchatConversationId = resolved.conversationId;
|
|
53
53
|
const meta = await sessionIndex.getSessionMetadata(webchatConversationId);
|
|
54
|
-
if (!meta) throw new Error("Session not found;
|
|
54
|
+
if (!meta) throw new Error("Session not found; submit a start input command first");
|
|
55
55
|
webchatTranscriptId = meta?.transcriptId;
|
|
56
56
|
webchatMetadata = meta;
|
|
57
57
|
runAbortControllers.set(runId, new AbortController());
|
|
@@ -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,22 @@
|
|
|
1
|
+
import type { ProjectService } from '../../projects/project-service.js';
|
|
2
|
+
import type { SessionInputState } from '../../storage/sqlite/session-input-repository.js';
|
|
3
|
+
export interface SessionPreparationWorkerService {
|
|
4
|
+
projects: Pick<ProjectService, 'get'>;
|
|
5
|
+
drainSessionInputs(conversationId: string): Promise<unknown>;
|
|
6
|
+
getSessionInputState(conversationId: string): SessionInputState;
|
|
7
|
+
emit(type: string, payload: unknown): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class SessionPreparationWorker {
|
|
10
|
+
private readonly service;
|
|
11
|
+
private timer?;
|
|
12
|
+
private readonly active;
|
|
13
|
+
private cleaning;
|
|
14
|
+
private cleanupTask?;
|
|
15
|
+
private readonly environments;
|
|
16
|
+
constructor(service: SessionPreparationWorkerService);
|
|
17
|
+
start(): void;
|
|
18
|
+
stop(): Promise<void>;
|
|
19
|
+
wake(conversationId: string): void;
|
|
20
|
+
private cleanup;
|
|
21
|
+
private prepare;
|
|
22
|
+
}
|