@arbidocs/sdk 0.3.13 → 0.3.14

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ConfigStore, a as CliConfig, b as CliCredentials, c as ChatSession, A as AuthHeaders, U as UploadBatchResult, d as UploadOptions, e as UploadResult } from './browser-BszYf6lU.cjs';
2
- export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthenticatedClient, n as ConnectOptions, D as DocumentWaiter, o as DocumentWaiterOptions, F as FormattedWsMessage, L as LIFECYCLE_LABELS, M as MessageLevel, p as MessageMetadataPayload, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, q as ReconnectableWsConnection, r as ResponseCompletedEvent, s as ResponseContentPartAddedEvent, t as ResponseCreatedEvent, u as ResponseFailedEvent, v as ResponseOutputItemAddedEvent, w as ResponseOutputItemDoneEvent, x as ResponseOutputTextDeltaEvent, y as ResponseOutputTextDoneEvent, z as ResponseUsage, S as SSEEvent, B as SSEStreamCallbacks, E as SSEStreamResult, G as SSEStreamStartData, T as TOOL_LABELS, H as UserInfo, I as UserInputRequestEvent, J as UserMessageEvent, W as WorkspaceContext, K as WsConnection, N as agentconfig, P as assistant, V as authenticatedFetch, X as buildRetrievalChunkTool, Y as buildRetrievalFullContextTool, Z as buildRetrievalTocTool, _ as connectWebSocket, $ as connectWithReconnect, a0 as consumeSSEStream, a1 as contacts, a2 as conversations, a3 as createAuthenticatedClient, a4 as createDocumentWaiter, a5 as dm, a6 as doctags, a7 as documents, a8 as files, a9 as formatAgentStepLabel, aa as formatFileSize, ab as formatUserName, ac as formatWorkspaceChoices, ad as formatWsMessage, ae as generateEncryptedWorkspaceKey, af as getErrorCode, ag as getErrorMessage, ah as health, ai as parseSSEEvents, aj as performPasswordLogin, ak as requireData, al as requireOk, am as resolveAuth, an as resolveWorkspace, ao as selectWorkspace, ap as selectWorkspaceById, aq as settings, ar as streamSSE, as as tags, at as workspaces } from './browser-BszYf6lU.cjs';
1
+ import { C as ConfigStore, a as CliConfig, b as CliCredentials, c as ChatSession, A as AuthHeaders, U as UploadBatchResult, d as UploadOptions, e as UploadResult } from './browser-DtwXhEkG.cjs';
2
+ export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthenticatedClient, n as ConnectOptions, D as DocumentWaiter, o as DocumentWaiterOptions, F as FormattedWsMessage, L as LIFECYCLE_LABELS, M as MessageLevel, p as MessageMetadataPayload, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, q as ReconnectableWsConnection, r as ResponseCompletedEvent, s as ResponseContentPartAddedEvent, t as ResponseCreatedEvent, u as ResponseFailedEvent, v as ResponseOutputItemAddedEvent, w as ResponseOutputItemDoneEvent, x as ResponseOutputTextDeltaEvent, y as ResponseOutputTextDoneEvent, z as ResponseUsage, S as SSEEvent, B as SSEStreamCallbacks, E as SSEStreamResult, G as SSEStreamStartData, T as TOOL_LABELS, H as UserInfo, I as UserInputRequestEvent, J as UserMessageEvent, W as WorkspaceContext, K as WsConnection, N as agentconfig, P as assistant, V as authenticatedFetch, X as buildRetrievalChunkTool, Y as buildRetrievalFullContextTool, Z as buildRetrievalTocTool, _ as connectWebSocket, $ as connectWithReconnect, a0 as consumeSSEStream, a1 as contacts, a2 as conversations, a3 as createAuthenticatedClient, a4 as createDocumentWaiter, a5 as dm, a6 as doctags, a7 as documents, a8 as files, a9 as formatAgentStepLabel, aa as formatFileSize, ab as formatUserName, ac as formatWorkspaceChoices, ad as formatWsMessage, ae as generateEncryptedWorkspaceKey, af as getErrorCode, ag as getErrorMessage, ah as health, ai as parseSSEEvents, aj as performPasswordLogin, ak as requireData, al as requireOk, am as resolveAuth, an as resolveWorkspace, ao as responses, ap as selectWorkspace, aq as selectWorkspaceById, ar as settings, as as streamSSE, at as tags, au as workspaces } from './browser-DtwXhEkG.cjs';
3
3
  import '@arbidocs/client';
