@exulu/backend 5.12.0 → 5.14.0

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
@@ -208,6 +208,49 @@ type ResolveOcrInput = {
208
208
  id: string;
209
209
  name: string;
210
210
  };
211
+ /**
212
+ * Abort an OCR request after this long (a timeout rejects, which the caller's retry logic treats
213
+ * as a failed attempt). Omitted = no explicit timeout, as before.
214
+ */
215
+ timeoutMs?: number;
216
+ };
217
+
218
+ /**
219
+ * Progress of reading one document into the store; delivered to every caller waiting on it.
220
+ * "text" is reserved (not emitted today; the frontend handles it).
221
+ */
222
+ type ProgressFn = (p: {
223
+ phase: "text" | "ocr" | "vision" | "storing";
224
+ pagesDone: number;
225
+ pagesTotal: number;
226
+ }) => void;
227
+ /**
228
+ * Interim tool result shown in the chat while a document is read. Never model-facing:
229
+ * the SDK marks every yielded value but the last as preliminary, and the convert
230
+ * wrapper passes these through untouched (no guard, no audit).
231
+ */
232
+ type ReadingStatus = {
233
+ status: "reading";
234
+ filename: string;
235
+ phase: "cached" | "text" | "ocr" | "vision" | "storing";
236
+ pagesDone: number;
237
+ pagesTotal: number;
238
+ };
239
+
240
+ /** Runs `fn` under a ceiling. */
241
+ type ProviderLimiter = <T>(fn: () => Promise<T>) => Promise<T>;
242
+ /**
243
+ * What the chat paths pass to documentProcessor. The call time limits travel with the limiters:
244
+ * a stalled provider must not pin chat slots, while knowledge-base processing (which passes
245
+ * none) keeps the transport's own, longer limit exactly as before.
246
+ */
247
+ type ProviderLimiters = {
248
+ ocr: ProviderLimiter;
249
+ vision: ProviderLimiter;
250
+ /** Longest one OCR request may take; a timeout counts as a failed attempt for the retry logic. */
251
+ ocrTimeoutMs?: number;
252
+ /** Longest one vision (page validation) call may take; same retry treatment. */
253
+ visionTimeoutMs?: number;
211
254
  };
212
255
 
