@arbidocs/sdk 0.3.109 → 0.3.110

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.
@@ -1,2 +1,2 @@
1
- export { A as AgentStepDeltaEvent, a as AgentStepEvent, b as Arbi, c as ArbiApiError, d as ArbiError, e as ArbiErrorEvent, f as ArbiOptions, g as ArtifactEvent, h as AuthContext, i as AuthHeaders, j as AuthenticatedClient, C as ChatSession, k as CitationSummary, l as CliConfig, m as CliCredentials, n as ConfigStore, o as ConnectOptions, p as CreateMemoryRequest, q as CreateTaskRequest, M as MemoryResponse, y as MemorySearchRequest, z as MemorySearchResponse, E as MessageMetadataPayload, G as MessageQueuedEvent, O as OutputTokensDetails, P as ParsedSlashCommand, Q as QueryOptions, R as ReconnectOptions, H as ReconnectableWsConnection, I as ResolvedCitation, J as ResponseCompletedEvent, K as ResponseContentPartAddedEvent, N as ResponseCreatedEvent, S as ResponseFailedEvent, T as ResponseOutputItemAddedEvent, U as ResponseOutputItemDoneEvent, V as ResponseOutputTextDeltaEvent, W as ResponseOutputTextDoneEvent, X as ResponseUsage, Y as SSEEvent, Z as SSEStreamCallbacks, _ as SSEStreamResult, $ as SSEStreamStartData, a1 as SkillSummary, a3 as TaskResponse, a4 as UpdateMemoryRequest, a5 as UpdateTaskRequest, ab as UserInfo, ac as UserInputRequestEvent, ad as UserMessageEvent, ae as WebSocketAuthError, af as WorkspaceContext, ag as WsConnection, ah as agentconfig, ai as assistant, aj as authenticatedFetch, ak as buildRetrievalChunkTool, al as buildRetrievalFullContextTool, am as buildRetrievalTocTool, an as connectWebSocket, ao as connectWithReconnect, ap as consumeSSEStream, aq as contacts, ar as conversations, as as countCitations, at as createAuthenticatedClient, av as dm, aw as doctags, ax as documents, ay as files, az as filterSkills, aA as formatAgentStepLabel, aB as formatFileSize, aD as formatUserName, aE as formatWorkspaceChoices, aJ as getErrorMessage, aK as getRawWorkspaceKey, aL as health, aM as memory, aN as parseSSEEvents, aO as parseSlashCommand, aP as parseSlashTokenInProgress, aQ as performPasswordLogin, aT as requireData, aU as requireOk, aV as resolveAuth, aW as resolveCitations, aX as resolveWorkspace, aY as responses, aZ as selectWorkspace, a_ as selectWorkspaceById, a$ as settings, b0 as streamSSE, b1 as stripCitationMarkdown, b2 as summarizeCitations, b3 as tags, b4 as tasks, b5 as workspaces } from './browser-C4gqnXaX.cjs';
1
+ export { A as AgentStepDeltaEvent, a as AgentStepEvent, b as Arbi, c as ArbiApiError, d as ArbiError, e as ArbiErrorEvent, f as ArbiOptions, g as ArtifactEvent, h as AuthContext, i as AuthHeaders, j as AuthenticatedClient, C as ChatSession, k as CitationSummary, l as CliConfig, m as CliCredentials, n as ConfigStore, o as ConnectOptions, p as CreateMemoryRequest, q as CreateTaskRequest, M as MemoryResponse, y as MemorySearchRequest, z as MemorySearchResponse, E as MessageMetadataPayload, G as MessageQueuedEvent, O as OutputTokensDetails, P as ParsedSlashCommand, Q as QueryOptions, R as ReconnectOptions, H as ReconnectableWsConnection, I as ResolvedCitation, J as ResponseCompletedEvent, K as ResponseContentPartAddedEvent, N as ResponseCreatedEvent, S as ResponseFailedEvent, T as ResponseOutputItemAddedEvent, U as ResponseOutputItemDoneEvent, V as ResponseOutputTextDeltaEvent, W as ResponseOutputTextDoneEvent, X as ResponseUsage, Y as SSEEvent, Z as SSEStreamCallbacks, _ as SSEStreamResult, $ as SSEStreamStartData, a1 as SkillSummary, a3 as TaskResponse, a4 as UpdateMemoryRequest, a5 as UpdateTaskRequest, ab as UserInfo, ac as UserInputRequestEvent, ad as UserMessageEvent, ae as WebSocketAuthError, af as WorkspaceContext, ag as WsConnection, ah as agentconfig, ai as assistant, aj as authenticatedFetch, ak as buildRetrievalChunkTool, al as buildRetrievalFullContextTool, am as buildRetrievalTocTool, an as connectWebSocket, ao as connectWithReconnect, ap as consumeSSEStream, aq as contacts, ar as conversations, as as countCitations, at as createAuthenticatedClient, av as dm, aw as doctags, ax as documents, ay as files, az as filterSkills, aA as formatAgentStepLabel, aB as formatFileSize, aD as formatUserName, aE as formatWorkspaceChoices, aJ as getErrorMessage, aK as getRawWorkspaceKey, aL as health, aM as memory, aN as parseSSEEvents, aO as parseSlashCommand, aP as parseSlashTokenInProgress, aQ as performPasswordLogin, aT as requireData, aU as requireOk, aV as resolveAuth, aW as resolveCitations, aX as resolveWorkspace, aY as responses, aZ as selectWorkspace, a_ as selectWorkspaceById, a$ as settings, b0 as streamSSE, b1 as stripCitationMarkdown, b2 as summarizeCitations, b3 as tags, b4 as tasks, b5 as workspaces } from './browser-DgApY8QV.cjs';
2
2
  import '@arbidocs/client';
