@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
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createLogger } from "../../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
4
|
+
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
5
|
+
import { init_session_repository } from "../../storage/sqlite/session-repository.js";
|
|
6
|
+
import { resolveGitCommit } from "../../execution-environments/git.js";
|
|
7
|
+
import { SessionEnvironmentService } from "../../execution-environments/session-environment-service.js";
|
|
8
|
+
import { claimSessionPreparation, finishSessionPreparation, getSessionPreparation, pendingSessionPreparations } from "../../storage/sqlite/session-creation-repository.js";
|
|
9
|
+
//#region src/gateway/service/session-preparation-worker.ts
|
|
10
|
+
init_transaction();
|
|
11
|
+
init_session_repository();
|
|
12
|
+
init_logger();
|
|
13
|
+
const log = createLogger("Gateway:SessionPreparation");
|
|
14
|
+
var SessionPreparationWorker = class {
|
|
15
|
+
timer;
|
|
16
|
+
active = /* @__PURE__ */ new Map();
|
|
17
|
+
cleaning = false;
|
|
18
|
+
cleanupTask;
|
|
19
|
+
environments = new SessionEnvironmentService();
|
|
20
|
+
constructor(service) {
|
|
21
|
+
this.service = service;
|
|
22
|
+
}
|
|
23
|
+
start() {
|
|
24
|
+
if (this.timer) return;
|
|
25
|
+
const scan = () => {
|
|
26
|
+
for (const id of pendingSessionPreparations()) this.wake(id);
|
|
27
|
+
this.cleanupTask ??= this.cleanup().catch((err) => log.error({ err }, "Session reservation cleanup scan failed")).finally(() => {
|
|
28
|
+
this.cleanupTask = void 0;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
scan();
|
|
32
|
+
this.timer = setInterval(scan, 5e3);
|
|
33
|
+
this.timer.unref();
|
|
34
|
+
}
|
|
35
|
+
async stop() {
|
|
36
|
+
clearInterval(this.timer);
|
|
37
|
+
this.timer = void 0;
|
|
38
|
+
await Promise.allSettled(this.active.values());
|
|
39
|
+
await this.cleanupTask;
|
|
40
|
+
}
|
|
41
|
+
wake(conversationId) {
|
|
42
|
+
if (this.active.has(conversationId)) return;
|
|
43
|
+
const work = this.prepare(conversationId).catch((err) => {
|
|
44
|
+
log.error({
|
|
45
|
+
err,
|
|
46
|
+
conversationId,
|
|
47
|
+
phase: "prepare"
|
|
48
|
+
}, "Session preparation failed");
|
|
49
|
+
}).finally(() => this.active.delete(conversationId));
|
|
50
|
+
this.active.set(conversationId, work);
|
|
51
|
+
}
|
|
52
|
+
async cleanup() {
|
|
53
|
+
if (this.cleaning) return;
|
|
54
|
+
this.cleaning = true;
|
|
55
|
+
try {
|
|
56
|
+
const pending = getSqliteDatabase().prepare("SELECT * FROM session_preparation_cleanup WHERE not_before<=?").all(Date.now());
|
|
57
|
+
for (const row of pending) {
|
|
58
|
+
if (this.active.has(row.conversation_id)) continue;
|
|
59
|
+
try {
|
|
60
|
+
if (await this.environments.removeUnboundReservation(row.environment_id)) getSqliteDatabase().prepare("DELETE FROM session_preparation_cleanup WHERE environment_id=?").run(row.environment_id);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
63
|
+
getSqliteDatabase().prepare("UPDATE session_preparation_cleanup SET last_error=?,not_before=? WHERE environment_id=?").run(message, Date.now() + 6e4, row.environment_id);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} finally {
|
|
67
|
+
this.cleaning = false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async prepare(conversationId) {
|
|
71
|
+
const operation = claimSessionPreparation(conversationId);
|
|
72
|
+
if (!operation) return;
|
|
73
|
+
const heartbeat = setInterval(() => {
|
|
74
|
+
getSqliteDatabase().prepare(`UPDATE session_preparations SET lease_until=?
|
|
75
|
+
WHERE operation_id=? AND revision=? AND state='preparing'`).run(Date.now() + 6e4, operation.operationId, operation.revision);
|
|
76
|
+
}, 15e3);
|
|
77
|
+
heartbeat.unref();
|
|
78
|
+
try {
|
|
79
|
+
const project = operation.creation.projectId ? this.service.projects.get(operation.creation.projectId) : null;
|
|
80
|
+
if (!project?.workspaceRoot || !operation.creation.execution) throw new Error("Project workspace is unavailable");
|
|
81
|
+
let baseRef = operation.baseCommit ?? void 0;
|
|
82
|
+
if (operation.creation.execution.mode === "managed_worktree" && !baseRef) {
|
|
83
|
+
baseRef = await resolveGitCommit(project.workspaceRoot, operation.creation.execution.baseRef ?? "HEAD");
|
|
84
|
+
if (!getSqliteDatabase().prepare("UPDATE session_preparations SET base_commit=? WHERE operation_id=? AND revision=?").run(baseRef, operation.operationId, operation.revision).changes) return;
|
|
85
|
+
}
|
|
86
|
+
if (!getSessionMetadata(conversationId)) return;
|
|
87
|
+
await this.environments.attach({
|
|
88
|
+
conversationId,
|
|
89
|
+
project,
|
|
90
|
+
mode: operation.creation.execution.mode,
|
|
91
|
+
baseRef,
|
|
92
|
+
environmentId: operation.environmentId,
|
|
93
|
+
assertCurrent: () => {
|
|
94
|
+
const current = getSessionPreparation(conversationId);
|
|
95
|
+
if (!current || current.operationId !== operation.operationId || current.revision !== operation.revision || current.state !== "preparing" || !getSessionMetadata(conversationId)) throw new Error("Session preparation ownership changed");
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (runSqliteWriteTransaction(() => {
|
|
99
|
+
if (!getSessionMetadata(conversationId)) return false;
|
|
100
|
+
return finishSessionPreparation(operation);
|
|
101
|
+
})) this.service.drainSessionInputs(conversationId).catch((err) => {
|
|
102
|
+
log.error({
|
|
103
|
+
err,
|
|
104
|
+
conversationId
|
|
105
|
+
}, "Prepared session input drain failed");
|
|
106
|
+
});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
finishSessionPreparation(operation, error instanceof Error ? error.message : String(error));
|
|
109
|
+
log.warn({
|
|
110
|
+
err: error,
|
|
111
|
+
conversationId,
|
|
112
|
+
operationId: operation.operationId
|
|
113
|
+
}, "Session environment preparation failed");
|
|
114
|
+
} finally {
|
|
115
|
+
clearInterval(heartbeat);
|
|
116
|
+
const preparation = getSessionPreparation(conversationId);
|
|
117
|
+
if (preparation) this.service.emit("session.input-state", {
|
|
118
|
+
...this.service.getSessionInputState(conversationId),
|
|
119
|
+
preparation
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
export { SessionPreparationWorker };
|
|
@@ -20,6 +20,7 @@ import { type BrowserAutomationService } from '../browser/automations/index.js';
|
|
|
20
20
|
import { GatewaySessionsApi } from './service/sessions-api.js';
|
|
21
21
|
import { GatewayMarketplaceService } from './service/marketplace-service.js';
|
|
22
22
|
import { GatewayAgentRunner } from './service/agent-runner.js';
|
|
23
|
+
import { SessionPreparationWorker } from './service/session-preparation-worker.js';
|
|
23
24
|
import { RealtimeRuntime } from '../realtime/runtime.js';
|
|
24
25
|
import { VoiceRealtimeRuntime } from '../voice/realtime/runtime.js';
|
|
25
26
|
import type { GatewayServiceConfig } from './service/types.js';
|
|
@@ -85,6 +86,7 @@ export declare class GatewayService {
|
|
|
85
86
|
* `activeWebchatRunBySession` + `runAbortControllers` maps.
|
|
86
87
|
*/
|
|
87
88
|
readonly agentRunner: GatewayAgentRunner;
|
|
89
|
+
readonly sessionPreparations: SessionPreparationWorker;
|
|
88
90
|
/** Process-local, non-persistent side conversations forked from durable sessions. */
|
|
89
91
|
readonly sideChats: EphemeralSideChatManager;
|
|
90
92
|
readonly sideChatRuns: SideChatRunService;
|
|
@@ -145,6 +147,28 @@ export declare class GatewayService {
|
|
|
145
147
|
ok: false;
|
|
146
148
|
code: "BAD_REQUEST" | "QUEUE_FULL" | "CONTEXT_UNAVAILABLE" | "SESSION_CHANGED";
|
|
147
149
|
}>;
|
|
150
|
+
prepareSessionCommandInput(input: Parameters<GatewayAgentRunner['inputs']['prepareInput']>[0]): Promise<{
|
|
151
|
+
status: "queued";
|
|
152
|
+
requestedDelivery: import("../storage/sqlite/session-input-repository.js").SessionInputDelivery;
|
|
153
|
+
effectiveDelivery: "next";
|
|
154
|
+
content: string;
|
|
155
|
+
attachments: import("./user-turn-input.js").UserTurnAttachment[];
|
|
156
|
+
contextRefs: import("../agent/source-context/types.js").SourceContextRefSummary[];
|
|
157
|
+
contextSnapshots: import("../agent/source-context/types.js").AgentSourceContext[];
|
|
158
|
+
thinking: string;
|
|
159
|
+
origin: {
|
|
160
|
+
type: "endpoint";
|
|
161
|
+
endpointId: string;
|
|
162
|
+
} | {
|
|
163
|
+
type: "channel";
|
|
164
|
+
channel: string;
|
|
165
|
+
} | {
|
|
166
|
+
type: "system";
|
|
167
|
+
source: "automation" | "cli" | "workflow" | "heartbeat" | "internal";
|
|
168
|
+
};
|
|
169
|
+
}>;
|
|
170
|
+
drainSessionInputs(conversationId: string): Promise<void>;
|
|
171
|
+
dispatchAcceptedSessionInput(conversationId: string, inputId: string): Promise<void>;
|
|
148
172
|
private appContextDispatcher;
|
|
149
173
|
prepareSessionAppContext(input: unknown, principal: GatewayPrincipal, conversationId: string, clientMessageId: string): Promise<import("../agent/source-context/types.js").AgentSourceContext>;
|
|
150
174
|
replaceLatestSessionTurn(...args: Parameters<GatewayAgentRunner['replaceLatestSessionTurn']>): Promise<{
|
|
@@ -16,17 +16,17 @@ import { init_session_repository, listSessionMetadata, patchSessionMetadata } fr
|
|
|
16
16
|
import { getSessionConfig, init_config_repository } from "../storage/sqlite/config-repository.js";
|
|
17
17
|
import { init_sqlite } from "../storage/sqlite/index.js";
|
|
18
18
|
import { normalizeAgentId } from "../agent-catalog/id.js";
|
|
19
|
+
import { init_agent_scope, listAgentEntries, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
20
|
+
import { init_paths, resolveConfigPath, resolveExtensionsDir } from "../config/paths.js";
|
|
19
21
|
import { init_config, resolveKnowledgeReadPolicy } from "../user-context/config.js";
|
|
20
22
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
21
|
-
import {
|
|
23
|
+
import { prewarmModelRegistry } from "../providers/model-registry.js";
|
|
22
24
|
import { init_agent_session_key, resolveAgentMainConversationId } from "../routing/agent-session-key.js";
|
|
23
25
|
import { init_session_key, resolveConversationId, sanitizeSegment } from "../routing/session-key.js";
|
|
24
26
|
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
25
|
-
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
26
|
-
import { init_paths, resolveConfigPath, resolveExtensionsDir } from "../config/paths.js";
|
|
27
|
-
import { prewarmModelRegistry } from "../providers/model-registry.js";
|
|
28
27
|
import { init_providers, providers_exports } from "../providers/index.js";
|
|
29
28
|
import { AI_USAGE_RETENTION_MS, markStaleAiUsageEventsUnknown, pruneAiUsageEvents } from "../storage/sqlite/ai-usage-repository.js";
|
|
29
|
+
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
30
30
|
import { TaskConversationRepository } from "../tasks/task-conversation-repository.js";
|
|
31
31
|
import { listKnowledgeItems } from "../knowledge-memory/repository.js";
|
|
32
32
|
import "../knowledge-memory/index.js";
|
|
@@ -73,24 +73,20 @@ import { ChatPreviewService } from "../chat-previews/service.js";
|
|
|
73
73
|
import "../chat-previews/index.js";
|
|
74
74
|
import { getWorkspacePath } from "../config/workspace-path-helpers.js";
|
|
75
75
|
import "../config/index.js";
|
|
76
|
-
import { DiscussionService } from "../discussions/service.js";
|
|
77
|
-
import { DiscussionOrganizer } from "../discussions/organizer.js";
|
|
78
|
-
import { DiscussionLiveWorker } from "../discussions/live-worker.js";
|
|
79
|
-
import { DiscussionOrganizerWorker } from "../discussions/organizer-worker.js";
|
|
80
|
-
import { DiscussionSealer } from "../discussions/sealer.js";
|
|
81
|
-
import "../discussions/index.js";
|
|
82
|
-
import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
83
|
-
import "../endpoint-tools/index.js";
|
|
84
76
|
import { ManagedComposioEventPoller } from "../connectors/composio-managed-events.js";
|
|
85
77
|
import { startConnectedKnowledgeCoordinator } from "../knowledge/coordinator.js";
|
|
86
78
|
import "../knowledge/index.js";
|
|
87
79
|
import { ConnectionRecoveryService } from "../connectors/connection-recovery-service.js";
|
|
88
80
|
import { startConnectorLearningCoordinator } from "../connectors/learning-coordinator.js";
|
|
89
81
|
import { startConnectorSupervisor } from "../connectors/supervisor.js";
|
|
90
|
-
import {
|
|
91
|
-
import
|
|
92
|
-
import {
|
|
93
|
-
import {
|
|
82
|
+
import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
83
|
+
import "../endpoint-tools/index.js";
|
|
84
|
+
import { DiscussionService } from "../discussions/service.js";
|
|
85
|
+
import { DiscussionOrganizer } from "../discussions/organizer.js";
|
|
86
|
+
import { DiscussionLiveWorker } from "../discussions/live-worker.js";
|
|
87
|
+
import { DiscussionOrganizerWorker } from "../discussions/organizer-worker.js";
|
|
88
|
+
import { DiscussionSealer } from "../discussions/sealer.js";
|
|
89
|
+
import "../discussions/index.js";
|
|
94
90
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
95
91
|
import { prepareAutomationAgentSession } from "./automation-agent-session.js";
|
|
96
92
|
import { stopTailscaleExposure } from "./tailscale-lifecycle.js";
|
|
@@ -136,6 +132,7 @@ import { GatewaySessionsApi } from "./service/sessions-api.js";
|
|
|
136
132
|
import { GatewayMarketplaceService } from "./service/marketplace-service.js";
|
|
137
133
|
import { GatewayConfigCoordinator } from "./service/config-coordinator.js";
|
|
138
134
|
import { GatewayAgentRunner } from "./service/agent-runner.js";
|
|
135
|
+
import { SessionPreparationWorker } from "./service/session-preparation-worker.js";
|
|
139
136
|
import { isBrowserSessionActive } from "../storage/sqlite/browser-session-repository.js";
|
|
140
137
|
import { RealtimeRuntime } from "../realtime/runtime.js";
|
|
141
138
|
import { VoiceRealtimeRuntime } from "../voice/realtime/runtime.js";
|
|
@@ -146,6 +143,10 @@ import { createGatewayStartupTrace } from "./startup-trace.js";
|
|
|
146
143
|
import { GatewaySceneHost } from "./scenes/host.js";
|
|
147
144
|
import { checkAppContextAccess, prepareAppContext } from "./service/app-context-access.js";
|
|
148
145
|
import { applyAutomaticVoiceLanguage, inferProductLanguageFromEnvironment, initializeVoiceDefaults } from "../voice/language-profile.js";
|
|
146
|
+
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
147
|
+
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
148
|
+
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
149
|
+
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
149
150
|
import crypto from "node:crypto";
|
|
150
151
|
//#region src/gateway/service.ts
|
|
151
152
|
init_session_repository();
|
|
@@ -312,6 +313,7 @@ var GatewayService = class {
|
|
|
312
313
|
* `activeWebchatRunBySession` + `runAbortControllers` maps.
|
|
313
314
|
*/
|
|
314
315
|
agentRunner;
|
|
316
|
+
sessionPreparations = new SessionPreparationWorker(this);
|
|
315
317
|
/** Process-local, non-persistent side conversations forked from durable sessions. */
|
|
316
318
|
sideChats;
|
|
317
319
|
sideChatRuns;
|
|
@@ -891,6 +893,15 @@ var GatewayService = class {
|
|
|
891
893
|
submitSessionInput(...args) {
|
|
892
894
|
return this.agentRunner.submitSessionInput(...args);
|
|
893
895
|
}
|
|
896
|
+
prepareSessionCommandInput(input) {
|
|
897
|
+
return this.agentRunner.inputs.prepareInput(input);
|
|
898
|
+
}
|
|
899
|
+
drainSessionInputs(conversationId) {
|
|
900
|
+
return this.agentRunner.inputs.drain(conversationId);
|
|
901
|
+
}
|
|
902
|
+
dispatchAcceptedSessionInput(conversationId, inputId) {
|
|
903
|
+
return this.agentRunner.inputs.dispatchAcceptedInput(conversationId, inputId);
|
|
904
|
+
}
|
|
894
905
|
appContextDispatcher() {
|
|
895
906
|
return createProductDispatcher(() => this.notesService, {
|
|
896
907
|
getProjects: () => this.projects,
|
|
@@ -1142,6 +1153,7 @@ var GatewayService = class {
|
|
|
1142
1153
|
});
|
|
1143
1154
|
this.ensureAgentService();
|
|
1144
1155
|
this.agentRunner.recoverSessionInputs();
|
|
1156
|
+
this.sessionPreparations.start();
|
|
1145
1157
|
this.connectionRecovery.start();
|
|
1146
1158
|
this.channelManager.setOutboundHooks({
|
|
1147
1159
|
runMessageSending: (to, content, channel) => this.agentService.outboundCoordinator.invokeOutboundMessageSending(to, content, channel),
|
|
@@ -1396,6 +1408,7 @@ var GatewayService = class {
|
|
|
1396
1408
|
}
|
|
1397
1409
|
async stop() {
|
|
1398
1410
|
if (!this.running) return;
|
|
1411
|
+
await this.sessionPreparations.stop();
|
|
1399
1412
|
setPairingBroadcastSink(null);
|
|
1400
1413
|
this.stopRealtimeLogBridge?.();
|
|
1401
1414
|
this.stopRealtimeLogBridge = null;
|
|
@@ -54,7 +54,6 @@ var SideChatPromotionService = class {
|
|
|
54
54
|
peerId: chatId
|
|
55
55
|
},
|
|
56
56
|
customData: {
|
|
57
|
-
genericNewChatShell: false,
|
|
58
57
|
promotedFromSideChatId: sideChatId,
|
|
59
58
|
promotedFromParentTranscriptId: snapshot.context.parentTranscriptId,
|
|
60
59
|
sideChatContextHash: snapshot.context.contentHash,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
2
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
2
3
|
import { getModelCatalogStore, init_model_catalog_store } from "../providers/model-catalog-store.js";
|
|
3
4
|
import { compareCatalogModels } from "../providers/model-catalog-ranking.js";
|
|
4
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
5
5
|
import { prepareUpdateGlobalDefaults } from "./global-defaults-admin.js";
|
|
6
6
|
//#region src/gateway/xopc-cloud-capability-setup.ts
|
|
7
7
|
init_repository();
|
|
@@ -118,8 +118,15 @@ export interface HomeModelGeneration {
|
|
|
118
118
|
estimatedCostUsd?: number;
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
+
export interface HomeProviderCallBudget {
|
|
122
|
+
allowProviderCall(): boolean;
|
|
123
|
+
}
|
|
124
|
+
export declare class HomeAdviceBudgetExceededError extends Error {
|
|
125
|
+
readonly usage: HomeModelGeneration['usage'];
|
|
126
|
+
constructor(usage?: HomeModelGeneration['usage']);
|
|
127
|
+
}
|
|
121
128
|
export declare class HomeAdviceGenerator {
|
|
122
129
|
private readonly config;
|
|
123
130
|
constructor(config: () => Config);
|
|
124
|
-
generate(snapshot: HomeContextSnapshot, capabilities: HomeCapabilityInventory, signal?: AbortSignal): Promise<HomeModelGeneration>;
|
|
131
|
+
generate(snapshot: HomeContextSnapshot, capabilities: HomeCapabilityInventory, signal?: AbortSignal, budget?: HomeProviderCallBudget): Promise<HomeModelGeneration>;
|
|
125
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { init_agent_scope, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
2
|
+
import { extractAssistantText, getAssistantMessageErrorReason } from "../providers/model-response.js";
|
|
2
3
|
import { init_providers, resolveModel } from "../providers/index.js";
|
|
3
4
|
import { completeWithResolvedCredentials, isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
4
|
-
import { extractAssistantText, getAssistantMessageErrorReason } from "../providers/model-response.js";
|
|
5
5
|
import { resolveModelSelector } from "../config/agent-model-intents.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/home-intelligence/generator.ts
|
|
@@ -146,11 +146,18 @@ function addUsage(left, right) {
|
|
|
146
146
|
estimatedCostUsd: add(left.estimatedCostUsd, right.estimatedCostUsd)
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
+
var HomeAdviceBudgetExceededError = class extends Error {
|
|
150
|
+
constructor(usage = {}) {
|
|
151
|
+
super("Home intelligence provider budget exhausted");
|
|
152
|
+
this.usage = usage;
|
|
153
|
+
this.name = "HomeAdviceBudgetExceededError";
|
|
154
|
+
}
|
|
155
|
+
};
|
|
149
156
|
var HomeAdviceGenerator = class {
|
|
150
157
|
constructor(config) {
|
|
151
158
|
this.config = config;
|
|
152
159
|
}
|
|
153
|
-
async generate(snapshot, capabilities, signal) {
|
|
160
|
+
async generate(snapshot, capabilities, signal, budget) {
|
|
154
161
|
const config = this.config();
|
|
155
162
|
const modelRef = resolveModelSelector(config, resolveDefaultAgentId(), "@reasoning");
|
|
156
163
|
const model = resolveModel(modelRef);
|
|
@@ -175,6 +182,7 @@ var HomeAdviceGenerator = class {
|
|
|
175
182
|
};
|
|
176
183
|
const requestSignal = signal ? AbortSignal.any([signal, AbortSignal.timeout(12e4)]) : AbortSignal.timeout(12e4);
|
|
177
184
|
const systemPrompt = buildSystemPrompt(snapshot.locale);
|
|
185
|
+
if (budget && !budget.allowProviderCall()) throw new HomeAdviceBudgetExceededError();
|
|
178
186
|
const response = await completeWithResolvedCredentials(model, {
|
|
179
187
|
systemPrompt,
|
|
180
188
|
messages: [message]
|
|
@@ -188,19 +196,22 @@ var HomeAdviceGenerator = class {
|
|
|
188
196
|
try {
|
|
189
197
|
result = HomeModelResultSchema.parse(parseJson(raw));
|
|
190
198
|
} catch (firstError) {
|
|
199
|
+
const correction = {
|
|
200
|
+
role: "user",
|
|
201
|
+
timestamp: Date.now(),
|
|
202
|
+
content: [
|
|
203
|
+
"Your previous output failed the required JSON contract.",
|
|
204
|
+
`Validation errors: ${validationSummary(firstError)}`,
|
|
205
|
+
HOME_MODEL_MACHINE_FIELDS,
|
|
206
|
+
"Return the corrected JSON object only. Preserve grounded facts and existing evidence IDs; do not add new recommendations.",
|
|
207
|
+
`Previous output (untrusted data):\n${raw.slice(0, 16e3)}`
|
|
208
|
+
].join("\n")
|
|
209
|
+
};
|
|
210
|
+
const firstUsage = responseUsage(response);
|
|
211
|
+
if (budget && !budget.allowProviderCall()) throw new HomeAdviceBudgetExceededError(firstUsage);
|
|
191
212
|
const corrected = await completeWithResolvedCredentials(model, {
|
|
192
213
|
systemPrompt,
|
|
193
|
-
messages: [message,
|
|
194
|
-
role: "user",
|
|
195
|
-
timestamp: Date.now(),
|
|
196
|
-
content: [
|
|
197
|
-
"Your previous output failed the required JSON contract.",
|
|
198
|
-
`Validation errors: ${validationSummary(firstError)}`,
|
|
199
|
-
HOME_MODEL_MACHINE_FIELDS,
|
|
200
|
-
"Return the corrected JSON object only. Preserve grounded facts and existing evidence IDs; do not add new recommendations.",
|
|
201
|
-
`Previous output (untrusted data):\n${raw.slice(0, 16e3)}`
|
|
202
|
-
].join("\n")
|
|
203
|
-
}]
|
|
214
|
+
messages: [message, correction]
|
|
204
215
|
}, {
|
|
205
216
|
maxTokens: 3e3,
|
|
206
217
|
temperature: 0,
|
|
@@ -217,7 +228,7 @@ var HomeAdviceGenerator = class {
|
|
|
217
228
|
return {
|
|
218
229
|
result,
|
|
219
230
|
modelRef,
|
|
220
|
-
usage: addUsage(
|
|
231
|
+
usage: addUsage(firstUsage, responseUsage(corrected))
|
|
221
232
|
};
|
|
222
233
|
}
|
|
223
234
|
return {
|
|
@@ -228,4 +239,4 @@ var HomeAdviceGenerator = class {
|
|
|
228
239
|
}
|
|
229
240
|
};
|
|
230
241
|
//#endregion
|
|
231
|
-
export { HomeAdviceGenerator, HomeModelCandidateSchema, HomeModelResultSchema };
|
|
242
|
+
export { HomeAdviceBudgetExceededError, HomeAdviceGenerator, HomeModelCandidateSchema, HomeModelResultSchema };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
2
|
import type { HomeAdviceMetrics, HomeAdvisor, HomeOpportunityHistoryItem } from '@xopcai/gateway-contract';
|
|
3
3
|
import type { HomeOpportunityActionRequest, HomeOpportunityActionResponse, HomeOpportunityFeedbackRequest } from '@xopcai/gateway-contract';
|
|
4
|
-
import type
|
|
4
|
+
import { type HomeAdviceGenerator } from './generator.js';
|
|
5
5
|
import { type HomeGenerationReason, type HomePrincipal } from './repository.js';
|
|
6
6
|
import { HomeSnapshotBuilder } from './snapshot.js';
|
|
7
7
|
import type { HomeCapabilityInventory } from './types.js';
|
|
8
8
|
import { type HomeOpportunityNotification } from './notification.js';
|
|
9
9
|
import type { HomeCapabilityRequirement, HomeCapabilityResolution } from './capability-preflight.js';
|
|
10
|
+
export declare const HOME_CONTEXT_REFRESH_COOLDOWN_MS: number;
|
|
11
|
+
export declare const DAILY_HOME_PROVIDER_CALL_BUDGET = 12;
|
|
12
|
+
export declare const DAILY_HOME_TOKEN_BUDGET = 120000;
|
|
10
13
|
export interface HomeIntelligenceHostDeps {
|
|
11
14
|
principal: HomePrincipal;
|
|
12
15
|
snapshot: HomeSnapshotBuilder;
|
|
@@ -32,6 +35,8 @@ export declare class HomeIntelligenceHost {
|
|
|
32
35
|
private stopped;
|
|
33
36
|
private abortController;
|
|
34
37
|
private localeHint;
|
|
38
|
+
private contextRefreshTimer?;
|
|
39
|
+
private readonly pendingContextReasons;
|
|
35
40
|
constructor(db: DatabaseSync, deps: HomeIntelligenceHostDeps);
|
|
36
41
|
start(): void;
|
|
37
42
|
stop(): void;
|
|
@@ -39,6 +44,8 @@ export declare class HomeIntelligenceHost {
|
|
|
39
44
|
getMetrics(since?: number): HomeAdviceMetrics;
|
|
40
45
|
getHistory(): HomeOpportunityHistoryItem[];
|
|
41
46
|
requestRefresh(reason: HomeGenerationReason, idempotencyKey?: string, locale?: string): string;
|
|
47
|
+
private currentFingerprint;
|
|
48
|
+
private scheduleContextRefresh;
|
|
42
49
|
sourceChanged(input: {
|
|
43
50
|
sourceInstanceId: string;
|
|
44
51
|
revision: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
+
import { HomeAdviceBudgetExceededError } from "./generator.js";
|
|
3
4
|
import { homePatternKey } from "./strategy.js";
|
|
5
|
+
import { HomeAdvicePolicy } from "./policy.js";
|
|
4
6
|
import { HomeIntelligenceRepository } from "./repository.js";
|
|
5
7
|
import { HomeOpportunityApplicationService } from "./application-service.js";
|
|
6
|
-
import { HomeAdvicePolicy } from "./policy.js";
|
|
7
8
|
import { buildHomeOpportunityNotification } from "./notification.js";
|
|
8
9
|
import { createHash } from "node:crypto";
|
|
9
10
|
//#region src/home-intelligence/host.ts
|
|
@@ -11,7 +12,16 @@ init_logger();
|
|
|
11
12
|
const log = createLogger("HomeIntelligence");
|
|
12
13
|
const POLL_INTERVAL_MS = 5e3;
|
|
13
14
|
const GENERATION_LEASE_MS = 5 * 6e4;
|
|
14
|
-
const
|
|
15
|
+
const HOME_CONTEXT_REFRESH_COOLDOWN_MS = 30 * 6e4;
|
|
16
|
+
const DAILY_HOME_PROVIDER_CALL_BUDGET = 12;
|
|
17
|
+
const DAILY_HOME_TOKEN_BUDGET = 12e4;
|
|
18
|
+
const HOME_USAGE_OPERATION = "home.generate_advice";
|
|
19
|
+
const CONTEXT_REFRESH_REASONS = new Set([
|
|
20
|
+
"project_changed",
|
|
21
|
+
"task_changed",
|
|
22
|
+
"connector_changed",
|
|
23
|
+
"conversation_changed"
|
|
24
|
+
]);
|
|
15
25
|
function generationFingerprint(snapshotHash, capabilities) {
|
|
16
26
|
return createHash("sha256").update(JSON.stringify({
|
|
17
27
|
snapshotHash,
|
|
@@ -29,6 +39,8 @@ var HomeIntelligenceHost = class {
|
|
|
29
39
|
stopped = false;
|
|
30
40
|
abortController = new AbortController();
|
|
31
41
|
localeHint;
|
|
42
|
+
contextRefreshTimer;
|
|
43
|
+
pendingContextReasons = /* @__PURE__ */ new Set();
|
|
32
44
|
constructor(db, deps) {
|
|
33
45
|
this.deps = deps;
|
|
34
46
|
this.repository = new HomeIntelligenceRepository(db);
|
|
@@ -49,6 +61,9 @@ var HomeIntelligenceHost = class {
|
|
|
49
61
|
this.abortController = new AbortController();
|
|
50
62
|
if (this.timer) clearInterval(this.timer);
|
|
51
63
|
this.timer = void 0;
|
|
64
|
+
if (this.contextRefreshTimer) clearTimeout(this.contextRefreshTimer);
|
|
65
|
+
this.contextRefreshTimer = void 0;
|
|
66
|
+
this.pendingContextReasons.clear();
|
|
52
67
|
}
|
|
53
68
|
getAdvisor() {
|
|
54
69
|
if (this.deps.enabled?.() === false) return { state: "disabled" };
|
|
@@ -65,6 +80,16 @@ var HomeIntelligenceHost = class {
|
|
|
65
80
|
if (this.deps.enabled?.() === false) return "disabled";
|
|
66
81
|
const now = this.now();
|
|
67
82
|
if (locale) this.localeHint = locale.toLowerCase().startsWith("zh") ? "zh" : "en";
|
|
83
|
+
if (CONTEXT_REFRESH_REASONS.has(reason)) {
|
|
84
|
+
const fingerprint = this.currentFingerprint(now);
|
|
85
|
+
if (this.repository.getLatestSnapshotHash(this.deps.principal) === fingerprint) return "unchanged";
|
|
86
|
+
const lastRequestedAt = this.repository.getLatestContextRefreshRequestedAt(this.deps.principal);
|
|
87
|
+
if (lastRequestedAt !== void 0 && now < lastRequestedAt + 18e5) {
|
|
88
|
+
this.pendingContextReasons.add(reason);
|
|
89
|
+
this.scheduleContextRefresh(lastRequestedAt + HOME_CONTEXT_REFRESH_COOLDOWN_MS - now);
|
|
90
|
+
return "cooldown";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
68
93
|
const bucket = Math.floor(now / (reason === "manual_refresh" ? 1 : 5 * 6e4));
|
|
69
94
|
const request = this.repository.enqueue(this.deps.principal, {
|
|
70
95
|
idempotencyKey: idempotencyKey ?? `${reason}:${bucket}`,
|
|
@@ -74,6 +99,32 @@ var HomeIntelligenceHost = class {
|
|
|
74
99
|
this.tick();
|
|
75
100
|
return request.generationId;
|
|
76
101
|
}
|
|
102
|
+
currentFingerprint(now) {
|
|
103
|
+
const successfulPatterns = this.repository.getSuccessfulPatterns(this.deps.principal);
|
|
104
|
+
return generationFingerprint(this.deps.snapshot.build({
|
|
105
|
+
now,
|
|
106
|
+
locale: this.localeHint,
|
|
107
|
+
successfulPatterns
|
|
108
|
+
}).hash, this.deps.capabilities());
|
|
109
|
+
}
|
|
110
|
+
scheduleContextRefresh(delayMs) {
|
|
111
|
+
if (this.contextRefreshTimer) return;
|
|
112
|
+
this.contextRefreshTimer = setTimeout(() => {
|
|
113
|
+
this.contextRefreshTimer = void 0;
|
|
114
|
+
if (this.stopped || this.pendingContextReasons.size === 0) return;
|
|
115
|
+
const reasons = [...this.pendingContextReasons];
|
|
116
|
+
this.pendingContextReasons.clear();
|
|
117
|
+
const now = this.now();
|
|
118
|
+
if (this.repository.getLatestSnapshotHash(this.deps.principal) === this.currentFingerprint(now)) return;
|
|
119
|
+
this.repository.enqueue(this.deps.principal, {
|
|
120
|
+
idempotencyKey: `context_refresh:${Math.floor(now / HOME_CONTEXT_REFRESH_COOLDOWN_MS)}`,
|
|
121
|
+
reasons,
|
|
122
|
+
requestedAt: now
|
|
123
|
+
});
|
|
124
|
+
this.tick();
|
|
125
|
+
}, Math.max(1, delayMs));
|
|
126
|
+
this.contextRefreshTimer.unref?.();
|
|
127
|
+
}
|
|
77
128
|
sourceChanged(input) {
|
|
78
129
|
const now = this.now();
|
|
79
130
|
const invalidated = this.repository.invalidateOpportunitiesByEvidenceSources(this.deps.principal, new Set([
|
|
@@ -174,16 +225,18 @@ var HomeIntelligenceHost = class {
|
|
|
174
225
|
let generation;
|
|
175
226
|
const startOfDay = new Date(startedAt);
|
|
176
227
|
startOfDay.setHours(0, 0, 0, 0);
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
228
|
+
const providerBudgetAvailable = () => {
|
|
229
|
+
const usage = this.repository.getProviderUsageSince(startOfDay.getTime(), HOME_USAGE_OPERATION);
|
|
230
|
+
return usage.calls < 12 && usage.totalTokens < 12e4;
|
|
231
|
+
};
|
|
232
|
+
const result = !providerBudgetAvailable() ? {
|
|
180
233
|
state: "quiet",
|
|
181
234
|
reason: "budget_exhausted"
|
|
182
|
-
} : previousHash === currentFingerprint && !
|
|
235
|
+
} : previousHash === currentFingerprint && !claim.reasons.includes("manual_refresh") ? {
|
|
183
236
|
state: "quiet",
|
|
184
237
|
reason: "no_change"
|
|
185
238
|
} : await (async () => {
|
|
186
|
-
generation = await this.deps.generator.generate(snapshot, capabilities, this.abortController.signal);
|
|
239
|
+
generation = await this.deps.generator.generate(snapshot, capabilities, this.abortController.signal, { allowProviderCall: providerBudgetAvailable });
|
|
187
240
|
return new HomeAdvicePolicy((requirements, options) => this.resolveCapabilityRequirements(requirements, Boolean(options?.degradedActionAvailable)), this.repository.listSuppressionKeys(this.deps.principal), new Map(successfulPatterns.map((item) => [homePatternKey(item.projectId, item.outcome), item.successCount])), this.repository.getPersonalization(this.deps.principal, this.now())).apply(snapshot, generation.result, this.now());
|
|
188
241
|
})();
|
|
189
242
|
const completedAt = this.now();
|
|
@@ -212,6 +265,27 @@ var HomeIntelligenceHost = class {
|
|
|
212
265
|
this.repository.fail(claim, this.now(), "cancelled", this.now());
|
|
213
266
|
return;
|
|
214
267
|
}
|
|
268
|
+
if (error instanceof HomeAdviceBudgetExceededError) {
|
|
269
|
+
const completedAt = this.now();
|
|
270
|
+
this.repository.complete(claim, {
|
|
271
|
+
result: {
|
|
272
|
+
state: "quiet",
|
|
273
|
+
reason: "budget_exhausted"
|
|
274
|
+
},
|
|
275
|
+
snapshotHash: currentFingerprint ?? this.repository.getLatestSnapshotHash(this.deps.principal) ?? "budget-exhausted",
|
|
276
|
+
evidenceIds: [],
|
|
277
|
+
inputTokens: error.usage.inputTokens,
|
|
278
|
+
outputTokens: error.usage.outputTokens,
|
|
279
|
+
estimatedCostUsd: error.usage.estimatedCostUsd,
|
|
280
|
+
outcomeReason: "budget_exhausted",
|
|
281
|
+
completedAt
|
|
282
|
+
});
|
|
283
|
+
this.deps.publish("home.advisor.updated", {
|
|
284
|
+
state: "quiet",
|
|
285
|
+
reason: "budget_exhausted"
|
|
286
|
+
});
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
215
289
|
const message = error instanceof Error ? error.message : String(error);
|
|
216
290
|
if (/no api key|no default model|credentials|unknown model|local model/i.test(message)) {
|
|
217
291
|
const completedAt = this.now();
|
|
@@ -246,4 +320,4 @@ var HomeIntelligenceHost = class {
|
|
|
246
320
|
}
|
|
247
321
|
};
|
|
248
322
|
//#endregion
|
|
249
|
-
export { HomeIntelligenceHost };
|
|
323
|
+
export { DAILY_HOME_PROVIDER_CALL_BUDGET, DAILY_HOME_TOKEN_BUDGET, HOME_CONTEXT_REFRESH_COOLDOWN_MS, HomeIntelligenceHost };
|
|
@@ -58,7 +58,11 @@ export declare class HomeIntelligenceRepository {
|
|
|
58
58
|
};
|
|
59
59
|
fail(claim: HomeGenerationClaim, now: number, errorCode: string, retryAt?: number): void;
|
|
60
60
|
getLatestSnapshotHash(principal: HomePrincipal): string | undefined;
|
|
61
|
-
|
|
61
|
+
getLatestContextRefreshRequestedAt(principal: HomePrincipal): number | undefined;
|
|
62
|
+
getProviderUsageSince(startedAt: number, operation: string): {
|
|
63
|
+
calls: number;
|
|
64
|
+
totalTokens: number;
|
|
65
|
+
};
|
|
62
66
|
listSuppressionKeys(principal: HomePrincipal): Set<string>;
|
|
63
67
|
getSuccessfulPatterns(principal: HomePrincipal): HomeSuccessfulPattern[];
|
|
64
68
|
getPersonalization(principal: HomePrincipal, now: number): HomeAdvicePersonalization;
|
|
@@ -151,16 +151,23 @@ var HomeIntelligenceRepository = class {
|
|
|
151
151
|
OR outcome_reason NOT IN ('no_change', 'budget_exhausted'))
|
|
152
152
|
ORDER BY completed_at DESC, rowid DESC LIMIT 1`).get(principal.ownerId, principal.workspaceId)?.snapshot_hash ?? void 0;
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
const row = this.db.prepare(`SELECT
|
|
156
|
-
WHEN generation_id = ? THEN MAX(attempt - 1, 0)
|
|
157
|
-
WHEN model_ref IS NOT NULL THEN 1
|
|
158
|
-
WHEN status IN ('failed', 'retry_wait') THEN attempt
|
|
159
|
-
ELSE 0
|
|
160
|
-
END), 0) AS count
|
|
154
|
+
getLatestContextRefreshRequestedAt(principal) {
|
|
155
|
+
const row = this.db.prepare(`SELECT MAX(requested_at) AS requested_at
|
|
161
156
|
FROM home_advice_generations
|
|
162
|
-
WHERE owner_id = ? AND workspace_id = ?
|
|
163
|
-
|
|
157
|
+
WHERE owner_id = ? AND workspace_id = ?
|
|
158
|
+
AND EXISTS (
|
|
159
|
+
SELECT 1 FROM json_each(reasons_json)
|
|
160
|
+
WHERE value IN ('project_changed', 'task_changed', 'connector_changed', 'conversation_changed')
|
|
161
|
+
)`).get(principal.ownerId, principal.workspaceId);
|
|
162
|
+
return row.requested_at === null ? void 0 : Number(row.requested_at);
|
|
163
|
+
}
|
|
164
|
+
getProviderUsageSince(startedAt, operation) {
|
|
165
|
+
const row = this.db.prepare(`SELECT COUNT(*) AS calls, COALESCE(SUM(total_tokens), 0) AS total_tokens
|
|
166
|
+
FROM ai_usage_events WHERE operation = ? AND started_at >= ?`).get(operation, startedAt);
|
|
167
|
+
return {
|
|
168
|
+
calls: Number(row.calls),
|
|
169
|
+
totalTokens: Number(row.total_tokens)
|
|
170
|
+
};
|
|
164
171
|
}
|
|
165
172
|
listSuppressionKeys(principal) {
|
|
166
173
|
const rows = this.db.prepare(`SELECT f.scope_json, p.kind, p.project_id
|
|
@@ -110,10 +110,10 @@ var HomeSnapshotBuilder = class {
|
|
|
110
110
|
const successfulPatterns = [...input.successfulPatterns ?? []].filter((item) => item.successCount > 0).sort((left, right) => right.successCount - left.successCount || left.outcome.localeCompare(right.outcome)).slice(0, 20);
|
|
111
111
|
const stableContent = {
|
|
112
112
|
locale: input.locale,
|
|
113
|
-
projects,
|
|
114
|
-
tasks,
|
|
115
|
-
knowledge,
|
|
116
|
-
recentSessions,
|
|
113
|
+
projects: projects.map(({ updatedAt: _updatedAt, ...project }) => project),
|
|
114
|
+
tasks: tasks.map(({ updatedAt: _updatedAt, ...task }) => task),
|
|
115
|
+
knowledge: knowledge.map(({ updatedAt: _updatedAt, ...item }) => item),
|
|
116
|
+
recentSessions: recentSessions.map(({ updatedAt: _updatedAt, ...session }) => session),
|
|
117
117
|
successfulPatterns
|
|
118
118
|
};
|
|
119
119
|
return {
|