@falai/agent 0.1.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/README.md +516 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +5 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/core/Agent.d.ts +98 -0
- package/dist/core/Agent.d.ts.map +1 -0
- package/dist/core/Agent.js +248 -0
- package/dist/core/Agent.js.map +1 -0
- package/dist/core/DomainRegistry.d.ts +26 -0
- package/dist/core/DomainRegistry.d.ts.map +1 -0
- package/dist/core/DomainRegistry.js +41 -0
- package/dist/core/DomainRegistry.js.map +1 -0
- package/dist/core/Events.d.ts +19 -0
- package/dist/core/Events.d.ts.map +1 -0
- package/dist/core/Events.js +79 -0
- package/dist/core/Events.js.map +1 -0
- package/dist/core/Observation.d.ts +24 -0
- package/dist/core/Observation.d.ts.map +1 -0
- package/dist/core/Observation.js +35 -0
- package/dist/core/Observation.js.map +1 -0
- package/dist/core/PromptBuilder.d.ts +121 -0
- package/dist/core/PromptBuilder.d.ts.map +1 -0
- package/dist/core/PromptBuilder.js +339 -0
- package/dist/core/PromptBuilder.js.map +1 -0
- package/dist/core/Route.d.ts +46 -0
- package/dist/core/Route.d.ts.map +1 -0
- package/dist/core/Route.js +113 -0
- package/dist/core/Route.js.map +1 -0
- package/dist/core/State.d.ts +50 -0
- package/dist/core/State.d.ts.map +1 -0
- package/dist/core/State.js +110 -0
- package/dist/core/State.js.map +1 -0
- package/dist/core/Tool.d.ts +31 -0
- package/dist/core/Tool.d.ts.map +1 -0
- package/dist/core/Tool.js +33 -0
- package/dist/core/Tool.js.map +1 -0
- package/dist/core/Transition.d.ts +32 -0
- package/dist/core/Transition.d.ts.map +1 -0
- package/dist/core/Transition.js +59 -0
- package/dist/core/Transition.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/GeminiProvider.d.ts +40 -0
- package/dist/providers/GeminiProvider.d.ts.map +1 -0
- package/dist/providers/GeminiProvider.js +126 -0
- package/dist/providers/GeminiProvider.js.map +1 -0
- package/dist/providers/OpenAIProvider.d.ts +42 -0
- package/dist/providers/OpenAIProvider.d.ts.map +1 -0
- package/dist/providers/OpenAIProvider.js +164 -0
- package/dist/providers/OpenAIProvider.js.map +1 -0
- package/dist/providers/OpenRouterProvider.d.ts +46 -0
- package/dist/providers/OpenRouterProvider.d.ts.map +1 -0
- package/dist/providers/OpenRouterProvider.js +171 -0
- package/dist/providers/OpenRouterProvider.js.map +1 -0
- package/dist/types/agent.d.ts +105 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +18 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/ai.d.ts +78 -0
- package/dist/types/ai.d.ts.map +1 -0
- package/dist/types/ai.js +5 -0
- package/dist/types/ai.js.map +1 -0
- package/dist/types/history.d.ts +112 -0
- package/dist/types/history.d.ts.map +1 -0
- package/dist/types/history.js +34 -0
- package/dist/types/history.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/observation.d.ts +25 -0
- package/dist/types/observation.d.ts.map +1 -0
- package/dist/types/observation.js +5 -0
- package/dist/types/observation.js.map +1 -0
- package/dist/types/prompt.d.ts +46 -0
- package/dist/types/prompt.d.ts.map +1 -0
- package/dist/types/prompt.js +16 -0
- package/dist/types/prompt.js.map +1 -0
- package/dist/types/route.d.ts +59 -0
- package/dist/types/route.d.ts.map +1 -0
- package/dist/types/route.js +5 -0
- package/dist/types/route.js.map +1 -0
- package/dist/types/tool.d.ts +46 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/tool.js +5 -0
- package/dist/types/tool.js.map +1 -0
- package/dist/utils/retry.d.ts +13 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +70 -0
- package/dist/utils/retry.js.map +1 -0
- package/docs/API_REFERENCE.md +517 -0
- package/docs/CONSTRUCTOR_OPTIONS.md +256 -0
- package/docs/CONTRIBUTING.md +481 -0
- package/docs/GETTING_STARTED.md +328 -0
- package/docs/PROVIDERS.md +472 -0
- package/docs/PUBLISHING.md +174 -0
- package/docs/README.md +68 -0
- package/docs/STRUCTURE.md +32 -0
- package/examples/declarative-agent.ts +217 -0
- package/examples/healthcare-agent.ts +283 -0
- package/examples/openai-agent.ts +167 -0
- package/examples/travel-agent.ts +342 -0
- package/package.json +73 -0
- package/src/constants/index.ts +5 -0
- package/src/core/Agent.ts +307 -0
- package/src/core/DomainRegistry.ts +50 -0
- package/src/core/Events.ts +101 -0
- package/src/core/Observation.ts +46 -0
- package/src/core/PromptBuilder.ts +511 -0
- package/src/core/Route.ts +136 -0
- package/src/core/State.ts +153 -0
- package/src/core/Tool.ts +54 -0
- package/src/core/Transition.ts +66 -0
- package/src/index.ts +83 -0
- package/src/providers/GeminiProvider.ts +220 -0
- package/src/providers/OpenAIProvider.ts +272 -0
- package/src/providers/OpenRouterProvider.ts +282 -0
- package/src/types/agent.ts +112 -0
- package/src/types/ai.ts +85 -0
- package/src/types/history.ts +125 -0
- package/src/types/index.ts +56 -0
- package/src/types/observation.ts +27 -0
- package/src/types/prompt.ts +49 -0
- package/src/types/route.ts +68 -0
- package/src/types/tool.ts +53 -0
- package/src/utils/retry.ts +96 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Complete API documentation for `@falai/agent`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Core Classes
|
|
8
|
+
|
|
9
|
+
### `Agent<TContext>`
|
|
10
|
+
|
|
11
|
+
Main agent class for managing conversational AI.
|
|
12
|
+
|
|
13
|
+
#### Constructor
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
new Agent<TContext>(options: AgentOptions<TContext>)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
See [Constructor Options](./CONSTRUCTOR_OPTIONS.md) for full details.
|
|
20
|
+
|
|
21
|
+
#### Methods
|
|
22
|
+
|
|
23
|
+
##### `createRoute(options: RouteOptions): Route`
|
|
24
|
+
|
|
25
|
+
Creates a new conversation route.
|
|
26
|
+
|
|
27
|
+
##### `createTerm(term: Term): this`
|
|
28
|
+
|
|
29
|
+
Adds a domain glossary term. Returns `this` for chaining.
|
|
30
|
+
|
|
31
|
+
##### `createGuideline(guideline: Guideline): this`
|
|
32
|
+
|
|
33
|
+
Adds a behavioral guideline. Returns `this` for chaining.
|
|
34
|
+
|
|
35
|
+
##### `createCapability(capability: Capability): this`
|
|
36
|
+
|
|
37
|
+
Adds an agent capability. Returns `this` for chaining.
|
|
38
|
+
|
|
39
|
+
##### `createObservation(description: string): Observation`
|
|
40
|
+
|
|
41
|
+
Creates an observation for disambiguation.
|
|
42
|
+
|
|
43
|
+
##### `addDomain<TName, TDomain>(name: TName, domainObject: TDomain): this`
|
|
44
|
+
|
|
45
|
+
Registers a domain with tools/methods. Returns `this` for chaining.
|
|
46
|
+
|
|
47
|
+
##### `respond(input: RespondInput<TContext>): Promise<RespondOutput>`
|
|
48
|
+
|
|
49
|
+
Generates an AI response based on conversation history.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
interface RespondInput<TContext> {
|
|
53
|
+
history: Event[];
|
|
54
|
+
contextOverride?: Partial<TContext>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface RespondOutput {
|
|
58
|
+
message: string;
|
|
59
|
+
// ... additional fields
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### Properties
|
|
64
|
+
|
|
65
|
+
##### `name: string`
|
|
66
|
+
|
|
67
|
+
Agent's name (readonly).
|
|
68
|
+
|
|
69
|
+
##### `description?: string`
|
|
70
|
+
|
|
71
|
+
Agent's description (readonly).
|
|
72
|
+
|
|
73
|
+
##### `goal?: string`
|
|
74
|
+
|
|
75
|
+
Agent's goal (readonly).
|
|
76
|
+
|
|
77
|
+
##### `domain: Record<string, Record<string, unknown>>`
|
|
78
|
+
|
|
79
|
+
Dynamic domain registry access.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### `Route`
|
|
84
|
+
|
|
85
|
+
Represents a conversation flow with states and transitions.
|
|
86
|
+
|
|
87
|
+
#### Constructor
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
new Route(options: RouteOptions)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### Methods
|
|
94
|
+
|
|
95
|
+
##### `createGuideline(guideline: Guideline): this`
|
|
96
|
+
|
|
97
|
+
Adds a guideline specific to this route. Returns `this` for chaining.
|
|
98
|
+
|
|
99
|
+
##### `getGuidelines(): Guideline[]`
|
|
100
|
+
|
|
101
|
+
Returns all guidelines for this route.
|
|
102
|
+
|
|
103
|
+
##### `getRef(): RouteRef`
|
|
104
|
+
|
|
105
|
+
Returns a reference to this route.
|
|
106
|
+
|
|
107
|
+
##### `toRef(): RouteRef`
|
|
108
|
+
|
|
109
|
+
Returns a reference including the route instance (for disambiguation).
|
|
110
|
+
|
|
111
|
+
##### `describe(): string`
|
|
112
|
+
|
|
113
|
+
Generates a description of this route's structure.
|
|
114
|
+
|
|
115
|
+
#### Properties
|
|
116
|
+
|
|
117
|
+
##### `id: string`
|
|
118
|
+
|
|
119
|
+
Unique route identifier (readonly).
|
|
120
|
+
|
|
121
|
+
##### `title: string`
|
|
122
|
+
|
|
123
|
+
Route title (readonly).
|
|
124
|
+
|
|
125
|
+
##### `description?: string`
|
|
126
|
+
|
|
127
|
+
Route description (readonly).
|
|
128
|
+
|
|
129
|
+
##### `conditions: string[]`
|
|
130
|
+
|
|
131
|
+
Conditions that trigger this route (readonly).
|
|
132
|
+
|
|
133
|
+
##### `initialState: State`
|
|
134
|
+
|
|
135
|
+
Starting state of the route (readonly).
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### `State`
|
|
140
|
+
|
|
141
|
+
Represents a state within a conversation route.
|
|
142
|
+
|
|
143
|
+
#### Methods
|
|
144
|
+
|
|
145
|
+
##### `transitionTo(spec: TransitionSpec, condition?: string): TransitionResult`
|
|
146
|
+
|
|
147
|
+
Creates a transition from this state.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
interface TransitionSpec {
|
|
151
|
+
chatState?: string; // Transition to a chat interaction
|
|
152
|
+
toolState?: ToolRef; // Transition to execute a tool
|
|
153
|
+
state?: StateRef | symbol; // Transition to specific state or END_ROUTE
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
##### `addGuideline(guideline: Guideline): void`
|
|
158
|
+
|
|
159
|
+
Adds a guideline specific to this state.
|
|
160
|
+
|
|
161
|
+
#### Properties
|
|
162
|
+
|
|
163
|
+
##### `id: string`
|
|
164
|
+
|
|
165
|
+
Unique state identifier (readonly).
|
|
166
|
+
|
|
167
|
+
##### `routeId: string`
|
|
168
|
+
|
|
169
|
+
ID of the route this state belongs to (readonly).
|
|
170
|
+
|
|
171
|
+
##### `description: string`
|
|
172
|
+
|
|
173
|
+
State description (readonly).
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### `Observation`
|
|
178
|
+
|
|
179
|
+
Handles disambiguation between multiple routes.
|
|
180
|
+
|
|
181
|
+
#### Constructor
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
new Observation(options: ObservationOptions)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Methods
|
|
188
|
+
|
|
189
|
+
##### `disambiguate(routes: (Route | RouteRef)[]): this`
|
|
190
|
+
|
|
191
|
+
Sets routes this observation can disambiguate between. Returns `this` for chaining.
|
|
192
|
+
|
|
193
|
+
##### `getRoutes(): RouteRef[]`
|
|
194
|
+
|
|
195
|
+
Returns routes associated with this observation.
|
|
196
|
+
|
|
197
|
+
#### Properties
|
|
198
|
+
|
|
199
|
+
##### `id: string`
|
|
200
|
+
|
|
201
|
+
Unique identifier (readonly).
|
|
202
|
+
|
|
203
|
+
##### `description: string`
|
|
204
|
+
|
|
205
|
+
Observation description (readonly).
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### `GeminiProvider`
|
|
210
|
+
|
|
211
|
+
AI provider implementation for Google Gemini.
|
|
212
|
+
|
|
213
|
+
#### Constructor
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
new GeminiProvider(options: GeminiProviderOptions)
|
|
217
|
+
|
|
218
|
+
interface GeminiProviderOptions {
|
|
219
|
+
apiKey: string;
|
|
220
|
+
model?: string; // Default: "models/gemini-2.5-flash"
|
|
221
|
+
backupModels?: string[]; // Fallback models
|
|
222
|
+
retryConfig?: {
|
|
223
|
+
timeout?: number; // Default: 60000ms
|
|
224
|
+
retries?: number; // Default: 3
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### Methods
|
|
230
|
+
|
|
231
|
+
##### `generateMessage<TContext>(input: GenerateMessageInput<TContext>): Promise<GenerateMessageOutput>`
|
|
232
|
+
|
|
233
|
+
Generates a message with retry logic and backup models.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### `PromptBuilder`
|
|
238
|
+
|
|
239
|
+
Constructs prompts for AI generation.
|
|
240
|
+
|
|
241
|
+
#### Methods
|
|
242
|
+
|
|
243
|
+
##### `addIdentity(name: string, description?: string, goal?: string): this`
|
|
244
|
+
|
|
245
|
+
Adds agent identity section.
|
|
246
|
+
|
|
247
|
+
##### `addContext(variables: ContextVariable[]): this`
|
|
248
|
+
|
|
249
|
+
Adds context variables.
|
|
250
|
+
|
|
251
|
+
##### `addGlossary(terms: Term[]): this`
|
|
252
|
+
|
|
253
|
+
Adds domain glossary terms.
|
|
254
|
+
|
|
255
|
+
##### `addGuidelinesForMessageGeneration(guidelines: GuidelineMatch[]): this`
|
|
256
|
+
|
|
257
|
+
Adds guidelines section.
|
|
258
|
+
|
|
259
|
+
##### `addCapabilitiesForMessageGeneration(capabilities: Capability[]): this`
|
|
260
|
+
|
|
261
|
+
Adds capabilities section.
|
|
262
|
+
|
|
263
|
+
##### `addObservations(observations): this`
|
|
264
|
+
|
|
265
|
+
Adds observations for disambiguation.
|
|
266
|
+
|
|
267
|
+
##### `addActiveRoutes(routes): this`
|
|
268
|
+
|
|
269
|
+
Adds active routes to the prompt.
|
|
270
|
+
|
|
271
|
+
##### `build(): string`
|
|
272
|
+
|
|
273
|
+
Builds the final prompt string.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Utility Functions
|
|
278
|
+
|
|
279
|
+
### `defineTool<TContext, TArgs, TReturn>()`
|
|
280
|
+
|
|
281
|
+
Defines a type-safe tool.
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
defineTool<TContext, TArgs extends unknown[], TReturn>(
|
|
285
|
+
name: string,
|
|
286
|
+
handler: ToolHandler<TContext, TArgs, TReturn>,
|
|
287
|
+
options?: {
|
|
288
|
+
description?: string;
|
|
289
|
+
metadata?: Record<string, unknown>;
|
|
290
|
+
}
|
|
291
|
+
): ToolRef<TContext, TArgs, TReturn>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Example:**
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
const getTool = defineTool<MyContext, [id: string], Data>(
|
|
298
|
+
"get_data",
|
|
299
|
+
async ({ context }, id) => {
|
|
300
|
+
return { data: await fetchData(id) };
|
|
301
|
+
},
|
|
302
|
+
{ description: "Fetches data by ID" }
|
|
303
|
+
);
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
### `createMessageEvent()`
|
|
309
|
+
|
|
310
|
+
Creates a message event for conversation history.
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
createMessageEvent(
|
|
314
|
+
source: EventSource,
|
|
315
|
+
name: string,
|
|
316
|
+
message: string
|
|
317
|
+
): Event
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
### `createToolEvent()`
|
|
323
|
+
|
|
324
|
+
Creates a tool execution event.
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
createToolEvent(
|
|
328
|
+
toolName: string,
|
|
329
|
+
data: unknown
|
|
330
|
+
): Event
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### `adaptEvent()`
|
|
336
|
+
|
|
337
|
+
Adapts an event to the internal format.
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
adaptEvent(event: EmittedEvent): Event
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## Type Definitions
|
|
346
|
+
|
|
347
|
+
### `Term`
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
interface Term {
|
|
351
|
+
name: string;
|
|
352
|
+
description: string;
|
|
353
|
+
synonyms?: string[];
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
### `Guideline`
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
interface Guideline {
|
|
363
|
+
id?: string;
|
|
364
|
+
condition?: string;
|
|
365
|
+
action: string;
|
|
366
|
+
enabled?: boolean; // Default: true
|
|
367
|
+
tags?: string[];
|
|
368
|
+
tools?: ToolRef[];
|
|
369
|
+
metadata?: Record<string, unknown>;
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
### `Capability`
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
interface Capability {
|
|
379
|
+
id?: string;
|
|
380
|
+
title: string;
|
|
381
|
+
description: string;
|
|
382
|
+
tools?: ToolRef[];
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
### `Event`
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
interface Event {
|
|
392
|
+
kind: EventKind;
|
|
393
|
+
source: EventSource;
|
|
394
|
+
data: MessageEventData | ToolEventData | StatusEventData;
|
|
395
|
+
creation_utc: string;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
enum EventKind {
|
|
399
|
+
MESSAGE = "message",
|
|
400
|
+
TOOL = "tool",
|
|
401
|
+
STATUS = "status",
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
enum EventSource {
|
|
405
|
+
CUSTOMER = "customer",
|
|
406
|
+
AI_AGENT = "agent",
|
|
407
|
+
SYSTEM = "system",
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
### `ToolContext<TContext>`
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
interface ToolContext<TContext> {
|
|
417
|
+
context: TContext;
|
|
418
|
+
// Additional runtime context
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
### `ToolResult<TReturn>`
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
interface ToolResult<TReturn> {
|
|
428
|
+
data: TReturn;
|
|
429
|
+
error?: string;
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Constants
|
|
436
|
+
|
|
437
|
+
### `END_ROUTE`
|
|
438
|
+
|
|
439
|
+
Symbol marking the end of a conversation route.
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
import { END_ROUTE } from "@falai/agent";
|
|
443
|
+
|
|
444
|
+
state.transitionTo({ state: END_ROUTE });
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## Enums
|
|
450
|
+
|
|
451
|
+
### `CompositionMode`
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
enum CompositionMode {
|
|
455
|
+
FLUID = "fluid",
|
|
456
|
+
CANNED_FLUID = "canned_fluid",
|
|
457
|
+
CANNED_COMPOSITED = "composited_canned",
|
|
458
|
+
CANNED_STRICT = "strict_canned",
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
### `BuiltInSection`
|
|
465
|
+
|
|
466
|
+
Prompt builder section identifiers.
|
|
467
|
+
|
|
468
|
+
```typescript
|
|
469
|
+
enum BuiltInSection {
|
|
470
|
+
IDENTITY = "identity",
|
|
471
|
+
GLOSSARY = "glossary",
|
|
472
|
+
CONTEXT = "context",
|
|
473
|
+
GUIDELINES = "guidelines",
|
|
474
|
+
CAPABILITIES = "capabilities",
|
|
475
|
+
OBSERVATIONS = "observations",
|
|
476
|
+
ACTIVE_ROUTES = "active_routes",
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Advanced Topics
|
|
483
|
+
|
|
484
|
+
### Custom AI Providers
|
|
485
|
+
|
|
486
|
+
Implement the `AiProvider` interface:
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
interface AiProvider {
|
|
490
|
+
generateMessage<TContext = unknown>(
|
|
491
|
+
input: GenerateMessageInput<TContext>
|
|
492
|
+
): Promise<GenerateMessageOutput>;
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### Domain Registry
|
|
497
|
+
|
|
498
|
+
Organize tools by domain:
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
const paymentDomain = {
|
|
502
|
+
processPayment: async (amount: number) => {
|
|
503
|
+
/*...*/
|
|
504
|
+
},
|
|
505
|
+
refund: async (transactionId: string) => {
|
|
506
|
+
/*...*/
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
agent.addDomain("payment", paymentDomain);
|
|
511
|
+
|
|
512
|
+
// Access via agent.domain.payment.processPayment()
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
**Made with ❤️ for the community**
|