package/dist/browser.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as AgentStepDeltaEvent, a as AgentStepEvent, b as Arbi, c as ArbiApiError, d as ArbiError, e as ArbiErrorEvent, f as ArbiOptions, g as ArtifactEvent, h as AuthContext, i as AuthHeaders, j as AuthenticatedClient, C as ChatSession, k as CitationSummary, l as CliConfig, m as CliCredentials, n as ConfigStore, o as ConnectOptions, p as CreateMemoryRequest, q as CreateTaskRequest, M as MemoryResponse, y as MemorySearchRequest, z as MemorySearchResponse, E as MessageMetadataPayload, G as MessageQueuedEvent, O as OutputTokensDetails, P as ParsedSlashCommand, Q as QueryOptions, R as ReconnectOptions, H as ReconnectableWsConnection, I as ResolvedCitation, J as ResponseCompletedEvent, K as ResponseContentPartAddedEvent, N as ResponseCreatedEvent, S as ResponseFailedEvent, T as ResponseOutputItemAddedEvent, U as ResponseOutputItemDoneEvent, V as ResponseOutputTextDeltaEvent, W as ResponseOutputTextDoneEvent, X as ResponseUsage, Y as SSEEvent, Z as SSEStreamCallbacks, _ as SSEStreamResult, $ as SSEStreamStartData, a1 as SkillSummary, a3 as TaskResponse, a4 as UpdateMemoryRequest, a5 as UpdateTaskRequest, ab as UserInfo, ac as UserInputRequestEvent, ad as UserMessageEvent, ae as WebSocketAuthError, af as WorkspaceContext, ag as WsConnection, ah as agentconfig, ai as assistant, aj as authenticatedFetch, ak as buildRetrievalChunkTool, al as buildRetrievalFullContextTool, am as buildRetrievalTocTool, an as connectWebSocket, ao as connectWithReconnect, ap as consumeSSEStream, aq as contacts, ar as conversations, as as countCitations, at as createAuthenticatedClient, av as dm, aw as doctags, ax as documents, ay as files, az as filterSkills, aA as formatAgentStepLabel, aB as formatFileSize, aD as formatUserName, aE as formatWorkspaceChoices, aJ as getErrorMessage, aK as getRawWorkspaceKey, aL as health, aM as memory, aN as parseSSEEvents, aO as parseSlashCommand, aP as parseSlashTokenInProgress, aQ as performPasswordLogin, aT as requireData, aU as requireOk, aV as resolveAuth, aW as resolveCitations, aX as resolveWorkspace, aY as responses, aZ as selectWorkspace, a_ as selectWorkspaceById, a$ as settings, b0 as streamSSE, b1 as stripCitationMarkdown, b2 as summarizeCitations, b3 as tags, b4 as tasks, b5 as workspaces } from './browser-C4gqnXaX.js';
1
+ export { A as AgentStepDeltaEvent, a as AgentStepEvent, b as Arbi, c as ArbiApiError, d as ArbiError, e as ArbiErrorEvent, f as ArbiOptions, g as ArtifactEvent, h as AuthContext, i as AuthHeaders, j as AuthenticatedClient, C as ChatSession, k as CitationSummary, l as CliConfig, m as CliCredentials, n as ConfigStore, o as ConnectOptions, p as CreateMemoryRequest, q as CreateTaskRequest, M as MemoryResponse, y as MemorySearchRequest, z as MemorySearchResponse, E as MessageMetadataPayload, G as MessageQueuedEvent, O as OutputTokensDetails, P as ParsedSlashCommand, Q as QueryOptions, R as ReconnectOptions, H as ReconnectableWsConnection, I as ResolvedCitation, J as ResponseCompletedEvent, K as ResponseContentPartAddedEvent, N as ResponseCreatedEvent, S as ResponseFailedEvent, T as ResponseOutputItemAddedEvent, U as ResponseOutputItemDoneEvent, V as ResponseOutputTextDeltaEvent, W as ResponseOutputTextDoneEvent, X as ResponseUsage, Y as SSEEvent, Z as SSEStreamCallbacks, _ as SSEStreamResult, $ as SSEStreamStartData, a1 as SkillSummary, a3 as TaskResponse, a4 as UpdateMemoryRequest, a5 as UpdateTaskRequest, ab as UserInfo, ac as UserInputRequestEvent, ad as UserMessageEvent, ae as WebSocketAuthError, af as WorkspaceContext, ag as WsConnection, ah as agentconfig, ai as assistant, aj as authenticatedFetch, ak as buildRetrievalChunkTool, al as buildRetrievalFullContextTool, am as buildRetrievalTocTool, an as connectWebSocket, ao as connectWithReconnect, ap as consumeSSEStream, aq as contacts, ar as conversations, as as countCitations, at as createAuthenticatedClient, av as dm, aw as doctags, ax as documents, ay as files, az as filterSkills, aA as formatAgentStepLabel, aB as formatFileSize, aD as formatUserName, aE as formatWorkspaceChoices, aJ as getErrorMessage, aK as getRawWorkspaceKey, aL as health, aM as memory, aN as parseSSEEvents, aO as parseSlashCommand, aP as parseSlashTokenInProgress, aQ as performPasswordLogin, aT as requireData, aU as requireOk, aV as resolveAuth, aW as resolveCitations, aX as resolveWorkspace, aY as responses, aZ as selectWorkspace, a_ as selectWorkspaceById, a$ as settings, b0 as streamSSE, b1 as stripCitationMarkdown, b2 as summarizeCitations, b3 as tags, b4 as tasks, b5 as workspaces } from './browser-DgApY8QV.js';
2
2
  import '@arbidocs/client';
