@arbidocs/sdk 0.3.78 → 0.3.80

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 AgentStepEvent, a as Arbi, b as ArbiApiError, c as ArbiError, d as ArbiErrorEvent, e as ArbiOptions, f as ArtifactEvent, g as AuthContext, h as AuthHeaders, i as AuthenticatedClient, C as ChatSession, j as CitationSummary, k as CliConfig, l as CliCredentials, m as ConfigStore, n as ConnectOptions, u as MessageMetadataPayload, v as MessageQueuedEvent, O as OutputTokensDetails, P as ParsedSlashCommand, Q as QueryOptions, R as ReconnectOptions, w as ReconnectableWsConnection, x as ResolvedCitation, y as ResponseCompletedEvent, z as ResponseContentPartAddedEvent, B as ResponseCreatedEvent, E as ResponseFailedEvent, G as ResponseOutputItemAddedEvent, H as ResponseOutputItemDoneEvent, I as ResponseOutputTextDeltaEvent, J as ResponseOutputTextDoneEvent, K as ResponseUsage, S as SSEEvent, N as SSEStreamCallbacks, T as SSEStreamResult, U as SSEStreamStartData, W as SkillSummary, a1 as UserInfo, a2 as UserInputRequestEvent, a3 as UserMessageEvent, a4 as WebSocketAuthError, a5 as WorkspaceContext, a6 as WsConnection, a7 as agentconfig, a8 as assistant, a9 as authenticatedFetch, aa as buildRetrievalChunkTool, ab as buildRetrievalFullContextTool, ac as buildRetrievalTocTool, ad as connectWebSocket, ae as connectWithReconnect, af as consumeSSEStream, ag as contacts, ah as conversations, ai as countCitations, aj as createAuthenticatedClient, al as dm, am as doctags, an as documents, ao as files, ap as filterSkills, aq as formatAgentStepLabel, ar as formatFileSize, at as formatUserName, au as formatWorkspaceChoices, az as getErrorMessage, aA as getRawWorkspaceKey, aB as health, aC as parseSSEEvents, aD as parseSlashCommand, aE as parseSlashTokenInProgress, aF as performPasswordLogin, aI as requireData, aJ as requireOk, aK as resolveAuth, aL as resolveCitations, aM as resolveWorkspace, aN as responses, aO as selectWorkspace, aP as selectWorkspaceById, aQ as settings, aR as streamSSE, aS as stripCitationMarkdown, aT as summarizeCitations, aU as tags, aV as workspaces } from './browser-CgUpQbyw.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, w as MessageMetadataPayload, x as MessageQueuedEvent, O as OutputTokensDetails, P as ParsedSlashCommand, Q as QueryOptions, R as ReconnectOptions, y as ReconnectableWsConnection, z as ResolvedCitation, B as ResponseCompletedEvent, E as ResponseContentPartAddedEvent, G as ResponseCreatedEvent, H as ResponseFailedEvent, I as ResponseOutputItemAddedEvent, J as ResponseOutputItemDoneEvent, K as ResponseOutputTextDeltaEvent, N as ResponseOutputTextDoneEvent, S as ResponseUsage, T as SSEEvent, U as SSEStreamCallbacks, V as SSEStreamResult, W as SSEStreamStartData, Y as SkillSummary, a3 as UserInfo, a4 as UserInputRequestEvent, a5 as UserMessageEvent, a6 as WebSocketAuthError, a7 as WorkspaceContext, a8 as WsConnection, a9 as agentconfig, aa as assistant, ab as authenticatedFetch, ac as buildRetrievalChunkTool, ad as buildRetrievalFullContextTool, ae as buildRetrievalTocTool, af as connectWebSocket, ag as connectWithReconnect, ah as consumeSSEStream, ai as contacts, aj as conversations, ak as countCitations, al as createAuthenticatedClient, an as dm, ao as doctags, ap as documents, aq as files, ar as filterSkills, as as formatAgentStepLabel, at as formatFileSize, av as formatUserName, aw as formatWorkspaceChoices, aB as getErrorMessage, aC as getRawWorkspaceKey, aD as health, aE as parseSSEEvents, aF as parseSlashCommand, aG as parseSlashTokenInProgress, aH as performPasswordLogin, aK as requireData, aL as requireOk, aM as resolveAuth, aN as resolveCitations, aO as resolveWorkspace, aP as responses, aQ as selectWorkspace, aR as selectWorkspaceById, aS as settings, aT as streamSSE, aU as stripCitationMarkdown, aV as summarizeCitations, aW as tags, aX as workspaces } from './browser-DIO4_N2g.cjs';
2
2
  import '@arbidocs/client';
