@arbidocs/sdk 0.3.11 → 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,101 +1,13 @@
1
- import * as _arbidocs_client from '@arbidocs/client';
2
- import { ArbiClient, LoginResult, components, WebSocketServerMessage, WsTaskUpdateMessage } from '@arbidocs/client';
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
+ import '@arbidocs/client';
3
4
 
4
5
  /**
5
- * Core error types and throwing error utilities.
6
+ * Configuration persistence file-based implementation for Node.js environments.
6
7
  *
7
- * Unlike CLI helpers which call process.exit(1), these throw typed errors
8
- * that consumers (CLI, MCP) can catch and handle in their own way.
8
+ * Browser consumers should import from './config-types.ts' directly.
9
9
  */
10
- declare class ArbiError extends Error {
11
- constructor(message: string);
12
- }
13
- declare class ArbiApiError extends ArbiError {
14
- readonly apiError?: unknown;
15
- constructor(message: string, apiError?: unknown);
16
- }
17
- /**
18
- * Check API response and throw on error. Returns narrowed non-null data.
19
- */
20
- declare function requireData<T>(result: {
21
- data?: T;
22
- error?: unknown;
23
- }, message: string): T;
24
- /**
25
- * Check API response for delete/void operations (no data expected).
26
- */
27
- declare function requireOk(result: {
28
- error?: unknown;
29
- }, message: string): void;
30
- /**
31
- * Extract a human-readable message from an unknown error value.
32
- * Centralises the `err instanceof Error ? err.message : String(err)` pattern.
33
- */
34
- declare function getErrorMessage(err: unknown): string;
35
10
 
