@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.
@@ -1,2 +1,2 @@
1
- export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, A as AuthHeaders, m as AuthenticatedClient, c as ChatSession, a as CliConfig, b as CliCredentials, C as ConfigStore, n as ConnectOptions, L as LIFECYCLE_LABELS, 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, a5 as dm, a6 as doctags, a7 as documents, a8 as files, a9 as formatAgentStepLabel, aa as formatFileSize, ab as formatUserName, ac as formatWorkspaceChoices, 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
+ export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, A as AuthHeaders, m as AuthenticatedClient, c as ChatSession, a as CliConfig, b as CliCredentials, C as ConfigStore, n as ConnectOptions, L as LIFECYCLE_LABELS, 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, a5 as dm, a6 as doctags, a7 as documents, a8 as files, a9 as formatAgentStepLabel, aa as formatFileSize, ab as formatUserName, ac as formatWorkspaceChoices, 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';
2
2
  import '@arbidocs/client';
package/dist/browser.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, A as AuthHeaders, m as AuthenticatedClient, c as ChatSession, a as CliConfig, b as CliCredentials, C as ConfigStore, n as ConnectOptions, L as LIFECYCLE_LABELS, 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, a5 as dm, a6 as doctags, a7 as documents, a8 as files, a9 as formatAgentStepLabel, aa as formatFileSize, ab as formatUserName, ac as formatWorkspaceChoices, 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
+ export { f as AgentStepEvent, g as Arbi, h as ArbiApiError, i as ArbiError, j as ArbiOptions, k as ArtifactEvent, l as AuthContext, A as AuthHeaders, m as AuthenticatedClient, c as ChatSession, a as CliConfig, b as CliCredentials, C as ConfigStore, n as ConnectOptions, L as LIFECYCLE_LABELS, 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, a5 as dm, a6 as doctags, a7 as documents, a8 as files, a9 as formatAgentStepLabel, aa as formatFileSize, ab as formatUserName, ac as formatWorkspaceChoices, 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';
2
2
  import '@arbidocs/client';
package/dist/browser.js CHANGED
@@ -324,11 +324,13 @@ async function streamSSE(response, callbacks = {}) {
324
324
  let text = "";
325
325
  let assistantMessageExtId = null;
326
326
  const agentSteps = [];
327
+ let toolCallCount = 0;
327
328
  const errors = [];
328
329
  const artifacts = [];
329
330
  let userMessage = null;
330
331
  let metadata = null;
331
332
  let usage = null;
333
+ let context = null;
332
334
  const eventHandlers = {
333
335
  // OpenAI Responses API events (dot-separated names from server)
334
336
  "response.created": (raw) => {
@@ -372,6 +374,9 @@ async function streamSSE(response, callbacks = {}) {
372
374
  metadata = meta;
373
375
  callbacks.onMetadata?.(meta);
374
376
  }
377
+ if (data.context) {
378
+ context = data.context;
379
+ }
375
380
  if (data.t != null) callbacks.onElapsedTime?.(data.t);
376
381
  callbacks.onComplete?.();
377
382
  },
@@ -386,6 +391,10 @@ async function streamSSE(response, callbacks = {}) {
386
391
  const data = JSON.parse(raw);
387
392
  const label = formatAgentStepLabel(data);
388
393
  if (label) agentSteps.push(label);
394
+ const detail = data.detail;
395
+ if (detail && Array.isArray(detail)) {
396
+ toolCallCount += detail.filter((d) => d.tool).length;
397
+ }
389
398
  callbacks.onAgentStep?.(data);
390
399
  if (data.t != null) callbacks.onElapsedTime?.(data.t);
391
400
  },
@@ -436,11 +445,13 @@ async function streamSSE(response, callbacks = {}) {
436
445
  text,
437
446
  assistantMessageExtId,
438
447
  agentSteps,
448
+ toolCallCount,
439
449
  errors,
440
450
  userMessage,
441
451
  metadata,
442
452
  artifacts,
443
- usage
453
+ usage,
454
+ context
444
455
  };
445
456
  }
446
457
  var consumeSSEStream = streamSSE;
@@ -1479,6 +1490,69 @@ var Arbi = class {
1479
1490
  }
1480
1491
  };
1481
1492
 
1482
- export { Arbi, ArbiApiError, ArbiError, 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, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, files_exports as files, formatAgentStepLabel, formatFileSize, formatUserName, formatWorkspaceChoices, 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 };
1493
+ // src/operations/responses.ts
1494
+ var responses_exports = {};
1495
+ __export(responses_exports, {
1496
+ extractResponseText: () => extractResponseText,
1497
+ getResponse: () => getResponse,
1498
+ submitBackgroundQuery: () => submitBackgroundQuery
1499
+ });
1500
+ async function submitBackgroundQuery(options) {
1501
+ const { workspaceId, question, docIds, previousResponseId, model, ...auth } = options;
1502
+ const tools = {};
1503
+ if (docIds.length > 0) {
1504
+ tools.retrieval_chunk = {
1505
+ name: "retrieval_chunk",
1506
+ description: "retrieval chunk",
1507
+ tool_args: { doc_ext_ids: docIds },
1508
+ tool_responses: {}
1509
+ };
1510
+ tools.retrieval_full_context = {
1511
+ name: "retrieval_full_context",
1512
+ description: "retrieval full context",
1513
+ tool_args: { doc_ext_ids: [] },
1514
+ tool_responses: {}
1515
+ };
1516
+ }
1517
+ const body = {
1518
+ input: question,
1519
+ workspace_ext_id: workspaceId,
1520
+ stream: false,
1521
+ background: true,
1522
+ store: true,
1523
+ tools,
1524
+ ...previousResponseId ? { previous_response_id: previousResponseId } : {},
1525
+ ...model ? { model } : {}
1526
+ };
1527
+ const res = await authenticatedFetch({
1528
+ ...auth,
1529
+ path: "/v1/responses",
1530
+ method: "POST",
1531
+ body: JSON.stringify(body),
1532
+ headers: { "Content-Type": "application/json" }
1533
+ });
1534
+ return await res.json();
1535
+ }
1536
+ async function getResponse(auth, responseId) {
1537
+ const res = await authenticatedFetch({
1538
+ ...auth,
1539
+ path: `/v1/responses/${responseId}`,
1540
+ method: "GET"
1541
+ });
1542
+ return await res.json();
1543
+ }
1544
+ function extractResponseText(response) {
1545
+ const parts = [];
1546
+ for (const msg of response.output) {
1547
+ for (const item of msg.content) {
1548
+ if ("type" in item && item.type === "output_text" && "text" in item) {
1549
+ parts.push(item.text);
1550
+ }
1551
+ }
1552
+ }
1553
+ return parts.join("");
1554
+ }
1555
+
1556
+ export { Arbi, ArbiApiError, ArbiError, 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, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, files_exports as files, formatAgentStepLabel, formatFileSize, formatUserName, formatWorkspaceChoices, 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 };
1483
1557
  //# sourceMappingURL=browser.js.map
1484
1558
  //# sourceMappingURL=browser.js.map