@dvina/sdk 4.0.210 → 4.0.214
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/{_generated_documents-OVKM6E6J.js → _generated_documents-AIL5TFBT.js} +3 -3
- package/dist/{_generated_documents-OVKM6E6J.js.map → _generated_documents-AIL5TFBT.js.map} +1 -1
- package/dist/{_generated_documents-UERNUJV2.cjs → _generated_documents-Y3SSPTRT.cjs} +608 -608
- package/dist/{_generated_documents-UERNUJV2.cjs.map → _generated_documents-Y3SSPTRT.cjs.map} +1 -1
- package/dist/adapters/angular/index.cjs +5 -5
- package/dist/adapters/angular/index.d.cts +2 -2
- package/dist/adapters/angular/index.d.ts +2 -2
- package/dist/adapters/angular/index.js +3 -3
- package/dist/billing/index.cjs +5 -5
- package/dist/billing/index.d.cts +2 -12
- package/dist/billing/index.d.ts +2 -12
- package/dist/billing/index.js +1 -1
- package/dist/{chunk-2C5KMNDM.cjs → chunk-32A6N4YK.cjs} +8 -8
- package/dist/chunk-32A6N4YK.cjs.map +1 -0
- package/dist/{chunk-UDAQBW74.js → chunk-BJDU4UX4.js} +294 -410
- package/dist/chunk-BJDU4UX4.js.map +1 -0
- package/dist/{chunk-BBXV2I6V.js → chunk-ETPR6MV5.js} +8 -8
- package/dist/chunk-ETPR6MV5.js.map +1 -0
- package/dist/{chunk-5TAY5I34.js → chunk-Q5XGHH7D.js} +471 -209
- package/dist/chunk-Q5XGHH7D.js.map +1 -0
- package/dist/{chunk-5KUJ63KT.cjs → chunk-XK5PW7IX.cjs} +916 -1032
- package/dist/chunk-XK5PW7IX.cjs.map +1 -0
- package/dist/{chunk-BL3GFOZR.cjs → chunk-Y4OD5SDF.cjs} +473 -208
- package/dist/chunk-Y4OD5SDF.cjs.map +1 -0
- package/dist/{client-DOYqm17u.d.ts → client-Bn-0nJ8y.d.ts} +14 -2
- package/dist/{client-BQliWrjz.d.cts → client-Ca2wlmC4.d.cts} +14 -2
- package/dist/{index-BKyI_YQS.d.cts → index-Ct2Mh0zl.d.cts} +1 -1
- package/dist/{index-BrsbEcIx.d.ts → index-D50r0Gl0.d.ts} +1 -1
- package/dist/index.cjs +451 -451
- package/dist/index.d.cts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +3 -3
- package/dist/pagination/index.d.cts +2 -2
- package/dist/pagination/index.d.ts +2 -2
- package/dist/{sync-engine-DN0tSqtg.d.cts → sync-engine-21OlgS5_.d.cts} +5 -16
- package/dist/{sync-engine-BmE8-rhX.d.ts → sync-engine-D35aV8Zc.d.ts} +5 -16
- package/package.json +1 -1
- package/dist/chunk-2C5KMNDM.cjs.map +0 -1
- package/dist/chunk-5KUJ63KT.cjs.map +0 -1
- package/dist/chunk-5TAY5I34.js.map +0 -1
- package/dist/chunk-BBXV2I6V.js.map +0 -1
- package/dist/chunk-BL3GFOZR.cjs.map +0 -1
- package/dist/chunk-UDAQBW74.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Connection, PageInfo, defaultConnection } from './chunk-KEM6SUTS.js';
|
|
2
2
|
import { createInferenceClientInternal } from './chunk-PDM2KR7T.js';
|
|
3
|
-
import { createHttpTransport, BillingClient, print, Kind } from './chunk-
|
|
3
|
+
import { ConnectionSupervisor, consumeSseStream, refreshTokenSingleFlight, createHttpTransport, BillingClient, print, Kind } from './chunk-Q5XGHH7D.js';
|
|
4
4
|
import { GRAPHQL_ERROR_CODES, DvinaAuthenticationError, DvinaNetworkError, DvinaGraphQLError, DvinaError, createGraphQLError } from './chunk-7XBJ77RJ.js';
|
|
5
|
-
import { ChatConnectionFragmentDoc, ChatFragmentDoc, FileFragmentDoc, ChatMessageFragmentDoc, AgentConnectionFragmentDoc, ArtifactConnectionFragmentDoc, DesktopDeviceFragmentDoc, InsightFragmentDoc, ChatMessageConnectionFragmentDoc, ProjectFragmentDoc, ContentBlockFragmentDoc, FeedbackFragmentDoc, DatabaseEngineFragmentDoc, TableConnectionFragmentDoc, ProjectDesktopBindingFragmentDoc, DocumentContentFragmentDoc, DocumentFormatFragmentDoc, FeedSendMessageActionFragmentDoc, FeedArtifactDataFragmentDoc, ReportMemberFragmentDoc, ReportConnectionFragmentDoc, IntegrationProviderFragmentDoc, FeedItemGeneratedFragmentDoc, CandidateFragmentDoc, IntegrationFragmentDoc, InsightConnectionFragmentDoc, DatabaseFragmentDoc, DocumentFragmentDoc, RelationFragmentDoc, AbortChatDocument, AddInsightToReportDocument, CancelOauthFlowDocument, CancelWorkspaceDeletionDocument, ConnectIntegrationDocument, ConsumePulseEventsDocument, ContinueImportedChatDocument, ContinueInterpretationDocument, CreateAgentDocument, CreateChatDocument, CreateDatabaseDocument, CreateDocumentDocument, CreateFeedbackDocument, CreateFolderDocument, CreateInsightDocument, CreateIntegrationDocument, CreateProjectDocument, CreateReportDocument, CreateTableDocument, CreateUserSkillFileDocument, CreateUserSkillFolderDocument, DeleteAgentDocument, DeleteAiProviderSettingDocument, DeleteArtifactDocument, DeleteChatDocument, DeleteDatabaseDocument, DeleteDocumentDocument, DeleteFolderDocument, DeleteInsightDocument, DeleteInsightsDocument, DeleteIntegrationDocument, DeleteProjectDocument, DeleteReportDocument, DeleteTableDocument, DeleteUserSkillFileDocument, DeleteUserSkillFolderDocument, DisconnectIntegrationDocument, DismissPulseEventDocument, ExecuteChatImportDocument, GenerateUploadUriDocument, PreviewChatImportDocument, ReanalyzeDocumentDocument, RefineAgentInstructionDocument, RefineSkillInstructionDocument, RefreshDatabaseSchemaDocument, RefreshInsightDocument, RegisterDesktopDeviceDocument, ReinterpretSourceDocument, ReinterpretSourcesOfuserDocument, RelocateInsightDocument, RemoveInsightFromReportDocument, ResetWorkspaceDocument, ResolvePulseEventDocument, ScheduleWorkspaceDeletionDocument, SendMessageDocument, SetDatabasePrimaryKeyDocument, SyncProjectDesktopBindingDocument, UpdateAgentDocument, UpdateArtifactNameDocument, UpdateChatDocument, UpdateDatabaseDocument, UpdateDocumentDocument, UpdateFolderDocument, UpdateInsightDocument, UpdateInsightInReportDocument, UpdateInsightThumbnailDocument, UpdateInterpDocument, UpdateLiveContextDocument, UpdateProjectDocument, UpdatePulseTriggerDocument, UpdateReportDocument, UpdateTableDocument, UpdateUserSkillFileDocument, UpdateUserSkillFolderDocument, UpsertAiProviderSettingDocument, AgentDocument, Agent_ChatsDocument, AgentsDocument, AiProviderSettingDocument, ArtifactDocument, Artifact_ChatDocument, Artifact_Chat_DesktopDeviceDocument, Artifact_Chat_InsightDocument, Artifact_Chat_ProjectDocument, Artifact_FileDocument, Artifact_MessageDocument, Artifact_Message_ChatDocument, Artifact_Message_ContentsDocument, Artifact_Message_FeedbackDocument, ArtifactsDocument, ChatDocument, Chat_AgentsDocument, Chat_ArtifactsDocument, Chat_DesktopDeviceDocument, Chat_DesktopDevice_DesktopBindingsDocument, Chat_InsightDocument, Chat_Insight_ReportMembersDocument, Chat_Insight_ThumbnailFileDocument, Chat_MessagesDocument, Chat_ProjectDocument, Chat_Project_DesktopBindingDocument, ChatMessageDocument, ChatMessage_ArtifactsDocument, ChatMessage_ChatDocument, ChatMessage_Chat_DesktopDeviceDocument, ChatMessage_Chat_InsightDocument, ChatMessage_Chat_ProjectDocument, ChatMessage_ContentsDocument, ChatMessage_FeedbackDocument, ChatMessagesDocument, ChatsDocument, DatabaseDocument, Database_EngineDocument, Database_Engine_CatalogDocument, Database_TablesDocument, DatabaseCatalogDocument, DatabaseCatalog_EngineDocument, DatabaseCatalogsDocument, DatabaseSchemaDocument, DatabasesDocument, DesktopDeviceDocument, DesktopDevice_ChatsDocument, DesktopDevice_DesktopBindingsDocument, DesktopDevicesDocument, DocumentDocument, Document_ContentsDocument, Document_FileDocument, Document_FormatDocument, Document_Format_CatalogDocument, Document_TablesDocument, DocumentCatalogDocument, DocumentCatalog_FormatDocument, DocumentCatalogsDocument, DocumentsDocument, ExportDocument, ExportWithInsightIdDocument, FeedItemDocument, FeedItem_ActionDocument, FeedItem_DataDocument, FeedItemsDocument, FileDocument, FileMetaDocument, FileUrlsDocument, FindFitTierDocument, FolderDocument, FoldersDocument, GetCapabilityDocument, GetDevAccessTokenDocument, GetLimitDocument, GetRemainingDocument, GetTokenUsageByModelDocument, GetTokenUsageHistoryDocument, GetTokenUsageStatusDocument, UsageWindowsStatusTypeFragmentDoc, GetTokenUsageStatus_WindowsDocument, GetTokenUsageStatus_Windows_DayDocument, GetTokenUsageStatus_Windows_FiveHourDocument, GetTokenUsageStatus_Windows_MonthDocument, GetTokenUsageStatus_Windows_WeekDocument, GetUsageDocument, InsightDocument, Insight_ChatDocument, Insight_Chat_DesktopDeviceDocument, Insight_Chat_ProjectDocument, Insight_ReportMembersDocument, Insight_ReportsDocument, Insight_ThumbnailFileDocument, InsightsDocument, IntegrationDocument, Integration_ProviderDocument, Integration_Provider_CatalogDocument, IntegrationCatalogDocument, IntegrationCatalog_ProviderDocument, IntegrationCatalogToolsDocument, IntegrationCatalogsDocument, IntegrationsDocument, InterpretationsDocument, LiveContextDocument, LiveContext_ItemsDocument, LiveContext_SourceDocument, LiveContext_Source_EvidencesDocument, LiveContextsDocument, LocalSandboxDeviceStatusesDocument, NotificationDocument, NotificationsDocument, NotificationsByReferenceDocument, PrivacyStatsDocument, ProjectDocument, Project_ChatsDocument, Project_DesktopBindingDocument, Project_DesktopBinding_DeviceDocument, ProjectsDocument, PulseAppSummaryDocument, PulseEventDocument, PulseEvent_IntegrationDocument, PulseEvent_Integration_ProviderDocument, PulseEventsDocument, PulseTriggerSettingsDocument, QueryDocument, QueryWithInsightIdDocument, QueryWithMessageIdDocument, ReportDocument, Report_InsightsDocument, Report_LayoutDocument, ReportsDocument, TableDocument, Table_DatabaseDocument, Table_Database_EngineDocument, Table_DocumentDocument, Table_Document_ContentsDocument, Table_Document_FileDocument, Table_Document_FormatDocument, Table_FromRelationsDocument, Table_ToRelationsDocument, TablesDocument, UserSkillFileDocument, UserSkillFilesDocument, UserSkillFolderDocument, UserSkillFoldersDocument, WorkspaceDeletionScheduleDocument, McpAuthUpdatesDocument, TokenUsageUpdatesDocument } from './chunk-
|
|
5
|
+
import { ChatConnectionFragmentDoc, ChatFragmentDoc, FileFragmentDoc, ChatMessageFragmentDoc, AgentConnectionFragmentDoc, ArtifactConnectionFragmentDoc, DesktopDeviceFragmentDoc, InsightFragmentDoc, ChatMessageConnectionFragmentDoc, ProjectFragmentDoc, ContentBlockFragmentDoc, FeedbackFragmentDoc, DatabaseEngineFragmentDoc, TableConnectionFragmentDoc, ProjectDesktopBindingFragmentDoc, DocumentContentFragmentDoc, DocumentFormatFragmentDoc, FeedSendMessageActionFragmentDoc, FeedArtifactDataFragmentDoc, ReportMemberFragmentDoc, ReportConnectionFragmentDoc, IntegrationProviderFragmentDoc, FeedItemGeneratedFragmentDoc, CandidateFragmentDoc, IntegrationFragmentDoc, InsightConnectionFragmentDoc, DatabaseFragmentDoc, DocumentFragmentDoc, RelationFragmentDoc, AbortChatDocument, AddInsightToReportDocument, CancelOauthFlowDocument, CancelWorkspaceDeletionDocument, ConnectIntegrationDocument, ConsumePulseEventsDocument, ContinueImportedChatDocument, ContinueInterpretationDocument, CreateAgentDocument, CreateChatDocument, CreateDatabaseDocument, CreateDocumentDocument, CreateFeedbackDocument, CreateFolderDocument, CreateInsightDocument, CreateIntegrationDocument, CreateProjectDocument, CreateReportDocument, CreateTableDocument, CreateUserSkillFileDocument, CreateUserSkillFolderDocument, DeleteAgentDocument, DeleteAiProviderSettingDocument, DeleteArtifactDocument, DeleteChatDocument, DeleteDatabaseDocument, DeleteDocumentDocument, DeleteFolderDocument, DeleteInsightDocument, DeleteInsightsDocument, DeleteIntegrationDocument, DeleteProjectDocument, DeleteReportDocument, DeleteTableDocument, DeleteUserSkillFileDocument, DeleteUserSkillFolderDocument, DisconnectIntegrationDocument, DismissPulseEventDocument, ExecuteChatImportDocument, GenerateUploadUriDocument, PreviewChatImportDocument, ReanalyzeDocumentDocument, RefineAgentInstructionDocument, RefineSkillInstructionDocument, RefreshDatabaseSchemaDocument, RefreshInsightDocument, RegisterDesktopDeviceDocument, ReinterpretSourceDocument, ReinterpretSourcesOfuserDocument, RelocateInsightDocument, RemoveInsightFromReportDocument, ResetWorkspaceDocument, ResolvePulseEventDocument, ScheduleWorkspaceDeletionDocument, SendMessageDocument, SetDatabasePrimaryKeyDocument, SyncProjectDesktopBindingDocument, UpdateAgentDocument, UpdateArtifactNameDocument, UpdateChatDocument, UpdateDatabaseDocument, UpdateDocumentDocument, UpdateFolderDocument, UpdateInsightDocument, UpdateInsightInReportDocument, UpdateInsightThumbnailDocument, UpdateInterpDocument, UpdateLiveContextDocument, UpdateProjectDocument, UpdatePulseTriggerDocument, UpdateReportDocument, UpdateTableDocument, UpdateUserSkillFileDocument, UpdateUserSkillFolderDocument, UpsertAiProviderSettingDocument, AgentDocument, Agent_ChatsDocument, AgentsDocument, AiProviderSettingDocument, ArtifactDocument, Artifact_ChatDocument, Artifact_Chat_DesktopDeviceDocument, Artifact_Chat_InsightDocument, Artifact_Chat_ProjectDocument, Artifact_FileDocument, Artifact_MessageDocument, Artifact_Message_ChatDocument, Artifact_Message_ContentsDocument, Artifact_Message_FeedbackDocument, ArtifactsDocument, ChatDocument, Chat_AgentsDocument, Chat_ArtifactsDocument, Chat_DesktopDeviceDocument, Chat_DesktopDevice_DesktopBindingsDocument, Chat_InsightDocument, Chat_Insight_ReportMembersDocument, Chat_Insight_ThumbnailFileDocument, Chat_MessagesDocument, Chat_ProjectDocument, Chat_Project_DesktopBindingDocument, ChatMessageDocument, ChatMessage_ArtifactsDocument, ChatMessage_ChatDocument, ChatMessage_Chat_DesktopDeviceDocument, ChatMessage_Chat_InsightDocument, ChatMessage_Chat_ProjectDocument, ChatMessage_ContentsDocument, ChatMessage_FeedbackDocument, ChatMessagesDocument, ChatsDocument, DatabaseDocument, Database_EngineDocument, Database_Engine_CatalogDocument, Database_TablesDocument, DatabaseCatalogDocument, DatabaseCatalog_EngineDocument, DatabaseCatalogsDocument, DatabaseSchemaDocument, DatabasesDocument, DesktopDeviceDocument, DesktopDevice_ChatsDocument, DesktopDevice_DesktopBindingsDocument, DesktopDevicesDocument, DocumentDocument, Document_ContentsDocument, Document_FileDocument, Document_FormatDocument, Document_Format_CatalogDocument, Document_TablesDocument, DocumentCatalogDocument, DocumentCatalog_FormatDocument, DocumentCatalogsDocument, DocumentsDocument, ExportDocument, ExportWithInsightIdDocument, FeedItemDocument, FeedItem_ActionDocument, FeedItem_DataDocument, FeedItemsDocument, FileDocument, FileMetaDocument, FileUrlsDocument, FindFitTierDocument, FolderDocument, FoldersDocument, GetCapabilityDocument, GetDevAccessTokenDocument, GetLimitDocument, GetRemainingDocument, GetTokenUsageByModelDocument, GetTokenUsageHistoryDocument, GetTokenUsageStatusDocument, UsageWindowsStatusTypeFragmentDoc, GetTokenUsageStatus_WindowsDocument, GetTokenUsageStatus_Windows_DayDocument, GetTokenUsageStatus_Windows_FiveHourDocument, GetTokenUsageStatus_Windows_MonthDocument, GetTokenUsageStatus_Windows_WeekDocument, GetUsageDocument, InsightDocument, Insight_ChatDocument, Insight_Chat_DesktopDeviceDocument, Insight_Chat_ProjectDocument, Insight_ReportMembersDocument, Insight_ReportsDocument, Insight_ThumbnailFileDocument, InsightsDocument, IntegrationDocument, Integration_ProviderDocument, Integration_Provider_CatalogDocument, IntegrationCatalogDocument, IntegrationCatalog_ProviderDocument, IntegrationCatalogToolsDocument, IntegrationCatalogsDocument, IntegrationsDocument, InterpretationsDocument, LiveContextDocument, LiveContext_ItemsDocument, LiveContext_SourceDocument, LiveContext_Source_EvidencesDocument, LiveContextsDocument, LocalSandboxDeviceStatusesDocument, NotificationDocument, NotificationsDocument, NotificationsByReferenceDocument, PrivacyStatsDocument, ProjectDocument, Project_ChatsDocument, Project_DesktopBindingDocument, Project_DesktopBinding_DeviceDocument, ProjectsDocument, PulseAppSummaryDocument, PulseEventDocument, PulseEvent_IntegrationDocument, PulseEvent_Integration_ProviderDocument, PulseEventsDocument, PulseTriggerSettingsDocument, QueryDocument, QueryWithInsightIdDocument, QueryWithMessageIdDocument, ReportDocument, Report_InsightsDocument, Report_LayoutDocument, ReportsDocument, TableDocument, Table_DatabaseDocument, Table_Database_EngineDocument, Table_DocumentDocument, Table_Document_ContentsDocument, Table_Document_FileDocument, Table_Document_FormatDocument, Table_FromRelationsDocument, Table_ToRelationsDocument, TablesDocument, UserSkillFileDocument, UserSkillFilesDocument, UserSkillFolderDocument, UserSkillFoldersDocument, WorkspaceDeletionScheduleDocument, McpAuthUpdatesDocument, TokenUsageUpdatesDocument } from './chunk-ETPR6MV5.js';
|
|
6
6
|
import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
|
|
7
7
|
|
|
8
8
|
// ../../node_modules/.pnpm/dexie@4.3.0/node_modules/dexie/dist/dexie.js
|
|
@@ -6033,7 +6033,6 @@ var require_dexie = __commonJS({
|
|
|
6033
6033
|
// src/chat-stream.ts
|
|
6034
6034
|
var INITIAL_RECONNECT_DELAY_MS = 1e3;
|
|
6035
6035
|
var MAX_RECONNECT_DELAY_MS = 3e4;
|
|
6036
|
-
var RECONNECT_BACKOFF_MULTIPLIER = 2;
|
|
6037
6036
|
var MAX_CONSECUTIVE_AUTH_FAILURES = 3;
|
|
6038
6037
|
var AuthChatStreamError = class extends Error {
|
|
6039
6038
|
constructor(status) {
|
|
@@ -6047,24 +6046,63 @@ var ChatStreamConnection = class {
|
|
|
6047
6046
|
this.chatId = chatId;
|
|
6048
6047
|
this.options = options;
|
|
6049
6048
|
this.onEmpty = onEmpty;
|
|
6049
|
+
this.supervisor = new ConnectionSupervisor({
|
|
6050
|
+
authRetryDelayMs: INITIAL_RECONNECT_DELAY_MS,
|
|
6051
|
+
baseReconnectDelayMs: INITIAL_RECONNECT_DELAY_MS,
|
|
6052
|
+
getToken: options.getToken,
|
|
6053
|
+
id: chatId,
|
|
6054
|
+
isAuthError: (error) => error instanceof AuthChatStreamError,
|
|
6055
|
+
kind: "chat-sse",
|
|
6056
|
+
maxConsecutiveAuthFailures: MAX_CONSECUTIVE_AUTH_FAILURES,
|
|
6057
|
+
maxReconnectDelayMs: MAX_RECONNECT_DELAY_MS,
|
|
6058
|
+
onFatalError: () => {
|
|
6059
|
+
const authError = new DvinaAuthenticationError("Chat SSE stream authentication failed permanently");
|
|
6060
|
+
this.options.onError?.(authError);
|
|
6061
|
+
this.close(authError);
|
|
6062
|
+
},
|
|
6063
|
+
dial: async (context) => {
|
|
6064
|
+
const url = new URL(`${this.options.baseUrl}/${encodeURIComponent(this.chatId)}/stream`);
|
|
6065
|
+
if (this.lastEventId) {
|
|
6066
|
+
url.searchParams.set("lastEventId", this.lastEventId);
|
|
6067
|
+
}
|
|
6068
|
+
const response = await fetch(url.toString(), {
|
|
6069
|
+
method: "GET",
|
|
6070
|
+
headers: {
|
|
6071
|
+
Accept: "text/event-stream",
|
|
6072
|
+
Authorization: `Bearer ${context.token}`,
|
|
6073
|
+
"Cache-Control": "no-cache",
|
|
6074
|
+
...this.lastEventId ? { "Last-Event-ID": this.lastEventId } : {}
|
|
6075
|
+
},
|
|
6076
|
+
signal: context.signal
|
|
6077
|
+
});
|
|
6078
|
+
if (!response.ok) {
|
|
6079
|
+
if (response.status === 401 || response.status === 403) {
|
|
6080
|
+
throw new AuthChatStreamError(response.status);
|
|
6081
|
+
}
|
|
6082
|
+
throw new Error(`Chat stream connection failed: ${response.status} ${response.statusText}`);
|
|
6083
|
+
}
|
|
6084
|
+
if (!response.body) {
|
|
6085
|
+
throw new Error("Chat stream response has no body");
|
|
6086
|
+
}
|
|
6087
|
+
context.markConnected();
|
|
6088
|
+
await consumeSseStream(response.body, context.signal, {
|
|
6089
|
+
onChunk: () => context.markActivity(),
|
|
6090
|
+
onEventBlock: (block) => this.processEventBlock(block, context.requestTokenRefresh)
|
|
6091
|
+
});
|
|
6092
|
+
}
|
|
6093
|
+
});
|
|
6050
6094
|
}
|
|
6051
|
-
abortController;
|
|
6052
|
-
consecutiveAuthFailures = 0;
|
|
6053
6095
|
destroyed = false;
|
|
6054
6096
|
lastEventId;
|
|
6055
|
-
needsForceRefresh = false;
|
|
6056
|
-
reconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
6057
|
-
reconnectTimer;
|
|
6058
|
-
shouldReconnect = false;
|
|
6059
6097
|
subscribers = /* @__PURE__ */ new Set();
|
|
6098
|
+
supervisor;
|
|
6060
6099
|
addSubscriber(subscriber) {
|
|
6061
6100
|
if (this.destroyed) {
|
|
6062
6101
|
throw new Error(`Chat stream '${this.chatId}' is closed`);
|
|
6063
6102
|
}
|
|
6064
6103
|
this.subscribers.add(subscriber);
|
|
6065
|
-
if (
|
|
6066
|
-
this.
|
|
6067
|
-
void this.doConnect();
|
|
6104
|
+
if (this.subscribers.size === 1) {
|
|
6105
|
+
void this.supervisor.start();
|
|
6068
6106
|
}
|
|
6069
6107
|
}
|
|
6070
6108
|
removeSubscriber(subscriber) {
|
|
@@ -6073,17 +6111,18 @@ var ChatStreamConnection = class {
|
|
|
6073
6111
|
this.close();
|
|
6074
6112
|
}
|
|
6075
6113
|
}
|
|
6076
|
-
|
|
6077
|
-
this.
|
|
6078
|
-
|
|
6079
|
-
if (this.reconnectTimer) {
|
|
6080
|
-
clearTimeout(this.reconnectTimer);
|
|
6081
|
-
this.reconnectTimer = void 0;
|
|
6114
|
+
reconnect() {
|
|
6115
|
+
if (this.destroyed || this.subscribers.size === 0) {
|
|
6116
|
+
return;
|
|
6082
6117
|
}
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6118
|
+
this.supervisor.reconnect();
|
|
6119
|
+
}
|
|
6120
|
+
close(error) {
|
|
6121
|
+
if (this.destroyed) {
|
|
6122
|
+
return;
|
|
6086
6123
|
}
|
|
6124
|
+
this.destroyed = true;
|
|
6125
|
+
this.supervisor.close();
|
|
6087
6126
|
for (const subscriber of Array.from(this.subscribers)) {
|
|
6088
6127
|
subscriber.finish(error);
|
|
6089
6128
|
}
|
|
@@ -6093,94 +6132,7 @@ var ChatStreamConnection = class {
|
|
|
6093
6132
|
get isDestroyed() {
|
|
6094
6133
|
return this.destroyed;
|
|
6095
6134
|
}
|
|
6096
|
-
|
|
6097
|
-
if (!this.shouldReconnect || this.destroyed || this.subscribers.size === 0) {
|
|
6098
|
-
return;
|
|
6099
|
-
}
|
|
6100
|
-
this.abortController = new AbortController();
|
|
6101
|
-
try {
|
|
6102
|
-
const forceRefresh = this.needsForceRefresh;
|
|
6103
|
-
this.needsForceRefresh = false;
|
|
6104
|
-
const token = await this.options.getToken(forceRefresh ? { forceRefresh: true } : void 0);
|
|
6105
|
-
const url = new URL(`${this.options.baseUrl}/${encodeURIComponent(this.chatId)}/stream`);
|
|
6106
|
-
if (this.lastEventId) {
|
|
6107
|
-
url.searchParams.set("lastEventId", this.lastEventId);
|
|
6108
|
-
}
|
|
6109
|
-
const response = await fetch(url.toString(), {
|
|
6110
|
-
method: "GET",
|
|
6111
|
-
headers: {
|
|
6112
|
-
Accept: "text/event-stream",
|
|
6113
|
-
Authorization: `Bearer ${token}`,
|
|
6114
|
-
"Cache-Control": "no-cache",
|
|
6115
|
-
...this.lastEventId ? { "Last-Event-ID": this.lastEventId } : {}
|
|
6116
|
-
},
|
|
6117
|
-
signal: this.abortController.signal
|
|
6118
|
-
});
|
|
6119
|
-
if (!response.ok) {
|
|
6120
|
-
if (response.status === 401 || response.status === 403) {
|
|
6121
|
-
throw new AuthChatStreamError(response.status);
|
|
6122
|
-
}
|
|
6123
|
-
throw new Error(`Chat stream connection failed: ${response.status} ${response.statusText}`);
|
|
6124
|
-
}
|
|
6125
|
-
if (!response.body) {
|
|
6126
|
-
throw new Error("Chat stream response has no body");
|
|
6127
|
-
}
|
|
6128
|
-
this.consecutiveAuthFailures = 0;
|
|
6129
|
-
this.reconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
6130
|
-
await this.parseSseStream(response.body, this.abortController.signal);
|
|
6131
|
-
} catch (error) {
|
|
6132
|
-
if (error.name === "AbortError") {
|
|
6133
|
-
return;
|
|
6134
|
-
}
|
|
6135
|
-
if (!this.shouldReconnect || this.destroyed || this.subscribers.size === 0) {
|
|
6136
|
-
return;
|
|
6137
|
-
}
|
|
6138
|
-
const isAuthError2 = error instanceof AuthChatStreamError;
|
|
6139
|
-
if (isAuthError2) {
|
|
6140
|
-
this.consecutiveAuthFailures += 1;
|
|
6141
|
-
if (this.consecutiveAuthFailures >= MAX_CONSECUTIVE_AUTH_FAILURES) {
|
|
6142
|
-
const authError = new DvinaAuthenticationError("Chat SSE stream authentication failed permanently");
|
|
6143
|
-
this.options.onError?.(authError);
|
|
6144
|
-
this.close(authError);
|
|
6145
|
-
return;
|
|
6146
|
-
}
|
|
6147
|
-
this.needsForceRefresh = true;
|
|
6148
|
-
}
|
|
6149
|
-
const delay = isAuthError2 ? INITIAL_RECONNECT_DELAY_MS : this.reconnectDelay;
|
|
6150
|
-
this.scheduleReconnect(delay);
|
|
6151
|
-
if (!isAuthError2) {
|
|
6152
|
-
this.reconnectDelay = Math.min(
|
|
6153
|
-
this.reconnectDelay * RECONNECT_BACKOFF_MULTIPLIER,
|
|
6154
|
-
MAX_RECONNECT_DELAY_MS
|
|
6155
|
-
);
|
|
6156
|
-
}
|
|
6157
|
-
}
|
|
6158
|
-
}
|
|
6159
|
-
async parseSseStream(body, signal) {
|
|
6160
|
-
const reader = body.getReader();
|
|
6161
|
-
const decoder = new TextDecoder();
|
|
6162
|
-
let buffer = "";
|
|
6163
|
-
try {
|
|
6164
|
-
while (!signal.aborted && this.shouldReconnect && !this.destroyed) {
|
|
6165
|
-
const { done, value } = await reader.read();
|
|
6166
|
-
if (done) {
|
|
6167
|
-
break;
|
|
6168
|
-
}
|
|
6169
|
-
buffer += decoder.decode(value, { stream: true });
|
|
6170
|
-
const parts = buffer.split(/(?:\r\n|\r|\n){2}/);
|
|
6171
|
-
buffer = parts.pop() ?? "";
|
|
6172
|
-
for (const part of parts) {
|
|
6173
|
-
this.processEventBlock(part.trim());
|
|
6174
|
-
}
|
|
6175
|
-
}
|
|
6176
|
-
} finally {
|
|
6177
|
-
reader.releaseLock();
|
|
6178
|
-
}
|
|
6179
|
-
if (this.shouldReconnect && !this.destroyed && this.subscribers.size > 0) {
|
|
6180
|
-
this.scheduleReconnect(this.reconnectDelay);
|
|
6181
|
-
}
|
|
6182
|
-
}
|
|
6183
|
-
processEventBlock(block) {
|
|
6135
|
+
processEventBlock(block, requestTokenRefresh) {
|
|
6184
6136
|
if (!block || block.startsWith(":")) {
|
|
6185
6137
|
return;
|
|
6186
6138
|
}
|
|
@@ -6197,8 +6149,8 @@ var ChatStreamConnection = class {
|
|
|
6197
6149
|
}
|
|
6198
6150
|
}
|
|
6199
6151
|
if (eventType === "token-expired") {
|
|
6200
|
-
|
|
6201
|
-
|
|
6152
|
+
requestTokenRefresh();
|
|
6153
|
+
throw new AuthChatStreamError(401);
|
|
6202
6154
|
}
|
|
6203
6155
|
if (!eventId || dataLines.length === 0) {
|
|
6204
6156
|
return;
|
|
@@ -6215,40 +6167,64 @@ var ChatStreamConnection = class {
|
|
|
6215
6167
|
subscriber.push(value);
|
|
6216
6168
|
}
|
|
6217
6169
|
}
|
|
6218
|
-
scheduleReconnect(delay) {
|
|
6219
|
-
if (!this.shouldReconnect || this.destroyed || this.subscribers.size === 0) {
|
|
6220
|
-
return;
|
|
6221
|
-
}
|
|
6222
|
-
if (this.reconnectTimer) {
|
|
6223
|
-
clearTimeout(this.reconnectTimer);
|
|
6224
|
-
}
|
|
6225
|
-
this.reconnectTimer = setTimeout(() => {
|
|
6226
|
-
this.reconnectTimer = void 0;
|
|
6227
|
-
void this.doConnect();
|
|
6228
|
-
}, delay);
|
|
6229
|
-
}
|
|
6230
6170
|
};
|
|
6231
6171
|
var ActiveChatStreamConnection = class {
|
|
6232
6172
|
constructor(options, onEmpty) {
|
|
6233
6173
|
this.options = options;
|
|
6234
6174
|
this.onEmpty = onEmpty;
|
|
6175
|
+
this.supervisor = new ConnectionSupervisor({
|
|
6176
|
+
authRetryDelayMs: INITIAL_RECONNECT_DELAY_MS,
|
|
6177
|
+
baseReconnectDelayMs: INITIAL_RECONNECT_DELAY_MS,
|
|
6178
|
+
getToken: options.getToken,
|
|
6179
|
+
id: "active",
|
|
6180
|
+
isAuthError: (error) => error instanceof AuthChatStreamError,
|
|
6181
|
+
kind: "active-chat-sse",
|
|
6182
|
+
maxConsecutiveAuthFailures: MAX_CONSECUTIVE_AUTH_FAILURES,
|
|
6183
|
+
maxReconnectDelayMs: MAX_RECONNECT_DELAY_MS,
|
|
6184
|
+
onFatalError: () => {
|
|
6185
|
+
const authError = new DvinaAuthenticationError(
|
|
6186
|
+
"Active chat SSE stream authentication failed permanently"
|
|
6187
|
+
);
|
|
6188
|
+
this.options.onError?.(authError);
|
|
6189
|
+
this.close(authError);
|
|
6190
|
+
},
|
|
6191
|
+
dial: async (context) => {
|
|
6192
|
+
const response = await fetch(new URL(`${this.options.baseUrl}/active`).toString(), {
|
|
6193
|
+
method: "GET",
|
|
6194
|
+
headers: {
|
|
6195
|
+
Accept: "text/event-stream",
|
|
6196
|
+
Authorization: `Bearer ${context.token}`,
|
|
6197
|
+
"Cache-Control": "no-cache"
|
|
6198
|
+
},
|
|
6199
|
+
signal: context.signal
|
|
6200
|
+
});
|
|
6201
|
+
if (!response.ok) {
|
|
6202
|
+
if (response.status === 401 || response.status === 403) {
|
|
6203
|
+
throw new AuthChatStreamError(response.status);
|
|
6204
|
+
}
|
|
6205
|
+
throw new Error(`Active chat stream connection failed: ${response.status} ${response.statusText}`);
|
|
6206
|
+
}
|
|
6207
|
+
if (!response.body) {
|
|
6208
|
+
throw new Error("Active chat stream response has no body");
|
|
6209
|
+
}
|
|
6210
|
+
context.markConnected();
|
|
6211
|
+
await consumeSseStream(response.body, context.signal, {
|
|
6212
|
+
onChunk: () => context.markActivity(),
|
|
6213
|
+
onEventBlock: (block) => this.processEventBlock(block, context.requestTokenRefresh)
|
|
6214
|
+
});
|
|
6215
|
+
}
|
|
6216
|
+
});
|
|
6235
6217
|
}
|
|
6236
|
-
abortController;
|
|
6237
|
-
consecutiveAuthFailures = 0;
|
|
6238
6218
|
destroyed = false;
|
|
6239
|
-
needsForceRefresh = false;
|
|
6240
|
-
reconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
6241
|
-
reconnectTimer;
|
|
6242
|
-
shouldReconnect = false;
|
|
6243
6219
|
subscribers = /* @__PURE__ */ new Set();
|
|
6220
|
+
supervisor;
|
|
6244
6221
|
addSubscriber(subscriber) {
|
|
6245
6222
|
if (this.destroyed) {
|
|
6246
6223
|
throw new Error("Active chat stream is closed");
|
|
6247
6224
|
}
|
|
6248
6225
|
this.subscribers.add(subscriber);
|
|
6249
|
-
if (
|
|
6250
|
-
this.
|
|
6251
|
-
void this.doConnect();
|
|
6226
|
+
if (this.subscribers.size === 1) {
|
|
6227
|
+
void this.supervisor.start();
|
|
6252
6228
|
}
|
|
6253
6229
|
}
|
|
6254
6230
|
removeSubscriber(subscriber) {
|
|
@@ -6257,17 +6233,18 @@ var ActiveChatStreamConnection = class {
|
|
|
6257
6233
|
this.close();
|
|
6258
6234
|
}
|
|
6259
6235
|
}
|
|
6260
|
-
|
|
6261
|
-
this.
|
|
6262
|
-
|
|
6263
|
-
if (this.reconnectTimer) {
|
|
6264
|
-
clearTimeout(this.reconnectTimer);
|
|
6265
|
-
this.reconnectTimer = void 0;
|
|
6236
|
+
reconnect() {
|
|
6237
|
+
if (this.destroyed || this.subscribers.size === 0) {
|
|
6238
|
+
return;
|
|
6266
6239
|
}
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6240
|
+
this.supervisor.reconnect();
|
|
6241
|
+
}
|
|
6242
|
+
close(error) {
|
|
6243
|
+
if (this.destroyed) {
|
|
6244
|
+
return;
|
|
6270
6245
|
}
|
|
6246
|
+
this.destroyed = true;
|
|
6247
|
+
this.supervisor.close();
|
|
6271
6248
|
for (const subscriber of Array.from(this.subscribers)) {
|
|
6272
6249
|
subscriber.finish(error);
|
|
6273
6250
|
}
|
|
@@ -6277,91 +6254,7 @@ var ActiveChatStreamConnection = class {
|
|
|
6277
6254
|
get isDestroyed() {
|
|
6278
6255
|
return this.destroyed;
|
|
6279
6256
|
}
|
|
6280
|
-
|
|
6281
|
-
if (!this.shouldReconnect || this.destroyed || this.subscribers.size === 0) {
|
|
6282
|
-
return;
|
|
6283
|
-
}
|
|
6284
|
-
this.abortController = new AbortController();
|
|
6285
|
-
try {
|
|
6286
|
-
const forceRefresh = this.needsForceRefresh;
|
|
6287
|
-
this.needsForceRefresh = false;
|
|
6288
|
-
const token = await this.options.getToken(forceRefresh ? { forceRefresh: true } : void 0);
|
|
6289
|
-
const response = await fetch(new URL(`${this.options.baseUrl}/active`).toString(), {
|
|
6290
|
-
method: "GET",
|
|
6291
|
-
headers: {
|
|
6292
|
-
Accept: "text/event-stream",
|
|
6293
|
-
Authorization: `Bearer ${token}`,
|
|
6294
|
-
"Cache-Control": "no-cache"
|
|
6295
|
-
},
|
|
6296
|
-
signal: this.abortController.signal
|
|
6297
|
-
});
|
|
6298
|
-
if (!response.ok) {
|
|
6299
|
-
if (response.status === 401 || response.status === 403) {
|
|
6300
|
-
throw new AuthChatStreamError(response.status);
|
|
6301
|
-
}
|
|
6302
|
-
throw new Error(`Active chat stream connection failed: ${response.status} ${response.statusText}`);
|
|
6303
|
-
}
|
|
6304
|
-
if (!response.body) {
|
|
6305
|
-
throw new Error("Active chat stream response has no body");
|
|
6306
|
-
}
|
|
6307
|
-
this.consecutiveAuthFailures = 0;
|
|
6308
|
-
this.reconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
6309
|
-
await this.parseSseStream(response.body, this.abortController.signal);
|
|
6310
|
-
} catch (error) {
|
|
6311
|
-
if (error.name === "AbortError") {
|
|
6312
|
-
return;
|
|
6313
|
-
}
|
|
6314
|
-
if (!this.shouldReconnect || this.destroyed || this.subscribers.size === 0) {
|
|
6315
|
-
return;
|
|
6316
|
-
}
|
|
6317
|
-
const isAuthError2 = error instanceof AuthChatStreamError;
|
|
6318
|
-
if (isAuthError2) {
|
|
6319
|
-
this.consecutiveAuthFailures += 1;
|
|
6320
|
-
if (this.consecutiveAuthFailures >= MAX_CONSECUTIVE_AUTH_FAILURES) {
|
|
6321
|
-
const authError = new DvinaAuthenticationError(
|
|
6322
|
-
"Active chat SSE stream authentication failed permanently"
|
|
6323
|
-
);
|
|
6324
|
-
this.options.onError?.(authError);
|
|
6325
|
-
this.close(authError);
|
|
6326
|
-
return;
|
|
6327
|
-
}
|
|
6328
|
-
this.needsForceRefresh = true;
|
|
6329
|
-
}
|
|
6330
|
-
const delay = isAuthError2 ? INITIAL_RECONNECT_DELAY_MS : this.reconnectDelay;
|
|
6331
|
-
this.scheduleReconnect(delay);
|
|
6332
|
-
if (!isAuthError2) {
|
|
6333
|
-
this.reconnectDelay = Math.min(
|
|
6334
|
-
this.reconnectDelay * RECONNECT_BACKOFF_MULTIPLIER,
|
|
6335
|
-
MAX_RECONNECT_DELAY_MS
|
|
6336
|
-
);
|
|
6337
|
-
}
|
|
6338
|
-
}
|
|
6339
|
-
}
|
|
6340
|
-
async parseSseStream(body, signal) {
|
|
6341
|
-
const reader = body.getReader();
|
|
6342
|
-
const decoder = new TextDecoder();
|
|
6343
|
-
let buffer = "";
|
|
6344
|
-
try {
|
|
6345
|
-
while (!signal.aborted && this.shouldReconnect && !this.destroyed) {
|
|
6346
|
-
const { done, value } = await reader.read();
|
|
6347
|
-
if (done) {
|
|
6348
|
-
break;
|
|
6349
|
-
}
|
|
6350
|
-
buffer += decoder.decode(value, { stream: true });
|
|
6351
|
-
const parts = buffer.split(/(?:\r\n|\r|\n){2}/);
|
|
6352
|
-
buffer = parts.pop() ?? "";
|
|
6353
|
-
for (const part of parts) {
|
|
6354
|
-
this.processEventBlock(part.trim());
|
|
6355
|
-
}
|
|
6356
|
-
}
|
|
6357
|
-
} finally {
|
|
6358
|
-
reader.releaseLock();
|
|
6359
|
-
}
|
|
6360
|
-
if (this.shouldReconnect && !this.destroyed && this.subscribers.size > 0) {
|
|
6361
|
-
this.scheduleReconnect(this.reconnectDelay);
|
|
6362
|
-
}
|
|
6363
|
-
}
|
|
6364
|
-
processEventBlock(block) {
|
|
6257
|
+
processEventBlock(block, requestTokenRefresh) {
|
|
6365
6258
|
if (!block || block.startsWith(":")) {
|
|
6366
6259
|
return;
|
|
6367
6260
|
}
|
|
@@ -6375,8 +6268,8 @@ var ActiveChatStreamConnection = class {
|
|
|
6375
6268
|
}
|
|
6376
6269
|
}
|
|
6377
6270
|
if (eventType === "token-expired") {
|
|
6378
|
-
|
|
6379
|
-
|
|
6271
|
+
requestTokenRefresh();
|
|
6272
|
+
throw new AuthChatStreamError(401);
|
|
6380
6273
|
}
|
|
6381
6274
|
if (eventType !== "active" || dataLines.length === 0) {
|
|
6382
6275
|
return;
|
|
@@ -6395,18 +6288,6 @@ var ActiveChatStreamConnection = class {
|
|
|
6395
6288
|
subscriber.push(value);
|
|
6396
6289
|
}
|
|
6397
6290
|
}
|
|
6398
|
-
scheduleReconnect(delay) {
|
|
6399
|
-
if (!this.shouldReconnect || this.destroyed || this.subscribers.size === 0) {
|
|
6400
|
-
return;
|
|
6401
|
-
}
|
|
6402
|
-
if (this.reconnectTimer) {
|
|
6403
|
-
clearTimeout(this.reconnectTimer);
|
|
6404
|
-
}
|
|
6405
|
-
this.reconnectTimer = setTimeout(() => {
|
|
6406
|
-
this.reconnectTimer = void 0;
|
|
6407
|
-
void this.doConnect();
|
|
6408
|
-
}, delay);
|
|
6409
|
-
}
|
|
6410
6291
|
};
|
|
6411
6292
|
function createChatStreamClient(options) {
|
|
6412
6293
|
const connections = /* @__PURE__ */ new Map();
|
|
@@ -6575,6 +6456,12 @@ function createChatStreamClient(options) {
|
|
|
6575
6456
|
}
|
|
6576
6457
|
};
|
|
6577
6458
|
}
|
|
6459
|
+
function reconnectAll() {
|
|
6460
|
+
for (const connection of connections.values()) {
|
|
6461
|
+
connection.reconnect();
|
|
6462
|
+
}
|
|
6463
|
+
activeConnection?.reconnect();
|
|
6464
|
+
}
|
|
6578
6465
|
function destroy() {
|
|
6579
6466
|
for (const connection of Array.from(connections.values())) {
|
|
6580
6467
|
connection.close();
|
|
@@ -6589,6 +6476,7 @@ function createChatStreamClient(options) {
|
|
|
6589
6476
|
},
|
|
6590
6477
|
listen,
|
|
6591
6478
|
stream,
|
|
6479
|
+
reconnectAll,
|
|
6592
6480
|
destroy
|
|
6593
6481
|
};
|
|
6594
6482
|
}
|
|
@@ -7336,20 +7224,12 @@ function createWsTransport(options) {
|
|
|
7336
7224
|
let lastCloseCode = null;
|
|
7337
7225
|
let nextToken;
|
|
7338
7226
|
let currentToken;
|
|
7339
|
-
let refreshPromise = null;
|
|
7340
7227
|
async function refreshToken() {
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
if (!token || token === failedToken) {
|
|
7345
|
-
throw new DvinaAuthenticationError("Token refresh did not produce a new token", failedToken);
|
|
7346
|
-
}
|
|
7347
|
-
nextToken = token;
|
|
7348
|
-
}).finally(() => {
|
|
7349
|
-
refreshPromise = null;
|
|
7350
|
-
});
|
|
7228
|
+
const token = await refreshTokenSingleFlight(options.getToken, currentToken);
|
|
7229
|
+
if (!token) {
|
|
7230
|
+
throw new DvinaAuthenticationError("Token refresh did not produce a new token", currentToken);
|
|
7351
7231
|
}
|
|
7352
|
-
|
|
7232
|
+
nextToken = token;
|
|
7353
7233
|
}
|
|
7354
7234
|
async function prepareSubscriptionConnection() {
|
|
7355
7235
|
const token = nextToken ?? await options.getToken();
|
|
@@ -8085,35 +7965,47 @@ var AuthSseError = class extends Error {
|
|
|
8085
7965
|
};
|
|
8086
7966
|
var INITIAL_RECONNECT_DELAY_MS2 = 1e3;
|
|
8087
7967
|
var MAX_RECONNECT_DELAY_MS2 = 3e4;
|
|
8088
|
-
var RECONNECT_BACKOFF_MULTIPLIER2 = 2;
|
|
8089
7968
|
var MAX_CONSECUTIVE_AUTH_FAILURES2 = 3;
|
|
8090
7969
|
var SUBSCRIPTION_REFRESH_INTERVAL_MS = 5 * 60 * 1e3;
|
|
7970
|
+
function mapSupervisorState(state) {
|
|
7971
|
+
if (state === "connected") {
|
|
7972
|
+
return "connected";
|
|
7973
|
+
}
|
|
7974
|
+
if (state === "connecting") {
|
|
7975
|
+
return "connecting";
|
|
7976
|
+
}
|
|
7977
|
+
return "disconnected";
|
|
7978
|
+
}
|
|
8091
7979
|
function createSseTransport(options) {
|
|
8092
|
-
let abortController;
|
|
8093
7980
|
let isConnected = false;
|
|
8094
|
-
let reconnectDelay = INITIAL_RECONNECT_DELAY_MS2;
|
|
8095
|
-
let reconnectTimer;
|
|
8096
|
-
let refreshTimer;
|
|
8097
|
-
let shouldReconnect = false;
|
|
8098
7981
|
let currentLastSyncId;
|
|
8099
|
-
let
|
|
8100
|
-
let consecutiveAuthFailures = 0;
|
|
7982
|
+
let refreshTimer;
|
|
8101
7983
|
let hasConnectedOnce = false;
|
|
7984
|
+
let lastLegacyState;
|
|
8102
7985
|
const activeSubscriptions = /* @__PURE__ */ new Map();
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
if (!
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
7986
|
+
const emitLegacyState = (state) => {
|
|
7987
|
+
const mapped = mapSupervisorState(state);
|
|
7988
|
+
if (mapped === lastLegacyState) {
|
|
7989
|
+
return;
|
|
7990
|
+
}
|
|
7991
|
+
lastLegacyState = mapped;
|
|
7992
|
+
isConnected = mapped === "connected";
|
|
7993
|
+
if (!isConnected) {
|
|
7994
|
+
stopSubscriptionRefresh();
|
|
7995
|
+
}
|
|
7996
|
+
options.onStateChange?.(mapped);
|
|
7997
|
+
};
|
|
7998
|
+
const supervisor = new ConnectionSupervisor({
|
|
7999
|
+
authRetryDelayMs: INITIAL_RECONNECT_DELAY_MS2,
|
|
8000
|
+
baseReconnectDelayMs: INITIAL_RECONNECT_DELAY_MS2,
|
|
8001
|
+
getToken: options.getToken,
|
|
8002
|
+
id: "primary",
|
|
8003
|
+
isAuthError: (error) => error instanceof AuthSseError,
|
|
8004
|
+
kind: "sync-sse",
|
|
8005
|
+
maxConsecutiveAuthFailures: MAX_CONSECUTIVE_AUTH_FAILURES2,
|
|
8006
|
+
maxReconnectDelayMs: MAX_RECONNECT_DELAY_MS2,
|
|
8007
|
+
onStateChange: (snapshot) => emitLegacyState(snapshot.state),
|
|
8008
|
+
dial: async (context) => {
|
|
8117
8009
|
const url = new URL(options.url);
|
|
8118
8010
|
if (currentLastSyncId && currentLastSyncId !== "0") {
|
|
8119
8011
|
url.searchParams.set("lastSyncId", currentLastSyncId);
|
|
@@ -8121,11 +8013,11 @@ function createSseTransport(options) {
|
|
|
8121
8013
|
const response = await fetch(url.toString(), {
|
|
8122
8014
|
method: "GET",
|
|
8123
8015
|
headers: {
|
|
8124
|
-
Authorization: `Bearer ${token}`,
|
|
8016
|
+
Authorization: `Bearer ${context.token}`,
|
|
8125
8017
|
Accept: "text/event-stream",
|
|
8126
8018
|
"Cache-Control": "no-cache"
|
|
8127
8019
|
},
|
|
8128
|
-
signal:
|
|
8020
|
+
signal: context.signal
|
|
8129
8021
|
});
|
|
8130
8022
|
if (!response.ok) {
|
|
8131
8023
|
if (response.status === 401 || response.status === 403) {
|
|
@@ -8136,73 +8028,100 @@ function createSseTransport(options) {
|
|
|
8136
8028
|
if (!response.body) {
|
|
8137
8029
|
throw new Error("SSE response has no body");
|
|
8138
8030
|
}
|
|
8139
|
-
isConnected = true;
|
|
8140
|
-
consecutiveAuthFailures = 0;
|
|
8141
|
-
reconnectDelay = INITIAL_RECONNECT_DELAY_MS2;
|
|
8142
|
-
options.onStateChange?.("connected");
|
|
8143
8031
|
const isReconnect = hasConnectedOnce;
|
|
8144
8032
|
hasConnectedOnce = true;
|
|
8145
|
-
|
|
8033
|
+
context.markConnected();
|
|
8034
|
+
await syncActiveSubscriptions(context.token);
|
|
8146
8035
|
startSubscriptionRefresh();
|
|
8147
8036
|
if (isReconnect && activeSubscriptions.size > 0) {
|
|
8148
8037
|
options.onReconnect?.();
|
|
8149
8038
|
}
|
|
8150
|
-
await
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8039
|
+
await consumeSseStream(response.body, context.signal, {
|
|
8040
|
+
onChunk: () => context.markActivity(),
|
|
8041
|
+
onEventBlock: (block) => processEventBlock(block, context.requestTokenRefresh)
|
|
8042
|
+
});
|
|
8043
|
+
}
|
|
8044
|
+
});
|
|
8045
|
+
async function connect(lastSyncId) {
|
|
8046
|
+
currentLastSyncId = lastSyncId;
|
|
8047
|
+
disconnect();
|
|
8048
|
+
await supervisor.start();
|
|
8049
|
+
}
|
|
8050
|
+
function disconnect() {
|
|
8051
|
+
supervisor.stop();
|
|
8052
|
+
isConnected = false;
|
|
8053
|
+
stopSubscriptionRefresh();
|
|
8054
|
+
if (lastLegacyState !== "disconnected") {
|
|
8055
|
+
lastLegacyState = "disconnected";
|
|
8157
8056
|
options.onStateChange?.("disconnected");
|
|
8158
|
-
if (shouldReconnect) {
|
|
8159
|
-
const isAuth = err instanceof AuthSseError;
|
|
8160
|
-
if (isAuth) {
|
|
8161
|
-
consecutiveAuthFailures++;
|
|
8162
|
-
if (consecutiveAuthFailures >= MAX_CONSECUTIVE_AUTH_FAILURES2) {
|
|
8163
|
-
disconnect();
|
|
8164
|
-
return;
|
|
8165
|
-
}
|
|
8166
|
-
needsForceRefresh = true;
|
|
8167
|
-
}
|
|
8168
|
-
const delay = isAuth ? INITIAL_RECONNECT_DELAY_MS2 : reconnectDelay;
|
|
8169
|
-
reconnectTimer = setTimeout(() => {
|
|
8170
|
-
doConnect();
|
|
8171
|
-
}, delay);
|
|
8172
|
-
if (!isAuth) {
|
|
8173
|
-
reconnectDelay = Math.min(reconnectDelay * RECONNECT_BACKOFF_MULTIPLIER2, MAX_RECONNECT_DELAY_MS2);
|
|
8174
|
-
}
|
|
8175
|
-
}
|
|
8176
8057
|
}
|
|
8177
8058
|
}
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
if (done) break;
|
|
8186
|
-
buffer += decoder.decode(value, { stream: true });
|
|
8187
|
-
const parts = buffer.split(/(?:\r\n|\r|\n){2}/);
|
|
8188
|
-
buffer = parts.pop() ?? "";
|
|
8189
|
-
for (const part of parts) {
|
|
8190
|
-
processEventBlock(part.trim());
|
|
8191
|
-
}
|
|
8192
|
-
}
|
|
8193
|
-
} finally {
|
|
8194
|
-
reader.releaseLock();
|
|
8059
|
+
function reconnect() {
|
|
8060
|
+
supervisor.reconnect();
|
|
8061
|
+
}
|
|
8062
|
+
function subscribe(descriptor) {
|
|
8063
|
+
activeSubscriptions.set(descriptor.id, descriptor);
|
|
8064
|
+
if (isConnected) {
|
|
8065
|
+
startSubscriptionRefresh();
|
|
8195
8066
|
}
|
|
8196
|
-
|
|
8197
|
-
|
|
8067
|
+
void postMessage({ type: "subscribe", subscription: descriptor });
|
|
8068
|
+
}
|
|
8069
|
+
function unsubscribe(subscriptionId) {
|
|
8070
|
+
activeSubscriptions.delete(subscriptionId);
|
|
8071
|
+
if (activeSubscriptions.size === 0) {
|
|
8198
8072
|
stopSubscriptionRefresh();
|
|
8199
|
-
options.onStateChange?.("disconnected");
|
|
8200
|
-
reconnectTimer = setTimeout(() => {
|
|
8201
|
-
doConnect();
|
|
8202
|
-
}, reconnectDelay);
|
|
8203
8073
|
}
|
|
8074
|
+
void postMessage({ type: "unsubscribe", subscriptionId });
|
|
8075
|
+
}
|
|
8076
|
+
function startSubscriptionRefresh() {
|
|
8077
|
+
if (!isConnected || activeSubscriptions.size === 0 || refreshTimer) {
|
|
8078
|
+
return;
|
|
8079
|
+
}
|
|
8080
|
+
refreshTimer = setInterval(() => {
|
|
8081
|
+
void syncActiveSubscriptions();
|
|
8082
|
+
}, SUBSCRIPTION_REFRESH_INTERVAL_MS);
|
|
8083
|
+
}
|
|
8084
|
+
function stopSubscriptionRefresh() {
|
|
8085
|
+
if (!refreshTimer) {
|
|
8086
|
+
return;
|
|
8087
|
+
}
|
|
8088
|
+
clearInterval(refreshTimer);
|
|
8089
|
+
refreshTimer = void 0;
|
|
8090
|
+
}
|
|
8091
|
+
async function syncActiveSubscriptions(token) {
|
|
8092
|
+
if (activeSubscriptions.size === 0) {
|
|
8093
|
+
return;
|
|
8094
|
+
}
|
|
8095
|
+
const resolvedToken = token ?? await options.getToken().catch(() => void 0);
|
|
8096
|
+
if (!resolvedToken) {
|
|
8097
|
+
return;
|
|
8098
|
+
}
|
|
8099
|
+
await Promise.all(
|
|
8100
|
+
Array.from(activeSubscriptions.values()).map(
|
|
8101
|
+
(descriptor) => postMessage({ type: "subscribe", subscription: descriptor }, resolvedToken).catch(() => {
|
|
8102
|
+
})
|
|
8103
|
+
)
|
|
8104
|
+
);
|
|
8204
8105
|
}
|
|
8205
|
-
function
|
|
8106
|
+
async function postMessage(body, token) {
|
|
8107
|
+
let resolvedToken = token ?? await options.getToken();
|
|
8108
|
+
const url = new URL(options.url);
|
|
8109
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
8110
|
+
const response = await fetch(url.toString(), {
|
|
8111
|
+
method: "POST",
|
|
8112
|
+
headers: {
|
|
8113
|
+
Authorization: `Bearer ${resolvedToken}`,
|
|
8114
|
+
"Content-Type": "application/json"
|
|
8115
|
+
},
|
|
8116
|
+
body: JSON.stringify(body)
|
|
8117
|
+
});
|
|
8118
|
+
if (response.status !== 401 && response.status !== 403) {
|
|
8119
|
+
return;
|
|
8120
|
+
}
|
|
8121
|
+
resolvedToken = await refreshTokenSingleFlight(options.getToken, resolvedToken);
|
|
8122
|
+
}
|
|
8123
|
+
}
|
|
8124
|
+
function processEventBlock(block, requestTokenRefresh) {
|
|
8206
8125
|
if (!block || block.startsWith(":")) {
|
|
8207
8126
|
return;
|
|
8208
8127
|
}
|
|
@@ -8219,8 +8138,8 @@ function createSseTransport(options) {
|
|
|
8219
8138
|
}
|
|
8220
8139
|
}
|
|
8221
8140
|
if (eventType === "token-expired") {
|
|
8222
|
-
|
|
8223
|
-
|
|
8141
|
+
requestTokenRefresh();
|
|
8142
|
+
throw new AuthSseError(401);
|
|
8224
8143
|
}
|
|
8225
8144
|
if (eventType === "full-resync") {
|
|
8226
8145
|
options.onFullResync?.();
|
|
@@ -8237,7 +8156,9 @@ function createSseTransport(options) {
|
|
|
8237
8156
|
}
|
|
8238
8157
|
return;
|
|
8239
8158
|
}
|
|
8240
|
-
if (!eventId)
|
|
8159
|
+
if (!eventId) {
|
|
8160
|
+
return;
|
|
8161
|
+
}
|
|
8241
8162
|
currentLastSyncId = eventId;
|
|
8242
8163
|
if (eventType === "cursor") {
|
|
8243
8164
|
options.onCursor?.(eventId);
|
|
@@ -8254,82 +8175,10 @@ function createSseTransport(options) {
|
|
|
8254
8175
|
}
|
|
8255
8176
|
}
|
|
8256
8177
|
}
|
|
8257
|
-
function disconnect() {
|
|
8258
|
-
shouldReconnect = false;
|
|
8259
|
-
isConnected = false;
|
|
8260
|
-
stopSubscriptionRefresh();
|
|
8261
|
-
if (reconnectTimer) {
|
|
8262
|
-
clearTimeout(reconnectTimer);
|
|
8263
|
-
reconnectTimer = void 0;
|
|
8264
|
-
}
|
|
8265
|
-
if (abortController) {
|
|
8266
|
-
abortController.abort();
|
|
8267
|
-
abortController = void 0;
|
|
8268
|
-
}
|
|
8269
|
-
options.onStateChange?.("disconnected");
|
|
8270
|
-
}
|
|
8271
|
-
function subscribe(descriptor) {
|
|
8272
|
-
activeSubscriptions.set(descriptor.id, descriptor);
|
|
8273
|
-
if (isConnected) {
|
|
8274
|
-
startSubscriptionRefresh();
|
|
8275
|
-
}
|
|
8276
|
-
postMessage({ type: "subscribe", subscription: descriptor }).catch(() => {
|
|
8277
|
-
});
|
|
8278
|
-
}
|
|
8279
|
-
function unsubscribe(subscriptionId) {
|
|
8280
|
-
activeSubscriptions.delete(subscriptionId);
|
|
8281
|
-
if (activeSubscriptions.size === 0) {
|
|
8282
|
-
stopSubscriptionRefresh();
|
|
8283
|
-
}
|
|
8284
|
-
postMessage({ type: "unsubscribe", subscriptionId }).catch(() => {
|
|
8285
|
-
});
|
|
8286
|
-
}
|
|
8287
|
-
function startSubscriptionRefresh() {
|
|
8288
|
-
if (!isConnected || activeSubscriptions.size === 0 || refreshTimer) {
|
|
8289
|
-
return;
|
|
8290
|
-
}
|
|
8291
|
-
refreshTimer = setInterval(() => {
|
|
8292
|
-
syncActiveSubscriptions().catch(() => {
|
|
8293
|
-
});
|
|
8294
|
-
}, SUBSCRIPTION_REFRESH_INTERVAL_MS);
|
|
8295
|
-
}
|
|
8296
|
-
function stopSubscriptionRefresh() {
|
|
8297
|
-
if (!refreshTimer) {
|
|
8298
|
-
return;
|
|
8299
|
-
}
|
|
8300
|
-
clearInterval(refreshTimer);
|
|
8301
|
-
refreshTimer = void 0;
|
|
8302
|
-
}
|
|
8303
|
-
async function syncActiveSubscriptions(token) {
|
|
8304
|
-
if (activeSubscriptions.size === 0) {
|
|
8305
|
-
return;
|
|
8306
|
-
}
|
|
8307
|
-
const resolvedToken = token ?? await options.getToken().catch(() => void 0);
|
|
8308
|
-
if (!resolvedToken) {
|
|
8309
|
-
return;
|
|
8310
|
-
}
|
|
8311
|
-
await Promise.all(
|
|
8312
|
-
Array.from(activeSubscriptions.values()).map(
|
|
8313
|
-
(descriptor) => postMessage({ type: "subscribe", subscription: descriptor }, resolvedToken).catch(() => {
|
|
8314
|
-
})
|
|
8315
|
-
)
|
|
8316
|
-
);
|
|
8317
|
-
}
|
|
8318
|
-
async function postMessage(body, token) {
|
|
8319
|
-
const resolvedToken = token ?? await options.getToken();
|
|
8320
|
-
const url = new URL(options.url);
|
|
8321
|
-
await fetch(url.toString(), {
|
|
8322
|
-
method: "POST",
|
|
8323
|
-
headers: {
|
|
8324
|
-
Authorization: `Bearer ${resolvedToken}`,
|
|
8325
|
-
"Content-Type": "application/json"
|
|
8326
|
-
},
|
|
8327
|
-
body: JSON.stringify(body)
|
|
8328
|
-
});
|
|
8329
|
-
}
|
|
8330
8178
|
return {
|
|
8331
8179
|
connect,
|
|
8332
8180
|
disconnect,
|
|
8181
|
+
reconnect,
|
|
8333
8182
|
subscribe,
|
|
8334
8183
|
unsubscribe,
|
|
8335
8184
|
get connected() {
|
|
@@ -10240,6 +10089,8 @@ async function applyRemoteCacheEpoch(db, engine, syncPolicyUrl, getToken) {
|
|
|
10240
10089
|
function createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, getDb) {
|
|
10241
10090
|
let realEngine;
|
|
10242
10091
|
let initPromise;
|
|
10092
|
+
let activeSseTransport;
|
|
10093
|
+
let shouldKeepSyncRunning = false;
|
|
10243
10094
|
async function getEngine() {
|
|
10244
10095
|
if (realEngine) return realEngine;
|
|
10245
10096
|
if (initPromise) return initPromise;
|
|
@@ -10272,10 +10123,12 @@ function createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, ge
|
|
|
10272
10123
|
}
|
|
10273
10124
|
});
|
|
10274
10125
|
sseTransport = transport;
|
|
10126
|
+
activeSseTransport = transport;
|
|
10275
10127
|
}
|
|
10276
10128
|
realEngine = new SyncEngine({ db, httpTransport, sseTransport });
|
|
10277
10129
|
await applyRemoteCacheEpoch(db, realEngine, syncPolicyUrl, getToken);
|
|
10278
10130
|
if (sseTransport) {
|
|
10131
|
+
shouldKeepSyncRunning = true;
|
|
10279
10132
|
realEngine.startSync().catch(() => {
|
|
10280
10133
|
});
|
|
10281
10134
|
}
|
|
@@ -10321,11 +10174,19 @@ function createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, ge
|
|
|
10321
10174
|
};
|
|
10322
10175
|
lazy.startSync = async function() {
|
|
10323
10176
|
const engine = await getEngine();
|
|
10177
|
+
shouldKeepSyncRunning = true;
|
|
10324
10178
|
return engine.startSync();
|
|
10325
10179
|
};
|
|
10326
10180
|
lazy.stopSync = function() {
|
|
10181
|
+
shouldKeepSyncRunning = false;
|
|
10327
10182
|
realEngine?.stopSync();
|
|
10328
10183
|
};
|
|
10184
|
+
lazy.reconnectActiveSync = function() {
|
|
10185
|
+
if (!shouldKeepSyncRunning) {
|
|
10186
|
+
return;
|
|
10187
|
+
}
|
|
10188
|
+
activeSseTransport?.reconnect();
|
|
10189
|
+
};
|
|
10329
10190
|
lazy.processSyncEvent = async function(event) {
|
|
10330
10191
|
const engine = await getEngine();
|
|
10331
10192
|
return engine.processSyncEvent(event);
|
|
@@ -10365,7 +10226,7 @@ function createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, ge
|
|
|
10365
10226
|
var DEFAULT_UPLOAD_CONTENT_TYPE = "application/octet-stream";
|
|
10366
10227
|
var AZURE_BLOCK_BLOB_TYPE = "BlockBlob";
|
|
10367
10228
|
async function uploadFile(request, getToken, file, name, options) {
|
|
10368
|
-
const { GenerateUploadUriDocument: GenerateUploadUriDocument2 } = await import('./_generated_documents-
|
|
10229
|
+
const { GenerateUploadUriDocument: GenerateUploadUriDocument2 } = await import('./_generated_documents-AIL5TFBT.js');
|
|
10369
10230
|
const key = `upload_${Date.now()}`;
|
|
10370
10231
|
const response = await request(
|
|
10371
10232
|
GenerateUploadUriDocument2,
|
|
@@ -10514,6 +10375,7 @@ function isBrowserRuntime() {
|
|
|
10514
10375
|
var DEFAULT_BASE_URL = "api.dvina.ai";
|
|
10515
10376
|
var DB_INIT_TOKEN_POLL_INTERVAL_MS = 100;
|
|
10516
10377
|
var DB_INIT_TOKEN_TIMEOUT_MS = 15e3;
|
|
10378
|
+
var LIFECYCLE_HINT_DEBOUNCE_MS = 250;
|
|
10517
10379
|
function resolveGetToken(options) {
|
|
10518
10380
|
if ("getToken" in options && options.getToken) {
|
|
10519
10381
|
return options.getToken;
|
|
@@ -10611,6 +10473,7 @@ function createDvinaClient(options) {
|
|
|
10611
10473
|
});
|
|
10612
10474
|
}
|
|
10613
10475
|
const syncEngine = createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, getDb);
|
|
10476
|
+
const recoverableSyncEngine = syncEngine;
|
|
10614
10477
|
const request = async (document2, variables, _options) => {
|
|
10615
10478
|
return syncEngine.query(document2, variables);
|
|
10616
10479
|
};
|
|
@@ -10622,6 +10485,21 @@ function createDvinaClient(options) {
|
|
|
10622
10485
|
const billingHttpUrl = `${billingBase}/graphql`;
|
|
10623
10486
|
const billingSseUrl = `${billingBase}/subscriptions/stream`;
|
|
10624
10487
|
const billing = new BillingClient({ billingHttpUrl, billingSseUrl, getToken, onError: options.onError });
|
|
10488
|
+
let lifecycleHintTimer;
|
|
10489
|
+
const lifecycle = {
|
|
10490
|
+
hint(_reason) {
|
|
10491
|
+
if (lifecycleHintTimer) {
|
|
10492
|
+
return;
|
|
10493
|
+
}
|
|
10494
|
+
lifecycleHintTimer = setTimeout(() => {
|
|
10495
|
+
lifecycleHintTimer = void 0;
|
|
10496
|
+
recoverableSyncEngine.reconnectActiveSync();
|
|
10497
|
+
chatStream.reconnectAll();
|
|
10498
|
+
wsTransport?.terminate();
|
|
10499
|
+
billing.reconnectAll();
|
|
10500
|
+
}, LIFECYCLE_HINT_DEBOUNCE_MS);
|
|
10501
|
+
}
|
|
10502
|
+
};
|
|
10625
10503
|
return {
|
|
10626
10504
|
syncEngine,
|
|
10627
10505
|
request,
|
|
@@ -10639,6 +10517,7 @@ function createDvinaClient(options) {
|
|
|
10639
10517
|
},
|
|
10640
10518
|
inference,
|
|
10641
10519
|
billing,
|
|
10520
|
+
lifecycle,
|
|
10642
10521
|
baseUrl
|
|
10643
10522
|
};
|
|
10644
10523
|
}
|
|
@@ -13079,6 +12958,7 @@ var UsageWindowsStatusType = class extends DvinaModel {
|
|
|
13079
12958
|
var UserAiProviderSetting = class extends DvinaModel {
|
|
13080
12959
|
id;
|
|
13081
12960
|
enabled;
|
|
12961
|
+
enableParallelToolCalls;
|
|
13082
12962
|
baseUrl;
|
|
13083
12963
|
model;
|
|
13084
12964
|
createdAt;
|
|
@@ -13087,6 +12967,7 @@ var UserAiProviderSetting = class extends DvinaModel {
|
|
|
13087
12967
|
super(request, syncEngine, baseUrl);
|
|
13088
12968
|
this.id = data.id;
|
|
13089
12969
|
this.enabled = data.enabled;
|
|
12970
|
+
this.enableParallelToolCalls = data.enableParallelToolCalls;
|
|
13090
12971
|
this.baseUrl = data.baseUrl;
|
|
13091
12972
|
this.model = data.model;
|
|
13092
12973
|
this.createdAt = new Date(data.createdAt);
|
|
@@ -22132,6 +22013,8 @@ var DvinaSdk = class extends Request {
|
|
|
22132
22013
|
syncEngine;
|
|
22133
22014
|
/** Chat SSE client for chat-scoped stream listeners. */
|
|
22134
22015
|
chatStream;
|
|
22016
|
+
/** Semantic lifecycle bridge for connectivity and foreground recovery hints. */
|
|
22017
|
+
lifecycle;
|
|
22135
22018
|
_getToken;
|
|
22136
22019
|
_terminateWs;
|
|
22137
22020
|
_closeDb;
|
|
@@ -22140,10 +22023,11 @@ var DvinaSdk = class extends Request {
|
|
|
22140
22023
|
/** Billing client for the Dvina Billing API (plans, subscriptions, seats, sessions). */
|
|
22141
22024
|
billing;
|
|
22142
22025
|
constructor(options) {
|
|
22143
|
-
const { syncEngine, request, subscribe, chatStream, getToken, terminateWs, closeDb, inference, billing, baseUrl } = createDvinaClient(options);
|
|
22026
|
+
const { syncEngine, request, subscribe, chatStream, lifecycle, getToken, terminateWs, closeDb, inference, billing, baseUrl } = createDvinaClient(options);
|
|
22144
22027
|
super(request, syncEngine, subscribe, baseUrl);
|
|
22145
22028
|
this.syncEngine = syncEngine;
|
|
22146
22029
|
this.chatStream = chatStream;
|
|
22030
|
+
this.lifecycle = lifecycle;
|
|
22147
22031
|
this._getToken = getToken;
|
|
22148
22032
|
this._terminateWs = terminateWs;
|
|
22149
22033
|
this._closeDb = closeDb;
|
|
@@ -22790,5 +22674,5 @@ var DvinaSdk = class extends Request {
|
|
|
22790
22674
|
};
|
|
22791
22675
|
|
|
22792
22676
|
export { AbortChatMutation, Action, AddInsightToReportMutation, Agent, AgentConnection, AgentQuery, AgentSubBuilder, Agent_ChatsQuery, AgentsQuery, AiProviderSettingQuery, Artifact, ArtifactConnection, ArtifactQuery, ArtifactSubBuilder, Artifact_ChatQuery, Artifact_Chat_DesktopDeviceQuery, Artifact_Chat_InsightQuery, Artifact_Chat_ProjectQuery, Artifact_FileQuery, Artifact_MessageQuery, Artifact_Message_ChatQuery, Artifact_Message_ContentsQuery, Artifact_Message_FeedbackQuery, ArtifactsQuery, AudioEventOutput, CancelOauthFlowMutation, CancelWorkspaceDeletionMutation, Candidate, CandidateEvidence, Chat, ChatConnection, ChatImportExecuteOutput, ChatImportPreviewOutput, ChatMessage, ChatMessageConnection, ChatMessageQuery, ChatMessageSubBuilder, ChatMessage_ArtifactsQuery, ChatMessage_ChatQuery, ChatMessage_Chat_DesktopDeviceQuery, ChatMessage_Chat_InsightQuery, ChatMessage_Chat_ProjectQuery, ChatMessage_ContentsQuery, ChatMessage_FeedbackQuery, ChatMessagesQuery, ChatQuery, ChatSubBuilder, ChatTitleEventOutput, Chat_AgentsQuery, Chat_ArtifactsQuery, Chat_DesktopDeviceQuery, Chat_DesktopDevice_DesktopBindingsQuery, Chat_InsightQuery, Chat_Insight_ReportMembersQuery, Chat_Insight_ThumbnailFileQuery, Chat_MessagesQuery, Chat_ProjectQuery, Chat_Project_DesktopBindingQuery, ChatsQuery, ConnectIntegrationMutation, ConsumePulseEventsMutation, ContentBlock, ContentMask, ContinueImportedChatMutation, ContinueInterpretationMutation, CreateAgentMutation, CreateChatMutation, CreateDatabaseMutation, CreateDocumentMutation, CreateFeedbackMutation, CreateFolderMutation, CreateInsightMutation, CreateIntegrationMutation, CreateIntegrationOutput, CreateProjectMutation, CreateReportMutation, CreateTableMutation, CreateUserSkillFileMutation, CreateUserSkillFolderMutation, CubeModel, DB_ENTITY_SCHEMA, Database, DatabaseCatalog, DatabaseCatalogConnection, DatabaseCatalogQuery, DatabaseCatalogSubBuilder, DatabaseCatalog_EngineQuery, DatabaseCatalogsQuery, DatabaseConnection, DatabaseEngine, DatabaseQuery, DatabaseSchemaQuery, DatabaseSubBuilder, Database_EngineQuery, Database_Engine_CatalogQuery, Database_TablesQuery, DatabasesQuery, DeepAnalysisUsage, DeferredDvinaQueryRef, DeleteAgentMutation, DeleteAiProviderSettingMutation, DeleteArtifactMutation, DeleteChatMutation, DeleteDatabaseMutation, DeleteDocumentMutation, DeleteFolderMutation, DeleteInsightMutation, DeleteInsightsMutation, DeleteIntegrationMutation, DeleteProjectMutation, DeleteReportMutation, DeleteTableMutation, DeleteUserSkillFileMutation, DeleteUserSkillFolderMutation, DesktopDevice, DesktopDeviceConnection, DesktopDeviceQuery, DesktopDeviceSubBuilder, DesktopDevice_ChatsQuery, DesktopDevice_DesktopBindingsQuery, DesktopDevicesQuery, DevAccessTokenOutput, DexieLiveQueryRef, DisconnectIntegrationMutation, DismissPulseEventMutation, Document, DocumentCatalog, DocumentCatalogConnection, DocumentCatalogQuery, DocumentCatalogSubBuilder, DocumentCatalog_FormatQuery, DocumentCatalogsQuery, DocumentConnection, DocumentContent, DocumentFormat, DocumentQuery, DocumentSubBuilder, Document_ContentsQuery, Document_FileQuery, Document_FormatQuery, Document_Format_CatalogQuery, Document_TablesQuery, DocumentsQuery, DvinaDatabase, DvinaModel, DvinaSdk, Evidence, ExecuteChatImportMutation, ExportQuery, ExportWithInsightIdQuery, FailedSyncEventIngestion, FeedArtifactData, FeedConnection, FeedDatabaseData, FeedDocumentData, FeedInsightData, FeedIntegrationData, FeedItem, FeedItemGenerated, FeedItemQuery, FeedItemSubBuilder, FeedItem_ActionQuery, FeedItem_DataQuery, FeedItemsQuery, FeedLiveContextData, FeedProjectData, FeedPulseData, FeedSendMessageAction, Feedback, File, FileMetaQuery, FileModel, FileQuery, FileUrlsQuery, FinalContentEventOutput, FindFitTierQuery, Folder, FolderConnection, FolderQuery, FoldersQuery, GenerateUploadUriMutation, GetCapabilityQuery, GetDevAccessTokenQuery, GetLimitQuery, GetRemainingQuery, GetTokenUsageByModelQuery, GetTokenUsageHistoryQuery, GetTokenUsageStatusQuery, GetTokenUsageStatus_WindowsQuery, GetTokenUsageStatus_Windows_DayQuery, GetTokenUsageStatus_Windows_FiveHourQuery, GetTokenUsageStatus_Windows_MonthQuery, GetTokenUsageStatus_Windows_WeekQuery, GetUsageQuery, ImportedChatSummaryOutput, InferenceRequestAudit, Insight, InsightConnection, InsightQuery, InsightSubBuilder, Insight_ChatQuery, Insight_Chat_DesktopDeviceQuery, Insight_Chat_ProjectQuery, Insight_ReportMembersQuery, Insight_ReportsQuery, Insight_ThumbnailFileQuery, InsightsQuery, Integration, IntegrationCatalog, IntegrationCatalogConnection, IntegrationCatalogQuery, IntegrationCatalogSubBuilder, IntegrationCatalogToolsQuery, IntegrationCatalog_ProviderQuery, IntegrationCatalogsQuery, IntegrationConnection, IntegrationProvider, IntegrationQuery, IntegrationSubBuilder, Integration_ProviderQuery, Integration_Provider_CatalogQuery, IntegrationsQuery, Interpretation, InterpretationConnection, InterpretationsQuery, Invocation, LiveContext, LiveContextConnection, LiveContextQuery, LiveContextSubBuilder, LiveContext_ItemsQuery, LiveContext_SourceQuery, LiveContext_Source_EvidencesQuery, LiveContextsQuery, LocalSandboxDeviceStatusModel, LocalSandboxDeviceStatusesQuery, MUTATION_CACHE_RULES, MappedDvinaQueryRef, McpAuthUpdateModel, McpAuthUpdatesSubscription, McpClientInformation, McpCodeVerifier, McpServer, McpTokens, McpTool, MessageEndEventOutput, MessageStartEventOutput, ModelTokenUsage, Notification, NotificationConnection, NotificationQuery, NotificationsByReferenceQuery, NotificationsQuery, PRIMARY_KEY_CONFIG, PreviewChatImportMutation, PrivacyStats, PrivacyStatsQuery, ProgressSummaryEventOutput, Project, ProjectConnection, ProjectDesktopBinding, ProjectQuery, ProjectSubBuilder, Project_ChatsQuery, Project_DesktopBindingQuery, Project_DesktopBinding_DeviceQuery, ProjectsQuery, PulseAppSummaryModel, PulseAppSummaryQuery, PulseEvent, PulseEventConnection, PulseEventQuery, PulseEventSubBuilder, PulseEvent_IntegrationQuery, PulseEvent_Integration_ProviderQuery, PulseEventsQuery, PulseTriggerSettingModel, PulseTriggerSettingsQuery, QueryQuery, QueryWithInsightIdQuery, QueryWithMessageIdQuery, ReanalyzeDocumentMutation, ReasoningEventOutput, RefineAgentInstructionMutation, RefineSkillInstructionMutation, RefreshDatabaseSchemaMutation, RefreshInsightMutation, RegisterDesktopDeviceMutation, ReinterpretSourceMutation, ReinterpretSourcesOfuserMutation, Relation, RelocateInsightMutation, RemoveInsightFromReportMutation, Report, ReportConnection, ReportMember, ReportQuery, ReportSubBuilder, Report_InsightsQuery, Report_LayoutQuery, ReportsQuery, ResetWorkspaceMutation, ResolvePulseEventMutation, ResolvedFileUrl, ScheduleWorkspaceDeletionMutation, SendMessageMutation, SetDatabasePrimaryKeyMutation, StreamEventSchemaAnchor, StreamMessageContentOutput, StreamMessageOutput, SyncEngine, SyncEvent, SyncEventCursor, SyncProjectDesktopBindingMutation, TABLE_TO_TYPENAME, TYPENAME_TO_TABLE, Table, TableConnection, TableQuery, TableSubBuilder, Table_DatabaseQuery, Table_Database_EngineQuery, Table_DocumentQuery, Table_Document_ContentsQuery, Table_Document_FileQuery, Table_Document_FormatQuery, Table_FromRelationsQuery, Table_ToRelationsQuery, TablesQuery, TextBlockEventOutput, TextDeltaEventOutput, TokenUsage, TokenUsageUpdatesSubscription, ToolInputDeltaEventOutput, ToolResultArtifactOutput, ToolResultEventOutput, ToolStartEventOutput, UpdateAgentMutation, UpdateArtifactNameMutation, UpdateChatMutation, UpdateDatabaseMutation, UpdateDocumentMutation, UpdateFolderMutation, UpdateInsightInReportMutation, UpdateInsightMutation, UpdateInsightThumbnailMutation, UpdateInterpMutation, UpdateLiveContextMutation, UpdateProjectMutation, UpdatePulseTriggerMutation, UpdateReportMutation, UpdateTableMutation, UpdateUserSkillFileMutation, UpdateUserSkillFolderMutation, UpsertAiProviderSettingMutation, UsageMetaOutput, UsageStatus, UsageWindowsStatusType, UserAiProviderSetting, UserSkillFile, UserSkillFileModel, UserSkillFileQuery, UserSkillFilesQuery, UserSkillFolder, UserSkillFolderModel, UserSkillFolderQuery, UserSkillFoldersQuery, WidgetBlockCompleteEventOutput, WidgetBlockErrorEventOutput, WidgetBlockStartEventOutput, WidgetHtmlDeltaEventOutput, WindowDetailType, WorkspaceDeleteSchedule, WorkspaceDeletionScheduleQuery, closeDatabase, createChatStreamClient, createDvinaClient, createLazySyncEngine, createSseTransport, createWsTransport, deleteDatabase, getOrCreateDatabase, reconstructConnectionNodes, reconstructEntity, uploadFile };
|
|
22793
|
-
//# sourceMappingURL=chunk-
|
|
22794
|
-
//# sourceMappingURL=chunk-
|
|
22677
|
+
//# sourceMappingURL=chunk-BJDU4UX4.js.map
|
|
22678
|
+
//# sourceMappingURL=chunk-BJDU4UX4.js.map
|