@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
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* `sessionEventUnsubscribers`) are still cleared via `disposeSession`, but they
|
|
17
17
|
* are NOT subject to TTL — sweeping them would race with their owners.
|
|
18
18
|
*/
|
|
19
|
-
export type
|
|
19
|
+
export type WebchatStreamPublisher = (event: {
|
|
20
20
|
type: string;
|
|
21
21
|
[key: string]: unknown;
|
|
22
22
|
}) => void;
|
|
@@ -34,7 +34,7 @@ export interface SessionStateBagOptions {
|
|
|
34
34
|
now?: () => number;
|
|
35
35
|
}
|
|
36
36
|
export declare class SessionStateBag {
|
|
37
|
-
/** Webchat
|
|
37
|
+
/** Webchat run publisher (register/unregister + TTL fallback). */
|
|
38
38
|
private readonly webchatPublishers;
|
|
39
39
|
/** Last assistant plain text (TTL + LRU). */
|
|
40
40
|
private readonly lastAssistantText;
|
|
@@ -51,9 +51,9 @@ export declare class SessionStateBag {
|
|
|
51
51
|
private readonly now;
|
|
52
52
|
private readonly sweepTimer;
|
|
53
53
|
constructor(opts?: SessionStateBagOptions);
|
|
54
|
-
registerWebchatPublisher(sessionKey: string, publisher:
|
|
54
|
+
registerWebchatPublisher(sessionKey: string, publisher: WebchatStreamPublisher): void;
|
|
55
55
|
unregisterWebchatPublisher(sessionKey: string): void;
|
|
56
|
-
getWebchatPublisher(sessionKey: string):
|
|
56
|
+
getWebchatPublisher(sessionKey: string): WebchatStreamPublisher | undefined;
|
|
57
57
|
setLastAssistantText(sessionKey: string, text: string): void;
|
|
58
58
|
getLastAssistantText(sessionKey: string): string | undefined;
|
|
59
59
|
appendEmbeddedStreamText(sessionKey: string, chunk: string): string;
|
|
@@ -7,7 +7,7 @@ const DEFAULT_TTL_MS = 3600 * 1e3;
|
|
|
7
7
|
const DEFAULT_SWEEP_INTERVAL_MS = 600 * 1e3;
|
|
8
8
|
const DEFAULT_MAX_ENTRIES = 5e3;
|
|
9
9
|
var SessionStateBag = class {
|
|
10
|
-
/** Webchat
|
|
10
|
+
/** Webchat run publisher (register/unregister + TTL fallback). */
|
|
11
11
|
webchatPublishers = /* @__PURE__ */ new Map();
|
|
12
12
|
/** Last assistant plain text (TTL + LRU). */
|
|
13
13
|
lastAssistantText = /* @__PURE__ */ new Map();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReasoningLevel } from '../transcript/thinking-types.js';
|
|
2
|
+
export type AgentStreamEvent = {
|
|
3
|
+
type: string;
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare function applyReasoningVisibility(event: AgentStreamEvent, reasoningLevel: ReasoningLevel): AgentStreamEvent | null;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
//#region src/agent/streaming/reasoning-visibility
|
|
2
|
-
|
|
3
|
-
* @returns `null` to drop the event; unchanged `event` otherwise.
|
|
4
|
-
*/
|
|
5
|
-
function applyReasoningVisibilityToSseEvent(event, reasoningLevel) {
|
|
1
|
+
//#region src/agent/streaming/reasoning-visibility.ts
|
|
2
|
+
function applyReasoningVisibility(event, reasoningLevel) {
|
|
6
3
|
if (reasoningLevel !== "off") return event;
|
|
7
4
|
if (event.type === "thinking") return null;
|
|
8
5
|
if (event.type === "message_update" && event.assistantMessageEvent?.type === "thinking_delta") return null;
|
|
@@ -10,4 +7,4 @@ function applyReasoningVisibilityToSseEvent(event, reasoningLevel) {
|
|
|
10
7
|
return event;
|
|
11
8
|
}
|
|
12
9
|
//#endregion
|
|
13
|
-
export {
|
|
10
|
+
export { applyReasoningVisibility };
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import type { AgentTool } from '@earendil-works/pi-agent-core';
|
|
10
10
|
import type { Model, Api } from '@earendil-works/pi-ai';
|
|
11
11
|
import type { Config } from '../../config/schema.js';
|
|
12
|
+
import type { EndpointToolRuntime } from '../../endpoint-tools/index.js';
|
|
13
|
+
import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
|
|
12
14
|
import type { ExtensionRegistry } from '../../extensions/types/index.js';
|
|
13
15
|
import type { MessageBus } from '../../infra/bus/index.js';
|
|
14
16
|
import { type SkillInstallToolOptions, type SkillInstallToolResult, type MarketplaceSkillInstallToolOptions, type MarketplaceSkillInstallToolResult } from './index.js';
|
|
@@ -31,7 +33,9 @@ export interface ToolFactoryDeps {
|
|
|
31
33
|
channel: string;
|
|
32
34
|
chatId: string;
|
|
33
35
|
sessionKey: string;
|
|
36
|
+
origin: TurnOrigin;
|
|
34
37
|
} | null;
|
|
38
|
+
endpointTools?: EndpointToolRuntime;
|
|
35
39
|
hookRunner?: import('../../extensions/index.js').ExtensionHookRunner;
|
|
36
40
|
bus: MessageBus;
|
|
37
41
|
toolExecutorConfig?: Partial<ToolExecutorConfig>;
|
|
@@ -182,6 +182,7 @@ var AgentToolsFactory = class {
|
|
|
182
182
|
workspace,
|
|
183
183
|
getConfig: () => this.deps.getConfig?.(),
|
|
184
184
|
getCurrentContext: this.deps.getCurrentContext,
|
|
185
|
+
endpointTools: this.deps.endpointTools,
|
|
185
186
|
agentId,
|
|
186
187
|
extensionRegistry: this.deps.extensionRegistry,
|
|
187
188
|
disabledTools: disabled,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { WorkflowRunInputEnvelope } from '../../workflows/domain/index.js';
|
|
2
2
|
import type { TaskCommand } from '@xopcai/gateway-contract';
|
|
3
|
+
import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
|
|
3
4
|
import type { WorkflowRunServiceLike } from '../../workflows/service/workflow-run-service.types.js';
|
|
4
5
|
export type AutomationSchedule = {
|
|
5
6
|
kind: 'once';
|
|
@@ -171,7 +172,7 @@ export interface AutomationDeps {
|
|
|
171
172
|
applyAutomationModelOverride?: (sessionKey: string, model: string | undefined) => Promise<boolean>;
|
|
172
173
|
};
|
|
173
174
|
turnDispatcher?: {
|
|
174
|
-
processDirect: (message: string, sessionKey: string, attachments?: unknown[], thinking?: string, options?: {
|
|
175
|
+
processDirect: (message: string, sessionKey: string, origin: TurnOrigin, attachments?: unknown[], thinking?: string, options?: {
|
|
175
176
|
signal?: AbortSignal;
|
|
176
177
|
runId?: string;
|
|
177
178
|
deadlineAtMs?: number;
|
|
@@ -656,6 +656,7 @@ export declare const UpdateAutomationSchema: z.ZodObject<{
|
|
|
656
656
|
}, z.core.$strip>;
|
|
657
657
|
}, z.core.$strip>], "type">;
|
|
658
658
|
}, z.core.$strict>], "kind">>;
|
|
659
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
659
660
|
state: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
660
661
|
nextRunAtMs: z.ZodOptional<z.ZodNumber>;
|
|
661
662
|
runningRunId: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
@@ -672,7 +673,6 @@ export declare const UpdateAutomationSchema: z.ZodObject<{
|
|
|
672
673
|
lastError: z.ZodOptional<z.ZodString>;
|
|
673
674
|
consecutiveFailures: z.ZodOptional<z.ZodNumber>;
|
|
674
675
|
}, z.core.$strict>>>;
|
|
675
|
-
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
676
676
|
trigger: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
677
677
|
kind: z.ZodLiteral<"manual">;
|
|
678
678
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -177,7 +177,10 @@ var AutomationActionExecutor = class {
|
|
|
177
177
|
model: action.model
|
|
178
178
|
}, "Automation model override invalid; using agent default");
|
|
179
179
|
}
|
|
180
|
-
const response = await agentService.turnDispatcher.processDirect(buildSafetyInstruction(automation, action.instruction), sessionKey,
|
|
180
|
+
const response = await agentService.turnDispatcher.processDirect(buildSafetyInstruction(automation, action.instruction), sessionKey, {
|
|
181
|
+
type: "system",
|
|
182
|
+
source: "automation"
|
|
183
|
+
}, void 0, void 0, {
|
|
181
184
|
signal,
|
|
182
185
|
runId: run.id,
|
|
183
186
|
deadlineAtMs
|
|
@@ -18,7 +18,7 @@ export type IssuePairingChallengeParams = {
|
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* OpenClaw-style pairing: mint or refresh a pending code; notify the user only on new codes.
|
|
21
|
-
* Repeat DMs refresh lastSeenAt and
|
|
21
|
+
* Repeat DMs refresh lastSeenAt and publish realtime status without re-sending the bot message.
|
|
22
22
|
*/
|
|
23
23
|
export declare function issuePairingChallenge(params: IssuePairingChallengeParams): Promise<{
|
|
24
24
|
created: boolean;
|
|
@@ -4,7 +4,7 @@ import { broadcastPairingEvent } from "./pairing-events.js";
|
|
|
4
4
|
//#region src/channels/pairing/pairing-challenge.ts
|
|
5
5
|
/**
|
|
6
6
|
* OpenClaw-style pairing: mint or refresh a pending code; notify the user only on new codes.
|
|
7
|
-
* Repeat DMs refresh lastSeenAt and
|
|
7
|
+
* Repeat DMs refresh lastSeenAt and publish realtime status without re-sending the bot message.
|
|
8
8
|
*/
|
|
9
9
|
async function issuePairingChallenge(params) {
|
|
10
10
|
const normalizedAccountId = params.accountId.trim().toLowerCase() || "default";
|
|
@@ -28,7 +28,10 @@ function formatToolArgs(args) {
|
|
|
28
28
|
*/
|
|
29
29
|
async function renderStreamToTerminal(agent, message, sessionKey) {
|
|
30
30
|
const stamped = message.trimStart().startsWith("/") ? message : prependEnvelopeTimestamp(message);
|
|
31
|
-
const stream = agent.turnDispatcher.processDirectStreaming(stamped, sessionKey
|
|
31
|
+
const stream = agent.turnDispatcher.processDirectStreaming(stamped, sessionKey, {
|
|
32
|
+
type: "system",
|
|
33
|
+
source: "cli"
|
|
34
|
+
});
|
|
32
35
|
let responseText = "";
|
|
33
36
|
let isFirstToken = true;
|
|
34
37
|
let isInThinking = false;
|
|
@@ -52,7 +52,7 @@ async function checkDatabaseSchema(ctx) {
|
|
|
52
52
|
id: "database-schema",
|
|
53
53
|
label: "Database schema",
|
|
54
54
|
status: "pass",
|
|
55
|
-
message: `SQLite schema v${status.dbVersion} (current release
|
|
55
|
+
message: `SQLite schema v${status.dbVersion} (current release v112).`,
|
|
56
56
|
hints: []
|
|
57
57
|
};
|
|
58
58
|
}
|
|
@@ -3,9 +3,9 @@ import { init_loader, loadConfig } from "../../config/loader.js";
|
|
|
3
3
|
import { downloadExtensionStoreZipBuffer, resolveExtensionZipDownloadUrl, resolveExtensionsStoreBaseUrl, verifyStoreArtifactSha256 } from "../../agent/skills/marketplace/adapters/store/store-api-client.js";
|
|
4
4
|
import { getContextWithOpts } from "../context.js";
|
|
5
5
|
import { getExtensionLockfileManager } from "../../extensions/lockfile.js";
|
|
6
|
-
import { fetchRegistry, findExtension, getExtensionMarketplaceStoreBaseUrl, listExtensions, searchExtensions } from "../../extensions/marketplace.js";
|
|
7
6
|
import { installFromLocal, installFromNpm, peekExtensionManifestFromStoreZip } from "../../extensions/install.js";
|
|
8
7
|
import { commitStagedExtensionInstall, finalizeStagedExtensionInstall, rollbackStagedExtensionInstall, stageExtensionStoreZip } from "../../extensions/install-transaction.js";
|
|
8
|
+
import { fetchRegistry, findExtension, getExtensionMarketplaceStoreBaseUrl, listExtensions, searchExtensions } from "../../extensions/marketplace.js";
|
|
9
9
|
import { colors } from "../utils/colors.js";
|
|
10
10
|
import { validateExtensionPackageDirectory } from "./extension-pack.js";
|
|
11
11
|
import { join, resolve } from "node:path";
|
package/dist/src/config/rules.js
CHANGED
|
@@ -93,11 +93,6 @@ const BASE_RELOAD_RULES = [
|
|
|
93
93
|
kind: "restart",
|
|
94
94
|
description: "Host-header origin fallback"
|
|
95
95
|
},
|
|
96
|
-
{
|
|
97
|
-
prefix: "gateway.maxSseConnections",
|
|
98
|
-
kind: "restart",
|
|
99
|
-
description: "SSE connection limit"
|
|
100
|
-
},
|
|
101
96
|
{
|
|
102
97
|
prefix: "gateway.channelConnectDeferMode",
|
|
103
98
|
kind: "restart",
|
|
@@ -781,8 +781,8 @@ export declare const WorkspaceConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
|
781
781
|
}, z.core.$strip>>;
|
|
782
782
|
export type WorkspaceConfig = z.infer<typeof WorkspaceConfigSchema>;
|
|
783
783
|
export declare const GatewayBindModeSchema: z.ZodEnum<{
|
|
784
|
-
auto: "auto";
|
|
785
784
|
custom: "custom";
|
|
785
|
+
auto: "auto";
|
|
786
786
|
loopback: "loopback";
|
|
787
787
|
lan: "lan";
|
|
788
788
|
tailnet: "tailnet";
|
|
@@ -796,8 +796,8 @@ export declare const GatewayWebchatConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
796
796
|
}, z.core.$strip>>;
|
|
797
797
|
export declare const GatewayConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
798
798
|
bind: z.ZodOptional<z.ZodEnum<{
|
|
799
|
-
auto: "auto";
|
|
800
799
|
custom: "custom";
|
|
800
|
+
auto: "auto";
|
|
801
801
|
loopback: "loopback";
|
|
802
802
|
lan: "lan";
|
|
803
803
|
tailnet: "tailnet";
|
|
@@ -886,7 +886,6 @@ export declare const GatewayConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
886
886
|
off: "off";
|
|
887
887
|
}>>;
|
|
888
888
|
}, z.core.$strip>>>;
|
|
889
|
-
maxSseConnections: z.ZodOptional<z.ZodNumber>;
|
|
890
889
|
corsOrigins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
891
890
|
publicUrl: z.ZodOptional<z.ZodString>;
|
|
892
891
|
dangerouslyAllowHostHeaderOriginFallback: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1930,8 +1929,8 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
1930
1929
|
channels: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1931
1930
|
gateway: z.ZodDefault<z.ZodObject<{
|
|
1932
1931
|
bind: z.ZodOptional<z.ZodEnum<{
|
|
1933
|
-
auto: "auto";
|
|
1934
1932
|
custom: "custom";
|
|
1933
|
+
auto: "auto";
|
|
1935
1934
|
loopback: "loopback";
|
|
1936
1935
|
lan: "lan";
|
|
1937
1936
|
tailnet: "tailnet";
|
|
@@ -2020,7 +2019,6 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
2020
2019
|
off: "off";
|
|
2021
2020
|
}>>;
|
|
2022
2021
|
}, z.core.$strip>>>;
|
|
2023
|
-
maxSseConnections: z.ZodOptional<z.ZodNumber>;
|
|
2024
2022
|
corsOrigins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2025
2023
|
publicUrl: z.ZodOptional<z.ZodString>;
|
|
2026
2024
|
dangerouslyAllowHostHeaderOriginFallback: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -465,7 +465,6 @@ activityDetailDefault: z.enum([
|
|
|
465
465
|
auth: GatewayAuthSchema.optional(),
|
|
466
466
|
heartbeat: HeartbeatConfigSchema.optional(),
|
|
467
467
|
webchat: GatewayWebchatConfigSchema.optional(),
|
|
468
|
-
maxSseConnections: z.number().optional(),
|
|
469
468
|
corsOrigins: z.array(z.string()).optional(),
|
|
470
469
|
/**
|
|
471
470
|
* Reverse-proxy publicly reachable URL (e.g. `https://gateway.example.com`).
|
|
@@ -639,7 +638,6 @@ activityDetailDefault: z.enum([
|
|
|
639
638
|
includeSystemPromptSection: false
|
|
640
639
|
},
|
|
641
640
|
webchat: { activityDetailDefault: "on" },
|
|
642
|
-
maxSseConnections: 100,
|
|
643
641
|
corsOrigins: [],
|
|
644
642
|
skillsMarketplaceProvider: "store",
|
|
645
643
|
skillsStoreBaseUrl: "https://store.xopc.ai"
|
|
@@ -1042,7 +1040,6 @@ workDiscoveryOnboarding: z.boolean().default(true) }).strict().default({ workDis
|
|
|
1042
1040
|
includeSystemPromptSection: false
|
|
1043
1041
|
},
|
|
1044
1042
|
webchat: { activityDetailDefault: "on" },
|
|
1045
|
-
maxSseConnections: 100,
|
|
1046
1043
|
corsOrigins: [],
|
|
1047
1044
|
skillsMarketplaceProvider: "store",
|
|
1048
1045
|
skillsStoreBaseUrl: "https://store.xopc.ai"
|
|
@@ -93,7 +93,6 @@ function mergeGatewaySkillsMarketplacePatch(config, patch) {
|
|
|
93
93
|
intervalMs: 18e5,
|
|
94
94
|
includeSystemPromptSection: false
|
|
95
95
|
},
|
|
96
|
-
maxSseConnections: 100,
|
|
97
96
|
corsOrigins: []
|
|
98
97
|
};
|
|
99
98
|
if (parsed.data.skillsMarketplaceProvider !== void 0) config.gateway.skillsMarketplaceProvider = parsed.data.skillsMarketplaceProvider.trim();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { type EndpointHelloPayload } from '@xopcai/endpoint-tools-protocol';
|
|
3
|
+
import type { EndpointPrincipal } from '../storage/sqlite/index.js';
|
|
4
|
+
export interface EndpointAuthenticatorDeps {
|
|
5
|
+
getPrincipal(id: string): EndpointPrincipal | undefined;
|
|
6
|
+
bindEndpoint(endpointId: string, principalId: string, boundAt?: number): boolean;
|
|
7
|
+
touchPrincipal(id: string, seenAt?: number): void;
|
|
8
|
+
now?: () => number;
|
|
9
|
+
}
|
|
10
|
+
export declare class EndpointAuthenticationError extends Error {
|
|
11
|
+
}
|
|
12
|
+
export declare function parseEndpointPublicKey(encoded: string): crypto.KeyObject;
|
|
13
|
+
export declare class EndpointAuthenticator {
|
|
14
|
+
private readonly deps;
|
|
15
|
+
private readonly usedNonces;
|
|
16
|
+
private readonly now;
|
|
17
|
+
constructor(deps: EndpointAuthenticatorDeps);
|
|
18
|
+
authenticate(payload: EndpointHelloPayload): EndpointPrincipal;
|
|
19
|
+
private pruneNonces;
|
|
20
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { endpointHelloSigningPayload } from "../../packages/endpoint-tools-protocol/src/index.js";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
//#region src/endpoint-tools/auth.ts
|
|
4
|
+
const MAX_CLOCK_SKEW_MS = 6e4;
|
|
5
|
+
var EndpointAuthenticationError = class extends Error {};
|
|
6
|
+
function parseEndpointPublicKey(encoded) {
|
|
7
|
+
const key = crypto.createPublicKey({
|
|
8
|
+
key: Buffer.from(encoded, "base64url"),
|
|
9
|
+
format: "der",
|
|
10
|
+
type: "spki"
|
|
11
|
+
});
|
|
12
|
+
if (key.asymmetricKeyType !== "ec" || key.asymmetricKeyDetails?.namedCurve !== "prime256v1") throw new Error("Endpoint public key must be ECDSA P-256");
|
|
13
|
+
return key;
|
|
14
|
+
}
|
|
15
|
+
var EndpointAuthenticator = class {
|
|
16
|
+
usedNonces = /* @__PURE__ */ new Map();
|
|
17
|
+
now;
|
|
18
|
+
constructor(deps) {
|
|
19
|
+
this.deps = deps;
|
|
20
|
+
this.now = deps.now ?? Date.now;
|
|
21
|
+
}
|
|
22
|
+
authenticate(payload) {
|
|
23
|
+
const now = this.now();
|
|
24
|
+
this.pruneNonces(now);
|
|
25
|
+
if (Math.abs(now - payload.signedAt) > MAX_CLOCK_SKEW_MS) throw new EndpointAuthenticationError("Endpoint signature timestamp is outside the allowed window");
|
|
26
|
+
const nonceKey = `${payload.principalId}:${payload.nonce}`;
|
|
27
|
+
if (this.usedNonces.has(nonceKey)) throw new EndpointAuthenticationError("Endpoint hello nonce was already used");
|
|
28
|
+
const principal = this.deps.getPrincipal(payload.principalId);
|
|
29
|
+
if (!principal || principal.revokedAt !== void 0) throw new EndpointAuthenticationError("Endpoint principal is unknown or revoked");
|
|
30
|
+
if (principal.kind !== payload.kind || principal.platform !== payload.platform || principal.displayName !== payload.displayName) throw new EndpointAuthenticationError("Endpoint identity does not match its registered principal");
|
|
31
|
+
let publicKey;
|
|
32
|
+
try {
|
|
33
|
+
publicKey = parseEndpointPublicKey(principal.publicKey);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new EndpointAuthenticationError("Endpoint principal public key is invalid", { cause: error });
|
|
36
|
+
}
|
|
37
|
+
if (!crypto.verify("sha256", Buffer.from(endpointHelloSigningPayload(payload), "utf8"), {
|
|
38
|
+
key: publicKey,
|
|
39
|
+
dsaEncoding: "ieee-p1363"
|
|
40
|
+
}, Buffer.from(payload.signature, "base64url"))) throw new EndpointAuthenticationError("Endpoint hello signature is invalid");
|
|
41
|
+
if (!this.deps.bindEndpoint(payload.endpointId, principal.id, now)) throw new EndpointAuthenticationError("Endpoint instance belongs to another principal");
|
|
42
|
+
this.usedNonces.set(nonceKey, now + MAX_CLOCK_SKEW_MS);
|
|
43
|
+
this.deps.touchPrincipal(principal.id, now);
|
|
44
|
+
return principal;
|
|
45
|
+
}
|
|
46
|
+
pruneNonces(now) {
|
|
47
|
+
for (const [key, expiresAt] of this.usedNonces) if (expiresAt <= now) this.usedNonces.delete(key);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { EndpointAuthenticationError, EndpointAuthenticator, parseEndpointPublicKey };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { EndpointToolRuntime } from './runtime.js';
|
|
2
|
+
export { EndpointInvocationService, EndpointToolExecutionError, type EndpointInvocationAuditSink, type EndpointInvocationResult, } from './invocation-service.js';
|
|
3
|
+
export { EndpointToolPolicy, EndpointToolPolicyError } from './policy.js';
|
|
4
|
+
export { EndpointRegistry, endpointToolRevision, type EndpointConnectionSnapshot, type RegisteredEndpointTool, } from './registry.js';
|
|
5
|
+
export { EndpointUploadError, EndpointUploadService, ENDPOINT_UPLOAD_MAX_BYTES, type EndpointUploadedFile, type EndpointUploadGrant, } from './upload-service.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EndpointToolPolicy, EndpointToolPolicyError } from "./policy.js";
|
|
2
|
+
import { EndpointInvocationService, EndpointToolExecutionError } from "./invocation-service.js";
|
|
3
|
+
import { EndpointRegistry, endpointToolRevision } from "./registry.js";
|
|
4
|
+
import { ENDPOINT_UPLOAD_MAX_BYTES, EndpointUploadError, EndpointUploadService } from "./upload-service.js";
|
|
5
|
+
import { EndpointToolRuntime } from "./runtime.js";
|
|
6
|
+
export { ENDPOINT_UPLOAD_MAX_BYTES, EndpointInvocationService, EndpointRegistry, EndpointToolExecutionError, EndpointToolPolicy, EndpointToolPolicyError, EndpointToolRuntime, EndpointUploadError, EndpointUploadService, endpointToolRevision };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ClientEndpointMessage, type EndpointToolContent, type EndpointToolErrorCode } from '@xopcai/endpoint-tools-protocol';
|
|
2
|
+
import { EndpointRegistry } from './registry.js';
|
|
3
|
+
import { EndpointToolPolicy } from './policy.js';
|
|
4
|
+
import type { EndpointUploadService } from './upload-service.js';
|
|
5
|
+
type ToolClientMessage = Exclude<ClientEndpointMessage, {
|
|
6
|
+
type: `endpoint.${string}`;
|
|
7
|
+
}>;
|
|
8
|
+
export interface EndpointInvocationAuditSink {
|
|
9
|
+
started(params: {
|
|
10
|
+
id: string;
|
|
11
|
+
principalId: string;
|
|
12
|
+
endpointId: string;
|
|
13
|
+
toolCallId: string;
|
|
14
|
+
toolName: string;
|
|
15
|
+
effect: 'read' | 'write' | 'destructive';
|
|
16
|
+
confirmationRequired: boolean;
|
|
17
|
+
argumentsSha256: string;
|
|
18
|
+
startedAt: number;
|
|
19
|
+
}): void;
|
|
20
|
+
finished(params: {
|
|
21
|
+
id: string;
|
|
22
|
+
status: 'succeeded' | 'failed';
|
|
23
|
+
errorCode?: EndpointToolErrorCode;
|
|
24
|
+
errorMessage?: string;
|
|
25
|
+
completedAt: number;
|
|
26
|
+
}): void;
|
|
27
|
+
}
|
|
28
|
+
export interface EndpointInvocationServiceOptions {
|
|
29
|
+
audit?: EndpointInvocationAuditSink;
|
|
30
|
+
uploads?: EndpointUploadService;
|
|
31
|
+
policy?: EndpointToolPolicy;
|
|
32
|
+
}
|
|
33
|
+
export interface EndpointInvocationResult {
|
|
34
|
+
content: EndpointToolContent[];
|
|
35
|
+
details?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
export declare class EndpointToolExecutionError extends Error {
|
|
38
|
+
readonly code: EndpointToolErrorCode;
|
|
39
|
+
constructor(code: EndpointToolErrorCode, message: string);
|
|
40
|
+
}
|
|
41
|
+
export declare class EndpointInvocationService {
|
|
42
|
+
private readonly registry;
|
|
43
|
+
private readonly options;
|
|
44
|
+
private readonly pending;
|
|
45
|
+
private readonly policy;
|
|
46
|
+
constructor(registry: EndpointRegistry, options?: EndpointInvocationServiceOptions);
|
|
47
|
+
invoke(params: {
|
|
48
|
+
endpointId: string;
|
|
49
|
+
toolCallId: string;
|
|
50
|
+
toolName: string;
|
|
51
|
+
arguments: Record<string, unknown>;
|
|
52
|
+
descriptorRevision: string;
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
onProgress?: (progress: {
|
|
55
|
+
message?: string;
|
|
56
|
+
percent?: number;
|
|
57
|
+
}) => void;
|
|
58
|
+
}): Promise<EndpointInvocationResult>;
|
|
59
|
+
handleMessage(endpointId: string, message: ToolClientMessage): void;
|
|
60
|
+
failEndpoint(endpointId: string): void;
|
|
61
|
+
close(): void;
|
|
62
|
+
private cancel;
|
|
63
|
+
private succeed;
|
|
64
|
+
private fail;
|
|
65
|
+
private take;
|
|
66
|
+
private error;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { ENDPOINT_INVOCATION_RECEIPT_TIMEOUT_MS, canonicalJson } from "../../packages/endpoint-tools-protocol/src/index.js";
|
|
2
|
+
import { EndpointToolPolicy, EndpointToolPolicyError } from "./policy.js";
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
|
+
//#region src/endpoint-tools/invocation-service.ts
|
|
5
|
+
var EndpointToolExecutionError = class extends Error {
|
|
6
|
+
constructor(code, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.name = "EndpointToolExecutionError";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var EndpointInvocationService = class {
|
|
13
|
+
pending = /* @__PURE__ */ new Map();
|
|
14
|
+
policy;
|
|
15
|
+
constructor(registry, options = {}) {
|
|
16
|
+
this.registry = registry;
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.policy = options.policy ?? new EndpointToolPolicy();
|
|
19
|
+
}
|
|
20
|
+
invoke(params) {
|
|
21
|
+
const endpoint = this.registry.get(params.endpointId);
|
|
22
|
+
if (!endpoint) return Promise.reject(this.error("ENDPOINT_OFFLINE", "Endpoint is offline"));
|
|
23
|
+
const tool = this.registry.getTool(params.endpointId, params.toolName);
|
|
24
|
+
if (!tool) return Promise.reject(this.error("TOOL_NOT_FOUND", "Endpoint tool is unavailable"));
|
|
25
|
+
if (tool.revision !== params.descriptorRevision) return Promise.reject(this.error("TOOL_REVISION_MISMATCH", "Endpoint tool contract changed"));
|
|
26
|
+
let confirmationRequired;
|
|
27
|
+
try {
|
|
28
|
+
confirmationRequired = this.policy.evaluate(tool.descriptor, endpoint.availability).confirmationRequired;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error instanceof EndpointToolPolicyError) return Promise.reject(this.error("ENDPOINT_NOT_FOREGROUND", error.message));
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
if (params.signal?.aborted) return Promise.reject(this.error("TOOL_CANCELLED", "Endpoint tool call was cancelled"));
|
|
34
|
+
const endpointPending = [...this.pending.values()].filter((item) => item.endpointId === params.endpointId);
|
|
35
|
+
if (endpointPending.length >= 4) return Promise.reject(this.error("TOOL_BUSY", "Endpoint has reached its invocation limit"));
|
|
36
|
+
if (endpointPending.filter((item) => item.toolName === params.toolName).length >= tool.descriptor.maxConcurrency) return Promise.reject(this.error("TOOL_BUSY", "Endpoint tool has reached its invocation limit"));
|
|
37
|
+
const invocationId = crypto.randomUUID();
|
|
38
|
+
const startedAt = Date.now();
|
|
39
|
+
const uploadGrant = tool.descriptor.resultKinds.includes("file") ? this.options.uploads?.createGrant(invocationId, params.endpointId, startedAt) : void 0;
|
|
40
|
+
try {
|
|
41
|
+
this.options.audit?.started({
|
|
42
|
+
id: invocationId,
|
|
43
|
+
principalId: endpoint.principalId,
|
|
44
|
+
endpointId: params.endpointId,
|
|
45
|
+
toolCallId: params.toolCallId,
|
|
46
|
+
toolName: params.toolName,
|
|
47
|
+
effect: tool.descriptor.effect,
|
|
48
|
+
confirmationRequired,
|
|
49
|
+
argumentsSha256: crypto.createHash("sha256").update(canonicalJson(params.arguments)).digest("hex"),
|
|
50
|
+
startedAt
|
|
51
|
+
});
|
|
52
|
+
} catch (error) {
|
|
53
|
+
this.options.uploads?.abort(invocationId);
|
|
54
|
+
return Promise.reject(error);
|
|
55
|
+
}
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const pending = {
|
|
58
|
+
id: invocationId,
|
|
59
|
+
endpointId: params.endpointId,
|
|
60
|
+
toolName: params.toolName,
|
|
61
|
+
state: "sent",
|
|
62
|
+
receiptTimer: setTimeout(() => {
|
|
63
|
+
this.fail(invocationId, this.error("TOOL_TIMEOUT", "Endpoint did not receive the invocation"));
|
|
64
|
+
}, ENDPOINT_INVOCATION_RECEIPT_TIMEOUT_MS),
|
|
65
|
+
deadlineTimer: setTimeout(() => {
|
|
66
|
+
this.cancel(invocationId, "Endpoint tool timed out", "TOOL_TIMEOUT");
|
|
67
|
+
}, tool.descriptor.timeoutMs),
|
|
68
|
+
abortSignal: params.signal,
|
|
69
|
+
onProgress: params.onProgress,
|
|
70
|
+
resolve,
|
|
71
|
+
reject
|
|
72
|
+
};
|
|
73
|
+
if (params.signal) {
|
|
74
|
+
pending.abortHandler = () => this.cancel(invocationId, "Agent cancelled the tool call", "TOOL_CANCELLED");
|
|
75
|
+
params.signal.addEventListener("abort", pending.abortHandler, { once: true });
|
|
76
|
+
}
|
|
77
|
+
this.pending.set(invocationId, pending);
|
|
78
|
+
try {
|
|
79
|
+
this.registry.send(params.endpointId, "tool.invoke", {
|
|
80
|
+
invocationId,
|
|
81
|
+
toolCallId: params.toolCallId,
|
|
82
|
+
toolName: params.toolName,
|
|
83
|
+
arguments: params.arguments,
|
|
84
|
+
descriptorRevision: params.descriptorRevision,
|
|
85
|
+
confirmationRequired,
|
|
86
|
+
deadlineAt: Date.now() + tool.descriptor.timeoutMs,
|
|
87
|
+
...uploadGrant ? { uploadGrant } : {}
|
|
88
|
+
});
|
|
89
|
+
} catch {
|
|
90
|
+
this.fail(invocationId, this.error("ENDPOINT_DISCONNECTED", "Endpoint disconnected before invocation"));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
handleMessage(endpointId, message) {
|
|
95
|
+
const invocationId = message.payload.invocationId;
|
|
96
|
+
const pending = this.pending.get(invocationId);
|
|
97
|
+
if (!pending || pending.endpointId !== endpointId) return;
|
|
98
|
+
switch (message.type) {
|
|
99
|
+
case "tool.received":
|
|
100
|
+
if (pending.state !== "sent") return;
|
|
101
|
+
pending.state = "running";
|
|
102
|
+
clearTimeout(pending.receiptTimer);
|
|
103
|
+
return;
|
|
104
|
+
case "tool.progress":
|
|
105
|
+
if (pending.state !== "running") return;
|
|
106
|
+
pending.onProgress?.({
|
|
107
|
+
...message.payload.message === void 0 ? {} : { message: message.payload.message },
|
|
108
|
+
...message.payload.percent === void 0 ? {} : { percent: message.payload.percent }
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
case "tool.result":
|
|
112
|
+
if (pending.state !== "running") return;
|
|
113
|
+
try {
|
|
114
|
+
this.options.uploads?.validateAndClose(invocationId, message.payload.content);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
this.fail(invocationId, this.error("PROTOCOL_ERROR", error instanceof Error ? error.message : String(error)));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.succeed(invocationId, {
|
|
120
|
+
content: message.payload.content,
|
|
121
|
+
...message.payload.details === void 0 ? {} : { details: message.payload.details }
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
case "tool.error":
|
|
125
|
+
this.fail(invocationId, this.error(message.payload.code, message.payload.message));
|
|
126
|
+
return;
|
|
127
|
+
case "tool.cancelled": this.fail(invocationId, this.error("TOOL_CANCELLED", "Endpoint cancelled the tool call"));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
failEndpoint(endpointId) {
|
|
131
|
+
for (const pending of this.pending.values()) if (pending.endpointId === endpointId) this.fail(pending.id, this.error("ENDPOINT_DISCONNECTED", "Endpoint disconnected"));
|
|
132
|
+
}
|
|
133
|
+
close() {
|
|
134
|
+
for (const pending of this.pending.values()) this.fail(pending.id, this.error("ENDPOINT_DISCONNECTED", "Endpoint runtime stopped"));
|
|
135
|
+
}
|
|
136
|
+
cancel(invocationId, reason, code) {
|
|
137
|
+
const pending = this.pending.get(invocationId);
|
|
138
|
+
if (!pending) return;
|
|
139
|
+
try {
|
|
140
|
+
this.registry.send(pending.endpointId, "tool.cancel", {
|
|
141
|
+
invocationId,
|
|
142
|
+
reason
|
|
143
|
+
});
|
|
144
|
+
} catch {}
|
|
145
|
+
this.fail(invocationId, this.error(code, reason));
|
|
146
|
+
}
|
|
147
|
+
succeed(invocationId, result) {
|
|
148
|
+
const pending = this.take(invocationId);
|
|
149
|
+
if (!pending) return;
|
|
150
|
+
try {
|
|
151
|
+
this.options.audit?.finished({
|
|
152
|
+
id: invocationId,
|
|
153
|
+
status: "succeeded",
|
|
154
|
+
completedAt: Date.now()
|
|
155
|
+
});
|
|
156
|
+
} finally {
|
|
157
|
+
pending.resolve(result);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
fail(invocationId, error) {
|
|
161
|
+
const pending = this.take(invocationId);
|
|
162
|
+
if (!pending) return;
|
|
163
|
+
try {
|
|
164
|
+
this.options.uploads?.abort(invocationId);
|
|
165
|
+
this.options.audit?.finished({
|
|
166
|
+
id: invocationId,
|
|
167
|
+
status: "failed",
|
|
168
|
+
...error instanceof EndpointToolExecutionError ? { errorCode: error.code } : {},
|
|
169
|
+
errorMessage: error.message,
|
|
170
|
+
completedAt: Date.now()
|
|
171
|
+
});
|
|
172
|
+
} finally {
|
|
173
|
+
pending.reject(error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
take(invocationId) {
|
|
177
|
+
const pending = this.pending.get(invocationId);
|
|
178
|
+
if (!pending) return void 0;
|
|
179
|
+
this.pending.delete(invocationId);
|
|
180
|
+
clearTimeout(pending.receiptTimer);
|
|
181
|
+
clearTimeout(pending.deadlineTimer);
|
|
182
|
+
if (pending.abortSignal && pending.abortHandler) pending.abortSignal.removeEventListener("abort", pending.abortHandler);
|
|
183
|
+
return pending;
|
|
184
|
+
}
|
|
185
|
+
error(code, message) {
|
|
186
|
+
return new EndpointToolExecutionError(code, message);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
//#endregion
|
|
190
|
+
export { EndpointInvocationService, EndpointToolExecutionError };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EndpointAvailability, EndpointKind, EndpointToolDescriptor } from '@xopcai/endpoint-tools-protocol';
|
|
2
|
+
export interface EndpointToolPolicyDecision {
|
|
3
|
+
confirmationRequired: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class EndpointToolPolicyError extends Error {
|
|
6
|
+
}
|
|
7
|
+
export declare class EndpointToolPolicy {
|
|
8
|
+
validateDescriptor(kind: EndpointKind, descriptor: EndpointToolDescriptor): void;
|
|
9
|
+
evaluate(descriptor: EndpointToolDescriptor, availability: EndpointAvailability): EndpointToolPolicyDecision;
|
|
10
|
+
}
|