@arbidocs/sdk 0.3.10 → 0.3.13
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 +3183 -0
- package/dist/browser-BszYf6lU.d.ts +3183 -0
- package/dist/browser.cjs +185 -30
- 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 +183 -26
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +393 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -2971
- package/dist/index.d.ts +40 -2971
- package/dist/index.js +388 -28
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/browser.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AgentStepEvent, Arbi, ArbiApiError, ArbiError, ArbiOptions, ArtifactEvent, AuthContext, AuthHeaders, AuthenticatedClient, ChatSession, CliConfig, CliCredentials, ConfigStore, ConnectOptions, MessageMetadataPayload, OutputTokensDetails, QueryOptions, ReconnectOptions, ReconnectableWsConnection, ResponseCompletedEvent, ResponseContentPartAddedEvent, ResponseCreatedEvent, ResponseFailedEvent, ResponseOutputItemAddedEvent, ResponseOutputItemDoneEvent, ResponseOutputTextDeltaEvent, ResponseOutputTextDoneEvent, ResponseUsage, SSEEvent, SSEStreamCallbacks, SSEStreamResult, SSEStreamStartData, UserInfo, UserInputRequestEvent, UserMessageEvent, WorkspaceContext, WsConnection, agentconfig, assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts, conversations, createAuthenticatedClient, dm, doctags, documents, files, formatFileSize, formatUserName, formatWorkspaceChoices, getErrorMessage, health, parseSSEEvents, performPasswordLogin, requireData, requireOk, resolveAuth, resolveWorkspace, selectWorkspace, selectWorkspaceById, settings, streamSSE, tags, workspaces } from './
|
|
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';
|
|
2
2
|
import '@arbidocs/client';
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AgentStepEvent, Arbi, ArbiApiError, ArbiError, ArbiOptions, ArtifactEvent, AuthContext, AuthHeaders, AuthenticatedClient, ChatSession, CliConfig, CliCredentials, ConfigStore, ConnectOptions, MessageMetadataPayload, OutputTokensDetails, QueryOptions, ReconnectOptions, ReconnectableWsConnection, ResponseCompletedEvent, ResponseContentPartAddedEvent, ResponseCreatedEvent, ResponseFailedEvent, ResponseOutputItemAddedEvent, ResponseOutputItemDoneEvent, ResponseOutputTextDeltaEvent, ResponseOutputTextDoneEvent, ResponseUsage, SSEEvent, SSEStreamCallbacks, SSEStreamResult, SSEStreamStartData, UserInfo, UserInputRequestEvent, UserMessageEvent, WorkspaceContext, WsConnection, agentconfig, assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts, conversations, createAuthenticatedClient, dm, doctags, documents, files, formatFileSize, formatUserName, formatWorkspaceChoices, getErrorMessage, health, parseSSEEvents, performPasswordLogin, requireData, requireOk, resolveAuth, resolveWorkspace, selectWorkspace, selectWorkspaceById, settings, streamSSE, tags, workspaces } from './
|
|
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';
|
|
2
2
|
import '@arbidocs/client';
|
package/dist/browser.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { createArbiClient, base64ToBytes, deriveEncryptionKeypairFromSigning, sealedBoxDecrypt, createWorkspaceKeyHeader, buildWebSocketUrl, createAuthMessage, parseServerMessage, isMessageType } from '@arbidocs/client';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
2
|
|
|
5
3
|
var __defProp = Object.defineProperty;
|
|
6
4
|
var __export = (target, all) => {
|
|
@@ -35,17 +33,55 @@ function requireOk(result, message) {
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
function getErrorMessage(err) {
|
|
38
|
-
|
|
36
|
+
if (!(err instanceof Error)) return String(err);
|
|
37
|
+
const rootCause = getDeepestCause(err);
|
|
38
|
+
if (rootCause !== err) {
|
|
39
|
+
const rootMsg = rootCause.message || String(rootCause);
|
|
40
|
+
if (err.message && !err.message.includes(rootMsg)) {
|
|
41
|
+
return `${err.message}: ${rootMsg}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return err.message;
|
|
45
|
+
}
|
|
46
|
+
function getDeepestCause(err) {
|
|
47
|
+
let current = err;
|
|
48
|
+
const seen = /* @__PURE__ */ new Set();
|
|
49
|
+
while (current.cause instanceof Error && !seen.has(current.cause)) {
|
|
50
|
+
seen.add(current);
|
|
51
|
+
current = current.cause;
|
|
52
|
+
}
|
|
53
|
+
return current;
|
|
39
54
|
}
|
|
40
55
|
|
|
41
56
|
// src/fetch.ts
|
|
42
|
-
var
|
|
57
|
+
var STATUS_FALLBACKS = {
|
|
43
58
|
401: "Token has expired. Please run: arbi login",
|
|
59
|
+
403: "Access denied. You may not have permission for this workspace.",
|
|
60
|
+
404: "Resource not found.",
|
|
44
61
|
503: "The selected LLM is not responding. Please retry or select another model."
|
|
45
62
|
};
|
|
63
|
+
async function extractErrorMessage(res) {
|
|
64
|
+
let bodyDetail;
|
|
65
|
+
try {
|
|
66
|
+
const text = await res.text();
|
|
67
|
+
if (text) {
|
|
68
|
+
try {
|
|
69
|
+
const json = JSON.parse(text);
|
|
70
|
+
bodyDetail = json.detail || json.message || json.error || void 0;
|
|
71
|
+
} catch {
|
|
72
|
+
if (text.length < 200) bodyDetail = text;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
if (bodyDetail) return `Request failed (${res.status}): ${bodyDetail}`;
|
|
78
|
+
const fallback = STATUS_FALLBACKS[res.status];
|
|
79
|
+
if (fallback) return fallback;
|
|
80
|
+
return `Request failed: ${res.status} ${res.statusText}`;
|
|
81
|
+
}
|
|
46
82
|
async function authenticatedFetch(options) {
|
|
47
|
-
const { baseUrl, accessToken, workspaceKeyHeader, path
|
|
48
|
-
const res = await fetch(`${baseUrl}${
|
|
83
|
+
const { baseUrl, accessToken, workspaceKeyHeader, path, method, body, headers } = options;
|
|
84
|
+
const res = await fetch(`${baseUrl}${path}`, {
|
|
49
85
|
method: method ?? (body ? "POST" : "GET"),
|
|
50
86
|
headers: {
|
|
51
87
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -55,10 +91,8 @@ async function authenticatedFetch(options) {
|
|
|
55
91
|
body
|
|
56
92
|
});
|
|
57
93
|
if (!res.ok) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const text = await res.text().catch(() => "");
|
|
61
|
-
throw new Error(`Request failed: ${res.status} ${text}`);
|
|
94
|
+
const message = await extractErrorMessage(res);
|
|
95
|
+
throw new ArbiApiError(message, { status: res.status, statusText: res.statusText });
|
|
62
96
|
}
|
|
63
97
|
return res;
|
|
64
98
|
}
|
|
@@ -86,7 +120,11 @@ async function createAuthenticatedClient(config, creds, store) {
|
|
|
86
120
|
});
|
|
87
121
|
store.saveCredentials({
|
|
88
122
|
...creds,
|
|
89
|
-
serverSessionKeyBase64: arbi.crypto.bytesToBase64(loginResult.serverSessionKey)
|
|
123
|
+
serverSessionKeyBase64: arbi.crypto.bytesToBase64(loginResult.serverSessionKey),
|
|
124
|
+
accessToken: void 0,
|
|
125
|
+
workspaceKeyHeader: void 0,
|
|
126
|
+
workspaceId: void 0,
|
|
127
|
+
tokenTimestamp: void 0
|
|
90
128
|
});
|
|
91
129
|
return { arbi, loginResult };
|
|
92
130
|
}
|
|
@@ -101,7 +139,12 @@ async function performPasswordLogin(config, email, password, store) {
|
|
|
101
139
|
store.saveCredentials({
|
|
102
140
|
email,
|
|
103
141
|
signingPrivateKeyBase64: arbi.crypto.bytesToBase64(loginResult.signingPrivateKey),
|
|
104
|
-
serverSessionKeyBase64: arbi.crypto.bytesToBase64(loginResult.serverSessionKey)
|
|
142
|
+
serverSessionKeyBase64: arbi.crypto.bytesToBase64(loginResult.serverSessionKey),
|
|
143
|
+
// Clear any cached workspace tokens — new session key invalidates them
|
|
144
|
+
accessToken: void 0,
|
|
145
|
+
workspaceKeyHeader: void 0,
|
|
146
|
+
workspaceId: void 0,
|
|
147
|
+
tokenTimestamp: void 0
|
|
105
148
|
});
|
|
106
149
|
return { arbi, loginResult, config };
|
|
107
150
|
}
|
|
@@ -154,6 +197,10 @@ async function resolveAuth(store) {
|
|
|
154
197
|
const { arbi, loginResult } = await createAuthenticatedClient(config, creds, store);
|
|
155
198
|
return { arbi, loginResult, config };
|
|
156
199
|
}
|
|
200
|
+
var TOKEN_MAX_AGE_MS = 50 * 60 * 1e3;
|
|
201
|
+
function isCachedTokenValid(creds, workspaceId) {
|
|
202
|
+
return !!(creds.accessToken && creds.workspaceKeyHeader && creds.workspaceId === workspaceId && creds.tokenTimestamp && Date.now() - new Date(creds.tokenTimestamp).getTime() < TOKEN_MAX_AGE_MS);
|
|
203
|
+
}
|
|
157
204
|
async function resolveWorkspace(store, workspaceOpt) {
|
|
158
205
|
const config = store.requireConfig();
|
|
159
206
|
const creds = store.requireCredentials();
|
|
@@ -161,6 +208,32 @@ async function resolveWorkspace(store, workspaceOpt) {
|
|
|
161
208
|
if (!workspaceId) {
|
|
162
209
|
throw new ArbiError("No workspace selected. Run: arbi workspace select <id>");
|
|
163
210
|
}
|
|
211
|
+
if (isCachedTokenValid(creds, workspaceId)) {
|
|
212
|
+
const arbi2 = createArbiClient({
|
|
213
|
+
baseUrl: config.baseUrl,
|
|
214
|
+
deploymentDomain: config.deploymentDomain,
|
|
215
|
+
credentials: "omit"
|
|
216
|
+
});
|
|
217
|
+
await arbi2.crypto.initSodium();
|
|
218
|
+
arbi2.session.setSelectedWorkspace(workspaceId);
|
|
219
|
+
arbi2.session.setAccessToken(creds.accessToken);
|
|
220
|
+
arbi2.session.setCachedWorkspaceHeader(workspaceId, creds.workspaceKeyHeader);
|
|
221
|
+
const signingPrivateKey = base64ToBytes(creds.signingPrivateKeyBase64);
|
|
222
|
+
const serverSessionKey = base64ToBytes(creds.serverSessionKeyBase64);
|
|
223
|
+
const loginResult2 = {
|
|
224
|
+
accessToken: creds.accessToken,
|
|
225
|
+
signingPrivateKey,
|
|
226
|
+
serverSessionKey
|
|
227
|
+
};
|
|
228
|
+
return {
|
|
229
|
+
arbi: arbi2,
|
|
230
|
+
loginResult: loginResult2,
|
|
231
|
+
config,
|
|
232
|
+
workspaceId,
|
|
233
|
+
accessToken: creds.accessToken,
|
|
234
|
+
workspaceKeyHeader: creds.workspaceKeyHeader
|
|
235
|
+
};
|
|
236
|
+
}
|
|
164
237
|
const { arbi, loginResult } = await createAuthenticatedClient(config, creds, store);
|
|
165
238
|
await selectWorkspaceById(
|
|
166
239
|
arbi,
|
|
@@ -173,10 +246,57 @@ async function resolveWorkspace(store, workspaceOpt) {
|
|
|
173
246
|
if (!accessToken || !workspaceKeyHeader) {
|
|
174
247
|
throw new ArbiError("Authentication error \u2014 missing token or workspace key");
|
|
175
248
|
}
|
|
249
|
+
store.saveCredentials({
|
|
250
|
+
...store.requireCredentials(),
|
|
251
|
+
accessToken,
|
|
252
|
+
workspaceKeyHeader,
|
|
253
|
+
workspaceId,
|
|
254
|
+
tokenTimestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
255
|
+
});
|
|
176
256
|
return { arbi, loginResult, config, workspaceId, accessToken, workspaceKeyHeader };
|
|
177
257
|
}
|
|
178
258
|
|
|
179
259
|
// src/sse.ts
|
|
260
|
+
var TOOL_LABELS = {
|
|
261
|
+
search_documents: "Searching documents",
|
|
262
|
+
get_document_passages: "Reading document",
|
|
263
|
+
get_table_of_contents: "Getting table of contents",
|
|
264
|
+
view_document_pages: "Viewing document pages",
|
|
265
|
+
get_full_document: "Reading full document",
|
|
266
|
+
web_search: "Searching the web",
|
|
267
|
+
read_url: "Reading web pages",
|
|
268
|
+
ask_user: "Asking user",
|
|
269
|
+
compaction: "Compacting conversation",
|
|
270
|
+
personal_agent: "Running agent",
|
|
271
|
+
create_artifact: "Creating artifact",
|
|
272
|
+
create_plan: "Creating plan",
|
|
273
|
+
save_skill: "Saving skill",
|
|
274
|
+
run_code: "Running code"
|
|
275
|
+
};
|
|
276
|
+
var LIFECYCLE_LABELS = {
|
|
277
|
+
evaluation: "Evaluating results",
|
|
278
|
+
answering: "Writing answer",
|
|
279
|
+
reviewing: "Reviewing answer",
|
|
280
|
+
planning: "Planning",
|
|
281
|
+
tool_progress: "Working"
|
|
282
|
+
};
|
|
283
|
+
function formatAgentStepLabel(step) {
|
|
284
|
+
if (step.focus) return step.focus;
|
|
285
|
+
const detail = step.detail;
|
|
286
|
+
if (step.step === "tool_progress" && detail && detail.length > 0) {
|
|
287
|
+
const toolName = detail[0].tool;
|
|
288
|
+
const label = toolName && TOOL_LABELS[toolName] || LIFECYCLE_LABELS.tool_progress;
|
|
289
|
+
const message = detail[0].message;
|
|
290
|
+
return message ? `${label}: ${message}` : label;
|
|
291
|
+
}
|
|
292
|
+
if (step.step) {
|
|
293
|
+
return LIFECYCLE_LABELS[step.step] || step.step;
|
|
294
|
+
}
|
|
295
|
+
if (detail && detail.length > 0 && detail[0].tool) {
|
|
296
|
+
return TOOL_LABELS[detail[0].tool] || detail[0].tool;
|
|
297
|
+
}
|
|
298
|
+
return "";
|
|
299
|
+
}
|
|
180
300
|
function parseSSEEvents(chunk, buffer) {
|
|
181
301
|
const combined = buffer + chunk;
|
|
182
302
|
const events = [];
|
|
@@ -247,6 +367,11 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
247
367
|
usage = data.response.usage;
|
|
248
368
|
callbacks.onUsage?.(data.response.usage);
|
|
249
369
|
}
|
|
370
|
+
if (data.response?.metadata) {
|
|
371
|
+
const meta = data.response.metadata;
|
|
372
|
+
metadata = meta;
|
|
373
|
+
callbacks.onMetadata?.(meta);
|
|
374
|
+
}
|
|
250
375
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
251
376
|
callbacks.onComplete?.();
|
|
252
377
|
},
|
|
@@ -259,8 +384,8 @@ async function streamSSE(response, callbacks = {}) {
|
|
|
259
384
|
// ARBI-specific events (dot-prefixed from server)
|
|
260
385
|
"arbi.agent_step": (raw) => {
|
|
261
386
|
const data = JSON.parse(raw);
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
387
|
+
const label = formatAgentStepLabel(data);
|
|
388
|
+
if (label) agentSteps.push(label);
|
|
264
389
|
callbacks.onAgentStep?.(data);
|
|
265
390
|
if (data.t != null) callbacks.onElapsedTime?.(data.t);
|
|
266
391
|
},
|
|
@@ -439,16 +564,34 @@ function formatUserName(user) {
|
|
|
439
564
|
// src/operations/documents.ts
|
|
440
565
|
var documents_exports = {};
|
|
441
566
|
__export(documents_exports, {
|
|
567
|
+
SUPPORTED_EXTENSIONS: () => SUPPORTED_EXTENSIONS,
|
|
442
568
|
deleteDocuments: () => deleteDocuments,
|
|
443
569
|
downloadDocument: () => downloadDocument,
|
|
444
570
|
getDocuments: () => getDocuments,
|
|
445
571
|
getParsedContent: () => getParsedContent,
|
|
446
572
|
listDocuments: () => listDocuments,
|
|
573
|
+
sanitizeFolderPath: () => sanitizeFolderPath,
|
|
447
574
|
updateDocuments: () => updateDocuments,
|
|
448
575
|
uploadFile: () => uploadFile,
|
|
449
|
-
|
|
576
|
+
uploadFiles: () => uploadFiles,
|
|
450
577
|
uploadUrl: () => uploadUrl
|
|
451
578
|
});
|
|
579
|
+
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
580
|
+
".pdf",
|
|
581
|
+
".txt",
|
|
582
|
+
".md",
|
|
583
|
+
".html",
|
|
584
|
+
".doc",
|
|
585
|
+
".docx",
|
|
586
|
+
".rtf",
|
|
587
|
+
".ppt",
|
|
588
|
+
".pptx",
|
|
589
|
+
".xls",
|
|
590
|
+
".xlsx"
|
|
591
|
+
]);
|
|
592
|
+
function sanitizeFolderPath(folderPath) {
|
|
593
|
+
return folderPath.replace(/[^a-zA-Z0-9_\-/]/g, "_").replace(/_{2,}/g, "_");
|
|
594
|
+
}
|
|
452
595
|
async function listDocuments(arbi) {
|
|
453
596
|
return requireData(await arbi.fetch.GET("/v1/document/list"), "Failed to fetch documents");
|
|
454
597
|
}
|
|
@@ -487,22 +630,31 @@ async function getParsedContent(auth, docId, stage) {
|
|
|
487
630
|
});
|
|
488
631
|
return res.json();
|
|
489
632
|
}
|
|
490
|
-
async function uploadFile(auth, workspaceId, fileData, fileName) {
|
|
633
|
+
async function uploadFile(auth, workspaceId, fileData, fileName, options) {
|
|
491
634
|
const formData = new FormData();
|
|
492
635
|
formData.append("files", fileData, fileName);
|
|
636
|
+
const params = new URLSearchParams({ workspace_ext_id: workspaceId });
|
|
637
|
+
if (options?.folder) params.set("folder", sanitizeFolderPath(options.folder));
|
|
493
638
|
const res = await authenticatedFetch({
|
|
494
639
|
...auth,
|
|
495
|
-
path: `/v1/document/upload
|
|
640
|
+
path: `/v1/document/upload?${params.toString()}`,
|
|
496
641
|
method: "POST",
|
|
497
642
|
body: formData
|
|
498
643
|
});
|
|
499
644
|
return res.json();
|
|
500
645
|
}
|
|
501
|
-
async function
|
|
502
|
-
const
|
|
503
|
-
const
|
|
504
|
-
const
|
|
505
|
-
|
|
646
|
+
async function uploadFiles(auth, workspaceId, files, options) {
|
|
647
|
+
const formData = new FormData();
|
|
648
|
+
for (const f of files) formData.append("files", f.data, f.name);
|
|
649
|
+
const params = new URLSearchParams({ workspace_ext_id: workspaceId });
|
|
650
|
+
if (options?.folder) params.set("folder", sanitizeFolderPath(options.folder));
|
|
651
|
+
const res = await authenticatedFetch({
|
|
652
|
+
...auth,
|
|
653
|
+
path: `/v1/document/upload?${params.toString()}`,
|
|
654
|
+
method: "POST",
|
|
655
|
+
body: formData
|
|
656
|
+
});
|
|
657
|
+
return res.json();
|
|
506
658
|
}
|
|
507
659
|
async function downloadDocument(auth, docId) {
|
|
508
660
|
return authenticatedFetch({
|
|
@@ -702,6 +854,8 @@ async function retrieve(options) {
|
|
|
702
854
|
input: query,
|
|
703
855
|
workspace_ext_id: workspaceId,
|
|
704
856
|
stream: false,
|
|
857
|
+
background: false,
|
|
858
|
+
store: true,
|
|
705
859
|
tools,
|
|
706
860
|
...model ? { model } : {}
|
|
707
861
|
};
|
|
@@ -717,6 +871,8 @@ async function queryAssistant(options) {
|
|
|
717
871
|
input: question,
|
|
718
872
|
workspace_ext_id: workspaceId,
|
|
719
873
|
stream: true,
|
|
874
|
+
background: false,
|
|
875
|
+
store: true,
|
|
720
876
|
tools: {
|
|
721
877
|
retrieval_chunk: buildRetrievalChunkTool(docIds),
|
|
722
878
|
retrieval_full_context: buildRetrievalFullContextTool([])
|
|
@@ -1176,11 +1332,12 @@ var Arbi = class {
|
|
|
1176
1332
|
workspaceId ?? this.requireWorkspace(),
|
|
1177
1333
|
shared
|
|
1178
1334
|
),
|
|
1179
|
-
uploadFile: (fileData, fileName,
|
|
1335
|
+
uploadFile: (fileData, fileName, options) => uploadFile(
|
|
1180
1336
|
this.getAuthHeaders(),
|
|
1181
|
-
workspaceId ?? this.requireWorkspace(),
|
|
1337
|
+
options?.workspaceId ?? this.requireWorkspace(),
|
|
1182
1338
|
fileData,
|
|
1183
|
-
fileName
|
|
1339
|
+
fileName,
|
|
1340
|
+
options?.folder ? { folder: options.folder } : void 0
|
|
1184
1341
|
),
|
|
1185
1342
|
download: (docId) => downloadDocument(this.getAuthHeaders(), docId),
|
|
1186
1343
|
getParsedContent: (docId, stage) => getParsedContent(this.getAuthHeaders(), docId, stage)
|
|
@@ -1322,6 +1479,6 @@ var Arbi = class {
|
|
|
1322
1479
|
}
|
|
1323
1480
|
};
|
|
1324
1481
|
|
|
1325
|
-
export { Arbi, ArbiApiError, ArbiError, 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, 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 };
|
|
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 };
|
|
1326
1483
|
//# sourceMappingURL=browser.js.map
|
|
1327
1484
|
//# sourceMappingURL=browser.js.map
|