@xopcai/xopc 0.0.362 → 0.0.364
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-_2aJ4ozN.js → activity-store-GvR2gZ0T.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CSIn4ghK.js → agent-avatar-dicebear-7Ct-ZlfL.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DBNFaHYa.js → agent-defaults-settings-panel-wYj-iyqv.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-DJkGbMVg.js → agent-plugin-dialog-C9HYMhnJ.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-admin-api-Dl0V7UQq.js → agents-admin-api-BkXb7VEZ.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-CuQayYYr.js → agents-hPkFQ81z.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CSczq9QV.js → app-management-settings-panel-CjfsIn9A.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-W0vc1J1Q.js → appearance-settings-qqHZ15GU.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-esnvb3hh.js → apps-page-Ba2VkQk6.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CBR91gHK.js → archive-plugin-CKe3qAaL.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-B9RdzKUS.js → automations-page-Bt8Q58ut.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-U9TEZd_t.js → automations-workspace-Ch0ViAJW.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-C9KIjPph.js → binary-plugins-J51oS7-D.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C0bammwh.js → block-editor-ClRFbHP7.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-D2E0co_S.js → browser-automation-inputs-5B3qAdmb.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-8kqdhAOz.js → browser-automations-page-BjMub7JM.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-Dl4idi13.js → browser-settings-page-CYrPA-Fp.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-Bfktn_7E.js → capabilities-BKu9BqPe.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-BmMMlNmY.js → capabilities-CT_ZW9fT.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-3ImhKPBx.js → capabilities-page-dW6FXtOy.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-4VDEB_ob.js → capabilities-settings-panel-gZ8auLwa.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-D1gxCGi8.js → capability-header-actions-L1NvoOUG.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-Drbr2JR-.js → channels-Dx5T2G73.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CSkksCaa.js → chat-terminal-dock-DsCpKPBe.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-BIXpOJAk.js → computer-settings-page-6FWwxYLe.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-CTnlVEE1.js → connector-service-page-mtH9mEBf.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BluT2l4d.js → connectors-page-DgDLaws0.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Bw-CydDe.js → date-picker-BDcwEaIx.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CgHzhtAc.js → dependency-picker-B_fPQBTM.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-YahEnyfd.js → desktop-pet-CJrO9Vd_.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-47Z4bqJr.js → desktop-pet-settings-DYAfri9w.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-C3aPEEaM.js → device-pairing-wizard-CqRys2R8.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DH_ok92y.js → directory-picker-path-field-D7_qSxNZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-t1TiLQrR.js → extension-debug-page-BGyJpRv4.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BeV-7G1h.js → extension-page-D1zBmd8F.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-CFCxzqna.js → extension-provider-F9JzOWZ3.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DCODJHOu.js → extension-settings-page-CTR8AjCG.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-CJzvASNV.js → fallback-models-Chhv4Nfv.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-B3LfyXpc.js → gateway-config-swr-CoRoOG1l.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-CWxXXAe_.js → gateway-realtime-D0ygm6bc.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-DBvCRclh.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-Q5NFzAJ_.js → gateway-settings-BVfz4Tla.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BzQP02wp.js → gateway-startup-retry-FDS6S6qa.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DndTkAw8.js → home-page-BF_9C9yW.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-BO-Xs__S.js → image-generation-api-BPd76jW5.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-Bb6Gm30L.js → imports-page-9EnECtcl.js} +1 -1
- package/dist/gateway/static/root/assets/{index-qOHWhsEK.js → index-BpXej9jJ.js} +7 -7
- package/dist/gateway/static/root/assets/index-CbJNcWAn.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D2u6sk5l.js → keyboard-shortcuts-settings-MC7mG2h2.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CHeMfXrB.js → local-app-workbench-page-CytNu0-_.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BanU1SLr.js → local-apps-page-c3HncHZ3.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-DLZQBcZY.js → local-session-drafts-gbemPamv.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BbwWB0ra.js → locale-store-DId6-v2R.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CQdHKCL0.js → logs-page-D4aXtitd.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-D0V5kCx0.js → management-settings-CRzWi_iJ.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DIBLXsPm.js → markdown-view-DQZ51j9e.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-XPzvDZPz.js → media-plugins-XLewwq2q.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-B4AhAW4B.js → messages-BHvpZNe9.js} +2 -2
- package/dist/gateway/static/root/assets/models-hub-cache-B9SKjidc.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-CodeKI_W.js → note-detail-panel-BgbByI-4.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-api-CLn4r03Z.js → notes-api-Byt65v3r.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-liRQoHbF.js → notes-page-R2BX5XCE.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-D9zkd42J.js → oauth-api-BYsCbyGZ.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-DO6DB9pi.js → page-context-capture-button-RBp1QK0F.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-DdfdwOv5.js → personal-page-F0jTBWva.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-C9a3sm6Z.js → product-open-page-BtDK68qb.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-BVe5R-Nj.js → project-detail-page-DmQEm0yH.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-D_rCwi7w.js → projects-page-CrLQvkHX.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-BFxQTbXQ.js → registry-api-7F2WNEZC.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-B3imt2du.js → remote-access-hub-C25_hQAd.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-C9WC8hJM.js → runtime-tools-settings-panel-B0c120iI.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-DL95V1UP.js → scenes-page-DM64yMnx.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CDgGmgrq.js → schema-form-DQpQc9tH.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-tkAQXGBG.js → send-session-input-D1oc6BC6.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-9X7qep91.js → session-api-N3N37MrR.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-Dy22bbJT.js → session-manager-CMGUwtbN.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CeeKIVsM.js → sessions-page-DvDO8LtA.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BNhgbmcX.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-xmUGYSOG.js → settings-page-GgBEp6O7.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-CmjT9Q4P.js → setup-status-panel-10bMi6yL.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-DeOe9qfQ.js → share-link-dialog-TBBGJPfT.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Ck27gozJ.js → share-preview-page-DyRLPsPv.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-D-GuMkPu.js → shares-api-DU0fHP2G.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DpvM2OyO.js → shares-settings-DJ1ME-XM.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-BpD02td8.js → skill-api-1Puv6wOz.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-CezAwYxM.js → skill-reload-api-ClyFqHk7.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-BCgbVI-P.js → skills-page-D52pEr5x.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-UODcpzsP.js → system-settings-panel--yV67a8L.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BbqQnNes.js → task-detail-page-D-tcS2bS.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-6IK2Ik2J.js → theme-store-OhcbFEUR.js} +1 -1
- package/dist/gateway/static/root/assets/tracing-settings-page-DoBJ0TYY.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-Eey2aZIz.js → tunnel-api-COLdiP_E.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-BrWj5mk3.js → usage-page-CtM5IfrL.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-B-3BJbnn.js → use-autosave-veoM0dHn.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-ByAHuR8v.js → use-composer-attachments-DB0bBGzZ.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-CXVwWJeP.js → use-file-preview-expanded-Bope6MW6.js} +2 -2
- package/dist/gateway/static/root/assets/{user-model-page-Cg-oM8nY.js → user-model-page-CSh61kZ5.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BtffIKZD.js → voice-api-key-field-CwD6a3KQ.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-BMm9dSKX.js → voice-config-api-Daexehmc.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-ByHhF_4r.js → work-discovery-overlay-C9u7tuEc.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DfNn5VTy.js → workflow-run-setup-panel-BMOBbf33.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-B67D-7Wt.js → workflows-page-BrD9vXqO.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-TAD7LYsc.js → workspace-api-Cs4sjV2A.js} +2 -2
- package/dist/gateway/static/root/index.html +28 -28
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +11 -7
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +28 -3
- package/dist/src/agent/embedded/run-turn.js +18 -3
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/service.js +6 -4
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth-provider-lock.js +1 -1
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/image-providers.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +3 -3
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/models.js +2 -2
- package/dist/src/cli/commands/onboard/model.js +4 -4
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/reload.d.ts +1 -0
- package/dist/src/config/reload.js +4 -0
- package/dist/src/config/rules.js +5 -0
- package/dist/src/config/schema.d.ts +23 -0
- package/dist/src/config/schema.js +6 -3
- package/dist/src/extensions/activation-context.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +2 -2
- package/dist/src/gateway/hono/routes/config-patch/misc.js +3 -3
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/models.js +2 -2
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/observability.d.ts +3 -0
- package/dist/src/gateway/hono/routes/observability.js +106 -0
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/config-coordinator.d.ts +0 -25
- package/dist/src/gateway/service/config-coordinator.js +31 -0
- package/dist/src/gateway/service.js +18 -8
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/observability/config.d.ts +40 -0
- package/dist/src/observability/config.js +31 -0
- package/dist/src/observability/langfuse.d.ts +31 -0
- package/dist/src/observability/langfuse.js +180 -0
- package/dist/src/observability/runtime.d.ts +57 -0
- package/dist/src/observability/runtime.js +404 -0
- package/dist/src/observability/sanitize.d.ts +3 -0
- package/dist/src/observability/sanitize.js +74 -0
- package/dist/src/observability/store.d.ts +20 -0
- package/dist/src/observability/store.js +128 -0
- package/dist/src/observability/storeWorker.d.ts +2 -0
- package/dist/src/observability/storeWorker.js +155 -0
- package/dist/src/observability/types.d.ts +21 -0
- package/dist/src/observability/types.js +1 -0
- package/dist/src/personal-agent/communication.js +1 -1
- package/dist/src/personal-agent/reply-composer.d.ts +22 -0
- package/dist/src/personal-agent/reply-composer.js +276 -0
- package/dist/src/personal-agent/reply-style.d.ts +2 -0
- package/dist/src/personal-agent/reply-style.js +14 -0
- package/dist/src/personal-agent/request-delivery.d.ts +1 -1
- package/dist/src/personal-agent/request-delivery.js +18 -4
- package/dist/src/personal-agent/request-service.js +1 -1
- package/dist/src/personal-agent/service.js +10 -2
- package/dist/src/platform/index.js +1 -1
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +3 -3
- package/dist/src/providers/model-call.js +19 -5
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/provider-disconnect-core.js +1 -1
- package/dist/src/providers/xopc-cloud-catalog-coordinator.js +1 -1
- package/dist/src/storage/sqlite/ai-usage-repository.d.ts +6 -0
- package/dist/src/storage/sqlite/ai-usage-repository.js +4 -2
- package/dist/src/storage/sqlite/migrations/233_observability_usage_links.sql +3 -0
- package/dist/src/storage/sqlite/migrations/234_task_result_reply.sql +14 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/task-result-delivery-service.js +20 -4
- package/dist/src/tui/backends/embedded-backend.js +3 -3
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/usage/recorder.d.ts +4 -2
- package/dist/src/usage/recorder.js +54 -26
- package/dist/src/usage/types.d.ts +3 -0
- package/dist/src/utils/logger/context.d.ts +1 -1
- package/dist/src/utils/logger/context.js +4 -1
- package/dist/src/utils/logger/types.d.ts +3 -0
- package/dist/src/voice/realtime/agentBroker.js +11 -2
- package/dist/src/voice/realtime/agentEngine.js +18 -10
- package/dist/src/voice/realtime/omniEngine.js +11 -2
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/realtime/playback-echo.d.ts +7 -0
- package/dist/src/voice/realtime/playback-echo.js +23 -1
- package/package.json +7 -4
- package/dist/gateway/static/root/assets/gateway-realtime-store-DS4WzQyF.js +0 -1
- package/dist/gateway/static/root/assets/index-Byk2QKIS.css +0 -1
- package/dist/gateway/static/root/assets/models-hub-cache-DN5MnhL8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DuvJrDU2.js +0 -1
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GatewayConfigCoordinator — owns config persistence, hot-reload, and the
|
|
3
|
-
* per-section reload handlers.
|
|
4
|
-
*
|
|
5
|
-
* Was 350 lines of `GatewayService` covering nine concerns:
|
|
6
|
-
* - manual `reloadConfig()` (CLI/UI trigger)
|
|
7
|
-
* - `saveConfig()` / `updateConfig()` (PATCH /api/config)
|
|
8
|
-
* - `setExtensionActivationTarget` (extension lifecycle)
|
|
9
|
-
* - `afterWeixinCredentialsPersisted` / `afterFeishuCredentialsPersisted`
|
|
10
|
-
* (QR-login follow-ups that bypass the watcher)
|
|
11
|
-
* - `ConfigHotReloader` (fs.watch → debounced per-section dispatch)
|
|
12
|
-
* - Section reload handlers (models / agents / channels /
|
|
13
|
-
* tools / mcp / extensions)
|
|
14
|
-
* - `scheduleChannelPluginsAfterPersist` (coalesces rapid saves so
|
|
15
|
-
* Telegram/Weixin do not stop/start repeatedly)
|
|
16
|
-
*
|
|
17
|
-
* Pulled out so the gateway composition root stays focused on lifecycle, and
|
|
18
|
-
* each handler is reachable from one place when adding a new config section.
|
|
19
|
-
*
|
|
20
|
-
* **Config state ownership.** `GatewayService.config` is still the single
|
|
21
|
-
* source of truth — this coordinator reads it via `getConfig()` and writes it
|
|
22
|
-
* back via `setConfig()` after every reload / persist. We pass through rather
|
|
23
|
-
* than holding our own copy so other coordinators (sessions, marketplace,
|
|
24
|
-
* agent runner) see the latest config the moment a reload commits.
|
|
25
|
-
*/
|
|
26
1
|
import type { Config } from '../../config/schema.js';
|
|
27
2
|
import type { AgentService } from '../../agent/service.js';
|
|
28
3
|
import type { ChannelManager } from '../../channels/manager.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { configureTracing } from "../../observability/runtime.js";
|
|
3
4
|
import { getModelRegistry } from "../../providers/model-registry.js";
|
|
4
5
|
import { init_providers } from "../../providers/index.js";
|
|
5
6
|
import { disposeAllSessionMcpRuntimes } from "../../agent/mcp/bundle-mcp-runtime.js";
|
|
@@ -11,6 +12,31 @@ import "../../config/index.js";
|
|
|
11
12
|
import { computeExtensionActivationPatch } from "../../extensions/bundled-extension-activation.js";
|
|
12
13
|
import { sanitizeTunnelConfig } from "../../tunnel/tunnel-config.js";
|
|
13
14
|
//#region src/gateway/service/config-coordinator.ts
|
|
15
|
+
/**
|
|
16
|
+
* GatewayConfigCoordinator — owns config persistence, hot-reload, and the
|
|
17
|
+
* per-section reload handlers.
|
|
18
|
+
*
|
|
19
|
+
* Was 350 lines of `GatewayService` covering nine concerns:
|
|
20
|
+
* - manual `reloadConfig()` (CLI/UI trigger)
|
|
21
|
+
* - `saveConfig()` / `updateConfig()` (PATCH /api/config)
|
|
22
|
+
* - `setExtensionActivationTarget` (extension lifecycle)
|
|
23
|
+
* - `afterWeixinCredentialsPersisted` / `afterFeishuCredentialsPersisted`
|
|
24
|
+
* (QR-login follow-ups that bypass the watcher)
|
|
25
|
+
* - `ConfigHotReloader` (fs.watch → debounced per-section dispatch)
|
|
26
|
+
* - Section reload handlers (models / agents / channels /
|
|
27
|
+
* tools / mcp / extensions)
|
|
28
|
+
* - `scheduleChannelPluginsAfterPersist` (coalesces rapid saves so
|
|
29
|
+
* Telegram/Weixin do not stop/start repeatedly)
|
|
30
|
+
*
|
|
31
|
+
* Pulled out so the gateway composition root stays focused on lifecycle, and
|
|
32
|
+
* each handler is reachable from one place when adding a new config section.
|
|
33
|
+
*
|
|
34
|
+
* **Config state ownership.** `GatewayService.config` is still the single
|
|
35
|
+
* source of truth — this coordinator reads it via `getConfig()` and writes it
|
|
36
|
+
* back via `setConfig()` after every reload / persist. We pass through rather
|
|
37
|
+
* than holding our own copy so other coordinators (sessions, marketplace,
|
|
38
|
+
* agent runner) see the latest config the moment a reload commits.
|
|
39
|
+
*/
|
|
14
40
|
init_providers();
|
|
15
41
|
init_logger();
|
|
16
42
|
const log = createLogger("GatewayConfigCoordinator");
|
|
@@ -26,6 +52,10 @@ var GatewayConfigCoordinator = class {
|
|
|
26
52
|
startHotReloader() {
|
|
27
53
|
if (this.configReloader) return;
|
|
28
54
|
this.configReloader = new ConfigHotReloader(this.opts.configPath, this.opts.getConfig(), {
|
|
55
|
+
onTracingReload: async (next) => {
|
|
56
|
+
this.opts.setConfig(next);
|
|
57
|
+
await configureTracing(next.observability?.tracing);
|
|
58
|
+
},
|
|
29
59
|
onModelsReload: (newConfig) => this.handleModelsReload(newConfig),
|
|
30
60
|
onChannelsReload: (newConfig) => this.handleChannelsReload(newConfig),
|
|
31
61
|
onCronReload: (newConfig) => this.handleAutomationReload(newConfig),
|
|
@@ -316,6 +346,7 @@ var GatewayConfigCoordinator = class {
|
|
|
316
346
|
await saveConfig(configToWrite, this.opts.configPath);
|
|
317
347
|
const reloaded = loadConfig(this.opts.configPath);
|
|
318
348
|
this.opts.setConfig(reloaded);
|
|
349
|
+
await configureTracing(reloaded.observability?.tracing);
|
|
319
350
|
if (sanitizeTunnelConfig(reloaded)) await saveConfig(reloaded, this.opts.configPath);
|
|
320
351
|
this.opts.getAgentService().applyRuntimeConfiguration(reloaded);
|
|
321
352
|
await this.opts.reconcileMemoryMaintenanceAutomations().catch((err) => {
|
|
@@ -17,14 +17,15 @@ import { init_session_repository, listSessionMetadata, patchSessionMetadata } fr
|
|
|
17
17
|
import { getSessionConfig, init_config_repository } from "../storage/sqlite/config-repository.js";
|
|
18
18
|
import { init_sqlite } from "../storage/sqlite/index.js";
|
|
19
19
|
import { normalizeAgentId } from "../agent-catalog/id.js";
|
|
20
|
+
import { init_agent_scope, listAgentEntries, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
21
|
+
import { init_paths, resolveConfigPath, resolveExtensionsDir } from "../config/paths.js";
|
|
22
|
+
import { flushTracing } from "../observability/runtime.js";
|
|
20
23
|
import { init_config, resolveKnowledgeReadPolicy } from "../user-context/config.js";
|
|
21
24
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
22
|
-
import { init_agent_scope, listAgentEntries, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
23
25
|
import { init_agent_session_key, resolveAgentMainConversationId } from "../routing/agent-session-key.js";
|
|
24
26
|
import { init_session_key, resolveConversationId, sanitizeSegment } from "../routing/session-key.js";
|
|
25
27
|
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
26
28
|
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
27
|
-
import { init_paths, resolveConfigPath, resolveExtensionsDir } from "../config/paths.js";
|
|
28
29
|
import { prewarmModelRegistry } from "../providers/model-registry.js";
|
|
29
30
|
import { init_providers, providers_exports } from "../providers/index.js";
|
|
30
31
|
import { AI_USAGE_RETENTION_MS, markStaleAiUsageEventsUnknown, pruneAiUsageEvents } from "../storage/sqlite/ai-usage-repository.js";
|
|
@@ -78,6 +79,7 @@ import "../config/index.js";
|
|
|
78
79
|
import { ManagedComposioEventPoller } from "../connectors/composio-managed-events.js";
|
|
79
80
|
import { startConnectedKnowledgeCoordinator } from "../knowledge/coordinator.js";
|
|
80
81
|
import "../knowledge/index.js";
|
|
82
|
+
import { PersonalReplyComposer } from "../personal-agent/reply-composer.js";
|
|
81
83
|
import { ConnectionRecoveryService } from "../connectors/connection-recovery-service.js";
|
|
82
84
|
import { startConnectorLearningCoordinator } from "../connectors/learning-coordinator.js";
|
|
83
85
|
import { startConnectorSupervisor } from "../connectors/supervisor.js";
|
|
@@ -89,6 +91,10 @@ import { DiscussionSealer } from "../discussions/sealer.js";
|
|
|
89
91
|
import "../discussions/index.js";
|
|
90
92
|
import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
91
93
|
import "../endpoint-tools/index.js";
|
|
94
|
+
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
95
|
+
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
96
|
+
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
97
|
+
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
92
98
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
93
99
|
import { prepareAutomationAgentSession } from "./automation-agent-session.js";
|
|
94
100
|
import { stopTailscaleExposure } from "./tailscale-lifecycle.js";
|
|
@@ -151,10 +157,6 @@ import { TaskMainUpdateDecisionService } from "../tasks/task-main-update-decisio
|
|
|
151
157
|
import { selectTaskMainUpdateAttempt, submitAndConfirmTaskMainUpdate } from "../tasks/task-main-update-input.js";
|
|
152
158
|
import { checkAppContextAccess, prepareAppContext } from "./service/app-context-access.js";
|
|
153
159
|
import { applyAutomaticVoiceLanguage, inferProductLanguageFromEnvironment, initializeVoiceDefaults } from "../voice/language-profile.js";
|
|
154
|
-
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
155
|
-
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
156
|
-
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
157
|
-
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
158
160
|
import crypto from "node:crypto";
|
|
159
161
|
//#region src/gateway/service.ts
|
|
160
162
|
init_session_repository();
|
|
@@ -883,7 +885,7 @@ var GatewayService = class {
|
|
|
883
885
|
}, `Main Agent update dispatch failed: ${errorMessage}`);
|
|
884
886
|
});
|
|
885
887
|
taskResultDispatch = createBackgroundTask(async () => {
|
|
886
|
-
|
|
888
|
+
const notify = (conversationId, deliveryId) => {
|
|
887
889
|
this.realtime.broker.publish("sessions", "session.task-result", {
|
|
888
890
|
conversationId,
|
|
889
891
|
deliveryId
|
|
@@ -892,6 +894,13 @@ var GatewayService = class {
|
|
|
892
894
|
key: conversationId,
|
|
893
895
|
deliveryId
|
|
894
896
|
});
|
|
897
|
+
};
|
|
898
|
+
await new TaskResultDeliveryService().drain(notify);
|
|
899
|
+
new PersonalReplyComposer().drain(notify).catch((err) => {
|
|
900
|
+
log.error({
|
|
901
|
+
err,
|
|
902
|
+
phase: "task_result_reply"
|
|
903
|
+
}, "Task result reply delivery failed");
|
|
895
904
|
});
|
|
896
905
|
}, (err) => {
|
|
897
906
|
log.error({
|
|
@@ -1513,6 +1522,7 @@ var GatewayService = class {
|
|
|
1513
1522
|
}
|
|
1514
1523
|
}
|
|
1515
1524
|
async stop() {
|
|
1525
|
+
await flushTracing();
|
|
1516
1526
|
if (!this.running) return;
|
|
1517
1527
|
this.stopping = true;
|
|
1518
1528
|
this.taskRunDispatcher?.stop();
|
|
@@ -1563,7 +1573,7 @@ var GatewayService = class {
|
|
|
1563
1573
|
await disposeAllSessionMcpRuntimes().catch((err) => {
|
|
1564
1574
|
log.warn({ err }, "MCP runtime shutdown failed");
|
|
1565
1575
|
});
|
|
1566
|
-
this._agentService?.stop();
|
|
1576
|
+
await this._agentService?.stop();
|
|
1567
1577
|
this.running = false;
|
|
1568
1578
|
this.bus.shutdown();
|
|
1569
1579
|
this.lastDeferredChannelConnectIds = [];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
2
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
2
3
|
import { getModelCatalogStore, init_model_catalog_store } from "../providers/model-catalog-store.js";
|
|
3
4
|
import { getAvailableModels, init_providers } from "../providers/index.js";
|
|
4
5
|
import { compareCatalogModels } from "../providers/model-catalog-ranking.js";
|
|
5
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
6
6
|
import { prepareUpdateGlobalDefaults } from "./global-defaults-admin.js";
|
|
7
7
|
//#region src/gateway/xopc-cloud-capability-setup.ts
|
|
8
8
|
init_repository();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import { HomeAdviceBudgetExceededError } from "./generator.js";
|
|
4
3
|
import { homePatternKey } from "./strategy.js";
|
|
5
|
-
import { HomeAdvicePolicy } from "./policy.js";
|
|
6
4
|
import { HomeIntelligenceRepository } from "./repository.js";
|
|
7
5
|
import { HomeOpportunityApplicationService } from "./application-service.js";
|
|
6
|
+
import { HomeAdvicePolicy } from "./policy.js";
|
|
7
|
+
import { HomeAdviceBudgetExceededError } from "./generator.js";
|
|
8
8
|
import { buildHomeOpportunityNotification } from "./notification.js";
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
//#region src/home-intelligence/host.ts
|
|
@@ -2,8 +2,8 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { init_paths, resolveConfigPath } from "../config/paths.js";
|
|
4
4
|
import { loadConfig } from "../config/loader.js";
|
|
5
|
-
import { resolveGatewayService } from "../daemon/service.js";
|
|
6
5
|
import { isRestartEnabled } from "../config/commands.flags.js";
|
|
6
|
+
import { resolveGatewayService } from "../daemon/service.js";
|
|
7
7
|
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "./restart.js";
|
|
8
8
|
import { findVerifiedGatewayListenerPidsOnPortSync, signalVerifiedGatewayPidSync } from "./gateway-processes.js";
|
|
9
9
|
import { refreshGatewayServiceAfterUpdate } from "./update-service-refresh.js";
|
|
@@ -5,10 +5,10 @@ import { currentOperationId, init_operation_context } from "../infra/operation-c
|
|
|
5
5
|
import { afterSqliteCommit, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
6
6
|
import { ExtensionCapabilityBindingsSchema, extensionCapabilityPermissions } from "../../packages/gateway-contract/src/extension-capabilities.js";
|
|
7
7
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
8
|
+
import { CapabilityError } from "../capabilities/runtime/errors.js";
|
|
8
9
|
import { init_paths, resolveExtensionsDir } from "../config/paths.js";
|
|
9
10
|
import { LocalAppStore } from "./store.js";
|
|
10
11
|
import { slugifyProjectName } from "../projects/project-store.js";
|
|
11
|
-
import { CapabilityError } from "../capabilities/runtime/errors.js";
|
|
12
12
|
import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
|
|
13
13
|
import { validateLocalAppCapabilityContracts } from "./capabilities/contracts.js";
|
|
14
14
|
import { buildLocalAppFixGuidance } from "./fix-guidance.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const TracingConfigSchema: z.ZodObject<{
|
|
3
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
4
|
+
capture: z.ZodDefault<z.ZodEnum<{
|
|
5
|
+
metadata: "metadata";
|
|
6
|
+
redacted: "redacted";
|
|
7
|
+
detailed: "detailed";
|
|
8
|
+
}>>;
|
|
9
|
+
detailedUntil: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
local: z.ZodPrefault<z.ZodObject<{
|
|
11
|
+
retentionDays: z.ZodDefault<z.ZodNumber>;
|
|
12
|
+
maxStoreMiB: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
maxTraces: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
maxSpans: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
maxTraceKiB: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
maxWriteMiBPerMinute: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
langfuse: z.ZodPrefault<z.ZodObject<{
|
|
19
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
export type TracingConfig = z.infer<typeof TracingConfigSchema>;
|
|
24
|
+
export declare const defaultTracingConfig: () => {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
capture: "metadata" | "redacted" | "detailed";
|
|
27
|
+
local: {
|
|
28
|
+
retentionDays: number;
|
|
29
|
+
maxStoreMiB: number;
|
|
30
|
+
maxTraces: number;
|
|
31
|
+
maxSpans: number;
|
|
32
|
+
maxTraceKiB: number;
|
|
33
|
+
maxWriteMiBPerMinute: number;
|
|
34
|
+
};
|
|
35
|
+
langfuse: {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
baseUrl: string;
|
|
38
|
+
};
|
|
39
|
+
detailedUntil?: number;
|
|
40
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/observability/config.ts
|
|
4
|
+
var TracingConfigSchema, defaultTracingConfig;
|
|
5
|
+
var init_config = __esmMin((() => {
|
|
6
|
+
TracingConfigSchema = z.object({
|
|
7
|
+
enabled: z.boolean().default(true),
|
|
8
|
+
capture: z.enum([
|
|
9
|
+
"metadata",
|
|
10
|
+
"redacted",
|
|
11
|
+
"detailed"
|
|
12
|
+
]).default("redacted"),
|
|
13
|
+
detailedUntil: z.number().int().nonnegative().optional(),
|
|
14
|
+
local: z.object({
|
|
15
|
+
retentionDays: z.number().int().min(1).max(90).default(7),
|
|
16
|
+
maxStoreMiB: z.number().int().min(16).max(4096).default(256),
|
|
17
|
+
maxTraces: z.number().int().min(10).max(1e5).default(1e4),
|
|
18
|
+
maxSpans: z.number().int().min(100).max(1e6).default(1e5),
|
|
19
|
+
maxTraceKiB: z.number().int().min(16).max(4096).default(1024),
|
|
20
|
+
maxWriteMiBPerMinute: z.number().int().min(1).max(100).default(2)
|
|
21
|
+
}).prefault({}),
|
|
22
|
+
langfuse: z.object({
|
|
23
|
+
enabled: z.boolean().default(false),
|
|
24
|
+
baseUrl: z.string().url().max(2048).refine((value) => ["http:", "https:"].includes(new URL(value).protocol), "HTTP(S) URL required").default("https://cloud.langfuse.com")
|
|
25
|
+
}).prefault({})
|
|
26
|
+
}).strict();
|
|
27
|
+
defaultTracingConfig = () => TracingConfigSchema.parse({});
|
|
28
|
+
}));
|
|
29
|
+
//#endregion
|
|
30
|
+
init_config();
|
|
31
|
+
export { TracingConfigSchema, defaultTracingConfig, init_config };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TraceRecord } from './types.js';
|
|
2
|
+
/** Bounded OTLP/HTTP JSON exporter. No hidden SDK queue or durable replay. */
|
|
3
|
+
export declare class LangfuseTarget {
|
|
4
|
+
private baseUrl;
|
|
5
|
+
private publicKey;
|
|
6
|
+
private secretKey;
|
|
7
|
+
private queue;
|
|
8
|
+
private bytes;
|
|
9
|
+
private timer?;
|
|
10
|
+
private sending?;
|
|
11
|
+
private controller?;
|
|
12
|
+
private closed;
|
|
13
|
+
private lastWarning;
|
|
14
|
+
dropped: number;
|
|
15
|
+
lastSuccess?: number;
|
|
16
|
+
lastFailure?: number;
|
|
17
|
+
lastError?: string;
|
|
18
|
+
constructor(baseUrl: string, publicKey: string, secretKey: string);
|
|
19
|
+
status(): {
|
|
20
|
+
state: string;
|
|
21
|
+
pending: number;
|
|
22
|
+
dropped: number;
|
|
23
|
+
lastSuccess: number;
|
|
24
|
+
lastFailure: number;
|
|
25
|
+
lastError: string;
|
|
26
|
+
};
|
|
27
|
+
enqueue(record: TraceRecord): void;
|
|
28
|
+
flush(): Promise<void>;
|
|
29
|
+
private send;
|
|
30
|
+
close(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { createLogger } from "../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../utils/logger.js";
|
|
3
|
+
//#region src/observability/langfuse.ts
|
|
4
|
+
init_logger();
|
|
5
|
+
const log = createLogger("Observability:Langfuse");
|
|
6
|
+
function otlp(record) {
|
|
7
|
+
const attributes = Object.entries(record.attributes).map(([key, value]) => ({
|
|
8
|
+
key,
|
|
9
|
+
value: typeof value === "number" ? { doubleValue: value } : typeof value === "boolean" ? { boolValue: value } : { stringValue: value }
|
|
10
|
+
}));
|
|
11
|
+
return {
|
|
12
|
+
traceId: record.traceId,
|
|
13
|
+
spanId: record.spanId,
|
|
14
|
+
parentSpanId: record.parentSpanId,
|
|
15
|
+
name: record.name,
|
|
16
|
+
kind: 1,
|
|
17
|
+
startTimeUnixNano: String(BigInt(Math.floor(record.startedAt * 1e3)) * 1000n),
|
|
18
|
+
endTimeUnixNano: String(BigInt(Math.floor((record.endedAt ?? record.startedAt) * 1e3)) * 1000n),
|
|
19
|
+
attributes,
|
|
20
|
+
status: { code: record.status === "error" ? 2 : 1 }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Bounded OTLP/HTTP JSON exporter. No hidden SDK queue or durable replay. */
|
|
24
|
+
var LangfuseTarget = class {
|
|
25
|
+
queue = [];
|
|
26
|
+
bytes = 0;
|
|
27
|
+
timer;
|
|
28
|
+
sending;
|
|
29
|
+
controller;
|
|
30
|
+
closed = false;
|
|
31
|
+
lastWarning = 0;
|
|
32
|
+
dropped = 0;
|
|
33
|
+
lastSuccess;
|
|
34
|
+
lastFailure;
|
|
35
|
+
lastError;
|
|
36
|
+
constructor(baseUrl, publicKey, secretKey) {
|
|
37
|
+
this.baseUrl = baseUrl;
|
|
38
|
+
this.publicKey = publicKey;
|
|
39
|
+
this.secretKey = secretKey;
|
|
40
|
+
}
|
|
41
|
+
status() {
|
|
42
|
+
return {
|
|
43
|
+
state: this.lastError ? "degraded" : "ready",
|
|
44
|
+
pending: this.queue.length,
|
|
45
|
+
dropped: this.dropped,
|
|
46
|
+
lastSuccess: this.lastSuccess,
|
|
47
|
+
lastFailure: this.lastFailure,
|
|
48
|
+
lastError: this.lastError
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
enqueue(record) {
|
|
52
|
+
if (this.closed) return;
|
|
53
|
+
const bytes = Buffer.byteLength(JSON.stringify(record));
|
|
54
|
+
if (this.queue.length >= 2e3 || this.bytes + bytes > 8 * 1048576) {
|
|
55
|
+
this.dropped++;
|
|
56
|
+
this.lastError = "Export queue full";
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.queue.push({
|
|
60
|
+
record,
|
|
61
|
+
bytes
|
|
62
|
+
});
|
|
63
|
+
this.bytes += bytes;
|
|
64
|
+
if (this.queue.length >= 100) this.flush();
|
|
65
|
+
else if (!this.timer) {
|
|
66
|
+
this.timer = setTimeout(() => {
|
|
67
|
+
this.timer = void 0;
|
|
68
|
+
this.flush();
|
|
69
|
+
}, 5e3);
|
|
70
|
+
this.timer.unref();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async flush() {
|
|
74
|
+
if (this.sending) {
|
|
75
|
+
await this.sending;
|
|
76
|
+
if (this.queue.length && !this.closed) await this.flush();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.timer) {
|
|
80
|
+
clearTimeout(this.timer);
|
|
81
|
+
this.timer = void 0;
|
|
82
|
+
}
|
|
83
|
+
if (this.closed || !this.queue.length) return;
|
|
84
|
+
const batch = this.queue.splice(0, 100);
|
|
85
|
+
this.bytes -= batch.reduce((n, row) => n + row.bytes, 0);
|
|
86
|
+
this.sending = this.send(batch.map((row) => row.record)).finally(() => {
|
|
87
|
+
this.sending = void 0;
|
|
88
|
+
});
|
|
89
|
+
await this.sending;
|
|
90
|
+
if (this.queue.length && !this.closed && !this.timer) {
|
|
91
|
+
this.timer = setTimeout(() => {
|
|
92
|
+
this.timer = void 0;
|
|
93
|
+
this.flush();
|
|
94
|
+
}, 5e3);
|
|
95
|
+
this.timer.unref();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async send(records) {
|
|
99
|
+
for (let attempt = 0; attempt < 3 && !this.closed; attempt++) {
|
|
100
|
+
this.controller = new AbortController();
|
|
101
|
+
const timeout = setTimeout(() => this.controller?.abort(), 5e3);
|
|
102
|
+
try {
|
|
103
|
+
const response = await fetch(this.baseUrl.replace(/\/$/, "") + "/api/public/otel/v1/traces", {
|
|
104
|
+
method: "POST",
|
|
105
|
+
redirect: "error",
|
|
106
|
+
signal: this.controller.signal,
|
|
107
|
+
headers: {
|
|
108
|
+
"Content-Type": "application/json",
|
|
109
|
+
Authorization: `Basic ${Buffer.from(`${this.publicKey}:${this.secretKey}`).toString("base64")}`,
|
|
110
|
+
"x-langfuse-ingestion-version": "4"
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify({ resourceSpans: [{
|
|
113
|
+
resource: { attributes: [{
|
|
114
|
+
key: "service.name",
|
|
115
|
+
value: { stringValue: "xopc" }
|
|
116
|
+
}] },
|
|
117
|
+
scopeSpans: [{
|
|
118
|
+
scope: { name: "xopc.observability" },
|
|
119
|
+
spans: records.map(otlp)
|
|
120
|
+
}]
|
|
121
|
+
}] })
|
|
122
|
+
});
|
|
123
|
+
if (!response.ok) {
|
|
124
|
+
await response.body?.cancel();
|
|
125
|
+
throw new Error(`Langfuse returned HTTP ${response.status}`);
|
|
126
|
+
}
|
|
127
|
+
if (response.body) {
|
|
128
|
+
const reader = response.body.getReader();
|
|
129
|
+
const chunks = [];
|
|
130
|
+
let size = 0;
|
|
131
|
+
try {
|
|
132
|
+
while (true) {
|
|
133
|
+
const chunk = await reader.read();
|
|
134
|
+
if (chunk.done) break;
|
|
135
|
+
size += chunk.value.length;
|
|
136
|
+
if (size > 16384) {
|
|
137
|
+
await reader.cancel();
|
|
138
|
+
throw new Error("Oversized ingestion response");
|
|
139
|
+
}
|
|
140
|
+
chunks.push(chunk.value);
|
|
141
|
+
}
|
|
142
|
+
const text = Buffer.concat(chunks).toString("utf8");
|
|
143
|
+
if (text && Number(JSON.parse(text).partialSuccess?.rejectedSpans ?? 0) > 0) throw new Error("Ingestion rejected spans");
|
|
144
|
+
} finally {
|
|
145
|
+
reader.releaseLock();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.lastSuccess = Date.now();
|
|
149
|
+
this.lastError = void 0;
|
|
150
|
+
return;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
this.lastFailure = Date.now();
|
|
153
|
+
if (Date.now() - this.lastWarning > 6e4) {
|
|
154
|
+
this.lastWarning = Date.now();
|
|
155
|
+
log.warn({
|
|
156
|
+
phase: "langfuse_export",
|
|
157
|
+
attempt: attempt + 1
|
|
158
|
+
}, "Langfuse trace export failed; local recording continues");
|
|
159
|
+
}
|
|
160
|
+
this.lastError = error instanceof Error && /^Langfuse returned HTTP \d+$/.test(error.message) ? error.message : "Langfuse export failed";
|
|
161
|
+
} finally {
|
|
162
|
+
clearTimeout(timeout);
|
|
163
|
+
}
|
|
164
|
+
if (attempt < 2 && !this.closed) await new Promise((resolve) => {
|
|
165
|
+
setTimeout(resolve, 250 * 2 ** attempt).unref();
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
this.dropped += records.length;
|
|
169
|
+
}
|
|
170
|
+
close() {
|
|
171
|
+
this.closed = true;
|
|
172
|
+
this.controller?.abort();
|
|
173
|
+
if (this.timer) clearTimeout(this.timer);
|
|
174
|
+
this.dropped += this.queue.length;
|
|
175
|
+
this.queue = [];
|
|
176
|
+
this.bytes = 0;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
//#endregion
|
|
180
|
+
export { LangfuseTarget };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Span, type Attributes } from '@opentelemetry/api';
|
|
2
|
+
import { type TracingConfig } from './config.js';
|
|
3
|
+
import { LocalTraceStore } from './store.js';
|
|
4
|
+
import type { TraceRecord } from './types.js';
|
|
5
|
+
export type TraceIdentity = {
|
|
6
|
+
conversationId?: string;
|
|
7
|
+
runId?: string;
|
|
8
|
+
agentId?: string;
|
|
9
|
+
transcriptId?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function localStore(): LocalTraceStore;
|
|
12
|
+
export declare function tracingConfig(): TracingConfig;
|
|
13
|
+
export declare function configureTracing(value?: unknown): Promise<void>;
|
|
14
|
+
export declare function tracingStatus(): Promise<{
|
|
15
|
+
local: any;
|
|
16
|
+
langfuse: {
|
|
17
|
+
state: string;
|
|
18
|
+
pending: number;
|
|
19
|
+
dropped: number;
|
|
20
|
+
lastSuccess: number;
|
|
21
|
+
lastFailure: number;
|
|
22
|
+
lastError: string;
|
|
23
|
+
} | {
|
|
24
|
+
state: string;
|
|
25
|
+
pending: number;
|
|
26
|
+
dropped: number;
|
|
27
|
+
};
|
|
28
|
+
active: number;
|
|
29
|
+
dropped: number;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function traceIds(): {
|
|
32
|
+
traceId?: string;
|
|
33
|
+
spanId?: string;
|
|
34
|
+
};
|
|
35
|
+
export type Observation = {
|
|
36
|
+
span?: Span;
|
|
37
|
+
run: <T>(fn: () => T) => T;
|
|
38
|
+
finish: (status?: string, output?: unknown) => void;
|
|
39
|
+
input: (value: unknown) => void;
|
|
40
|
+
update: (values: Attributes) => void;
|
|
41
|
+
};
|
|
42
|
+
export declare function startObservation(name: string, type: TraceRecord['type'], identity?: TraceIdentity): Observation;
|
|
43
|
+
export declare function traceRun<T extends {
|
|
44
|
+
ok?: boolean;
|
|
45
|
+
stopReason?: string;
|
|
46
|
+
errorMessage?: string;
|
|
47
|
+
lastAssistantText?: string;
|
|
48
|
+
}>(name: string, identity: TraceIdentity, fn: () => Promise<T>, input?: unknown): Promise<T>;
|
|
49
|
+
export declare function traceTools<T extends {
|
|
50
|
+
name: string;
|
|
51
|
+
execute: (...args: any[]) => any;
|
|
52
|
+
}>(tools: T[]): T[];
|
|
53
|
+
export declare function flushTracing(): Promise<void>;
|
|
54
|
+
export declare function testLangfuse(): Promise<boolean>;
|
|
55
|
+
export declare function closeTracing(): Promise<void>;
|
|
56
|
+
export declare function traceOperation<T>(name: string, fn: () => Promise<T>, attributes?: Attributes): Promise<T>;
|
|
57
|
+
export declare function setTraceIdentity(identity: TraceIdentity): void;
|