@exulu/backend 1.48.2 → 1.49.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.
Files changed (164) hide show
  1. package/dist/index.cjs +351 -42
  2. package/dist/index.d.cts +96 -1
  3. package/dist/index.d.ts +96 -1
  4. package/dist/index.js +340 -38
  5. package/ee/{markdown.ts → chunking/markdown.ts} +2 -2
  6. package/ee/python/README.md +295 -0
  7. package/ee/python/documents/processing/README.md +155 -0
  8. package/ee/{documents → python/documents}/processing/doc_processor.ts +25 -17
  9. package/ee/{documents/processing/pdf_to_markdown.py → python/documents/processing/document_to_markdown.py} +3 -10
  10. package/ee/python/setup.sh +180 -0
  11. package/package.json +14 -3
  12. package/scripts/postinstall.cjs +149 -0
  13. package/.agents/skills/mintlify/SKILL.md +0 -347
  14. package/.editorconfig +0 -15
  15. package/.eslintrc.json +0 -52
  16. package/.github/workflows/release-backend.yml +0 -38
  17. package/.husky/commit-msg +0 -1
  18. package/.jscpd.json +0 -18
  19. package/.mcp.json +0 -25
  20. package/.nvmrc +0 -1
  21. package/.prettierignore +0 -5
  22. package/.prettierrc.json +0 -12
  23. package/CHANGELOG.md +0 -8
  24. package/SECURITY.md +0 -5
  25. package/commitlint.config.js +0 -4
  26. package/devops/documentation/patch-older-releases.md +0 -42
  27. package/ee/documents/processing/build_pdf_processor.sh +0 -35
  28. package/ee/documents/processing/chunk_markdown.py +0 -263
  29. package/ee/documents/processing/pdf_processor.spec +0 -115
  30. package/eslint.config.js +0 -88
  31. package/jest.config.ts +0 -25
  32. package/mintlify-docs/.mintignore +0 -7
  33. package/mintlify-docs/AGENTS.md +0 -33
  34. package/mintlify-docs/CLAUDE.MD +0 -50
  35. package/mintlify-docs/CONTRIBUTING.md +0 -32
  36. package/mintlify-docs/LICENSE +0 -21
  37. package/mintlify-docs/README.md +0 -55
  38. package/mintlify-docs/ai-tools/claude-code.mdx +0 -43
  39. package/mintlify-docs/ai-tools/cursor.mdx +0 -39
  40. package/mintlify-docs/ai-tools/windsurf.mdx +0 -39
  41. package/mintlify-docs/api-reference/core-types/agent-types.mdx +0 -110
  42. package/mintlify-docs/api-reference/core-types/analytics-types.mdx +0 -95
  43. package/mintlify-docs/api-reference/core-types/configuration-types.mdx +0 -83
  44. package/mintlify-docs/api-reference/core-types/evaluation-types.mdx +0 -106
  45. package/mintlify-docs/api-reference/core-types/job-types.mdx +0 -135
  46. package/mintlify-docs/api-reference/core-types/overview.mdx +0 -73
  47. package/mintlify-docs/api-reference/core-types/prompt-types.mdx +0 -102
  48. package/mintlify-docs/api-reference/core-types/rbac-types.mdx +0 -163
  49. package/mintlify-docs/api-reference/core-types/session-types.mdx +0 -77
  50. package/mintlify-docs/api-reference/core-types/user-management.mdx +0 -112
  51. package/mintlify-docs/api-reference/core-types/workflow-types.mdx +0 -88
  52. package/mintlify-docs/api-reference/core-types.mdx +0 -585
  53. package/mintlify-docs/api-reference/dynamic-types.mdx +0 -851
  54. package/mintlify-docs/api-reference/endpoint/create.mdx +0 -4
  55. package/mintlify-docs/api-reference/endpoint/delete.mdx +0 -4
  56. package/mintlify-docs/api-reference/endpoint/get.mdx +0 -4
  57. package/mintlify-docs/api-reference/endpoint/webhook.mdx +0 -4
  58. package/mintlify-docs/api-reference/introduction.mdx +0 -661
  59. package/mintlify-docs/api-reference/mutations.mdx +0 -1012
  60. package/mintlify-docs/api-reference/openapi.json +0 -217
  61. package/mintlify-docs/api-reference/queries.mdx +0 -1154
  62. package/mintlify-docs/backend/introduction.mdx +0 -218
  63. package/mintlify-docs/changelog.mdx +0 -387
  64. package/mintlify-docs/community-edition.mdx +0 -304
  65. package/mintlify-docs/core/exulu-agent/api-reference.mdx +0 -894
  66. package/mintlify-docs/core/exulu-agent/configuration.mdx +0 -690
  67. package/mintlify-docs/core/exulu-agent/introduction.mdx +0 -552
  68. package/mintlify-docs/core/exulu-app/api-reference.mdx +0 -481
  69. package/mintlify-docs/core/exulu-app/configuration.mdx +0 -319
  70. package/mintlify-docs/core/exulu-app/introduction.mdx +0 -117
  71. package/mintlify-docs/core/exulu-authentication.mdx +0 -810
  72. package/mintlify-docs/core/exulu-chunkers/api-reference.mdx +0 -1011
  73. package/mintlify-docs/core/exulu-chunkers/configuration.mdx +0 -596
  74. package/mintlify-docs/core/exulu-chunkers/introduction.mdx +0 -403
  75. package/mintlify-docs/core/exulu-context/api-reference.mdx +0 -911
  76. package/mintlify-docs/core/exulu-context/configuration.mdx +0 -648
  77. package/mintlify-docs/core/exulu-context/introduction.mdx +0 -394
  78. package/mintlify-docs/core/exulu-database.mdx +0 -811
  79. package/mintlify-docs/core/exulu-default-agents.mdx +0 -545
  80. package/mintlify-docs/core/exulu-eval/api-reference.mdx +0 -772
  81. package/mintlify-docs/core/exulu-eval/configuration.mdx +0 -680
  82. package/mintlify-docs/core/exulu-eval/introduction.mdx +0 -459
  83. package/mintlify-docs/core/exulu-logging.mdx +0 -464
  84. package/mintlify-docs/core/exulu-otel.mdx +0 -670
  85. package/mintlify-docs/core/exulu-queues/api-reference.mdx +0 -648
  86. package/mintlify-docs/core/exulu-queues/configuration.mdx +0 -650
  87. package/mintlify-docs/core/exulu-queues/introduction.mdx +0 -474
  88. package/mintlify-docs/core/exulu-reranker/api-reference.mdx +0 -630
  89. package/mintlify-docs/core/exulu-reranker/configuration.mdx +0 -663
  90. package/mintlify-docs/core/exulu-reranker/introduction.mdx +0 -516
  91. package/mintlify-docs/core/exulu-tool/api-reference.mdx +0 -723
  92. package/mintlify-docs/core/exulu-tool/configuration.mdx +0 -805
  93. package/mintlify-docs/core/exulu-tool/introduction.mdx +0 -539
  94. package/mintlify-docs/core/exulu-variables/api-reference.mdx +0 -699
  95. package/mintlify-docs/core/exulu-variables/configuration.mdx +0 -736
  96. package/mintlify-docs/core/exulu-variables/introduction.mdx +0 -511
  97. package/mintlify-docs/development.mdx +0 -94
  98. package/mintlify-docs/docs.json +0 -248
  99. package/mintlify-docs/enterprise-edition.mdx +0 -538
  100. package/mintlify-docs/essentials/code.mdx +0 -35
  101. package/mintlify-docs/essentials/images.mdx +0 -59
  102. package/mintlify-docs/essentials/markdown.mdx +0 -88
  103. package/mintlify-docs/essentials/navigation.mdx +0 -87
  104. package/mintlify-docs/essentials/reusable-snippets.mdx +0 -110
  105. package/mintlify-docs/essentials/settings.mdx +0 -318
  106. package/mintlify-docs/favicon.svg +0 -3
  107. package/mintlify-docs/frontend/introduction.mdx +0 -39
  108. package/mintlify-docs/getting-started.mdx +0 -267
  109. package/mintlify-docs/guides/custom-agent.mdx +0 -608
  110. package/mintlify-docs/guides/first-agent.mdx +0 -315
  111. package/mintlify-docs/images/admin_ui.png +0 -0
  112. package/mintlify-docs/images/contexts.png +0 -0
  113. package/mintlify-docs/images/create_agents.png +0 -0
  114. package/mintlify-docs/images/evals.png +0 -0
  115. package/mintlify-docs/images/graphql.png +0 -0
  116. package/mintlify-docs/images/graphql_api.png +0 -0
  117. package/mintlify-docs/images/hero-dark.png +0 -0
  118. package/mintlify-docs/images/hero-light.png +0 -0
  119. package/mintlify-docs/images/hero.png +0 -0
  120. package/mintlify-docs/images/knowledge_sources.png +0 -0
  121. package/mintlify-docs/images/mcp.png +0 -0
  122. package/mintlify-docs/images/scaling.png +0 -0
  123. package/mintlify-docs/index.mdx +0 -411
  124. package/mintlify-docs/logo/dark.svg +0 -9
  125. package/mintlify-docs/logo/light.svg +0 -9
  126. package/mintlify-docs/partners.mdx +0 -558
  127. package/mintlify-docs/products.mdx +0 -77
  128. package/mintlify-docs/snippets/snippet-intro.mdx +0 -4
  129. package/mintlify-docs/styles.css +0 -207
  130. package/ngrok.bash +0 -1
  131. package/ngrok.md +0 -6
  132. package/ngrok.yml +0 -10
  133. package/release.config.cjs +0 -15
  134. package/skills-lock.json +0 -10
  135. package/types/context-processor.ts +0 -45
  136. package/types/enums/eval-types.ts +0 -5
  137. package/types/enums/field-types.ts +0 -1
  138. package/types/enums/jobs.ts +0 -11
  139. package/types/enums/statistics.ts +0 -13
  140. package/types/exulu-table-definition.ts +0 -79
  141. package/types/file-types.ts +0 -18
  142. package/types/models/agent-session.ts +0 -27
  143. package/types/models/agent.ts +0 -68
  144. package/types/models/context.ts +0 -53
  145. package/types/models/embedding.ts +0 -17
  146. package/types/models/eval-run.ts +0 -40
  147. package/types/models/exulu-agent-tool-config.ts +0 -11
  148. package/types/models/item.ts +0 -21
  149. package/types/models/job.ts +0 -8
  150. package/types/models/project.ts +0 -16
  151. package/types/models/rate-limiter-rules.ts +0 -7
  152. package/types/models/test-case.ts +0 -25
  153. package/types/models/tool.ts +0 -9
  154. package/types/models/user-role.ts +0 -12
  155. package/types/models/user.ts +0 -20
  156. package/types/models/variable.ts +0 -8
  157. package/types/models/vector-methods.ts +0 -7
  158. package/types/provider-config.ts +0 -21
  159. package/types/queue-config.ts +0 -16
  160. package/types/rbac-rights-modes.ts +0 -1
  161. package/types/statistics.ts +0 -20
  162. package/types/workflow.ts +0 -31
  163. /package/ee/{documents → python/documents}/THIRD_PARTY_LICENSES/docling.txt +0 -0
  164. /package/ee/{documents/processing → python}/requirements.txt +0 -0
