@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
|
@@ -2,11 +2,11 @@ import { resolveStateDir } from "../../config/paths-state.js";
|
|
|
2
2
|
import { init_global_singleton, resolveGlobalSingleton } from "../../utils/global-singleton.js";
|
|
3
3
|
import { init_paths } from "../../config/paths.js";
|
|
4
4
|
import { DurableState } from "../../storage/sqlite/durable-state.js";
|
|
5
|
+
import { spawnProcess } from "../../process/run-process.js";
|
|
5
6
|
import { isolatedCommand, removeCommandContainer } from "./command-isolation.js";
|
|
6
7
|
import { readWorkspaceRevision } from "../coding/workspace-revision.js";
|
|
7
8
|
import { join } from "node:path";
|
|
8
9
|
import { appendFileSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
9
|
-
import { spawn } from "node:child_process";
|
|
10
10
|
import { createHash, randomUUID } from "node:crypto";
|
|
11
11
|
//#region src/agent/commands/command-registry.ts
|
|
12
12
|
init_paths();
|
|
@@ -17,26 +17,6 @@ const MAX_LOG_BYTES = 8 * 1024 * 1024;
|
|
|
17
17
|
function commandTimeout(raw, ceiling = MAX_COMMAND_TIMEOUT_MS) {
|
|
18
18
|
return Math.min(ceiling, Math.max(1, typeof raw === "number" && Number.isFinite(raw) ? Math.floor(raw) : DEFAULT_COMMAND_TIMEOUT_MS));
|
|
19
19
|
}
|
|
20
|
-
function killTree(child) {
|
|
21
|
-
if (!child.pid) return;
|
|
22
|
-
if (process.platform === "win32") {
|
|
23
|
-
const killer = spawn("taskkill", [
|
|
24
|
-
"/pid",
|
|
25
|
-
String(child.pid),
|
|
26
|
-
"/t",
|
|
27
|
-
"/f"
|
|
28
|
-
], {
|
|
29
|
-
stdio: "ignore",
|
|
30
|
-
windowsHide: true
|
|
31
|
-
});
|
|
32
|
-
killer.on("error", () => child.kill("SIGKILL"));
|
|
33
|
-
killer.unref();
|
|
34
|
-
} else try {
|
|
35
|
-
process.kill(-child.pid, "SIGKILL");
|
|
36
|
-
} catch {
|
|
37
|
-
child.kill("SIGKILL");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
20
|
/** Foreground and background tools share ownership, cancellation, output and durable receipts. */
|
|
41
21
|
var CommandRegistry = class {
|
|
42
22
|
prunedAt = /* @__PURE__ */ new Map();
|
|
@@ -97,12 +77,6 @@ var CommandRegistry = class {
|
|
|
97
77
|
flag: "wx"
|
|
98
78
|
});
|
|
99
79
|
this.persist(input.owner, result);
|
|
100
|
-
const child = spawn(launch.executable, launch.args, {
|
|
101
|
-
shell: launch.shell,
|
|
102
|
-
cwd: input.cwd,
|
|
103
|
-
env: input.env,
|
|
104
|
-
detached: process.platform !== "win32"
|
|
105
|
-
});
|
|
106
80
|
const limit = input.maxOutputChars ?? 5e4;
|
|
107
81
|
let logBytes = 0;
|
|
108
82
|
let closed = false;
|
|
@@ -123,6 +97,19 @@ var CommandRegistry = class {
|
|
|
123
97
|
result.logTruncated ||= bytes.length > remaining;
|
|
124
98
|
input.onOutput?.(stream, value.length > 16e3 ? `${value.slice(0, 16e3)}\n[stream delta truncated]` : value);
|
|
125
99
|
};
|
|
100
|
+
const handle = spawnProcess({
|
|
101
|
+
program: launch.executable,
|
|
102
|
+
args: launch.args,
|
|
103
|
+
shell: launch.shell,
|
|
104
|
+
cwd: input.cwd,
|
|
105
|
+
env: input.env,
|
|
106
|
+
detached: process.platform !== "win32",
|
|
107
|
+
terminationPolicy: "tree",
|
|
108
|
+
keepStdinOpen: true,
|
|
109
|
+
maxOutputBytes: 0,
|
|
110
|
+
onOutput: append
|
|
111
|
+
});
|
|
112
|
+
const child = handle.child;
|
|
126
113
|
const stop = (status) => {
|
|
127
114
|
if (result.status !== "running" || closed) return;
|
|
128
115
|
result.status = status;
|
|
@@ -131,25 +118,23 @@ var CommandRegistry = class {
|
|
|
131
118
|
result.status = "interrupted";
|
|
132
119
|
append("stderr", `Container cleanup failed: ${String(error)}`);
|
|
133
120
|
});
|
|
134
|
-
|
|
121
|
+
handle.terminate(status === "timed_out" ? "timed_out" : "cancelled");
|
|
135
122
|
};
|
|
136
123
|
const timer = setTimeout(() => stop("timed_out"), commandTimeout(input.timeoutMs));
|
|
137
124
|
timer.unref();
|
|
138
125
|
const abort = () => stop("cancelled");
|
|
139
126
|
input.signal?.addEventListener("abort", abort, { once: true });
|
|
140
127
|
const done = new Promise((resolve) => {
|
|
141
|
-
child.stdout?.on("data", (value) => append("stdout", value));
|
|
142
|
-
child.stderr?.on("data", (value) => append("stderr", value));
|
|
143
128
|
child.on("error", (error) => append("stderr", error.message));
|
|
144
129
|
child.stdin?.on("error", (error) => append("stderr", error.message));
|
|
145
|
-
|
|
130
|
+
handle.completion.then(async (processResult) => {
|
|
146
131
|
closed = true;
|
|
147
132
|
clearTimeout(timer);
|
|
148
133
|
input.signal?.removeEventListener("abort", abort);
|
|
149
134
|
if (containerCleanup) await containerCleanup;
|
|
150
135
|
if (input.snapshot) result.endRevision = await readWorkspaceRevision(input.cwd);
|
|
151
|
-
if (result.status === "running") result.status = exitCode === 0 ? "success" : "failed";
|
|
152
|
-
result.exitCode = exitCode;
|
|
136
|
+
if (result.status === "running") result.status = processResult.exitCode === 0 ? "success" : "failed";
|
|
137
|
+
result.exitCode = processResult.exitCode;
|
|
153
138
|
result.durationMs = Date.now() - result.createdAtMs;
|
|
154
139
|
try {
|
|
155
140
|
this.persist(input.owner, result);
|
|
@@ -11,6 +11,7 @@ function recordExecutionContext(context, input) {
|
|
|
11
11
|
for (const item of selected.goals) included.add(`goal:${item.id}`);
|
|
12
12
|
for (const item of selected.priorities) included.add(`priority:${item.id}`);
|
|
13
13
|
for (const item of selected.knowledge) included.add(`knowledge:${item.id}`);
|
|
14
|
+
for (const item of selected.externalKnowledge) included.add(`knowledge:external:${item.citation.providerId}:${item.record.id}`);
|
|
14
15
|
const items = [
|
|
15
16
|
...context.rules.map((item) => ({
|
|
16
17
|
objectType: "rule",
|
|
@@ -44,6 +45,13 @@ function recordExecutionContext(context, input) {
|
|
|
44
45
|
score: item.importance,
|
|
45
46
|
reasons: ["task_relevant_knowledge"],
|
|
46
47
|
included: included.has(`knowledge:${item.id}`)
|
|
48
|
+
})),
|
|
49
|
+
...context.externalKnowledge.map((item) => ({
|
|
50
|
+
objectType: "knowledge",
|
|
51
|
+
objectId: `external:${item.citation.providerId}:${item.record.id}`,
|
|
52
|
+
score: item.score,
|
|
53
|
+
reasons: ["external_memory", "task_relevant_knowledge"],
|
|
54
|
+
included: included.has(`knowledge:external:${item.citation.providerId}:${item.record.id}`)
|
|
47
55
|
}))
|
|
48
56
|
];
|
|
49
57
|
const metrics = {
|
|
@@ -51,12 +59,14 @@ function recordExecutionContext(context, input) {
|
|
|
51
59
|
assertions: context.assertions.length,
|
|
52
60
|
goals: context.goals.length,
|
|
53
61
|
priorities: context.priorities.length,
|
|
54
|
-
knowledge: context.knowledge.length,
|
|
62
|
+
knowledge: context.knowledge.length + context.externalKnowledge.length,
|
|
63
|
+
externalKnowledge: context.externalKnowledge.length,
|
|
55
64
|
includedRules: selected.rules.length,
|
|
56
65
|
includedAssertions: selected.assertions.length,
|
|
57
66
|
includedGoals: selected.goals.length,
|
|
58
67
|
includedPriorities: selected.priorities.length,
|
|
59
|
-
includedKnowledge: selected.knowledge.length,
|
|
68
|
+
includedKnowledge: selected.knowledge.length + selected.externalKnowledge.length,
|
|
69
|
+
includedExternalKnowledge: selected.externalKnowledge.length,
|
|
60
70
|
renderedChars: input.renderedChars
|
|
61
71
|
};
|
|
62
72
|
runSqliteWriteTransaction((db) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AgentMessage } from '@earendil-works/pi-agent-core';
|
|
2
2
|
import type { Config } from '../../config/schema.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { KnowledgeReadPolicy } from '../../knowledge-memory/index.js';
|
|
4
|
+
import type { MemorySearchResult } from '../memory/types.js';
|
|
4
5
|
import { type ExecutionContext } from './execution-context.js';
|
|
5
6
|
export interface ExecutionContextPlan {
|
|
6
7
|
traceId: string;
|
|
7
|
-
|
|
8
|
+
dynamicSystemContext?: string;
|
|
8
9
|
executionContext?: ExecutionContext;
|
|
9
10
|
estimatedTokens: number;
|
|
10
11
|
contextChars: number;
|
|
@@ -15,10 +16,19 @@ export interface ExecutionContextCoordinatorOptions {
|
|
|
15
16
|
getAccessForSession: (conversationId: string) => {
|
|
16
17
|
userModel: boolean;
|
|
17
18
|
knowledge: boolean;
|
|
18
|
-
|
|
19
|
+
knowledgePolicy: KnowledgeReadPolicy;
|
|
19
20
|
};
|
|
20
21
|
getWorkspaceIdForSession: (conversationId: string) => string;
|
|
21
22
|
getProjectIdForSession: (conversationId: string) => string | undefined;
|
|
23
|
+
ensureMemoryReady: (conversationId: string) => Promise<void>;
|
|
24
|
+
searchExternalMemory: (input: {
|
|
25
|
+
query: string;
|
|
26
|
+
conversationId: string;
|
|
27
|
+
agentId: string;
|
|
28
|
+
workspaceId: string;
|
|
29
|
+
projectId?: string;
|
|
30
|
+
maxResults: number;
|
|
31
|
+
}) => Promise<MemorySearchResult[]>;
|
|
22
32
|
}
|
|
23
33
|
export declare class ExecutionContextCoordinator {
|
|
24
34
|
private readonly options;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { extractProfileAgentId } from "../../config/agent-profile.js";
|
|
2
2
|
import { assembleTaskContext } from "../../tasks/task-context-assembler.js";
|
|
3
3
|
import { recordExecutionContext } from "./audit.js";
|
|
4
|
-
import { prependAgentContext } from "./prepend.js";
|
|
5
4
|
import { extractAgentUserPlainText } from "../memory/user-message-text.js";
|
|
6
5
|
import { buildExecutionContext, fitExecutionContextToChars } from "./execution-context.js";
|
|
7
6
|
//#region src/agent/context/coordinator.ts
|
|
@@ -22,7 +21,6 @@ var ExecutionContextCoordinator = class {
|
|
|
22
21
|
async prepare(userMessage, conversationId, turnId) {
|
|
23
22
|
const empty = () => ({
|
|
24
23
|
traceId: "",
|
|
25
|
-
modelMessage: userMessage,
|
|
26
24
|
estimatedTokens: 0,
|
|
27
25
|
contextChars: 0,
|
|
28
26
|
contextItemCount: 0
|
|
@@ -30,30 +28,48 @@ var ExecutionContextCoordinator = class {
|
|
|
30
28
|
const config = this.options.getConfig();
|
|
31
29
|
const access = this.options.getAccessForSession(conversationId);
|
|
32
30
|
if (!config || !config.userContext.contextPlanning.enabled || !access.userModel && !access.knowledge) return empty();
|
|
31
|
+
await this.options.ensureMemoryReady(conversationId);
|
|
33
32
|
const task = assembleTaskContext(conversationId, extractAgentUserPlainText(userMessage));
|
|
33
|
+
const agentId = extractProfileAgentId(conversationId, config);
|
|
34
|
+
const workspaceId = this.options.getWorkspaceIdForSession(conversationId);
|
|
35
|
+
const projectId = this.options.getProjectIdForSession(conversationId);
|
|
36
|
+
const maxKnowledge = Math.min(config.userContext.contextPlanning.maxKnowledge, task.allocation.maxResults);
|
|
37
|
+
const strategy = config.userContext.knowledgeMemory.searchStrategy;
|
|
38
|
+
const externalResults = access.knowledge && access.knowledgePolicy.contentSources.includes("connector") && strategy !== "local-only" && maxKnowledge > 0 ? await this.options.searchExternalMemory({
|
|
39
|
+
query: task.retrievalQuery,
|
|
40
|
+
conversationId,
|
|
41
|
+
agentId,
|
|
42
|
+
workspaceId,
|
|
43
|
+
projectId,
|
|
44
|
+
maxResults: maxKnowledge
|
|
45
|
+
}) : [];
|
|
46
|
+
const externalReserved = strategy === "external-only" || strategy === "external-first" ? Math.min(maxKnowledge, externalResults.length) : strategy === "fanout" ? Math.min(Math.ceil(maxKnowledge / 2), externalResults.length) : 0;
|
|
47
|
+
const localBudget = strategy === "external-only" ? 0 : maxKnowledge - externalReserved;
|
|
34
48
|
const context = buildExecutionContext({
|
|
35
49
|
query: task.retrievalQuery,
|
|
36
|
-
agentId
|
|
37
|
-
workspaceId
|
|
38
|
-
projectId
|
|
50
|
+
agentId,
|
|
51
|
+
workspaceId,
|
|
52
|
+
projectId,
|
|
39
53
|
conversationId,
|
|
40
54
|
maxAssertions: Math.min(config.userContext.contextPlanning.maxAssertions, task.allocation.maxResults),
|
|
41
|
-
maxKnowledge:
|
|
55
|
+
maxKnowledge: localBudget,
|
|
42
56
|
includeUserModel: access.userModel,
|
|
43
|
-
includeKnowledge: access.knowledge,
|
|
44
|
-
|
|
57
|
+
includeKnowledge: access.knowledge && strategy !== "external-only",
|
|
58
|
+
knowledgePolicy: access.knowledgePolicy
|
|
45
59
|
});
|
|
60
|
+
const remainingKnowledge = Math.max(0, maxKnowledge - context.knowledge.length);
|
|
61
|
+
context.externalKnowledge = externalResults.slice(0, remainingKnowledge);
|
|
46
62
|
this.currentBySession.set(conversationId, context);
|
|
47
63
|
const maxChars = Math.min(config.userContext.contextPlanning.maxChars, task.allocation.maxChars);
|
|
48
64
|
const fitted = fitExecutionContextToChars(context, maxChars);
|
|
49
65
|
const rendered = fitted.rendered;
|
|
50
|
-
const contextItemCount = fitted.context.rules.length + fitted.context.assertions.length + fitted.context.goals.length + fitted.context.priorities.length + fitted.context.knowledge.length;
|
|
66
|
+
const contextItemCount = fitted.context.rules.length + fitted.context.assertions.length + fitted.context.goals.length + fitted.context.priorities.length + fitted.context.knowledge.length + fitted.context.externalKnowledge.length;
|
|
51
67
|
recordExecutionContext(context, {
|
|
52
68
|
turnId,
|
|
53
69
|
conversationId,
|
|
54
70
|
budget: {
|
|
55
71
|
maxAssertions: Math.min(config.userContext.contextPlanning.maxAssertions, task.allocation.maxResults),
|
|
56
|
-
maxKnowledge
|
|
72
|
+
maxKnowledge,
|
|
57
73
|
maxChars
|
|
58
74
|
},
|
|
59
75
|
renderedChars: rendered.length,
|
|
@@ -61,7 +77,7 @@ var ExecutionContextCoordinator = class {
|
|
|
61
77
|
});
|
|
62
78
|
return {
|
|
63
79
|
traceId: context.traceId,
|
|
64
|
-
|
|
80
|
+
dynamicSystemContext: rendered,
|
|
65
81
|
executionContext: context,
|
|
66
82
|
estimatedTokens: Math.ceil(rendered.length / 4),
|
|
67
83
|
contextChars: rendered.length,
|
|
@@ -133,7 +133,7 @@ function buildExecutionContext(request) {
|
|
|
133
133
|
context: request,
|
|
134
134
|
asOf,
|
|
135
135
|
trustedOnly: true,
|
|
136
|
-
|
|
136
|
+
policy: request.knowledgePolicy,
|
|
137
137
|
limit: Math.min(100, maxKnowledge * 2)
|
|
138
138
|
}).map((item) => ({
|
|
139
139
|
item,
|
|
@@ -147,7 +147,8 @@ function buildExecutionContext(request) {
|
|
|
147
147
|
assertions,
|
|
148
148
|
goals: includeUserModel ? loadGoals(request, asOf) : [],
|
|
149
149
|
priorities: includeUserModel ? loadPriorities(request, asOf) : [],
|
|
150
|
-
knowledge
|
|
150
|
+
knowledge,
|
|
151
|
+
externalKnowledge: []
|
|
151
152
|
};
|
|
152
153
|
}
|
|
153
154
|
function getAssertionScope(slotId) {
|
|
@@ -171,6 +172,10 @@ function renderExecutionContext(context) {
|
|
|
171
172
|
if (assumedGoals.length) sections.push(`Possible goals (not yet confirmed):\n${assumedGoals.map((goal) => `- ${goal.title}: ${goal.desiredOutcome}`).join("\n")}`);
|
|
172
173
|
if (context.priorities.length) sections.push(`Current priorities:\n${context.priorities.map((item) => `- ${item.rank}: ${item.targetType}/${item.targetId}`).join("\n")}`);
|
|
173
174
|
if (context.knowledge.length) sections.push(`Relevant knowledge:\n${context.knowledge.map((item) => `- ${item.content}`).join("\n")}`);
|
|
175
|
+
if (context.externalKnowledge.length) sections.push(`Relevant external memory:\n${context.externalKnowledge.map((item) => {
|
|
176
|
+
const citation = item.citation.title ?? item.citation.path ?? item.citation.uri;
|
|
177
|
+
return `- ${item.snippet || item.record.content}${citation ? ` [${citation}]` : ""}`;
|
|
178
|
+
}).join("\n")}`);
|
|
174
179
|
return sections.join("\n\n");
|
|
175
180
|
}
|
|
176
181
|
function fitExecutionContextToChars(context, maxChars) {
|
|
@@ -180,28 +185,43 @@ function fitExecutionContextToChars(context, maxChars) {
|
|
|
180
185
|
assertions: [],
|
|
181
186
|
goals: [],
|
|
182
187
|
priorities: [],
|
|
183
|
-
knowledge: []
|
|
188
|
+
knowledge: [],
|
|
189
|
+
externalKnowledge: []
|
|
184
190
|
};
|
|
185
191
|
const fits = () => buildUserContextBlock(renderExecutionContext(selected)).length <= maxChars;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
192
|
+
const categories = [
|
|
193
|
+
{
|
|
194
|
+
source: context.rules,
|
|
195
|
+
target: selected.rules
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
source: context.assertions,
|
|
199
|
+
target: selected.assertions
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
source: context.goals,
|
|
203
|
+
target: selected.goals
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
source: context.priorities,
|
|
207
|
+
target: selected.priorities
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
source: context.knowledge,
|
|
211
|
+
target: selected.knowledge
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
source: context.externalKnowledge,
|
|
215
|
+
target: selected.externalKnowledge
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
const positions = categories.map(() => 0);
|
|
219
|
+
while (categories.some((category, index) => positions[index] < category.source.length)) for (const [index, category] of categories.entries()) {
|
|
220
|
+
const item = category.source[positions[index]];
|
|
221
|
+
if (item === void 0) continue;
|
|
222
|
+
positions[index] = positions[index] + 1;
|
|
223
|
+
category.target.push(item);
|
|
224
|
+
if (!fits()) category.target.pop();
|
|
205
225
|
}
|
|
206
226
|
return {
|
|
207
227
|
context: selected,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { KnowledgeItem,
|
|
1
|
+
import type { KnowledgeItem, KnowledgeReadPolicy, KnowledgeVisibilityContext } from '../../knowledge-memory/index.js';
|
|
2
2
|
import type { UserAssertion } from '../../user-model/domain.js';
|
|
3
|
+
import type { MemorySearchResult } from '../memory/types.js';
|
|
3
4
|
export type RuleEnforcementLevel = 'prompt' | 'planner' | 'tool_gate';
|
|
4
5
|
export interface ExecutionRule {
|
|
5
6
|
id: string;
|
|
@@ -40,6 +41,7 @@ export interface ExecutionContext {
|
|
|
40
41
|
goals: ExecutionGoal[];
|
|
41
42
|
priorities: ExecutionPriority[];
|
|
42
43
|
knowledge: KnowledgeItem[];
|
|
44
|
+
externalKnowledge: MemorySearchResult[];
|
|
43
45
|
}
|
|
44
46
|
export interface ExecutionContextRequest extends KnowledgeVisibilityContext {
|
|
45
47
|
query: string;
|
|
@@ -48,5 +50,5 @@ export interface ExecutionContextRequest extends KnowledgeVisibilityContext {
|
|
|
48
50
|
maxKnowledge?: number;
|
|
49
51
|
includeUserModel?: boolean;
|
|
50
52
|
includeKnowledge?: boolean;
|
|
51
|
-
|
|
53
|
+
knowledgePolicy?: KnowledgeReadPolicy;
|
|
52
54
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { KnowledgeReadPolicy } from '../../knowledge-memory/index.js';
|
|
2
2
|
export type ExecutionObjective = {
|
|
3
3
|
kind: 'task';
|
|
4
4
|
id: string;
|
|
@@ -26,5 +26,5 @@ export declare function resolveExecutionScope(conversationId: string): Execution
|
|
|
26
26
|
export declare function formatCurrentWorkForPrompt(scope: ExecutionScope): string | undefined;
|
|
27
27
|
export declare function buildExecutionScopeContextForPrompt(conversationId: string, options?: {
|
|
28
28
|
includeKnowledge?: boolean;
|
|
29
|
-
|
|
29
|
+
knowledgePolicy?: KnowledgeReadPolicy;
|
|
30
30
|
}): string | undefined;
|
|
@@ -82,7 +82,7 @@ function buildExecutionScopeContextForPrompt(conversationId, options = {}) {
|
|
|
82
82
|
return [buildActiveProjectContextForPrompt(conversationId, {
|
|
83
83
|
knowledgeQuery: scope.objective?.objective,
|
|
84
84
|
includeKnowledge: options.includeKnowledge,
|
|
85
|
-
|
|
85
|
+
knowledgePolicy: options.knowledgePolicy
|
|
86
86
|
}), formatCurrentWorkForPrompt(scope)].filter((section) => Boolean(section?.trim())).join("\n\n") || void 0;
|
|
87
87
|
}
|
|
88
88
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Project } from '../../projects/types.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type KnowledgeReadPolicy } from '../../knowledge-memory/index.js';
|
|
3
3
|
export interface ProjectTaskContext {
|
|
4
4
|
title: string;
|
|
5
5
|
state: string;
|
|
@@ -8,7 +8,7 @@ export interface ProjectTaskContext {
|
|
|
8
8
|
export declare function buildActiveProjectContextForPrompt(conversationId: string, options?: {
|
|
9
9
|
knowledgeQuery?: string;
|
|
10
10
|
includeKnowledge?: boolean;
|
|
11
|
-
|
|
11
|
+
knowledgePolicy?: KnowledgeReadPolicy;
|
|
12
12
|
}): string | undefined;
|
|
13
13
|
export declare function formatActiveProjectContextForPrompt(input: {
|
|
14
14
|
project: Project;
|
|
@@ -4,7 +4,7 @@ import { TaskReadModelProjector } from "../../tasks/task-read-model-projector.js
|
|
|
4
4
|
import { LocalAppStore } from "../../local-apps/store.js";
|
|
5
5
|
import { ProjectStore } from "../../projects/project-store.js";
|
|
6
6
|
import { getProjectForSession, getProjectWorkspacePathForSession } from "../../projects/workspace.js";
|
|
7
|
-
import {
|
|
7
|
+
import { knowledgeItemAllowed, listKnowledgeItems, searchKnowledgeItems } from "../../knowledge-memory/repository.js";
|
|
8
8
|
import "../../knowledge-memory/index.js";
|
|
9
9
|
//#region src/agent/context/project-context.ts
|
|
10
10
|
const MAX_TEXT = 1200;
|
|
@@ -59,7 +59,7 @@ function buildActiveProjectContextForPrompt(conversationId, options = {}) {
|
|
|
59
59
|
conversationId
|
|
60
60
|
},
|
|
61
61
|
trustedOnly: true,
|
|
62
|
-
|
|
62
|
+
policy: options.knowledgePolicy,
|
|
63
63
|
limit: MAX_RELEVANT_KNOWLEDGE
|
|
64
64
|
}) : [],
|
|
65
65
|
recent: listKnowledgeItems({
|
|
@@ -69,7 +69,7 @@ function buildActiveProjectContextForPrompt(conversationId, options = {}) {
|
|
|
69
69
|
id: project.id
|
|
70
70
|
},
|
|
71
71
|
limit: 500
|
|
72
|
-
}).filter((item) => item.originClass !== "untrusted").filter((item) => !options.
|
|
72
|
+
}).filter((item) => item.originClass !== "untrusted").filter((item) => !options.knowledgePolicy || knowledgeItemAllowed(item, options.knowledgePolicy)).slice(0, MAX_RECENT_KNOWLEDGE)
|
|
73
73
|
}),
|
|
74
74
|
localApp: localApp ? {
|
|
75
75
|
extensionId: localApp.extensionId,
|
|
@@ -8,6 +8,7 @@ export type RunEmbeddedForSessionParams = {
|
|
|
8
8
|
conversationId: string;
|
|
9
9
|
runId?: string;
|
|
10
10
|
userMessage: AgentMessage;
|
|
11
|
+
dynamicSystemContext?: string;
|
|
11
12
|
llmImages?: import('@earendil-works/pi-ai').ImageContent[];
|
|
12
13
|
sessionStore: SessionStore;
|
|
13
14
|
agentManager: AgentInstanceGateway;
|
|
@@ -4,6 +4,7 @@ import { parseTurnOutcome } from "../../../packages/gateway-contract/src/turn-ou
|
|
|
4
4
|
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
5
5
|
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
6
6
|
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
7
|
+
import { appendDynamicPromptSection } from "../prompt/cache-boundary.js";
|
|
7
8
|
import { runWithEmbeddedExecutionSession } from "./execution-context.js";
|
|
8
9
|
import { resolveAgentTurnTimeoutMs } from "../orchestration/run-agent-turn-with-timeout.js";
|
|
9
10
|
import { resolvePromptCachePolicy } from "../../providers/prompt-cache-plan.js";
|
|
@@ -71,6 +72,11 @@ async function runEmbeddedTurnForSession(params) {
|
|
|
71
72
|
ok: false,
|
|
72
73
|
errorMessage: "aborted"
|
|
73
74
|
};
|
|
75
|
+
await agentManager.ensureMemoryReadyForSession?.(conversationId);
|
|
76
|
+
if (supervisor.signal.aborted) return {
|
|
77
|
+
ok: false,
|
|
78
|
+
errorMessage: "aborted"
|
|
79
|
+
};
|
|
74
80
|
const agent = agentManager.getOrCreateAgent(conversationId);
|
|
75
81
|
const mm = modelManager;
|
|
76
82
|
const configuredModelRef = String(mm.getModelForSession(conversationId));
|
|
@@ -100,7 +106,7 @@ async function runEmbeddedTurnForSession(params) {
|
|
|
100
106
|
agentManager.setModelForSession(conversationId, modelRef);
|
|
101
107
|
const tools = agent.state.tools;
|
|
102
108
|
const turnPolicy = agentManager.createAgentTurnPolicy(conversationId);
|
|
103
|
-
const systemPrompt = [agent.state.systemPrompt ?? "", params.presentation === "voice" ? voicePresentationPrompt : ""].filter(Boolean).join("\n\n");
|
|
109
|
+
const systemPrompt = appendDynamicPromptSection([agent.state.systemPrompt ?? "", params.presentation === "voice" ? voicePresentationPrompt : ""].filter(Boolean).join("\n\n"), params.dynamicSystemContext ?? "");
|
|
104
110
|
const thinkingLevel = params.thinkingOverride ?? agent.state.thinkingLevel;
|
|
105
111
|
const workspaceDir = agentManager.getResolvedWorkspaceForSession(conversationId);
|
|
106
112
|
const promptCachePolicy = resolvePromptCachePolicy(config ? resolveEffectiveAgentProfileForSession(config, conversationId).config.runtime.promptCache : void 0);
|
|
@@ -24,6 +24,8 @@ export declare function buildTranscriptUserMessage(opts: {
|
|
|
24
24
|
modelRef: string;
|
|
25
25
|
config: Config | undefined;
|
|
26
26
|
agentManager: AgentInstanceGateway;
|
|
27
|
+
/** Keep these attachments in transcript metadata without exposing read_media hints to the LLM. */
|
|
28
|
+
suppressMediaPromptUris?: ReadonlySet<string>;
|
|
27
29
|
}): Promise<TranscriptUserMessage>;
|
|
28
30
|
/** Hydrate images from media store for the current LLM prompt. */
|
|
29
31
|
export declare function hydrateUserTurnForLlm(opts: {
|
|
@@ -58,8 +58,8 @@ async function readImageBase64FromRef(ref) {
|
|
|
58
58
|
mimeType: prepared.mimeType
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
function appendMediaAttachedLines(textParts, media) {
|
|
62
|
-
for (const ref of media) if (!isImageInboundAttachment(ref)) textParts.push([
|
|
61
|
+
function appendMediaAttachedLines(textParts, media, suppressMediaPromptUris) {
|
|
62
|
+
for (const ref of media) if (!isImageInboundAttachment(ref) && !suppressMediaPromptUris?.has(ref.uri)) textParts.push([
|
|
63
63
|
`[media attached: ${ref.name} (${ref.mimeType}, ${ref.size} bytes)]`,
|
|
64
64
|
`xopc-media-uri:${ref.uri}`,
|
|
65
65
|
`xopc-media-path:${ref.path}`,
|
|
@@ -85,7 +85,7 @@ async function buildTranscriptUserMessage(opts) {
|
|
|
85
85
|
const textParts = [];
|
|
86
86
|
if (expandedText) textParts.push(expandedText);
|
|
87
87
|
const strategy = resolveImageHandlingStrategy(opts.modelRef);
|
|
88
|
-
appendMediaAttachedLines(textParts, prepared.filter((m) => !isImageInboundAttachment(m)));
|
|
88
|
+
appendMediaAttachedLines(textParts, prepared.filter((m) => !isImageInboundAttachment(m)), opts.suppressMediaPromptUris);
|
|
89
89
|
if (imageRefs.length > 0 && strategy !== "native") {
|
|
90
90
|
const images = await Promise.all(imageRefs.map((ref) => readImageBase64FromRef(ref)));
|
|
91
91
|
const agentId = opts.config ? extractProfileAgentId(opts.conversationId, opts.config) : void 0;
|
|
@@ -95,6 +95,7 @@ var InboundLoop = class {
|
|
|
95
95
|
...sessionMetadata?.transcriptId ? { transcriptId: sessionMetadata.transcriptId } : {}
|
|
96
96
|
});
|
|
97
97
|
await this.cfg.sessionContextManager.runWith(sessionContext, async () => {
|
|
98
|
+
await this.cfg.agentManager.ensureMemoryReadyForSession?.(sessionContext.conversationId);
|
|
98
99
|
this.cfg.agentManager.getOrCreateAgent(sessionContext.conversationId);
|
|
99
100
|
this.cfg.setupSessionEventHandling(sessionContext.conversationId);
|
|
100
101
|
await this.cfg.sessionLifecycleManager.startSession(sessionContext);
|
|
@@ -106,13 +106,14 @@ var TurnDispatcher = class {
|
|
|
106
106
|
sessionConfigStore: c.sessionConfigStore,
|
|
107
107
|
commandHandler: c.commandHandler,
|
|
108
108
|
prepareInboundAttachments: c.prepareInboundAttachments,
|
|
109
|
-
buildTranscriptUserMessage: async (text, prepared, sk) => buildDirectUserMessageContent({
|
|
109
|
+
buildTranscriptUserMessage: async (text, prepared, sk, options) => buildDirectUserMessageContent({
|
|
110
110
|
content: text,
|
|
111
111
|
attachments: prepared,
|
|
112
112
|
conversationId: sk,
|
|
113
113
|
config: c.requireConfig(),
|
|
114
114
|
agentManager: c.agentManager,
|
|
115
|
-
modelManager: c.modelManager
|
|
115
|
+
modelManager: c.modelManager,
|
|
116
|
+
suppressMediaPromptUris: options?.suppressMediaPromptUris
|
|
116
117
|
}),
|
|
117
118
|
recordTaskReviewStreamHint: (sk, o) => c.sessionState.recordTaskReviewStreamHint(sk, o),
|
|
118
119
|
enqueueProvisionalSessionTitle: (sk, userText) => {
|
|
@@ -128,7 +129,6 @@ var TurnDispatcher = class {
|
|
|
128
129
|
sourceContextResolver: c.sourceContextResolver,
|
|
129
130
|
maybeEmitWebchatTts: (sk, hadVoice) => maybeEmitWebchatTts({
|
|
130
131
|
config: c.getConfig(),
|
|
131
|
-
sessionStore: c.sessionStore,
|
|
132
132
|
getLastAssistantPlainText: (conversationId) => c.sessionState.getLastAssistantText(conversationId) ?? c.agentManager.getLastAssistantContent(conversationId) ?? "",
|
|
133
133
|
log: this.log
|
|
134
134
|
}, sk, hadVoice),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { terminateProcess } from "../../process/kill-tree.js";
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { getDefaultEnvironment } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
4
4
|
import process from "node:process";
|
|
@@ -87,7 +87,10 @@ var XopcStdioClientTransport = class {
|
|
|
87
87
|
} catch {}
|
|
88
88
|
await Promise.race([closePromise, delay(CLOSE_TIMEOUT_MS)]);
|
|
89
89
|
if (processToClose.exitCode === null && processToClose.pid) {
|
|
90
|
-
|
|
90
|
+
await terminateProcess(processToClose, {
|
|
91
|
+
tree: true,
|
|
92
|
+
detached: process.platform !== "win32"
|
|
93
|
+
});
|
|
91
94
|
await Promise.race([closePromise, delay(CLOSE_TIMEOUT_MS)]);
|
|
92
95
|
}
|
|
93
96
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { listKnowledgeItems,
|
|
1
|
+
import { listKnowledgeItems, transitionKnowledgeStatus, writeKnowledgeItem } from "../../knowledge-memory/repository.js";
|
|
2
2
|
import "../../knowledge-memory/index.js";
|
|
3
3
|
import { resolveMemorySessionKind } from "./turn-provenance.js";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -146,7 +146,12 @@ function promoteCompactionLedger(input) {
|
|
|
146
146
|
result.episodicRecordIds.push(episode.item.id);
|
|
147
147
|
if (!(active && input.audit.status === "passed" && sessionKind === "interactive" && originClass === "agent" && !classified.derivedFromRecalledContext && DURABLE_KINDS.has(item.kind))) {
|
|
148
148
|
const existingDurable = !active ? listKnowledgeItems({ limit: 2e3 }).find((entry) => entry.canonicalKey === `durable:${item.kind}:${stableId("fact", item.text)}`) : void 0;
|
|
149
|
-
if (existingDurable?.sourceConversationId === input.conversationId)
|
|
149
|
+
if (existingDurable?.sourceConversationId === input.conversationId) transitionKnowledgeStatus({
|
|
150
|
+
id: existingDurable.id,
|
|
151
|
+
status: "archived",
|
|
152
|
+
actor: "runtime",
|
|
153
|
+
reason: "The source session no longer supports this durable memory."
|
|
154
|
+
});
|
|
150
155
|
result.rejectedRecordIds.push(episode.item.id);
|
|
151
156
|
continue;
|
|
152
157
|
}
|
|
@@ -19,6 +19,7 @@ function resolveMemoryManagerOptions(config) {
|
|
|
19
19
|
const providerRouting = config.userContext.knowledgeMemory;
|
|
20
20
|
return {
|
|
21
21
|
searchStrategy: providerRouting.searchStrategy,
|
|
22
|
+
searchTimeoutMs: providerRouting.searchTimeoutMs,
|
|
22
23
|
writeStrategy: providerRouting.writeStrategy,
|
|
23
24
|
writePolicy: {
|
|
24
25
|
allowExternalWrites: providerRouting.allowExternalWrites,
|
|
@@ -14,6 +14,7 @@ export interface MemoryManagerOptions extends MemoryRoutingOptions {
|
|
|
14
14
|
loadProviders?: () => Promise<MemoryProvider[]>;
|
|
15
15
|
writePolicy?: MemoryWritePolicy;
|
|
16
16
|
memoryRuntime?: MemoryRuntime;
|
|
17
|
+
searchTimeoutMs?: number;
|
|
17
18
|
}
|
|
18
19
|
export interface MemoryWritePolicy {
|
|
19
20
|
allowExternalWrites?: boolean;
|
|
@@ -27,7 +28,10 @@ export declare class MemoryManager {
|
|
|
27
28
|
private readonly loadProviders?;
|
|
28
29
|
private readonly writePolicy;
|
|
29
30
|
private pluginProvidersLoaded;
|
|
31
|
+
private pluginProvidersPromise?;
|
|
32
|
+
private readonly sessionInitializations;
|
|
30
33
|
private readonly memoryRuntime?;
|
|
34
|
+
private readonly searchTimeoutMs;
|
|
31
35
|
private readonly sessionContexts;
|
|
32
36
|
constructor(options?: MemoryManagerOptions);
|
|
33
37
|
addProvider(provider: MemoryProvider): void;
|
|
@@ -48,6 +52,8 @@ export declare class MemoryManager {
|
|
|
48
52
|
}>;
|
|
49
53
|
handleToolCall(toolName: string, args: Record<string, unknown>): Promise<string>;
|
|
50
54
|
search(request: MemorySearchRequest): Promise<MemorySearchResult[]>;
|
|
55
|
+
searchExternal(request: MemorySearchRequest): Promise<MemorySearchResult[]>;
|
|
56
|
+
private searchProviders;
|
|
51
57
|
read(request: MemoryReadRequest): Promise<MemoryReadResult | null>;
|
|
52
58
|
get(id: string): Promise<MemoryRecord | null>;
|
|
53
59
|
list(request: MemoryListRequest): Promise<MemoryRecord[]>;
|