213
256
  type DocumentProcessorConfig = {
@@ -222,6 +265,14 @@ type DocumentProcessorConfig = {
222
265
  model: string;
223
266
  concurrency: number;
224
267
  };
268
+ /**
269
+ * OCR settings. `concurrency` is how many OCR chunk calls ONE document runs
270
+ * at once (default 3, 1..8). Reads in chat additionally share a process-wide
271
+ * ceiling of 8 (see limits.ts); knowledge-base processing does not.
272
+ */
273
+ ocr?: {
274
+ concurrency?: number;
275
+ };
225
276
  processor: {
226
277
  name: "liteparse" | "mistral" | "officeparser";
227
278
  /**
@@ -259,12 +310,23 @@ type ProcessedPage = {
259
310
  image?: string;
260
311
  vlm_corrected_text?: string;
261
312
  vlm_validated?: boolean;
313
+ /** Set only under tolerateVisionFailures: the vision pass failed for this page, the text is OCR only. */
314
+ vlm_failed?: boolean;
262
315
  };
263
316
  type ProcessedDocument = ProcessedPage[];
264
- declare function documentProcessor({ file, name, config }: {
317
+ declare function documentProcessor({ file, name, config, tolerateVisionFailures, onProgress, limiters, }: {
265
318
  file: string | Buffer;
266
319
  name: string;
267
320
  config?: DocumentProcessorConfig;
321
+ /** A page whose vision pass failed keeps its OCR text and is flagged `vlm_failed` instead of failing the document. */
322
+ tolerateVisionFailures?: boolean;
323
+ /** Reports OCR progress per finished chunk and vision progress per finished page. */
324
+ onProgress?: ProgressFn;
325
+ /**
326
+ * Process-wide ceilings on OCR and vision calls. Passed by the chat paths only (extractDocument);
327
+ * absent for knowledge-base processing, which keeps its per-document limits unchanged.
328
+ */
329
+ limiters?: ProviderLimiters;
268
330
  }): Promise<ProcessedDocument | undefined>;
269
331
 
270
332
  interface TestCase {
@@ -1018,6 +1080,13 @@ declare class ExuluTool {
1018
1080
  toolCallId: string;
1019
1081
  messages: unknown[];
1020
1082
  }) => Promise<boolean>;
1083
+ /**
1084
+ * Calls for which approval is ALWAYS asked, even when the user allowed the tool for this
1085
+ * chat (e.g. save_to_project with overwrite: true). Only narrows the shortcut: a call whose
1086
+ * approval was already answered is still honoured by the approval wiring.
1087
+ * Ignored for tools that set `needsApprovalFn` (that check decides every call on its own).
1088
+ */
1089
+ alwaysAskWhen?: (input: unknown) => boolean;
1021
1090
  authentication?: ExuluAuthConfig;
1022
1091
  config: {
1023
1092
  name: string;
@@ -1025,7 +1094,7 @@ declare class ExuluTool {
1025
1094
  type: "boolean" | "string" | "number" | "variable" | "json";
1026
1095
  default?: string | boolean | number | object;
1027
1096
  }[];
1028
- constructor({ id, name, description, category, inputSchema, type, execute, config, needsApproval, needsApprovalFn, authentication, }: {
1097
+ constructor({ id, name, description, category, inputSchema, type, execute, config, needsApproval, needsApprovalFn, alwaysAskWhen, authentication, }: {
1029
1098
  id: string;
1030
1099
  name: string;
1031
1100
  description: string;
@@ -1043,6 +1112,7 @@ declare class ExuluTool {
1043
1112
  toolCallId: string;
1044
1113
  messages: unknown[];
1045
1114
  }) => Promise<boolean>;
1115
+ alwaysAskWhen?: (input: unknown) => boolean;
1046
1116
  authentication?: ExuluAuthConfig;
1047
1117
  execute: (inputs: any, options?: any) => Promise<{
1048
1118
  result?: string;
@@ -1052,7 +1122,7 @@ declare class ExuluTool {
1052
1122
  result?: string;
1053
1123
  job?: string;
1054
1124
  items?: Item[];
1055
- }>;
1125
+ } | ReadingStatus>;
1056
1126
  });
1057
1127
  /**
1058
1128
  * Framework-only factory for tools whose `type` is managed by Exulu itself —
@@ -1333,6 +1403,32 @@ declare class ExuluApp {
1333
1403
  private server;
1334
1404
  }
1335
1405
 
1406
+ type AddFileResult = {
1407
+ name: string;
1408
+ skipped?: true;
1409
+ } | {
1410
+ error: string;
1411
+ };
1412
+ /**
1413
+ * For trusted server-side code (scripts, migrations). There is no user context: never call
1414
+ * this from a tool on behalf of a user.
1415
+ */
1416
+ declare const ExuluProjects: {
1417
+ create(input: {
1418
+ name: string;
1419
+ description?: string;
1420
+ ownerId: number | string;
1421
+ }): Promise<{
1422
+ id: string;
1423
+ }>;
1424
+ addFile(input: {
1425
+ projectId: string;
1426
+ name: string;
1427
+ data: Uint8Array | Buffer;
1428
+ ifExists?: "error" | "skip";
1429
+ }): Promise<AddFileResult>;
1430
+ };
1431
+
1336
1432
  declare class ExuluQueues {
1337
1433
  queues: {
1338
1434
  queue: Queue;
@@ -2887,4 +2983,4 @@ declare const ExuluPython: {
2887
2983
  instructions: typeof getPythonSetupInstructions;
2888
2984
  };
2889
2985
 
2890
- export { type AuditConfig, type AuditEvent, type AuditLogger, type ChunkerOperation, type ChunkerResponse, type CredentialField, CredentialInvalidError, type JOB_STATUS as EXULU_JOB_STATUS, JOB_STATUS_ENUM as EXULU_JOB_STATUS_ENUM, type STATISTICS_TYPE as EXULU_STATISTICS_TYPE, STATISTICS_TYPE_ENUM as EXULU_STATISTICS_TYPE_ENUM, type ExuluAgent, ExuluApp, type ExuluAuthConfig, ExuluAuthentication, ExuluChunkers, ExuluContext, type ExuluContextEmbedder, type ExuluCredentialsToolContext, ExuluDatabase, ExuluDefaultTools, ExuluDocumentProcessor, ExuluEval, type Item as ExuluItem, ExuluJobs, ExuluModels, type ExuluOauthConfig, type ExuluOauthToolContext, ExuluOtel, ExuluPython, queues as ExuluQueues, ExuluReadApi, ExuluRecall, ExuluReranker, ExuluTool, type ExuluUserCredentialsConfig, ExuluVariables, PROJECTION_VERSION, type RoutineHandle, type RoutineRunPatch, type VectorSearchChunkResult, backfillCoordinates, checkMemoryBase, defaultChunker, enableLiteLLMClientMode, fitContextProjection, listFittableContexts, postgresClient, recallMemories };
2986
+ export { type AuditConfig, type AuditEvent, type AuditLogger, type ChunkerOperation, type ChunkerResponse, type CredentialField, CredentialInvalidError, type JOB_STATUS as EXULU_JOB_STATUS, JOB_STATUS_ENUM as EXULU_JOB_STATUS_ENUM, type STATISTICS_TYPE as EXULU_STATISTICS_TYPE, STATISTICS_TYPE_ENUM as EXULU_STATISTICS_TYPE_ENUM, type ExuluAgent, ExuluApp, type ExuluAuthConfig, ExuluAuthentication, ExuluChunkers, ExuluContext, type ExuluContextEmbedder, type ExuluCredentialsToolContext, ExuluDatabase, ExuluDefaultTools, ExuluDocumentProcessor, ExuluEval, type Item as ExuluItem, ExuluJobs, ExuluModels, type ExuluOauthConfig, type ExuluOauthToolContext, ExuluOtel, ExuluProjects, ExuluPython, queues as ExuluQueues, ExuluReadApi, ExuluRecall, ExuluReranker, ExuluTool, type ExuluUserCredentialsConfig, ExuluVariables, PROJECTION_VERSION, type RoutineHandle, type RoutineRunPatch, type VectorSearchChunkResult, backfillCoordinates, checkMemoryBase, defaultChunker, enableLiteLLMClientMode, fitContextProjection, listFittableContexts, postgresClient, recallMemories };
package/dist/index.d.ts CHANGED
@@ -208,6 +208,49 @@ type ResolveOcrInput = {
208
208
  id: string;
209
209
  name: string;
210
210
  };
211
+ /**
212
+ * Abort an OCR request after this long (a timeout rejects, which the caller's retry logic treats
213
+ * as a failed attempt). Omitted = no explicit timeout, as before.
214
+ */
215
+ timeoutMs?: number;
216
+ };
217
+
218
+ /**
219
+ * Progress of reading one document into the store; delivered to every caller waiting on it.
220
+ * "text" is reserved (not emitted today; the frontend handles it).
221
+ */
222
+ type ProgressFn = (p: {
223
+ phase: "text" | "ocr" | "vision" | "storing";
224
+ pagesDone: number;
225
+ pagesTotal: number;
226
+ }) => void;
227
+ /**
228
+ * Interim tool result shown in the chat while a document is read. Never model-facing:
229
+ * the SDK marks every yielded value but the last as preliminary, and the convert
230
+ * wrapper passes these through untouched (no guard, no audit).
231
+ */
232
+ type ReadingStatus = {
233
+ status: "reading";
234
+ filename: string;
235
+ phase: "cached" | "text" | "ocr" | "vision" | "storing";
236
+ pagesDone: number;
237
+ pagesTotal: number;
238
+ };
239
+
240
+ /** Runs `fn` under a ceiling. */
241
+ type ProviderLimiter = <T>(fn: () => Promise<T>) => Promise<T>;
242
+ /**
243
+ * What the chat paths pass to documentProcessor. The call time limits travel with the limiters:
244
+ * a stalled provider must not pin chat slots, while knowledge-base processing (which passes
245
+ * none) keeps the transport's own, longer limit exactly as before.
246
+ */
247
+ type ProviderLimiters = {
248
+ ocr: ProviderLimiter;
249
+ vision: ProviderLimiter;
250
+ /** Longest one OCR request may take; a timeout counts as a failed attempt for the retry logic. */
251
+ ocrTimeoutMs?: number;
252
+ /** Longest one vision (page validation) call may take; same retry treatment. */
253
+ visionTimeoutMs?: number;
211
254
  };
212
255
 
213
256
  type DocumentProcessorConfig = {
@@ -222,6 +265,14 @@ type DocumentProcessorConfig = {
222
265
  model: string;
223
266
  concurrency: number;
224
267
  };
268
+ /**
269
+ * OCR settings. `concurrency` is how many OCR chunk calls ONE document runs
270
+ * at once (default 3, 1..8). Reads in chat additionally share a process-wide
271
+ * ceiling of 8 (see limits.ts); knowledge-base processing does not.
272
+ */
273
+ ocr?: {
274
+ concurrency?: number;
275
+ };
225
276
  processor: {
226
277
  name: "liteparse" | "mistral" | "officeparser";
227
278
  /**
@@ -259,12 +310,23 @@ type ProcessedPage = {
259
310
  image?: string;
260
311
  vlm_corrected_text?: string;
261
312
  vlm_validated?: boolean;
313
+ /** Set only under tolerateVisionFailures: the vision pass failed for this page, the text is OCR only. */
314
+ vlm_failed?: boolean;
262
315
  };
263
316
  type ProcessedDocument = ProcessedPage[];
264
- declare function documentProcessor({ file, name, config }: {
317
+ declare function documentProcessor({ file, name, config, tolerateVisionFailures, onProgress, limiters, }: {
265
318
  file: string | Buffer;
266
319
  name: string;
267
320
  config?: DocumentProcessorConfig;
321
+ /** A page whose vision pass failed keeps its OCR text and is flagged `vlm_failed` instead of failing the document. */
322
+ tolerateVisionFailures?: boolean;
323
+ /** Reports OCR progress per finished chunk and vision progress per finished page. */
324
+ onProgress?: ProgressFn;
325
+ /**
326
+ * Process-wide ceilings on OCR and vision calls. Passed by the chat paths only (extractDocument);
327
+ * absent for knowledge-base processing, which keeps its per-document limits unchanged.
328
+ */
329
+ limiters?: ProviderLimiters;
268
330
  }): Promise<ProcessedDocument | undefined>;
269
331
 
270
332
  interface TestCase {
@@ -1018,6 +1080,13 @@ declare class ExuluTool {
1018
1080
  toolCallId: string;
1019
1081
  messages: unknown[];
1020
1082
  }) => Promise<boolean>;
1083
+ /**
1084
+ * Calls for which approval is ALWAYS asked, even when the user allowed the tool for this
1085
+ * chat (e.g. save_to_project with overwrite: true). Only narrows the shortcut: a call whose
1086
+ * approval was already answered is still honoured by the approval wiring.
1087
+ * Ignored for tools that set `needsApprovalFn` (that check decides every call on its own).
1088
+ */
1089
+ alwaysAskWhen?: (input: unknown) => boolean;
1021
1090
  authentication?: ExuluAuthConfig;
1022
1091
  config: {
1023
1092
  name: string;
@@ -1025,7 +1094,7 @@ declare class ExuluTool {
1025
1094
  type: "boolean" | "string" | "number" | "variable" | "json";
1026
1095
  default?: string | boolean | number | object;
1027
1096
  }[];
1028
- constructor({ id, name, description, category, inputSchema, type, execute, config, needsApproval, needsApprovalFn, authentication, }: {
1097
+ constructor({ id, name, description, category, inputSchema, type, execute, config, needsApproval, needsApprovalFn, alwaysAskWhen, authentication, }: {
1029
1098
  id: string;
1030
1099
  name: string;
1031
1100
  description: string;
@@ -1043,6 +1112,7 @@ declare class ExuluTool {
1043
1112
  toolCallId: string;
1044
1113
  messages: unknown[];
1045
1114
  }) => Promise<boolean>;
1115
+ alwaysAskWhen?: (input: unknown) => boolean;
1046
1116
  authentication?: ExuluAuthConfig;
1047
1117
  execute: (inputs: any, options?: any) => Promise<{
1048
1118
  result?: string;
@@ -1052,7 +1122,7 @@ declare class ExuluTool {
1052
1122
  result?: string;
1053
1123
  job?: string;
1054
1124
  items?: Item[];
1055
- }>;
1125
+ } | ReadingStatus>;
1056
1126
  });
1057
1127
  /**
1058
1128
  * Framework-only factory for tools whose `type` is managed by Exulu itself —
@@ -1333,6 +1403,32 @@ declare class ExuluApp {
1333
1403
  private server;
1334
1404
  }
1335
1405
 
1406
+ type AddFileResult = {
1407
+ name: string;
1408
+ skipped?: true;
1409
+ } | {
1410
+ error: string;
1411
+ };
1412
+ /**
1413
+ * For trusted server-side code (scripts, migrations). There is no user context: never call
1414
+ * this from a tool on behalf of a user.
1415
+ */
1416
+ declare const ExuluProjects: {
1417
+ create(input: {
1418
+ name: string;
1419
+ description?: string;
1420
+ ownerId: number | string;
1421
+ }): Promise<{
1422
+ id: string;
1423
+ }>;
1424
+ addFile(input: {
1425
+ projectId: string;
1426
+ name: string;
1427
+ data: Uint8Array | Buffer;
1428
+ ifExists?: "error" | "skip";
1429
+ }): Promise<AddFileResult>;
1430
+ };
1431
+
1336
1432
  declare class ExuluQueues {
1337
1433
  queues: {
1338
1434
  queue: Queue;
@@ -2887,4 +2983,4 @@ declare const ExuluPython: {
2887
2983
  instructions: typeof getPythonSetupInstructions;
2888
2984
  };
2889
2985
 
2890
- export { type AuditConfig, type AuditEvent, type AuditLogger, type ChunkerOperation, type ChunkerResponse, type CredentialField, CredentialInvalidError, type JOB_STATUS as EXULU_JOB_STATUS, JOB_STATUS_ENUM as EXULU_JOB_STATUS_ENUM, type STATISTICS_TYPE as EXULU_STATISTICS_TYPE, STATISTICS_TYPE_ENUM as EXULU_STATISTICS_TYPE_ENUM, type ExuluAgent, ExuluApp, type ExuluAuthConfig, ExuluAuthentication, ExuluChunkers, ExuluContext, type ExuluContextEmbedder, type ExuluCredentialsToolContext, ExuluDatabase, ExuluDefaultTools, ExuluDocumentProcessor, ExuluEval, type Item as ExuluItem, ExuluJobs, ExuluModels, type ExuluOauthConfig, type ExuluOauthToolContext, ExuluOtel, ExuluPython, queues as ExuluQueues, ExuluReadApi, ExuluRecall, ExuluReranker, ExuluTool, type ExuluUserCredentialsConfig, ExuluVariables, PROJECTION_VERSION, type RoutineHandle, type RoutineRunPatch, type VectorSearchChunkResult, backfillCoordinates, checkMemoryBase, defaultChunker, enableLiteLLMClientMode, fitContextProjection, listFittableContexts, postgresClient, recallMemories };
2986
+ export { type AuditConfig, type AuditEvent, type AuditLogger, type ChunkerOperation, type ChunkerResponse, type CredentialField, CredentialInvalidError, type JOB_STATUS as EXULU_JOB_STATUS, JOB_STATUS_ENUM as EXULU_JOB_STATUS_ENUM, type STATISTICS_TYPE as EXULU_STATISTICS_TYPE, STATISTICS_TYPE_ENUM as EXULU_STATISTICS_TYPE_ENUM, type ExuluAgent, ExuluApp, type ExuluAuthConfig, ExuluAuthentication, ExuluChunkers, ExuluContext, type ExuluContextEmbedder, type ExuluCredentialsToolContext, ExuluDatabase, ExuluDefaultTools, ExuluDocumentProcessor, ExuluEval, type Item as ExuluItem, ExuluJobs, ExuluModels, type ExuluOauthConfig, type ExuluOauthToolContext, ExuluOtel, ExuluProjects, ExuluPython, queues as ExuluQueues, ExuluReadApi, ExuluRecall, ExuluReranker, ExuluTool, type ExuluUserCredentialsConfig, ExuluVariables, PROJECTION_VERSION, type RoutineHandle, type RoutineRunPatch, type VectorSearchChunkResult, backfillCoordinates, checkMemoryBase, defaultChunker, enableLiteLLMClientMode, fitContextProjection, listFittableContexts, postgresClient, recallMemories };