package/dist/browser.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as AgentStepEvent, a as Arbi, b as ArbiApiError, c as ArbiError, d as ArbiErrorEvent, e as ArbiOptions, f as ArtifactEvent, g as AuthContext, h as AuthHeaders, i as AuthenticatedClient, C as ChatSession, j as CitationSummary, k as CliConfig, l as CliCredentials, m as ConfigStore, n as ConnectOptions, u as MessageMetadataPayload, v as MessageQueuedEvent, O as OutputTokensDetails, P as ParsedSlashCommand, Q as QueryOptions, R as ReconnectOptions, w as ReconnectableWsConnection, x as ResolvedCitation, y as ResponseCompletedEvent, z as ResponseContentPartAddedEvent, B as ResponseCreatedEvent, E as ResponseFailedEvent, G as ResponseOutputItemAddedEvent, H as ResponseOutputItemDoneEvent, I as ResponseOutputTextDeltaEvent, J as ResponseOutputTextDoneEvent, K as ResponseUsage, S as SSEEvent, N as SSEStreamCallbacks, T as SSEStreamResult, U as SSEStreamStartData, W as SkillSummary, a1 as UserInfo, a2 as UserInputRequestEvent, a3 as UserMessageEvent, a4 as WebSocketAuthError, a5 as WorkspaceContext, a6 as WsConnection, a7 as agentconfig, a8 as assistant, a9 as authenticatedFetch, aa as buildRetrievalChunkTool, ab as buildRetrievalFullContextTool, ac as buildRetrievalTocTool, ad as connectWebSocket, ae as connectWithReconnect, af as consumeSSEStream, ag as contacts, ah as conversations, ai as countCitations, aj as createAuthenticatedClient, al as dm, am as doctags, an as documents, ao as files, ap as filterSkills, aq as formatAgentStepLabel, ar as formatFileSize, at as formatUserName, au as formatWorkspaceChoices, az as getErrorMessage, aA as getRawWorkspaceKey, aB as health, aC as parseSSEEvents, aD as parseSlashCommand, aE as parseSlashTokenInProgress, aF as performPasswordLogin, aI as requireData, aJ as requireOk, aK as resolveAuth, aL as resolveCitations, aM as resolveWorkspace, aN as responses, aO as selectWorkspace, aP as selectWorkspaceById, aQ as settings, aR as streamSSE, aS as stripCitationMarkdown, aT as summarizeCitations, aU as tags, aV as workspaces } from './browser-CgUpQbyw.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, w as MessageMetadataPayload, x as MessageQueuedEvent, O as OutputTokensDetails, P as ParsedSlashCommand, Q as QueryOptions, R as ReconnectOptions, y as ReconnectableWsConnection, z as ResolvedCitation, B as ResponseCompletedEvent, E as ResponseContentPartAddedEvent, G as ResponseCreatedEvent, H as ResponseFailedEvent, I as ResponseOutputItemAddedEvent, J as ResponseOutputItemDoneEvent, K as ResponseOutputTextDeltaEvent, N as ResponseOutputTextDoneEvent, S as ResponseUsage, T as SSEEvent, U as SSEStreamCallbacks, V as SSEStreamResult, W as SSEStreamStartData, Y as SkillSummary, a3 as UserInfo, a4 as UserInputRequestEvent, a5 as UserMessageEvent, a6 as WebSocketAuthError, a7 as WorkspaceContext, a8 as WsConnection, a9 as agentconfig, aa as assistant, ab as authenticatedFetch, ac as buildRetrievalChunkTool, ad as buildRetrievalFullContextTool, ae as buildRetrievalTocTool, af as connectWebSocket, ag as connectWithReconnect, ah as consumeSSEStream, ai as contacts, aj as conversations, ak as countCitations, al as createAuthenticatedClient, an as dm, ao as doctags, ap as documents, aq as files, ar as filterSkills, as as formatAgentStepLabel, at as formatFileSize, av as formatUserName, aw as formatWorkspaceChoices, aB as getErrorMessage, aC as getRawWorkspaceKey, aD as health, aE as parseSSEEvents, aF as parseSlashCommand, aG as parseSlashTokenInProgress, aH as performPasswordLogin, aK as requireData, aL as requireOk, aM as resolveAuth, aN as resolveCitations, aO as resolveWorkspace, aP as responses, aQ as selectWorkspace, aR as selectWorkspaceById, aS as settings, aT as streamSSE, aU as stripCitationMarkdown, aV as summarizeCitations, aW as tags, aX as workspaces } from './browser-DIO4_N2g.js';
2
2
  import '@arbidocs/client';