package/dist/browser.js CHANGED
@@ -4040,7 +4040,7 @@ var WebSocketAuthError = class extends Error {
4040
4040
  }
4041
4041
  };
4042
4042
  function connectWebSocket(options) {
4043
- const { baseUrl, accessToken, onMessage, onClose } = options;
4043
+ const { baseUrl, accessToken, onMessage, onClose, onAuthenticated } = options;
4044
4044
  const url = buildWebSocketUrl(baseUrl);
4045
4045
  return new Promise((resolve, reject) => {
4046
4046
  const ws = new WebSocket(url);
@@ -4063,6 +4063,7 @@ function connectWebSocket(options) {
4063
4063
  clearTimeout(timeout);
4064
4064
  if (msg.success) {
4065
4065
  authenticated = true;
4066
+ onAuthenticated?.(msg);
4066
4067
  resolve({ close: () => ws.close() });
4067
4068
  } else {
4068
4069
  ws.close();
@@ -4096,6 +4097,8 @@ async function connectWithReconnect(options) {
4096
4097
  onReconnectFailed,
4097
4098
  onClose,
4098
4099
  onMessage,
4100
+ onAuthenticated,
4101
+ shouldReconnect,
4099
4102
  baseUrl,
4100
4103
  accessToken
4101
4104
  } = options;
@@ -4110,10 +4113,11 @@ async function connectWithReconnect(options) {
4110
4113
  baseUrl,
4111
4114
  accessToken: token,
4112
4115
  onMessage,
4116
+ onAuthenticated,
4113
4117
  onClose: (code, reason) => {
4114
4118
  currentConnection = null;
4115
4119
  onClose?.(code, reason);
4116
- if (!closed) void scheduleReconnect();
4120
+ if (!closed && (shouldReconnect?.(code, reason) ?? true)) void scheduleReconnect();
4117
4121
  }
4118
4122
  });
4119
4123
  };
@@ -4144,7 +4148,14 @@ async function connectWithReconnect(options) {
4144
4148
  }
4145
4149
  if (!closed) onReconnectFailed?.();
4146
4150
  };
4147
- currentConnection = await connectOnce();
4151
+ try {
4152
+ currentConnection = await connectOnce();
4153
+ } catch (err) {
4154
+ if (!(err instanceof WebSocketAuthError) || !refreshAuth) throw err;
4155
+ await refreshAuth().catch(() => {
4156
+ });
4157
+ currentConnection = await connectOnce();
4158
+ }
4148
4159
  return {
4149
4160
  close: () => {
4150
4161
  closed = true;
@@ -5553,6 +5564,19 @@ var Arbi = class {
5553
5564
  get hasWorkspace() {
5554
5565
  return this.currentWorkspaceId !== null;
5555
5566
  }
5567
+ /**
5568
+ * Live connection info for opening a raw transport (e.g. a WebSocket).
5569
+ *
5570
+ * Reads the access token from the session on each call, so a token refreshed
5571
+ * elsewhere is reflected on the next (re)connect. Returns `null` when there is
5572
+ * no client/token yet (not logged in) rather than throwing, so callers can
5573
+ * poll for readiness instead of guarding against exceptions.
5574
+ */
5575
+ getConnectionInfo() {
5576
+ const accessToken = this.client?.session.getState().accessToken;
5577
+ if (!accessToken) return null;
5578
+ return { baseUrl: this.options.url, accessToken };
5579
+ }
5556
5580
  // ── Auth headers (for raw fetch operations) ───────────────────────────
5557
5581
  getAuthHeaders() {
5558
5582
  const client = this.requireClient();