@xopcai/xopc 0.0.188 → 0.0.189
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 +1 -1
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store--QoUGhiS.js → activity-store-DTFKTPs8.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B0yweLNQ.js → agent-avatar-dicebear-DqO25Qe5.js} +1 -1
- package/dist/gateway/static/root/assets/agents-BvdqdER9.js +2 -0
- package/dist/gateway/static/root/assets/{api-5laWqfiE.js → api-DWeXfwVU.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BXJ8Jiv_.js → app-management-settings-panel-BRpV8PXG.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DG9n9D1M.js → appearance-settings-3ntKM9nQ.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-nKLsfy6C.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Ceh5qrZf.js → archive-plugin-Df7Ycj_7.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-jFW7uYf7.js → attachment-load-UHgfZYtj.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Dh5bdZiN.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-XDlkI1r4.js → binary-plugins-BJah99wE.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-kyKc2IhE.js → block-editor-DNlY5KqF.js} +46 -46
- package/dist/gateway/static/root/assets/browser-settings-page-CRJ_nAuh.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BJa5Iz_v.js → browser-workflow-inputs-vyUfdzAd.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CTQQOsn5.js → browser-workflows-page-C1cKZjx-.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DeQR5BZt.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-Dn-7MMEo.js → capability-presets-api-D7tkhDMv.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-D7uK3q1p.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-BgIkWq01.js → channel-recipient-api-BGG2kpJB.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Bw6Dniyq.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-BrUTz4uU.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-TRr9ybf6.js → connector-logo-8YU53RUT.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-k9tMiOL5.js +2 -0
- package/dist/gateway/static/root/assets/{desktop-pet-CSwd00CV.js → desktop-pet-BUuBEJuP.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CuNQvHGu.js → desktop-pet-settings-BGfVIJM3.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-ct0n5Rje.js → directory-picker-path-field-DrQFfHH_.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BeRBuMUU.js → extension-debug-page-CEnIFOX-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DbK-Cwao.js → extension-page-CCqHbexs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-C9ag5tb5.js → extension-settings-page-DEZw_7zN.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CC7EvEFp.js → gateway-config-api-CgUE2Ii1.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-Dg8qCiIp.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B2DmdlwO.js → gateway-startup-retry-DxhKNiCF.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-fl1oC_-5.js → heartbeat-settings-27tRzDEo.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-VA511kMr.js +3 -0
- package/dist/gateway/static/root/assets/{image-generation-api-GMTaS6eI.js → image-generation-api-DCFdc-HD.js} +1 -1
- package/dist/gateway/static/root/assets/index-BvR-i-m6.js +216 -0
- package/dist/gateway/static/root/assets/index-zybP34zk.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DhGYddbI.js → keyboard-shortcuts-settings-Bf2VLtXW.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CaJq4-wV.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CmnrBmWi.js → local-apps-page-Ca1RuI13.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-D6hs74o5.js → locale-store-DUW5YE3R.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-BLTCg69e.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-B3Eop1zn.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-split-CZaBPOVn.js → markdown-split-BGOYjgnM.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CiKvSgCv.js → media-plugins-CT0txyM4.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CMjnbdbn.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-Bisbzqlz.js → notes-page-DfKgAe78.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-Bp1w9UM1.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-BxlwhAbH.js → page-tabs-DNrbCgmC.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-RM8wXxfT.js → preview-open-alternatives-BTqViDOR.js} +1 -1
- package/dist/gateway/static/root/assets/product-delivery-tRr-7IxY.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-DdBlibek.js → product-open-page-C_2L4_Iu.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CZmbPDQN.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-D5pzqfm5.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CC-XhVGI.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-BDKbpmXv.js → schema-form-BFLfkDGG.js} +1 -1
- package/dist/gateway/static/root/assets/{schemas-C6onAggk.js → schemas-zIBW3wiV.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-B2eTLVDV.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CRuZ_bl0.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-zxo5ZGOu.js → settings-form-section-C4GXGeA4.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DgIp8_S6.js → settings-loading-skeleton-C9a-EbTZ.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-DI9qDH5x.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-97LmwrzC.js → settings-page-layout-D-LWQdI5.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CJwmPvgs.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BH7i3g1S.js → share-preview-page-BKSMG9r5.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-YzSDS4G_.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CwOo8zZk.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-xd1cgSGN.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-s-a5WV9j.js → skills-page.utils-zsz2HIlZ.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BxjeMT5k.js → system-settings-panel-IWNDBI1O.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BahycnfW.js → task-detail-page-CgtK02kP.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BRxdsmic.js → theme-store-BkJe7UDo.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-CstQ___Y.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-39MjwPSq.js → typed-models-lib-C07LGthO.js} +1 -1
- package/dist/gateway/static/root/assets/{use-save-bar-registration-5aVSjTjO.js → use-save-bar-registration-CQYE0l6z.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-BnQAWS_B.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-XU-7sBSg.js → voice-api-key-field-Boue1D46.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CJqu8UHq.js → work-discovery-overlay-bbmvCmc8.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CAszL1y8.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DXtg8Qxl.js → workflow-run-setup-panel-DlHv-GZC.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DxGzo3-x.js +11 -0
- package/dist/gateway/static/root/index.html +9 -9
- package/dist/package.js +1 -1
- package/dist/packages/endpoint-tools-protocol/src/index.js +184 -0
- package/dist/packages/realtime-client/src/index.js +199 -0
- package/dist/packages/realtime-protocol/src/index.js +83 -0
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/background-review/prompts.d.ts +1 -1
- package/dist/src/agent/background-review/prompts.js +3 -1
- package/dist/src/agent/background-review/run-background-review.d.ts +2 -0
- package/dist/src/agent/background-review/run-background-review.js +5 -2
- package/dist/src/agent/client-error-format.d.ts +1 -1
- package/dist/src/agent/client-error-format.js +1 -1
- package/dist/src/agent/external-tools/endpoint-provider.d.ts +17 -0
- package/dist/src/agent/external-tools/endpoint-provider.js +93 -0
- package/dist/src/agent/external-tools/gateway-tools.js +1 -1
- package/dist/src/agent/external-tools/index.d.ts +4 -5
- package/dist/src/agent/external-tools/index.js +8 -2
- package/dist/src/agent/external-tools/types.d.ts +8 -1
- package/dist/src/agent/external-tools/types.js +2 -1
- package/dist/src/agent/inbound/inbound-loop.js +4 -0
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +9 -8
- package/dist/src/agent/inbound/turn-dispatcher.js +13 -11
- package/dist/src/agent/messaging/command-handler.d.ts +2 -2
- package/dist/src/agent/messaging/command-handler.js +3 -3
- package/dist/src/agent/service/async-queue.d.ts +1 -1
- package/dist/src/agent/service/async-queue.js +1 -1
- package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +1 -1
- package/dist/src/agent/service/process-direct-one-shot.d.ts +3 -1
- package/dist/src/agent/service/process-direct-one-shot.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.d.ts +7 -5
- package/dist/src/agent/service/process-direct-streaming.js +5 -5
- package/dist/src/agent/service.d.ts +1 -1
- package/dist/src/agent/service.js +6 -4
- package/dist/src/agent/service.types.d.ts +2 -0
- package/dist/src/agent/session/index.d.ts +1 -1
- package/dist/src/agent/session/session-context.d.ts +2 -0
- package/dist/src/agent/session/session-context.js +4 -0
- package/dist/src/agent/session/session-state-bag.d.ts +4 -4
- package/dist/src/agent/session/session-state-bag.js +1 -1
- package/dist/src/agent/streaming/reasoning-visibility.d.ts +6 -0
- package/dist/src/agent/streaming/{reasoning-visibility-sse.js → reasoning-visibility.js} +3 -6
- package/dist/src/agent/tools/factory.d.ts +4 -0
- package/dist/src/agent/tools/factory.js +1 -0
- package/dist/src/automations/domain/types.d.ts +2 -1
- package/dist/src/automations/domain/validation.d.ts +1 -1
- package/dist/src/automations/service/action-executor.js +4 -1
- package/dist/src/channels/pairing/pairing-challenge.d.ts +1 -1
- package/dist/src/channels/pairing/pairing-challenge.js +1 -1
- package/dist/src/cli/commands/agent/stream-renderer.js +4 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/config/rules.js +0 -5
- package/dist/src/config/schema.d.ts +3 -5
- package/dist/src/config/schema.js +0 -3
- package/dist/src/config/web-patch.js +0 -1
- package/dist/src/endpoint-tools/auth.d.ts +20 -0
- package/dist/src/endpoint-tools/auth.js +51 -0
- package/dist/src/endpoint-tools/index.d.ts +5 -0
- package/dist/src/endpoint-tools/index.js +6 -0
- package/dist/src/endpoint-tools/invocation-service.d.ts +68 -0
- package/dist/src/endpoint-tools/invocation-service.js +190 -0
- package/dist/src/endpoint-tools/policy.d.ts +10 -0
- package/dist/src/endpoint-tools/policy.js +18 -0
- package/dist/src/endpoint-tools/registry.d.ts +45 -0
- package/dist/src/endpoint-tools/registry.js +121 -0
- package/dist/src/endpoint-tools/runtime.d.ts +23 -0
- package/dist/src/endpoint-tools/runtime.js +86 -0
- package/dist/src/endpoint-tools/upload-service.d.ts +41 -0
- package/dist/src/endpoint-tools/upload-service.js +103 -0
- package/dist/src/extensions/types/hooks.d.ts +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +0 -1
- package/dist/src/gateway/clarify-bridge.d.ts +5 -4
- package/dist/src/gateway/clarify-bridge.js +3 -4
- package/dist/src/gateway/heartbeat/service.js +4 -1
- package/dist/src/gateway/hono/app.js +1 -5
- package/dist/src/gateway/hono/index.d.ts +0 -1
- package/dist/src/gateway/hono/index.js +1 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -2
- package/dist/src/gateway/hono/lib/config-payload.js +0 -1
- package/dist/src/gateway/hono/middleware/auth.js +3 -5
- package/dist/src/gateway/hono/routes/agent-stream.js +49 -6
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +2 -2
- package/dist/src/gateway/hono/routes/config-patch/gateway.js +0 -19
- package/dist/src/gateway/hono/routes/deps.d.ts +0 -2
- package/dist/src/gateway/hono/routes/endpoint-tools.d.ts +3 -0
- package/dist/src/gateway/hono/routes/endpoint-tools.js +196 -0
- package/dist/src/gateway/hono/routes/index.js +4 -0
- package/dist/src/gateway/hono/routes/logs.js +0 -4
- package/dist/src/gateway/hono/routes/public-gateway.js +2 -2
- package/dist/src/gateway/hono/routes/realtime.d.ts +3 -0
- package/dist/src/gateway/hono/routes/realtime.js +35 -0
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/hono/routes/you.d.ts +0 -9
- package/dist/src/gateway/hono/routes/you.js +78 -125
- package/dist/src/gateway/index.d.ts +1 -1
- package/dist/src/gateway/index.js +1 -2
- package/dist/src/gateway/protocol.d.ts +1 -7
- package/dist/src/gateway/security/index.js +1 -1
- package/dist/src/gateway/security/operator-scopes.js +1 -1
- package/dist/src/gateway/server.js +4 -4
- package/dist/src/gateway/service/agent-runner.d.ts +11 -9
- package/dist/src/gateway/service/agent-runner.js +18 -18
- package/dist/src/gateway/service/config-coordinator.d.ts +2 -2
- package/dist/src/gateway/service/run-gateway-agent.d.ts +4 -3
- package/dist/src/gateway/service/run-gateway-agent.js +13 -13
- package/dist/src/gateway/service/session-input-coordinator.d.ts +3 -0
- package/dist/src/gateway/service/session-input-coordinator.js +4 -2
- package/dist/src/gateway/service/types.d.ts +0 -5
- package/dist/src/gateway/service.d.ts +7 -6
- package/dist/src/gateway/service.js +43 -26
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/mcp/channel-bridge.d.ts +6 -9
- package/dist/src/mcp/channel-bridge.js +48 -76
- package/dist/src/mcp/channel-server.js +2 -6
- package/dist/src/realtime/broker.d.ts +30 -0
- package/dist/src/realtime/broker.js +97 -0
- package/dist/src/realtime/runtime.d.ts +20 -0
- package/dist/src/realtime/runtime.js +258 -0
- package/dist/src/realtime/tickets.d.ts +15 -0
- package/dist/src/realtime/tickets.js +38 -0
- package/dist/src/realtime/writer.d.ts +15 -0
- package/dist/src/realtime/writer.js +78 -0
- package/dist/src/share/share-config.js +0 -1
- package/dist/src/share/site-share-config.js +0 -1
- package/dist/src/storage/sqlite/endpoint-principal-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/endpoint-principal-repository.js +54 -0
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.d.ts +25 -0
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +42 -0
- package/dist/src/storage/sqlite/index.d.ts +2 -0
- package/dist/src/storage/sqlite/index.js +3 -1
- package/dist/src/storage/sqlite/migrations/109_endpoint_principals.sql +14 -0
- package/dist/src/storage/sqlite/migrations/110_session_input_origin.sql +43 -0
- package/dist/src/storage/sqlite/migrations/111_endpoint_tool_invocations.sql +18 -0
- package/dist/src/storage/sqlite/migrations/112_endpoint_instance_bindings.sql +8 -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/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/session-input-repository.js +5 -3
- package/dist/src/tasks/home-query-service.d.ts +1 -1
- package/dist/src/tui/backends/embedded-backend.js +5 -2
- package/dist/src/tui/backends/{gateway-sse-backend.d.ts → gateway-realtime-backend.d.ts} +13 -10
- package/dist/src/tui/backends/{gateway-sse-backend.js → gateway-realtime-backend.js} +114 -151
- package/dist/src/tui/tui-agent-events.d.ts +0 -1
- package/dist/src/tui/tui-agent-events.js +2 -15
- package/dist/src/tui/tui-backend.d.ts +4 -4
- package/dist/src/tui/tui-run-state.js +0 -4
- package/dist/src/tui/tui-types.d.ts +2 -9
- package/dist/src/tui/tui-types.js +0 -1
- package/dist/src/tui/tui.js +5 -5
- package/dist/src/tunnel/gateway-lifecycle.d.ts +1 -1
- package/dist/src/tunnel/gateway-lifecycle.js +1 -1
- package/dist/src/user-context/actionableInsights.d.ts +14 -0
- package/dist/src/user-context/actionableInsights.js +34 -0
- package/dist/src/user-context/manual-understanding.js +6 -1
- package/dist/src/user-context/projection.d.ts +1 -1
- package/dist/src/user-context/understandingQuality.d.ts +5 -0
- package/dist/src/user-context/understandingQuality.js +44 -0
- package/dist/src/utils/logger/log-stream.d.ts +3 -10
- package/dist/src/utils/logger/log-stream.js +2 -73
- package/dist/src/utils/logger/pino-record.d.ts +1 -1
- package/dist/src/utils/logger/streams.js +1 -1
- package/package.json +6 -3
- package/dist/gateway/static/root/assets/agents-C6OV-gMm.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-Ci14lDeO.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Q1xmb4Rh.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-DbowrHXD.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DoZPFdKF.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Bt8Hnx0h.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-Bpsebsru.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DFmdYRE5.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-Tg5kl22i.js +0 -2
- package/dist/gateway/static/root/assets/gateway-settings-9g8uIry9.js +0 -1
- package/dist/gateway/static/root/assets/home-page-Bao9jq_z.js +0 -3
- package/dist/gateway/static/root/assets/index-Cl5n1f_U.css +0 -1
- package/dist/gateway/static/root/assets/index-OJgiMh07.js +0 -223
- package/dist/gateway/static/root/assets/local-app-workbench-page-B69NvtvH.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-Cq3cABqg.js +0 -7
- package/dist/gateway/static/root/assets/messages-D02NNLCZ.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-BOZfJFhE.js +0 -4
- package/dist/gateway/static/root/assets/product-delivery-C8JbSj5Y.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-TSKFb2tN.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BokeBrTT.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C56anxCX.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-C7TQADrD.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BDOPKeAX.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-BUPSIa9P.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BRg766eW.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DhEAviQ_.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Ct7AV8ls.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DoVuprZm.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-BGk_Tbsj.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-B9K41qmy.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BBVnRHju.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-Bs_tYfst.js +0 -11
- package/dist/src/agent/streaming/reasoning-visibility-sse.d.ts +0 -15
- package/dist/src/gateway/agent-run-relay.d.ts +0 -19
- package/dist/src/gateway/agent-run-relay.js +0 -169
- package/dist/src/gateway/hono/sse.d.ts +0 -53
- package/dist/src/gateway/hono/sse.js +0 -207
- package/dist/src/gateway/service/sse-hub.d.ts +0 -10
- package/dist/src/gateway/service/sse-hub.js +0 -53
- package/dist/src/tui/sse-consumer.d.ts +0 -15
- package/dist/src/tui/sse-consumer.js +0 -73
|
@@ -21,12 +21,12 @@ import { listConnectorCatalog } from "../../../connectors/catalog.js";
|
|
|
21
21
|
import { nextDreamingRunTimes } from "../../../agent/memory/dreaming/schedule.js";
|
|
22
22
|
import { resolveDreamingSettings } from "../../../agent/memory/dreaming/config.js";
|
|
23
23
|
import { readUserProfileFile, writeUserProfileFile } from "../../agents-admin.js";
|
|
24
|
-
import {
|
|
25
|
-
import { defineTaskContract } from "../../../tasks/task-contract-definition.js";
|
|
24
|
+
import { TaskContextRepository } from "../../../tasks/task-context-repository.js";
|
|
26
25
|
import "../../../tasks/index.js";
|
|
27
|
-
import { nextMemoryReviewAt
|
|
26
|
+
import { nextMemoryReviewAt } from "../../../agent/memory/lifecycle.js";
|
|
28
27
|
import { isUserContextMemoryKind, isUserContextRecord, projectPersonalContextSources, projectUserContextRecord, recordsDerivedFromPersonalContextSource } from "../../../user-context/projection.js";
|
|
29
28
|
import { PERSONAL_PLAYBOOK_DISABLED_TAG, PERSONAL_PLAYBOOK_ORDER_PREFIX, PERSONAL_PLAYBOOK_RULE_TAG, patchPersonalPlaybookContextTags, personalPlaybookContext } from "../../../user-context/personal-playbook.js";
|
|
29
|
+
import { INSIGHT_ACCEPTED_TAG, INSIGHT_DISMISSED_TAG, USER_CONFIRMED_MEMORY_TAG, buildActionableInsightSuggestions } from "../../../user-context/actionableInsights.js";
|
|
30
30
|
import { createManualUnderstanding } from "../../../user-context/manual-understanding.js";
|
|
31
31
|
import { resolveDreamingAgentScope } from "../../../agent/memory/dreaming/scope.js";
|
|
32
32
|
import { runDreamingPhase } from "../../../agent/memory/dreaming/runner.js";
|
|
@@ -36,7 +36,6 @@ import { renderUserClaim } from "../../../knowledge/connected-understanding-pipe
|
|
|
36
36
|
import { prepareUserContextImport } from "../../../user-context/import.js";
|
|
37
37
|
import { buildUserProfileSetup, parseUserProfileMarkdown, patchUserProfileMarkdown } from "../../../user-context/profile.js";
|
|
38
38
|
import { buildTaskSourceRecommendations } from "../../../user-context/source-recommendations.js";
|
|
39
|
-
import { randomUUID } from "node:crypto";
|
|
40
39
|
//#region src/gateway/hono/routes/you.ts
|
|
41
40
|
init_agent_scope();
|
|
42
41
|
init_config();
|
|
@@ -54,15 +53,6 @@ const FEEDBACK_RATINGS = new Set([
|
|
|
54
53
|
"outdated",
|
|
55
54
|
"sensitive"
|
|
56
55
|
]);
|
|
57
|
-
const ACTIONABLE_INSIGHT_KINDS = new Set([
|
|
58
|
-
"routine",
|
|
59
|
-
"commitment",
|
|
60
|
-
"long_term_goal",
|
|
61
|
-
"derived_insight",
|
|
62
|
-
"task_lesson"
|
|
63
|
-
]);
|
|
64
|
-
const INSIGHT_ACCEPTED_TAG = "insight-action:accepted";
|
|
65
|
-
const INSIGHT_DISMISSED_TAG = "insight-action:dismissed";
|
|
66
56
|
const PLAYBOOK_IDS = [
|
|
67
57
|
"communication",
|
|
68
58
|
"execution",
|
|
@@ -239,20 +229,6 @@ function buildPersonalPlaybooks(records) {
|
|
|
239
229
|
};
|
|
240
230
|
});
|
|
241
231
|
}
|
|
242
|
-
function buildInsightSuggestions(records) {
|
|
243
|
-
return records.filter((record) => record.status === "active").filter((record) => ACTIONABLE_INSIGHT_KINDS.has(record.kind)).filter((record) => !record.tags?.includes(INSIGHT_ACCEPTED_TAG) && !record.tags?.includes(INSIGHT_DISMISSED_TAG)).filter((record) => {
|
|
244
|
-
const stability = resolveMemoryStability(record);
|
|
245
|
-
return record.explicitness === "explicit" || (record.evidence?.length ?? 0) >= 2 || stability.band === "strong";
|
|
246
|
-
}).sort((left, right) => right.importance - left.importance || Date.parse(right.updatedAt) - Date.parse(left.updatedAt)).slice(0, 5).map((record) => ({
|
|
247
|
-
id: record.id,
|
|
248
|
-
insight: record.content,
|
|
249
|
-
kind: record.kind,
|
|
250
|
-
action: record.kind === "routine" ? "make_repeatable" : record.kind === "task_lesson" || record.kind === "derived_insight" ? "add_playbook" : "start_progress",
|
|
251
|
-
evidenceCount: record.evidence?.length ?? 0,
|
|
252
|
-
confidence: record.confidence,
|
|
253
|
-
sourceName: record.source.provider ?? "local"
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
256
232
|
function buildRoutineAutomationDraftHref(record) {
|
|
257
233
|
return `/automations?${new URLSearchParams({
|
|
258
234
|
draft: record.content,
|
|
@@ -350,13 +326,13 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
350
326
|
learningJobs: listConnectorLearningJobs({ limit: 500 }),
|
|
351
327
|
claimStatsBySource: listUserClaimStatsBySource()
|
|
352
328
|
});
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
return
|
|
329
|
+
const openTasks = new TaskRepository().list({ limit: 500 }).filter((task) => task.delegateAgentId === agentId && task.phase !== "closed");
|
|
330
|
+
const activeTasks = openTasks.slice(0, 20).map((task) => {
|
|
331
|
+
return {
|
|
356
332
|
id: task.id,
|
|
357
333
|
title: task.title,
|
|
358
334
|
body: task.body
|
|
359
|
-
}
|
|
335
|
+
};
|
|
360
336
|
});
|
|
361
337
|
return c.json({
|
|
362
338
|
scope: {
|
|
@@ -382,7 +358,10 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
382
358
|
return record ? [projectReferenceConsent(consent, record)] : [];
|
|
383
359
|
}),
|
|
384
360
|
conflictGroups: buildConflictGroups(allUserContextRecords),
|
|
385
|
-
insights:
|
|
361
|
+
insights: buildActionableInsightSuggestions(records, openTasks.map((task) => [task.title, task.body].filter(Boolean).join("\n"))).map((insight) => ({
|
|
362
|
+
...insight,
|
|
363
|
+
delegateAgentId: agentId
|
|
364
|
+
})),
|
|
386
365
|
playbooks: buildPersonalPlaybooks(allUserContextRecords),
|
|
387
366
|
sources,
|
|
388
367
|
sourceRecommendations: buildTaskSourceRecommendations(sourceDefinitions, new Set(sourceInstances.map((instance) => instance.connectorId)), activeTasks),
|
|
@@ -615,7 +594,7 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
615
594
|
tags: [...new Set([
|
|
616
595
|
"user-understanding",
|
|
617
596
|
...candidate.tags ?? [],
|
|
618
|
-
|
|
597
|
+
USER_CONFIRMED_MEMORY_TAG
|
|
619
598
|
])],
|
|
620
599
|
evidence: evidence.map((item) => ({
|
|
621
600
|
sourceItemId: item.sourceItemId,
|
|
@@ -766,7 +745,10 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
766
745
|
if (action === "forget") deleteMemoryRecord(id);
|
|
767
746
|
else preserveRecord(record, {
|
|
768
747
|
status: action === "confirm" ? "active" : "rejected",
|
|
769
|
-
...action === "confirm" ? {
|
|
748
|
+
...action === "confirm" ? {
|
|
749
|
+
reviewAfter: nextMemoryReviewAt(record),
|
|
750
|
+
tags: [...new Set([...record.tags ?? [], USER_CONFIRMED_MEMORY_TAG])]
|
|
751
|
+
} : {}
|
|
770
752
|
});
|
|
771
753
|
updatedCount += 1;
|
|
772
754
|
}
|
|
@@ -786,7 +768,8 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
786
768
|
runSqliteWriteTransaction(() => {
|
|
787
769
|
for (const record of group) preserveRecord(record, record.id === winnerId ? {
|
|
788
770
|
status: "active",
|
|
789
|
-
reviewAfter: nextMemoryReviewAt(record)
|
|
771
|
+
reviewAfter: nextMemoryReviewAt(record),
|
|
772
|
+
tags: [...new Set([...record.tags ?? [], USER_CONFIRMED_MEMORY_TAG])]
|
|
790
773
|
} : {
|
|
791
774
|
status: "archived",
|
|
792
775
|
validTo: record.validTo ?? now
|
|
@@ -950,106 +933,74 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
950
933
|
rule: buildPersonalPlaybooks([...all, rolledBack]).find((playbook) => playbook.id === id)?.rules.find((rule) => rule.id === rolledBack.id)
|
|
951
934
|
});
|
|
952
935
|
});
|
|
953
|
-
authenticated.
|
|
936
|
+
authenticated.post("/api/you/insights/:id/apply", deps.strictRateLimitMiddleware, async (c) => {
|
|
954
937
|
const config = deps.service.currentConfig;
|
|
955
938
|
const existing = editableRecord(c.req.param("id"));
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
if (
|
|
960
|
-
preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_DISMISSED_TAG])] });
|
|
961
|
-
return c.json({
|
|
962
|
-
ok: true,
|
|
963
|
-
status: "dismissed"
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
if (action === "complete" && existing.kind === "routine") {
|
|
939
|
+
const suggestion = existing ? buildActionableInsightSuggestions([existing], [])[0] : void 0;
|
|
940
|
+
if (!existing || !suggestion) return c.json({ error: "Insight not found" }, 404);
|
|
941
|
+
if (suggestion.action === "start_progress") return c.json({ error: "Progress insights must be reviewed as task drafts" }, 400);
|
|
942
|
+
if (existing.kind === "routine") {
|
|
967
943
|
preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_ACCEPTED_TAG])] });
|
|
968
944
|
return c.json({
|
|
969
945
|
ok: true,
|
|
970
|
-
status: "
|
|
946
|
+
status: "drafting",
|
|
947
|
+
href: buildRoutineAutomationDraftHref(existing)
|
|
971
948
|
});
|
|
972
949
|
}
|
|
973
|
-
|
|
974
|
-
|
|
950
|
+
upsertMemoryRecord({
|
|
951
|
+
providerId: "local",
|
|
952
|
+
kind: "task_lesson",
|
|
953
|
+
sourceAgentId: selectedAgentId(config),
|
|
954
|
+
content: existing.content,
|
|
955
|
+
source: {
|
|
956
|
+
provider: "local",
|
|
957
|
+
path: "you://insight-proposal"
|
|
958
|
+
},
|
|
959
|
+
confidence: 1,
|
|
960
|
+
tags: [
|
|
961
|
+
"user-understanding",
|
|
962
|
+
USER_CONFIRMED_MEMORY_TAG,
|
|
963
|
+
PERSONAL_PLAYBOOK_RULE_TAG,
|
|
964
|
+
`${PERSONAL_PLAYBOOK_ORDER_PREFIX}1000`
|
|
965
|
+
],
|
|
966
|
+
status: "active",
|
|
967
|
+
sensitivity: existing.sensitivity,
|
|
968
|
+
explicitness: "explicit",
|
|
969
|
+
durability: "durable",
|
|
970
|
+
importance: existing.importance,
|
|
971
|
+
disclosurePolicy: existing.disclosurePolicy,
|
|
972
|
+
evidence: existing.evidence
|
|
973
|
+
});
|
|
974
|
+
preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_ACCEPTED_TAG])] });
|
|
975
|
+
return c.json({
|
|
975
976
|
ok: true,
|
|
976
|
-
status: "
|
|
977
|
-
href: buildRoutineAutomationDraftHref(existing)
|
|
977
|
+
status: "saved"
|
|
978
978
|
});
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
},
|
|
989
|
-
confidence: 1,
|
|
990
|
-
tags: [
|
|
991
|
-
"user-understanding",
|
|
992
|
-
PERSONAL_PLAYBOOK_RULE_TAG,
|
|
993
|
-
`${PERSONAL_PLAYBOOK_ORDER_PREFIX}1000`
|
|
994
|
-
],
|
|
995
|
-
status: "active",
|
|
996
|
-
sensitivity: existing.sensitivity,
|
|
997
|
-
explicitness: "explicit",
|
|
998
|
-
durability: "durable",
|
|
999
|
-
importance: existing.importance,
|
|
1000
|
-
disclosurePolicy: existing.disclosurePolicy,
|
|
1001
|
-
evidence: existing.evidence
|
|
1002
|
-
});
|
|
1003
|
-
preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_ACCEPTED_TAG])] });
|
|
1004
|
-
return c.json({
|
|
1005
|
-
ok: true,
|
|
1006
|
-
status: "saved"
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
const title = existing.content.trim().split(/\r?\n/)[0].slice(0, 72);
|
|
1010
|
-
const uiLocale = body.uiLocale === "zh" ? "zh" : "en";
|
|
1011
|
-
const contract = defineTaskContract(title);
|
|
1012
|
-
const created = new TaskApplicationService().create({
|
|
1013
|
-
idempotencyKey: randomUUID(),
|
|
1014
|
-
title,
|
|
1015
|
-
body: existing.content,
|
|
1016
|
-
priority: "normal",
|
|
1017
|
-
delegateAgentId: selectedAgentId(config),
|
|
1018
|
-
locale: uiLocale,
|
|
1019
|
-
contract: {
|
|
1020
|
-
...contract,
|
|
1021
|
-
acceptancePolicy: "verified_auto",
|
|
1022
|
-
outputDestinations: []
|
|
1023
|
-
},
|
|
1024
|
-
dependencies: [],
|
|
1025
|
-
context: [{
|
|
1026
|
-
targetKind: "memory",
|
|
1027
|
-
targetId: existing.id,
|
|
1028
|
-
role: "input",
|
|
1029
|
-
pinned: true,
|
|
1030
|
-
retrievalPolicy: {},
|
|
1031
|
-
metadata: {}
|
|
1032
|
-
}],
|
|
1033
|
-
authorityGrants: [],
|
|
1034
|
-
activation: {
|
|
1035
|
-
mode: "start",
|
|
1036
|
-
executor: {
|
|
1037
|
-
kind: "agent",
|
|
1038
|
-
agentId: selectedAgentId(config)
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
979
|
+
});
|
|
980
|
+
authenticated.delete("/api/you/insights/:id", deps.strictRateLimitMiddleware, (c) => {
|
|
981
|
+
const existing = editableRecord(c.req.param("id"));
|
|
982
|
+
const suggestion = existing ? buildActionableInsightSuggestions([existing], [])[0] : void 0;
|
|
983
|
+
if (!existing || !suggestion) return c.json({ error: "Insight not found" }, 404);
|
|
984
|
+
preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_DISMISSED_TAG])] });
|
|
985
|
+
return c.json({
|
|
986
|
+
ok: true,
|
|
987
|
+
status: "dismissed"
|
|
1041
988
|
});
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
if (
|
|
989
|
+
});
|
|
990
|
+
authenticated.post("/api/you/insights/:id/complete", deps.strictRateLimitMiddleware, async (c) => {
|
|
991
|
+
const existing = editableRecord(c.req.param("id"));
|
|
992
|
+
const suggestion = existing ? buildActionableInsightSuggestions([existing], [])[0] : void 0;
|
|
993
|
+
if (!existing || suggestion?.action !== "start_progress") return c.json({ error: "Insight not found" }, 404);
|
|
994
|
+
const body = await c.req.json().catch(() => ({}));
|
|
995
|
+
const taskId = typeof body.taskId === "string" ? body.taskId.trim() : "";
|
|
996
|
+
const task = taskId ? new TaskRepository().get(taskId) : null;
|
|
997
|
+
const linked = task && new TaskContextRepository().list(task.id).some((edge) => edge.targetKind === "memory" && edge.targetId === existing.id);
|
|
998
|
+
if (!task || !linked) return c.json({ error: "A linked task draft is required" }, 400);
|
|
1047
999
|
preserveRecord(existing, { tags: [...new Set([...existing.tags ?? [], INSIGHT_ACCEPTED_TAG])] });
|
|
1048
1000
|
return c.json({
|
|
1049
1001
|
ok: true,
|
|
1050
|
-
status:
|
|
1051
|
-
taskId:
|
|
1052
|
-
href: `/tasks/${encodeURIComponent(created.model.task.id)}`
|
|
1002
|
+
status: "saved",
|
|
1003
|
+
taskId: task.id
|
|
1053
1004
|
});
|
|
1054
1005
|
});
|
|
1055
1006
|
authenticated.patch("/api/you/controls", deps.strictRateLimitMiddleware, async (c) => {
|
|
@@ -1160,7 +1111,8 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
1160
1111
|
const action = typeof body.action === "string" ? body.action : "";
|
|
1161
1112
|
if (action === "confirm") return c.json({ understanding: projectUserContextRecord(preserveRecord(existing, {
|
|
1162
1113
|
status: "active",
|
|
1163
|
-
reviewAfter: nextMemoryReviewAt(existing)
|
|
1114
|
+
reviewAfter: nextMemoryReviewAt(existing),
|
|
1115
|
+
tags: [...new Set([...existing.tags ?? [], USER_CONFIRMED_MEMORY_TAG])]
|
|
1164
1116
|
})) });
|
|
1165
1117
|
if (action === "reject") return c.json({ understanding: projectUserContextRecord(preserveRecord(existing, { status: "rejected" })) });
|
|
1166
1118
|
if (action === "update") {
|
|
@@ -1179,7 +1131,8 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
1179
1131
|
tags: [...new Set([
|
|
1180
1132
|
...existing.tags ?? [],
|
|
1181
1133
|
"user-understanding",
|
|
1182
|
-
"explicit-user-correction"
|
|
1134
|
+
"explicit-user-correction",
|
|
1135
|
+
USER_CONFIRMED_MEMORY_TAG
|
|
1183
1136
|
])],
|
|
1184
1137
|
status: "active",
|
|
1185
1138
|
sensitivity: existing.sensitivity,
|
|
@@ -1211,4 +1164,4 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
1211
1164
|
});
|
|
1212
1165
|
}
|
|
1213
1166
|
//#endregion
|
|
1214
|
-
export {
|
|
1167
|
+
export { buildPersonalPlaybooks, buildRoutineAutomationDraftHref, registerYouRoutes };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { GatewayServer, type GatewayServerConfig } from './server.js';
|
|
2
|
-
export { GatewayService, type GatewayChannelStartupPhase1Metrics, type GatewayChannelStartupPhase2Metrics, type GatewayServiceConfig,
|
|
2
|
+
export { GatewayService, type GatewayChannelStartupPhase1Metrics, type GatewayChannelStartupPhase2Metrics, type GatewayServiceConfig, } from './service.js';
|
|
3
3
|
export { acquireGatewayLock, GatewayLockError, type GatewayLockHandle } from './lock.js';
|
|
4
4
|
export { runGatewayLoop, type RunGatewayLoopOptions } from './run-loop.js';
|
|
5
5
|
export { restartGatewayProcessWithFreshPid, type GatewayRespawnResult } from './respawn.js';
|
|
@@ -8,7 +8,6 @@ import { resolveGatewayListenHost, resolveGatewayListenPlan } from "./listen.js"
|
|
|
8
8
|
import { assertGatewayRuntimeConfig } from "./runtime-config.js";
|
|
9
9
|
import { restartGatewayProcessWithFreshPid } from "./respawn.js";
|
|
10
10
|
import { GatewayService } from "./service.js";
|
|
11
|
-
import { createAgentResumeHandler, createEventsSSEHandler, createSendHandler } from "./hono/sse.js";
|
|
12
11
|
import { createHonoApp } from "./hono/app.js";
|
|
13
12
|
import { GatewayServer } from "./server.js";
|
|
14
13
|
import { GatewayLockError, acquireGatewayLock } from "./lock.js";
|
|
@@ -17,4 +16,4 @@ import { checkPortAvailable, forceFreePortAndWait, listPortListeners, parseLsofO
|
|
|
17
16
|
import { apiError, apiOk } from "./protocol.js";
|
|
18
17
|
import "./hono/index.js";
|
|
19
18
|
import { assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, isInsecurePrivateWsAllowed, isSecureWebSocketUrl } from "./ws-security.js";
|
|
20
|
-
export { GatewayLockError, GatewayServer, GatewayService, acquireGatewayLock, apiError, apiOk, assertGatewayAuthConfigured, assertGatewayRuntimeConfig, assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, buckets, buildDefaultCorsOrigins, checkPortAvailable,
|
|
19
|
+
export { GatewayLockError, GatewayServer, GatewayService, acquireGatewayLock, apiError, apiOk, assertGatewayAuthConfigured, assertGatewayRuntimeConfig, assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, buckets, buildDefaultCorsOrigins, checkPortAvailable, createHonoApp, defaultGatewayBindMode, extractToken, forceFreePortAndWait, isAllInterfacesHost, isContainerEnvironment, isGatewayStrictSecurityEnabled, isInsecurePrivateWsAllowed, isLoopbackHost, isSecureWebSocketUrl, listPortListeners, parseLsofOutput, resolveEffectiveGatewayPort, resolveGatewayAuth, resolveGatewayBindHost, resolveGatewayBindHostSync, resolveGatewayBindMode, resolveGatewayEffectiveHost, resolveGatewayListenHost, resolveGatewayListenPlan, resolveGatewayServiceListenPort, restartGatewayProcessWithFreshPid, runGatewayLoop, validateToken };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Gateway protocol types
|
|
2
|
+
* Gateway HTTP protocol types.
|
|
3
3
|
*
|
|
4
4
|
* All client → server communication uses standard HTTP (POST/GET/PATCH/DELETE).
|
|
5
|
-
* Server → client streaming uses SSE (text/event-stream).
|
|
6
5
|
*/
|
|
7
6
|
export interface ApiResponse<T = unknown> {
|
|
8
7
|
ok: boolean;
|
|
@@ -13,11 +12,6 @@ export interface ApiError {
|
|
|
13
12
|
code: string;
|
|
14
13
|
message: string;
|
|
15
14
|
}
|
|
16
|
-
export interface SSEEvent {
|
|
17
|
-
id: string;
|
|
18
|
-
event: string;
|
|
19
|
-
data: unknown;
|
|
20
|
-
}
|
|
21
15
|
export interface GatewayConfig {
|
|
22
16
|
host: string;
|
|
23
17
|
port: number;
|
|
@@ -2,9 +2,9 @@ import { safeEqualSecret } from "./secret-equal.js";
|
|
|
2
2
|
import { KNOWN_WEAK_GATEWAY_TOKEN_PLACEHOLDERS, assertGatewayAuthNotKnownWeak } from "./known-weak-secrets.js";
|
|
3
3
|
import { auditGatewayConfig, collectGatewayConfigFindings, collectGatewaySecurityFindings, collectGatewayStartupGuardFindings } from "./audit.js";
|
|
4
4
|
import { detectSuspiciousPatterns, wrapExternalContent, wrapWebContent } from "./external-content.js";
|
|
5
|
+
import { createPreauthConnectionBudget, getMaxPreauthConnectionsPerIp } from "./preauth-connection-budget.js";
|
|
5
6
|
import { buildGatewayConsoleCspHeader, computeInlineScriptHashes } from "./csp.js";
|
|
6
7
|
import { checkBrowserOrigin } from "./origin-check.js";
|
|
7
8
|
import { ADMIN_SCOPE, DEFAULT_OPERATOR_SCOPES, KNOWN_OPERATOR_SCOPES, READ_SCOPE, WRITE_SCOPE, authorizeRouteScope, authorizeScope, isOperatorScope, parseScopesHeader } from "./operator-scopes.js";
|
|
8
9
|
import { DEFAULT_GATEWAY_HTTP_TOOL_DENY, filterDangerousHttpTools, isDangerousHttpTool } from "./dangerous-tools.js";
|
|
9
|
-
import { createPreauthConnectionBudget, getMaxPreauthConnectionsPerIp } from "./preauth-connection-budget.js";
|
|
10
10
|
export { ADMIN_SCOPE, DEFAULT_GATEWAY_HTTP_TOOL_DENY, DEFAULT_OPERATOR_SCOPES, KNOWN_OPERATOR_SCOPES, KNOWN_WEAK_GATEWAY_TOKEN_PLACEHOLDERS, READ_SCOPE, WRITE_SCOPE, assertGatewayAuthNotKnownWeak, auditGatewayConfig, authorizeRouteScope, authorizeScope, buildGatewayConsoleCspHeader, checkBrowserOrigin, collectGatewayConfigFindings, collectGatewaySecurityFindings, collectGatewayStartupGuardFindings, computeInlineScriptHashes, createPreauthConnectionBudget, detectSuspiciousPatterns, filterDangerousHttpTools, getMaxPreauthConnectionsPerIp, isDangerousHttpTool, isOperatorScope, parseScopesHeader, safeEqualSecret, wrapExternalContent, wrapWebContent };
|
|
@@ -2,7 +2,6 @@ import { resolveGatewayBindHost, resolveGatewayListenHosts } from "../config/gat
|
|
|
2
2
|
import { ensureXopcCliOnPath } from "../infra/path-env.js";
|
|
3
3
|
import { resolveGatewayListenPlan } from "./listen.js";
|
|
4
4
|
import { GatewayService } from "./service.js";
|
|
5
|
-
import { closeAllEventStreams } from "./hono/sse.js";
|
|
6
5
|
import { handleSiteShareUpgrade } from "../share/site-share-router.js";
|
|
7
6
|
import { createHonoApp } from "./hono/app.js";
|
|
8
7
|
import { serve } from "@hono/node-server";
|
|
@@ -57,9 +56,11 @@ var GatewayServer = class {
|
|
|
57
56
|
const attachUpgrade = (server) => {
|
|
58
57
|
server.on("upgrade", (req, socket, head) => {
|
|
59
58
|
try {
|
|
60
|
-
|
|
59
|
+
if (this.service.realtime.handleUpgrade(req, socket, head)) return;
|
|
60
|
+
if (handleSiteShareUpgrade(this.service, req, socket, head)) return;
|
|
61
|
+
socket.destroy();
|
|
61
62
|
} catch (err) {
|
|
62
|
-
console.error("[GatewayServer]
|
|
63
|
+
console.error("[GatewayServer] WebSocket upgrade error:", err);
|
|
63
64
|
try {
|
|
64
65
|
socket.destroy();
|
|
65
66
|
} catch {}
|
|
@@ -95,7 +96,6 @@ var GatewayServer = class {
|
|
|
95
96
|
}
|
|
96
97
|
async stop() {
|
|
97
98
|
console.log("[GatewayServer] Stopping gateway server...");
|
|
98
|
-
closeAllEventStreams();
|
|
99
99
|
const closeServer = async (server) => {
|
|
100
100
|
if (!server) return;
|
|
101
101
|
const forceClose = setTimeout(() => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
|
|
1
2
|
/**
|
|
2
3
|
* GatewayAgentRunner — webchat agent invocation and the surrounding control
|
|
3
4
|
* surface (abort, steer, clarify-bridge plumbing, scheduled Task continuations).
|
|
@@ -23,7 +24,7 @@ import type { MessageBus } from '../../infra/bus/index.js';
|
|
|
23
24
|
import type { AgentService } from '../../agent/service.js';
|
|
24
25
|
import type { ChannelManager } from '../../channels/manager.js';
|
|
25
26
|
import type { SessionIndex } from '../../session/index.js';
|
|
26
|
-
import {
|
|
27
|
+
import type { ClarifyStreamEvent } from '../clarify-bridge.js';
|
|
27
28
|
import { ClarifyBridge, type ClarifyBridgeRequest } from '../clarify-bridge.js';
|
|
28
29
|
import type { UserTurnAttachment, UserTurnInput } from '../user-turn-input.js';
|
|
29
30
|
import { SessionInputCoordinator, type SubmitSessionInput } from './session-input-coordinator.js';
|
|
@@ -34,12 +35,13 @@ export interface GatewayAgentRunnerOptions {
|
|
|
34
35
|
getAgentService: () => AgentService;
|
|
35
36
|
getChannelManager: () => ChannelManager;
|
|
36
37
|
getConfig: () => Config;
|
|
37
|
-
/**
|
|
38
|
+
/** Publish low-frequency gateway state changes. */
|
|
38
39
|
emit: (type: string, payload: unknown) => void;
|
|
40
|
+
publishRealtime: (topic: string, event: string, data: unknown) => void;
|
|
41
|
+
completeRealtimeTopic: (topic: string) => void;
|
|
39
42
|
}
|
|
40
43
|
export declare class GatewayAgentRunner {
|
|
41
44
|
private readonly opts;
|
|
42
|
-
readonly runRelay: AgentRunRelay;
|
|
43
45
|
/** Per-run abort for webchat (POST /api/agent/abort or client disconnect). */
|
|
44
46
|
private readonly runAbortControllers;
|
|
45
47
|
private readonly runCompletions;
|
|
@@ -55,7 +57,7 @@ export declare class GatewayAgentRunner {
|
|
|
55
57
|
getClarifyBridge(): ClarifyBridge;
|
|
56
58
|
/** Called from `GatewayService.stop()` so the bridge gets cleaned up. */
|
|
57
59
|
disposeClarifyBridge(): void;
|
|
58
|
-
runAgent(message: string, channel: string, chatId: string, attachments?: UserTurnAttachment[], thinking?: string, runOptions?: {
|
|
60
|
+
runAgent(message: string, channel: string, chatId: string, origin: TurnOrigin, attachments?: UserTurnAttachment[], thinking?: string, runOptions?: {
|
|
59
61
|
signal?: AbortSignal;
|
|
60
62
|
runId?: string;
|
|
61
63
|
}): AsyncGenerator<{
|
|
@@ -89,7 +91,7 @@ export declare class GatewayAgentRunner {
|
|
|
89
91
|
state: import("../../storage/sqlite/session-input-repository.js").SessionInputState;
|
|
90
92
|
};
|
|
91
93
|
recoverSessionInputs(): void;
|
|
92
|
-
/** Abort an in-flight webchat agent run
|
|
94
|
+
/** Abort an in-flight webchat agent run. */
|
|
93
95
|
abortAgentRun(runId: string): Promise<{
|
|
94
96
|
aborted: boolean;
|
|
95
97
|
idle: boolean;
|
|
@@ -103,17 +105,17 @@ export declare class GatewayAgentRunner {
|
|
|
103
105
|
drainScheduledWebchatContinuation(sessionKey: string, message: string): Promise<void>;
|
|
104
106
|
/**
|
|
105
107
|
* Resolve clarify-bridge config for `sessionKey`: who delivers the question
|
|
106
|
-
* (webchat
|
|
108
|
+
* (webchat stream, Telegram message, or both), then start the bridge request.
|
|
107
109
|
* Rejects when neither path is available (e.g. CLI without webchat or TG).
|
|
108
110
|
*
|
|
109
|
-
* `
|
|
110
|
-
* `turnDispatcher.
|
|
111
|
+
* `publishStreamFor(runId)` is the bridge into AgentService's
|
|
112
|
+
* `turnDispatcher.enqueueWebchatStreamEvent`. We take it as a callback so the
|
|
111
113
|
* runner does not import AgentService statically.
|
|
112
114
|
*/
|
|
113
115
|
requestClarification(opts: {
|
|
114
116
|
sessionKey: string;
|
|
115
117
|
request: ClarifyBridgeRequest;
|
|
116
|
-
|
|
118
|
+
publishStreamFor: (runId: string) => (event: ClarifyStreamEvent) => void;
|
|
117
119
|
}): Promise<string>;
|
|
118
120
|
private deliverTelegramClarify;
|
|
119
121
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { AgentRunRelay } from "../agent-run-relay.js";
|
|
4
3
|
import { ClarifyBridge } from "../clarify-bridge.js";
|
|
5
4
|
import { runGatewayAgent } from "./run-gateway-agent.js";
|
|
6
5
|
import { SessionInputCoordinator } from "./session-input-coordinator.js";
|
|
@@ -10,7 +9,6 @@ init_logger();
|
|
|
10
9
|
const log = createLogger("Gateway:AgentRunner");
|
|
11
10
|
var GatewayAgentRunner = class {
|
|
12
11
|
opts;
|
|
13
|
-
runRelay = new AgentRunRelay();
|
|
14
12
|
/** Per-run abort for webchat (POST /api/agent/abort or client disconnect). */
|
|
15
13
|
runAbortControllers = /* @__PURE__ */ new Map();
|
|
16
14
|
runCompletions = /* @__PURE__ */ new Map();
|
|
@@ -24,7 +22,7 @@ var GatewayAgentRunner = class {
|
|
|
24
22
|
this.inputs = new SessionInputCoordinator({
|
|
25
23
|
sessionExists: async (sessionKey) => Boolean(await opts.sessionIndex.getSessionMetadata(sessionKey)),
|
|
26
24
|
execute: async (input) => {
|
|
27
|
-
const generator = this.runAgent(input.content, "webchat", input.sessionKey, input.attachments, input.thinking, { runId: input.runId });
|
|
25
|
+
const generator = this.runAgent(input.content, "webchat", input.sessionKey, input.origin, input.attachments, input.thinking, { runId: input.runId });
|
|
28
26
|
let result;
|
|
29
27
|
while (true) {
|
|
30
28
|
const step = await generator.next();
|
|
@@ -65,7 +63,7 @@ var GatewayAgentRunner = class {
|
|
|
65
63
|
disposeClarifyBridge() {
|
|
66
64
|
this.clarifyBridge.dispose();
|
|
67
65
|
}
|
|
68
|
-
async *runAgent(message, channel, chatId, attachments, thinking, runOptions) {
|
|
66
|
+
async *runAgent(message, channel, chatId, origin, attachments, thinking, runOptions) {
|
|
69
67
|
const trackedRunId = runOptions?.runId;
|
|
70
68
|
if (trackedRunId) {
|
|
71
69
|
let resolve = () => {};
|
|
@@ -78,12 +76,13 @@ var GatewayAgentRunner = class {
|
|
|
78
76
|
config: this.opts.getConfig(),
|
|
79
77
|
agentService: this.opts.getAgentService(),
|
|
80
78
|
bus: this.opts.bus,
|
|
81
|
-
runRelay: this.runRelay,
|
|
82
79
|
runAbortControllers: this.runAbortControllers,
|
|
83
80
|
activeWebchatRunBySession: this.activeWebchatRunBySession,
|
|
84
81
|
sessionIndex: this.opts.sessionIndex,
|
|
85
|
-
emit: this.opts.emit
|
|
86
|
-
|
|
82
|
+
emit: this.opts.emit,
|
|
83
|
+
publishRealtime: this.opts.publishRealtime,
|
|
84
|
+
completeRealtimeTopic: this.opts.completeRealtimeTopic
|
|
85
|
+
}, message, channel, chatId, origin, attachments, thinking, runOptions);
|
|
87
86
|
try {
|
|
88
87
|
let step = await iter.next();
|
|
89
88
|
while (!step.done) {
|
|
@@ -114,13 +113,11 @@ var GatewayAgentRunner = class {
|
|
|
114
113
|
recoverSessionInputs() {
|
|
115
114
|
this.inputs.recover();
|
|
116
115
|
}
|
|
117
|
-
/** Abort an in-flight webchat agent run
|
|
116
|
+
/** Abort an in-flight webchat agent run. */
|
|
118
117
|
async abortAgentRun(runId) {
|
|
119
118
|
this.clarifyBridge.cancelForRun(runId);
|
|
120
119
|
const keysToMark = [];
|
|
121
120
|
for (const [sk, id] of this.activeWebchatRunBySession) if (id === runId) keysToMark.push(sk);
|
|
122
|
-
const relaySk = this.runRelay.getSessionKey(runId);
|
|
123
|
-
if (relaySk && !keysToMark.includes(relaySk)) keysToMark.push(relaySk);
|
|
124
121
|
const c = this.runAbortControllers.get(runId);
|
|
125
122
|
if (!c) return {
|
|
126
123
|
aborted: false,
|
|
@@ -152,7 +149,11 @@ var GatewayAgentRunner = class {
|
|
|
152
149
|
clientMessageId,
|
|
153
150
|
delivery: "next",
|
|
154
151
|
content: userTurn.text,
|
|
155
|
-
attachments: userTurn.attachments
|
|
152
|
+
attachments: userTurn.attachments,
|
|
153
|
+
origin: {
|
|
154
|
+
type: "system",
|
|
155
|
+
source: "workflow"
|
|
156
|
+
}
|
|
156
157
|
});
|
|
157
158
|
if (accepted.ok === false) throw new Error(`Scheduled session input was rejected: ${accepted.code}`);
|
|
158
159
|
await this.inputs.waitForCompletion(sessionKey, clientMessageId);
|
|
@@ -173,17 +174,17 @@ var GatewayAgentRunner = class {
|
|
|
173
174
|
}
|
|
174
175
|
/**
|
|
175
176
|
* Resolve clarify-bridge config for `sessionKey`: who delivers the question
|
|
176
|
-
* (webchat
|
|
177
|
+
* (webchat stream, Telegram message, or both), then start the bridge request.
|
|
177
178
|
* Rejects when neither path is available (e.g. CLI without webchat or TG).
|
|
178
179
|
*
|
|
179
|
-
* `
|
|
180
|
-
* `turnDispatcher.
|
|
180
|
+
* `publishStreamFor(runId)` is the bridge into AgentService's
|
|
181
|
+
* `turnDispatcher.enqueueWebchatStreamEvent`. We take it as a callback so the
|
|
181
182
|
* runner does not import AgentService statically.
|
|
182
183
|
*/
|
|
183
184
|
async requestClarification(opts) {
|
|
184
|
-
const { sessionKey, request,
|
|
185
|
+
const { sessionKey, request, publishStreamFor } = opts;
|
|
185
186
|
const runId = this.activeWebchatRunBySession.get(sessionKey);
|
|
186
|
-
const
|
|
187
|
+
const publishStream = runId ? publishStreamFor(runId) : void 0;
|
|
187
188
|
const deliver = ((await this.opts.sessionIndex.getSessionMetadata(sessionKey).catch(() => null))?.routing)?.source === "telegram" ? async (ctx) => {
|
|
188
189
|
await this.deliverTelegramClarify(ctx);
|
|
189
190
|
} : void 0;
|
|
@@ -191,8 +192,7 @@ var GatewayAgentRunner = class {
|
|
|
191
192
|
return this.clarifyBridge.startRequest({
|
|
192
193
|
sessionKey,
|
|
193
194
|
runId,
|
|
194
|
-
|
|
195
|
-
publishSse,
|
|
195
|
+
publishStream,
|
|
196
196
|
request,
|
|
197
197
|
deliver
|
|
198
198
|
});
|
|
@@ -45,9 +45,9 @@ export interface GatewayConfigCoordinatorOptions {
|
|
|
45
45
|
reconcileBrowserExtensionServer: () => Promise<void>;
|
|
46
46
|
/** Sync built-in dreaming automations after memory.dreaming changes. */
|
|
47
47
|
reconcileDreamingAutomations: () => Promise<void>;
|
|
48
|
-
/** Latest channel status snapshot for the `channels.status`
|
|
48
|
+
/** Latest channel status snapshot for the `channels.status` event. */
|
|
49
49
|
getChannelsStatus: () => unknown;
|
|
50
|
-
/**
|
|
50
|
+
/** Realtime emit used for `config.reload` and `channels.status`. */
|
|
51
51
|
emit: (type: string, payload: unknown) => void;
|
|
52
52
|
}
|
|
53
53
|
export declare class GatewayConfigCoordinator {
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
+
import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
|
|
1
2
|
import type { AgentService } from '../../agent/service.js';
|
|
2
3
|
import type { Config } from '../../config/schema.js';
|
|
3
4
|
import type { MessageBus } from '../../infra/bus/index.js';
|
|
4
5
|
import type { SessionIndex } from '../../session/index.js';
|
|
5
6
|
import type { ChatStreamEvent } from '../chat-stream/protocol.js';
|
|
6
|
-
import type { AgentRunRelay } from '../agent-run-relay.js';
|
|
7
7
|
import type { UserTurnAttachment } from '../user-turn-input.js';
|
|
8
8
|
export type RunGatewayAgentYield = ChatStreamEvent;
|
|
9
9
|
export type RunGatewayAgentDeps = {
|
|
10
10
|
config: Config;
|
|
11
11
|
agentService: AgentService;
|
|
12
12
|
bus: MessageBus;
|
|
13
|
-
runRelay: AgentRunRelay;
|
|
14
13
|
runAbortControllers: Map<string, AbortController>;
|
|
15
14
|
activeWebchatRunBySession: Map<string, string>;
|
|
16
15
|
sessionIndex: SessionIndex;
|
|
17
16
|
emit: (type: string, payload: unknown) => void;
|
|
17
|
+
publishRealtime: (topic: string, event: string, data: unknown) => void;
|
|
18
|
+
completeRealtimeTopic: (topic: string) => void;
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
21
|
* @param runOptions.signal — When set (e.g. client disconnect), aborts in-flight generation and persists partial output.
|
|
21
22
|
*/
|
|
22
|
-
export declare function runGatewayAgent(deps: RunGatewayAgentDeps, message: string, channel: string, chatId: string, attachments?: UserTurnAttachment[], thinking?: string, runOptions?: {
|
|
23
|
+
export declare function runGatewayAgent(deps: RunGatewayAgentDeps, message: string, channel: string, chatId: string, origin: TurnOrigin, attachments?: UserTurnAttachment[], thinking?: string, runOptions?: {
|
|
23
24
|
signal?: AbortSignal;
|
|
24
25
|
runId?: string;
|
|
25
26
|
}): AsyncGenerator<RunGatewayAgentYield, {
|