package/dist/browser.js CHANGED
@@ -3784,26 +3784,66 @@ async function resolveWorkspace(store, workspaceOpt) {
3784
3784
 
3785
3785
  // src/sse.ts
3786
3786
  var LIFECYCLE_LABELS_FALLBACK = {
3787
+ goal: "Thinking\u2026",
3787
3788
  evaluation: "Evaluating results",
3788
- answering: "Writing answer",
3789
+ answering: "Answered",
3789
3790
  reviewing: "Reviewing answer",
3790
3791
  planning: "Planning",
3791
3792
  tool_progress: "Working"
3792
3793
  };
3793
- function formatAgentStepLabel(step) {
3794
- if (step.focus) return step.focus;
3795
- if (step.label) return step.label;
3794
+ function resolveDocRefs(text, docNames) {
3795
+ if (!docNames) return text;
3796
+ return text.replace(/\{(doc-[^}]+)\}/g, (_match, id) => docNames[id] ?? id);
3797
+ }
3798
+ function resolveStepDocName(step, docNames) {
3799
+ if (!docNames) return void 0;
3800
+ const detail = step.detail;
3801
+ if (!detail || detail.length === 0) return void 0;
3802
+ for (const d2 of detail) {
3803
+ const id = d2.doc_ext_id ?? d2.document_ext_id;
3804
+ if (typeof id === "string") return docNames[id] ?? id;
3805
+ }
3806
+ return void 0;
3807
+ }
3808
+ function extractPageRange(step) {
3809
+ const detail = step.detail;
3810
+ if (!detail || detail.length === 0) return void 0;
3811
+ for (const d2 of detail) {
3812
+ const summary = typeof d2.summary === "string" ? d2.summary : void 0;
3813
+ if (!summary) continue;
3814
+ const match = summary.match(/\bpp?\.\s*(\d[\d.,\s–—-]*)/);
3815
+ if (!match) continue;
3816
+ const floored = match[1].replace(/\d+(?:\.\d+)?/g, (n2) => String(Math.floor(parseFloat(n2)))).replace(/(\d+)\s*[–—-]\s*\1(?!\d)/g, "$1");
3817
+ const items = [];
3818
+ for (const raw of floored.split(",")) {
3819
+ const item = raw.trim();
3820
+ if (item && !items.includes(item)) items.push(item);
3821
+ }
3822
+ if (items.length > 0) return `pp. ${items.join(", ")}`;
3823
+ }
3824
+ return void 0;
3825
+ }
3826
+ function formatAgentStepLabel(step, docNames) {
3827
+ if (step.step === "goal") {
3828
+ return step.label && step.label !== "Goal" ? step.label : "Thinking\u2026";
3829
+ }
3830
+ if (step.focus) return resolveDocRefs(step.focus, docNames);
3831
+ const docName = resolveStepDocName(step, docNames);
3832
+ const pages = docName ? extractPageRange(step) : void 0;
3833
+ const suffix = docName ? ` \u2014 ${docName}${pages ? ` \xB7 ${pages}` : ""}` : "";
3834
+ if (step.label) return `${step.label}${suffix}`;
3796
3835
  const detail = step.detail;
3797
3836
  if (step.step === "tool_progress" && detail && detail.length > 0) {
3798
3837
  const label = detail[0].label || LIFECYCLE_LABELS_FALLBACK.tool_progress;
3838
+ if (suffix) return `${label}${suffix}`;
3799
3839
  const message = detail[0].message;
3800
- return message ? `${label}: ${message}` : label;
3840
+ return message ? `${label}: ${resolveDocRefs(message, docNames)}` : label;
3801
3841
  }
3802
3842
  if (step.step) {
3803
3843
  return LIFECYCLE_LABELS_FALLBACK[step.step] || step.step;
3804
3844
  }
3805
3845
  if (detail && detail.length > 0) {
3806
- if (detail[0].label) return detail[0].label;
3846
+ if (detail[0].label) return `${detail[0].label}${suffix}`;
3807
3847
  if (detail[0].tool) return detail[0].tool;
3808
3848
  }
3809
3849
  return "";
@@ -3917,6 +3957,11 @@ async function streamSSE(response, callbacks = {}) {
3917
3957
  callbacks.onAgentStep?.(data);
3918
3958
  if (data.t != null) callbacks.onElapsedTime?.(data.t);
3919
3959
  },
3960
+ "arbi.agent_step_delta": (raw) => {
3961
+ const data = JSON.parse(raw);
3962
+ callbacks.onAgentStepDelta?.(data);
3963
+ if (data.t != null) callbacks.onElapsedTime?.(data.t);
3964
+ },
3920
3965
  "arbi.user_message": (raw) => {
3921
3966
  const data = JSON.parse(raw);
3922
3967
  userMessage = data;
@@ -3942,16 +3987,21 @@ async function streamSSE(response, callbacks = {}) {
3942
3987
  errors.push(message);
3943
3988
  callbacks.onArbiError?.(data);
3944
3989
  callbacks.onError?.(message);
3945
- },
3946
- "response.complete": () => {
3947
- callbacks.onComplete?.();
3948
3990
  }
3949
3991
  };
3950
3992
  const processEvents = (events) => {
3951
3993
  for (const { event, data } of events) {
3952
3994
  try {
3995
+ if (event === "reasoning") {
3996
+ callbacks.onReasoningDelta?.(data);
3997
+ continue;
3998
+ }
3953
3999
  const handler = eventHandlers[event];
3954
- if (handler) handler(data);
4000
+ if (handler) {
4001
+ handler(data);
4002
+ } else {
4003
+ console.warn(`[arbi-sse] unhandled SSE event: ${event}`);
4004
+ }
3955
4005
  } catch {
3956
4006
  }
3957
4007
  }