@xopcai/xopc 0.0.302 → 0.0.306
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/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/browser-ext/dist/assets/{auth-B_9ZuGDx.js → auth-C3yV1y_l.js} +67 -22
- package/dist/browser-ext/dist/background.js +4 -4
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +3 -3
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/xopc.extension.json +0 -3
- package/dist/extensions/telegram/xopc.extension.json +1 -4
- package/dist/extensions/weixin/xopc.extension.json +0 -3
- package/dist/gateway/static/root/assets/{activity-store-DCi5rh4e.js → activity-store-DLtim-_I.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C0zP6W2B.js → agent-avatar-dicebear-iQXtiilH.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CxOv4ivK.js +1 -0
- package/dist/gateway/static/root/assets/agents-DzKx7z3k.js +1 -0
- package/dist/gateway/static/root/assets/{api-CAV9PN9i.js → api-DfSU0-lD.js} +1 -1
- package/dist/gateway/static/root/assets/api-gpHh07OL.js +1 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-BpYFKz7B.js +1 -0
- package/dist/gateway/static/root/assets/{appearance-settings-ZFjV_opr.js → appearance-settings-BQfR5vrq.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BceB7JHZ.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-MaKWrpgC.js → archive-plugin-BxOvZ-ZX.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-IfqbP2BN.js → attachment-load-B0FzTMAJ.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CeI2NGSO.js → automations-page-BpXuPaPg.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Cn_p8zY_.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-jvQ6FaBZ.js → binary-plugins-BP7wfpqy.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D4ZIVQbk.css → block-editor-BdOTO0Yo.css} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B7U3qlB3.js → block-editor-oMLvdnOQ.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BGT0xoTv.js → browser-automation-inputs-DTxSZ00u.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-DvLAwoiQ.js → browser-automations-page-IbJnwEY4.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-CCUO3G23.js +3 -0
- package/dist/gateway/static/root/assets/button-CS04eWY9.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BjMb5H2_.js +8 -0
- package/dist/gateway/static/root/assets/channels-settings-P22-_i13.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-C_icwbWj.js → channels-status-swr-D2AmAoty.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BtL71IOs.js → chat-terminal-dock-B-yI3Mi1.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-Bu6ZJtmS.js → computer-settings-page-CWx_jnng.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BLgPORmH.js +2 -0
- package/dist/gateway/static/root/assets/cron-expression-DMRRL4Zg.js +2 -0
- package/dist/gateway/static/root/assets/date-picker-BSwL0e6E.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-BNugauiZ.js → dependency-picker-BQTspLzC.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DTy_3-OY.js → desktop-pet-C3lFxDF6.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-Y8pjpXFE.js +1 -0
- package/dist/gateway/static/root/assets/device-pairing-wizard-DM4_GMzo.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-C3F7RiGW.js → extension-debug-page-CVGiGVcR.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C0jhcCT_.js → extension-page-g3JtCP_y.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CNvJQkrr.js → extension-settings-page-CjpoKV1f.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-D5AM8cyQ.js → gateway-config-swr-BSvXXpKM.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-BDCpS7U1.js +1 -0
- package/dist/gateway/static/root/assets/gateway-realtime-store-BGmP1obI.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-CYG9WCZn.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CSJWdnFs.js → gateway-startup-retry-Caf8g3sC.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-Cd1VJsHe.js → heartbeat-settings-Cl834-SS.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-CB_XVtIM.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-BNh604hw.js → image-generation-api-BwEWBUVC.js} +1 -1
- package/dist/gateway/static/root/assets/imports-page-CoMlgSIA.js +1 -0
- package/dist/gateway/static/root/assets/index-CI37dTAn.css +1 -0
- package/dist/gateway/static/root/assets/index-Do9MltC4.js +79 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CNq5D4pe.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-BxQlEje6.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DyrFxW3G.js → local-apps-page-DQnRA598.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DLK05Y1a.js → locale-store-D16nmbaN.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CT5GrcMs.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-DKcO5fQ-.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-B8maDRWh.js → markdown-view-DCp4BlZP.js} +2 -2
- package/dist/gateway/static/root/assets/{media-plugins-5DakFba_.js → media-plugins-Cy64sn_C.js} +1 -1
- package/dist/gateway/static/root/assets/messages-C-9oo69N.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-5dc3LKTL.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-AbwxgXuG.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-DzJpglJJ.js → page-tabs-CgEoHSVT.js} +1 -1
- package/dist/gateway/static/root/assets/{popover-select-DldSX8GX.js → popover-select-9i-ZtHXL.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Dj6LJsuQ.js → preview-open-alternatives-Ck2uKTbf.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-CwudBdrQ.js → proactive-page-Dr1mCJhZ.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CujZXOea.js → product-open-page-DbZvJ5GE.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DnE1zI1c.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BD0nLYxk.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BMFL4vis.js → registry-api-DcQdwpPu.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-TYuE6A3S.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DV554qyN.js → runtime-tools-settings-panel-CPwdgWKo.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-Bh2Er67B.js → schema-form-8psK4cFO.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BcWDQQFX.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DzGQX6Hq.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BsdM7P1d.js → settings-form-section-D_Gsz5rl.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-3yEAqoME.js → settings-page-C_Tj_mkZ.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CE2X89qN.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-B_M_oPsT.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-BL4H9Iym.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-WMKIgUOp.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DYgwzl5B.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-dHBD7YqU.js → skills-page.utils-Cuh6s2HM.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-lItR5Kah.js → system-settings-panel-aassGyNb.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-BjeRslap.js +1 -0
- package/dist/gateway/static/root/assets/theme-store-RUBQBsFP.js +1 -0
- package/dist/gateway/static/root/assets/tunnel-api-DJYcPWIV.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-DO50_g_S.js → use-autosave-QGYG7oMZ.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-PrRsd4go.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-k7tWLXzM.js → voice-api-key-field-D1s0gIRW.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-bZqN8-UF.js → voice-config-api-D2goEn5e.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BHI6gO_u.js → work-discovery-overlay-DkFW9aJ6.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BYToUPUY.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-Z8iZe9YP.js +6 -0
- package/dist/gateway/static/root/index.html +14 -12
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/device-pairing.js +100 -7
- package/dist/packages/gateway-contract/src/gateway-scopes.js +53 -0
- package/dist/packages/gateway-contract/src/index.js +2 -0
- package/dist/packages/realtime-client/src/index.js +14 -2
- package/dist/packages/realtime-protocol/src/index.js +18 -14
- package/dist/src/agent/agent-instance-gateway.d.ts +2 -0
- package/dist/src/agent/agent-manager.d.ts +2 -0
- package/dist/src/agent/agent-manager.js +40 -12
- package/dist/src/agent/agent-scope.d.ts +4 -1
- package/dist/src/agent/agent-scope.js +19 -3
- package/dist/src/agent/commands/command-isolation.js +11 -9
- package/dist/src/agent/commands/command-registry.js +18 -33
- package/dist/src/agent/context/audit.js +12 -2
- package/dist/src/agent/context/coordinator.d.ts +13 -3
- package/dist/src/agent/context/coordinator.js +27 -11
- package/dist/src/agent/context/execution-context.js +42 -22
- package/dist/src/agent/context/execution-context.types.d.ts +4 -2
- package/dist/src/agent/context/execution-scope.d.ts +2 -2
- package/dist/src/agent/context/execution-scope.js +1 -1
- package/dist/src/agent/context/project-context.d.ts +2 -2
- package/dist/src/agent/context/project-context.js +3 -3
- package/dist/src/agent/embedded/run-for-session.d.ts +1 -0
- package/dist/src/agent/embedded/run-for-session.js +7 -1
- package/dist/src/agent/inbound/attachment-pipeline.d.ts +2 -0
- package/dist/src/agent/inbound/attachment-pipeline.js +3 -3
- package/dist/src/agent/inbound/inbound-loop.js +1 -0
- package/dist/src/agent/inbound/turn-dispatcher.js +3 -3
- package/dist/src/agent/mcp/mcp-stdio-transport.js +5 -2
- package/dist/src/agent/memory/compaction-promotion.js +7 -2
- package/dist/src/agent/memory/create-memory-manager.js +1 -0
- package/dist/src/agent/memory/manager.d.ts +6 -0
- package/dist/src/agent/memory/manager.js +74 -39
- package/dist/src/agent/memory/runtime.d.ts +3 -3
- package/dist/src/agent/memory/runtime.js +11 -4
- package/dist/src/agent/orchestration/agent-orchestrator.js +4 -1
- package/dist/src/agent/prompt/cache-boundary.d.ts +2 -0
- package/dist/src/agent/prompt/cache-boundary.js +10 -1
- package/dist/src/agent/service/build-direct-message-content.d.ts +1 -0
- package/dist/src/agent/service/build-direct-message-content.js +2 -1
- package/dist/src/agent/service/direct-turn-helpers.js +3 -2
- package/dist/src/agent/service/process-direct-streaming.d.ts +3 -1
- package/dist/src/agent/service/process-direct-streaming.js +3 -2
- package/dist/src/agent/service/webchat-tts.d.ts +0 -4
- package/dist/src/agent/service/webchat-tts.js +20 -19
- package/dist/src/agent/tools/factory.js +3 -3
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +2 -2
- package/dist/src/agent/tools/knowledge-memory-tool.js +7 -7
- package/dist/src/browser/native-messaging-host.js +2 -2
- package/dist/src/channels/attachments/voice-stt-webchat.d.ts +3 -0
- package/dist/src/channels/attachments/voice-stt-webchat.js +22 -9
- package/dist/src/cli/commands/agent.js +2 -0
- package/dist/src/cli/commands/config.js +8 -9
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +69 -44
- package/dist/src/cli/commands/extension-pack.js +0 -2
- package/dist/src/cli/commands/extension.js +4 -25
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/onboard/gateway.js +2 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +5 -2
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/loader.d.ts +1 -0
- package/dist/src/config/loader.js +14 -1
- package/dist/src/config/schema.d.ts +10 -3
- package/dist/src/config/schema.js +10 -2
- package/dist/src/execution-environments/local-worktree-manager.js +17 -15
- package/dist/src/execution-environments/store.js +4 -2
- package/dist/src/execution-environments/types.d.ts +3 -0
- package/dist/src/execution-environments/types.js +2 -1
- package/dist/src/execution-environments/worktree-safety.d.ts +8 -0
- package/dist/src/execution-environments/worktree-safety.js +43 -0
- package/dist/src/extensions/activation-planner.d.ts +1 -1
- package/dist/src/extensions/activation-planner.js +1 -1
- package/dist/src/extensions/api-version.d.ts +4 -0
- package/dist/src/extensions/api-version.js +15 -0
- package/dist/src/extensions/api.d.ts +3 -9
- package/dist/src/extensions/api.js +26 -32
- package/dist/src/extensions/config-validation.d.ts +8 -0
- package/dist/src/extensions/config-validation.js +25 -0
- package/dist/src/extensions/extension-registry-impl.d.ts +20 -9
- package/dist/src/extensions/extension-registry-impl.js +79 -11
- package/dist/src/extensions/hooks.d.ts +1 -1
- package/dist/src/extensions/index.d.ts +2 -1
- package/dist/src/extensions/install-transaction.d.ts +2 -0
- package/dist/src/extensions/install-transaction.js +32 -21
- package/dist/src/extensions/install.js +18 -1
- package/dist/src/extensions/loader.d.ts +5 -5
- package/dist/src/extensions/loader.js +109 -47
- package/dist/src/extensions/lockfile.d.ts +3 -5
- package/dist/src/extensions/lockfile.js +41 -14
- package/dist/src/extensions/normalize-manifest.js +6 -60
- package/dist/src/extensions/sdk/index.d.ts +3 -2
- package/dist/src/extensions/sdk/index.js +2 -2
- package/dist/src/extensions/sdk/testing.js +0 -4
- package/dist/src/extensions/security.js +5 -7
- package/dist/src/extensions/types/core.d.ts +0 -5
- package/dist/src/extensions/types/index.d.ts +1 -1
- package/dist/src/extensions/types/manifest.d.ts +1 -25
- package/dist/src/extensions/types/providers.d.ts +1 -1
- package/dist/src/extensions/types/registration.d.ts +0 -12
- package/dist/src/extensions/update.js +71 -30
- package/dist/src/gateway/heartbeat/service.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +47 -10
- package/dist/src/gateway/hono/routes/devices.js +10 -7
- package/dist/src/gateway/hono/routes/endpoint-compatibility.js +6 -0
- package/dist/src/gateway/hono/routes/extension-gateway.js +0 -33
- package/dist/src/gateway/hono/routes/imports.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +0 -1
- package/dist/src/gateway/hono/routes/local-apps.js +1 -1
- package/dist/src/gateway/hono/routes/realtime.js +30 -8
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/hono/routes/user-model.js +25 -6
- package/dist/src/gateway/index.js +5 -2
- package/dist/src/gateway/lock.d.ts +2 -0
- package/dist/src/gateway/lock.js +31 -14
- package/dist/src/gateway/run-loop.js +3 -2
- package/dist/src/gateway/security/gateway-scopes.d.ts +2 -5
- package/dist/src/gateway/security/gateway-scopes.js +3 -45
- package/dist/src/gateway/security/index.js +2 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.js +11 -7
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/imports/importService.d.ts +1 -1
- package/dist/src/imports/inventory.js +16 -2
- package/dist/src/imports/productImport.js +5 -5
- package/dist/src/imports/types.d.ts +3 -3
- package/dist/src/infra/exec.d.ts +2 -2
- package/dist/src/infra/exec.js +32 -27
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/run-command.js +15 -50
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/knowledge/connected-knowledge-pipeline.js +13 -3
- package/dist/src/knowledge-memory/domain.d.ts +17 -1
- package/dist/src/knowledge-memory/index.js +2 -2
- package/dist/src/knowledge-memory/repository.d.ts +26 -4
- package/dist/src/knowledge-memory/repository.js +171 -36
- package/dist/src/mcp/channel-bridge.js +7 -3
- package/dist/src/media-understanding/registry.js +6 -1
- package/dist/src/migrations/knowledge-memory-read-policy-config.d.ts +2 -0
- package/dist/src/migrations/knowledge-memory-read-policy-config.js +48 -0
- package/dist/src/migrations/runner.js +2 -1
- package/dist/src/process/bounded-output.d.ts +10 -0
- package/dist/src/process/bounded-output.js +41 -0
- package/dist/src/process/kill-tree.d.ts +6 -17
- package/dist/src/process/kill-tree.js +43 -75
- package/dist/src/process/process-spec.d.ts +39 -0
- package/dist/src/process/process-spec.js +13 -0
- package/dist/src/process/run-process.d.ts +4 -0
- package/dist/src/process/run-process.js +97 -0
- package/dist/src/providers/plugin-registry.d.ts +1 -1
- package/dist/src/providers/plugin-registry.js +6 -0
- package/dist/src/realtime/runtime.js +3 -1
- package/dist/src/session/store.js +1 -1
- package/dist/src/storage/sqlite/device-pairing-approval.js +1 -1
- package/dist/src/storage/sqlite/index.d.ts +1 -1
- package/dist/src/storage/sqlite/index.js +2 -2
- package/dist/src/storage/sqlite/migrations/180_execution_environment_ownership.sql +7 -0
- package/dist/src/storage/sqlite/migrations/181_knowledge_item_status_events.sql +12 -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/schema.sql +13 -0
- package/dist/src/storage/sqlite/transcript-repository.d.ts +4 -0
- package/dist/src/storage/sqlite/transcript-repository.js +36 -1
- package/dist/src/tui/backends/embedded-backend.d.ts +24 -8
- package/dist/src/tui/backends/embedded-backend.js +114 -10
- package/dist/src/tui/backends/gateway-realtime-backend.d.ts +18 -0
- package/dist/src/tui/backends/gateway-realtime-backend.js +32 -5
- package/dist/src/tui/components/assistant-message.d.ts +4 -1
- package/dist/src/tui/components/assistant-message.js +10 -2
- package/dist/src/tui/components/cell-render-mode.d.ts +4 -0
- package/dist/src/tui/components/cell-render-mode.js +1 -0
- package/dist/src/tui/components/chat-log.d.ts +17 -4
- package/dist/src/tui/components/chat-log.js +68 -50
- package/dist/src/tui/components/custom-editor.d.ts +2 -2
- package/dist/src/tui/components/custom-editor.js +5 -1
- package/dist/src/tui/components/pending-input-preview.d.ts +9 -0
- package/dist/src/tui/components/pending-input-preview.js +33 -0
- package/dist/src/tui/components/semantic-cell.d.ts +17 -0
- package/dist/src/tui/components/semantic-cell.js +29 -0
- package/dist/src/tui/components/tool-execution.d.ts +5 -1
- package/dist/src/tui/components/tool-execution.js +33 -10
- package/dist/src/tui/components/transcript-overlay.d.ts +29 -0
- package/dist/src/tui/components/transcript-overlay.js +114 -0
- package/dist/src/tui/components/tui-bottom-bar.js +3 -1
- package/dist/src/tui/components/user-message.d.ts +5 -1
- package/dist/src/tui/components/user-message.js +12 -1
- package/dist/src/tui/extension-host/load-extensions.d.ts +1 -1
- package/dist/src/tui/extension-host/runtime-context.js +2 -1
- package/dist/src/tui/extension-host/runtime.d.ts +1 -1
- package/dist/src/tui/format-tui-hotkeys.js +8 -1
- package/dist/src/tui/tui-agent-events.js +31 -0
- package/dist/src/tui/tui-backend.d.ts +23 -11
- package/dist/src/tui/tui-backend.js +1 -9
- package/dist/src/tui/tui-chat-input-state.d.ts +25 -0
- package/dist/src/tui/tui-chat-input-state.js +36 -0
- package/dist/src/tui/tui-command-formatters.js +2 -1
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-types.d.ts +2 -1
- package/dist/src/tui/tui-types.js +2 -1
- package/dist/src/tui/tui.js +122 -30
- package/dist/src/tui/xopc-tui-keybindings.d.ts +23 -3
- package/dist/src/tui/xopc-tui-keybindings.js +22 -2
- package/dist/src/user-context/access-policy.d.ts +2 -2
- package/dist/src/user-context/access-policy.js +10 -2
- package/dist/src/user-context/config.d.ts +23 -6
- package/dist/src/user-context/config.js +54 -7
- package/dist/src/voice/platform-streams.js +11 -1
- package/dist/src/voice/realtime/omniEngine.js +13 -1
- package/dist/src/voice/realtime/runtime.js +2 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/speech-registry.js +6 -1
- package/package.json +9 -7
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D0ITeUFb.js +0 -1
- package/dist/gateway/static/root/assets/agents-DcfWhk2S.js +0 -1
- package/dist/gateway/static/root/assets/api-fPapljyb.js +0 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-U3yDRzKF.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-FgMHY1Pr.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-DxaiBwrD.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CHrfg3BX.js +0 -3
- package/dist/gateway/static/root/assets/button-CGlRPNzi.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DpYDPk_o.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-DMq-NBUQ.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-LsEiI9L5.js +0 -2
- package/dist/gateway/static/root/assets/cron-expression-B25FHn4w.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-CzVHO7z9.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-CXfnejTb.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-CxKwfncn.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CQTcIvlZ.js +0 -1
- package/dist/gateway/static/root/assets/home-page-B_uyfCGq.js +0 -1
- package/dist/gateway/static/root/assets/imports-page-DXNfRmk9.js +0 -1
- package/dist/gateway/static/root/assets/index-BAqVpc1H.css +0 -1
- package/dist/gateway/static/root/assets/index-hlU8MUEz.js +0 -79
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CgW5_XVP.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-C4h3qDRL.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-Goy_QHfL.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-DgQyGEpR.js +0 -1
- package/dist/gateway/static/root/assets/messages-C9h8SImu.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-lcZby9NY.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-CDGPPI-W.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-CyAf_sK-.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BW5m_HhZ.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-B4JgwB0s.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-D5SmvlQ1.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DDALROy_.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BOHNZ-S3.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-wV056nz2.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-io4NzfJL.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CERFaxLj.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CtwUqvsE.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-CCKc67a-.js +0 -1
- package/dist/gateway/static/root/assets/theme-store-KfFEGMlp.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-DPyLgmWw.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-CcnGgH1n.js +0 -2
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-jEMtNIG8.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-CX4bcAD-.js +0 -6
- package/dist/src/extensions/when-context.d.ts +0 -6
- package/dist/src/extensions/when-context.js +0 -26
- package/dist/src/extensions/when-expression.d.ts +0 -11
- package/dist/src/extensions/when-expression.js +0 -213
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createBoundedOutput } from "./bounded-output.js";
|
|
2
|
+
import { terminateProcess } from "./kill-tree.js";
|
|
3
|
+
import { ProcessExitError } from "./process-spec.js";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
//#region src/process/run-process.ts
|
|
6
|
+
const DEFAULT_MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
7
|
+
function spawnProcess(spec) {
|
|
8
|
+
spec.signal?.throwIfAborted();
|
|
9
|
+
const detached = spec.detached ?? (spec.terminationPolicy === "tree" && process.platform !== "win32");
|
|
10
|
+
const child = spawn(spec.program, [...spec.args ?? []], {
|
|
11
|
+
cwd: spec.cwd,
|
|
12
|
+
env: spec.env ?? process.env,
|
|
13
|
+
stdio: [
|
|
14
|
+
"pipe",
|
|
15
|
+
"pipe",
|
|
16
|
+
"pipe"
|
|
17
|
+
],
|
|
18
|
+
detached,
|
|
19
|
+
windowsHide: spec.windowsHide ?? true,
|
|
20
|
+
shell: spec.shell ?? false
|
|
21
|
+
});
|
|
22
|
+
const stdout = createBoundedOutput(spec.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES);
|
|
23
|
+
const stderr = createBoundedOutput(spec.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES);
|
|
24
|
+
let timedOut = false;
|
|
25
|
+
let aborted = false;
|
|
26
|
+
let terminationRequested = false;
|
|
27
|
+
let settled = false;
|
|
28
|
+
let timer;
|
|
29
|
+
const terminate = (reason = "cancelled") => {
|
|
30
|
+
if (settled || terminationRequested) return;
|
|
31
|
+
terminationRequested = true;
|
|
32
|
+
timedOut = reason === "timed_out";
|
|
33
|
+
aborted = reason === "cancelled";
|
|
34
|
+
terminateProcess(child, {
|
|
35
|
+
tree: spec.terminationPolicy === "tree",
|
|
36
|
+
detached
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const abort = () => terminate("cancelled");
|
|
40
|
+
spec.signal?.addEventListener("abort", abort, { once: true });
|
|
41
|
+
if (spec.signal?.aborted) abort();
|
|
42
|
+
if (spec.timeoutMs != null && spec.timeoutMs > 0) {
|
|
43
|
+
timer = setTimeout(() => terminate("timed_out"), spec.timeoutMs);
|
|
44
|
+
timer.unref();
|
|
45
|
+
}
|
|
46
|
+
child.stdout?.on("data", (chunk) => {
|
|
47
|
+
stdout.append(chunk);
|
|
48
|
+
spec.onOutput?.("stdout", chunk);
|
|
49
|
+
});
|
|
50
|
+
child.stderr?.on("data", (chunk) => {
|
|
51
|
+
stderr.append(chunk);
|
|
52
|
+
spec.onOutput?.("stderr", chunk);
|
|
53
|
+
});
|
|
54
|
+
child.stdin?.on("error", (error) => stderr.append(error.message));
|
|
55
|
+
if (spec.input !== void 0) child.stdin?.end(spec.input);
|
|
56
|
+
else if (!spec.keepStdinOpen) child.stdin?.end();
|
|
57
|
+
return {
|
|
58
|
+
child,
|
|
59
|
+
completion: new Promise((resolve) => {
|
|
60
|
+
let spawnError;
|
|
61
|
+
child.once("error", (error) => {
|
|
62
|
+
spawnError = error;
|
|
63
|
+
});
|
|
64
|
+
child.once("close", (exitCode, signal) => {
|
|
65
|
+
if (settled) return;
|
|
66
|
+
settled = true;
|
|
67
|
+
if (timer) clearTimeout(timer);
|
|
68
|
+
spec.signal?.removeEventListener("abort", abort);
|
|
69
|
+
if (spawnError && stderr.snapshot().totalBytes === 0) stderr.append(spawnError.message);
|
|
70
|
+
const out = stdout.snapshot();
|
|
71
|
+
const err = stderr.snapshot();
|
|
72
|
+
resolve({
|
|
73
|
+
exitCode: spawnError ? null : exitCode,
|
|
74
|
+
...spawnError && spawnError.code ? { spawnErrorCode: spawnError.code } : {},
|
|
75
|
+
signal,
|
|
76
|
+
stdout: out.text,
|
|
77
|
+
stderr: err.text,
|
|
78
|
+
timedOut,
|
|
79
|
+
aborted,
|
|
80
|
+
outputTruncated: out.truncated || err.truncated,
|
|
81
|
+
terminationVerified: !terminationRequested || child.exitCode !== null || child.signalCode !== null
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}),
|
|
85
|
+
terminate
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function runProcess(spec) {
|
|
89
|
+
return spawnProcess(spec).completion;
|
|
90
|
+
}
|
|
91
|
+
async function runProcessChecked(spec) {
|
|
92
|
+
const result = await runProcess(spec);
|
|
93
|
+
if (result.exitCode !== 0) throw new ProcessExitError(spec, result);
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { runProcess, runProcessChecked, spawnProcess };
|
|
@@ -23,8 +23,14 @@ var init_plugin_registry = __esmMin((() => {
|
|
|
23
23
|
if (!provider.id) throw new Error("Provider must have an id");
|
|
24
24
|
if (!provider.name) throw new Error("Provider must have a name");
|
|
25
25
|
if (!provider.createStream || typeof provider.createStream !== "function") throw new Error("Provider must implement createStream method");
|
|
26
|
+
const previous = this.providers.get(provider.id);
|
|
26
27
|
this.providers.set(provider.id, provider);
|
|
27
28
|
log.info(`Registered provider: ${provider.name} (${provider.id})`);
|
|
29
|
+
return () => {
|
|
30
|
+
if (this.providers.get(provider.id) !== provider) return;
|
|
31
|
+
if (previous) this.providers.set(provider.id, previous);
|
|
32
|
+
else this.providers.delete(provider.id);
|
|
33
|
+
};
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* Get a provider by ID
|
|
@@ -2,7 +2,7 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { hasGatewayScope } from "../gateway/security/gateway-scopes.js";
|
|
4
4
|
import { EndpointToolPolicyError } from "../endpoint-tools/policy.js";
|
|
5
|
-
import { REALTIME_HEARTBEAT_INTERVAL_MS, REALTIME_HEARTBEAT_TIMEOUT_MS, REALTIME_HELLO_TIMEOUT_MS, REALTIME_MAX_CLIENT_FRAME_BYTES, parseClientRealtimeJsonFrame, parseClientRealtimeMessage } from "../../packages/realtime-protocol/src/index.js";
|
|
5
|
+
import { REALTIME_CAPABILITIES, REALTIME_HEARTBEAT_INTERVAL_MS, REALTIME_HEARTBEAT_TIMEOUT_MS, REALTIME_HELLO_TIMEOUT_MS, REALTIME_MAX_CLIENT_FRAME_BYTES, parseClientRealtimeJsonFrame, parseClientRealtimeMessage } from "../../packages/realtime-protocol/src/index.js";
|
|
6
6
|
import { createPreauthConnectionBudget } from "../gateway/security/preauth-connection-budget.js";
|
|
7
7
|
import { RealtimeBroker } from "./broker.js";
|
|
8
8
|
import { RealtimeTicketStore } from "./tickets.js";
|
|
@@ -265,10 +265,12 @@ var RealtimeRuntime = class {
|
|
|
265
265
|
}
|
|
266
266
|
clearTimeout(helloTimer);
|
|
267
267
|
releaseBudget();
|
|
268
|
+
const negotiatedCapabilities = message.payload.capabilities ? [...new Set(message.payload.capabilities.filter((capability) => REALTIME_CAPABILITIES.includes(capability)))] : void 0;
|
|
268
269
|
writer.enqueue(serverMessage("realtime.ready", {
|
|
269
270
|
connectionId,
|
|
270
271
|
heartbeatIntervalMs: REALTIME_HEARTBEAT_INTERVAL_MS,
|
|
271
272
|
heartbeatTimeoutMs: REALTIME_HEARTBEAT_TIMEOUT_MS,
|
|
273
|
+
...message.payload.capabilities ? { negotiatedCapabilities } : {},
|
|
272
274
|
...endpointReady ? { endpoint: endpointReady } : {}
|
|
273
275
|
}), "critical");
|
|
274
276
|
subscribe(message.payload.subscriptions);
|
|
@@ -502,7 +502,7 @@ var SessionStore = class {
|
|
|
502
502
|
handover: result.handover,
|
|
503
503
|
audit: result.audit,
|
|
504
504
|
sourceEntries: expectedSnapshot.entries,
|
|
505
|
-
writePolicy: access.knowledge &&
|
|
505
|
+
writePolicy: access.knowledge && access.knowledgePolicy.scopes.includes("session") && access.knowledgePolicy.contentSources.includes("memory") ? this.options.config.userContext.knowledgeMemory.writePolicy : "deny"
|
|
506
506
|
});
|
|
507
507
|
log.info({
|
|
508
508
|
conversationId: key,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
2
|
import { buildDevicePairingProof, devicePairingCompleteSchema, devicePairingDeviceSchema } from "../../../packages/gateway-contract/src/device-pairing.js";
|
|
3
|
+
import { DEFAULT_BROWSER_EXTENSION_SCOPES, DEFAULT_MOBILE_SCOPES } from "../../../packages/gateway-contract/src/gateway-scopes.js";
|
|
3
4
|
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
4
|
-
import { DEFAULT_BROWSER_EXTENSION_SCOPES, DEFAULT_MOBILE_SCOPES } from "../../gateway/security/gateway-scopes.js";
|
|
5
5
|
import { createDevice, getDevice, registerInitialDeviceRefreshToken, revokeDevice } from "./device-access-repository.js";
|
|
6
6
|
import { getOrCreateGatewayIdentity } from "./gateway-identity-repository.js";
|
|
7
7
|
import { browserEnrollmentPublicKeyThumbprint } from "../../browser/enrollment.js";
|
|
@@ -29,7 +29,7 @@ export { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAll
|
|
|
29
29
|
export { buildDefaultSessionMetadata, type SessionMetadataSeed, } from './session-metadata.js';
|
|
30
30
|
export { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow, type SessionConfigRow, type SessionRow, type TranscriptEntryRow, } from './row-mappers.js';
|
|
31
31
|
export { deleteSessionRecord, ensureSessionRecord, getCurrentTranscriptId, getGlobalSessionStats, findConversationIdByTranscriptId, getSessionPersistedLevels, getSessionMetadata, incrementSessionStatsOnAppend, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats, } from './session-repository.js';
|
|
32
|
-
export { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, loadCompactionSourceSnapshot, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript, type CompactionSourceSnapshot, type SessionTranscriptRecallMatch, type TranscriptSourceEntry, } from './transcript-repository.js';
|
|
32
|
+
export { appendCompactionBoundaryIfUnchanged, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, findLatestAssistantTranscriptEntryId, listCompactionBoundaries, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, loadCompactionSourceSnapshot, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript, type CompactionSourceSnapshot, type SessionTranscriptRecallMatch, type TranscriptSourceEntry, } from './transcript-repository.js';
|
|
33
33
|
export { deleteNoteRecord, getNoteRecord, listNoteRecords, upsertNoteRecord, } from './notes-repository.js';
|
|
34
34
|
export { deleteNoteAgentContextRecord, getNoteAgentContextRecord, upsertNoteAgentContextRecord, type NoteAgentContextRecord, } from './note-agent-context-repository.js';
|
|
35
35
|
export { claimKnowledgeSourceItems, countKnowledgeSourceItems, completeKnowledgeSourceItemSynthesis, deleteKnowledgeSourceItems, finishKnowledgeSyncRun, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, listKnowledgeSourceItems, listKnowledgeSourceChanges, listKnowledgeSyncRuns, pruneBoundedKnowledgeSourceItems, setKnowledgeSourceItemSynthesisStatus, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, startKnowledgeSyncRun, upsertKnowledgeSourceItems, } from './knowledge-repository.js';
|
|
@@ -31,7 +31,7 @@ import { getInteractionState, setInteractionState, updateInteractionStateFromMes
|
|
|
31
31
|
import { deleteSessionRecord, ensureSessionRecord, findConversationIdByTranscriptId, getCurrentTranscriptId, getGlobalSessionStats, getSessionMetadata, getSessionPersistedLevels, incrementSessionStatsOnAppend, init_session_repository, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats } from "./session-repository.js";
|
|
32
32
|
import { getSessionTaskPlan, setSessionTaskPlan } from "./session-task-plan-repository.js";
|
|
33
33
|
import { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings } from "./relationship-settings-repository.js";
|
|
34
|
-
import { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript } from "./transcript-repository.js";
|
|
34
|
+
import { appendCompactionBoundaryIfUnchanged, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, findLatestAssistantTranscriptEntryId, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript } from "./transcript-repository.js";
|
|
35
35
|
import { deleteNoteRecord, getNoteRecord, listNoteRecords, upsertNoteRecord } from "./notes-repository.js";
|
|
36
36
|
import { deleteNoteAgentContextRecord, getNoteAgentContextRecord, upsertNoteAgentContextRecord } from "./note-agent-context-repository.js";
|
|
37
37
|
import { claimKnowledgeSourceItems, completeKnowledgeSourceItemSynthesis, countKnowledgeSourceItems, deleteKnowledgeSourceItems, finishKnowledgeSyncRun, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, pruneBoundedKnowledgeSourceItems, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, startKnowledgeSyncRun, upsertKnowledgeSourceItems } from "./knowledge-repository.js";
|
|
@@ -54,4 +54,4 @@ init_session_metadata();
|
|
|
54
54
|
init_row_mappers();
|
|
55
55
|
init_session_repository();
|
|
56
56
|
//#endregion
|
|
57
|
-
export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, DatabaseSchemaTooOldError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendTranscriptEntry, applyPendingMigrations, authenticateDeviceAccessToken, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRefreshProofMessage, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, clearGatewayIdentityForTest, closeTemporalAssertions, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeClarificationApproval, consumeClarificationResume, consumeConnectorApproval, countKnowledgeSourceItems, createClarificationWait, createCollaborationRule, createConnectorApproval, createContextEvidence, createDevice, createDevicePairingSetup, createEndpointPrincipal, createObjectLinkRecord, createTemporalAssertion, decideConnectorApproval, deleteBrowserTabBinding, deleteBrowserTabBindingsByEndpoint, deleteBrowserTabBindingsByPrincipal, deleteConnectorConnection, deleteConnectorInstallation, deleteEndpointSessionBinding, deleteEndpointSessionBindingsByPrincipal, deleteKnowledgeSourceItems, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, enqueueConnectorLearningJob, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findConversationIdByTranscriptId, findSessionInput, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActiveClarification, getActivityEventRecord, getBrowserTabBinding, getBrowserTabBindingById, getCachedConnectorCatalogEntry, getClarification, getClarificationResumeInput, getClarificationSnapshot, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextExtractionRun, getCurrentTranscriptId, getDevice, getEndpointPrincipal, getEndpointSessionBinding, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getNoteAgentContextRecord, getNoteRecord, getOrCreateGatewayIdentity, getRelationshipSettings, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getUserPeopleIndexState, getUserPerson, getUserTrustPolicy, getXopcDatabase, hasIndependentExtractionOutput, hasSessionConfig, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isClarificationSuspended, isDevicePairingSetupActive, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isXopcDatabaseOpen, issueDeviceTokenPair, linkContextObjects, listActiveSessionInputRuns, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextExtractionOutputs, listContextExtractionRuns, listContextObjectRelations, listDevices, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTemporalAssertions, listUserPeople, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, mergeUserPeople, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, replaceUserPeopleIndex, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveClarification, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, revokeDevice, revokeEndpointPrincipal, rotateDeviceRefreshToken, runSqliteWriteTransaction, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setBrowserTabBinding, setCollaborationRuleStatus, setConnectorLearningPaused, setEndpointSessionBinding, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUserTrustPolicy, signGatewayPayload, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeUserPeople, supersedeActiveClarification, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserPerson, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
|
|
57
|
+
export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, DatabaseSchemaTooOldError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, applyPendingMigrations, authenticateDeviceAccessToken, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRefreshProofMessage, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, clearGatewayIdentityForTest, closeTemporalAssertions, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeClarificationApproval, consumeClarificationResume, consumeConnectorApproval, countKnowledgeSourceItems, createClarificationWait, createCollaborationRule, createConnectorApproval, createContextEvidence, createDevice, createDevicePairingSetup, createEndpointPrincipal, createObjectLinkRecord, createTemporalAssertion, decideConnectorApproval, deleteBrowserTabBinding, deleteBrowserTabBindingsByEndpoint, deleteBrowserTabBindingsByPrincipal, deleteConnectorConnection, deleteConnectorInstallation, deleteEndpointSessionBinding, deleteEndpointSessionBindingsByPrincipal, deleteKnowledgeSourceItems, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, enqueueConnectorLearningJob, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findConversationIdByTranscriptId, findLatestAssistantTranscriptEntryId, findSessionInput, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActiveClarification, getActivityEventRecord, getBrowserTabBinding, getBrowserTabBindingById, getCachedConnectorCatalogEntry, getClarification, getClarificationResumeInput, getClarificationSnapshot, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextExtractionRun, getCurrentTranscriptId, getDevice, getEndpointPrincipal, getEndpointSessionBinding, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getNoteAgentContextRecord, getNoteRecord, getOrCreateGatewayIdentity, getRelationshipSettings, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getUserPeopleIndexState, getUserPerson, getUserTrustPolicy, getXopcDatabase, hasIndependentExtractionOutput, hasSessionConfig, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isClarificationSuspended, isDevicePairingSetupActive, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isXopcDatabaseOpen, issueDeviceTokenPair, linkContextObjects, listActiveSessionInputRuns, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextExtractionOutputs, listContextExtractionRuns, listContextObjectRelations, listDevices, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTemporalAssertions, listUserPeople, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, mergeUserPeople, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, replaceUserPeopleIndex, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveClarification, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, revokeDevice, revokeEndpointPrincipal, rotateDeviceRefreshToken, runSqliteWriteTransaction, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setBrowserTabBinding, setCollaborationRuleStatus, setConnectorLearningPaused, setEndpointSessionBinding, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUserTrustPolicy, signGatewayPayload, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeUserPeople, supersedeActiveClarification, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserPerson, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS knowledge_item_status_events (
|
|
2
|
+
event_id TEXT PRIMARY KEY,
|
|
3
|
+
knowledge_id TEXT NOT NULL REFERENCES knowledge_items(knowledge_id) ON DELETE CASCADE,
|
|
4
|
+
from_status TEXT,
|
|
5
|
+
to_status TEXT NOT NULL,
|
|
6
|
+
actor_type TEXT NOT NULL CHECK(actor_type IN ('user', 'agent', 'runtime', 'maintenance', 'migration')),
|
|
7
|
+
reason TEXT NOT NULL,
|
|
8
|
+
created_at INTEGER NOT NULL
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
CREATE INDEX IF NOT EXISTS idx_knowledge_item_status_events_item
|
|
12
|
+
ON knowledge_item_status_events(knowledge_id, created_at DESC);
|
|
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
|
|
|
3
3
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
4
4
|
export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 165;
|
|
5
5
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
6
|
-
export declare const XOPC_DB_SCHEMA_VERSION =
|
|
6
|
+
export declare const XOPC_DB_SCHEMA_VERSION = 181;
|
|
7
7
|
export declare function resolveMigrationsDir(override?: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
|
|
@@ -63,7 +63,7 @@ function applySingleMigration(db, migration) {
|
|
|
63
63
|
* Each step runs in its own transaction and updates schema_meta on success.
|
|
64
64
|
*/
|
|
65
65
|
function applyPendingMigrations(db, options = {}) {
|
|
66
|
-
const targetVersion = options.targetVersion ??
|
|
66
|
+
const targetVersion = options.targetVersion ?? 181;
|
|
67
67
|
let currentVersion = readSchemaVersion(db);
|
|
68
68
|
if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
|
|
69
69
|
if (!options.migrationsDir && currentVersion < 165) throw new DatabaseSchemaTooOldError(currentVersion, 165);
|
|
@@ -118,7 +118,7 @@ function applyPendingMigrations(db, options = {}) {
|
|
|
118
118
|
}
|
|
119
119
|
/** Inspect schema version without mutating the database. */
|
|
120
120
|
function inspectSchemaMigrationStatus(db, options = {}) {
|
|
121
|
-
const appVersion = options.targetVersion ??
|
|
121
|
+
const appVersion = options.targetVersion ?? 181;
|
|
122
122
|
const dbVersion = readSchemaVersion(db);
|
|
123
123
|
if (dbVersion > appVersion) return {
|
|
124
124
|
dbVersion,
|
|
@@ -157,7 +157,7 @@ var init_runner = __esmMin((() => {
|
|
|
157
157
|
init_errors();
|
|
158
158
|
log = createLogger("Sqlite:Migrations");
|
|
159
159
|
XOPC_DB_BASELINE_SCHEMA_VERSION = 165;
|
|
160
|
-
XOPC_DB_SCHEMA_VERSION =
|
|
160
|
+
XOPC_DB_SCHEMA_VERSION = 181;
|
|
161
161
|
MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
162
162
|
}));
|
|
163
163
|
//#endregion
|
|
@@ -2320,6 +2320,19 @@ CREATE VIRTUAL TABLE knowledge_items_fts USING fts5(
|
|
|
2320
2320
|
tokenize='unicode61'
|
|
2321
2321
|
);
|
|
2322
2322
|
|
|
2323
|
+
CREATE TABLE knowledge_item_status_events (
|
|
2324
|
+
event_id TEXT PRIMARY KEY,
|
|
2325
|
+
knowledge_id TEXT NOT NULL REFERENCES knowledge_items(knowledge_id) ON DELETE CASCADE,
|
|
2326
|
+
from_status TEXT,
|
|
2327
|
+
to_status TEXT NOT NULL,
|
|
2328
|
+
actor_type TEXT NOT NULL CHECK(actor_type IN ('user', 'agent', 'runtime', 'maintenance', 'migration')),
|
|
2329
|
+
reason TEXT NOT NULL,
|
|
2330
|
+
created_at INTEGER NOT NULL
|
|
2331
|
+
);
|
|
2332
|
+
|
|
2333
|
+
CREATE INDEX idx_knowledge_item_status_events_item
|
|
2334
|
+
ON knowledge_item_status_events(knowledge_id, created_at DESC);
|
|
2335
|
+
|
|
2323
2336
|
CREATE TABLE memory_maintenance_runs (
|
|
2324
2337
|
run_id TEXT PRIMARY KEY,
|
|
2325
2338
|
principal_id TEXT NOT NULL,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentMessage } from '@earendil-works/pi-agent-core';
|
|
2
|
+
import type { MediaRef } from '../../media/types.js';
|
|
2
3
|
import type { CompactionBoundarySummary } from '../../session/types.js';
|
|
3
4
|
import { type TranscriptStoredRow, type XopcTranscriptCompactionEntry } from '../../session/session-context-for-llm.js';
|
|
4
5
|
import { type TranscriptEntryRow } from './row-mappers.js';
|
|
@@ -34,6 +35,9 @@ export declare function loadTranscriptRowsForSession(conversationId: string): Tr
|
|
|
34
35
|
export declare function loadTranscriptHistoryRowsForSession(conversationId: string): TranscriptStoredRow[];
|
|
35
36
|
export declare function loadTranscriptRows(transcriptId: string): TranscriptStoredRow[];
|
|
36
37
|
export declare function loadLlmMessagesForSession(conversationId: string): AgentMessage[];
|
|
38
|
+
export declare function findLatestAssistantTranscriptEntryId(conversationId: string): string | null;
|
|
39
|
+
/** Attach generated media to one exact assistant row without rewriting the transcript. */
|
|
40
|
+
export declare function appendMediaToAssistantTranscriptEntry(conversationId: string, entryId: string, media: MediaRef): boolean;
|
|
37
41
|
export declare function replaceTranscriptRows(conversationId: string, rows: TranscriptStoredRow[]): void;
|
|
38
42
|
export declare function paginateTranscriptMessages(conversationId: string, options?: {
|
|
39
43
|
offset?: number;
|
|
@@ -218,6 +218,41 @@ function loadLlmMessagesForSession(conversationId) {
|
|
|
218
218
|
)
|
|
219
219
|
ORDER BY seq ASC`).all(transcriptId, transcriptId).map(transcriptEntryRowToStoredRow));
|
|
220
220
|
}
|
|
221
|
+
function findLatestAssistantTranscriptEntryId(conversationId) {
|
|
222
|
+
const transcriptId = getCurrentTranscriptId(conversationId);
|
|
223
|
+
if (!transcriptId) return null;
|
|
224
|
+
return getSqliteDatabase().prepare(`SELECT entry_id
|
|
225
|
+
FROM transcript_entries
|
|
226
|
+
WHERE transcript_id = ? AND entry_kind = 'message' AND role = 'assistant'
|
|
227
|
+
ORDER BY seq DESC
|
|
228
|
+
LIMIT 1`).get(transcriptId)?.entry_id ?? null;
|
|
229
|
+
}
|
|
230
|
+
/** Attach generated media to one exact assistant row without rewriting the transcript. */
|
|
231
|
+
function appendMediaToAssistantTranscriptEntry(conversationId, entryId, media) {
|
|
232
|
+
if (!entryId.trim() || !media.uri?.trim()) return false;
|
|
233
|
+
return runSqliteWriteTransaction((db) => {
|
|
234
|
+
const transcriptId = readCurrentTranscriptId(db, conversationId);
|
|
235
|
+
if (!transcriptId) return false;
|
|
236
|
+
const row = db.prepare(`SELECT payload_json
|
|
237
|
+
FROM transcript_entries
|
|
238
|
+
WHERE transcript_id = ? AND entry_id = ? AND entry_kind = 'message' AND role = 'assistant'`).get(transcriptId, entryId);
|
|
239
|
+
if (!row) return false;
|
|
240
|
+
let message;
|
|
241
|
+
try {
|
|
242
|
+
message = JSON.parse(row.payload_json);
|
|
243
|
+
} catch {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
const existing = Array.isArray(message.media) ? message.media : [];
|
|
247
|
+
if (existing.some((item) => item?.uri === media.uri)) return true;
|
|
248
|
+
const next = {
|
|
249
|
+
...message,
|
|
250
|
+
media: [...existing, media]
|
|
251
|
+
};
|
|
252
|
+
return db.prepare(`UPDATE transcript_entries SET payload_json = ?
|
|
253
|
+
WHERE transcript_id = ? AND entry_id = ?`).run(JSON.stringify(next), transcriptId, entryId).changes === 1;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
221
256
|
function replaceTranscriptRows(conversationId, rows) {
|
|
222
257
|
if (rows.some(isRuntimeOnlyTranscriptMessage)) throw new Error("Runtime-only messages cannot be persisted in a session transcript");
|
|
223
258
|
runSqliteWriteTransaction((db) => {
|
|
@@ -349,4 +384,4 @@ function restoreBeforeCompactionBoundary(conversationId, compactionId) {
|
|
|
349
384
|
});
|
|
350
385
|
}
|
|
351
386
|
//#endregion
|
|
352
|
-
export { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript };
|
|
387
|
+
export { appendCompactionBoundaryIfUnchanged, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, findLatestAssistantTranscriptEntryId, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ExtensionRegistryImpl } from '../../extensions/
|
|
1
|
+
import type { ExtensionRegistryImpl } from '../../extensions/extension-registry-impl.js';
|
|
2
2
|
import { type SessionTimelineItem } from '../../session/transcript-outline.js';
|
|
3
3
|
import { type Config } from '../../config/schema.js';
|
|
4
4
|
import type { ExportFormat } from '../../session/types.js';
|
|
5
|
-
import type { ChatSendOptions, HistoryMessage, TuiBackend, TuiCompactionResult, TuiComposerHistoryItem, TuiEvent, TuiModelChoice, TuiShareRequest, TuiShareResult, TuiSessionStats, TuiSessionItem, TuiTranscriptTreeEntry, TuiAgentInfo, TuiWorkspaceFileSearchEntry, TuiWorkflowRunStartRequest, TuiWorkflowRunStartResult, TuiStartupProjectResult } from '../tui-backend.js';
|
|
5
|
+
import type { ChatSendOptions, HistoryMessage, TuiBackend, TuiCompactionResult, TuiComposerHistoryItem, TuiEvent, TuiModelChoice, TuiShareRequest, TuiShareResult, TuiSessionStats, TuiSessionItem, TuiTranscriptTreeEntry, TuiAgentInfo, TuiWorkspaceFileSearchEntry, TuiWorkflowRunStartRequest, TuiWorkflowRunStartResult, TuiStartupProjectResult, TuiChatInputState } from '../tui-backend.js';
|
|
6
6
|
import type { SessionInfo } from '../tui-types.js';
|
|
7
7
|
interface EmbeddedBackendOptions {
|
|
8
8
|
config?: Config;
|
|
@@ -28,6 +28,7 @@ export declare class EmbeddedBackend implements TuiBackend {
|
|
|
28
28
|
private workflowRunService;
|
|
29
29
|
private running;
|
|
30
30
|
private chatAbort;
|
|
31
|
+
private readonly chatInputStates;
|
|
31
32
|
onEvent?: (evt: TuiEvent) => void;
|
|
32
33
|
onConnected?: () => void;
|
|
33
34
|
onDisconnected?: (reason: string) => void;
|
|
@@ -73,15 +74,30 @@ export declare class EmbeddedBackend implements TuiBackend {
|
|
|
73
74
|
}): Promise<{
|
|
74
75
|
ok: boolean;
|
|
75
76
|
effectiveDelivery?: 'next' | 'steer';
|
|
77
|
+
state?: TuiChatInputState;
|
|
76
78
|
}>;
|
|
77
|
-
getChatInputState(conversationId: string): Promise<
|
|
79
|
+
getChatInputState(conversationId: string): Promise<TuiChatInputState>;
|
|
80
|
+
updateChatInput(opts: {
|
|
78
81
|
conversationId: string;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
inputId: string;
|
|
83
|
+
version: number;
|
|
84
|
+
content: string;
|
|
85
|
+
}): Promise<{
|
|
86
|
+
ok: boolean;
|
|
87
|
+
state?: TuiChatInputState;
|
|
88
|
+
}>;
|
|
89
|
+
removeChatInput(opts: {
|
|
90
|
+
conversationId: string;
|
|
91
|
+
inputId: string;
|
|
92
|
+
version: number;
|
|
93
|
+
}): Promise<{
|
|
94
|
+
ok: boolean;
|
|
95
|
+
state?: TuiChatInputState;
|
|
84
96
|
}>;
|
|
97
|
+
private appendPendingChatInput;
|
|
98
|
+
private consumePendingChatInput;
|
|
99
|
+
private publishChatInputState;
|
|
100
|
+
private replaceEmbeddedQueue;
|
|
85
101
|
loadHistory(opts: {
|
|
86
102
|
conversationId: string;
|
|
87
103
|
limit?: number;
|
|
@@ -33,6 +33,7 @@ import { WorkflowSessionBridge } from "../../workflows/service/workflow-session-
|
|
|
33
33
|
import { ChatStreamMapper } from "../../gateway/chat-stream/mapper.js";
|
|
34
34
|
import { getXopcCloudCatalogCoordinator } from "../../providers/xopc-cloud-catalog-coordinator.js";
|
|
35
35
|
import { fuzzySearchWorkspaceFiles } from "../../gateway/workspace-file-search.js";
|
|
36
|
+
import { commitDeliveredChatInput } from "../tui-chat-input-state.js";
|
|
36
37
|
import { sessionMetadataToTuiItem } from "../tui-session-format.js";
|
|
37
38
|
import { buildTuiTranscriptTree, transcriptTreeEntryIdToRowNumber } from "../tui-transcript-tree.js";
|
|
38
39
|
import { computeTuiSessionStats } from "../tui-session-stats.js";
|
|
@@ -54,6 +55,14 @@ function isPathSameOrInside(parentDir, childDir) {
|
|
|
54
55
|
const rel = relative(resolve(parentDir), resolve(childDir));
|
|
55
56
|
return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute(rel);
|
|
56
57
|
}
|
|
58
|
+
function deliveredUserMessageText(event) {
|
|
59
|
+
if (event.type !== "message_start" || !event.message || typeof event.message !== "object") return void 0;
|
|
60
|
+
const message = event.message;
|
|
61
|
+
if (message.role !== "user") return void 0;
|
|
62
|
+
if (typeof message.content === "string") return message.content;
|
|
63
|
+
if (!Array.isArray(message.content)) return void 0;
|
|
64
|
+
return message.content.map((block) => block && typeof block === "object" && block.type === "text" ? String(block.text ?? "") : "").join("");
|
|
65
|
+
}
|
|
57
66
|
/**
|
|
58
67
|
* TUI backend that runs the agent in-process (no gateway required).
|
|
59
68
|
*
|
|
@@ -71,6 +80,7 @@ var EmbeddedBackend = class {
|
|
|
71
80
|
workflowRunService = null;
|
|
72
81
|
running = false;
|
|
73
82
|
chatAbort = null;
|
|
83
|
+
chatInputStates = /* @__PURE__ */ new Map();
|
|
74
84
|
onEvent;
|
|
75
85
|
onConnected;
|
|
76
86
|
onDisconnected;
|
|
@@ -319,6 +329,7 @@ var EmbeddedBackend = class {
|
|
|
319
329
|
source: "embedded"
|
|
320
330
|
});
|
|
321
331
|
(async () => {
|
|
332
|
+
let initialUserMessageObserved = false;
|
|
322
333
|
try {
|
|
323
334
|
const messageForAgent = opts.message.trimStart().startsWith("/") ? opts.message : prependEnvelopeTimestamp(opts.message);
|
|
324
335
|
const stream = agent.turnDispatcher.processDirectStreaming(messageForAgent, opts.conversationId, {
|
|
@@ -330,6 +341,9 @@ var EmbeddedBackend = class {
|
|
|
330
341
|
});
|
|
331
342
|
for await (const event of stream) {
|
|
332
343
|
if (signal.aborted) break;
|
|
344
|
+
const deliveredInput = deliveredUserMessageText(event);
|
|
345
|
+
if (deliveredInput !== void 0) if (initialUserMessageObserved) this.consumePendingChatInput(opts.conversationId, deliveredInput);
|
|
346
|
+
else initialUserMessageObserved = true;
|
|
333
347
|
for (const mapped of mapper.map(event)) this.onEvent?.({
|
|
334
348
|
event: mapped.type,
|
|
335
349
|
data: mapped,
|
|
@@ -369,10 +383,11 @@ var EmbeddedBackend = class {
|
|
|
369
383
|
async submitChatInput(opts) {
|
|
370
384
|
if (!this.agent) return { ok: false };
|
|
371
385
|
if (opts.delivery === "steer") {
|
|
372
|
-
|
|
386
|
+
if (!await this.agent.turnDispatcher.steerWebchatSession(opts.conversationId, opts.message)) return { ok: false };
|
|
373
387
|
return {
|
|
374
|
-
ok,
|
|
375
|
-
effectiveDelivery:
|
|
388
|
+
ok: true,
|
|
389
|
+
effectiveDelivery: "steer",
|
|
390
|
+
state: this.appendPendingChatInput(opts.conversationId, opts.message, "steer")
|
|
376
391
|
};
|
|
377
392
|
}
|
|
378
393
|
const { getEmbeddedRunByConversationId } = await import("../../agent/embedded/runs.js");
|
|
@@ -381,20 +396,109 @@ var EmbeddedBackend = class {
|
|
|
381
396
|
await handle.session.followUp(opts.message);
|
|
382
397
|
return {
|
|
383
398
|
ok: true,
|
|
384
|
-
effectiveDelivery: "next"
|
|
399
|
+
effectiveDelivery: "next",
|
|
400
|
+
state: this.appendPendingChatInput(opts.conversationId, opts.message, "next")
|
|
385
401
|
};
|
|
386
402
|
}
|
|
387
403
|
async getChatInputState(conversationId) {
|
|
388
|
-
|
|
389
|
-
|
|
404
|
+
return this.chatInputStates.get(conversationId) ?? {
|
|
405
|
+
conversationId,
|
|
406
|
+
revision: 0,
|
|
407
|
+
inputs: []
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
async updateChatInput(opts) {
|
|
411
|
+
const current = await this.getChatInputState(opts.conversationId);
|
|
412
|
+
const target = current.inputs.find((input) => input.id === opts.inputId);
|
|
413
|
+
if (!target || target.version !== opts.version || target.status !== "queued") return {
|
|
414
|
+
ok: false,
|
|
415
|
+
state: current
|
|
416
|
+
};
|
|
417
|
+
const state = {
|
|
418
|
+
...current,
|
|
419
|
+
revision: current.revision + 1,
|
|
420
|
+
inputs: current.inputs.map((input) => input.id === target.id ? {
|
|
421
|
+
...input,
|
|
422
|
+
content: opts.content,
|
|
423
|
+
version: input.version + 1
|
|
424
|
+
} : input)
|
|
425
|
+
};
|
|
426
|
+
if (!await this.replaceEmbeddedQueue(opts.conversationId, state)) return {
|
|
427
|
+
ok: false,
|
|
428
|
+
state: current
|
|
429
|
+
};
|
|
430
|
+
this.publishChatInputState(state);
|
|
431
|
+
return {
|
|
432
|
+
ok: true,
|
|
433
|
+
state
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
async removeChatInput(opts) {
|
|
437
|
+
const current = await this.getChatInputState(opts.conversationId);
|
|
438
|
+
const target = current.inputs.find((input) => input.id === opts.inputId);
|
|
439
|
+
if (!target || target.version !== opts.version || target.status !== "queued" && target.status !== "interrupted") return {
|
|
440
|
+
ok: false,
|
|
441
|
+
state: current
|
|
442
|
+
};
|
|
443
|
+
const state = {
|
|
444
|
+
...current,
|
|
445
|
+
revision: current.revision + 1,
|
|
446
|
+
inputs: current.inputs.filter((input) => input.id !== target.id)
|
|
447
|
+
};
|
|
448
|
+
if (!await this.replaceEmbeddedQueue(opts.conversationId, state)) return {
|
|
449
|
+
ok: false,
|
|
450
|
+
state: current
|
|
451
|
+
};
|
|
452
|
+
this.publishChatInputState(state);
|
|
390
453
|
return {
|
|
454
|
+
ok: true,
|
|
455
|
+
state
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
appendPendingChatInput(conversationId, content, delivery) {
|
|
459
|
+
const current = this.chatInputStates.get(conversationId) ?? {
|
|
391
460
|
conversationId,
|
|
392
461
|
revision: 0,
|
|
393
|
-
inputs:
|
|
394
|
-
id: String(index),
|
|
395
|
-
status: "queued"
|
|
396
|
-
}))
|
|
462
|
+
inputs: []
|
|
397
463
|
};
|
|
464
|
+
const state = {
|
|
465
|
+
...current,
|
|
466
|
+
revision: current.revision + 1,
|
|
467
|
+
inputs: [...current.inputs, {
|
|
468
|
+
id: crypto.randomUUID(),
|
|
469
|
+
content,
|
|
470
|
+
requestedDelivery: delivery,
|
|
471
|
+
effectiveDelivery: delivery,
|
|
472
|
+
status: delivery === "steer" ? "injecting" : "queued",
|
|
473
|
+
version: 1,
|
|
474
|
+
position: current.inputs.length
|
|
475
|
+
}]
|
|
476
|
+
};
|
|
477
|
+
this.publishChatInputState(state);
|
|
478
|
+
return state;
|
|
479
|
+
}
|
|
480
|
+
consumePendingChatInput(conversationId, content) {
|
|
481
|
+
const current = this.chatInputStates.get(conversationId);
|
|
482
|
+
if (!current?.inputs.length) return;
|
|
483
|
+
const next = commitDeliveredChatInput(current, content);
|
|
484
|
+
if (next !== current) this.publishChatInputState(next);
|
|
485
|
+
}
|
|
486
|
+
publishChatInputState(state) {
|
|
487
|
+
this.chatInputStates.set(state.conversationId, state);
|
|
488
|
+
this.onEvent?.({
|
|
489
|
+
event: "session.input-state",
|
|
490
|
+
data: state,
|
|
491
|
+
source: "embedded"
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
async replaceEmbeddedQueue(conversationId, state) {
|
|
495
|
+
const { getEmbeddedRunByConversationId } = await import("../../agent/embedded/runs.js");
|
|
496
|
+
const handle = getEmbeddedRunByConversationId(conversationId);
|
|
497
|
+
if (!handle) return false;
|
|
498
|
+
handle.session.clearQueue();
|
|
499
|
+
for (const input of state.inputs) if (input.status === "injecting") await handle.session.steer(input.content);
|
|
500
|
+
else await handle.session.followUp(input.content);
|
|
501
|
+
return true;
|
|
398
502
|
}
|
|
399
503
|
async loadHistory(opts) {
|
|
400
504
|
if (!this.agent) return { messages: [] };
|
|
@@ -71,8 +71,26 @@ export declare class GatewayRealtimeBackend implements TuiBackend {
|
|
|
71
71
|
}): Promise<{
|
|
72
72
|
ok: boolean;
|
|
73
73
|
effectiveDelivery?: 'next' | 'steer';
|
|
74
|
+
state?: TuiChatInputState;
|
|
74
75
|
}>;
|
|
75
76
|
getChatInputState(conversationId: string): Promise<TuiChatInputState>;
|
|
77
|
+
updateChatInput(opts: {
|
|
78
|
+
conversationId: string;
|
|
79
|
+
inputId: string;
|
|
80
|
+
version: number;
|
|
81
|
+
content: string;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
ok: boolean;
|
|
84
|
+
state?: TuiChatInputState;
|
|
85
|
+
}>;
|
|
86
|
+
removeChatInput(opts: {
|
|
87
|
+
conversationId: string;
|
|
88
|
+
inputId: string;
|
|
89
|
+
version: number;
|
|
90
|
+
}): Promise<{
|
|
91
|
+
ok: boolean;
|
|
92
|
+
state?: TuiChatInputState;
|
|
93
|
+
}>;
|
|
76
94
|
getStartupResources(conversationId: string): Promise<TuiStartupResources>;
|
|
77
95
|
loadHistory(opts: {
|
|
78
96
|
conversationId: string;
|