4
4
 
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ConfigStore, a as CliConfig, b as CliCredentials, c as ChatSession, A as AuthHeaders, U as UploadBatchResult, d as UploadOptions, e as UploadResult } from './browser-BszYf6lU.js';
2
- export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthenticatedClient, n as ConnectOptions, D as DocumentWaiter, o as DocumentWaiterOptions, F as FormattedWsMessage, L as LIFECYCLE_LABELS, M as MessageLevel, p as MessageMetadataPayload, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, q as ReconnectableWsConnection, r as ResponseCompletedEvent, s as ResponseContentPartAddedEvent, t as ResponseCreatedEvent, u as ResponseFailedEvent, v as ResponseOutputItemAddedEvent, w as ResponseOutputItemDoneEvent, x as ResponseOutputTextDeltaEvent, y as ResponseOutputTextDoneEvent, z as ResponseUsage, S as SSEEvent, B as SSEStreamCallbacks, E as SSEStreamResult, G as SSEStreamStartData, T as TOOL_LABELS, H as UserInfo, I as UserInputRequestEvent, J as UserMessageEvent, W as WorkspaceContext, K as WsConnection, N as agentconfig, P as assistant, V as authenticatedFetch, X as buildRetrievalChunkTool, Y as buildRetrievalFullContextTool, Z as buildRetrievalTocTool, _ as connectWebSocket, $ as connectWithReconnect, a0 as consumeSSEStream, a1 as contacts, a2 as conversations, a3 as createAuthenticatedClient, a4 as createDocumentWaiter, a5 as dm, a6 as doctags, a7 as documents, a8 as files, a9 as formatAgentStepLabel, aa as formatFileSize, ab as formatUserName, ac as formatWorkspaceChoices, ad as formatWsMessage, ae as generateEncryptedWorkspaceKey, af as getErrorCode, ag as getErrorMessage, ah as health, ai as parseSSEEvents, aj as performPasswordLogin, ak as requireData, al as requireOk, am as resolveAuth, an as resolveWorkspace, ao as selectWorkspace, ap as selectWorkspaceById, aq as settings, ar as streamSSE, as as tags, at as workspaces } from './browser-BszYf6lU.js';
1
+ import { C as ConfigStore, a as CliConfig, b as CliCredentials, c as ChatSession, A as AuthHeaders, U as UploadBatchResult, d as UploadOptions, e as UploadResult } from './browser-DtwXhEkG.js';
2
+ export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthenticatedClient, n as ConnectOptions, D as DocumentWaiter, o as DocumentWaiterOptions, F as FormattedWsMessage, L as LIFECYCLE_LABELS, M as MessageLevel, p as MessageMetadataPayload, O as OutputTokensDetails, Q as QueryOptions, R as ReconnectOptions, q as ReconnectableWsConnection, r as ResponseCompletedEvent, s as ResponseContentPartAddedEvent, t as ResponseCreatedEvent, u as ResponseFailedEvent, v as ResponseOutputItemAddedEvent, w as ResponseOutputItemDoneEvent, x as ResponseOutputTextDeltaEvent, y as ResponseOutputTextDoneEvent, z as ResponseUsage, S as SSEEvent, B as SSEStreamCallbacks, E as SSEStreamResult, G as SSEStreamStartData, T as TOOL_LABELS, H as UserInfo, I as UserInputRequestEvent, J as UserMessageEvent, W as WorkspaceContext, K as WsConnection, N as agentconfig, P as assistant, V as authenticatedFetch, X as buildRetrievalChunkTool, Y as buildRetrievalFullContextTool, Z as buildRetrievalTocTool, _ as connectWebSocket, $ as connectWithReconnect, a0 as consumeSSEStream, a1 as contacts, a2 as conversations, a3 as createAuthenticatedClient, a4 as createDocumentWaiter, a5 as dm, a6 as doctags, a7 as documents, a8 as files, a9 as formatAgentStepLabel, aa as formatFileSize, ab as formatUserName, ac as formatWorkspaceChoices, ad as formatWsMessage, ae as generateEncryptedWorkspaceKey, af as getErrorCode, ag as getErrorMessage, ah as health, ai as parseSSEEvents, aj as performPasswordLogin, ak as requireData, al as requireOk, am as resolveAuth, an as resolveWorkspace, ao as responses, ap as selectWorkspace, aq as selectWorkspaceById, ar as settings, as as streamSSE, at as tags, au as workspaces } from './browser-DtwXhEkG.js';
3
3
  import '@arbidocs/client';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -506,11 +506,13 @@ async function streamSSE(response, callbacks = {}) {
506
506
  let text = "";
507
507
  let assistantMessageExtId = null;
508
508
  const agentSteps = [];
509
+ let toolCallCount = 0;
509
510
  const errors = [];
510
511
  const artifacts = [];
511
512
  let userMessage = null;
512
513
  let metadata = null;
513
514
  let usage = null;
515
+ let context = null;
514
516
  const eventHandlers = {
515
517
  // OpenAI Responses API events (dot-separated names from server)
516
518
  "response.created": (raw) => {
@@ -554,6 +556,9 @@ async function streamSSE(response, callbacks = {}) {
554
556
  metadata = meta;
555
557
  callbacks.onMetadata?.(meta);
556
558
  }
559
+ if (data.context) {
560
+ context = data.context;
561
+ }
557
562
  if (data.t != null) callbacks.onElapsedTime?.(data.t);
558
563
  callbacks.onComplete?.();
559
564
  },
@@ -568,6 +573,10 @@ async function streamSSE(response, callbacks = {}) {
568
573
  const data = JSON.parse(raw);
569
574
  const label = formatAgentStepLabel(data);
570
575
  if (label) agentSteps.push(label);
576
+ const detail = data.detail;
577
+ if (detail && Array.isArray(detail)) {
578
+ toolCallCount += detail.filter((d) => d.tool).length;
579
+ }
571
580
  callbacks.onAgentStep?.(data);
572
581
  if (data.t != null) callbacks.onElapsedTime?.(data.t);
573
582
  },
@@ -618,11 +627,13 @@ async function streamSSE(response, callbacks = {}) {
618
627
  text,
619
628
  assistantMessageExtId,
620
629
  agentSteps,
630
+ toolCallCount,
621
631
  errors,
622
632
  userMessage,
623
633
  metadata,
624
634
  artifacts,
625
- usage
635
+ usage,
636
+ context
626
637
  };
627
638
  }
628
639
  var consumeSSEStream = streamSSE;
@@ -821,6 +832,13 @@ function formatWsMessage(msg) {
821
832
  if (isMessageType(msg, "presence_update")) {
822
833
  return { text: `${msg.user_id} is ${msg.status}`, level: "info" };
823
834
  }
835
+ if (isMessageType(msg, "response_complete")) {
836
+ const icon = msg.status === "completed" ? "\u2713" : "\u2717";
837
+ return {
838
+ text: `${icon} Task ${msg.response_id} ${msg.status}`,
839
+ level: msg.status === "completed" ? "success" : "error"
840
+ };
841
+ }
824
842
  if (isNotification(msg)) {
825
843
  const sender = msg.sender?.email || "someone";
826
844
  const content = msg.content ?? msg.type;
@@ -1877,6 +1895,69 @@ async function uploadZip(auth, workspaceId, zipPath) {
1877
1895
  return { doc_ext_ids: allDocIds, duplicates: allDuplicates, folders };
1878
1896
  }
1879
1897
 
1880
- export { Arbi, ArbiApiError, ArbiError, FileConfigStore, LIFECYCLE_LABELS, TOOL_LABELS, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, createAuthenticatedClient, createDocumentWaiter, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, files_exports as files, formatAgentStepLabel, formatFileSize, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, getErrorCode, getErrorMessage, health_exports as health, parseSSEEvents, performPasswordLogin, requireData, requireOk, resolveAuth, resolveWorkspace, selectWorkspace, selectWorkspaceById, settings_exports as settings, streamSSE, tags_exports as tags, workspaces_exports as workspaces };
1898
+ // src/operations/responses.ts
1899
+ var responses_exports = {};
1900
+ __export(responses_exports, {
1901
+ extractResponseText: () => extractResponseText,
1902
+ getResponse: () => getResponse,
1903
+ submitBackgroundQuery: () => submitBackgroundQuery
1904
+ });
1905
+ async function submitBackgroundQuery(options) {
1906
+ const { workspaceId, question, docIds, previousResponseId, model, ...auth } = options;
1907
+ const tools = {};
1908
+ if (docIds.length > 0) {
1909
+ tools.retrieval_chunk = {
1910
+ name: "retrieval_chunk",
1911
+ description: "retrieval chunk",
1912
+ tool_args: { doc_ext_ids: docIds },
1913
+ tool_responses: {}
1914
+ };
1915
+ tools.retrieval_full_context = {
1916
+ name: "retrieval_full_context",
1917
+ description: "retrieval full context",
1918
+ tool_args: { doc_ext_ids: [] },
1919
+ tool_responses: {}
1920
+ };
1921
+ }
1922
+ const body = {
1923
+ input: question,
1924
+ workspace_ext_id: workspaceId,
1925
+ stream: false,
1926
+ background: true,
1927
+ store: true,
1928
+ tools,
1929
+ ...previousResponseId ? { previous_response_id: previousResponseId } : {},
1930
+ ...model ? { model } : {}
1931
+ };
1932
+ const res = await authenticatedFetch({
1933
+ ...auth,
1934
+ path: "/v1/responses",
1935
+ method: "POST",
1936
+ body: JSON.stringify(body),
1937
+ headers: { "Content-Type": "application/json" }
1938
+ });
1939
+ return await res.json();
1940
+ }
1941
+ async function getResponse(auth, responseId) {
1942
+ const res = await authenticatedFetch({
1943
+ ...auth,
1944
+ path: `/v1/responses/${responseId}`,
1945
+ method: "GET"
1946
+ });
1947
+ return await res.json();
1948
+ }
1949
+ function extractResponseText(response) {
1950
+ const parts = [];
1951
+ for (const msg of response.output) {
1952
+ for (const item of msg.content) {
1953
+ if ("type" in item && item.type === "output_text" && "text" in item) {
1954
+ parts.push(item.text);
1955
+ }
1956
+ }
1957
+ }
1958
+ return parts.join("");
1959
+ }
1960
+
1961
+ export { Arbi, ArbiApiError, ArbiError, FileConfigStore, LIFECYCLE_LABELS, TOOL_LABELS, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, createAuthenticatedClient, createDocumentWaiter, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, files_exports as files, formatAgentStepLabel, formatFileSize, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, getErrorCode, getErrorMessage, health_exports as health, parseSSEEvents, performPasswordLogin, requireData, requireOk, resolveAuth, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, settings_exports as settings, streamSSE, tags_exports as tags, workspaces_exports as workspaces };
1881
1962
  //# sourceMappingURL=index.js.map
1882
1963
  //# sourceMappingURL=index.js.map