@exulu/backend 1.23.2 → 1.24.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.ts CHANGED
@@ -2,9 +2,9 @@ import * as _opentelemetry_sdk_node from '@opentelemetry/sdk-node';
2
2
  import * as bullmq from 'bullmq';
3
3
  import { Queue } from 'bullmq';
4
4
  import { RedisClientType } from 'redis';
5
- import { ZodSchema } from 'zod';
5
+ import { z } from 'zod';
6
6
  import { Tool, LanguageModel, UIMessage } from 'ai';
7
- import { Response, Request, Express } from 'express';
7
+ import { Express, Response, Request } from 'express';
8
8
  import { Knex } from 'knex';
9
9
  import { Tiktoken } from 'tiktoken/lite';
10
10
  import models from 'tiktoken/model_to_encoding.json';
@@ -26,7 +26,7 @@ declare const STATISTICS_TYPE_ENUM: {
26
26
  AGENT_RUN: string;
27
27
  };
28
28
 
29
- type ExuluFieldTypes = "text" | "longText" | "shortText" | "number" | "boolean" | "code" | "json" | "enum";
29
+ type ExuluFieldTypes = "text" | "longText" | "shortText" | "number" | "boolean" | "code" | "json" | "enum" | "markdown";
30
30
 
31
31
  interface Item {
32
32
  id?: string;
@@ -50,12 +50,92 @@ interface Item {
50
50
  [key: string]: any;
51
51
  }
52
52
 
53
- declare const VectorMethodEnum: {
54
- readonly cosineDistance: "cosineDistance";
55
- readonly hybridSearch: "hybridSearch";
56
- readonly tsvector: "tsvector";
53
+ type ExuluConfig = {
54
+ telemetry?: {
55
+ enabled: boolean;
56
+ };
57
+ workers: {
58
+ enabled: boolean;
59
+ logsDir?: string;
60
+ telemetry?: {
61
+ enabled: boolean;
62
+ };
63
+ };
64
+ MCP: {
65
+ enabled: boolean;
66
+ };
67
+ fileUploads: {
68
+ s3region: string;
69
+ s3key: string;
70
+ s3secret: string;
71
+ s3Bucket: string;
72
+ s3endpoint?: string;
73
+ };
74
+ };
75
+ declare class ExuluApp {
76
+ private _agents;
77
+ private _config?;
78
+ private _queues;
79
+ private _contexts?;
80
+ private _tools;
81
+ private _expressApp;
82
+ constructor();
83
+ create: ({ contexts, agents, config, tools }: {
84
+ contexts?: Record<string, ExuluContext>;
85
+ config: ExuluConfig;
86
+ agents?: ExuluAgent[];
87
+ tools?: ExuluTool[];
88
+ }) => Promise<Express>;
89
+ get expressApp(): Express;
90
+ tool(id: string): ExuluTool | undefined;
91
+ tools(): ExuluTool[];
92
+ context(id: string): ExuluContext | undefined;
93
+ agent(id: string): ExuluAgent | undefined;
94
+ get contexts(): ExuluContext[];
95
+ get agents(): ExuluAgent[];
96
+ embeddings: {
97
+ generate: {
98
+ one: ({ context: contextId, item: itemId }: {
99
+ context: string;
100
+ item: string;
101
+ }) => Promise<{
102
+ id: string;
103
+ job?: string;
104
+ chunks?: number;
105
+ }>;
106
+ all: ({ context: contextId }: {
107
+ context: string;
108
+ }) => Promise<{
109
+ jobs: string[];
110
+ items: number;
111
+ }>;
112
+ };
113
+ };
114
+ bullmq: {
115
+ workers: {
116
+ create: () => Promise<bullmq.Worker<any, any, string>[]>;
117
+ };
118
+ };
119
+ private server;
120
+ }
121
+
122
+ type User = {
123
+ id: number;
124
+ email: string;
125
+ emailVerified?: string;
126
+ type?: "api" | "user";
127
+ anthropic_token?: string;
128
+ super_admin?: boolean;
129
+ favourite_agents?: string[];
130
+ role: {
131
+ id: string;
132
+ name: string;
133
+ agents: "read" | "write";
134
+ workflows: "read" | "write";
135
+ variables: "read" | "write";
136
+ users: "read" | "write";
137
+ };
57
138
  };
58
- type VectorMethod = (typeof VectorMethodEnum)[keyof typeof VectorMethodEnum];
59
139
 
60
140
  interface RateLimiterRule {
61
141
  name?: string;
@@ -72,7 +152,7 @@ type ExuluAgentConfig = {
72
152
  apiKey: string;
73
153
  }) => LanguageModel;
74
154
  };
75
- outputSchema?: ZodSchema;
155
+ outputSchema?: z.ZodType;
76
156
  custom?: {
77
157
  name: string;
78
158
  description: string;
@@ -89,25 +169,31 @@ type ExuluAgentConfig = {
89
169
  type ExuluAgentEval = {
90
170
  runner: ExuluEvalRunnerInstance;
91
171
  };
172
+ type imageTypes = '.png' | '.jpg' | '.jpeg' | '.gif' | '.webp';
173
+ type fileTypes = '.pdf' | '.docx' | '.xlsx' | '.xls' | '.csv' | '.pptx' | '.ppt' | '.txt' | '.md' | '.json';
174
+ type audioTypes = '.mp3' | '.wav' | '.m4a' | '.mp4' | '.mpeg';
175
+ type videoTypes = '.mp4' | '.m4a' | '.mp3' | '.mpeg' | '.wav';
92
176
  interface ExuluAgentParams {
93
177
  id: string;
94
178
  name: string;
95
- type: "agent" | "custom";
179
+ type: "agent";
96
180
  description: string;
97
181
  config?: ExuluAgentConfig | undefined;
182
+ maxContextLength?: number;
98
183
  capabilities?: {
99
184
  text: boolean;
100
- images: ('.png' | '.jpg' | '.jpeg' | '.gif' | '.webp')[];
101
- files: ('.pdf' | '.docx' | '.xlsx' | '.xls' | '.csv' | '.pptx' | '.ppt')[];
102
- audio: ('.mp3' | '.wav' | '.m4a' | '.mp4' | '.mpeg')[];
103
- video: ('.mp4' | '.m4a' | '.mp3' | '.mpeg' | '.wav')[];
185
+ images: imageTypes[];
186
+ files: fileTypes[];
187
+ audio: audioTypes[];
188
+ video: videoTypes[];
104
189
  };
105
190
  evals?: ExuluAgentEval[];
106
- outputSchema?: ZodSchema;
191
+ outputSchema?: z.ZodType;
107
192
  rateLimit?: RateLimiterRule;
108
193
  }
109
194
  interface ExuluAgentToolConfig {
110
- toolId: string;
195
+ id: string;
196
+ type: string;
111
197
  config: {
112
198
  name: string;
113
199
  variable: string;
@@ -119,8 +205,9 @@ declare class ExuluAgent {
119
205
  name: string;
120
206
  description: string;
121
207
  slug: string;
122
- type: "agent" | "custom";
208
+ type: "agent";
123
209
  streaming: boolean;
210
+ maxContextLength?: number;
124
211
  rateLimit?: RateLimiterRule;
125
212
  config?: ExuluAgentConfig | undefined;
126
213
  evals?: ExuluAgentEval[];
@@ -136,34 +223,43 @@ declare class ExuluAgent {
136
223
  audio: string[];
137
224
  video: string[];
138
225
  };
139
- constructor({ id, name, description, config, rateLimit, capabilities, type, evals }: ExuluAgentParams);
226
+ constructor({ id, name, description, config, rateLimit, capabilities, type, evals, maxContextLength }: ExuluAgentParams);
140
227
  get providerName(): string;
141
228
  get modelName(): string;
142
- tool: () => ExuluTool;
143
- generateSync: ({ prompt, user, role, session, message, tools, statistics, toolConfigs, providerApiKey }: {
229
+ tool: (instance: string, agents: ExuluAgent[]) => Promise<ExuluTool | null>;
230
+ generateSync: ({ prompt, user, session, message, currentTools, allExuluTools, statistics, toolConfigs, providerapikey, contexts, exuluConfig, filesContext, outputSchema, instructions }: {
144
231
  prompt?: string;
145
- user?: string;
146
- role?: string;
232
+ user?: User;
147
233
  session?: string;
148
234
  message?: UIMessage;
149
- tools?: ExuluTool[];
235
+ currentTools?: ExuluTool[];
236
+ allExuluTools?: ExuluTool[];
150
237
  statistics?: ExuluStatisticParams;
151
238
  toolConfigs?: ExuluAgentToolConfig[];
152
- providerApiKey: string;
153
- }) => Promise<string | undefined>;
154
- generateStream: ({ express, user, role, session, message, tools, statistics, toolConfigs, providerApiKey }: {
239
+ providerapikey: string;
240
+ contexts?: ExuluContext[] | undefined;
241
+ exuluConfig?: ExuluConfig;
242
+ filesContext?: ExuluContext;
243
+ instructions?: string;
244
+ outputSchema?: z.ZodType;
245
+ }) => Promise<string | any>;
246
+ generateStream: ({ express, user, session, message, currentTools, allExuluTools, statistics, toolConfigs, providerapikey, contexts, exuluConfig, filesContext, instructions, }: {
155
247
  express: {
156
248
  res: Response;
157
249
  req: Request;
158
250
  };
159
- user: string;
160
- role: string;
251
+ user: User;
161
252
  session: string;
162
253
  message?: UIMessage;
163
- tools?: ExuluTool[];
254
+ currentTools?: ExuluTool[];
255
+ allExuluTools?: ExuluTool[];
164
256
  statistics?: ExuluStatisticParams;
165
257
  toolConfigs?: ExuluAgentToolConfig[];
166
- providerApiKey: string;
258
+ providerapikey: string;
259
+ contexts?: ExuluContext[] | undefined;
260
+ exuluConfig?: ExuluConfig;
261
+ filesContext?: ExuluContext;
262
+ instructions?: string;
167
263
  }) => Promise<void>;
168
264
  }
169
265
  type VectorOperationResponse = Promise<{
@@ -211,8 +307,8 @@ declare class ExuluEmbedder {
211
307
  vectorDimensions: number;
212
308
  maxChunkSize: number;
213
309
  });
214
- generateFromQuery(query: string, statistics?: ExuluStatisticParams, user?: string, role?: string): VectorGenerationResponse;
215
- generateFromDocument(input: Item, statistics?: ExuluStatisticParams, user?: string, role?: string): VectorGenerationResponse;
310
+ generateFromQuery(query: string, statistics?: ExuluStatisticParams, user?: number, role?: string): VectorGenerationResponse;
311
+ generateFromDocument(input: Item, statistics?: ExuluStatisticParams, user?: number, role?: string): VectorGenerationResponse;
216
312
  }
217
313
  interface WorkflowVariable {
218
314
  name: string;
@@ -258,7 +354,7 @@ type ExuluEvalRunner = ({ data, runner }: {
258
354
  data: ExuluEvalInput;
259
355
  runner: {
260
356
  agent?: ExuluAgent & {
261
- providerApiKey: string;
357
+ providerapikey: string;
262
358
  };
263
359
  workflow?: ExuluWorkflow;
264
360
  };
@@ -301,7 +397,7 @@ declare class ExuluTool {
301
397
  id: string;
302
398
  name: string;
303
399
  description: string;
304
- inputSchema?: ZodSchema;
400
+ inputSchema?: z.ZodType;
305
401
  type: "context" | "function" | "agent";
306
402
  tool: Tool;
307
403
  config: {
@@ -312,13 +408,21 @@ declare class ExuluTool {
312
408
  id: string;
313
409
  name: string;
314
410
  description: string;
315
- inputSchema?: ZodSchema;
411
+ inputSchema?: z.ZodType;
316
412
  type: "context" | "function" | "agent";
317
413
  config: {
318
414
  name: string;
319
415
  description: string;
320
416
  }[];
321
- execute: (inputs: any) => Promise<any>;
417
+ execute: (inputs: any) => Promise<{
418
+ result?: string;
419
+ job?: string;
420
+ items?: Item[];
421
+ }> | AsyncGenerator<{
422
+ result?: string;
423
+ job?: string;
424
+ items?: Item[];
425
+ }>;
322
426
  });
323
427
  }
324
428
  type ExuluContextFieldDefinition = {
@@ -361,16 +465,28 @@ declare class ExuluContext {
361
465
  deleteAll: () => Promise<VectorOperationResponse>;
362
466
  tableExists: () => Promise<boolean>;
363
467
  chunksTableExists: () => Promise<boolean>;
364
- createAndUpsertEmbeddings: (item: Item, user?: string, statistics?: ExuluStatisticParams, role?: string, job?: string) => Promise<{
468
+ createAndUpsertEmbeddings: (item: Item, user?: number, statistics?: ExuluStatisticParams, role?: string, job?: string) => Promise<{
365
469
  id: string;
366
470
  chunks?: number;
367
471
  job?: string;
368
472
  }>;
473
+ createItem: (item: Item, user?: number, role?: string, upsert?: boolean) => Promise<{
474
+ item: Item;
475
+ job?: string;
476
+ }>;
477
+ updateItem: (item: Item, user?: number, role?: string) => Promise<{
478
+ item: Item;
479
+ job?: string;
480
+ }>;
481
+ deleteItem: (item: Item, user?: number, role?: string) => Promise<{
482
+ id: string;
483
+ job?: string;
484
+ }>;
369
485
  embeddings: {
370
486
  generate: {
371
487
  one: ({ item, user, role, trigger }: {
372
488
  item: Item;
373
- user?: string;
489
+ user?: number;
374
490
  role?: string;
375
491
  trigger: STATISTICS_LABELS;
376
492
  }) => Promise<{
@@ -378,61 +494,12 @@ declare class ExuluContext {
378
494
  job?: string;
379
495
  chunks?: number;
380
496
  }>;
381
- all: (userId?: string, roleId?: string) => Promise<{
497
+ all: (userId?: number, roleId?: string) => Promise<{
382
498
  jobs: string[];
383
499
  items: number;
384
500
  }>;
385
501
  };
386
502
  };
387
- getItems: ({ statistics, limit, sort, order, page, name, user, role, archived, query, method }: {
388
- statistics?: ExuluStatisticParams;
389
- page: number;
390
- sort?: "created_at" | "embeddings_updated_at";
391
- order?: "desc" | "asc";
392
- limit: number;
393
- name?: string;
394
- user?: string;
395
- role?: string;
396
- archived?: boolean;
397
- query?: string;
398
- method?: VectorMethod;
399
- }) => Promise<{
400
- pagination: {
401
- totalCount: number;
402
- currentPage: number;
403
- limit: number;
404
- from: number;
405
- pageCount: number;
406
- to: number;
407
- lastPage: number;
408
- nextPage: number | null;
409
- previousPage: number | null;
410
- };
411
- filters: {
412
- archived: boolean | undefined;
413
- name: string | undefined;
414
- query: string | undefined;
415
- };
416
- context: {
417
- name: string;
418
- id: string;
419
- embedder: string | undefined;
420
- };
421
- items: any[];
422
- } | {
423
- filters: {
424
- archived: boolean | undefined;
425
- name: string | undefined;
426
- query: string;
427
- };
428
- context: {
429
- name: string;
430
- id: string;
431
- embedder: string;
432
- };
433
- items: any[];
434
- pagination?: undefined;
435
- } | undefined>;
436
503
  createItemsTable: () => Promise<void>;
437
504
  createChunksTable: () => Promise<void>;
438
505
  tool: () => ExuluTool;
@@ -447,93 +514,6 @@ type ExuluStatistic = {
447
514
  };
448
515
  type ExuluStatisticParams = Omit<ExuluStatistic, "total" | "name" | "type">;
449
516
 
450
- type ExuluConfig = {
451
- telemetry?: {
452
- enabled: boolean;
453
- };
454
- workers: {
455
- enabled: boolean;
456
- logsDir?: string;
457
- telemetry?: {
458
- enabled: boolean;
459
- };
460
- };
461
- MCP: {
462
- enabled: boolean;
463
- };
464
- fileUploads: {
465
- s3region: string;
466
- s3key: string;
467
- s3secret: string;
468
- s3Bucket: string;
469
- s3endpoint?: string;
470
- };
471
- };
472
- declare class ExuluApp {
473
- private _agents;
474
- private _config?;
475
- private _queues;
476
- private _contexts?;
477
- private _tools;
478
- private _expressApp;
479
- constructor();
480
- create: ({ contexts, agents, config, tools }: {
481
- contexts?: Record<string, ExuluContext>;
482
- config: ExuluConfig;
483
- agents?: ExuluAgent[];
484
- tools?: ExuluTool[];
485
- }) => Promise<Express>;
486
- get expressApp(): Express;
487
- tool(id: string): ExuluTool | undefined;
488
- tools(): ExuluTool[];
489
- context(id: string): ExuluContext | undefined;
490
- agent(id: string): ExuluAgent | undefined;
491
- get contexts(): ExuluContext[];
492
- get agents(): ExuluAgent[];
493
- embeddings: {
494
- generate: {
495
- one: ({ context: contextId, item: itemId }: {
496
- context: string;
497
- item: string;
498
- }) => Promise<{
499
- id: string;
500
- job?: string;
501
- chunks?: number;
502
- }>;
503
- all: ({ context: contextId }: {
504
- context: string;
505
- }) => Promise<{
506
- jobs: string[];
507
- items: number;
508
- }>;
509
- };
510
- };
511
- bullmq: {
512
- workers: {
513
- create: () => Promise<bullmq.Worker<any, any, string>[]>;
514
- };
515
- };
516
- private server;
517
- }
518
-
519
- type User = {
520
- id: string;
521
- email: string;
522
- emailVerified?: string;
523
- type?: "api" | "user";
524
- anthropic_token?: string;
525
- super_admin?: boolean;
526
- favourite_agents?: string[];
527
- role: {
528
- id: string;
529
- name: string;
530
- agents: "read" | "write";
531
- workflows: "read" | "write";
532
- variables: "read" | "write";
533
- users: "read" | "write";
534
- };
535
- };
536
-
537
517
  declare const authentication: ({ apikey, authtoken, internalkey, db, }: {
538
518
  authtoken?: any;
539
519
  apikey?: string;
@@ -1426,6 +1406,41 @@ declare const ExuluJobs: {
1426
1406
  validate: (job: bullmq.Job) => bullmq.Job<any, any, string>;
1427
1407
  };
1428
1408
  };
1409
+ declare const ExuluDefaultContexts: {
1410
+ files: ExuluContext;
1411
+ codeStandards: ExuluContext;
1412
+ outputs: ExuluContext;
1413
+ };
1414
+ declare const ExuluDefaultAgents: {
1415
+ anthropic: {
1416
+ opus4: ExuluAgent;
1417
+ sonnet4: ExuluAgent;
1418
+ };
1419
+ openai: {
1420
+ gpt5Mini: ExuluAgent;
1421
+ gpt5: ExuluAgent;
1422
+ };
1423
+ };
1424
+ declare const ExuluVariables: {
1425
+ get: (name: string) => Promise<string>;
1426
+ };
1427
+ declare const ExuluUtils: {
1428
+ batch: ({ fn, size, inputs, delay, retries }: {
1429
+ fn: (data: any) => Promise<any>;
1430
+ size: number;
1431
+ inputs: any[];
1432
+ delay: number;
1433
+ retries: {
1434
+ max: number;
1435
+ delays: number[];
1436
+ };
1437
+ }) => Promise<any[]>;
1438
+ retry: ({ fn, retries, delays }: {
1439
+ fn: () => Promise<any>;
1440
+ retries?: number;
1441
+ delays?: number[];
1442
+ }) => Promise<any>;
1443
+ };
1429
1444
  declare const ExuluOtel: {
1430
1445
  create: ({ SIGNOZ_ACCESS_TOKEN, SIGNOZ_TRACES_URL, SIGNOZ_LOGS_URL }: {
1431
1446
  SIGNOZ_ACCESS_TOKEN: string;
@@ -1454,4 +1469,4 @@ declare const ExuluChunkers: {
1454
1469
  };
1455
1470
  };
1456
1471
 
1457
- export { 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, ExuluAgent, ExuluApp, authentication as ExuluAuthentication, ExuluChunkers, ExuluContext, ExuluEmbedder, ExuluEval, ExuluJobs, ExuluOtel, queues as ExuluQueues, ExuluTool, db };
1472
+ export { 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, ExuluAgent, ExuluApp, authentication as ExuluAuthentication, ExuluChunkers, ExuluContext, ExuluDefaultAgents, ExuluDefaultContexts, ExuluEmbedder, ExuluEval, ExuluJobs, ExuluOtel, queues as ExuluQueues, ExuluTool, ExuluUtils, ExuluVariables, db };