@xopcai/xopc 0.0.335 → 0.0.337
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/dist/assets/{auth-Cjj5SuoT.js → auth-BsvblhQz.js} +2 -1
- package/dist/browser-ext/dist/background.js +1 -1
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +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/{agent-avatar-dicebear-DtmNsTNI.js → agent-avatar-dicebear-CSHghJkF.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-AvGo9fao.js → agent-defaults-settings-panel-DcDz1HJb.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-DZCh4_E1.js → agent-plugin-dialog-C7A9k86o.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-Drt1vHf6.js → agents-wih5cVy1.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-IKZm5_s2.js → app-management-settings-panel-LQ_zVJ9C.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DKWGkrVW.js → appearance-settings-C2gaax8U.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DY6Q7TMZ.js → apps-page-CobrkzwB.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-DXGAt0G7.js → archive-plugin-CK_qS4Ex.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DzqfYcqe.js → automations-page-DtuUM9W8.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-qMpqvBz1.js → automations-workspace-BNcU6ReT.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-Cy2FLsPv.js → binary-plugins-BN0iLzVY.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BqSpSNnv.js → block-editor-CpLJmCV2.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BEeyiVEw.js → browser-automations-page-DqKKZQNI.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-D6SygxnY.js → browser-settings-page-B0Vxlns8.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-C9Od0WN-.js → capabilities-page-Bn72DIFn.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-6HAVkNE4.js → capabilities-settings-panel-n4g4t5LK.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-CwcT7mjE.js → capability-header-actions-CIxZrN4w.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-D5HNBMLS.js → channels-D8P0Sbu1.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BsxTfU1T.js → chat-terminal-dock-BJzZ5vkP.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CH01h8yI.js → computer-settings-page-WT8yMsKu.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-CTi8iaOn.js → connector-service-page-71NVbenX.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-C3GhbPPg.js → connectors-page-DdBdSoYi.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-DTEOeiC4.js → date-picker-WyLSk4_J.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DFA0RZ02.js → dependency-picker-BTdAiaBP.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Txr49_Zi.js → desktop-pet-f0MgT5Um.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-Coi0DUai.js → desktop-pet-settings-DKVITn3D.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-OPY8ujCN.js → device-pairing-wizard-1Buarqmz.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-B1ckH4hn.js → directory-picker-path-field-BoGtoYn0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-6e8BCEb6.js → extension-debug-page-DPwnz1-y.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DgaFykYf.js → extension-page-CzioOhli.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-B-TyR9GM.js → extension-settings-page-Cqq5bdYp.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-vOLum3RR.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-CtjGyqB2.js → gateway-settings-CoXYbhk4.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-Cs5fPXcJ.js → home-page-z3Jiv5fF.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-C72wCY44.js → imports-page-DHiUg7PR.js} +1 -1
- package/dist/gateway/static/root/assets/index-Bd7mDZFV.css +1 -0
- package/dist/gateway/static/root/assets/{index-BkSp_1Il.js → index-D3OtdgCs.js} +10 -10
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D1nzw6zI.js → keyboard-shortcuts-settings-CbcZK4S6.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DqB0hGrZ.js → local-app-workbench-page-3HC00KSx.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-D4FX0Ptx.js → local-apps-page-etrJtvmm.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CcWD_-zy.js → logs-page-BsSdbCw2.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-L9YGzLaz.js → management-settings-DODrHfBO.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DqsiYyAz.js → media-plugins-C0JdlHpy.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-DwK9Ndw1.js → note-detail-panel-fPUNv1PI.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-D2FvAV9x.js → notes-page-I9h6l38z.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-CeWnFomm.js → page-context-capture-button-BlcjlzGF.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-B90ywILw.js → page-tabs-_eLR6cpb.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CwuY-FIE.js → preview-open-alternatives-BfJBJ4NU.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CUcJOCAz.js → product-open-page-RdYBwQ_V.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Blo9-zcq.js → project-detail-page-DyAKlm_h.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-C9rh1U9Z.js → projects-page-Bk51sbKy.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-Cw2Beq7s.js → remote-access-hub-BbMbnizV.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Cj8LnZRV.js → runtime-tools-settings-panel-yqbX-cYN.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-BZd4VZBP.js → scenes-page-L69Imde_.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CNbrdYAu.js → schema-form-BWlMiaNv.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-DAck_U0C.js → session-manager-g96pFnRm.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BKt3Cd0a.js → sessions-page-S-UqCz6P.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Q52AAHh_.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-u6ZXo3oJ.js → settings-form-section-DqUsAh0K.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-gXacaOIv.js → settings-page-4eoaA_Hs.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-qKaz5drv.js → setup-status-panel-6BuwbANT.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-DdkQ-B5M.js → share-preview-page-B-w3pIG5.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-BwFn5CYE.js → shares-settings-Bn03bnYk.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-Cf3_ZQOb.js → skill-api-BN7zgPjv.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-CdNp1N-Y.js → skill-reload-api-BsBfMvch.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-fKPvwSpa.js → skills-page-CcYeAh5v.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CO3l1jdd.js → system-settings-panel-BV2zesop.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-zClWGuT5.js → task-detail-page-BqN3GUm7.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Dw6DW1j5.js → tunnel-api-Dk3SmnSL.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-QP_8nuHU.js → usage-page-DStU1Zyn.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-ZwnXUpG4.js → use-autosave-D3oLuZ7h.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-B72PRFAI.js → user-model-page-BXMZoqpb.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-CbIxN5SC.js → voice-api-key-field-CzvudzG6.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-WIGHfEL3.js → work-discovery-overlay-D6oUEOYn.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Bk0Jhdeq.js → workflow-run-setup-panel-CXxr4wmO.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-BC385JPr.js → workflows-page-D9uPt_T2.js} +1 -1
- package/dist/gateway/static/root/index.html +4 -4
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/product-delivery.js +10 -1
- package/dist/packages/realtime-protocol/src/index.js +2 -1
- package/dist/src/agent/agent-manager.js +5 -5
- package/dist/src/agent/background-review/run-background-review.js +2 -2
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/image/tool-model-config.js +2 -2
- package/dist/src/agent/service.js +4 -4
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +1 -1
- package/dist/src/auth/oauth-provider-lock.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/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/provider-auth.js +2 -2
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/computer/runtime.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/chat-stream/mapper.js +2 -0
- package/dist/src/gateway/chat-stream/protocol.d.ts +1 -0
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- 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/sessions.js +11 -2
- 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/service/sessions-api.d.ts +4 -1
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/generator.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/notes/service.js +1 -1
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/realtime/compact-run-event.d.ts +3 -0
- package/dist/src/realtime/compact-run-event.js +50 -0
- package/dist/src/realtime/runtime.js +7 -2
- package/dist/src/session/client-history.d.ts +1 -0
- package/dist/src/session/compact-history.d.ts +6 -0
- package/dist/src/session/compact-history.js +55 -0
- package/dist/src/session/manager.d.ts +1 -0
- package/dist/src/session/store.d.ts +1 -0
- package/dist/src/session/store.js +6 -3
- package/dist/src/storage/sqlite/transcript-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/transcript-repository.js +10 -1
- package/dist/src/tasks/capabilities/read.js +2 -2
- 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 +2 -2
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/work-discovery/service.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/gateway-realtime-CGjSxzj6.js +0 -1
- package/dist/gateway/static/root/assets/index-DbLEkdNg.css +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BToasX5M.js +0 -1
|
@@ -16,17 +16,17 @@ import { init_session_repository, listSessionMetadata, patchSessionMetadata } fr
|
|
|
16
16
|
import { getSessionConfig, init_config_repository } from "../storage/sqlite/config-repository.js";
|
|
17
17
|
import { init_sqlite } from "../storage/sqlite/index.js";
|
|
18
18
|
import { normalizeAgentId } from "../agent-catalog/id.js";
|
|
19
|
-
import { init_agent_scope, listAgentEntries, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
20
|
-
import { init_paths, resolveConfigPath, resolveExtensionsDir } from "../config/paths.js";
|
|
21
19
|
import { init_config, resolveKnowledgeReadPolicy } from "../user-context/config.js";
|
|
22
20
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
23
|
-
import {
|
|
21
|
+
import { init_agent_scope, listAgentEntries, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
24
22
|
import { init_agent_session_key, resolveAgentMainConversationId } from "../routing/agent-session-key.js";
|
|
25
23
|
import { init_session_key, resolveConversationId, sanitizeSegment } from "../routing/session-key.js";
|
|
26
24
|
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
25
|
+
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
26
|
+
import { init_paths, resolveConfigPath, resolveExtensionsDir } from "../config/paths.js";
|
|
27
|
+
import { prewarmModelRegistry } from "../providers/model-registry.js";
|
|
27
28
|
import { init_providers, providers_exports } from "../providers/index.js";
|
|
28
29
|
import { AI_USAGE_RETENTION_MS, markStaleAiUsageEventsUnknown, pruneAiUsageEvents } from "../storage/sqlite/ai-usage-repository.js";
|
|
29
|
-
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
30
30
|
import { TaskConversationRepository } from "../tasks/task-conversation-repository.js";
|
|
31
31
|
import { listKnowledgeItems } from "../knowledge-memory/repository.js";
|
|
32
32
|
import "../knowledge-memory/index.js";
|
|
@@ -79,14 +79,14 @@ import "../knowledge/index.js";
|
|
|
79
79
|
import { ConnectionRecoveryService } from "../connectors/connection-recovery-service.js";
|
|
80
80
|
import { startConnectorLearningCoordinator } from "../connectors/learning-coordinator.js";
|
|
81
81
|
import { startConnectorSupervisor } from "../connectors/supervisor.js";
|
|
82
|
-
import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
83
|
-
import "../endpoint-tools/index.js";
|
|
84
82
|
import { DiscussionService } from "../discussions/service.js";
|
|
85
83
|
import { DiscussionOrganizer } from "../discussions/organizer.js";
|
|
86
84
|
import { DiscussionLiveWorker } from "../discussions/live-worker.js";
|
|
87
85
|
import { DiscussionOrganizerWorker } from "../discussions/organizer-worker.js";
|
|
88
86
|
import { DiscussionSealer } from "../discussions/sealer.js";
|
|
89
87
|
import "../discussions/index.js";
|
|
88
|
+
import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
89
|
+
import "../endpoint-tools/index.js";
|
|
90
90
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
91
91
|
import { prepareAutomationAgentSession } from "./automation-agent-session.js";
|
|
92
92
|
import { stopTailscaleExposure } from "./tailscale-lifecycle.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
2
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
3
2
|
import { getModelCatalogStore, init_model_catalog_store } from "../providers/model-catalog-store.js";
|
|
4
3
|
import { compareCatalogModels } from "../providers/model-catalog-ranking.js";
|
|
4
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
5
5
|
import { prepareUpdateGlobalDefaults } from "./global-defaults-admin.js";
|
|
6
6
|
//#region src/gateway/xopc-cloud-capability-setup.ts
|
|
7
7
|
init_repository();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { init_agent_scope, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
2
|
-
import { extractAssistantText, getAssistantMessageErrorReason } from "../providers/model-response.js";
|
|
3
2
|
import { init_providers, resolveModel } from "../providers/index.js";
|
|
4
3
|
import { completeWithResolvedCredentials, isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
4
|
+
import { extractAssistantText, getAssistantMessageErrorReason } from "../providers/model-response.js";
|
|
5
5
|
import { resolveModelSelector } from "../config/agent-model-intents.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/home-intelligence/generator.ts
|
|
@@ -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";
|
|
9
8
|
import { init_paths, resolveExtensionsDir } from "../config/paths.js";
|
|
10
9
|
import { LocalAppStore } from "./store.js";
|
|
11
10
|
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";
|
|
@@ -7,8 +7,8 @@ import { init_note_markdown, parseNoteMarkdown } from "./note-markdown.js";
|
|
|
7
7
|
import { init_notes_repository, listNoteProjectSummaries } from "../storage/sqlite/notes-repository.js";
|
|
8
8
|
import { changedFieldsFromPatch, emitActivity, previewText, systemActivityActor, systemActivitySource } from "../activity/emitter.js";
|
|
9
9
|
import { getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
|
|
10
|
-
import { completeWithResolvedCredentials } from "../providers/model-call.js";
|
|
11
10
|
import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
|
|
11
|
+
import { completeWithResolvedCredentials } from "../providers/model-call.js";
|
|
12
12
|
import { partitionAttachmentsByReference } from "./note-attachment-sync.js";
|
|
13
13
|
import { buildNoteAgentContextArtifact, getCachedNoteAgentContextArtifact } from "./agent-context.js";
|
|
14
14
|
import { revokeNoteShareRecords } from "../share/note-share-revocation.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getApiKeyFromEnv, init_env_keys } from "../env-keys.js";
|
|
2
1
|
import { init_sync_provider_auth, resolveProviderApiKeyForAgentSync } from "../../auth/sync-provider-auth.js";
|
|
2
|
+
import { getApiKeyFromEnv, init_env_keys } from "../env-keys.js";
|
|
3
3
|
import { getDefaultAuthProfileStore } from "./auth-profile-store.js";
|
|
4
4
|
//#region src/providers/auth-runtime/resolve-auth.ts
|
|
5
5
|
init_env_keys();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __esmMin, __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
3
|
+
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
4
|
+
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
3
5
|
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
4
6
|
import { init_model_ref, splitProviderModelRef } from "./model-ref.js";
|
|
5
7
|
import { ModelRegistry, getModelRegistry, init_model_registry, prewarmModelRegistry, resetModelRegistry } from "./model-registry.js";
|
|
6
|
-
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
7
8
|
import { CredentialResolver, hasCredentials, init_credentials } from "../auth/credentials.js";
|
|
8
|
-
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
9
9
|
import { EXTENSION_PROVIDER_BASE_URL, init_constants } from "./constants.js";
|
|
10
10
|
import { applyOfficialModelMetadataCorrections, getSupplementalModels, init_model_supplements } from "./model-supplements.js";
|
|
11
11
|
import { getProviderRegistry, init_plugin_registry } from "./plugin-registry.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { init_paths_state, resolveXopcCloudCatalogCachePath } from "../config/paths-state.js";
|
|
3
|
-
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
4
3
|
import { ComputerProfileSchema, init_src } from "../../packages/computer-control-contract/src/index.js";
|
|
4
|
+
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
5
5
|
import { voiceManifestSchema } from "../../packages/realtime-protocol/src/voice-catalog.js";
|
|
6
6
|
import { init_voice } from "../../packages/realtime-protocol/src/voice.js";
|
|
7
7
|
import { readFileSync, rmSync } from "node:fs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
3
2
|
import { getOAuthProviderDefinition, init_registry } from "../auth/oauth/registry.js";
|
|
3
|
+
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
4
4
|
import { XOPC_CLOUD_PROVIDER_ID, init_xopc_cloud_config, resolveXopcModelRouterUrl } from "./xopc-cloud-config.js";
|
|
5
5
|
//#region src/providers/register-runtime-providers.ts
|
|
6
6
|
function registerRuntimeProvider(modelRuntime, source) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { conciseProgress } from "../session/compact-history.js";
|
|
2
|
+
//#region src/realtime/compact-run-event.ts
|
|
3
|
+
/** Keep the original sequence watermark, including across omitted diagnostic events. */
|
|
4
|
+
function compactRunEvent(message) {
|
|
5
|
+
if (message.kind !== "realtime.event" || !message.payload.topic.startsWith("run:")) return message;
|
|
6
|
+
const event = message.payload.data;
|
|
7
|
+
let payload = event.payload;
|
|
8
|
+
switch (event.type) {
|
|
9
|
+
case "tool_end":
|
|
10
|
+
if (!event.payload.deliveries?.length || event.payload.status !== "success") return null;
|
|
11
|
+
payload = { deliveries: event.payload.deliveries };
|
|
12
|
+
break;
|
|
13
|
+
case "progress":
|
|
14
|
+
if (!event.payload.petFeedback.publicSummary) return null;
|
|
15
|
+
payload = { message: conciseProgress(event.payload.petFeedback.publicSummary) };
|
|
16
|
+
break;
|
|
17
|
+
case "turn_outcome":
|
|
18
|
+
payload = {
|
|
19
|
+
...event.payload,
|
|
20
|
+
evidence: [],
|
|
21
|
+
changeSet: void 0
|
|
22
|
+
};
|
|
23
|
+
break;
|
|
24
|
+
case "user_message":
|
|
25
|
+
payload = {};
|
|
26
|
+
break;
|
|
27
|
+
case "run_start":
|
|
28
|
+
case "run_end":
|
|
29
|
+
case "assistant_delta":
|
|
30
|
+
case "assistant_message_end":
|
|
31
|
+
case "error":
|
|
32
|
+
case "clarify_request":
|
|
33
|
+
case "session_config_updated":
|
|
34
|
+
case "tts_audio":
|
|
35
|
+
case "review": break;
|
|
36
|
+
default: return null;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...message,
|
|
40
|
+
payload: {
|
|
41
|
+
...message.payload,
|
|
42
|
+
data: {
|
|
43
|
+
...event,
|
|
44
|
+
payload
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { compactRunEvent };
|
|
@@ -2,6 +2,7 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { hasGatewayScope, init_gateway_scopes } from "../gateway/security/gateway-scopes.js";
|
|
4
4
|
import { EndpointToolPolicyError } from "../endpoint-tools/policy.js";
|
|
5
|
+
import { compactRunEvent } from "./compact-run-event.js";
|
|
5
6
|
import { REALTIME_CAPABILITIES, REALTIME_HEARTBEAT_INTERVAL_MS, REALTIME_HEARTBEAT_TIMEOUT_MS, REALTIME_HELLO_TIMEOUT_MS, REALTIME_MAX_CLIENT_FRAME_BYTES, parseClientRealtimeJsonFrame, parseClientRealtimeMessage } from "../../packages/realtime-protocol/src/index.js";
|
|
6
7
|
import { createPreauthConnectionBudget } from "../gateway/security/preauth-connection-budget.js";
|
|
7
8
|
import { RealtimeBroker } from "./broker.js";
|
|
@@ -185,14 +186,18 @@ var RealtimeRuntime = class {
|
|
|
185
186
|
}
|
|
186
187
|
subscriptions.get(item.topic)?.unsubscribe();
|
|
187
188
|
const handle = this.broker.subscribe(item.topic, item.afterSeq, (event) => {
|
|
188
|
-
|
|
189
|
+
const output = item.view === "compact" ? compactRunEvent(event) : event;
|
|
190
|
+
if (output) writer.enqueue(output);
|
|
189
191
|
});
|
|
190
192
|
subscriptions.set(item.topic, handle);
|
|
191
193
|
writer.enqueue(serverMessage("realtime.subscribed", {
|
|
192
194
|
topic: item.topic,
|
|
193
195
|
cursor: handle.cursor
|
|
194
196
|
}), "critical");
|
|
195
|
-
for (const message of handle.initial)
|
|
197
|
+
for (const message of handle.initial) {
|
|
198
|
+
const output = item.view === "compact" ? compactRunEvent(message) : message;
|
|
199
|
+
if (output) writer.enqueue(output);
|
|
200
|
+
}
|
|
196
201
|
}
|
|
197
202
|
return true;
|
|
198
203
|
};
|
|
@@ -11,6 +11,7 @@ export interface ClientHistoryMessage {
|
|
|
11
11
|
rawContent?: string | unknown[];
|
|
12
12
|
/** Persisted inbound attachment metadata used by chat clients to reload media. */
|
|
13
13
|
media?: Message['media'];
|
|
14
|
+
deliveries?: import('@xopcai/gateway-contract').ProductDeliveryEnvelope[];
|
|
14
15
|
timestamp?: number;
|
|
15
16
|
/** Whitelisted display metadata; never includes source snapshot text. */
|
|
16
17
|
metadata?: {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ProductDeliveryEnvelope } from '@xopcai/gateway-contract';
|
|
2
|
+
import type { ClientHistoryMessage } from './client-history.js';
|
|
3
|
+
export declare function conciseProgress(text: string): string;
|
|
4
|
+
export declare function productDeliveries(result: unknown): ProductDeliveryEnvelope[];
|
|
5
|
+
/** Transport-only projection: stored transcripts and default clients remain unchanged. */
|
|
6
|
+
export declare function compactHistory(messages: ClientHistoryMessage[]): ClientHistoryMessage[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { parseProductDeliveryEnvelope, parseProductDeliveryText } from "../../packages/gateway-contract/src/product-delivery.js";
|
|
2
|
+
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
3
|
+
//#region src/session/compact-history.ts
|
|
4
|
+
init_src();
|
|
5
|
+
function conciseProgress(text) {
|
|
6
|
+
const plain = text.replace(/\s+/g, " ").trim();
|
|
7
|
+
return plain.length > 160 ? plain.slice(0, 159) + "…" : plain;
|
|
8
|
+
}
|
|
9
|
+
function productDeliveries(result) {
|
|
10
|
+
if (!result || typeof result !== "object") return [];
|
|
11
|
+
const value = result;
|
|
12
|
+
const details = value.details;
|
|
13
|
+
const text = typeof value.text === "string" ? value.text : typeof value.result === "string" ? value.result : Array.isArray(value.content) ? value.content.filter((b) => b?.type === "text").map((b) => b.text).join("\n") : "";
|
|
14
|
+
const delivery = parseProductDeliveryEnvelope(details?.delivery) ?? parseProductDeliveryEnvelope(details) ?? parseProductDeliveryText(text);
|
|
15
|
+
return delivery ? [delivery] : [];
|
|
16
|
+
}
|
|
17
|
+
/** Transport-only projection: stored transcripts and default clients remain unchanged. */
|
|
18
|
+
function compactHistory(messages) {
|
|
19
|
+
return messages.flatMap((message) => {
|
|
20
|
+
if (message.role === "system") return [];
|
|
21
|
+
if (message.role === "user") return [message];
|
|
22
|
+
const narration = !!message.toolCalls?.length;
|
|
23
|
+
const content = narration ? conciseProgress(message.content) : message.content;
|
|
24
|
+
const mediaAndReview = (Array.isArray(message.rawContent) ? message.rawContent : []).filter((block) => block && typeof block === "object" && [
|
|
25
|
+
"image",
|
|
26
|
+
"audio",
|
|
27
|
+
"tts_audio",
|
|
28
|
+
"review"
|
|
29
|
+
].includes(String(block.type)));
|
|
30
|
+
const deliveries = (message.toolCalls ?? []).filter((call) => !call.isError).flatMap(productDeliveries);
|
|
31
|
+
const outcome = message.metadata?.turnOutcome;
|
|
32
|
+
if (!content && !mediaAndReview.length && !message.media?.length && !outcome && !deliveries.length) return [];
|
|
33
|
+
return [{
|
|
34
|
+
id: message.id,
|
|
35
|
+
turnId: message.turnId,
|
|
36
|
+
role: message.role,
|
|
37
|
+
content,
|
|
38
|
+
timestamp: message.timestamp,
|
|
39
|
+
media: message.media,
|
|
40
|
+
deliveries,
|
|
41
|
+
rawContent: [...content ? [{
|
|
42
|
+
type: "text",
|
|
43
|
+
text: content,
|
|
44
|
+
presentation: narration ? "narration" : "answer"
|
|
45
|
+
}] : [], ...mediaAndReview],
|
|
46
|
+
...outcome ? { metadata: { turnOutcome: {
|
|
47
|
+
...outcome,
|
|
48
|
+
evidence: [],
|
|
49
|
+
changeSet: void 0
|
|
50
|
+
} } } : {}
|
|
51
|
+
}];
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { compactHistory, conciseProgress, productDeliveries };
|
|
@@ -22,6 +22,7 @@ import { readPostCompactionContext } from "../agent/reply/post-compaction-contex
|
|
|
22
22
|
import { promoteCompactionLedger } from "../agent/memory/compaction-promotion.js";
|
|
23
23
|
import { SlidingWindow } from "../agent/memory/window.js";
|
|
24
24
|
import { isAppendOnlyLlmTranscriptMessage } from "./transcript-stats.js";
|
|
25
|
+
import { compactHistory } from "./compact-history.js";
|
|
25
26
|
import { backfillStructuredTurnOutcomes } from "./turn-outcome-projector.js";
|
|
26
27
|
import { computeTranscriptUserRoundDeleteRange } from "./user-round-delete.js";
|
|
27
28
|
import { findSessionMessages } from "./session-find.js";
|
|
@@ -186,11 +187,13 @@ var SessionStore = class {
|
|
|
186
187
|
limit,
|
|
187
188
|
offset: hasBeforeCursor ? void 0 : offset,
|
|
188
189
|
beforeIndex: hasBeforeCursor ? parsedBefore : void 0,
|
|
189
|
-
includeContext: true
|
|
190
|
+
includeContext: true,
|
|
191
|
+
userTurns: options.compact
|
|
190
192
|
});
|
|
191
193
|
const endIndex = hasBeforeCursor ? Math.min(page.total, Math.max(0, parsedBefore)) : Math.max(0, page.total - offset);
|
|
192
194
|
const startIndex = Math.max(0, endIndex - page.rows.length);
|
|
193
|
-
const
|
|
195
|
+
const history = transcriptRowsToClientHistory(page.rows, { rowNumberOffset: startIndex });
|
|
196
|
+
const messages = options.compact ? compactHistory(history) : history;
|
|
194
197
|
const session = {
|
|
195
198
|
...metadata,
|
|
196
199
|
messages,
|
|
@@ -203,7 +206,7 @@ var SessionStore = class {
|
|
|
203
206
|
total: page.total,
|
|
204
207
|
limit,
|
|
205
208
|
offset,
|
|
206
|
-
hasMore:
|
|
209
|
+
hasMore: startIndex > 0,
|
|
207
210
|
...hasBeforeCursor ? { before: String(endIndex) } : {},
|
|
208
211
|
...nextBeforeCursor ? { nextBeforeCursor } : {},
|
|
209
212
|
revision: page.revision
|
|
@@ -46,6 +46,8 @@ export declare function paginateTranscriptMessages(conversationId: string, optio
|
|
|
46
46
|
includeContext?: boolean;
|
|
47
47
|
/** Include reset/rollover transcripts for read-only conversation history. */
|
|
48
48
|
includeArchived?: boolean;
|
|
49
|
+
/** Count user turns rather than diagnostic rows for compact chat history. */
|
|
50
|
+
userTurns?: boolean;
|
|
49
51
|
}): {
|
|
50
52
|
rows: TranscriptStoredRow[];
|
|
51
53
|
messages: AgentMessage[];
|
|
@@ -300,8 +300,17 @@ function paginateTranscriptMessages(conversationId, options = {}) {
|
|
|
300
300
|
const revisionRow = db.prepare(`SELECT COALESCE(MAX(seq), 0) AS revision
|
|
301
301
|
FROM transcript_entries
|
|
302
302
|
WHERE transcript_id = ? AND entry_kind IN (${kindPlaceholders})`).get(transcriptId, ...kinds);
|
|
303
|
-
|
|
303
|
+
let limit = Math.min(200, Math.max(1, Math.trunc(options.limit ?? 50)));
|
|
304
304
|
const offset = Math.max(0, Math.trunc(options.offset ?? 0));
|
|
305
|
+
if (options.userTurns) {
|
|
306
|
+
const end = options.beforeIndex === void 0 ? Math.max(0, total - offset) : Math.min(total, Math.max(0, Math.trunc(options.beforeIndex)));
|
|
307
|
+
const anchors = db.prepare(`SELECT idx FROM (
|
|
308
|
+
SELECT e.role, ROW_NUMBER() OVER (ORDER BY t.created_at ASC, t.rowid ASC, e.seq ASC) - 1 AS idx
|
|
309
|
+
FROM transcript_entries e JOIN transcripts t ON t.transcript_id = e.transcript_id
|
|
310
|
+
WHERE ${transcriptWhere} AND e.entry_kind IN (${kindPlaceholders})
|
|
311
|
+
) WHERE role = 'user' AND idx < ? ORDER BY idx DESC LIMIT ?`).all(transcriptArg, ...kinds, end, limit + 1);
|
|
312
|
+
limit = end - (anchors.length > limit ? anchors[limit - 1].idx : 0);
|
|
313
|
+
}
|
|
305
314
|
let rows;
|
|
306
315
|
if (options.beforeIndex !== void 0 && Number.isFinite(options.beforeIndex)) {
|
|
307
316
|
const endExclusive = Math.min(total, Math.max(0, Math.trunc(options.beforeIndex)));
|
|
@@ -2,10 +2,10 @@ import { ProductReadContracts } from "../../../packages/gateway-contract/src/cap
|
|
|
2
2
|
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
3
3
|
import { TaskRepository, init_task_repository } from "../task-repository.js";
|
|
4
4
|
import { TaskRunRepository, init_task_run_repository } from "../task-run-repository.js";
|
|
5
|
-
import { CapabilityError } from "../../capabilities/runtime/errors.js";
|
|
6
|
-
import { defineReadCapability } from "../../capabilities/runtime/dispatcher.js";
|
|
7
5
|
import { TaskConversationRepository } from "../task-conversation-repository.js";
|
|
8
6
|
import { TaskReadModelProjector } from "../task-read-model-projector.js";
|
|
7
|
+
import { CapabilityError } from "../../capabilities/runtime/errors.js";
|
|
8
|
+
import { defineReadCapability } from "../../capabilities/runtime/dispatcher.js";
|
|
9
9
|
import { TaskContextRepository } from "../task-context-repository.js";
|
|
10
10
|
import { TaskDependencyService } from "../task-dependency-service.js";
|
|
11
11
|
import { TaskValueMetricsService } from "../task-value-metrics-service.js";
|
|
@@ -9,12 +9,11 @@ import { appendComposerInputHistory, listComposerInputHistory } from "../../stor
|
|
|
9
9
|
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
10
10
|
import { init_sqlite } from "../../storage/sqlite/index.js";
|
|
11
11
|
import { normalizeAgentId } from "../../agent-catalog/id.js";
|
|
12
|
-
import { init_agent_scope, listAgentEntries } from "../../agent/agent-scope.js";
|
|
13
|
-
import { init_paths } from "../../config/paths.js";
|
|
14
|
-
import { AgentCatalogService } from "../../agent-catalog/service.js";
|
|
15
12
|
import { getAgentDefaultModelRef, init_schema } from "../../config/schema.js";
|
|
13
|
+
import { init_agent_scope, listAgentEntries } from "../../agent/agent-scope.js";
|
|
16
14
|
import { init_agent_session_key, resolveAgentIdFromConversationId } from "../../routing/agent-session-key.js";
|
|
17
15
|
import { resolveEffectiveAgentProfile } from "../../config/agent-profile.js";
|
|
16
|
+
import { init_paths } from "../../config/paths.js";
|
|
18
17
|
import { effectiveWorkspacePathForSession } from "../../session/session-workspace.js";
|
|
19
18
|
import { ProjectService } from "../../projects/project-service.js";
|
|
20
19
|
import { inferSuggestedProjectDefaultAgentId } from "../../projects/project-agent-suggestion.js";
|
|
@@ -23,6 +22,7 @@ import { buildSessionTimeline } from "../../session/transcript-outline.js";
|
|
|
23
22
|
import { transcriptRowsToClientHistory } from "../../session/client-history.js";
|
|
24
23
|
import { createCreateShareTool, isShareToolAvailable } from "../../agent/tools/create-share-tool.js";
|
|
25
24
|
import { evictEmbeddedSessionRunner } from "../../agent/embedded/session-runner.js";
|
|
25
|
+
import { AgentCatalogService } from "../../agent-catalog/service.js";
|
|
26
26
|
import { SessionIndex } from "../../session/manager.js";
|
|
27
27
|
import "../../session/index.js";
|
|
28
28
|
import { parseModelRef } from "../../agent/models/selection.js";
|
|
@@ -2,8 +2,8 @@ import { closeXopcDatabase, isXopcDatabaseOpen, openXopcDatabase } from "../stor
|
|
|
2
2
|
import { TaskRepository } from "../tasks/task-repository.js";
|
|
3
3
|
import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
|
|
4
4
|
import { init_sqlite } from "../storage/sqlite/index.js";
|
|
5
|
-
import { resolveConfigPath } from "../config/paths.js";
|
|
6
5
|
import { init_agent_session_key, isValidAgentId, normalizeAgentId } from "../routing/agent-session-key.js";
|
|
6
|
+
import { resolveConfigPath } from "../config/paths.js";
|
|
7
7
|
import { init_providers, providerSupportsOAuth } from "../providers/index.js";
|
|
8
8
|
import { ProjectService } from "../projects/project-service.js";
|
|
9
9
|
import { isValidProjectAgentId, normalizeProjectAgentId } from "../projects/project-agent.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveStateDir } from "../config/paths-state.js";
|
|
2
|
-
import { init_paths, resolveAgentProfileDir, resolveBundledSkillsDir } from "../config/paths.js";
|
|
3
2
|
import { resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
3
|
+
import { init_paths, resolveAgentProfileDir, resolveBundledSkillsDir } from "../config/paths.js";
|
|
4
4
|
import { resolveBootstrapFilesSync } from "../agent/bootstrap/bootstrap-files.js";
|
|
5
5
|
import { listConnectorInstances } from "../connectors/instances.js";
|
|
6
6
|
import { createSkillConfigManager, isSkillEnabled } from "../agent/skills/config.js";
|
package/dist/src/tui/tui.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { version } from "../../package.js";
|
|
2
2
|
import { resolveStateDir, resolveXopcDatabasePath } from "../config/paths-state.js";
|
|
3
|
-
import { init_paths } from "../config/paths.js";
|
|
4
3
|
import { init_agent_session_key, normalizeAgentId } from "../routing/agent-session-key.js";
|
|
5
|
-
import { getAllModels, getAllProviders, getApiKey, init_providers, isProviderConfiguredSync } from "../providers/index.js";
|
|
6
4
|
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
5
|
+
import { init_paths } from "../config/paths.js";
|
|
6
|
+
import { getAllModels, getAllProviders, getApiKey, init_providers, isProviderConfiguredSync } from "../providers/index.js";
|
|
7
7
|
import { isTerminalWorkflowRunStatus } from "../workflows/domain/run.js";
|
|
8
8
|
import "../workflows/domain/index.js";
|
|
9
9
|
import { ProjectTrustStore, hasTrustRequiringProjectResources } from "../project-trust/trust-store.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { init_agent_scope, resolveAgentProfileDir } from "../../agent/agent-scope.js";
|
|
2
|
-
import { DEFAULT_IDENTITY_FILENAME, DEFAULT_SOUL_FILENAME } from "../../agent/context/workspace.js";
|
|
3
2
|
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
3
|
+
import { DEFAULT_IDENTITY_FILENAME, DEFAULT_SOUL_FILENAME } from "../../agent/context/workspace.js";
|
|
4
4
|
import { loadProfileBootstrapFiles } from "../../agent/bootstrap/load-bootstrap-files.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { statSync } from "node:fs";
|
|
@@ -8,15 +8,15 @@ import { ActivityService } from "../activity/service.js";
|
|
|
8
8
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
9
9
|
import { init_session_key, resolveConversationId } from "../routing/session-key.js";
|
|
10
10
|
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
11
|
-
import { init_providers, resolveModel } from "../providers/index.js";
|
|
12
|
-
import { isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
13
11
|
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
12
|
+
import { init_providers, resolveModel } from "../providers/index.js";
|
|
14
13
|
import { writeKnowledgeItem } from "../knowledge-memory/repository.js";
|
|
15
14
|
import "../knowledge-memory/index.js";
|
|
16
15
|
import { createWorkDiscoveryRun, getProjectUnderstandingRun, getWorkDiscoveryOnboardingState, getWorkDiscoveryRun, getWorkDiscoveryRunByIdempotencyKey, listPendingProjectUnderstandingRuns, setWorkDiscoveryFeedback, setWorkDiscoveryOnboardingState, updateWorkDiscoveryRun } from "./repository.js";
|
|
17
16
|
import { linkAssertionEvidence, reconcileAssertion } from "../user-model/repository.js";
|
|
18
17
|
import { createPriorityWindow, createUserGoal } from "../user-model/goals.js";
|
|
19
18
|
import "../user-model/index.js";
|
|
19
|
+
import { isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
20
20
|
import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
|
|
21
21
|
import { allowsRemoteSourceProcessing } from "../user-context/sources/processing-policy.js";
|
|
22
22
|
import { analyzeUnderstandingSources, analyzeWorkContext, workDiscoveryResultMarkdown } from "./analyzer.js";
|
|
@@ -2,8 +2,8 @@ import { TaskRepository, init_task_repository } from "../../tasks/task-repositor
|
|
|
2
2
|
import { TaskRunRepository, init_task_run_repository } from "../../tasks/task-run-repository.js";
|
|
3
3
|
import { init_conversation_repository, resolveRoutedConversation } from "../../storage/sqlite/conversation-repository.js";
|
|
4
4
|
import { getDefaultAgentId, init_resolve_route } from "../../routing/resolve-route.js";
|
|
5
|
-
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
6
5
|
import { extractProfileAgentId, resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
6
|
+
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
7
7
|
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
8
8
|
import { getProjectWorkspacePathForSession } from "../../projects/workspace.js";
|
|
9
9
|
import { automationEventPublisher, getAutomationEventForRun } from "../../automations/events/event-repository.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xopcai/xopc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.337",
|
|
4
4
|
"description": "Local-first personal AI for the one-person company, with durable context, tasks, workflows, automations, and local or cloud models.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -159,12 +159,12 @@
|
|
|
159
159
|
"vitest": "4.1.5",
|
|
160
160
|
"vue": "^3.5.35",
|
|
161
161
|
"@xopcai/browser-control-contract": "0.1.0",
|
|
162
|
-
"@xopcai/endpoint-tools-client": "0.0.0",
|
|
163
|
-
"@xopcai/computer-control-contract": "0.1.0",
|
|
164
162
|
"@xopcai/endpoint-tools-protocol": "0.0.0",
|
|
165
163
|
"@xopcai/gateway-contract": "0.0.0",
|
|
166
|
-
"@xopcai/realtime-
|
|
167
|
-
"@xopcai/
|
|
164
|
+
"@xopcai/realtime-client": "0.0.0",
|
|
165
|
+
"@xopcai/endpoint-tools-client": "0.0.0",
|
|
166
|
+
"@xopcai/computer-control-contract": "0.1.0",
|
|
167
|
+
"@xopcai/realtime-protocol": "0.0.0"
|
|
168
168
|
},
|
|
169
169
|
"scripts": {
|
|
170
170
|
"assets:brand": "node scripts/generate-brand-assets.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./locale-store-7F4l6DRV.js";import{a as t,d as n,f as r,g as i,i as a,l as o,p as s,r as c,s as l,t as u,u as d,v as f}from"./schemas-CObaziC7.js";import{t as p}from"./gateway-realtime-store-DytaaEu8.js";var m=25*1024*1024,h=u([`web`,`desktop`,`mobile`,`browser`]),g=u([`foreground`,`background`]),_=u([`read`,`write`,`destructive`]),ee=u([`never`,`always`]),te=u([`text`,`json`,`file`]),ne=u([`public`,`personal`]),v=s().min(1).max(160),re=s().min(32).max(160).regex(/^[A-Za-z0-9_-]+$/);t(`type`,[r({type:l(`endpoint`),endpointId:v}),r({type:l(`channel`),channel:s().min(1).max(64)}),r({type:l(`system`),source:u([`cli`,`automation`,`heartbeat`,`workflow`,`internal`])})]).options[0].extend({token:re});var ie=f(),y=o().int().nonnegative(),b=n(s(),i()),x=r({name:s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120),title:s().min(1).max(120),description:s().min(1).max(2e3),inputSchema:b,outputSchema:b,policyId:s().regex(/^[a-z][a-z0-9_.-]+$/).max(120),sensitivity:ne,effect:_,confirmation:ee,requiresForeground:a(),requiredPermissions:c(s().min(1).max(120)).max(20),timeoutMs:o().int().min(1e3).max(3e5),maxConcurrency:o().int().min(1).max(4),supportsCancellation:a(),idempotent:a(),resultKinds:c(te).min(1).max(3)});r({principalId:v,displayName:s().min(1).max(120),kind:h,platform:s().min(1).max(80),publicKey:s().min(32).max(2048)}),r({endpointId:v});var S=s().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120);r({jobId:f(),endpointId:v,capability:S,input:b,idempotencyKey:v,consentGrantId:v,createdAt:y,expiresAt:y}),r({jobId:f(),status:u([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),updatedAt:y,output:b.optional(),error:r({code:v,message:s().min(1).max(2e3)}).optional()}),r({eventId:f(),endpointId:v,subscriptionId:v,eventType:S,data:b,occurredAt:y});var C=r({principalId:v,endpointId:v,connectionInstanceId:f(),displayName:s().min(1).max(120),kind:h,platform:s().min(1).max(80),appVersion:s().min(1).max(80),availability:g,nonce:v,signedAt:y,signature:s().min(16).max(1024),tools:c(x).max(100)}),w=r({invocationId:f(),toolCallId:v,toolName:x.shape.name,arguments:b,descriptorRevision:s().min(1).max(128),confirmationRequired:a(),deadlineAt:y,uploadGrant:r({path:s().startsWith(`/`).max(500),token:v,maxBytes:o().int().positive(),maxFiles:o().int().min(1).max(20),expiresAt:y}).optional()}),ae=r({invocationId:f(),reason:s().min(1).max(500)}),T=r({invocationId:f()}),E=t(`type`,[r({type:l(`text`),text:s().max(256*1024)}),r({type:l(`json`),value:i()}),r({type:l(`file`),fileId:v,name:s().min(1).max(255),mimeType:s().min(1).max(255),size:o().int().nonnegative(),sha256:s().regex(/^[a-f0-9]{64}$/)})]),D=u([`ENDPOINT_OFFLINE`,`ENDPOINT_NOT_FOREGROUND`,`ENDPOINT_DISCONNECTED`,`TOOL_NOT_FOUND`,`TOOL_REVISION_MISMATCH`,`INVALID_ARGUMENTS`,`PERMISSION_DENIED`,`USER_DENIED`,`TOOL_BUSY`,`TOOL_TIMEOUT`,`TOOL_CANCELLED`,`RESULT_TOO_LARGE`,`PROTOCOL_ERROR`]),O=(e,t)=>r({protocolVersion:l(2),messageId:ie,type:l(e),sentAt:y,payload:t}),oe=t(`type`,[O(`endpoint.availability_changed`,r({availability:g})),O(`tool.received`,T),O(`tool.progress`,r({invocationId:f(),message:s().max(500).optional(),percent:o().min(0).max(100).optional()})),O(`tool.result`,r({invocationId:f(),content:c(E).min(1).max(20),details:b.optional()})),O(`tool.error`,r({invocationId:f(),code:D,message:s().min(1).max(2e3)})),O(`tool.cancelled`,T)]),se=t(`type`,[O(`tool.invoke`,w),O(`tool.cancel`,ae)]),ce={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`text`],properties:{type:{const:`text`},text:{type:`string`,maxLength:256*1024}}}},le={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`fileId`,`name`,`mimeType`,`size`,`sha256`],properties:{type:{const:`file`},fileId:{type:`string`,minLength:1,maxLength:160},name:{type:`string`,minLength:1,maxLength:255},mimeType:{type:`string`,minLength:1,maxLength:255},size:{type:`integer`,minimum:0},sha256:{type:`string`,pattern:`^[a-f0-9]{64}$`}}}};function k(e){if(e===null)return`null`;if(typeof e==`string`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Canonical JSON only supports finite numbers`);return JSON.stringify(e)}if(typeof e!=`object`)throw Error(`Canonical JSON does not support ${typeof e}`);if(Array.isArray(e))return`[${e.map(k).join(`,`)}]`;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error(`Canonical JSON only supports plain objects`);let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${k(n[e])}`).join(`,`)}}`}function A(e){let{signature:t,...n}=e;return k(n)}var j=256*1024,M=15e3,N=45e3,P=[`realtime.capability-negotiation.v1`],F=u([`web`,`desktop`,`mobile`,`browser_extension`,`tui`,`mcp`]),I=s().min(1).max(512),L=s().regex(/^[a-z][a-z0-9_.-]*$/).max(160),R=f(),z=o().int().nonnegative(),B=o().int().positive(),V=s().min(1).max(160),H=(e,t)=>d({protocolVersion:l(2),messageId:R,kind:l(e),sentAt:z,payload:t}),U=d({topic:I,afterSeq:o().int().nonnegative().optional()});t(`kind`,[H(`realtime.hello`,d({ticket:s().min(32).max(512),clientId:s().min(1).max(160),clientKind:F,subscriptions:c(U).max(100).default([]),capabilities:c(V).max(64).optional(),endpoint:C.optional()})),H(`realtime.subscribe`,d({subscriptions:c(U).min(1).max(100)})),H(`realtime.unsubscribe`,d({topics:c(I).min(1).max(100)})),H(`realtime.ping`,d({})),H(`endpoint.message`,oe)]);var W=d({topic:I,seq:B,event:L,data:i()}),ue=t(`kind`,[H(`realtime.ready`,d({connectionId:f(),heartbeatIntervalMs:l(M),heartbeatTimeoutMs:l(N),negotiatedCapabilities:c(V).max(64).optional(),endpoint:d({endpointId:s().min(1).max(160),turnToken:s().min(32).max(160)}).optional()})),H(`realtime.event`,W),H(`realtime.subscribed`,d({topic:I,cursor:o().int().nonnegative()})),H(`realtime.gap`,d({topic:I,requestedSeq:o().int().nonnegative(),earliestSeq:B,recoverable:a()})),H(`realtime.pong`,d({})),H(`realtime.error`,d({code:s().min(1).max(80),message:s().min(1).max(500)})),H(`endpoint.message`,se)]);function de(e){return ue.parse(e)}var G=class extends Error{retryable;constructor(e,t){super(e),this.retryable=t,this.name=`RealtimeConnectionError`}},fe=class extends Error{bytes;maxBytes;constructor(e,t){super(`Realtime client frame is ${e} bytes; maximum is ${t} bytes`),this.bytes=e,this.maxBytes=t,this.name=`RealtimeFrameTooLargeError`}};function pe(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(e);if(ArrayBuffer.isView(e)){let t=Uint8Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return new TextDecoder().decode(t)}throw Error(`Realtime server sent a non-text frame`)}function me(e){return e===1009||e===4400||e===4401||e===4409||e===4413}var he=class{options;desiredSubscriptions=new Map;cursors=new Map;socket;reconnectTimer;heartbeatTimer;connectionTimer;ticketAbort;generation=0;reconnectAttempts=0;shouldReconnect=!1;ready=!1;lastServerMessageAt=0;endpointBinding;reconnectWhenSocketOpens=!1;offeredCapabilities=new Set;constructor(e){this.options=e}connect(){this.shouldReconnect||(this.shouldReconnect=!0,this.open(!1))}disconnect(){this.shouldReconnect=!1,this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client disconnected`),this.socket=void 0,this.options.onStateChange?.(`disconnected`)}reconnect(){this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client reconnecting`),this.socket=void 0,this.reconnectAttempts=0,this.shouldReconnect=!0,this.open(!0)}subscribe(e,t){this.desiredSubscriptions.set(e,t),t!==void 0&&this.cursors.set(e,t),this.ready&&this.sendSubscriptions([{topic:e,afterSeq:this.cursors.get(e)??t}])}unsubscribe(e){this.desiredSubscriptions.delete(e),this.ready&&this.send(this.clientMessage(`realtime.unsubscribe`,{topics:[e]}))}sendEndpointMessage(e){if(!this.ready)throw Error(`Realtime connection is not ready`);this.send(this.clientMessage(`endpoint.message`,e))}setEndpoint(e){this.endpointBinding=e,this.refreshEndpointConnection()}clearEndpoint(e){if(e&&this.endpointBinding!==e)return;let t=this.endpointBinding;this.endpointBinding=void 0,t?.onDisconnected?.(),this.refreshEndpointConnection()}refreshEndpointConnection(){if(this.shouldReconnect){if(this.socket?.readyState===0){this.reconnectWhenSocketOpens=!0;return}this.reconnect()}}async open(e){let t=++this.generation,n=this.options.connectionTimeoutMs??15e3,r=new AbortController;this.ticketAbort?.abort(),this.ticketAbort=r;let i,a=!1,o,s=(e,n=!0)=>{a||t!==this.generation||(a=!0,this.clearConnectionTimer(),r.abort(),this.ticketAbort===r&&(this.ticketAbort=void 0),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.clearHeartbeat(),this.socket===i&&(this.socket=void 0),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(4e3,e.slice(0,120))),this.shouldReconnect&&n?this.scheduleReconnect(e):this.shouldReconnect?(this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e)):this.options.onStateChange?.(`disconnected`))};this.connectionTimer=setTimeout(()=>s(`Realtime connection timed out`),n),this.options.onStateChange?.(e?`reconnecting`:`connecting`);try{let[e,n]=await Promise.all([this.options.issueTicket(r.signal),this.endpointBinding?.createHello()]),c=e.ticket;if(2<e.realtime.minVersion)throw new G(`CLIENT_UPDATE_REQUIRED`,!1);if(2>e.realtime.maxVersion)throw new G(`GATEWAY_UPDATE_REQUIRED`,!1);let l=P.filter(t=>e.realtime.capabilities.includes(t));if(a||!this.shouldReconnect||t!==this.generation)return;this.offeredCapabilities=new Set(l??[]),i=this.options.createWebSocket(this.options.getWebSocketUrl()),this.socket=i,i.onopen=()=>{if(t!==this.generation)return;if(this.reconnectWhenSocketOpens){this.reconnect();return}let e=[...this.desiredSubscriptions].map(([e,t])=>({topic:e,afterSeq:this.cursors.get(e)??t}));this.send(this.clientMessage(`realtime.hello`,{ticket:c,clientId:this.options.clientId,clientKind:this.options.clientKind,subscriptions:e,...l?.length?{capabilities:l}:{},...n?{endpoint:n}:{}}))},i.onmessage=e=>{if(t!==this.generation)return;let n=()=>{if(!(a||t!==this.generation))return this.handleServerMessage(pe(e.data))};if(!o){try{let e=n();if(!e)return;let t=e.catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=t,t.finally(()=>{o===t&&(o=void 0)})}catch(e){s(e instanceof Error?e.message:`Invalid realtime server message`)}return}let r=o.then(n).catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=r,r.finally(()=>{o===r&&(o=void 0)})},i.onerror=()=>{},i.onclose=e=>{s(e.reason||`WebSocket closed (${e.code??0})`,!me(e.code))}}catch(e){s(e instanceof Error?e.message:`Realtime connection failed`,!(e instanceof G)||e.retryable)}}handleServerMessage(e){let t=de(JSON.parse(e));if(this.lastServerMessageAt=Date.now(),t.kind===`realtime.ready`){let e=t.payload.negotiatedCapabilities??[];if(e.some(e=>!this.offeredCapabilities.has(e)))throw Error(`Realtime server negotiated a capability the client did not offer`);this.ready=!0,this.reconnectAttempts=0,this.clearConnectionTimer(),this.ticketAbort=void 0,this.options.onStateChange?.(`connected`),this.options.onCapabilities?.(e),t.payload.endpoint&&this.endpointBinding?.onReady(t.payload.endpoint),this.clearHeartbeat(),this.heartbeatTimer=setInterval(()=>{if(this.ready){if(Date.now()-this.lastServerMessageAt>=t.payload.heartbeatTimeoutMs){this.reconnect();return}this.send(this.clientMessage(`realtime.ping`,{}))}},t.payload.heartbeatIntervalMs)}else if(t.kind===`realtime.event`){let e=this.cursors.get(t.payload.topic);if(e!==void 0&&t.payload.seq<=e)return;this.options.onEvent?.(t.payload),this.cursors.set(t.payload.topic,t.payload.seq)}else if(t.kind===`realtime.subscribed`)this.cursors.set(t.payload.topic,t.payload.cursor),this.options.onSubscribed?.(t.payload);else if(t.kind===`realtime.gap`)return this.cursors.set(t.payload.topic,t.payload.earliestSeq-1),this.options.onGap?.(t.payload);else t.kind===`realtime.error`?this.options.onStateChange?.(`error`,t.payload.message):t.kind===`endpoint.message`&&(this.endpointBinding?.onMessage(t.payload),this.options.onEndpointMessage?.(t.payload))}sendSubscriptions(e){this.send(this.clientMessage(`realtime.subscribe`,{subscriptions:e}))}clientMessage(e,t){let n=this.options.createMessageId?.()??globalThis.crypto?.randomUUID?.();if(!n)throw Error(`RealtimeClient requires createMessageId when crypto.randomUUID is unavailable`);return{protocolVersion:2,messageId:n,kind:e,sentAt:Date.now(),payload:t}}send(e){if(!this.socket||this.socket.readyState!==1)return;let t=JSON.stringify(e),n=new TextEncoder().encode(t).byteLength;if(n>262144)throw new fe(n,j);this.socket.send(t)}scheduleReconnect(e){if(!this.shouldReconnect)return;this.reconnectAttempts+=1;let t=this.options.maxReconnectAttempts;if(t!==void 0&&this.reconnectAttempts>t){this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e);return}this.options.onStateChange?.(`reconnecting`,e);let n=Math.min(3e4,1e3*2**Math.min(this.reconnectAttempts-1,5)),r=Math.round(n*(.5+Math.random()*.5));this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.open(!0)},r)}clearHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0}clearTimers(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.clearConnectionTimer(),this.ticketAbort?.abort(),this.ticketAbort=void 0,this.clearHeartbeat()}clearConnectionTimer(){this.connectionTimer&&clearTimeout(this.connectionTimer),this.connectionTimer=void 0}},ge=500,K=null,q;function J(e){q=e,K!==null&&clearTimeout(K),K=setTimeout(()=>{K=null;let e=q;q=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},ge)}function _e(e,t){if(e===`config.reload`){J(t);return}window.dispatchEvent(new CustomEvent(e.replace(/[._]/g,`-`),{detail:t}))}var Y=new Map,X=new Map,Z,Q;function $(){let e=`xopc:realtime-client-id`,t=sessionStorage.getItem(e);if(t)return t;let n=crypto.randomUUID();return sessionStorage.setItem(e,n),n}function ve(){let t=new URL(e(`/api/realtime/v1/ws`));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}function ye(){let t=$(),n=window.electronAPI?`desktop`:`web`,r=new he({clientId:t,clientKind:n,getWebSocketUrl:ve,issueTicket:async r=>{let i=await fetch(e(`/api/realtime/tickets`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t,clientKind:n,protocolVersion:2}),signal:r}),a=await i.json().catch(()=>null);if(!i.ok||!a?.payload?.ticket||!a.payload.realtime)throw Error(a?.error?.message??`Realtime ticket failed (${i.status})`);return{ticket:a.payload.ticket,realtime:a.payload.realtime}},createWebSocket:e=>new WebSocket(e),onStateChange:(e,t)=>{p({connectionState:e,error:t??null}),e===`connected`&&window.dispatchEvent(new CustomEvent(`gateway-realtime-connected`))},onEvent:e=>{(e.topic===`gateway`||e.topic===`sessions`)&&_e(e.event,e.data);let t=X.get(e.topic);(t===void 0||e.seq>t)&&X.set(e.topic,e.seq);for(let t of Y.get(e.topic)??[])if(!(t.cursor!==void 0&&e.seq<=t.cursor))try{t.listener.onEvent(e)}catch(e){console.error(`[realtime] topic listener failed:`,e)}finally{t.cursor=Math.max(t.cursor??0,e.seq)}},onGap:async e=>{window.dispatchEvent(new CustomEvent(`realtime-gap`,{detail:e}));let t=[...Y.get(e.topic)??[]].filter(t=>!e.recoverable||t.cursor===void 0||t.cursor<e.earliestSeq-1),n=await Promise.allSettled(t.map(t=>t.listener.onGap?.(e)));for(let e of n)e.status===`rejected`&&console.error(`[realtime] topic gap handler failed:`,e.reason)}});Z?.disconnect(),Z=r,Q&&r.setEndpoint(Q),r.subscribe(`gateway`,X.get(`gateway`)),r.subscribe(`sessions`,X.get(`sessions`));for(let e of Y.keys())r.subscribe(e,X.get(e));return p({connectionState:`connecting`,error:null}),r.connect(),()=>{Z===r&&(r.disconnect(),Z=void 0)}}function be(e){return Q=e,Z?.setEndpoint(e),()=>{Q===e&&(Q=void 0,Z?.clearEndpoint(e))}}function xe(e){Z?.sendEndpointMessage(e)}function Se(){Z?.reconnect()}function Ce(e,t,n){let r=Y.get(e)??new Set,i=r.size===0,a=X.get(e),o={listener:t,cursor:n??a};if(r.add(o),Y.set(e,r),i){let t=n??a;X.set(e,t),Z?.subscribe(e,t)}else n!==void 0&&(a===void 0||n<a)&&Z?.subscribe(e,n);return()=>{let t=Y.get(e);t?.delete(o),(!t||t.size===0)&&(Y.delete(e),X.delete(e),Z?.unsubscribe(e))}}export{Ce as a,m as c,A as d,E as f,ye as i,ce as l,Se as n,J as o,xe as r,le as s,be as t,k as u};
|