36
- /**
37
- * Authenticated fetch utility — eliminates repeated raw-fetch boilerplate
38
- * in operations that can't use the typed SDK client (streaming, multipart, etc.).
39
- */
40
- interface AuthHeaders {
41
- baseUrl: string;
42
- accessToken: string;
43
- workspaceKeyHeader: string;
44
- }
45
- interface AuthFetchOptions extends AuthHeaders {
46
- /** URL path relative to baseUrl (e.g. '/v1/document/upload'). */
47
- path: string;
48
- method?: string;
49
- body?: string | FormData | ArrayBuffer | ReadableStream | Blob | null;
50
- /** Extra headers to merge in. */
51
- headers?: Record<string, string>;
52
- }
53
- /**
54
- * Make an authenticated fetch request with standard error handling.
55
- * Automatically sets Authorization + workspace-key headers.
56
- * Throws on non-ok responses with a human-readable message including server error details.
57
- */
58
- declare function authenticatedFetch(options: AuthFetchOptions): Promise<Response>;
59
-
60
- /**
61
- * Configuration persistence — types, interface, and file-based implementation.
62
- *
63
- * Both CLI and MCP share the same ~/.arbi/ config directory.
64
- */
65
- interface CliConfig {
66
- baseUrl: string;
67
- deploymentDomain: string;
68
- selectedWorkspaceId?: string;
69
- autoUpdate?: boolean;
70
- notifications?: boolean;
71
- }
72
- interface CliCredentials {
73
- email: string;
74
- signingPrivateKeyBase64: string;
75
- serverSessionKeyBase64: string;
76
- }
77
- interface ChatSession {
78
- /** Last assistant message ID — used as previous_response_id for follow-ups */
79
- lastMessageExtId: string | null;
80
- /** Conversation external ID — used to restore chat history on restart */
81
- conversationExtId: string | null;
82
- /** Workspace ID where the conversation started — used to detect workspace changes */
83
- workspaceId: string | null;
84
- }
85
- interface ConfigStore {
86
- getConfig(): CliConfig | null;
87
- saveConfig(config: CliConfig): void;
88
- updateConfig(updates: Partial<CliConfig>): void;
89
- requireConfig(): CliConfig;
90
- getCredentials(): CliCredentials | null;
91
- saveCredentials(creds: CliCredentials): void;
92
- deleteCredentials(): void;
93
- requireCredentials(): CliCredentials;
94
- getChatSession(): ChatSession;
95
- saveChatSession(session: ChatSession): void;
96
- updateChatSession(updates: Partial<ChatSession>): void;
97
- clearChatSession(): void;
98
- }
99
11
  declare class FileConfigStore implements ConfigStore {
100
12
  private readonly configDir;
101
13
  private readonly configFile;
@@ -117,2907 +29,62 @@ declare class FileConfigStore implements ConfigStore {
117
29
  saveChatSession(session: ChatSession): void;
118
30
  updateChatSession(updates: Partial<ChatSession>): void;
119
31
  clearChatSession(): void;
120
- }
121
-
122
- /**
123
- * Parameterized authentication functions.
124
- *
125
- * Unlike CLI's client.ts, these take explicit params instead of reading from disk.
126
- * This allows both CLI and MCP to use them with their own config sources.
127
- */
128
-
129
- interface AuthenticatedClient {
130
- arbi: ArbiClient;
131
- loginResult: LoginResult;
132
- }
133
- interface AuthContext {
134
- arbi: ArbiClient;
135
- loginResult: LoginResult;
136
- config: CliConfig;
137
- }
138
- interface WorkspaceContext extends AuthContext {
139
- workspaceId: string;
140
- accessToken: string;
141
- workspaceKeyHeader: string;
142
- }
143
- /** Minimal workspace shape required by formatWorkspaceChoices. */
144
- interface WorkspaceForChoice {
145
- name: string;
146
- external_id: string;
147
- shared_document_count: number;
148
- private_document_count: number;
149
- }
150
- /**
151
- * Format a list of workspaces into prompt-friendly choices.
152
- * Returns `{ name, value, description }` objects suitable for @inquirer/prompts
153
- * or any similar select component.
154
- */
155
- declare function formatWorkspaceChoices(wsList: WorkspaceForChoice[]): Array<{
156
- name: string;
157
- value: string;
158
- description: string;
159
- }>;
160
- /**
161
- * Create an SDK client, init sodium, and log in with stored signing key.
162
- * Returns the client + login result (which includes serverSessionKey).
163
- */
164
- declare function createAuthenticatedClient(config: CliConfig, creds: CliCredentials, store: ConfigStore): Promise<AuthenticatedClient>;
165
- /**
166
- * Interactive (password-based) login flow.
167
- *
168
- * Creates an SDK client, initializes sodium, authenticates with email/password,
169
- * and persists the derived credentials to the config store.
170
- *
171
- * Use this for CLI/TUI login commands. For session recovery from stored keys,
172
- * use createAuthenticatedClient() instead.
173
- */
174
- declare function performPasswordLogin(config: CliConfig, email: string, password: string, store: ConfigStore): Promise<AuthContext>;
175
- /**
176
- * Decrypt wrapped workspace key and set it as the active workspace header.
177
- */
178
- declare function selectWorkspace(arbi: ArbiClient, workspaceId: string, wrappedKey: string, serverSessionKey: Uint8Array, signingPrivateKeyBase64: string): Promise<void>;
179
- /**
180
- * Generate an encrypted workspace key for the given workspace.
181
- * Used for operations that need a key for a workspace other than the current one
182
- * (e.g., copy documents to a target workspace).
183
- */
184
- declare function generateEncryptedWorkspaceKey(arbi: ArbiClient, wrappedKey: string, serverSessionKey: Uint8Array, signingPrivateKeyBase64: string): Promise<string>;
185
- /**
186
- * Find a workspace by ID in the user's workspace list, select it, and return workspace info.
187
- */
188
- declare function selectWorkspaceById(arbi: ArbiClient, workspaceId: string, serverSessionKey: Uint8Array, signingPrivateKeyBase64: string): Promise<{
189
- external_id: string;
190
- name: string;
191
- wrapped_key: string;
192
- }>;
193
- /**
194
- * Authenticate and return the SDK client + config.
195
- * Throws ArbiError instead of calling process.exit.
196
- */
197
- declare function resolveAuth(store: ConfigStore): Promise<AuthContext>;
198
- /**
199
- * Authenticate, resolve workspace, and set up headers.
200
- * Throws ArbiError instead of calling process.exit.
201
- */
202
- declare function resolveWorkspace(store: ConfigStore, workspaceOpt?: string): Promise<WorkspaceContext>;
203
-
204
- /**
205
- * SSE event types — re-exported from the auto-generated OpenAPI schema.
206
- *
207
- * Consumers should import these from '@arbidocs/sdk' (or '/browser')
208
- * rather than reaching into '@arbidocs/client' directly.
209
- */
210
-
211
- type ResponseCreatedEvent = components['schemas']['ResponseCreatedEvent'];
212
- type ResponseCompletedEvent = components['schemas']['ResponseCompletedEvent'];
213
- type ResponseFailedEvent = components['schemas']['ResponseFailedEvent'];
214
- type ResponseOutputTextDeltaEvent = components['schemas']['ResponseOutputTextDeltaEvent'];
215
- type ResponseOutputTextDoneEvent = components['schemas']['ResponseOutputTextDoneEvent'];
216
- type ResponseOutputItemAddedEvent = components['schemas']['ResponseOutputItemAddedEvent'];
217
- type ResponseOutputItemDoneEvent = components['schemas']['ResponseOutputItemDoneEvent'];
218
- type ResponseContentPartAddedEvent = components['schemas']['ResponseContentPartAddedEvent'];
219
- type AgentStepEvent = components['schemas']['AgentStepEvent'];
220
- type UserInputRequestEvent = components['schemas']['UserInputRequestEvent'];
221
- type ArtifactEvent = components['schemas']['ArtifactEvent'];
222
- type UserMessageEvent = components['schemas']['UserMessageEvent'];
223
- type MessageMetadataPayload = components['schemas']['MessageMetadataPayload'];
224
- type ResponseUsage = components['schemas']['ResponseUsage'];
225
- type OutputTokensDetails = components['schemas']['OutputTokensDetails'];
226
- /** Convenience type — what onStreamStart callbacks receive. */
227
- type SSEStreamStartData = {
228
- assistant_message_ext_id: string;
229
- };
230
-
231
- /**
232
- * Server-Sent Events (SSE) parsing utilities.
233
- *
234
- * Extracted from CLI ask.ts for shared use by CLI and MCP.
235
- */
236
-
237
- interface SSEEvent {
238
- event: string;
239
- data: string;
240
- }
241
- /**
242
- * Parse SSE events from a chunk of text, combining with a buffer
243
- * of incomplete data from previous chunks.
244
- *
245
- * Returns parsed events and any remaining incomplete data.
246
- */
247
- declare function parseSSEEvents(chunk: string, buffer: string): {
248
- events: SSEEvent[];
249
- remaining: string;
250
- };
251
- /**
252
- * Callbacks for streaming SSE events. All callbacks are optional —
253
- * omitted callbacks simply ignore that event type.
254
- */
255
- interface SSEStreamCallbacks {
256
- onStreamStart?: (data: SSEStreamStartData) => void;
257
- onToken?: (content: string) => void;
258
- onTextDone?: (text: string) => void;
259
- onOutputItemAdded?: (data: ResponseOutputItemAddedEvent) => void;
260
- onOutputItemDone?: (data: ResponseOutputItemDoneEvent) => void;
261
- onContentPartAdded?: (data: ResponseContentPartAddedEvent) => void;
262
- onAgentStep?: (data: AgentStepEvent) => void;
263
- onError?: (message: string) => void;
264
- onUserMessage?: (data: UserMessageEvent) => void;
265
- onMetadata?: (data: MessageMetadataPayload) => void;
266
- onUserInputRequest?: (data: UserInputRequestEvent) => void;
267
- onArtifact?: (data: ArtifactEvent) => void;
268
- onElapsedTime?: (t: number) => void;
269
- onUsage?: (usage: ResponseUsage) => void;
270
- onComplete?: () => void;
271
- }
272
- /**
273
- * Result returned after the SSE stream is fully consumed.
274
- */
275
- interface SSEStreamResult {
276
- text: string;
277
- assistantMessageExtId: string | null;
278
- agentSteps: string[];
279
- errors: string[];
280
- userMessage: UserMessageEvent | null;
281
- metadata: MessageMetadataPayload | null;
282
- artifacts: ArtifactEvent[];
283
- usage: ResponseUsage | null;
284
- }
285
- /**
286
- * Stream SSE events from a Response, invoking callbacks as events arrive.
287
- *
288
- * This is the primary streaming function — use it when you need real-time
289
- * event handling (CLI streaming to stdout, TUI rendering, etc.).
290
- *
291
- * Also accumulates the full response and returns it, so callers can use
292
- * both the streaming callbacks and the final result.
293
- */
294
- declare function streamSSE(response: Response, callbacks?: SSEStreamCallbacks): Promise<SSEStreamResult>;
295
- /**
296
- * Consume an entire SSE stream without streaming callbacks.
297
- * Convenience alias for `streamSSE(response)`.
298
- */
299
- declare const consumeSSEStream: typeof streamSSE;
300
-
301
- /**
302
- * WebSocket connection manager.
303
- *
304
- * Uses Node.js native WebSocket (available in Node 22+).
305
- * Authenticates via SDK helpers, routes typed messages to the consumer.
306
- */
307
-
308
- interface WsConnection {
309
- close: () => void;
310
- }
311
- interface ConnectOptions {
312
- baseUrl: string;
313
- accessToken: string;
314
- onMessage: (msg: WebSocketServerMessage) => void;
315
- onClose?: (code: number, reason: string) => void;
316
- }
317
- interface ReconnectOptions extends ConnectOptions {
318
- maxRetries?: number;
319
- initialDelayMs?: number;
320
- onReconnecting?: (attempt: number, maxRetries: number) => void;
321
- onReconnected?: () => void;
322
- onReconnectFailed?: () => void;
323
- }
324
- interface ReconnectableWsConnection {
325
- close: () => void;
326
- }
327
- /**
328
- * Open a WebSocket, authenticate, and start routing messages.
329
- *
330
- * Resolves after a successful `auth_result`, rejects on auth failure or timeout.
331
- * Subsequent messages are dispatched to `onMessage`.
332
- */
333
- declare function connectWebSocket(options: ConnectOptions): Promise<WsConnection>;
334
- /**
335
- * Connect WebSocket with automatic reconnection on disconnect.
336
- *
337
- * Initial connection throws on failure (same as connectWebSocket).
338
- * After successful auth, disconnects trigger exponential backoff reconnection.
339
- * Call close() on the returned handle to stop reconnection attempts.
340
- */
341
- declare function connectWithReconnect(options: ReconnectOptions): Promise<ReconnectableWsConnection>;
342
- interface DocumentWaiterOptions {
343
- /** Base URL of the ARBI server (e.g. "https://app.arbi.city"). */
344
- baseUrl: string;
345
- /** JWT access token for WebSocket authentication. */
346
- accessToken: string;
347
- /** Optional callback invoked for every task_update on tracked documents. */
348
- onStatus?: (msg: WsTaskUpdateMessage) => void;
349
- }
350
- interface DocumentWaiter {
351
- /** Register document IDs to track. Can be called multiple times. */
352
- addDocIds(ids: string[]): void;
353
- /** Block until all tracked documents reach terminal status. */
354
- waitUntilDone(timeoutMs?: number): Promise<Map<string, string>>;
355
- /** Close the WebSocket without waiting. */
356
- close(): void;
357
- }
358
- /**
359
- * Open a WebSocket and start collecting document status events.
360
- *
361
- * Call this BEFORE uploading so no events are missed. Then call `addDocIds()`
362
- * once you know the IDs, and `waitUntilDone()` to block until all reach a
363
- * terminal status (completed, failed, or skipped).
364
- *
365
- * Mirrors the backend SDK's `ArbiWebSocket.wait_for_docs()` pattern.
366
- *
367
- * @example
368
- * ```ts
369
- * const waiter = createDocumentWaiter({ baseUrl, accessToken })
370
- * const result = await uploadDocuments(...)
371
- * waiter.addDocIds(result.doc_ext_ids)
372
- * const statuses = await waiter.waitUntilDone(120_000)
373
- * ```
374
- */
375
- declare function createDocumentWaiter(options: DocumentWaiterOptions): DocumentWaiter;
376
- type MessageLevel = 'info' | 'success' | 'error' | 'warning';
377
- interface FormattedWsMessage {
378
- text: string;
379
- level: MessageLevel;
380
- }
381
- /**
382
- * Format a WebSocket message into display text + severity level.
383
- * Shared by TUI (toasts) and CLI (stderr lines) — single source of truth.
384
- */
385
- declare function formatWsMessage(msg: WebSocketServerMessage): FormattedWsMessage;
386
-
387
- /**
388
- * Shared formatting utilities.
389
- */
390
- /**
391
- * Converts file size in bytes to human-readable format.
392
- *
393
- * @param bytes File size in bytes
394
- * @param fallback String to return for null/undefined values (default: 'N/A')
395
- * @returns Formatted string (e.g., "1.5 MB", "250 KB")
396
- */
397
- declare function formatFileSize(bytes: number | null | undefined, fallback?: string): string;
398
- /** Minimal user shape used for display formatting. */
399
- type UserInfo = {
400
- external_id?: string;
401
- email?: string;
402
- given_name?: string;
403
- family_name?: string;
404
- };
405
- /**
406
- * Format a user's display name from given_name + family_name.
407
- * Returns empty string if no name parts are available.
408
- */
409
- declare function formatUserName(user: UserInfo | null | undefined): string;
410
-
411
- /**
412
- * Assistant operations — retrieve (search-only) and query (with LLM).
413
- *
414
- * retrieve: Uses the typed SDK route POST /v1/assistant/retrieve.
415
- * Returns matching chunks without LLM generation.
416
- *
417
- * queryAssistant: Returns the raw Response for SSE streaming.
418
- * Uses raw fetch because the SDK client doesn't support streaming responses.
419
- */
420
-
421
- declare function buildRetrievalChunkTool(docIds: string[], searchMode?: 'semantic' | 'keyword' | 'hybrid'): components['schemas']['RetrievalChunkTool'];
422
- declare function buildRetrievalFullContextTool(docIds: string[]): components['schemas']['RetrievalFullContextTool'];
423
- declare function buildRetrievalTocTool(docIds: string[]): components['schemas']['RetrievalTOCTool'];
424
- interface RetrieveOptions {
425
- arbi: ArbiClient;
426
- workspaceId: string;
427
- query: string;
428
- docIds: string[];
429
- searchMode?: 'semantic' | 'keyword' | 'hybrid';
430
- fullContextDocIds?: string[];
431
- tocDocIds?: string[];
432
- model?: string;
433
- }
434
- interface ChunkMetadata {
435
- doc_ext_id?: string | null;
436
- doc_title?: string | null;
437
- chunk_ext_id: string;
438
- chunk_pg_idx: number;
439
- chunk_doc_idx: number;
440
- page_number: number;
441
- score?: number | null;
442
- rerank_score?: number | null;
443
- tokens?: number | null;
444
- created_at: string;
445
- heading: boolean;
446
- }
447
- interface Chunk {
448
- metadata: ChunkMetadata;
449
- content: string;
450
- }
451
- interface RetrieveResult {
452
- retrieval_chunk?: {
453
- tool_responses: Record<string, Chunk[]>;
454
- };
455
- retrieval_full_context?: {
456
- tool_responses: Record<string, Chunk[]>;
457
- };
458
- retrieval_toc?: {
459
- tool_responses: Record<string, Record<string, unknown>[]>;
460
- };
461
- }
462
- /**
463
- * Search documents and return matching chunks without LLM generation.
464
- * Uses the typed SDK route POST /v1/assistant/retrieve.
465
- */
466
- declare function retrieve(options: RetrieveOptions): Promise<RetrieveResult>;
467
- interface AssistantQueryOptions extends AuthHeaders {
468
- workspaceId: string;
469
- question: string;
470
- docIds: string[];
471
- previousResponseId?: string | null;
472
- model?: string;
473
- }
474
- /**
475
- * Send a query to the RAG assistant. Returns the raw Response
476
- * so the caller can stream or buffer as needed.
477
- *
478
- * Uses raw fetch (not the SDK client) because we need the streaming
479
- * Response body — the SDK client consumes the body to parse JSON.
480
- */
481
- declare function queryAssistant(options: AssistantQueryOptions): Promise<Response>;
482
- /**
483
- * Respond to an agent's question during a human-in-the-loop workflow.
484
- * The assistant_message_ext_id identifies which agent message to answer.
485
- */
486
- declare function respondToAgent(arbi: ArbiClient, assistantMessageExtId: string, answer: string): Promise<unknown>;
487
-
488
- type assistant_AssistantQueryOptions = AssistantQueryOptions;
489
- type assistant_Chunk = Chunk;
490
- type assistant_ChunkMetadata = ChunkMetadata;
491
- type assistant_RetrieveOptions = RetrieveOptions;
492
- type assistant_RetrieveResult = RetrieveResult;
493
- declare const assistant_buildRetrievalChunkTool: typeof buildRetrievalChunkTool;
494
- declare const assistant_buildRetrievalFullContextTool: typeof buildRetrievalFullContextTool;
495
- declare const assistant_buildRetrievalTocTool: typeof buildRetrievalTocTool;
496
- declare const assistant_queryAssistant: typeof queryAssistant;
497
- declare const assistant_respondToAgent: typeof respondToAgent;
498
- declare const assistant_retrieve: typeof retrieve;
499
- declare namespace assistant {
500
- export { type assistant_AssistantQueryOptions as AssistantQueryOptions, type assistant_Chunk as Chunk, type assistant_ChunkMetadata as ChunkMetadata, type assistant_RetrieveOptions as RetrieveOptions, type assistant_RetrieveResult as RetrieveResult, assistant_buildRetrievalChunkTool as buildRetrievalChunkTool, assistant_buildRetrievalFullContextTool as buildRetrievalFullContextTool, assistant_buildRetrievalTocTool as buildRetrievalTocTool, assistant_queryAssistant as queryAssistant, assistant_respondToAgent as respondToAgent, assistant_retrieve as retrieve };
501
- }
502
-
503
- /**
504
- * Contact operations — list, add, remove.
505
- */
506
-
507
- declare function listContacts(arbi: ArbiClient): Promise<{
508
- external_id: string;
509
- email: string;
510
- user?: {
511
- external_id: string;
512
- email: string;
513
- given_name: string;
514
- family_name: string;
515
- picture?: string | null | undefined;
516
- encryption_public_key: string;
517
- } | null | undefined;
518
- status: "invitation_pending" | "invitation_expired" | "registered";
519
- created_at: string;
520
- }[]>;
521
- declare function addContacts(arbi: ArbiClient, emails: string[]): Promise<{
522
- external_id: string;
523
- email: string;
524
- user?: {
525
- external_id: string;
526
- email: string;
527
- given_name: string;
528
- family_name: string;
529
- picture?: string | null | undefined;
530
- encryption_public_key: string;
531
- } | null | undefined;
532
- status: "invitation_pending" | "invitation_expired" | "registered";
533
- created_at: string;
534
- }[]>;
535
- declare function removeContacts(arbi: ArbiClient, contactIds: string[]): Promise<void>;
536
- /**
537
- * Group contacts by registration status.
538
- * Returns registered contacts and pending (not yet registered) contacts.
539
- */
540
- declare function groupContactsByStatus<T extends {
541
- status: string;
542
- }>(contactList: T[]): {
543
- registered: T[];
544
- pending: T[];
545
- };
546
-
547
- declare const contacts_addContacts: typeof addContacts;
548
- declare const contacts_groupContactsByStatus: typeof groupContactsByStatus;
549
- declare const contacts_listContacts: typeof listContacts;
550
- declare const contacts_removeContacts: typeof removeContacts;
551
- declare namespace contacts {
552
- export { contacts_addContacts as addContacts, contacts_groupContactsByStatus as groupContactsByStatus, contacts_listContacts as listContacts, contacts_removeContacts as removeContacts };
553
- }
554
-
555
- /**
556
- * File operations — OpenAI-compatible Files API (list, get, delete, upload, content).
557
- */
558
-
559
- type FileObject = components['schemas']['FileObject'];
560
- type FileDeleteResponse = components['schemas']['FileDeleteResponse'];
561
- type FileListResponse = components['schemas']['FileListResponse'];
562
-
563
- interface ListFilesOptions {
564
- purpose?: string | null;
565
- limit?: number;
566
- order?: string;
567
- after?: string | null;
568
- }
569
- declare function listFiles(arbi: ArbiClient, options?: ListFilesOptions): Promise<{
570
- object: string;
571
- data: {
572
- id: string;
573
- object: string;
574
- bytes: number;
575
- created_at: number;
576
- filename: string;
577
- purpose: string;
578
- status: string;
579
- expires_at?: number | null | undefined;
580
- status_details?: string | null | undefined;
581
- }[];
582
- has_more: boolean;
583
- first_id?: string | null | undefined;
584
- last_id?: string | null | undefined;
585
- }>;
586
- declare function getFile(arbi: ArbiClient, fileId: string): Promise<{
587
- id: string;
588
- object: string;
589
- bytes: number;
590
- created_at: number;
591
- filename: string;
592
- purpose: string;
593
- status: string;
594
- expires_at?: number | null | undefined;
595
- status_details?: string | null | undefined;
596
- }>;
597
- declare function deleteFile(arbi: ArbiClient, fileId: string): Promise<{
598
- id: string;
599
- object: string;
600
- deleted: boolean;
601
- }>;
602
- /**
603
- * Upload a file via the OpenAI-compatible Files API.
604
- * Uses raw fetch for multipart upload.
605
- */
606
- declare function uploadFile$1(auth: AuthHeaders, fileData: Blob, fileName: string, purpose?: string): Promise<FileObject>;
607
- /**
608
- * Get file content (binary). Returns the raw Response for the caller to handle.
609
- */
610
- declare function getFileContent(auth: AuthHeaders, fileId: string): Promise<Response>;
611
-
612
- type files_FileDeleteResponse = FileDeleteResponse;
613
- type files_FileListResponse = FileListResponse;
614
- type files_FileObject = FileObject;
615
- type files_ListFilesOptions = ListFilesOptions;
616
- declare const files_deleteFile: typeof deleteFile;
617
- declare const files_getFile: typeof getFile;
618
- declare const files_getFileContent: typeof getFileContent;
619
- declare const files_listFiles: typeof listFiles;
620
- declare namespace files {
621
- export { type files_FileDeleteResponse as FileDeleteResponse, type files_FileListResponse as FileListResponse, type files_FileObject as FileObject, type files_ListFilesOptions as ListFilesOptions, files_deleteFile as deleteFile, files_getFile as getFile, files_getFileContent as getFileContent, files_listFiles as listFiles, uploadFile$1 as uploadFile };
622
- }
623
-
624
- /**
625
- * High-level convenience class that wraps the full ARBI stack into a simple API.
626
- *
627
- * Handles SDK client creation, sodium initialization, authentication,
628
- * workspace key decryption, and delegates to all operations modules.
629
- *
630
- * Usage:
631
- * const arbi = new Arbi({ url: 'https://arbi.mycompany.com' })
632
- * await arbi.login('user@example.com', 'password')
633
- * const workspaces = await arbi.workspaces.list()
634
- * await arbi.selectWorkspace(workspaces[0].external_id)
635
- * const docs = await arbi.documents.list()
636
- */
637
-
638
- type DocUpdateRequest$1 = components['schemas']['DocUpdateRequest'];
639
- type WorkspaceUpdateRequest$1 = components['schemas']['WorkspaceUpdateRequest'];
640
- type UpdateTagRequest$1 = components['schemas']['UpdateTagRequest'];
641
- type TagFormat = components['schemas']['TagFormat'];
642
- type CitationData$1 = components['schemas']['CitationData'];
643
- type UserSettingsUpdate$1 = components['schemas']['UserSettingsUpdate'];
644
- type ConfigUpdateData$1 = components['schemas']['ConfigUpdateData'];
645
-
646
- interface ArbiOptions {
647
- /** Backend API URL (e.g. 'https://arbi.mycompany.com') */
648
- url: string;
649
- /** Deployment domain for key derivation. Defaults to hostname of url. */
650
- deploymentDomain?: string;
651
- /** Include credentials (cookies) in requests. Default: 'omit' for SDK consumers. */
652
- credentials?: 'include' | 'omit' | 'same-origin';
653
- }
654
- interface QueryOptions {
655
- /** Document IDs to search against */
656
- docIds: string[];
657
- /** Previous response ID for follow-up questions */
658
- previousResponseId?: string | null;
659
- /** Model to use for generation */
660
- model?: string;
661
- /** Called for each streaming token */
662
- onToken?: (content: string) => void;
663
- /** Called when stream starts */
664
- onStreamStart?: (data: SSEStreamStartData) => void;
665
- /** Called for each agent step */
666
- onAgentStep?: (data: AgentStepEvent) => void;
667
- /** Called on stream error */
668
- onError?: (message: string) => void;
669
- /** Called when a user message event is received */
670
- onUserMessage?: (data: UserMessageEvent) => void;
671
- /** Called when message metadata is received */
672
- onMetadata?: (data: MessageMetadataPayload) => void;
673
- /** Called when the agent requests user input */
674
- onUserInputRequest?: (data: UserInputRequestEvent) => void;
675
- /** Called when an artifact event is received */
676
- onArtifact?: (data: ArtifactEvent) => void;
677
- /** Called when backend elapsed time is received */
678
- onElapsedTime?: (t: number) => void;
679
- /** Called when stream completes */
680
- onComplete?: () => void;
681
- }
682
- declare class Arbi {
683
- private client;
684
- private loginResult;
685
- private currentWorkspaceId;
686
- private readonly options;
687
- constructor(options: ArbiOptions);
688
- /** Initialize the SDK client and sodium crypto. Called automatically by login(). */
689
- init(): Promise<ArbiClient>;
690
32
  /**
691
- * Request a verification email for registration.
692
- * The user will receive an email with a 3-word verification code.
33
+ * Try to resolve config from multiple sources, in priority order:
34
+ *
35
+ * 1. Existing `~/.arbi/config.json` (highest priority)
36
+ * 2. `ARBI_SERVER_URL` environment variable
37
+ * 3. `.env` file in `searchDir` → read `VITE_DEPLOYMENT_DOMAIN`
38
+ * 4. `public/config.json` in `searchDir` → read `deployment.domain`
39
+ * 5. Default to `https://localhost`
40
+ *
41
+ * Returns `{ config, source }` where source describes where the config came from.
42
+ * Saves auto-detected config to disk so subsequent calls use the fast path.
693
43
  */
694
- requestVerification(email: string): Promise<void>;
695
- /**
696
- * Register a new account using the verification code received by email.
697
- */
698
- register(params: {
699
- email: string;
700
- password: string;
701
- verificationCode: string;
702
- firstName?: string;
703
- lastName?: string;
704
- }): Promise<void>;
705
- /**
706
- * Log in with email and password.
707
- * Initializes the SDK client if not already done.
708
- */
709
- login(email: string, password: string): Promise<void>;
44
+ resolveConfigWithFallbacks(searchDir?: string): {
45
+ config: CliConfig;
46
+ source: string;
47
+ };
710
48
  /**
711
- * Recover a session using a stored signing private key (base64).
712
- * Useful for session recovery without re-entering the password.
49
+ * Read VITE_DEPLOYMENT_DOMAIN from a .env file.
713
50
  */
714
- loginWithKey(email: string, signingPrivateKeyBase64: string): Promise<void>;
51
+ private readDotEnvDomain;
715
52
  /**
716
- * Select a workspace by ID. Fetches the workspace list, finds the matching
717
- * workspace, decrypts the wrapped key, and sets up auth headers.
53
+ * Read deployment.domain from a public/config.json file.
718
54
  */
719
- selectWorkspace(workspaceId: string): Promise<void>;
720
- /** Log out and clear internal state. */
721
- logout(): Promise<void>;
722
- /** Get the underlying ArbiClient (throws if not initialized). */
723
- getClient(): ArbiClient;
724
- /** Get the current workspace ID (throws if none selected). */
725
- getWorkspaceId(): string;
726
- /** Check if the user is logged in. */
727
- get isLoggedIn(): boolean;
728
- /** Check if a workspace is selected. */
729
- get hasWorkspace(): boolean;
730
- private getAuthHeaders;
731
- readonly workspaces: {
732
- list: () => Promise<{
733
- external_id: string;
734
- name: string;
735
- description: string | null;
736
- is_public: boolean;
737
- created_by_ext_id: string;
738
- updated_by_ext_id?: string | null | undefined;
739
- created_at: string;
740
- updated_at: string;
741
- wrapped_key?: string | null | undefined;
742
- shared_conversation_count: number;
743
- private_conversation_count: number;
744
- shared_document_count: number;
745
- private_document_count: number;
746
- user_files_mb: number;
747
- users: {
748
- user: {
749
- external_id: string;
750
- email: string;
751
- given_name: string;
752
- family_name: string;
753
- picture?: string | null | undefined;
754
- encryption_public_key: string;
755
- };
756
- role: components["schemas"]["WorkspaceRole"];
757
- joined_at: string;
758
- conversation_count: number;
759
- document_count: number;
760
- }[];
761
- }[]>;
762
- create: (name: string, description?: string | null, isPublic?: boolean) => Promise<{
763
- external_id: string;
764
- name: string;
765
- description: string | null;
766
- is_public: boolean;
767
- created_by_ext_id: string;
768
- updated_by_ext_id?: string | null | undefined;
769
- created_at: string;
770
- updated_at: string;
771
- wrapped_key?: string | null | undefined;
772
- shared_conversation_count: number;
773
- private_conversation_count: number;
774
- shared_document_count: number;
775
- private_document_count: number;
776
- user_files_mb: number;
777
- users: {
778
- user: {
779
- external_id: string;
780
- email: string;
781
- given_name: string;
782
- family_name: string;
783
- picture?: string | null | undefined;
784
- encryption_public_key: string;
785
- };
786
- role: components["schemas"]["WorkspaceRole"];
787
- joined_at: string;
788
- conversation_count: number;
789
- document_count: number;
790
- }[];
791
- }>;
792
- delete: (workspaceIds: string[]) => Promise<void>;
793
- update: (body: WorkspaceUpdateRequest$1) => Promise<{
794
- external_id: string;
795
- name: string;
796
- description: string | null;
797
- is_public: boolean;
798
- created_by_ext_id: string;
799
- updated_by_ext_id?: string | null | undefined;
800
- created_at: string;
801
- updated_at: string;
802
- wrapped_key?: string | null | undefined;
803
- shared_conversation_count: number;
804
- private_conversation_count: number;
805
- shared_document_count: number;
806
- private_document_count: number;
807
- user_files_mb: number;
808
- users: {
809
- user: {
810
- external_id: string;
811
- email: string;
812
- given_name: string;
813
- family_name: string;
814
- picture?: string | null | undefined;
815
- encryption_public_key: string;
816
- };
817
- role: components["schemas"]["WorkspaceRole"];
818
- joined_at: string;
819
- conversation_count: number;
820
- document_count: number;
821
- }[];
822
- }>;
823
- listUsers: () => Promise<{
824
- user: {
825
- external_id: string;
826
- email: string;
827
- given_name: string;
828
- family_name: string;
829
- picture?: string | null | undefined;
830
- encryption_public_key: string;
831
- };
832
- role: components["schemas"]["WorkspaceRole"];
833
- joined_at: string;
834
- conversation_count: number;
835
- document_count: number;
836
- }[]>;
837
- addUsers: (emails: string[], role?: "owner" | "collaborator" | "guest") => Promise<{
838
- user: {
839
- external_id: string;
840
- email: string;
841
- given_name: string;
842
- family_name: string;
843
- picture?: string | null | undefined;
844
- encryption_public_key: string;
845
- };
846
- role: components["schemas"]["WorkspaceRole"];
847
- joined_at: string;
848
- conversation_count: number;
849
- document_count: number;
850
- }[]>;
851
- removeUsers: (userIds: string[]) => Promise<void>;
852
- setUserRole: (userIds: string[], role: "owner" | "collaborator" | "guest") => Promise<{
853
- user: {
854
- external_id: string;
855
- email: string;
856
- given_name: string;
857
- family_name: string;
858
- picture?: string | null | undefined;
859
- encryption_public_key: string;
860
- };
861
- role: components["schemas"]["WorkspaceRole"];
862
- joined_at: string;
863
- conversation_count: number;
864
- document_count: number;
865
- }[]>;
866
- copyDocuments: (targetWorkspaceId: string, docIds: string[], targetWorkspaceKey: string) => Promise<{
867
- detail: string;
868
- documents_copied: number;
869
- results: {
870
- source_doc_ext_id: string;
871
- success: boolean;
872
- new_doc_ext_id?: string | null | undefined;
873
- error?: string | null | undefined;
874
- }[];
875
- }>;
876
- };
877
- readonly documents: {
878
- list: () => Promise<{
879
- external_id: string;
880
- workspace_ext_id: string;
881
- file_name?: string | null | undefined;
882
- status?: string | null | undefined;
883
- n_pages?: number | null | undefined;
884
- n_chunks?: number | null | undefined;
885
- tokens?: number | null | undefined;
886
- file_type?: string | null | undefined;
887
- file_size?: number | null | undefined;
888
- storage_type?: string | null | undefined;
889
- storage_uri?: string | null | undefined;
890
- content_hash?: string | null | undefined;
891
- shared?: boolean | null | undefined;
892
- re_ocred?: boolean | null | undefined;
893
- config_ext_id?: string | null | undefined;
894
- parent_ext_id?: string | null | undefined;
895
- created_by_ext_id: string;
896
- updated_by_ext_id?: string | null | undefined;
897
- created_at: string;
898
- updated_at: string;
899
- wp_type?: string | null | undefined;
900
- doctags: {
901
- doc_ext_id: string;
902
- tag_ext_id: string;
903
- note?: string | null | undefined;
904
- citations?: {
905
- [x: string]: {
906
- chunk_ids: string[];
907
- statement: string;
908
- offset_start: number;
909
- offset_end: number;
910
- };
911
- } | null | undefined;
912
- created_by_ext_id: string;
913
- updated_by_ext_id?: string | null | undefined;
914
- created_at: string;
915
- updated_at: string;
916
- }[];
917
- doc_metadata?: {
918
- doc_nature?: string | null | undefined;
919
- doc_author?: string | null | undefined;
920
- doc_subject?: string | null | undefined;
921
- doc_date?: string | null | undefined;
922
- title?: string | null | undefined;
923
- } | null | undefined;
924
- }[]>;
925
- get: (externalIds: string[]) => Promise<{
926
- external_id: string;
927
- workspace_ext_id: string;
928
- file_name?: string | null | undefined;
929
- status?: string | null | undefined;
930
- n_pages?: number | null | undefined;
931
- n_chunks?: number | null | undefined;
932
- tokens?: number | null | undefined;
933
- file_type?: string | null | undefined;
934
- file_size?: number | null | undefined;
935
- storage_type?: string | null | undefined;
936
- storage_uri?: string | null | undefined;
937
- content_hash?: string | null | undefined;
938
- shared?: boolean | null | undefined;
939
- re_ocred?: boolean | null | undefined;
940
- config_ext_id?: string | null | undefined;
941
- parent_ext_id?: string | null | undefined;
942
- created_by_ext_id: string;
943
- updated_by_ext_id?: string | null | undefined;
944
- created_at: string;
945
- updated_at: string;
946
- wp_type?: string | null | undefined;
947
- doctags: {
948
- doc_ext_id: string;
949
- tag_ext_id: string;
950
- note?: string | null | undefined;
951
- citations?: {
952
- [x: string]: {
953
- chunk_ids: string[];
954
- statement: string;
955
- offset_start: number;
956
- offset_end: number;
957
- };
958
- } | null | undefined;
959
- created_by_ext_id: string;
960
- updated_by_ext_id?: string | null | undefined;
961
- created_at: string;
962
- updated_at: string;
963
- }[];
964
- doc_metadata?: {
965
- doc_nature?: string | null | undefined;
966
- doc_author?: string | null | undefined;
967
- doc_subject?: string | null | undefined;
968
- doc_date?: string | null | undefined;
969
- title?: string | null | undefined;
970
- } | null | undefined;
971
- }[]>;
972
- delete: (externalIds: string[]) => Promise<void>;
973
- update: (documents: DocUpdateRequest$1[]) => Promise<{
974
- external_id: string;
975
- workspace_ext_id: string;
976
- file_name?: string | null | undefined;
977
- status?: string | null | undefined;
978
- n_pages?: number | null | undefined;
979
- n_chunks?: number | null | undefined;
980
- tokens?: number | null | undefined;
981
- file_type?: string | null | undefined;
982
- file_size?: number | null | undefined;
983
- storage_type?: string | null | undefined;
984
- storage_uri?: string | null | undefined;
985
- content_hash?: string | null | undefined;
986
- shared?: boolean | null | undefined;
987
- re_ocred?: boolean | null | undefined;
988
- config_ext_id?: string | null | undefined;
989
- parent_ext_id?: string | null | undefined;
990
- created_by_ext_id: string;
991
- updated_by_ext_id?: string | null | undefined;
992
- created_at: string;
993
- updated_at: string;
994
- wp_type?: string | null | undefined;
995
- doctags: {
996
- doc_ext_id: string;
997
- tag_ext_id: string;
998
- note?: string | null | undefined;
999
- citations?: {
1000
- [x: string]: {
1001
- chunk_ids: string[];
1002
- statement: string;
1003
- offset_start: number;
1004
- offset_end: number;
1005
- };
1006
- } | null | undefined;
1007
- created_by_ext_id: string;
1008
- updated_by_ext_id?: string | null | undefined;
1009
- created_at: string;
1010
- updated_at: string;
1011
- }[];
1012
- doc_metadata?: {
1013
- doc_nature?: string | null | undefined;
1014
- doc_author?: string | null | undefined;
1015
- doc_subject?: string | null | undefined;
1016
- doc_date?: string | null | undefined;
1017
- title?: string | null | undefined;
1018
- } | null | undefined;
1019
- }[]>;
1020
- uploadUrl: (urls: string[], shared?: boolean, workspaceId?: string) => Promise<{
1021
- doc_ext_ids: string[];
1022
- duplicates?: string[] | undefined;
1023
- }>;
1024
- uploadFile: (fileData: Blob, fileName: string, workspaceId?: string) => Promise<{
1025
- doc_ext_ids: string[];
1026
- duplicates?: string[];
1027
- }>;
1028
- download: (docId: string) => Promise<Response>;
1029
- getParsedContent: (docId: string, stage: string) => Promise<Record<string, unknown>>;
1030
- };
1031
- readonly conversations: {
1032
- list: () => Promise<{
1033
- external_id: string;
1034
- title: string | null;
1035
- created_by_ext_id: string;
1036
- updated_by_ext_id?: string | null | undefined;
1037
- created_at: string;
1038
- updated_at: string;
1039
- is_shared: boolean;
1040
- message_count: number;
1041
- }[]>;
1042
- getThreads: (conversationId: string) => Promise<{
1043
- conversation_ext_id: string;
1044
- threads: {
1045
- leaf_message_ext_id: string;
1046
- history: {
1047
- role: "user" | "assistant" | "system";
1048
- content: string;
1049
- tools?: {
1050
- [x: string]: {
1051
- name: "model_citation";
1052
- description: string;
1053
- tool_responses: {
1054
- [x: string]: {
1055
- chunk_ids: string[];
1056
- statement: string;
1057
- offset_start: number;
1058
- offset_end: number;
1059
- };
1060
- };
1061
- } | {
1062
- name: "retrieval_chunk";
1063
- description: string;
1064
- tool_args: {
1065
- doc_ext_ids: string[];
1066
- search_mode?: ("semantic" | "keyword" | "hybrid") | null | undefined;
1067
- };
1068
- tool_responses: {
1069
- [x: string]: {
1070
- metadata: {
1071
- workspace_ext_id?: string | null | undefined;
1072
- doc_ext_id?: string | null | undefined;
1073
- doc_title?: string | null | undefined;
1074
- chunk_id?: string | null | undefined;
1075
- chunk_ext_id: string;
1076
- chunk_pg_idx: number;
1077
- chunk_doc_idx: number;
1078
- page_number: number;
1079
- score?: number | null | undefined;
1080
- rerank_score?: number | null | undefined;
1081
- tokens?: number | null | undefined;
1082
- created_at: string;
1083
- heading: boolean;
1084
- bbox?: number[] | null | undefined;
1085
- element_type?: string | null | undefined;
1086
- heading_level?: number | null | undefined;
1087
- };
1088
- content: string;
1089
- }[];
1090
- };
1091
- } | {
1092
- name: "retrieval_full_context";
1093
- description: string;
1094
- tool_args: {
1095
- doc_ext_ids: string[];
1096
- from_ref?: string | null | undefined;
1097
- to_ref?: string | null | undefined;
1098
- };
1099
- tool_responses: {
1100
- [x: string]: {
1101
- metadata: {
1102
- workspace_ext_id?: string | null | undefined;
1103
- doc_ext_id?: string | null | undefined;
1104
- doc_title?: string | null | undefined;
1105
- chunk_id?: string | null | undefined;
1106
- chunk_ext_id: string;
1107
- chunk_pg_idx: number;
1108
- chunk_doc_idx: number;
1109
- page_number: number;
1110
- score?: number | null | undefined;
1111
- rerank_score?: number | null | undefined;
1112
- tokens?: number | null | undefined;
1113
- created_at: string;
1114
- heading: boolean;
1115
- bbox?: number[] | null | undefined;
1116
- element_type?: string | null | undefined;
1117
- heading_level?: number | null | undefined;
1118
- };
1119
- content: string;
1120
- }[];
1121
- };
1122
- } | {
1123
- name: "retrieval_toc";
1124
- description: string;
1125
- tool_args: {
1126
- doc_ext_ids: string[];
1127
- };
1128
- tool_responses: {
1129
- [x: string]: {
1130
- [x: string]: unknown;
1131
- }[];
1132
- };
1133
- } | {
1134
- name: "trace";
1135
- description: string;
1136
- trace_id?: string | null | undefined;
1137
- start_time?: number | null | undefined;
1138
- duration_seconds?: number | null | undefined;
1139
- steps: {
1140
- [x: string]: unknown;
1141
- }[];
1142
- } | {
1143
- name: "compaction";
1144
- description: string;
1145
- tool_args: {
1146
- source_conversation_ext_id: string;
1147
- source_leaf_message_ext_id: string;
1148
- };
1149
- tool_responses: {
1150
- [x: string]: string;
1151
- };
1152
- };
1153
- } | undefined;
1154
- config_ext_id?: string | null | undefined;
1155
- shared: boolean;
1156
- tokens: number;
1157
- external_id: string;
1158
- created_at: string;
1159
- created_by_ext_id: string;
1160
- conversation_ext_id: string;
1161
- parent_message_ext_id?: string | null | undefined;
1162
- }[];
1163
- }[];
1164
- }>;
1165
- delete: (conversationId: string) => Promise<{
1166
- detail: string;
1167
- }>;
1168
- share: (conversationId: string) => Promise<{
1169
- detail: string;
1170
- }>;
1171
- updateTitle: (conversationId: string, title: string) => Promise<{
1172
- detail: string;
1173
- title: string;
1174
- }>;
1175
- getMessage: (messageId: string) => Promise<{
1176
- role: "user" | "assistant" | "system";
1177
- content: string;
1178
- tools?: {
1179
- [x: string]: {
1180
- name: "model_citation";
1181
- description: string;
1182
- tool_responses: {
1183
- [x: string]: {
1184
- chunk_ids: string[];
1185
- statement: string;
1186
- offset_start: number;
1187
- offset_end: number;
1188
- };
1189
- };
1190
- } | {
1191
- name: "retrieval_chunk";
1192
- description: string;
1193
- tool_args: {
1194
- doc_ext_ids: string[];
1195
- search_mode?: ("semantic" | "keyword" | "hybrid") | null | undefined;
1196
- };
1197
- tool_responses: {
1198
- [x: string]: {
1199
- metadata: {
1200
- workspace_ext_id?: string | null | undefined;
1201
- doc_ext_id?: string | null | undefined;
1202
- doc_title?: string | null | undefined;
1203
- chunk_id?: string | null | undefined;
1204
- chunk_ext_id: string;
1205
- chunk_pg_idx: number;
1206
- chunk_doc_idx: number;
1207
- page_number: number;
1208
- score?: number | null | undefined;
1209
- rerank_score?: number | null | undefined;
1210
- tokens?: number | null | undefined;
1211
- created_at: string;
1212
- heading: boolean;
1213
- bbox?: number[] | null | undefined;
1214
- element_type?: string | null | undefined;
1215
- heading_level?: number | null | undefined;
1216
- };
1217
- content: string;
1218
- }[];
1219
- };
1220
- } | {
1221
- name: "retrieval_full_context";
1222
- description: string;
1223
- tool_args: {
1224
- doc_ext_ids: string[];
1225
- from_ref?: string | null | undefined;
1226
- to_ref?: string | null | undefined;
1227
- };
1228
- tool_responses: {
1229
- [x: string]: {
1230
- metadata: {
1231
- workspace_ext_id?: string | null | undefined;
1232
- doc_ext_id?: string | null | undefined;
1233
- doc_title?: string | null | undefined;
1234
- chunk_id?: string | null | undefined;
1235
- chunk_ext_id: string;
1236
- chunk_pg_idx: number;
1237
- chunk_doc_idx: number;
1238
- page_number: number;
1239
- score?: number | null | undefined;
1240
- rerank_score?: number | null | undefined;
1241
- tokens?: number | null | undefined;
1242
- created_at: string;
1243
- heading: boolean;
1244
- bbox?: number[] | null | undefined;
1245
- element_type?: string | null | undefined;
1246
- heading_level?: number | null | undefined;
1247
- };
1248
- content: string;
1249
- }[];
1250
- };
1251
- } | {
1252
- name: "retrieval_toc";
1253
- description: string;
1254
- tool_args: {
1255
- doc_ext_ids: string[];
1256
- };
1257
- tool_responses: {
1258
- [x: string]: {
1259
- [x: string]: unknown;
1260
- }[];
1261
- };
1262
- } | {
1263
- name: "trace";
1264
- description: string;
1265
- trace_id?: string | null | undefined;
1266
- start_time?: number | null | undefined;
1267
- duration_seconds?: number | null | undefined;
1268
- steps: {
1269
- [x: string]: unknown;
1270
- }[];
1271
- } | {
1272
- name: "compaction";
1273
- description: string;
1274
- tool_args: {
1275
- source_conversation_ext_id: string;
1276
- source_leaf_message_ext_id: string;
1277
- };
1278
- tool_responses: {
1279
- [x: string]: string;
1280
- };
1281
- };
1282
- } | undefined;
1283
- config_ext_id?: string | null | undefined;
1284
- shared: boolean;
1285
- tokens: number;
1286
- external_id: string;
1287
- created_at: string;
1288
- created_by_ext_id: string;
1289
- conversation_ext_id: string;
1290
- parent_message_ext_id?: string | null | undefined;
1291
- }>;
1292
- deleteMessage: (messageId: string) => Promise<{
1293
- detail: string;
1294
- }>;
1295
- };
1296
- readonly assistant: {
1297
- /**
1298
- * Send a question to the RAG assistant with streaming support.
1299
- * Returns the accumulated result after the stream completes.
1300
- */
1301
- query: (question: string, options: QueryOptions) => Promise<SSEStreamResult>;
1302
- /**
1303
- * Respond to an agent's question during a human-in-the-loop workflow.
1304
- */
1305
- respond: (assistantMessageExtId: string, answer: string) => Promise<unknown>;
1306
- /**
1307
- * Search documents without LLM generation (retrieval only).
1308
- */
1309
- retrieve: (query: string, docIds: string[], options?: {
1310
- searchMode?: "semantic" | "keyword" | "hybrid";
1311
- fullContextDocIds?: string[];
1312
- tocDocIds?: string[];
1313
- model?: string;
1314
- }) => Promise<RetrieveResult>;
1315
- };
1316
- readonly tags: {
1317
- list: () => Promise<{
1318
- external_id: string;
1319
- workspace_ext_id: string;
1320
- name: string;
1321
- instruction?: string | null | undefined;
1322
- tag_type: {
1323
- type: "checkbox" | "text" | "number" | "select" | "folder" | "search" | "date";
1324
- options: string[];
1325
- };
1326
- shared: boolean;
1327
- parent_ext_id?: string | null | undefined;
1328
- doctag_count: number;
1329
- created_by_ext_id: string;
1330
- updated_by_ext_id?: string | null | undefined;
1331
- created_at: string;
1332
- updated_at: string;
1333
- }[]>;
1334
- create: (options: {
1335
- name: string;
1336
- workspaceId?: string;
1337
- tagType?: TagFormat;
1338
- instruction?: string | null;
1339
- shared?: boolean;
1340
- }) => Promise<{
1341
- external_id: string;
1342
- workspace_ext_id: string;
1343
- name: string;
1344
- instruction?: string | null | undefined;
1345
- tag_type: {
1346
- type: "checkbox" | "text" | "number" | "select" | "folder" | "search" | "date";
1347
- options: string[];
1348
- };
1349
- shared: boolean;
1350
- parent_ext_id?: string | null | undefined;
1351
- doctag_count: number;
1352
- created_by_ext_id: string;
1353
- updated_by_ext_id?: string | null | undefined;
1354
- created_at: string;
1355
- updated_at: string;
1356
- }>;
1357
- delete: (tagId: string) => Promise<{
1358
- detail: string;
1359
- }>;
1360
- update: (tagId: string, body: UpdateTagRequest$1) => Promise<{
1361
- external_id: string;
1362
- workspace_ext_id: string;
1363
- name: string;
1364
- instruction?: string | null | undefined;
1365
- tag_type: {
1366
- type: "checkbox" | "text" | "number" | "select" | "folder" | "search" | "date";
1367
- options: string[];
1368
- };
1369
- shared: boolean;
1370
- parent_ext_id?: string | null | undefined;
1371
- doctag_count: number;
1372
- created_by_ext_id: string;
1373
- updated_by_ext_id?: string | null | undefined;
1374
- created_at: string;
1375
- updated_at: string;
1376
- }>;
1377
- };
1378
- readonly doctags: {
1379
- assign: (tagId: string, docIds: string[], note?: string | null) => Promise<{
1380
- doc_ext_id: string;
1381
- tag_ext_id: string;
1382
- note?: string | null | undefined;
1383
- citations?: {
1384
- [x: string]: {
1385
- chunk_ids: string[];
1386
- statement: string;
1387
- offset_start: number;
1388
- offset_end: number;
1389
- };
1390
- } | null | undefined;
1391
- created_by_ext_id: string;
1392
- updated_by_ext_id?: string | null | undefined;
1393
- created_at: string;
1394
- updated_at: string;
1395
- }[]>;
1396
- remove: (tagId: string, docIds: string[]) => Promise<void>;
1397
- update: (tagId: string, docId: string, updates: {
1398
- note?: string | null;
1399
- citations?: Record<string, CitationData$1> | null;
1400
- }) => Promise<{
1401
- doc_ext_id: string;
1402
- tag_ext_id: string;
1403
- note?: string | null | undefined;
1404
- citations?: {
1405
- [x: string]: {
1406
- chunk_ids: string[];
1407
- statement: string;
1408
- offset_start: number;
1409
- offset_end: number;
1410
- };
1411
- } | null | undefined;
1412
- created_by_ext_id: string;
1413
- updated_by_ext_id?: string | null | undefined;
1414
- created_at: string;
1415
- updated_at: string;
1416
- }>;
1417
- generate: (tagIds: string[], docIds: string[]) => Promise<{
1418
- doc_ext_ids: string[];
1419
- tag_ext_ids: string[];
1420
- }>;
1421
- };
1422
- readonly contacts: {
1423
- list: () => Promise<{
1424
- external_id: string;
1425
- email: string;
1426
- user?: {
1427
- external_id: string;
1428
- email: string;
1429
- given_name: string;
1430
- family_name: string;
1431
- picture?: string | null | undefined;
1432
- encryption_public_key: string;
1433
- } | null | undefined;
1434
- status: "invitation_pending" | "invitation_expired" | "registered";
1435
- created_at: string;
1436
- }[]>;
1437
- add: (emails: string[]) => Promise<{
1438
- external_id: string;
1439
- email: string;
1440
- user?: {
1441
- external_id: string;
1442
- email: string;
1443
- given_name: string;
1444
- family_name: string;
1445
- picture?: string | null | undefined;
1446
- encryption_public_key: string;
1447
- } | null | undefined;
1448
- status: "invitation_pending" | "invitation_expired" | "registered";
1449
- created_at: string;
1450
- }[]>;
1451
- remove: (contactIds: string[]) => Promise<void>;
1452
- groupByStatus: typeof groupContactsByStatus;
1453
- };
1454
- readonly dm: {
1455
- list: () => Promise<{
1456
- type: components["schemas"]["NotificationType"];
1457
- external_id: string;
1458
- sender: {
1459
- external_id: string;
1460
- email: string;
1461
- given_name: string;
1462
- family_name: string;
1463
- picture?: string | null | undefined;
1464
- encryption_public_key: string;
1465
- };
1466
- recipient: {
1467
- external_id: string;
1468
- email: string;
1469
- given_name: string;
1470
- family_name: string;
1471
- picture?: string | null | undefined;
1472
- encryption_public_key: string;
1473
- };
1474
- workspace_ext_id?: string | null | undefined;
1475
- content?: string | null | undefined;
1476
- read: boolean;
1477
- created_at: string;
1478
- updated_at: string;
1479
- }[]>;
1480
- send: (messages: Array<{
1481
- recipient_ext_id: string;
1482
- content: string;
1483
- }>) => Promise<{
1484
- type: components["schemas"]["NotificationType"];
1485
- external_id: string;
1486
- sender: {
1487
- external_id: string;
1488
- email: string;
1489
- given_name: string;
1490
- family_name: string;
1491
- picture?: string | null | undefined;
1492
- encryption_public_key: string;
1493
- };
1494
- recipient: {
1495
- external_id: string;
1496
- email: string;
1497
- given_name: string;
1498
- family_name: string;
1499
- picture?: string | null | undefined;
1500
- encryption_public_key: string;
1501
- };
1502
- workspace_ext_id?: string | null | undefined;
1503
- content?: string | null | undefined;
1504
- read: boolean;
1505
- created_at: string;
1506
- updated_at: string;
1507
- }[]>;
1508
- markRead: (messageIds: string[]) => Promise<{
1509
- type: components["schemas"]["NotificationType"];
1510
- external_id: string;
1511
- sender: {
1512
- external_id: string;
1513
- email: string;
1514
- given_name: string;
1515
- family_name: string;
1516
- picture?: string | null | undefined;
1517
- encryption_public_key: string;
1518
- };
1519
- recipient: {
1520
- external_id: string;
1521
- email: string;
1522
- given_name: string;
1523
- family_name: string;
1524
- picture?: string | null | undefined;
1525
- encryption_public_key: string;
1526
- };
1527
- workspace_ext_id?: string | null | undefined;
1528
- content?: string | null | undefined;
1529
- read: boolean;
1530
- created_at: string;
1531
- updated_at: string;
1532
- }[]>;
1533
- delete: (messageIds: string[]) => Promise<void>;
1534
- };
1535
- readonly settings: {
1536
- get: () => Promise<{
1537
- [x: string]: unknown;
1538
- subscription?: {
1539
- status: string;
1540
- trial_expires?: number | null | undefined;
1541
- } | null | undefined;
1542
- last_workspace?: string | null | undefined;
1543
- pinned_workspaces: string[];
1544
- tableviews: {
1545
- workspace: string;
1546
- name: string;
1547
- columns: string[];
1548
- }[];
1549
- developer: boolean;
1550
- show_document_navigator: boolean;
1551
- show_thread_visualization: boolean;
1552
- show_smart_search: boolean;
1553
- show_security_settings: boolean;
1554
- show_invite_tab: boolean;
1555
- show_help_page: boolean;
1556
- show_templates: boolean;
1557
- hide_online_status: boolean;
1558
- muted_users: string[];
1559
- }>;
1560
- update: (body: UserSettingsUpdate$1) => Promise<void>;
1561
- };
1562
- readonly agentConfig: {
1563
- list: () => Promise<{
1564
- versions: {
1565
- external_id: string;
1566
- title: string | null;
1567
- created_at: string;
1568
- }[];
1569
- }>;
1570
- get: (configId: string) => Promise<{
1571
- Agents: {
1572
- ENABLED: boolean;
1573
- HUMAN_IN_THE_LOOP: boolean;
1574
- WEB_SEARCH?: {
1575
- ENABLED: boolean;
1576
- SAVE_SOURCES: boolean;
1577
- } | undefined;
1578
- MCP_TOOLS: string[];
1579
- PLANNING_ENABLED: boolean;
1580
- SUGGESTED_QUERIES: boolean;
1581
- ARTIFACTS_ENABLED: boolean;
1582
- VISION_ENABLED: boolean;
1583
- PERSONAL_AGENT: boolean;
1584
- REVIEW_ENABLED: boolean;
1585
- PERSONA: string;
1586
- AGENT_MODEL_NAME: string;
1587
- AGENT_API_TYPE: "local" | "remote";
1588
- LLM_AGENT_TEMPERATURE: number;
1589
- AGENT_MAX_TOKENS: number;
1590
- AGENT_MAX_ITERATIONS: number;
1591
- MAX_PASSAGE_PAGES: number;
1592
- AGENT_HISTORY_CHAR_THRESHOLD: number;
1593
- AGENT_SYSTEM_PROMPT: string;
1594
- };
1595
- QueryLLM: {
1596
- API_TYPE: "local" | "remote";
1597
- MODEL_NAME: string;
1598
- SYSTEM_INSTRUCTION: string;
1599
- MAX_CHAR_SIZE_TO_ANSWER: number;
1600
- TEMPERATURE: number;
1601
- MAX_TOKENS: number;
1602
- };
1603
- ReviewLLM: {
1604
- API_TYPE: "local" | "remote";
1605
- MODEL_NAME: string;
1606
- SYSTEM_INSTRUCTION: string;
1607
- TEMPERATURE: number;
1608
- MAX_TOKENS: number;
1609
- MAX_CHAR_SIZE_TO_ANSWER: number;
1610
- };
1611
- EvaluatorLLM: {
1612
- API_TYPE: "local" | "remote";
1613
- MODEL_NAME: string;
1614
- SYSTEM_INSTRUCTION: string;
1615
- TEMPERATURE: number;
1616
- MAX_TOKENS: number;
1617
- MAX_CHAR_SIZE_TO_ANSWER: number;
1618
- };
1619
- TitleLLM: {
1620
- API_TYPE: "local" | "remote";
1621
- MODEL_NAME: string;
1622
- SYSTEM_INSTRUCTION: string;
1623
- MAX_CHAR_SIZE_TO_ANSWER: number;
1624
- TEMPERATURE: number;
1625
- MAX_TOKENS: number;
1626
- };
1627
- SummariseLLM: {
1628
- API_TYPE: "local" | "remote";
1629
- MODEL_NAME: string;
1630
- SYSTEM_INSTRUCTION: string;
1631
- TEMPERATURE: number;
1632
- MAX_TOKENS: number;
1633
- MAX_CHAR_SIZE_TO_ANSWER: number;
1634
- COMPACTION_THRESHOLD_TOKENS: number;
1635
- COMPACTION_KEEP_RECENT: number;
1636
- };
1637
- DoctagLLM: {
1638
- API_TYPE: "local" | "remote";
1639
- MODEL_NAME: string;
1640
- SYSTEM_INSTRUCTION: string;
1641
- MAX_CHAR_CONTEXT_TO_ANSWER: number;
1642
- TEMPERATURE: number;
1643
- MAX_TOKENS: number;
1644
- MAX_CONCURRENT_DOCS: number;
1645
- DEFAULT_METADATA_TAGS: {
1646
- name: string;
1647
- instruction?: string | null | undefined;
1648
- tag_type?: {
1649
- type: "checkbox" | "text" | "number" | "select" | "folder" | "search" | "date";
1650
- options: string[];
1651
- } | undefined;
1652
- }[];
1653
- };
1654
- MemoryLLM: {
1655
- API_TYPE: "local" | "remote";
1656
- MODEL_NAME: string;
1657
- ENABLED: boolean;
1658
- SYSTEM_INSTRUCTION: string;
1659
- TEMPERATURE: number;
1660
- MAX_TOKENS: number;
1661
- MAX_CHAR_CONTEXT: number;
1662
- MAX_CONCURRENT: number;
1663
- };
1664
- PlanningLLM: {
1665
- API_TYPE: "local" | "remote";
1666
- MODEL_NAME: string;
1667
- SYSTEM_INSTRUCTION: string;
1668
- TEMPERATURE: number;
1669
- MAX_TOKENS: number;
1670
- MAX_CHAR_SIZE_TO_ANSWER: number;
1671
- APPROVAL_TIMEOUT: number;
1672
- };
1673
- VisionLLM: {
1674
- API_TYPE: "local" | "remote";
1675
- MODEL_NAME: string;
1676
- TEMPERATURE: number;
1677
- MAX_TOKENS: number;
1678
- MAX_PAGES_PER_CALL: number;
1679
- IMAGE_MAX_DIMENSION: number;
1680
- };
1681
- ModelCitation: {
1682
- SIM_THREASHOLD: number;
1683
- MIN_CHAR_SIZE_TO_ANSWER: number;
1684
- MAX_NUMB_CITATIONS: number;
1685
- };
1686
- Retriever: {
1687
- MIN_RETRIEVAL_SIM_SCORE: number;
1688
- MAX_DISTINCT_DOCUMENTS: number;
1689
- MAX_TOTAL_CHUNKS_TO_RETRIEVE: number;
1690
- GROUP_SIZE: number;
1691
- SEARCH_MODE: components["schemas"]["SearchMode"];
1692
- HYBRID_DENSE_WEIGHT: number;
1693
- HYBRID_SPARSE_WEIGHT: number;
1694
- HYBRID_RERANKER_WEIGHT: number;
1695
- };
1696
- Reranker: {
1697
- MAX_NUMB_OF_CHUNKS: number;
1698
- MAX_CONCURRENT_REQUESTS: number;
1699
- MODEL_NAME: string;
1700
- API_TYPE: "local" | "remote";
1701
- QUERY_INSTRUCTION: string;
1702
- };
1703
- Parser: {};
1704
- Chunker: {
1705
- MAX_CHUNK_TOKENS: number;
1706
- };
1707
- Embedder: {
1708
- MODEL_NAME: string;
1709
- API_TYPE: "local" | "remote";
1710
- BATCH_SIZE: number;
1711
- MAX_CONCURRENT_REQUESTS: number;
1712
- DOCUMENT_PREFIX: string;
1713
- QUERY_PREFIX: string;
1714
- };
1715
- KeywordEmbedder: {
1716
- DIMENSION_SPACE: number;
1717
- FILTER_STOPWORDS: boolean;
1718
- BM25_K1: number;
1719
- BM25_B: number;
1720
- BM25_AVGDL: number;
1721
- };
1722
- } | {
1723
- Agents: {
1724
- [x: string]: string | boolean;
1725
- };
1726
- MemoryLLM: {
1727
- [x: string]: boolean;
1728
- };
1729
- }>;
1730
- save: (body: ConfigUpdateData$1) => Promise<{
1731
- external_id: string;
1732
- title: string | null;
1733
- created_at: string;
1734
- }>;
1735
- delete: (configId: string) => Promise<{
1736
- detail: string;
1737
- }>;
1738
- getSchema: () => Promise<unknown>;
1739
- getModels: () => Promise<{
1740
- models: {
1741
- model_name: string;
1742
- api_type: string;
1743
- max_input_tokens?: number | null | undefined;
1744
- max_output_tokens?: number | null | undefined;
1745
- input_cost_per_token?: number | null | undefined;
1746
- output_cost_per_token?: number | null | undefined;
1747
- provider?: string | null | undefined;
1748
- mode?: string | null | undefined;
1749
- supports_vision?: boolean | null | undefined;
1750
- supports_reasoning?: boolean | null | undefined;
1751
- supports_function_calling?: boolean | null | undefined;
1752
- supports_response_schema?: boolean | null | undefined;
1753
- }[];
1754
- }>;
1755
- };
1756
- readonly health: {
1757
- check: () => Promise<{
1758
- status: string;
1759
- backend_git_hash?: string | null | undefined;
1760
- frontend_docker_version?: string | null | undefined;
1761
- services: {
1762
- name: string;
1763
- status: string;
1764
- detail?: string | null | undefined;
1765
- service_info?: {
1766
- [x: string]: unknown;
1767
- } | null | undefined;
1768
- }[];
1769
- models_health?: {
1770
- application: string;
1771
- models: {
1772
- model: string;
1773
- status: string;
1774
- detail?: string | null | undefined;
1775
- }[];
1776
- } | null | undefined;
1777
- available_models: string[];
1778
- }>;
1779
- models: () => Promise<{
1780
- models: {
1781
- model_name: string;
1782
- api_type: string;
1783
- max_input_tokens?: number | null | undefined;
1784
- max_output_tokens?: number | null | undefined;
1785
- input_cost_per_token?: number | null | undefined;
1786
- output_cost_per_token?: number | null | undefined;
1787
- provider?: string | null | undefined;
1788
- mode?: string | null | undefined;
1789
- supports_vision?: boolean | null | undefined;
1790
- supports_reasoning?: boolean | null | undefined;
1791
- supports_function_calling?: boolean | null | undefined;
1792
- supports_response_schema?: boolean | null | undefined;
1793
- }[];
1794
- }>;
1795
- remoteModels: () => Promise<{
1796
- application: string;
1797
- models: {
1798
- model: string;
1799
- status: string;
1800
- detail?: string | null | undefined;
1801
- }[];
1802
- }>;
1803
- mcpTools: () => Promise<{
1804
- tools: {
1805
- name: string;
1806
- description: string;
1807
- server_name: string;
1808
- }[];
1809
- }>;
1810
- };
1811
- readonly files: {
1812
- list: (options?: ListFilesOptions) => Promise<{
1813
- object: string;
1814
- data: {
1815
- id: string;
1816
- object: string;
1817
- bytes: number;
1818
- created_at: number;
1819
- filename: string;
1820
- purpose: string;
1821
- status: string;
1822
- expires_at?: number | null | undefined;
1823
- status_details?: string | null | undefined;
1824
- }[];
1825
- has_more: boolean;
1826
- first_id?: string | null | undefined;
1827
- last_id?: string | null | undefined;
1828
- }>;
1829
- get: (fileId: string) => Promise<{
1830
- id: string;
1831
- object: string;
1832
- bytes: number;
1833
- created_at: number;
1834
- filename: string;
1835
- purpose: string;
1836
- status: string;
1837
- expires_at?: number | null | undefined;
1838
- status_details?: string | null | undefined;
1839
- }>;
1840
- delete: (fileId: string) => Promise<{
1841
- id: string;
1842
- object: string;
1843
- deleted: boolean;
1844
- }>;
1845
- upload: (fileData: Blob, fileName: string, purpose?: string) => Promise<{
1846
- id: string;
1847
- object: string;
1848
- bytes: number;
1849
- created_at: number;
1850
- filename: string;
1851
- purpose: string;
1852
- status: string;
1853
- expires_at?: number | null;
1854
- status_details?: string | null;
1855
- }>;
1856
- getContent: (fileId: string) => Promise<Response>;
1857
- };
1858
- private requireClient;
1859
- private requireLogin;
1860
- private requireWorkspace;
55
+ private readPublicConfigDomain;
1861
56
  }
1862
57
 
1863
58
  /**
1864
- * Document operations — list, get, delete, update, upload-url, parsed content, upload, download.
59
+ * Document operations — Node.js file system operations.
60
+ *
61
+ * These functions require Node.js built-ins (fs, path) and are not browser-safe.
62
+ * Browser consumers should use the Blob-based uploadFile/uploadFiles from './documents.js'.
1865
63
  */
1866
64
 
1867
- type DocUpdateRequest = components['schemas']['DocUpdateRequest'];
1868
- declare function listDocuments(arbi: ArbiClient): Promise<{
1869
- external_id: string;
1870
- workspace_ext_id: string;
1871
- file_name?: string | null | undefined;
1872
- status?: string | null | undefined;
1873
- n_pages?: number | null | undefined;
1874
- n_chunks?: number | null | undefined;
1875
- tokens?: number | null | undefined;
1876
- file_type?: string | null | undefined;
1877
- file_size?: number | null | undefined;
1878
- storage_type?: string | null | undefined;
1879
- storage_uri?: string | null | undefined;
1880
- content_hash?: string | null | undefined;
1881
- shared?: boolean | null | undefined;
1882
- re_ocred?: boolean | null | undefined;
1883
- config_ext_id?: string | null | undefined;
1884
- parent_ext_id?: string | null | undefined;
1885
- created_by_ext_id: string;
1886
- updated_by_ext_id?: string | null | undefined;
1887
- created_at: string;
1888
- updated_at: string;
1889
- wp_type?: string | null | undefined;
1890
- doctags: {
1891
- doc_ext_id: string;
1892
- tag_ext_id: string;
1893
- note?: string | null | undefined;
1894
- citations?: {
1895
- [x: string]: {
1896
- chunk_ids: string[];
1897
- statement: string;
1898
- offset_start: number;
1899
- offset_end: number;
1900
- };
1901
- } | null | undefined;
1902
- created_by_ext_id: string;
1903
- updated_by_ext_id?: string | null | undefined;
1904
- created_at: string;
1905
- updated_at: string;
1906
- }[];
1907
- doc_metadata?: {
1908
- doc_nature?: string | null | undefined;
1909
- doc_author?: string | null | undefined;
1910
- doc_subject?: string | null | undefined;
1911
- doc_date?: string | null | undefined;
1912
- title?: string | null | undefined;
1913
- } | null | undefined;
1914
- }[]>;
1915
- declare function getDocuments(arbi: ArbiClient, externalIds: string[]): Promise<{
1916
- external_id: string;
1917
- workspace_ext_id: string;
1918
- file_name?: string | null | undefined;
1919
- status?: string | null | undefined;
1920
- n_pages?: number | null | undefined;
1921
- n_chunks?: number | null | undefined;
1922
- tokens?: number | null | undefined;
1923
- file_type?: string | null | undefined;
1924
- file_size?: number | null | undefined;
1925
- storage_type?: string | null | undefined;
1926
- storage_uri?: string | null | undefined;
1927
- content_hash?: string | null | undefined;
1928
- shared?: boolean | null | undefined;
1929
- re_ocred?: boolean | null | undefined;
1930
- config_ext_id?: string | null | undefined;
1931
- parent_ext_id?: string | null | undefined;
1932
- created_by_ext_id: string;
1933
- updated_by_ext_id?: string | null | undefined;
1934
- created_at: string;
1935
- updated_at: string;
1936
- wp_type?: string | null | undefined;
1937
- doctags: {
1938
- doc_ext_id: string;
1939
- tag_ext_id: string;
1940
- note?: string | null | undefined;
1941
- citations?: {
1942
- [x: string]: {
1943
- chunk_ids: string[];
1944
- statement: string;
1945
- offset_start: number;
1946
- offset_end: number;
1947
- };
1948
- } | null | undefined;
1949
- created_by_ext_id: string;
1950
- updated_by_ext_id?: string | null | undefined;
1951
- created_at: string;
1952
- updated_at: string;
1953
- }[];
1954
- doc_metadata?: {
1955
- doc_nature?: string | null | undefined;
1956
- doc_author?: string | null | undefined;
1957
- doc_subject?: string | null | undefined;
1958
- doc_date?: string | null | undefined;
1959
- title?: string | null | undefined;
1960
- } | null | undefined;
1961
- }[]>;
1962
- declare function deleteDocuments(arbi: ArbiClient, externalIds: string[]): Promise<void>;
1963
- declare function updateDocuments(arbi: ArbiClient, documents: DocUpdateRequest[]): Promise<{
1964
- external_id: string;
1965
- workspace_ext_id: string;
1966
- file_name?: string | null | undefined;
1967
- status?: string | null | undefined;
1968
- n_pages?: number | null | undefined;
1969
- n_chunks?: number | null | undefined;
1970
- tokens?: number | null | undefined;
1971
- file_type?: string | null | undefined;
1972
- file_size?: number | null | undefined;
1973
- storage_type?: string | null | undefined;
1974
- storage_uri?: string | null | undefined;
1975
- content_hash?: string | null | undefined;
1976
- shared?: boolean | null | undefined;
1977
- re_ocred?: boolean | null | undefined;
1978
- config_ext_id?: string | null | undefined;
1979
- parent_ext_id?: string | null | undefined;
1980
- created_by_ext_id: string;
1981
- updated_by_ext_id?: string | null | undefined;
1982
- created_at: string;
1983
- updated_at: string;
1984
- wp_type?: string | null | undefined;
1985
- doctags: {
1986
- doc_ext_id: string;
1987
- tag_ext_id: string;
1988
- note?: string | null | undefined;
1989
- citations?: {
1990
- [x: string]: {
1991
- chunk_ids: string[];
1992
- statement: string;
1993
- offset_start: number;
1994
- offset_end: number;
1995
- };
1996
- } | null | undefined;
1997
- created_by_ext_id: string;
1998
- updated_by_ext_id?: string | null | undefined;
1999
- created_at: string;
2000
- updated_at: string;
2001
- }[];
2002
- doc_metadata?: {
2003
- doc_nature?: string | null | undefined;
2004
- doc_author?: string | null | undefined;
2005
- doc_subject?: string | null | undefined;
2006
- doc_date?: string | null | undefined;
2007
- title?: string | null | undefined;
2008
- } | null | undefined;
2009
- }[]>;
2010
- declare function uploadUrl(arbi: ArbiClient, urls: string[], workspaceId: string, shared?: boolean): Promise<{
2011
- doc_ext_ids: string[];
2012
- duplicates?: string[] | undefined;
2013
- }>;
2014
- /**
2015
- * Get parsed document content.
2016
- */
2017
- declare function getParsedContent(auth: AuthHeaders, docId: string, stage: string): Promise<Record<string, unknown>>;
2018
- /**
2019
- * Upload a file to a workspace. Uses raw fetch for multipart upload.
2020
- */
2021
- declare function uploadFile(auth: AuthHeaders, workspaceId: string, fileData: Blob, fileName: string): Promise<{
2022
- doc_ext_ids: string[];
2023
- duplicates?: string[];
2024
- }>;
2025
65
  /**
2026
66
  * Upload a local file by path. Handles readFileSync + basename + Blob + uploadFile.
2027
67
  * Convenience wrapper for CLI/TUI consumers that work with file system paths.
2028
68
  */
2029
- declare function uploadLocalFile(auth: AuthHeaders, workspaceId: string, filePath: string): Promise<{
2030
- doc_ext_ids: string[];
2031
- duplicates?: string[];
69
+ declare function uploadLocalFile(auth: AuthHeaders, workspaceId: string, filePath: string, options?: UploadOptions): Promise<UploadResult & {
2032
70
  fileName: string;
2033
71
  }>;
2034
72
  /**
2035
- * Download a document. Returns the response for the caller to handle.
73
+ * Upload all supported files from a directory, preserving folder structure.
74
+ * Files are grouped by their relative folder path and uploaded per group.
2036
75
  */
2037
- declare function downloadDocument(auth: AuthHeaders, docId: string): Promise<Response>;
2038
-
2039
- declare const documents_deleteDocuments: typeof deleteDocuments;
2040
- declare const documents_downloadDocument: typeof downloadDocument;
2041
- declare const documents_getDocuments: typeof getDocuments;
2042
- declare const documents_getParsedContent: typeof getParsedContent;
2043
- declare const documents_listDocuments: typeof listDocuments;
2044
- declare const documents_updateDocuments: typeof updateDocuments;
2045
- declare const documents_uploadFile: typeof uploadFile;
2046
- declare const documents_uploadLocalFile: typeof uploadLocalFile;
2047
- declare const documents_uploadUrl: typeof uploadUrl;
2048
- declare namespace documents {
2049
- export { documents_deleteDocuments as deleteDocuments, documents_downloadDocument as downloadDocument, documents_getDocuments as getDocuments, documents_getParsedContent as getParsedContent, documents_listDocuments as listDocuments, documents_updateDocuments as updateDocuments, documents_uploadFile as uploadFile, documents_uploadLocalFile as uploadLocalFile, documents_uploadUrl as uploadUrl };
2050
- }
2051
-
76
+ declare function uploadDirectory(auth: AuthHeaders, workspaceId: string, dirPath: string): Promise<UploadBatchResult>;
2052
77
  /**
2053
- * Workspace operations list, create, delete, update, users, copy.
78
+ * Upload files from a zip archive, preserving internal folder structure.
79
+ * Uses jszip via dynamic import so the dependency is optional at load time.
2054
80
  */
81
+ declare function uploadZip(auth: AuthHeaders, workspaceId: string, zipPath: string): Promise<UploadBatchResult>;
2055
82
 
2056
- type WorkspaceUpdateRequest = components['schemas']['WorkspaceUpdateRequest'];
2057
- declare function listWorkspaces(arbi: ArbiClient): Promise<{
2058
- external_id: string;
2059
- name: string;
2060
- description: string | null;
2061
- is_public: boolean;
2062
- created_by_ext_id: string;
2063
- updated_by_ext_id?: string | null | undefined;
2064
- created_at: string;
2065
- updated_at: string;
2066
- wrapped_key?: string | null | undefined;
2067
- shared_conversation_count: number;
2068
- private_conversation_count: number;
2069
- shared_document_count: number;
2070
- private_document_count: number;
2071
- user_files_mb: number;
2072
- users: {
2073
- user: {
2074
- external_id: string;
2075
- email: string;
2076
- given_name: string;
2077
- family_name: string;
2078
- picture?: string | null | undefined;
2079
- encryption_public_key: string;
2080
- };
2081
- role: components["schemas"]["WorkspaceRole"];
2082
- joined_at: string;
2083
- conversation_count: number;
2084
- document_count: number;
2085
- }[];
2086
- }[]>;
2087
- declare function createWorkspace(arbi: ArbiClient, name: string, description?: string | null, isPublic?: boolean): Promise<{
2088
- external_id: string;
2089
- name: string;
2090
- description: string | null;
2091
- is_public: boolean;
2092
- created_by_ext_id: string;
2093
- updated_by_ext_id?: string | null | undefined;
2094
- created_at: string;
2095
- updated_at: string;
2096
- wrapped_key?: string | null | undefined;
2097
- shared_conversation_count: number;
2098
- private_conversation_count: number;
2099
- shared_document_count: number;
2100
- private_document_count: number;
2101
- user_files_mb: number;
2102
- users: {
2103
- user: {
2104
- external_id: string;
2105
- email: string;
2106
- given_name: string;
2107
- family_name: string;
2108
- picture?: string | null | undefined;
2109
- encryption_public_key: string;
2110
- };
2111
- role: components["schemas"]["WorkspaceRole"];
2112
- joined_at: string;
2113
- conversation_count: number;
2114
- document_count: number;
2115
- }[];
2116
- }>;
2117
- declare function deleteWorkspaces(arbi: ArbiClient, workspaceIds: string[]): Promise<void>;
2118
- declare function updateWorkspace(arbi: ArbiClient, body: WorkspaceUpdateRequest): Promise<{
2119
- external_id: string;
2120
- name: string;
2121
- description: string | null;
2122
- is_public: boolean;
2123
- created_by_ext_id: string;
2124
- updated_by_ext_id?: string | null | undefined;
2125
- created_at: string;
2126
- updated_at: string;
2127
- wrapped_key?: string | null | undefined;
2128
- shared_conversation_count: number;
2129
- private_conversation_count: number;
2130
- shared_document_count: number;
2131
- private_document_count: number;
2132
- user_files_mb: number;
2133
- users: {
2134
- user: {
2135
- external_id: string;
2136
- email: string;
2137
- given_name: string;
2138
- family_name: string;
2139
- picture?: string | null | undefined;
2140
- encryption_public_key: string;
2141
- };
2142
- role: components["schemas"]["WorkspaceRole"];
2143
- joined_at: string;
2144
- conversation_count: number;
2145
- document_count: number;
2146
- }[];
2147
- }>;
2148
- declare function listWorkspaceUsers(arbi: ArbiClient): Promise<{
2149
- user: {
2150
- external_id: string;
2151
- email: string;
2152
- given_name: string;
2153
- family_name: string;
2154
- picture?: string | null | undefined;
2155
- encryption_public_key: string;
2156
- };
2157
- role: components["schemas"]["WorkspaceRole"];
2158
- joined_at: string;
2159
- conversation_count: number;
2160
- document_count: number;
2161
- }[]>;
2162
- declare function addWorkspaceUsers(arbi: ArbiClient, emails: string[], role?: 'owner' | 'collaborator' | 'guest'): Promise<{
2163
- user: {
2164
- external_id: string;
2165
- email: string;
2166
- given_name: string;
2167
- family_name: string;
2168
- picture?: string | null | undefined;
2169
- encryption_public_key: string;
2170
- };
2171
- role: components["schemas"]["WorkspaceRole"];
2172
- joined_at: string;
2173
- conversation_count: number;
2174
- document_count: number;
2175
- }[]>;
2176
- declare function removeWorkspaceUsers(arbi: ArbiClient, userIds: string[]): Promise<void>;
2177
- declare function setUserRole(arbi: ArbiClient, userIds: string[], role: 'owner' | 'collaborator' | 'guest'): Promise<{
2178
- user: {
2179
- external_id: string;
2180
- email: string;
2181
- given_name: string;
2182
- family_name: string;
2183
- picture?: string | null | undefined;
2184
- encryption_public_key: string;
2185
- };
2186
- role: components["schemas"]["WorkspaceRole"];
2187
- joined_at: string;
2188
- conversation_count: number;
2189
- document_count: number;
2190
- }[]>;
2191
- declare function copyDocuments(arbi: ArbiClient, targetWorkspaceId: string, docIds: string[], targetWorkspaceKey: string): Promise<{
2192
- detail: string;
2193
- documents_copied: number;
2194
- results: {
2195
- source_doc_ext_id: string;
2196
- success: boolean;
2197
- new_doc_ext_id?: string | null | undefined;
2198
- error?: string | null | undefined;
2199
- }[];
2200
- }>;
2201
-
2202
- declare const workspaces_addWorkspaceUsers: typeof addWorkspaceUsers;
2203
- declare const workspaces_copyDocuments: typeof copyDocuments;
2204
- declare const workspaces_createWorkspace: typeof createWorkspace;
2205
- declare const workspaces_deleteWorkspaces: typeof deleteWorkspaces;
2206
- declare const workspaces_listWorkspaceUsers: typeof listWorkspaceUsers;
2207
- declare const workspaces_listWorkspaces: typeof listWorkspaces;
2208
- declare const workspaces_removeWorkspaceUsers: typeof removeWorkspaceUsers;
2209
- declare const workspaces_setUserRole: typeof setUserRole;
2210
- declare const workspaces_updateWorkspace: typeof updateWorkspace;
2211
- declare namespace workspaces {
2212
- export { workspaces_addWorkspaceUsers as addWorkspaceUsers, workspaces_copyDocuments as copyDocuments, workspaces_createWorkspace as createWorkspace, workspaces_deleteWorkspaces as deleteWorkspaces, workspaces_listWorkspaceUsers as listWorkspaceUsers, workspaces_listWorkspaces as listWorkspaces, workspaces_removeWorkspaceUsers as removeWorkspaceUsers, workspaces_setUserRole as setUserRole, workspaces_updateWorkspace as updateWorkspace };
2213
- }
2214
-
2215
- /**
2216
- * Tag operations — list, create, delete, update.
2217
- */
2218
-
2219
- type UpdateTagRequest = components['schemas']['UpdateTagRequest'];
2220
- declare function listTags(arbi: ArbiClient): Promise<{
2221
- external_id: string;
2222
- workspace_ext_id: string;
2223
- name: string;
2224
- instruction?: string | null | undefined;
2225
- tag_type: {
2226
- type: "checkbox" | "text" | "number" | "select" | "folder" | "search" | "date";
2227
- options: string[];
2228
- };
2229
- shared: boolean;
2230
- parent_ext_id?: string | null | undefined;
2231
- doctag_count: number;
2232
- created_by_ext_id: string;
2233
- updated_by_ext_id?: string | null | undefined;
2234
- created_at: string;
2235
- updated_at: string;
2236
- }[]>;
2237
- declare function createTag(arbi: ArbiClient, options: {
2238
- name: string;
2239
- workspaceId?: string;
2240
- tagType?: components['schemas']['TagFormat'];
2241
- instruction?: string | null;
2242
- shared?: boolean;
2243
- }): Promise<{
2244
- external_id: string;
2245
- workspace_ext_id: string;
2246
- name: string;
2247
- instruction?: string | null | undefined;
2248
- tag_type: {
2249
- type: "checkbox" | "text" | "number" | "select" | "folder" | "search" | "date";
2250
- options: string[];
2251
- };
2252
- shared: boolean;
2253
- parent_ext_id?: string | null | undefined;
2254
- doctag_count: number;
2255
- created_by_ext_id: string;
2256
- updated_by_ext_id?: string | null | undefined;
2257
- created_at: string;
2258
- updated_at: string;
2259
- }>;
2260
- declare function deleteTag(arbi: ArbiClient, tagId: string): Promise<{
2261
- detail: string;
2262
- }>;
2263
- declare function updateTag(arbi: ArbiClient, tagId: string, body: UpdateTagRequest): Promise<{
2264
- external_id: string;
2265
- workspace_ext_id: string;
2266
- name: string;
2267
- instruction?: string | null | undefined;
2268
- tag_type: {
2269
- type: "checkbox" | "text" | "number" | "select" | "folder" | "search" | "date";
2270
- options: string[];
2271
- };
2272
- shared: boolean;
2273
- parent_ext_id?: string | null | undefined;
2274
- doctag_count: number;
2275
- created_by_ext_id: string;
2276
- updated_by_ext_id?: string | null | undefined;
2277
- created_at: string;
2278
- updated_at: string;
2279
- }>;
2280
-
2281
- declare const tags_createTag: typeof createTag;
2282
- declare const tags_deleteTag: typeof deleteTag;
2283
- declare const tags_listTags: typeof listTags;
2284
- declare const tags_updateTag: typeof updateTag;
2285
- declare namespace tags {
2286
- export { tags_createTag as createTag, tags_deleteTag as deleteTag, tags_listTags as listTags, tags_updateTag as updateTag };
2287
- }
2288
-
2289
- /**
2290
- * Conversation operations — list, threads, delete, share, title, messages.
2291
- */
2292
-
2293
- declare function listConversations(arbi: ArbiClient): Promise<{
2294
- external_id: string;
2295
- title: string | null;
2296
- created_by_ext_id: string;
2297
- updated_by_ext_id?: string | null | undefined;
2298
- created_at: string;
2299
- updated_at: string;
2300
- is_shared: boolean;
2301
- message_count: number;
2302
- }[]>;
2303
- declare function getConversationThreads(arbi: ArbiClient, conversationId: string): Promise<{
2304
- conversation_ext_id: string;
2305
- threads: {
2306
- leaf_message_ext_id: string;
2307
- history: {
2308
- role: "user" | "assistant" | "system";
2309
- content: string;
2310
- tools?: {
2311
- [x: string]: {
2312
- name: "model_citation";
2313
- description: string;
2314
- tool_responses: {
2315
- [x: string]: {
2316
- chunk_ids: string[];
2317
- statement: string;
2318
- offset_start: number;
2319
- offset_end: number;
2320
- };
2321
- };
2322
- } | {
2323
- name: "retrieval_chunk";
2324
- description: string;
2325
- tool_args: {
2326
- doc_ext_ids: string[];
2327
- search_mode?: ("semantic" | "keyword" | "hybrid") | null | undefined;
2328
- };
2329
- tool_responses: {
2330
- [x: string]: {
2331
- metadata: {
2332
- workspace_ext_id?: string | null | undefined;
2333
- doc_ext_id?: string | null | undefined;
2334
- doc_title?: string | null | undefined;
2335
- chunk_id?: string | null | undefined;
2336
- chunk_ext_id: string;
2337
- chunk_pg_idx: number;
2338
- chunk_doc_idx: number;
2339
- page_number: number;
2340
- score?: number | null | undefined;
2341
- rerank_score?: number | null | undefined;
2342
- tokens?: number | null | undefined;
2343
- created_at: string;
2344
- heading: boolean;
2345
- bbox?: number[] | null | undefined;
2346
- element_type?: string | null | undefined;
2347
- heading_level?: number | null | undefined;
2348
- };
2349
- content: string;
2350
- }[];
2351
- };
2352
- } | {
2353
- name: "retrieval_full_context";
2354
- description: string;
2355
- tool_args: {
2356
- doc_ext_ids: string[];
2357
- from_ref?: string | null | undefined;
2358
- to_ref?: string | null | undefined;
2359
- };
2360
- tool_responses: {
2361
- [x: string]: {
2362
- metadata: {
2363
- workspace_ext_id?: string | null | undefined;
2364
- doc_ext_id?: string | null | undefined;
2365
- doc_title?: string | null | undefined;
2366
- chunk_id?: string | null | undefined;
2367
- chunk_ext_id: string;
2368
- chunk_pg_idx: number;
2369
- chunk_doc_idx: number;
2370
- page_number: number;
2371
- score?: number | null | undefined;
2372
- rerank_score?: number | null | undefined;
2373
- tokens?: number | null | undefined;
2374
- created_at: string;
2375
- heading: boolean;
2376
- bbox?: number[] | null | undefined;
2377
- element_type?: string | null | undefined;
2378
- heading_level?: number | null | undefined;
2379
- };
2380
- content: string;
2381
- }[];
2382
- };
2383
- } | {
2384
- name: "retrieval_toc";
2385
- description: string;
2386
- tool_args: {
2387
- doc_ext_ids: string[];
2388
- };
2389
- tool_responses: {
2390
- [x: string]: {
2391
- [x: string]: unknown;
2392
- }[];
2393
- };
2394
- } | {
2395
- name: "trace";
2396
- description: string;
2397
- trace_id?: string | null | undefined;
2398
- start_time?: number | null | undefined;
2399
- duration_seconds?: number | null | undefined;
2400
- steps: {
2401
- [x: string]: unknown;
2402
- }[];
2403
- } | {
2404
- name: "compaction";
2405
- description: string;
2406
- tool_args: {
2407
- source_conversation_ext_id: string;
2408
- source_leaf_message_ext_id: string;
2409
- };
2410
- tool_responses: {
2411
- [x: string]: string;
2412
- };
2413
- };
2414
- } | undefined;
2415
- config_ext_id?: string | null | undefined;
2416
- shared: boolean;
2417
- tokens: number;
2418
- external_id: string;
2419
- created_at: string;
2420
- created_by_ext_id: string;
2421
- conversation_ext_id: string;
2422
- parent_message_ext_id?: string | null | undefined;
2423
- }[];
2424
- }[];
2425
- }>;
2426
- declare function deleteConversation(arbi: ArbiClient, conversationId: string): Promise<{
2427
- detail: string;
2428
- }>;
2429
- declare function shareConversation(arbi: ArbiClient, conversationId: string): Promise<{
2430
- detail: string;
2431
- }>;
2432
- declare function updateConversationTitle(arbi: ArbiClient, conversationId: string, title: string): Promise<{
2433
- detail: string;
2434
- title: string;
2435
- }>;
2436
- declare function getMessage(arbi: ArbiClient, messageId: string): Promise<{
2437
- role: "user" | "assistant" | "system";
2438
- content: string;
2439
- tools?: {
2440
- [x: string]: {
2441
- name: "model_citation";
2442
- description: string;
2443
- tool_responses: {
2444
- [x: string]: {
2445
- chunk_ids: string[];
2446
- statement: string;
2447
- offset_start: number;
2448
- offset_end: number;
2449
- };
2450
- };
2451
- } | {
2452
- name: "retrieval_chunk";
2453
- description: string;
2454
- tool_args: {
2455
- doc_ext_ids: string[];
2456
- search_mode?: ("semantic" | "keyword" | "hybrid") | null | undefined;
2457
- };
2458
- tool_responses: {
2459
- [x: string]: {
2460
- metadata: {
2461
- workspace_ext_id?: string | null | undefined;
2462
- doc_ext_id?: string | null | undefined;
2463
- doc_title?: string | null | undefined;
2464
- chunk_id?: string | null | undefined;
2465
- chunk_ext_id: string;
2466
- chunk_pg_idx: number;
2467
- chunk_doc_idx: number;
2468
- page_number: number;
2469
- score?: number | null | undefined;
2470
- rerank_score?: number | null | undefined;
2471
- tokens?: number | null | undefined;
2472
- created_at: string;
2473
- heading: boolean;
2474
- bbox?: number[] | null | undefined;
2475
- element_type?: string | null | undefined;
2476
- heading_level?: number | null | undefined;
2477
- };
2478
- content: string;
2479
- }[];
2480
- };
2481
- } | {
2482
- name: "retrieval_full_context";
2483
- description: string;
2484
- tool_args: {
2485
- doc_ext_ids: string[];
2486
- from_ref?: string | null | undefined;
2487
- to_ref?: string | null | undefined;
2488
- };
2489
- tool_responses: {
2490
- [x: string]: {
2491
- metadata: {
2492
- workspace_ext_id?: string | null | undefined;
2493
- doc_ext_id?: string | null | undefined;
2494
- doc_title?: string | null | undefined;
2495
- chunk_id?: string | null | undefined;
2496
- chunk_ext_id: string;
2497
- chunk_pg_idx: number;
2498
- chunk_doc_idx: number;
2499
- page_number: number;
2500
- score?: number | null | undefined;
2501
- rerank_score?: number | null | undefined;
2502
- tokens?: number | null | undefined;
2503
- created_at: string;
2504
- heading: boolean;
2505
- bbox?: number[] | null | undefined;
2506
- element_type?: string | null | undefined;
2507
- heading_level?: number | null | undefined;
2508
- };
2509
- content: string;
2510
- }[];
2511
- };
2512
- } | {
2513
- name: "retrieval_toc";
2514
- description: string;
2515
- tool_args: {
2516
- doc_ext_ids: string[];
2517
- };
2518
- tool_responses: {
2519
- [x: string]: {
2520
- [x: string]: unknown;
2521
- }[];
2522
- };
2523
- } | {
2524
- name: "trace";
2525
- description: string;
2526
- trace_id?: string | null | undefined;
2527
- start_time?: number | null | undefined;
2528
- duration_seconds?: number | null | undefined;
2529
- steps: {
2530
- [x: string]: unknown;
2531
- }[];
2532
- } | {
2533
- name: "compaction";
2534
- description: string;
2535
- tool_args: {
2536
- source_conversation_ext_id: string;
2537
- source_leaf_message_ext_id: string;
2538
- };
2539
- tool_responses: {
2540
- [x: string]: string;
2541
- };
2542
- };
2543
- } | undefined;
2544
- config_ext_id?: string | null | undefined;
2545
- shared: boolean;
2546
- tokens: number;
2547
- external_id: string;
2548
- created_at: string;
2549
- created_by_ext_id: string;
2550
- conversation_ext_id: string;
2551
- parent_message_ext_id?: string | null | undefined;
2552
- }>;
2553
- declare function deleteMessage(arbi: ArbiClient, messageId: string): Promise<{
2554
- detail: string;
2555
- }>;
2556
-
2557
- declare const conversations_deleteConversation: typeof deleteConversation;
2558
- declare const conversations_deleteMessage: typeof deleteMessage;
2559
- declare const conversations_getConversationThreads: typeof getConversationThreads;
2560
- declare const conversations_getMessage: typeof getMessage;
2561
- declare const conversations_listConversations: typeof listConversations;
2562
- declare const conversations_shareConversation: typeof shareConversation;
2563
- declare const conversations_updateConversationTitle: typeof updateConversationTitle;
2564
- declare namespace conversations {
2565
- export { conversations_deleteConversation as deleteConversation, conversations_deleteMessage as deleteMessage, conversations_getConversationThreads as getConversationThreads, conversations_getMessage as getMessage, conversations_listConversations as listConversations, conversations_shareConversation as shareConversation, conversations_updateConversationTitle as updateConversationTitle };
2566
- }
2567
-
2568
- /**
2569
- * Document-tag (doctag) operations — assign, remove, generate.
2570
- */
2571
-
2572
- type CitationData = components['schemas']['CitationData'];
2573
- declare function assignDocTags(arbi: ArbiClient, tagId: string, docIds: string[], note?: string | null): Promise<{
2574
- doc_ext_id: string;
2575
- tag_ext_id: string;
2576
- note?: string | null | undefined;
2577
- citations?: {
2578
- [x: string]: {
2579
- chunk_ids: string[];
2580
- statement: string;
2581
- offset_start: number;
2582
- offset_end: number;
2583
- };
2584
- } | null | undefined;
2585
- created_by_ext_id: string;
2586
- updated_by_ext_id?: string | null | undefined;
2587
- created_at: string;
2588
- updated_at: string;
2589
- }[]>;
2590
- declare function removeDocTags(arbi: ArbiClient, tagId: string, docIds: string[]): Promise<void>;
2591
- declare function updateDocTag(arbi: ArbiClient, tagId: string, docId: string, updates: {
2592
- note?: string | null;
2593
- citations?: Record<string, CitationData> | null;
2594
- }): Promise<{
2595
- doc_ext_id: string;
2596
- tag_ext_id: string;
2597
- note?: string | null | undefined;
2598
- citations?: {
2599
- [x: string]: {
2600
- chunk_ids: string[];
2601
- statement: string;
2602
- offset_start: number;
2603
- offset_end: number;
2604
- };
2605
- } | null | undefined;
2606
- created_by_ext_id: string;
2607
- updated_by_ext_id?: string | null | undefined;
2608
- created_at: string;
2609
- updated_at: string;
2610
- }>;
2611
- declare function generateDocTags(arbi: ArbiClient, tagIds: string[], docIds: string[]): Promise<{
2612
- doc_ext_ids: string[];
2613
- tag_ext_ids: string[];
2614
- }>;
2615
-
2616
- declare const doctags_assignDocTags: typeof assignDocTags;
2617
- declare const doctags_generateDocTags: typeof generateDocTags;
2618
- declare const doctags_removeDocTags: typeof removeDocTags;
2619
- declare const doctags_updateDocTag: typeof updateDocTag;
2620
- declare namespace doctags {
2621
- export { doctags_assignDocTags as assignDocTags, doctags_generateDocTags as generateDocTags, doctags_removeDocTags as removeDocTags, doctags_updateDocTag as updateDocTag };
2622
- }
2623
-
2624
- declare function listDMs(arbi: ArbiClient): Promise<{
2625
- type: _arbidocs_client.components["schemas"]["NotificationType"];
2626
- external_id: string;
2627
- sender: {
2628
- external_id: string;
2629
- email: string;
2630
- given_name: string;
2631
- family_name: string;
2632
- picture?: string | null | undefined;
2633
- encryption_public_key: string;
2634
- };
2635
- recipient: {
2636
- external_id: string;
2637
- email: string;
2638
- given_name: string;
2639
- family_name: string;
2640
- picture?: string | null | undefined;
2641
- encryption_public_key: string;
2642
- };
2643
- workspace_ext_id?: string | null | undefined;
2644
- content?: string | null | undefined;
2645
- read: boolean;
2646
- created_at: string;
2647
- updated_at: string;
2648
- }[]>;
2649
- declare function sendDM(arbi: ArbiClient, messages: Array<{
2650
- recipient_ext_id: string;
2651
- content: string;
2652
- }>): Promise<{
2653
- type: _arbidocs_client.components["schemas"]["NotificationType"];
2654
- external_id: string;
2655
- sender: {
2656
- external_id: string;
2657
- email: string;
2658
- given_name: string;
2659
- family_name: string;
2660
- picture?: string | null | undefined;
2661
- encryption_public_key: string;
2662
- };
2663
- recipient: {
2664
- external_id: string;
2665
- email: string;
2666
- given_name: string;
2667
- family_name: string;
2668
- picture?: string | null | undefined;
2669
- encryption_public_key: string;
2670
- };
2671
- workspace_ext_id?: string | null | undefined;
2672
- content?: string | null | undefined;
2673
- read: boolean;
2674
- created_at: string;
2675
- updated_at: string;
2676
- }[]>;
2677
- declare function markRead(arbi: ArbiClient, messageIds: string[]): Promise<{
2678
- type: _arbidocs_client.components["schemas"]["NotificationType"];
2679
- external_id: string;
2680
- sender: {
2681
- external_id: string;
2682
- email: string;
2683
- given_name: string;
2684
- family_name: string;
2685
- picture?: string | null | undefined;
2686
- encryption_public_key: string;
2687
- };
2688
- recipient: {
2689
- external_id: string;
2690
- email: string;
2691
- given_name: string;
2692
- family_name: string;
2693
- picture?: string | null | undefined;
2694
- encryption_public_key: string;
2695
- };
2696
- workspace_ext_id?: string | null | undefined;
2697
- content?: string | null | undefined;
2698
- read: boolean;
2699
- created_at: string;
2700
- updated_at: string;
2701
- }[]>;
2702
- declare function deleteDMs(arbi: ArbiClient, messageIds: string[]): Promise<void>;
2703
-
2704
- declare const dm_deleteDMs: typeof deleteDMs;
2705
- declare const dm_listDMs: typeof listDMs;
2706
- declare const dm_markRead: typeof markRead;
2707
- declare const dm_sendDM: typeof sendDM;
2708
- declare namespace dm {
2709
- export { dm_deleteDMs as deleteDMs, dm_listDMs as listDMs, dm_markRead as markRead, dm_sendDM as sendDM };
2710
- }
2711
-
2712
- /**
2713
- * User settings operations — get, update.
2714
- */
2715
-
2716
- type UserSettingsUpdate = components['schemas']['UserSettingsUpdate'];
2717
- declare function getSettings(arbi: ArbiClient): Promise<{
2718
- [x: string]: unknown;
2719
- subscription?: {
2720
- status: string;
2721
- trial_expires?: number | null | undefined;
2722
- } | null | undefined;
2723
- last_workspace?: string | null | undefined;
2724
- pinned_workspaces: string[];
2725
- tableviews: {
2726
- workspace: string;
2727
- name: string;
2728
- columns: string[];
2729
- }[];
2730
- developer: boolean;
2731
- show_document_navigator: boolean;
2732
- show_thread_visualization: boolean;
2733
- show_smart_search: boolean;
2734
- show_security_settings: boolean;
2735
- show_invite_tab: boolean;
2736
- show_help_page: boolean;
2737
- show_templates: boolean;
2738
- hide_online_status: boolean;
2739
- muted_users: string[];
2740
- }>;
2741
- declare function updateSettings(arbi: ArbiClient, body: UserSettingsUpdate): Promise<void>;
2742
-
2743
- declare const settings_getSettings: typeof getSettings;
2744
- declare const settings_updateSettings: typeof updateSettings;
2745
- declare namespace settings {
2746
- export { settings_getSettings as getSettings, settings_updateSettings as updateSettings };
2747
- }
2748
-
2749
- /**
2750
- * Agent configuration operations — list, get, save, delete, schema, models.
2751
- */
2752
-
2753
- type ConfigUpdateData = components['schemas']['ConfigUpdateData'];
2754
- declare function listConfigs(arbi: ArbiClient): Promise<{
2755
- versions: {
2756
- external_id: string;
2757
- title: string | null;
2758
- created_at: string;
2759
- }[];
2760
- }>;
2761
- declare function getConfig(arbi: ArbiClient, configId: string): Promise<{
2762
- Agents: {
2763
- ENABLED: boolean;
2764
- HUMAN_IN_THE_LOOP: boolean;
2765
- WEB_SEARCH?: {
2766
- ENABLED: boolean;
2767
- SAVE_SOURCES: boolean;
2768
- } | undefined;
2769
- MCP_TOOLS: string[];
2770
- PLANNING_ENABLED: boolean;
2771
- SUGGESTED_QUERIES: boolean;
2772
- ARTIFACTS_ENABLED: boolean;
2773
- VISION_ENABLED: boolean;
2774
- PERSONAL_AGENT: boolean;
2775
- REVIEW_ENABLED: boolean;
2776
- PERSONA: string;
2777
- AGENT_MODEL_NAME: string;
2778
- AGENT_API_TYPE: "local" | "remote";
2779
- LLM_AGENT_TEMPERATURE: number;
2780
- AGENT_MAX_TOKENS: number;
2781
- AGENT_MAX_ITERATIONS: number;
2782
- MAX_PASSAGE_PAGES: number;
2783
- AGENT_HISTORY_CHAR_THRESHOLD: number;
2784
- AGENT_SYSTEM_PROMPT: string;
2785
- };
2786
- QueryLLM: {
2787
- API_TYPE: "local" | "remote";
2788
- MODEL_NAME: string;
2789
- SYSTEM_INSTRUCTION: string;
2790
- MAX_CHAR_SIZE_TO_ANSWER: number;
2791
- TEMPERATURE: number;
2792
- MAX_TOKENS: number;
2793
- };
2794
- ReviewLLM: {
2795
- API_TYPE: "local" | "remote";
2796
- MODEL_NAME: string;
2797
- SYSTEM_INSTRUCTION: string;
2798
- TEMPERATURE: number;
2799
- MAX_TOKENS: number;
2800
- MAX_CHAR_SIZE_TO_ANSWER: number;
2801
- };
2802
- EvaluatorLLM: {
2803
- API_TYPE: "local" | "remote";
2804
- MODEL_NAME: string;
2805
- SYSTEM_INSTRUCTION: string;
2806
- TEMPERATURE: number;
2807
- MAX_TOKENS: number;
2808
- MAX_CHAR_SIZE_TO_ANSWER: number;
2809
- };
2810
- TitleLLM: {
2811
- API_TYPE: "local" | "remote";
2812
- MODEL_NAME: string;
2813
- SYSTEM_INSTRUCTION: string;
2814
- MAX_CHAR_SIZE_TO_ANSWER: number;
2815
- TEMPERATURE: number;
2816
- MAX_TOKENS: number;
2817
- };
2818
- SummariseLLM: {
2819
- API_TYPE: "local" | "remote";
2820
- MODEL_NAME: string;
2821
- SYSTEM_INSTRUCTION: string;
2822
- TEMPERATURE: number;
2823
- MAX_TOKENS: number;
2824
- MAX_CHAR_SIZE_TO_ANSWER: number;
2825
- COMPACTION_THRESHOLD_TOKENS: number;
2826
- COMPACTION_KEEP_RECENT: number;
2827
- };
2828
- DoctagLLM: {
2829
- API_TYPE: "local" | "remote";
2830
- MODEL_NAME: string;
2831
- SYSTEM_INSTRUCTION: string;
2832
- MAX_CHAR_CONTEXT_TO_ANSWER: number;
2833
- TEMPERATURE: number;
2834
- MAX_TOKENS: number;
2835
- MAX_CONCURRENT_DOCS: number;
2836
- DEFAULT_METADATA_TAGS: {
2837
- name: string;
2838
- instruction?: string | null | undefined;
2839
- tag_type?: {
2840
- type: "checkbox" | "text" | "number" | "select" | "folder" | "search" | "date";
2841
- options: string[];
2842
- } | undefined;
2843
- }[];
2844
- };
2845
- MemoryLLM: {
2846
- API_TYPE: "local" | "remote";
2847
- MODEL_NAME: string;
2848
- ENABLED: boolean;
2849
- SYSTEM_INSTRUCTION: string;
2850
- TEMPERATURE: number;
2851
- MAX_TOKENS: number;
2852
- MAX_CHAR_CONTEXT: number;
2853
- MAX_CONCURRENT: number;
2854
- };
2855
- PlanningLLM: {
2856
- API_TYPE: "local" | "remote";
2857
- MODEL_NAME: string;
2858
- SYSTEM_INSTRUCTION: string;
2859
- TEMPERATURE: number;
2860
- MAX_TOKENS: number;
2861
- MAX_CHAR_SIZE_TO_ANSWER: number;
2862
- APPROVAL_TIMEOUT: number;
2863
- };
2864
- VisionLLM: {
2865
- API_TYPE: "local" | "remote";
2866
- MODEL_NAME: string;
2867
- TEMPERATURE: number;
2868
- MAX_TOKENS: number;
2869
- MAX_PAGES_PER_CALL: number;
2870
- IMAGE_MAX_DIMENSION: number;
2871
- };
2872
- ModelCitation: {
2873
- SIM_THREASHOLD: number;
2874
- MIN_CHAR_SIZE_TO_ANSWER: number;
2875
- MAX_NUMB_CITATIONS: number;
2876
- };
2877
- Retriever: {
2878
- MIN_RETRIEVAL_SIM_SCORE: number;
2879
- MAX_DISTINCT_DOCUMENTS: number;
2880
- MAX_TOTAL_CHUNKS_TO_RETRIEVE: number;
2881
- GROUP_SIZE: number;
2882
- SEARCH_MODE: components["schemas"]["SearchMode"];
2883
- HYBRID_DENSE_WEIGHT: number;
2884
- HYBRID_SPARSE_WEIGHT: number;
2885
- HYBRID_RERANKER_WEIGHT: number;
2886
- };
2887
- Reranker: {
2888
- MAX_NUMB_OF_CHUNKS: number;
2889
- MAX_CONCURRENT_REQUESTS: number;
2890
- MODEL_NAME: string;
2891
- API_TYPE: "local" | "remote";
2892
- QUERY_INSTRUCTION: string;
2893
- };
2894
- Parser: {};
2895
- Chunker: {
2896
- MAX_CHUNK_TOKENS: number;
2897
- };
2898
- Embedder: {
2899
- MODEL_NAME: string;
2900
- API_TYPE: "local" | "remote";
2901
- BATCH_SIZE: number;
2902
- MAX_CONCURRENT_REQUESTS: number;
2903
- DOCUMENT_PREFIX: string;
2904
- QUERY_PREFIX: string;
2905
- };
2906
- KeywordEmbedder: {
2907
- DIMENSION_SPACE: number;
2908
- FILTER_STOPWORDS: boolean;
2909
- BM25_K1: number;
2910
- BM25_B: number;
2911
- BM25_AVGDL: number;
2912
- };
2913
- } | {
2914
- Agents: {
2915
- [x: string]: string | boolean;
2916
- };
2917
- MemoryLLM: {
2918
- [x: string]: boolean;
2919
- };
2920
- }>;
2921
- declare function saveConfig(arbi: ArbiClient, body: ConfigUpdateData): Promise<{
2922
- external_id: string;
2923
- title: string | null;
2924
- created_at: string;
2925
- }>;
2926
- declare function deleteConfig(arbi: ArbiClient, configId: string): Promise<{
2927
- detail: string;
2928
- }>;
2929
- declare function getSchema(arbi: ArbiClient): Promise<unknown>;
2930
- declare function getModels(arbi: ArbiClient): Promise<{
2931
- models: {
2932
- model_name: string;
2933
- api_type: string;
2934
- max_input_tokens?: number | null | undefined;
2935
- max_output_tokens?: number | null | undefined;
2936
- input_cost_per_token?: number | null | undefined;
2937
- output_cost_per_token?: number | null | undefined;
2938
- provider?: string | null | undefined;
2939
- mode?: string | null | undefined;
2940
- supports_vision?: boolean | null | undefined;
2941
- supports_reasoning?: boolean | null | undefined;
2942
- supports_function_calling?: boolean | null | undefined;
2943
- supports_response_schema?: boolean | null | undefined;
2944
- }[];
2945
- }>;
2946
-
2947
- declare const agentconfig_deleteConfig: typeof deleteConfig;
2948
- declare const agentconfig_getConfig: typeof getConfig;
2949
- declare const agentconfig_getModels: typeof getModels;
2950
- declare const agentconfig_getSchema: typeof getSchema;
2951
- declare const agentconfig_listConfigs: typeof listConfigs;
2952
- declare const agentconfig_saveConfig: typeof saveConfig;
2953
- declare namespace agentconfig {
2954
- export { agentconfig_deleteConfig as deleteConfig, agentconfig_getConfig as getConfig, agentconfig_getModels as getModels, agentconfig_getSchema as getSchema, agentconfig_listConfigs as listConfigs, agentconfig_saveConfig as saveConfig };
2955
- }
2956
-
2957
- /**
2958
- * Health and model operations.
2959
- */
2960
-
2961
- declare function getHealth(arbi: ArbiClient): Promise<{
2962
- status: string;
2963
- backend_git_hash?: string | null | undefined;
2964
- frontend_docker_version?: string | null | undefined;
2965
- services: {
2966
- name: string;
2967
- status: string;
2968
- detail?: string | null | undefined;
2969
- service_info?: {
2970
- [x: string]: unknown;
2971
- } | null | undefined;
2972
- }[];
2973
- models_health?: {
2974
- application: string;
2975
- models: {
2976
- model: string;
2977
- status: string;
2978
- detail?: string | null | undefined;
2979
- }[];
2980
- } | null | undefined;
2981
- available_models: string[];
2982
- }>;
2983
- declare function getHealthModels(arbi: ArbiClient): Promise<{
2984
- models: {
2985
- model_name: string;
2986
- api_type: string;
2987
- max_input_tokens?: number | null | undefined;
2988
- max_output_tokens?: number | null | undefined;
2989
- input_cost_per_token?: number | null | undefined;
2990
- output_cost_per_token?: number | null | undefined;
2991
- provider?: string | null | undefined;
2992
- mode?: string | null | undefined;
2993
- supports_vision?: boolean | null | undefined;
2994
- supports_reasoning?: boolean | null | undefined;
2995
- supports_function_calling?: boolean | null | undefined;
2996
- supports_response_schema?: boolean | null | undefined;
2997
- }[];
2998
- }>;
2999
- declare function getRemoteModels(arbi: ArbiClient): Promise<{
3000
- application: string;
3001
- models: {
3002
- model: string;
3003
- status: string;
3004
- detail?: string | null | undefined;
3005
- }[];
3006
- }>;
3007
- declare function getMcpTools(arbi: ArbiClient): Promise<{
3008
- tools: {
3009
- name: string;
3010
- description: string;
3011
- server_name: string;
3012
- }[];
3013
- }>;
3014
-
3015
- declare const health_getHealth: typeof getHealth;
3016
- declare const health_getHealthModels: typeof getHealthModels;
3017
- declare const health_getMcpTools: typeof getMcpTools;
3018
- declare const health_getRemoteModels: typeof getRemoteModels;
3019
- declare namespace health {
3020
- export { health_getHealth as getHealth, health_getHealthModels as getHealthModels, health_getMcpTools as getMcpTools, health_getRemoteModels as getRemoteModels };
83
+ declare const documentsNode_uploadDirectory: typeof uploadDirectory;
84
+ declare const documentsNode_uploadLocalFile: typeof uploadLocalFile;
85
+ declare const documentsNode_uploadZip: typeof uploadZip;
86
+ declare namespace documentsNode {
87
+ export { documentsNode_uploadDirectory as uploadDirectory, documentsNode_uploadLocalFile as uploadLocalFile, documentsNode_uploadZip as uploadZip };
3021
88
  }
3022
89
 
3023
- export { type AgentStepEvent, Arbi, ArbiApiError, ArbiError, type ArbiOptions, type ArtifactEvent, type AuthContext, type AuthHeaders, type AuthenticatedClient, type ChatSession, type CliConfig, type CliCredentials, type ConfigStore, type ConnectOptions, type DocumentWaiter, type DocumentWaiterOptions, FileConfigStore, type FormattedWsMessage, type MessageLevel, type MessageMetadataPayload, type OutputTokensDetails, type QueryOptions, type ReconnectOptions, type ReconnectableWsConnection, type ResponseCompletedEvent, type ResponseContentPartAddedEvent, type ResponseCreatedEvent, type ResponseFailedEvent, type ResponseOutputItemAddedEvent, type ResponseOutputItemDoneEvent, type ResponseOutputTextDeltaEvent, type ResponseOutputTextDoneEvent, type ResponseUsage, type SSEEvent, type SSEStreamCallbacks, type SSEStreamResult, type SSEStreamStartData, type UserInfo, type UserInputRequestEvent, type UserMessageEvent, type WorkspaceContext, type WsConnection, agentconfig, assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts, conversations, createAuthenticatedClient, createDocumentWaiter, dm, doctags, documents, files, formatFileSize, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, getErrorMessage, health, parseSSEEvents, performPasswordLogin, requireData, requireOk, resolveAuth, resolveWorkspace, selectWorkspace, selectWorkspaceById, settings, streamSSE, tags, workspaces };
90
+ export { AuthHeaders, ChatSession, CliConfig, CliCredentials, ConfigStore, FileConfigStore, documentsNode };