@@ -1,894 +0,0 @@
1
- ---
2
- title: "API reference"
3
- description: "Complete method and property reference for ExuluAgent"
4
- ---
5
-
6
- ## Constructor
7
-
8
- ```typescript
9
- const agent = new ExuluAgent(options: ExuluAgentParams);
10
- ```
11
-
12
- Creates a new ExuluAgent instance. See the [configuration guide](/core/exulu-agent/configuration) for all available options.
13
-
14
- ## Methods
15
-
16
- ### generateSync()
17
-
18
- Generates a synchronous (non-streaming) response from the agent.
19
-
20
- ```typescript
21
- async generateSync({
22
- prompt,
23
- user,
24
- session,
25
- inputMessages,
26
- currentTools,
27
- allExuluTools,
28
- statistics,
29
- toolConfigs,
30
- providerapikey,
31
- contexts,
32
- rerankers,
33
- exuluConfig,
34
- outputSchema,
35
- agentInstance,
36
- instructions,
37
- req
38
- }: GenerateSyncOptions): Promise<string | object>
39
- ```
40
-
41
- <ParamField path="prompt" type="string">
42
- The user's prompt or question (mutually exclusive with `inputMessages`)
43
- </ParamField>
44
-
45
- <ParamField path="inputMessages" type="UIMessage[]">
46
- Array of conversation messages (mutually exclusive with `prompt`)
47
- </ParamField>
48
-
49
- <ParamField path="user" type="User">
50
- User object for access control and personalization
51
- </ParamField>
52
-
53
- <ParamField path="session" type="string">
54
- Session ID to load previous conversation history
55
- </ParamField>
56
-
57
- <ParamField path="currentTools" type="ExuluTool[]">
58
- Tools available to the agent during this execution
59
- </ParamField>
60
-
61
- <ParamField path="allExuluTools" type="ExuluTool[]">
62
- Complete list of all available tools (for nested tool calling)
63
- </ParamField>
64
-
65
- <ParamField path="statistics" type="ExuluStatisticParams">
66
- Statistics tracking configuration with `label` and `trigger`
67
- </ParamField>
68
-
69
- <ParamField path="toolConfigs" type="ExuluAgentToolConfig[]">
70
- Tool-specific configuration overrides
71
- </ParamField>
72
-
73
- <ParamField path="providerapikey" type="string">
74
- API key for the LLM provider (overrides default)
75
- </ParamField>
76
-
77
- <ParamField path="contexts" type="ExuluContext[]">
78
- Available contexts for semantic search
79
- </ParamField>
80
-
81
- <ParamField path="rerankers" type="ExuluReranker[]">
82
- Available rerankers for search optimization
83
- </ParamField>
84
-
85
- <ParamField path="exuluConfig" type="ExuluConfig">
86
- ExuluApp configuration object
87
- </ParamField>
88
-
89
- <ParamField path="outputSchema" type="z.ZodType">
90
- Zod schema for structured output generation
91
- </ParamField>
92
-
93
- <ParamField path="agentInstance" type="Agent">
94
- Agent database record with configuration
95
- </ParamField>
96
-
97
- <ParamField path="instructions" type="string">
98
- Override default instructions for this execution
99
- </ParamField>
100
-
101
- <ParamField path="req" type="Request">
102
- Express request object for context
103
- </ParamField>
104
-
105
- <ResponseField name="return" type="Promise<string | object>">
106
- Generated text response, or structured object if `outputSchema` is provided
107
- </ResponseField>
108
-
109
- ```typescript
110
- // Simple text generation
111
- const response = await agent.generateSync({
112
- prompt: "What is the capital of France?",
113
- agentInstance: agentData,
114
- currentTools: [],
115
- statistics: {
116
- label: "assistant",
117
- trigger: "api"
118
- }
119
- });
120
-
121
- console.log(response); // "The capital of France is Paris."
122
-
123
- // With tools
124
- const response = await agent.generateSync({
125
- prompt: "Search our docs for authentication information",
126
- agentInstance: agentData,
127
- currentTools: [documentSearchTool, databaseTool],
128
- contexts: [docsContext],
129
- statistics: {
130
- label: "assistant",
131
- trigger: "api"
132
- }
133
- });
134
-
135
- // Structured output
136
- const data = await agent.generateSync({
137
- prompt: "Extract contact information from this email",
138
- outputSchema: z.object({
139
- name: z.string(),
140
- email: z.string().email(),
141
- phone: z.string().optional()
142
- }),
143
- agentInstance: agentData,
144
- statistics: {
145
- label: "extractor",
146
- trigger: "api"
147
- }
148
- });
149
-
150
- console.log(data.name); // Type-safe access
151
- console.log(data.email);
152
- ```
153
-
154
- <Info>
155
- Use `generateSync()` for API endpoints, background jobs, or when you need the complete response before proceeding.
156
- </Info>
157
-
158
- ### generateStream()
159
-
160
- Generates a streaming response from the agent for real-time output.
161
-
162
- ```typescript
163
- async generateStream({
164
- user,
165
- session,
166
- agentInstance,
167
- message,
168
- previousMessages,
169
- currentTools,
170
- approvedTools,
171
- allExuluTools,
172
- toolConfigs,
173
- providerapikey,
174
- contexts,
175
- rerankers,
176
- exuluConfig,
177
- instructions,
178
- req
179
- }: GenerateStreamOptions): Promise<{
180
- stream: ReturnType<typeof streamText>;
181
- originalMessages: UIMessage[];
182
- previousMessages: UIMessage[];
183
- }>
184
- ```
185
-
186
- <ParamField path="message" type="UIMessage" required>
187
- The new user message to process
188
- </ParamField>
189
-
190
- <ParamField path="session" type="string">
191
- Session ID to load and continue conversation history
192
- </ParamField>
193
-
194
- <ParamField path="user" type="User">
195
- User object for access control
196
- </ParamField>
197
-
198
- <ParamField path="agentInstance" type="Agent">
199
- Agent database record with configuration
200
- </ParamField>
201
-
202
- <ParamField path="previousMessages" type="UIMessage[]">
203
- Previous messages to include in context
204
- </ParamField>
205
-
206
- <ParamField path="currentTools" type="ExuluTool[]">
207
- Tools available to the agent
208
- </ParamField>
209
-
210
- <ParamField path="approvedTools" type="string[]">
211
- Tool IDs that have been pre-approved for execution
212
- </ParamField>
213
-
214
- <ParamField path="allExuluTools" type="ExuluTool[]">
215
- Complete list of all tools
216
- </ParamField>
217
-
218
- <ParamField path="toolConfigs" type="ExuluAgentToolConfig[]">
219
- Tool configuration overrides
220
- </ParamField>
221
-
222
- <ParamField path="providerapikey" type="string">
223
- API key override
224
- </ParamField>
225
-
226
- <ParamField path="contexts" type="ExuluContext[]">
227
- Available contexts
228
- </ParamField>
229
-
230
- <ParamField path="rerankers" type="ExuluReranker[]">
231
- Available rerankers
232
- </ParamField>
233
-
234
- <ParamField path="exuluConfig" type="ExuluConfig">
235
- App configuration
236
- </ParamField>
237
-
238
- <ParamField path="instructions" type="string">
239
- Override instructions
240
- </ParamField>
241
-
242
- <ParamField path="req" type="Request">
243
- Express request object
244
- </ParamField>
245
-
246
- <ResponseField name="stream" type="StreamTextResult">
247
- AI SDK stream object with text chunks and tool calls
248
- </ResponseField>
249
-
250
- <ResponseField name="originalMessages" type="UIMessage[]">
251
- All messages including the new one
252
- </ResponseField>
253
-
254
- <ResponseField name="previousMessages" type="UIMessage[]">
255
- Messages from before this request
256
- </ResponseField>
257
-
258
- ```typescript
259
- // Stream a response
260
- const { stream, originalMessages } = await agent.generateStream({
261
- message: {
262
- id: "msg-123",
263
- role: "user",
264
- parts: [{ type: "text", text: "Tell me about your services" }]
265
- },
266
- session: sessionId,
267
- user: currentUser,
268
- agentInstance: agentData,
269
- currentTools: tools,
270
- contexts: contexts,
271
- exuluConfig: config
272
- });
273
-
274
- // Consume the stream
275
- for await (const chunk of stream.textStream) {
276
- process.stdout.write(chunk);
277
- }
278
-
279
- // Or use with Express
280
- app.post("/chat", async (req, res) => {
281
- const { stream } = await agent.generateStream({
282
- message: req.body.message,
283
- session: req.body.session,
284
- user: req.user,
285
- agentInstance: agentData,
286
- currentTools: tools
287
- });
288
-
289
- return stream.toDataStreamResponse();
290
- });
291
- ```
292
-
293
- <Note>
294
- Use `generateStream()` for interactive chat applications where you want to display responses progressively.
295
- </Note>
296
-
297
- ### tool()
298
-
299
- Exports the agent as a tool that other agents can call.
300
-
301
- ```typescript
302
- async tool(
303
- instance: string,
304
- agents: ExuluAgent[],
305
- contexts: ExuluContext[],
306
- rerankers: ExuluReranker[]
307
- ): Promise<ExuluTool | null>
308
- ```
309
-
310
- <ParamField path="instance" type="string" required>
311
- Agent ID to load from the database
312
- </ParamField>
313
-
314
- <ParamField path="agents" type="ExuluAgent[]" required>
315
- Array of all available agents
316
- </ParamField>
317
-
318
- <ParamField path="contexts" type="ExuluContext[]" required>
319
- Array of all available contexts
320
- </ParamField>
321
-
322
- <ParamField path="rerankers" type="ExuluReranker[]" required>
323
- Array of all available rerankers
324
- </ParamField>
325
-
326
- <ResponseField name="return" type="Promise<ExuluTool | null>">
327
- Tool instance that wraps the agent, or null if agent not found
328
- </ResponseField>
329
-
330
- ```typescript
331
- // Create specialist agent
332
- const sqlAgent = new ExuluAgent({
333
- id: "sql_specialist",
334
- name: "SQL Specialist",
335
- type: "agent",
336
- description: "Expert at writing SQL queries",
337
- provider: "openai",
338
- config: {
339
- name: "gpt-4o",
340
- model: { /* ... */ },
341
- instructions: "You are an expert SQL developer."
342
- },
343
- capabilities: { text: true, images: [], files: [], audio: [], video: [] }
344
- });
345
-
346
- // Export as tool
347
- const sqlTool = await sqlAgent.tool(
348
- "sql_specialist",
349
- [sqlAgent],
350
- contexts,
351
- rerankers
352
- );
353
-
354
- // Main agent can use it
355
- const mainAgent = new ExuluAgent({
356
- id: "assistant",
357
- name: "Assistant",
358
- // ... config
359
- });
360
-
361
- const response = await mainAgent.generateSync({
362
- prompt: "Write a query to find top customers",
363
- currentTools: [sqlTool], // Delegates to SQL specialist
364
- // ... other params
365
- });
366
- ```
367
-
368
- <Tip>
369
- Use agent-as-tool for multi-agent workflows where specialized agents handle specific tasks.
370
- </Tip>
371
-
372
- ## Properties
373
-
374
- ### id
375
-
376
- <ResponseField name="id" type="string">
377
- Unique agent identifier
378
- </ResponseField>
379
-
380
- ```typescript
381
- console.log(agent.id); // "customer_support_agent"
382
- ```
383
-
384
- ### name
385
-
386
- <ResponseField name="name" type="string">
387
- Human-readable agent name
388
- </ResponseField>
389
-
390
- ```typescript
391
- console.log(agent.name); // "Customer Support Agent"
392
- ```
393
-
394
- ### provider
395
-
396
- <ResponseField name="provider" type="string">
397
- LLM provider name
398
- </ResponseField>
399
-
400
- ```typescript
401
- console.log(agent.provider); // "openai"
402
- ```
403
-
404
- ### providerName
405
-
406
- <ResponseField name="providerName" type="string" getter>
407
- Computed provider name (empty string if no model configured)
408
- </ResponseField>
409
-
410
- ```typescript
411
- console.log(agent.providerName); // "openai"
412
- ```
413
-
414
- ### modelName
415
-
416
- <ResponseField name="modelName" type="string" getter>
417
- Computed model name from config
418
- </ResponseField>
419
-
420
- ```typescript
421
- console.log(agent.modelName); // "gpt-4o"
422
- ```
423
-
424
- ### description
425
-
426
- <ResponseField name="description" type="string">
427
- Agent description
428
- </ResponseField>
429
-
430
- ```typescript
431
- console.log(agent.description); // "Handles customer support inquiries"
432
- ```
433
-
434
- ### type
435
-
436
- <ResponseField name="type" type="'agent'">
437
- Always `"agent"`
438
- </ResponseField>
439
-
440
- ```typescript
441
- console.log(agent.type); // "agent"
442
- ```
443
-
444
- ### slug
445
-
446
- <ResponseField name="slug" type="string">
447
- URL-friendly slug for the agent
448
- </ResponseField>
449
-
450
- ```typescript
451
- console.log(agent.slug); // "/agents/customer-support-agent/run"
452
- ```
453
-
454
- ### capabilities
455
-
456
- <ResponseField name="capabilities" type="Capabilities">
457
- Supported input types
458
- </ResponseField>
459
-
460
- ```typescript
461
- console.log(agent.capabilities);
462
- // {
463
- // text: true,
464
- // images: [".png", ".jpg"],
465
- // files: [".pdf", ".txt"],
466
- // audio: [],
467
- // video: []
468
- // }
469
- ```
470
-
471
- ### config
472
-
473
- <ResponseField name="config" type="ExuluAgentConfig | undefined">
474
- Agent configuration including model and instructions
475
- </ResponseField>
476
-
477
- ```typescript
478
- console.log(agent.config?.name); // "gpt-4o"
479
- console.log(agent.config?.instructions); // "You are a helpful assistant..."
480
- ```
481
-
482
- ### model
483
-
484
- <ResponseField name="model" type="ModelFactory | undefined">
485
- Model factory function
486
- </ResponseField>
487
-
488
- ```typescript
489
- const languageModel = agent.model?.create({ apiKey: "..." });
490
- ```
491
-
492
- ### maxContextLength
493
-
494
- <ResponseField name="maxContextLength" type="number | undefined">
495
- Maximum context window size in tokens
496
- </ResponseField>
497
-
498
- ```typescript
499
- console.log(agent.maxContextLength); // 128000
500
- ```
501
-
502
- ### workflows
503
-
504
- <ResponseField name="workflows" type="WorkflowConfig | undefined">
505
- Workflow configuration
506
- </ResponseField>
507
-
508
- ```typescript
509
- console.log(agent.workflows?.enabled); // true
510
- ```
511
-
512
- ### queue
513
-
514
- <ResponseField name="queue" type="ExuluQueueConfig | undefined">
515
- Queue configuration
516
- </ResponseField>
517
-
518
- ```typescript
519
- console.log(agent.queue?.name); // "agent_tasks"
520
- ```
521
-
522
- ### rateLimit
523
-
524
- <ResponseField name="rateLimit" type="RateLimiterRule | undefined">
525
- Rate limiting configuration
526
- </ResponseField>
527
-
528
- ```typescript
529
- console.log(agent.rateLimit?.points); // 100
530
- ```
531
-
532
- ## Usage examples
533
-
534
- ### Basic text generation
535
-
536
- ```typescript
537
- import { ExuluAgent } from "@exulu/backend";
538
- import { createOpenAI } from "@ai-sdk/openai";
539
-
540
- const agent = new ExuluAgent({
541
- id: "assistant",
542
- name: "Assistant",
543
- type: "agent",
544
- description: "General AI assistant",
545
- provider: "openai",
546
- config: {
547
- name: "gpt-4o",
548
- model: {
549
- create: ({ apiKey }) => createOpenAI({ apiKey })("gpt-4o")
550
- },
551
- instructions: "You are a helpful assistant."
552
- },
553
- capabilities: {
554
- text: true,
555
- images: [],
556
- files: [],
557
- audio: [],
558
- video: []
559
- }
560
- });
561
-
562
- const response = await agent.generateSync({
563
- prompt: "Explain quantum computing in simple terms",
564
- agentInstance: await loadAgent("assistant"),
565
- statistics: { label: "assistant", trigger: "api" }
566
- });
567
-
568
- console.log(response);
569
- ```
570
-
571
- ### Streaming chat
572
-
573
- ```typescript
574
- const { stream } = await agent.generateStream({
575
- message: {
576
- id: "msg-123",
577
- role: "user",
578
- parts: [{ type: "text", text: "Write a poem about AI" }]
579
- },
580
- session: "session-abc",
581
- user: currentUser,
582
- agentInstance: agentData,
583
- currentTools: []
584
- });
585
-
586
- // Stream to console
587
- for await (const chunk of stream.textStream) {
588
- process.stdout.write(chunk);
589
- }
590
- ```
591
-
592
- ### With tools
593
-
594
- ```typescript
595
- import { ExuluTool } from "@exulu/backend";
596
- import { z } from "zod";
597
-
598
- // Define a tool
599
- const weatherTool = new ExuluTool({
600
- id: "weather",
601
- name: "get_weather",
602
- description: "Gets weather for a location",
603
- type: "function",
604
- inputSchema: z.object({
605
- location: z.string()
606
- }),
607
- config: [],
608
- execute: async ({ location }) => {
609
- const weather = await fetchWeather(location);
610
- return { result: JSON.stringify(weather) };
611
- }
612
- });
613
-
614
- // Use with agent
615
- const response = await agent.generateSync({
616
- prompt: "What's the weather in Paris?",
617
- agentInstance: agentData,
618
- currentTools: [weatherTool],
619
- statistics: { label: "assistant", trigger: "api" }
620
- });
621
- ```
622
-
623
- ### Structured output
624
-
625
- ```typescript
626
- import { z } from "zod";
627
-
628
- const ContactSchema = z.object({
629
- name: z.string(),
630
- email: z.string().email(),
631
- phone: z.string().optional(),
632
- company: z.string().optional(),
633
- role: z.string().optional()
634
- });
635
-
636
- const contacts = await agent.generateSync({
637
- prompt: `Extract all contact information from this email:
638
-
639
- Hi, I'm John Smith from Acme Corp. You can reach me at
640
- john@acme.com or call me at 555-1234. I'm the CTO.`,
641
- outputSchema: ContactSchema,
642
- agentInstance: agentData,
643
- statistics: { label: "extractor", trigger: "api" }
644
- });
645
-
646
- console.log(contacts.name); // "John Smith"
647
- console.log(contacts.email); // "john@acme.com"
648
- console.log(contacts.company); // "Acme Corp"
649
- console.log(contacts.role); // "CTO"
650
- ```
651
-
652
- ### With conversation history
653
-
654
- ```typescript
655
- // First message
656
- const { stream: stream1 } = await agent.generateStream({
657
- message: {
658
- id: "msg-1",
659
- role: "user",
660
- parts: [{ type: "text", text: "My name is Alice" }]
661
- },
662
- session: "session-123",
663
- user: currentUser,
664
- agentInstance: agentData,
665
- currentTools: []
666
- });
667
-
668
- await stream1.toTextStreamResponse(); // Wait for completion
669
-
670
- // Second message - agent remembers context
671
- const { stream: stream2 } = await agent.generateStream({
672
- message: {
673
- id: "msg-2",
674
- role: "user",
675
- parts: [{ type: "text", text: "What's my name?" }]
676
- },
677
- session: "session-123", // Same session
678
- user: currentUser,
679
- agentInstance: agentData,
680
- currentTools: []
681
- });
682
-
683
- // Agent responds: "Your name is Alice."
684
- ```
685
-
686
- ### With memory
687
-
688
- ```typescript
689
- // Configure agent with memory
690
- const agent = new ExuluAgent({
691
- id: "memory_agent",
692
- name: "Agent with Memory",
693
- type: "agent",
694
- description: "Agent that remembers past interactions",
695
- provider: "openai",
696
- config: {
697
- name: "gpt-4o",
698
- model: { /* ... */ },
699
- instructions: "You are an assistant with memory.",
700
- memory: "agent_memory_context" // Context ID
701
- },
702
- capabilities: { text: true, images: [], files: [], audio: [], video: [] }
703
- });
704
-
705
- // Agent automatically searches memory before responding
706
- const response = await agent.generateSync({
707
- prompt: "What did we discuss about the project last week?",
708
- agentInstance: agentData,
709
- contexts: [memoryContext], // Include memory context
710
- statistics: { label: "memory_agent", trigger: "api" }
711
- });
712
-
713
- // Agent can also create new memories via the auto-generated tool
714
- ```
715
-
716
- ### Multi-agent workflow
717
-
718
- ```typescript
719
- // Create specialist agents
720
- const researchAgent = new ExuluAgent({
721
- id: "researcher",
722
- name: "Research Specialist",
723
- type: "agent",
724
- description: "Conducts research and gathers information",
725
- provider: "openai",
726
- config: {
727
- name: "gpt-4o",
728
- model: { /* ... */ },
729
- instructions: "You are a research specialist. Gather comprehensive information."
730
- },
731
- capabilities: { text: true, images: [], files: [], audio: [], video: [] }
732
- });
733
-
734
- const writerAgent = new ExuluAgent({
735
- id: "writer",
736
- name: "Content Writer",
737
- type: "agent",
738
- description: "Writes content based on research",
739
- provider: "anthropic",
740
- config: {
741
- name: "claude-opus-4",
742
- model: { /* ... */ },
743
- instructions: "You are a skilled writer. Create engaging, well-structured content."
744
- },
745
- capabilities: { text: true, images: [], files: [], audio: [], video: [] }
746
- });
747
-
748
- // Coordinator agent that delegates
749
- const coordinatorAgent = new ExuluAgent({
750
- id: "coordinator",
751
- name: "Coordinator",
752
- type: "agent",
753
- description: "Coordinates workflow between specialists",
754
- provider: "openai",
755
- config: {
756
- name: "gpt-4o",
757
- model: { /* ... */ },
758
- instructions: "You coordinate work between specialists."
759
- },
760
- capabilities: { text: true, images: [], files: [], audio: [], video: [] }
761
- });
762
-
763
- // Export specialists as tools
764
- const researchTool = await researchAgent.tool("researcher", [researchAgent], [], []);
765
- const writerTool = await writerAgent.tool("writer", [writerAgent], [], []);
766
-
767
- // Coordinator uses them
768
- const article = await coordinatorAgent.generateSync({
769
- prompt: "Create an article about quantum computing",
770
- currentTools: [researchTool, writerTool],
771
- agentInstance: await loadAgent("coordinator"),
772
- statistics: { label: "coordinator", trigger: "api" }
773
- });
774
- ```
775
-
776
- ### Processing files
777
-
778
- ```typescript
779
- const documentAgent = new ExuluAgent({
780
- id: "doc_processor",
781
- name: "Document Processor",
782
- type: "agent",
783
- description: "Processes and analyzes documents",
784
- provider: "openai",
785
- config: {
786
- name: "gpt-4o",
787
- model: { /* ... */ },
788
- instructions: "Analyze documents and extract key information."
789
- },
790
- capabilities: {
791
- text: true,
792
- images: [],
793
- files: [".pdf", ".docx", ".txt"],
794
- audio: [],
795
- video: []
796
- }
797
- });
798
-
799
- // Files are automatically converted to text
800
- const { stream } = await documentAgent.generateStream({
801
- message: {
802
- id: "msg-1",
803
- role: "user",
804
- parts: [
805
- { type: "text", text: "Summarize this document" },
806
- {
807
- type: "file",
808
- mediaType: "application/pdf",
809
- url: "https://example.com/document.pdf",
810
- filename: "document.pdf"
811
- }
812
- ]
813
- },
814
- session: sessionId,
815
- user: currentUser,
816
- agentInstance: agentData,
817
- currentTools: []
818
- });
819
- ```
820
-
821
- ## Type definitions
822
-
823
- ```typescript
824
- // Agent constructor parameters
825
- interface ExuluAgentParams {
826
- id: string;
827
- name: string;
828
- type: "agent";
829
- description: string;
830
- config?: ExuluAgentConfig;
831
- queue?: ExuluQueueConfig;
832
- maxContextLength?: number;
833
- authenticationInformation?: string;
834
- provider: string;
835
- workflows?: {
836
- enabled: boolean;
837
- queue?: Promise<ExuluQueueConfig>;
838
- };
839
- capabilities?: {
840
- text: boolean;
841
- images: imageTypes[];
842
- files: fileTypes[];
843
- audio: audioTypes[];
844
- video: videoTypes[];
845
- };
846
- rateLimit?: RateLimiterRule;
847
- }
848
-
849
- // Agent configuration
850
- interface ExuluAgentConfig {
851
- name: string;
852
- model?: {
853
- create: ({ apiKey }: { apiKey?: string }) => LanguageModel;
854
- };
855
- instructions?: string;
856
- memory?: string;
857
- }
858
-
859
- // Capabilities types
860
- type imageTypes = '.png' | '.jpg' | '.jpeg' | '.gif' | '.webp';
861
- type fileTypes = '.pdf' | '.docx' | '.xlsx' | '.xls' | '.csv' |
862
- '.pptx' | '.ppt' | '.txt' | '.md' | '.json';
863
- type audioTypes = '.mp3' | '.wav' | '.m4a' | '.mp4' | '.mpeg';
864
- type videoTypes = '.mp4' | '.m4a' | '.mp3' | '.mpeg' | '.wav';
865
- ```
866
-
867
- ## Best practices
868
-
869
- <Tip>
870
- **Test with different prompts**: Agent behavior can vary significantly with different phrasings. Test edge cases and refine instructions.
871
- </Tip>
872
-
873
- <Note>
874
- **Monitor token usage**: Track input/output tokens to optimize costs and prevent context window overflow.
875
- </Note>
876
-
877
- <Warning>
878
- **Validate structured outputs**: Even with schemas, validate critical data before using it in production systems.
879
- </Warning>
880
-
881
- <Info>
882
- **Tool selection**: Provide only necessary tools. Too many tools can confuse the agent and increase latency.
883
- </Info>
884
-
885
- ## Next steps
886
-
887
- <CardGroup cols={2}>
888
- <Card title="Configuration guide" icon="gear" href="/core/exulu-agent/configuration">
889
- Learn about configuration options
890
- </Card>
891
- <Card title="ExuluTool" icon="wrench" href="/core/exulu-tool/introduction">
892
- Learn about agent tools
893
- </Card>
894
- </CardGroup>