@arbidocs/sdk 0.5.56 → 0.5.58
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/README.md +41 -0
- package/dist/{browser-DEZ7kJKE.d.ts → browser-BX1E63gK.d.ts} +31 -5
- package/dist/{browser-DvpIH-Qk.d.cts → browser-ENBx11nT.d.cts} +31 -5
- package/dist/browser.cjs +78 -25
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +78 -25
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +78 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +78 -25
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3685,10 +3685,19 @@ var STATUS_FALLBACKS = {
|
|
|
3685
3685
|
503: "The selected LLM is not responding. Please retry or select another model."
|
|
3686
3686
|
};
|
|
3687
3687
|
async function authenticatedFetch(options) {
|
|
3688
|
-
const {
|
|
3688
|
+
const {
|
|
3689
|
+
baseUrl,
|
|
3690
|
+
accessToken,
|
|
3691
|
+
path: path5,
|
|
3692
|
+
method,
|
|
3693
|
+
body,
|
|
3694
|
+
headers,
|
|
3695
|
+
signal,
|
|
3696
|
+
fetch: send = globalThis.fetch
|
|
3697
|
+
} = options;
|
|
3689
3698
|
let res;
|
|
3690
3699
|
try {
|
|
3691
|
-
res = await
|
|
3700
|
+
res = await send(`${baseUrl}${path5}`, {
|
|
3692
3701
|
method: method ?? (body ? "POST" : "GET"),
|
|
3693
3702
|
headers: {
|
|
3694
3703
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -3722,11 +3731,11 @@ function parseHeaders(raw) {
|
|
|
3722
3731
|
}
|
|
3723
3732
|
return headers;
|
|
3724
3733
|
}
|
|
3725
|
-
function progressFetch(onProgress) {
|
|
3734
|
+
function progressFetch(onProgress, transport) {
|
|
3726
3735
|
const Xhr = globalThis.XMLHttpRequest;
|
|
3727
|
-
|
|
3728
|
-
if (!Xhr) {
|
|
3729
|
-
const response = await fetch(request);
|
|
3736
|
+
const adapter = async (request) => {
|
|
3737
|
+
if (!Xhr || transport?.customFetch) {
|
|
3738
|
+
const response = await (transport?.customFetch ? transport.fetch : globalThis.fetch)(request);
|
|
3730
3739
|
const size = Number(request.headers.get("content-length") ?? 0);
|
|
3731
3740
|
onProgress(size, size);
|
|
3732
3741
|
return response;
|
|
@@ -3740,7 +3749,10 @@ function progressFetch(onProgress) {
|
|
|
3740
3749
|
xhr.upload.onprogress = (event) => {
|
|
3741
3750
|
if (event.lengthComputable) onProgress(event.loaded, event.total);
|
|
3742
3751
|
};
|
|
3752
|
+
const cleanup = () => request.signal.removeEventListener("abort", abort);
|
|
3753
|
+
const abort = () => xhr.abort();
|
|
3743
3754
|
xhr.onload = () => {
|
|
3755
|
+
cleanup();
|
|
3744
3756
|
onProgress(body.size, body.size);
|
|
3745
3757
|
resolve2(
|
|
3746
3758
|
new Response(NULL_BODY_STATUSES.has(xhr.status) ? null : xhr.responseText, {
|
|
@@ -3750,12 +3762,30 @@ function progressFetch(onProgress) {
|
|
|
3750
3762
|
})
|
|
3751
3763
|
);
|
|
3752
3764
|
};
|
|
3753
|
-
xhr.onerror = () =>
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3765
|
+
xhr.onerror = () => {
|
|
3766
|
+
cleanup();
|
|
3767
|
+
reject(new TypeError("Network error during upload"));
|
|
3768
|
+
};
|
|
3769
|
+
xhr.onabort = () => {
|
|
3770
|
+
cleanup();
|
|
3771
|
+
reject(request.signal.reason ?? new DOMException("Upload aborted", "AbortError"));
|
|
3772
|
+
};
|
|
3773
|
+
if (request.signal.aborted) {
|
|
3774
|
+
reject(request.signal.reason ?? new DOMException("Upload aborted", "AbortError"));
|
|
3775
|
+
return;
|
|
3776
|
+
}
|
|
3777
|
+
request.signal.addEventListener("abort", abort, { once: true });
|
|
3778
|
+
try {
|
|
3779
|
+
xhr.send(body);
|
|
3780
|
+
} catch (error) {
|
|
3781
|
+
cleanup();
|
|
3782
|
+
reject(error);
|
|
3783
|
+
}
|
|
3757
3784
|
});
|
|
3758
3785
|
};
|
|
3786
|
+
if (transport?.customFetch) return adapter;
|
|
3787
|
+
const send = transport?.withFetch((input, init) => adapter(new Request(input, init)));
|
|
3788
|
+
return send ? (request) => send(request) : adapter;
|
|
3759
3789
|
}
|
|
3760
3790
|
var DEFAULT_SESSION = {
|
|
3761
3791
|
lastMessageExtId: null,
|
|
@@ -5763,7 +5793,7 @@ async function uploadDocuments(arbi, files, options = {}) {
|
|
|
5763
5793
|
}
|
|
5764
5794
|
const result = await arbi.fetch.POST("/v1/document/upload", {
|
|
5765
5795
|
params: { query: query2 },
|
|
5766
|
-
...options.onProgress ? { fetch: progressFetch(options.onProgress) } : {},
|
|
5796
|
+
...options.onProgress ? { fetch: progressFetch(options.onProgress, arbi.http) } : {},
|
|
5767
5797
|
// The schema types the files as strings; they go as multipart parts.
|
|
5768
5798
|
body: { files },
|
|
5769
5799
|
bodySerializer: () => {
|
|
@@ -6721,10 +6751,11 @@ function searchChunks(result) {
|
|
|
6721
6751
|
return Array.from(byId3.values()).sort((a2, b2) => b2.score - a2.score);
|
|
6722
6752
|
}
|
|
6723
6753
|
async function queryAssistant(options) {
|
|
6724
|
-
const { baseUrl, accessToken, signal, ...request } = options;
|
|
6754
|
+
const { baseUrl, accessToken, signal, fetch: fetch2, ...request } = options;
|
|
6725
6755
|
return authenticatedFetch({
|
|
6726
6756
|
baseUrl,
|
|
6727
6757
|
accessToken,
|
|
6758
|
+
fetch: fetch2,
|
|
6728
6759
|
path: "/v1/responses",
|
|
6729
6760
|
method: "POST",
|
|
6730
6761
|
body: JSON.stringify(buildTurnRequest(request)),
|
|
@@ -6779,7 +6810,7 @@ async function refusal(response) {
|
|
|
6779
6810
|
);
|
|
6780
6811
|
}
|
|
6781
6812
|
async function openTurnStream(auth, body, signal) {
|
|
6782
|
-
const response = await fetch(`${auth.baseUrl}/v1/responses`, {
|
|
6813
|
+
const response = await (auth.fetch ?? globalThis.fetch)(`${auth.baseUrl}/v1/responses`, {
|
|
6783
6814
|
method: "POST",
|
|
6784
6815
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${auth.accessToken}` },
|
|
6785
6816
|
body: JSON.stringify(body),
|
|
@@ -6797,7 +6828,7 @@ async function openTurnStream(auth, body, signal) {
|
|
|
6797
6828
|
return response;
|
|
6798
6829
|
}
|
|
6799
6830
|
async function openRunStream(auth, responseId, signal) {
|
|
6800
|
-
const response = await fetch(
|
|
6831
|
+
const response = await (auth.fetch ?? globalThis.fetch)(
|
|
6801
6832
|
`${auth.baseUrl}/v1/assistant/run/${encodeURIComponent(responseId)}/stream`,
|
|
6802
6833
|
{
|
|
6803
6834
|
method: "GET",
|
|
@@ -9780,6 +9811,7 @@ async function remindFact(arbi, factId, options = {}) {
|
|
|
9780
9811
|
var databases_exports = {};
|
|
9781
9812
|
__export(databases_exports, {
|
|
9782
9813
|
addDatabaseRows: () => addDatabaseRows,
|
|
9814
|
+
aggregateDatabase: () => aggregateDatabase,
|
|
9783
9815
|
createDatabase: () => createDatabase,
|
|
9784
9816
|
deleteDatabase: () => deleteDatabase,
|
|
9785
9817
|
deleteDatabaseRows: () => deleteDatabaseRows,
|
|
@@ -9815,6 +9847,15 @@ async function listDatabaseRows(arbi, databaseId, query2 = {}) {
|
|
|
9815
9847
|
"Failed to read the rows"
|
|
9816
9848
|
);
|
|
9817
9849
|
}
|
|
9850
|
+
async function aggregateDatabase(arbi, databaseId, body) {
|
|
9851
|
+
return requireData(
|
|
9852
|
+
await arbi.fetch.POST("/v1/databases/{database_id}/aggregate", {
|
|
9853
|
+
params: path2(databaseId),
|
|
9854
|
+
body: { time_bucket: "month", limit: 50, ...body }
|
|
9855
|
+
}),
|
|
9856
|
+
"Failed to aggregate the database"
|
|
9857
|
+
);
|
|
9858
|
+
}
|
|
9818
9859
|
async function createDatabase(arbi, body) {
|
|
9819
9860
|
return requireData(
|
|
9820
9861
|
await arbi.fetch.POST("/v1/databases", { body }),
|
|
@@ -11203,6 +11244,10 @@ var Arbi = class {
|
|
|
11203
11244
|
options;
|
|
11204
11245
|
constructor(options) {
|
|
11205
11246
|
this.options = options;
|
|
11247
|
+
if (options.session && options.transport)
|
|
11248
|
+
throw new ArbiError(
|
|
11249
|
+
"Configure transport on the host session client, not on its Arbi wrapper."
|
|
11250
|
+
);
|
|
11206
11251
|
if (options.session) {
|
|
11207
11252
|
this.client = options.session.client;
|
|
11208
11253
|
this.loginResult = options.session.login;
|
|
@@ -11227,6 +11272,7 @@ var Arbi = class {
|
|
|
11227
11272
|
baseUrl: this.options.url,
|
|
11228
11273
|
deploymentDomain: domain,
|
|
11229
11274
|
credentials: this.options.credentials ?? "omit",
|
|
11275
|
+
transport: this.options.transport,
|
|
11230
11276
|
session: client.createSessionManager({ storage: this.options.sessionStorage }),
|
|
11231
11277
|
// A silent re-login rotates the server session key: keep ours in step, or the next
|
|
11232
11278
|
// workspace open would seal the key for a session the server no longer has.
|
|
@@ -11421,11 +11467,15 @@ var Arbi = class {
|
|
|
11421
11467
|
await this.targetWorkspace(workspaceId);
|
|
11422
11468
|
return createTag(this.requireClient(), { ...options, workspaceId });
|
|
11423
11469
|
}
|
|
11424
|
-
/**
|
|
11470
|
+
/**
|
|
11471
|
+
* The workspace a call acts on, captured when it is called: the one it names (opened for this session, not
|
|
11472
|
+
* switched to), else the current one. The request names it, so a switch while it is in flight cannot move it.
|
|
11473
|
+
* `undefined` only when no workspace is known here (the server's open one then applies, as before).
|
|
11474
|
+
*/
|
|
11425
11475
|
async targetWorkspace(workspaceId) {
|
|
11426
|
-
|
|
11427
|
-
await this.openWorkspace(
|
|
11428
|
-
return
|
|
11476
|
+
const target = workspaceId ?? this.currentWorkspaceId ?? void 0;
|
|
11477
|
+
if (target) await this.openWorkspace(target);
|
|
11478
|
+
return target;
|
|
11429
11479
|
}
|
|
11430
11480
|
/**
|
|
11431
11481
|
* Make a workspace the CURRENT one: decrypt its key, open it on the server (which makes it the
|
|
@@ -11655,7 +11705,8 @@ var Arbi = class {
|
|
|
11655
11705
|
}
|
|
11656
11706
|
return {
|
|
11657
11707
|
baseUrl: this.options.url,
|
|
11658
|
-
accessToken
|
|
11708
|
+
accessToken,
|
|
11709
|
+
...client.http ? { fetch: client.http.fetch } : {}
|
|
11659
11710
|
};
|
|
11660
11711
|
}
|
|
11661
11712
|
// ── Projects ──────────────────────────────────────────────────────────
|
|
@@ -12172,10 +12223,10 @@ var Arbi = class {
|
|
|
12172
12223
|
/** Authenticated native Word transport, with normal session recovery. */
|
|
12173
12224
|
editor = {
|
|
12174
12225
|
request: (path5, options = {}) => this.recovering(async () => {
|
|
12175
|
-
const { baseUrl, accessToken } = this.getAuthHeaders();
|
|
12226
|
+
const { baseUrl, accessToken, fetch: send = globalThis.fetch } = this.getAuthHeaders();
|
|
12176
12227
|
const headers = new Headers(options.headers);
|
|
12177
12228
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
12178
|
-
const response = await
|
|
12229
|
+
const response = await send(`${baseUrl}/v1/editor${path5}`, { ...options, headers });
|
|
12179
12230
|
if (!response.ok) {
|
|
12180
12231
|
const body = await response.json().catch(() => null);
|
|
12181
12232
|
throw new ArbiApiError(body?.detail || `Document request failed (${response.status})`, {
|
|
@@ -12193,12 +12244,12 @@ var Arbi = class {
|
|
|
12193
12244
|
mail = {
|
|
12194
12245
|
/** Fetch a path under `/v1/mail`; rejects a non-2xx response with an `ArbiApiError` (`status`). */
|
|
12195
12246
|
fetch: (path5, init = {}) => this.recovering(async () => {
|
|
12196
|
-
const { baseUrl, accessToken } = this.getAuthHeaders();
|
|
12247
|
+
const { baseUrl, accessToken, fetch: send = globalThis.fetch } = this.getAuthHeaders();
|
|
12197
12248
|
const headers = new Headers(init.headers);
|
|
12198
12249
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
12199
12250
|
if (init.body && !headers.has("Content-Type"))
|
|
12200
12251
|
headers.set("Content-Type", "application/json");
|
|
12201
|
-
const response = await
|
|
12252
|
+
const response = await send(`${baseUrl}/v1/mail${path5}`, { ...init, headers });
|
|
12202
12253
|
if (!response.ok) {
|
|
12203
12254
|
const body = await response.json().catch(() => null);
|
|
12204
12255
|
throw new ArbiApiError(
|
|
@@ -12394,8 +12445,8 @@ var Arbi = class {
|
|
|
12394
12445
|
*/
|
|
12395
12446
|
/** The open workspace's tags, or `query.workspaceId`'s (opened for this session, not switched to). */
|
|
12396
12447
|
list: async (query2) => {
|
|
12397
|
-
await this.targetWorkspace(query2?.workspaceId);
|
|
12398
|
-
return listTags(this.requireClient(), query2);
|
|
12448
|
+
const workspaceId = await this.targetWorkspace(query2?.workspaceId);
|
|
12449
|
+
return listTags(this.requireClient(), { ...query2, workspaceId });
|
|
12399
12450
|
},
|
|
12400
12451
|
create: (options) => this.createTagIn(options.workspaceId ?? this.requireWorkspace(), options),
|
|
12401
12452
|
delete: (tagId) => deleteTag(this.requireClient(), tagId),
|
|
@@ -13071,6 +13122,8 @@ var Arbi = class {
|
|
|
13071
13122
|
get: (databaseId) => getDatabase(this.requireClient(), databaseId),
|
|
13072
13123
|
/** A search of the rows (any cell), sorted and paged on the server. */
|
|
13073
13124
|
rows: (databaseId, query2) => listDatabaseRows(this.requireClient(), databaseId, query2),
|
|
13125
|
+
/** Group and measure the rows on the server (a chart's labels and series). */
|
|
13126
|
+
aggregate: (databaseId, body) => aggregateDatabase(this.requireClient(), databaseId, body),
|
|
13074
13127
|
create: (body) => createDatabase(this.requireClient(), body),
|
|
13075
13128
|
update: (databaseId, body) => updateDatabase(this.requireClient(), databaseId, body),
|
|
13076
13129
|
delete: (databaseId) => deleteDatabase(this.requireClient(), databaseId),
|