@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/{browser-BszYf6lU.d.cts → browser-DtwXhEkG.d.cts} +48 -1
- package/dist/{browser-BszYf6lU.d.ts → browser-DtwXhEkG.d.ts} +48 -1
- package/dist/browser.cjs +76 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +76 -2
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +83 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +83 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -77,6 +77,8 @@ interface CliConfig {
|
|
|
77
77
|
selectedWorkspaceId?: string;
|
|
78
78
|
autoUpdate?: boolean;
|
|
79
79
|
notifications?: boolean;
|
|
80
|
+
verbose?: boolean;
|
|
81
|
+
watch?: boolean;
|
|
80
82
|
}
|
|
81
83
|
interface CliCredentials {
|
|
82
84
|
email: string;
|
|
@@ -219,6 +221,7 @@ type UserMessageEvent = components['schemas']['UserMessageEvent'];
|
|
|
219
221
|
type MessageMetadataPayload = components['schemas']['MessageMetadataPayload'];
|
|
220
222
|
type ResponseUsage = components['schemas']['ResponseUsage'];
|
|
221
223
|
type OutputTokensDetails = components['schemas']['OutputTokensDetails'];
|
|
224
|
+
type TokenBudgetContext = components['schemas']['TokenBudgetContext'];
|
|
222
225
|
/** Convenience type — what onStreamStart callbacks receive. */
|
|
223
226
|
type SSEStreamStartData = {
|
|
224
227
|
assistant_message_ext_id: string;
|
|
@@ -285,11 +288,15 @@ interface SSEStreamResult {
|
|
|
285
288
|
text: string;
|
|
286
289
|
assistantMessageExtId: string | null;
|
|
287
290
|
agentSteps: string[];
|
|
291
|
+
/** Total number of tool calls across all agent steps. */
|
|
292
|
+
toolCallCount: number;
|
|
288
293
|
errors: string[];
|
|
289
294
|
userMessage: UserMessageEvent | null;
|
|
290
295
|
metadata: MessageMetadataPayload | null;
|
|
291
296
|
artifacts: ArtifactEvent[];
|
|
292
297
|
usage: ResponseUsage | null;
|
|
298
|
+
/** Token budget context snapshot from response.completed. */
|
|
299
|
+
context: TokenBudgetContext | null;
|
|
293
300
|
}
|
|
294
301
|
/**
|
|
295
302
|
* Stream SSE events from a Response, invoking callbacks as events arrive.
|
|
@@ -3180,4 +3187,44 @@ declare namespace health {
|
|
|
3180
3187
|
export { health_getHealth as getHealth, health_getHealthModels as getHealthModels, health_getMcpTools as getMcpTools, health_getRemoteModels as getRemoteModels };
|
|
3181
3188
|
}
|
|
3182
3189
|
|
|
3183
|
-
|
|
3190
|
+
/**
|
|
3191
|
+
* Responses operations — background query submission and retrieval.
|
|
3192
|
+
*
|
|
3193
|
+
* submitBackgroundQuery: POST /v1/responses with background=true → 202 with task ID.
|
|
3194
|
+
* getResponse: GET /v1/responses/{responseId} → current status + output.
|
|
3195
|
+
* extractResponseText: Walk response output and join text content.
|
|
3196
|
+
*/
|
|
3197
|
+
|
|
3198
|
+
type ResponsesAPIResponse = components['schemas']['ResponsesAPIResponse'];
|
|
3199
|
+
interface SubmitBackgroundQueryOptions extends AuthHeaders {
|
|
3200
|
+
workspaceId: string;
|
|
3201
|
+
question: string;
|
|
3202
|
+
docIds: string[];
|
|
3203
|
+
previousResponseId?: string | null;
|
|
3204
|
+
model?: string;
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Submit a query for background processing.
|
|
3208
|
+
* Returns immediately with a response ID and "queued" status.
|
|
3209
|
+
*/
|
|
3210
|
+
declare function submitBackgroundQuery(options: SubmitBackgroundQueryOptions): Promise<ResponsesAPIResponse>;
|
|
3211
|
+
/**
|
|
3212
|
+
* Fetch the current state of a response by ID.
|
|
3213
|
+
* Returns progressive status, output, usage, and metadata.
|
|
3214
|
+
*/
|
|
3215
|
+
declare function getResponse(auth: AuthHeaders, responseId: string): Promise<ResponsesAPIResponse>;
|
|
3216
|
+
/**
|
|
3217
|
+
* Walk response output messages and join all output_text content.
|
|
3218
|
+
* Pure function, no I/O.
|
|
3219
|
+
*/
|
|
3220
|
+
declare function extractResponseText(response: ResponsesAPIResponse): string;
|
|
3221
|
+
|
|
3222
|
+
type responses_SubmitBackgroundQueryOptions = SubmitBackgroundQueryOptions;
|
|
3223
|
+
declare const responses_extractResponseText: typeof extractResponseText;
|
|
3224
|
+
declare const responses_getResponse: typeof getResponse;
|
|
3225
|
+
declare const responses_submitBackgroundQuery: typeof submitBackgroundQuery;
|
|
3226
|
+
declare namespace responses {
|
|
3227
|
+
export { type responses_SubmitBackgroundQueryOptions as SubmitBackgroundQueryOptions, responses_extractResponseText as extractResponseText, responses_getResponse as getResponse, responses_submitBackgroundQuery as submitBackgroundQuery };
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
export { connectWithReconnect as $, type AuthHeaders as A, type SSEStreamCallbacks as B, type ConfigStore as C, type DocumentWaiter as D, type SSEStreamResult as E, type FormattedWsMessage as F, type SSEStreamStartData as G, type UserInfo as H, type UserInputRequestEvent as I, type UserMessageEvent as J, type WsConnection as K, LIFECYCLE_LABELS as L, type MessageLevel as M, agentconfig as N, type OutputTokensDetails as O, assistant as P, type QueryOptions as Q, type ReconnectOptions as R, type SSEEvent as S, TOOL_LABELS as T, type UploadBatchResult as U, authenticatedFetch as V, type WorkspaceContext as W, buildRetrievalChunkTool as X, buildRetrievalFullContextTool as Y, buildRetrievalTocTool as Z, connectWebSocket as _, type CliConfig as a, consumeSSEStream as a0, contacts as a1, conversations as a2, createAuthenticatedClient as a3, createDocumentWaiter as a4, dm as a5, doctags as a6, documents as a7, files as a8, formatAgentStepLabel as a9, formatFileSize as aa, formatUserName as ab, formatWorkspaceChoices as ac, formatWsMessage as ad, generateEncryptedWorkspaceKey as ae, getErrorCode as af, getErrorMessage as ag, health as ah, parseSSEEvents as ai, performPasswordLogin as aj, requireData as ak, requireOk as al, resolveAuth as am, resolveWorkspace as an, responses as ao, selectWorkspace as ap, selectWorkspaceById as aq, settings as ar, streamSSE as as, tags as at, workspaces as au, type CliCredentials as b, type ChatSession as c, type UploadOptions as d, type UploadResult as e, type AgentStepEvent as f, Arbi as g, ArbiApiError as h, ArbiError as i, type ArbiOptions as j, type ArtifactEvent as k, type AuthContext as l, type AuthenticatedClient as m, type ConnectOptions as n, type DocumentWaiterOptions as o, type MessageMetadataPayload as p, type ReconnectableWsConnection as q, type ResponseCompletedEvent as r, type ResponseContentPartAddedEvent as s, type ResponseCreatedEvent as t, type ResponseFailedEvent as u, type ResponseOutputItemAddedEvent as v, type ResponseOutputItemDoneEvent as w, type ResponseOutputTextDeltaEvent as x, type ResponseOutputTextDoneEvent as y, type ResponseUsage as z };
|
|
@@ -77,6 +77,8 @@ interface CliConfig {
|
|
|
77
77
|
selectedWorkspaceId?: string;
|
|
78
78
|
autoUpdate?: boolean;
|
|
79
79
|
notifications?: boolean;
|
|
80
|
+
verbose?: boolean;
|
|
81
|
+
watch?: boolean;
|
|
80
82
|
}
|
|
81
83
|
interface CliCredentials {
|
|
82
84
|
email: string;
|
|
@@ -219,6 +221,7 @@ type UserMessageEvent = components['schemas']['UserMessageEvent'];
|
|
|
219
221
|
type MessageMetadataPayload = components['schemas']['MessageMetadataPayload'];
|
|
220
222
|
type ResponseUsage = components['schemas']['ResponseUsage'];
|
|
221
223
|
type OutputTokensDetails = components['schemas']['OutputTokensDetails'];
|
|
224
|
+
type TokenBudgetContext = components['schemas']['TokenBudgetContext'];
|
|
222
225
|
/** Convenience type — what onStreamStart callbacks receive. */
|
|
223
226
|
type SSEStreamStartData = {
|
|
224
227
|
assistant_message_ext_id: string;
|
|
@@ -285,11 +288,15 @@ interface SSEStreamResult {
|
|
|
285
288
|
text: string;
|
|
286
289
|
assistantMessageExtId: string | null;
|
|
287
290
|
agentSteps: string[];
|
|
291
|
+
/** Total number of tool calls across all agent steps. */
|
|
292
|
+
toolCallCount: number;
|
|
288
293
|
errors: string[];
|
|
289
294
|
userMessage: UserMessageEvent | null;
|
|
290
295
|
metadata: MessageMetadataPayload | null;
|
|
291
296
|
artifacts: ArtifactEvent[];
|
|
292
297
|
usage: ResponseUsage | null;
|
|
298
|
+
/** Token budget context snapshot from response.completed. */
|
|
299
|
+
context: TokenBudgetContext | null;
|
|
293
300
|
}
|
|
294
301
|
/**
|
|
295
302
|
* Stream SSE events from a Response, invoking callbacks as events arrive.
|
|
@@ -3180,4 +3187,44 @@ declare namespace health {
|
|
|
3180
3187
|
export { health_getHealth as getHealth, health_getHealthModels as getHealthModels, health_getMcpTools as getMcpTools, health_getRemoteModels as getRemoteModels };
|
|
3181
3188
|
}
|
|
3182
3189
|
|
|
3183
|
-
|
|
3190
|
+
/**
|
|
3191
|
+
* Responses operations — background query submission and retrieval.
|
|
3192
|
+
*
|
|
3193
|
+
* submitBackgroundQuery: POST /v1/responses with background=true → 202 with task ID.
|
|
3194
|
+
* getResponse: GET /v1/responses/{responseId} → current status + output.
|
|
3195
|
+
* extractResponseText: Walk response output and join text content.
|
|
3196
|
+
*/
|
|
3197
|
+
|
|
3198
|
+
type ResponsesAPIResponse = components['schemas']['ResponsesAPIResponse'];
|
|
3199
|
+
interface SubmitBackgroundQueryOptions extends AuthHeaders {
|
|
3200
|
+
workspaceId: string;
|
|
3201
|
+
question: string;
|
|
3202
|
+
docIds: string[];
|
|
3203
|
+
previousResponseId?: string | null;
|
|
3204
|
+
model?: string;
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Submit a query for background processing.
|
|
3208
|
+
* Returns immediately with a response ID and "queued" status.
|
|
3209
|
+
*/
|
|
3210
|
+
declare function submitBackgroundQuery(options: SubmitBackgroundQueryOptions): Promise<ResponsesAPIResponse>;
|
|
3211
|
+
/**
|
|
3212
|
+
* Fetch the current state of a response by ID.
|
|
3213
|
+
* Returns progressive status, output, usage, and metadata.
|
|
3214
|
+
*/
|
|
3215
|
+
declare function getResponse(auth: AuthHeaders, responseId: string): Promise<ResponsesAPIResponse>;
|
|
3216
|
+
/**
|
|
3217
|
+
* Walk response output messages and join all output_text content.
|
|
3218
|
+
* Pure function, no I/O.
|
|
3219
|
+
*/
|
|
3220
|
+
declare function extractResponseText(response: ResponsesAPIResponse): string;
|
|
3221
|
+
|
|
3222
|
+
type responses_SubmitBackgroundQueryOptions = SubmitBackgroundQueryOptions;
|
|
3223
|
+
declare const responses_extractResponseText: typeof extractResponseText;
|
|
3224
|
+
declare const responses_getResponse: typeof getResponse;
|
|
3225
|
+
declare const responses_submitBackgroundQuery: typeof submitBackgroundQuery;
|
|
3226
|
+
declare namespace responses {
|
|
3227
|
+
export { type responses_SubmitBackgroundQueryOptions as SubmitBackgroundQueryOptions, responses_extractResponseText as extractResponseText, responses_getResponse as getResponse, responses_submitBackgroundQuery as submitBackgroundQuery };
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
export { connectWithReconnect as $, type AuthHeaders as A, type SSEStreamCallbacks as B, type ConfigStore as C, type DocumentWaiter as D, type SSEStreamResult as E, type FormattedWsMessage as F, type SSEStreamStartData as G, type UserInfo as H, type UserInputRequestEvent as I, type UserMessageEvent as J, type WsConnection as K, LIFECYCLE_LABELS as L, type MessageLevel as M, agentconfig as N, type OutputTokensDetails as O, assistant as P, type QueryOptions as Q, type ReconnectOptions as R, type SSEEvent as S, TOOL_LABELS as T, type UploadBatchResult as U, authenticatedFetch as V, type WorkspaceContext as W, buildRetrievalChunkTool as X, buildRetrievalFullContextTool as Y, buildRetrievalTocTool as Z, connectWebSocket as _, type CliConfig as a, consumeSSEStream as a0, contacts as a1, conversations as a2, createAuthenticatedClient as a3, createDocumentWaiter as a4, dm as a5, doctags as a6, documents as a7, files as a8, formatAgentStepLabel as a9, formatFileSize as aa, formatUserName as ab, formatWorkspaceChoices as ac, formatWsMessage as ad, generateEncryptedWorkspaceKey as ae, getErrorCode as af, getErrorMessage as ag, health as ah, parseSSEEvents as ai, performPasswordLogin as aj, requireData as ak, requireOk as al, resolveAuth as am, resolveWorkspace as an, responses as ao, selectWorkspace as ap, selectWorkspaceById as aq, settings as ar, streamSSE as as, tags as at, workspaces as au, type CliCredentials as b, type ChatSession as c, type UploadOptions as d, type UploadResult as e, type AgentStepEvent as f, Arbi as g, ArbiApiError as h, ArbiError as i, type ArbiOptions as j, type ArtifactEvent as k, type AuthContext as l, type AuthenticatedClient as m, type ConnectOptions as n, type DocumentWaiterOptions as o, type MessageMetadataPayload as p, type ReconnectableWsConnection as q, type ResponseCompletedEvent as r, type ResponseContentPartAddedEvent as s, type ResponseCreatedEvent as t, type ResponseFailedEvent as u, type ResponseOutputItemAddedEvent as v, type ResponseOutputItemDoneEvent as w, type ResponseOutputTextDeltaEvent as x, type ResponseOutputTextDoneEvent as y, type ResponseUsage as z };
|
package/dist/browser.cjs
CHANGED
|
@@ -326,11 +326,13 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
326
326
|
let text = "";
|
|
327
327
|
let assistantMessageExtId = null;
|
|
328
328
|
const agentSteps = [];
|
|
329
|
+
let toolCallCount = 0;
|
|
329
330
|
const errors = [];
|
|
330
331
|
const artifacts = [];
|
|
331
332
|
let userMessage = null;
|
|
332
333
|
let metadata = null;
|
|
333
334
|
let usage = null;
|
|
335
|
+
let context = null;
|
|
334
336
|
const eventHandlers = {
|
|
335
337
|
// OpenAI Responses API events (dot-separated names from server)
|
|
336
338
|
"response.created": (raw) => {
|
|
@@ -374,6 +376,9 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
374
376
|
metadata = meta;
|
|
375
377
|
callbacks.onMetadata?.(meta);
|
|
376
378
|
}
|
|
379
|
+
if (data.context) {
|
|
380
|
+
context = data.context;
|
|
381
|
+
}
|
|
377
382
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
378
383
|
callbacks.onComplete?.();
|
|
379
384
|
},
|
|
@@ -388,6 +393,10 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
388
393
|
const data = JSON.parse(raw);
|
|
389
394
|
const label = formatAgentStepLabel(data);
|
|
390
395
|
if (label) agentSteps.push(label);
|
|
396
|
+
const detail = data.detail;
|
|
397
|
+
if (detail && Array.isArray(detail)) {
|
|
398
|
+
toolCallCount += detail.filter((d) => d.tool).length;
|
|
399
|
+
}
|
|
391
400
|
callbacks.onAgentStep?.(data);
|
|
392
401
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
393
402
|
},
|
|
@@ -438,11 +447,13 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
438
447
|
text,
|
|
439
448
|
assistantMessageExtId,
|
|
440
449
|
agentSteps,
|
|
450
|
+
toolCallCount,
|
|
441
451
|
errors,
|
|
442
452
|
userMessage,
|
|
443
453
|
metadata,
|
|
444
454
|
artifacts,
|
|
445
|
-
usage
|
|
455
|
+
usage,
|
|
456
|
+
context
|
|
446
457
|
};
|
|
447
458
|
}
|
|
448
459
|
var consumeSSEStream = streamSSE;
|
|
@@ -1481,6 +1492,69 @@ var Arbi = class {
|
|
|
1481
1492
|
}
|
|
1482
1493
|
};
|
|
1483
1494
|
|
|
1495
|
+
// src/operations/responses.ts
|
|
1496
|
+
var responses_exports = {};
|
|
1497
|
+
__export(responses_exports, {
|
|
1498
|
+
extractResponseText: () => extractResponseText,
|
|
1499
|
+
getResponse: () => getResponse,
|
|
1500
|
+
submitBackgroundQuery: () => submitBackgroundQuery
|
|
1501
|
+
});
|
|
1502
|
+
async function submitBackgroundQuery(options) {
|
|
1503
|
+
const { workspaceId, question, docIds, previousResponseId, model, ...auth } = options;
|
|
1504
|
+
const tools = {};
|
|
1505
|
+
if (docIds.length > 0) {
|
|
1506
|
+
tools.retrieval_chunk = {
|
|
1507
|
+
name: "retrieval_chunk",
|
|
1508
|
+
description: "retrieval chunk",
|
|
1509
|
+
tool_args: { doc_ext_ids: docIds },
|
|
1510
|
+
tool_responses: {}
|
|
1511
|
+
};
|
|
1512
|
+
tools.retrieval_full_context = {
|
|
1513
|
+
name: "retrieval_full_context",
|
|
1514
|
+
description: "retrieval full context",
|
|
1515
|
+
tool_args: { doc_ext_ids: [] },
|
|
1516
|
+
tool_responses: {}
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
const body = {
|
|
1520
|
+
input: question,
|
|
1521
|
+
workspace_ext_id: workspaceId,
|
|
1522
|
+
stream: false,
|
|
1523
|
+
background: true,
|
|
1524
|
+
store: true,
|
|
1525
|
+
tools,
|
|
1526
|
+
...previousResponseId ? { previous_response_id: previousResponseId } : {},
|
|
1527
|
+
...model ? { model } : {}
|
|
1528
|
+
};
|
|
1529
|
+
const res = await authenticatedFetch({
|
|
1530
|
+
...auth,
|
|
1531
|
+
path: "/v1/responses",
|
|
1532
|
+
method: "POST",
|
|
1533
|
+
body: JSON.stringify(body),
|
|
1534
|
+
headers: { "Content-Type": "application/json" }
|
|
1535
|
+
});
|
|
1536
|
+
return await res.json();
|
|
1537
|
+
}
|
|
1538
|
+
async function getResponse(auth, responseId) {
|
|
1539
|
+
const res = await authenticatedFetch({
|
|
1540
|
+
...auth,
|
|
1541
|
+
path: `/v1/responses/${responseId}`,
|
|
1542
|
+
method: "GET"
|
|
1543
|
+
});
|
|
1544
|
+
return await res.json();
|
|
1545
|
+
}
|
|
1546
|
+
function extractResponseText(response) {
|
|
1547
|
+
const parts = [];
|
|
1548
|
+
for (const msg of response.output) {
|
|
1549
|
+
for (const item of msg.content) {
|
|
1550
|
+
if ("type" in item && item.type === "output_text" && "text" in item) {
|
|
1551
|
+
parts.push(item.text);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
return parts.join("");
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1484
1558
|
exports.Arbi = Arbi;
|
|
1485
1559
|
exports.ArbiApiError = ArbiApiError;
|
|
1486
1560
|
exports.ArbiError = ArbiError;
|
|
@@ -1514,6 +1588,7 @@ exports.requireData = requireData;
|
|
|
1514
1588
|
exports.requireOk = requireOk;
|
|
1515
1589
|
exports.resolveAuth = resolveAuth;
|
|
1516
1590
|
exports.resolveWorkspace = resolveWorkspace;
|
|
1591
|
+
exports.responses = responses_exports;
|
|
1517
1592
|
exports.selectWorkspace = selectWorkspace;
|
|
1518
1593
|
exports.selectWorkspaceById = selectWorkspaceById;
|
|
1519
1594
|
exports.settings = settings_exports;
|