@statelyai/agent 2.0.0-next.2 → 2.0.0-next.4

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 (41) hide show
  1. package/.changeset/nice-pants-rule.md +10 -0
  2. package/.changeset/pink-eagles-deliver.md +13 -0
  3. package/.changeset/pre.json +7 -1
  4. package/.changeset/quiet-turtles-do.md +7 -0
  5. package/.changeset/sweet-clouds-mix.md +16 -0
  6. package/.changeset/swift-mangos-rush.md +5 -0
  7. package/.changeset/tough-ways-rhyme.md +5 -0
  8. package/CHANGELOG.md +50 -0
  9. package/architecture.tldr +175 -0
  10. package/dist/index.d.mts +116 -102
  11. package/dist/index.d.ts +116 -102
  12. package/dist/index.js +51 -74
  13. package/dist/index.mjs +51 -74
  14. package/examples/cot.ts +19 -53
  15. package/examples/customer-service-sim.ts +3 -3
  16. package/examples/email.ts +2 -10
  17. package/examples/example.ts +2 -2
  18. package/examples/goal.ts +2 -2
  19. package/examples/joke.ts +10 -10
  20. package/examples/learn-from-feedback.ts +47 -24
  21. package/examples/number.ts +2 -2
  22. package/examples/raffle.ts +2 -2
  23. package/examples/support.ts +7 -11
  24. package/examples/ticTacToe.ts +2 -2
  25. package/examples/todo.ts +3 -3
  26. package/examples/tutor.ts +2 -2
  27. package/examples/verify.ts +2 -2
  28. package/examples/weather-agent.ts +3 -5
  29. package/examples/weather.ts +10 -7
  30. package/package.json +1 -1
  31. package/src/agent.test.ts +124 -43
  32. package/src/agent.ts +61 -42
  33. package/src/decide.test.ts +22 -0
  34. package/src/decide.ts +27 -29
  35. package/src/strategies/chainOfThought.ts +5 -3
  36. package/src/strategies/shortestPath.ts +7 -2
  37. package/src/strategies/{simple.ts → simpleStrategy.ts} +5 -16
  38. package/src/templates/defaultText.ts +3 -0
  39. package/src/text.ts +13 -14
  40. package/src/types.ts +103 -104
  41. package/src/utils.ts +1 -1
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as ai from 'ai';
2
2
  import { generateText, streamText, LanguageModel, CoreMessage, GenerateTextResult, LanguageModelV1, CoreTool } from 'ai';
3
- import { EventObject, AnyStateMachine, AnyEventObject, ActorRefLike, SnapshotFrom, EventFrom, PromiseActorLogic, ActorLogic, TransitionSnapshot, Values, StateValue, Actor, Subscription, ObservableActorLogic } from 'xstate';
3
+ import { AnyStateMachine, ActorRefLike, SnapshotFrom, EventFrom, AnyEventObject, PromiseActorLogic, ActorLogic, TransitionSnapshot, Values, StateValue, EventObject, Actor, Subscription, ObservableActorLogic } from 'xstate';
4
4
  import { SomeZodObject, ZodType, TypeOf } from 'zod';
5
5
 
6
6
  type ZodEventMapping = {
@@ -12,12 +12,17 @@ type ZodContextMapping = {
12
12
 
13
13
  type GenerateTextOptions = Parameters<typeof generateText>[0];
14
14
  type StreamTextOptions = Parameters<typeof streamText>[0];
15
- type CostFunction<TEvent extends EventObject> = (path: AgentPath<TEvent>) => number;
16
- type AgentDecideInput<TEvent extends EventObject> = Omit<AgentGenerateTextOptions, 'prompt' | 'tools'> & {
15
+ type CostFunction<TAgent extends AnyAgent> = (path: AgentPath<TAgent>) => number;
16
+ type AgentDecideInput<TAgent extends AnyAgent> = Omit<AgentGenerateTextOptions<TAgent>, 'model' | 'prompt' | 'tools'> & {
17
+ episodeId?: string;
17
18
  /**
18
19
  * The currently observed state.
19
20
  */
20
- state: ObservedState;
21
+ state: ObservedState<TAgent>;
22
+ /**
23
+ * The context to provide in the prompt to the agent. This overrides the `state.context`.
24
+ */
25
+ context?: Record<string, any>;
21
26
  /**
22
27
  * The goal for the agent to accomplish.
23
28
  * The agent will make a decision based on this goal.
@@ -27,40 +32,40 @@ type AgentDecideInput<TEvent extends EventObject> = Omit<AgentGenerateTextOption
27
32
  * The events that the agent can trigger. This is a mapping of
28
33
  * event types to Zod event schemas.
29
34
  */
30
- events: ZodEventMapping;
35
+ events?: ZodEventMapping;
36
+ allowedEvents?: Array<EventFromAgent<TAgent>['type']>;
31
37
  /**
32
38
  * The state machine that represents the environment the agent
33
39
  * is interacting with.
34
40
  */
35
41
  machine?: AnyStateMachine;
36
- /**
37
- * The previous decision made by the agent.
38
- */
39
- prevDecision?: AgentDecision<TEvent>;
40
42
  /**
41
43
  * The total cost of the path to the goal state.
42
44
  */
43
- costFunction?: CostFunction<TEvent>;
45
+ costFunction?: CostFunction<TAgent>;
44
46
  /**
45
47
  * The maximum number of attempts to make a decision.
46
48
  * Defaults to 2.
47
49
  */
48
50
  maxAttempts?: number;
51
+ strategy?: AgentStrategy<TAgent>;
52
+ model?: LanguageModel;
49
53
  };
50
- type AgentStep<TEvent extends EventObject> = {
54
+ type AgentStep<TAgent extends AnyAgent> = {
51
55
  /** The event to take */
52
- event: TEvent;
56
+ event: EventFromAgent<TAgent>;
53
57
  /** The next expected state after taking the event */
54
- state: ObservedState | undefined;
58
+ state: ObservedState<TAgent> | undefined;
55
59
  };
56
- type AgentPath<TEvent extends EventObject> = {
60
+ type AgentPath<TAgent extends AnyAgent> = {
57
61
  /** The expected ending state of the path */
58
- state: ObservedState | undefined;
62
+ state: ObservedState<TAgent> | undefined;
59
63
  /** The steps to reach the ending state */
60
- steps: Array<AgentStep<TEvent>>;
64
+ steps: Array<AgentStep<TAgent>>;
61
65
  weight?: number;
62
66
  };
63
- type AgentDecision<TEvent extends EventObject> = {
67
+ type AgentDecision<TAgent extends AnyAgent> = {
68
+ id: string;
64
69
  /**
65
70
  * The strategy used to generate the decision
66
71
  */
@@ -69,17 +74,17 @@ type AgentDecision<TEvent extends EventObject> = {
69
74
  /**
70
75
  * The ending state of the decision.
71
76
  */
72
- goalState: ObservedState | undefined;
77
+ goalState: ObservedState<TAgent> | undefined;
73
78
  /**
74
79
  * The next event that the agent decided needs to occur to achieve the `goal`.
75
80
  *
76
81
  * This next event is chosen from the
77
82
  */
78
- nextEvent: TEvent | undefined;
83
+ nextEvent: EventFromAgent<TAgent> | undefined;
79
84
  /**
80
85
  * The paths that the agent can take to achieve the goal.
81
86
  */
82
- paths: AgentPath<TEvent>[];
87
+ paths: AgentPath<TAgent>[];
83
88
  episodeId: string;
84
89
  timestamp: number;
85
90
  };
@@ -91,17 +96,13 @@ interface TransitionData {
91
96
  };
92
97
  target?: any;
93
98
  }
94
- type PromptTemplate<TEvents extends EventObject> = (data: {
99
+ type PromptTemplate<TAgent extends AnyAgent> = (data: {
95
100
  goal: string;
96
101
  /**
97
102
  * The observed state
98
103
  */
99
- state?: ObservedState;
100
- /**
101
- * The context to provide.
102
- * This overrides the observed state.context, if provided.
103
- */
104
- context?: any;
104
+ stateValue?: any;
105
+ context?: Record<string, any>;
105
106
  /**
106
107
  * The state machine model of the observed environment
107
108
  */
@@ -117,42 +118,38 @@ type PromptTemplate<TEvents extends EventObject> = (data: {
117
118
  observations?: AgentObservation<any>[];
118
119
  feedback?: AgentFeedback[];
119
120
  messages?: AgentMessage[];
120
- decisions?: AgentDecision<TEvents>[];
121
+ decisions?: AgentDecision<TAgent>[];
121
122
  }) => string;
122
- type AgentStrategy<T extends AnyAgent> = (agent: T, input: AgentDecideInput<EventsFromAgent<T>>) => Promise<AgentDecision<EventsFromAgent<T>> | undefined>;
123
- type AgentInteractInput<T extends AnyAgent> = Omit<AgentDecideOptions<T>, 'state'>;
124
- type AgentDecideOptions<T extends AnyAgent> = {
125
- goal: string;
126
- state: ObservedState;
127
- context?: Record<string, any>;
128
- machine?: AnyStateMachine;
129
- model?: LanguageModel;
130
- execute?: (event: AnyEventObject) => Promise<void>;
131
- strategy?: AgentStrategy<T>;
132
- events?: ZodEventMapping;
133
- allowedEvents?: Array<EventsFromAgent<T>['type']>;
134
- /**
135
- * The maximum number of times the agent will attempt to make a decision.
136
- * Defaults to 2.
137
- */
138
- maxAttempts?: number;
139
- } & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;
140
- interface AgentFeedback {
141
- goal: string;
142
- observationId: string;
143
- /**
144
- * The message correlation that the feedback is relevant for
145
- */
123
+ type AgentStrategy<TAgent extends AnyAgent> = (agent: TAgent, input: AgentDecideInput<EventFromAgent<TAgent>>) => Promise<AgentDecision<TAgent> | undefined>;
124
+ type AgentInteractInput<T extends AnyAgent> = Omit<AgentDecideInput<T>, 'state'> & {
125
+ state?: never;
126
+ };
127
+ type AgentFeedback = {
128
+ score: number;
129
+ comment: string | undefined;
146
130
  attributes: Record<string, any>;
147
131
  timestamp: number;
148
132
  episodeId: string;
149
- }
150
- interface AgentFeedbackInput {
151
- goal: string;
133
+ } & ({
152
134
  observationId: string;
153
- attributes: Record<string, any>;
135
+ decisionId?: never;
136
+ } | {
137
+ decisionId: string;
138
+ observationId?: never;
139
+ });
140
+ type AgentFeedbackInput = {
141
+ episodeId?: string;
142
+ score: number;
143
+ comment?: string;
144
+ attributes?: Record<string, any>;
154
145
  timestamp?: number;
155
- }
146
+ } & ({
147
+ observationId: string;
148
+ decisionId?: never;
149
+ } | {
150
+ decisionId: string;
151
+ observationId?: never;
152
+ });
156
153
  type AgentMessage = CoreMessage & {
157
154
  timestamp: number;
158
155
  id: string;
@@ -216,28 +213,34 @@ type AgentMessageInput = CoreMessage & {
216
213
  };
217
214
  interface AgentObservation<TActor extends ActorRefLike> {
218
215
  id: string;
216
+ decisionId?: string | undefined;
217
+ goal?: string;
219
218
  prevState: SnapshotFrom<TActor> | undefined;
220
219
  event: EventFrom<TActor> | undefined;
221
220
  state: SnapshotFrom<TActor>;
222
- machineHash: string | undefined;
223
221
  episodeId: string;
224
222
  timestamp: number;
225
223
  }
226
- interface AgentObservationInput {
224
+ interface AgentObservationInput<TAgent extends AnyAgent> {
227
225
  id?: string;
228
- prevState?: ObservedState;
226
+ episodeId?: string;
227
+ /**
228
+ * The agent decision that the observation is relevant for
229
+ */
230
+ decisionId?: string | undefined;
231
+ prevState?: ObservedState<TAgent>;
229
232
  event?: AnyEventObject;
230
- state: ObservedState;
231
- machine?: AnyStateMachine;
233
+ state: ObservedState<TAgent>;
232
234
  timestamp?: number;
235
+ goal?: string | undefined;
233
236
  }
234
237
  type AgentDecisionInput = {
235
238
  goal: string;
236
239
  model?: LanguageModel;
237
240
  context?: Record<string, any>;
238
241
  } & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;
239
- type AgentDecisionLogic<TEvents extends EventObject> = PromiseActorLogic<AgentDecision<TEvents> | undefined, AgentDecisionInput | string>;
240
- type AgentEmitted<TEvents extends EventObject> = {
242
+ type AgentDecisionLogic<TAgent extends AnyAgent> = PromiseActorLogic<AgentDecision<TAgent> | undefined, AgentDecisionInput | string>;
243
+ type AgentEmitted<TAgent extends AnyAgent> = {
241
244
  type: 'feedback';
242
245
  feedback: AgentFeedback;
243
246
  } | {
@@ -248,9 +251,9 @@ type AgentEmitted<TEvents extends EventObject> = {
248
251
  message: AgentMessage;
249
252
  } | {
250
253
  type: 'decision';
251
- decision: AgentDecision<TEvents>;
254
+ decision: AgentDecision<TAgent>;
252
255
  };
253
- type AgentLogic<TEvents extends EventObject> = ActorLogic<TransitionSnapshot<AgentMemoryContext>, {
256
+ type AgentLogic<TAgent extends AnyAgent> = ActorLogic<TransitionSnapshot<AgentMemoryContext<TAgent>>, {
254
257
  type: 'agent.feedback';
255
258
  feedback: AgentFeedback;
256
259
  } | {
@@ -261,29 +264,29 @@ type AgentLogic<TEvents extends EventObject> = ActorLogic<TransitionSnapshot<Age
261
264
  message: AgentMessage;
262
265
  } | {
263
266
  type: 'agent.decision';
264
- decision: AgentDecision<TEvents>;
267
+ decision: AgentDecision<TAgent>;
265
268
  }, any, // TODO: input
266
- any, AgentEmitted<TEvents>>;
267
- type EventsFromZodEventMapping<TEventSchemas extends ZodEventMapping> = Values<{
269
+ any, AgentEmitted<TAgent>>;
270
+ type EventsFromZodEventMapping<TEventSchemas extends ZodEventMapping> = Compute<Values<{
268
271
  [K in keyof TEventSchemas & string]: {
269
272
  type: K;
270
273
  } & TypeOf<TEventSchemas[K]>;
271
- }>;
274
+ }>>;
272
275
  type ContextFromZodContextMapping<TContextSchema extends ZodContextMapping> = {
273
276
  [K in keyof TContextSchema & string]: TypeOf<TContextSchema[K]>;
274
277
  };
275
278
  type AnyAgent = Agent<any, any, any, any>;
276
279
  type FromAgent<T> = T | ((agent: AnyAgent) => T | Promise<T>);
277
- type CommonTextOptions = {
280
+ type CommonTextOptions<TAgent extends AnyAgent> = {
278
281
  prompt: FromAgent<string>;
279
282
  model?: LanguageModel;
280
- context?: Record<string, any>;
281
283
  messages?: FromAgent<CoreMessage[]>;
282
284
  template?: PromptTemplate<any>;
285
+ context?: Record<string, any>;
283
286
  };
284
- type AgentGenerateTextOptions = Omit<GenerateTextOptions, 'model' | 'prompt' | 'messages'> & CommonTextOptions;
285
- type AgentStreamTextOptions = Omit<StreamTextOptions, 'model' | 'prompt' | 'messages'> & CommonTextOptions;
286
- interface ObservedState {
287
+ type AgentGenerateTextOptions<TAgent extends AnyAgent> = Omit<GenerateTextOptions, 'model' | 'prompt' | 'messages'> & CommonTextOptions<TAgent>;
288
+ type AgentStreamTextOptions<TAgent extends AnyAgent> = Omit<StreamTextOptions, 'model' | 'prompt' | 'messages'> & CommonTextOptions<TAgent>;
289
+ interface ObservedState<TAgent extends AnyAgent> {
287
290
  /**
288
291
  * The current state value of the state machine, e.g.
289
292
  * `"loading"` or `"processing"` or `"ready"`
@@ -292,32 +295,32 @@ interface ObservedState {
292
295
  /**
293
296
  * Additional contextual data related to the current state
294
297
  */
295
- context?: Record<string, unknown>;
298
+ context?: ContextFromAgent<TAgent>;
296
299
  }
297
300
  type ObservedStateFrom<TActor extends ActorRefLike> = Pick<SnapshotFrom<TActor>, 'value' | 'context'>;
298
- type AgentMemoryContext = {
299
- observations: AgentObservation<any>[];
301
+ type AgentMemoryContext<TAgent extends AnyAgent> = {
302
+ observations: AgentObservation<TAgent>[];
300
303
  messages: AgentMessage[];
301
- decisions: AgentDecision<any>[];
304
+ decisions: AgentDecision<TAgent>[];
302
305
  feedback: AgentFeedback[];
303
306
  };
304
- interface AgentLongTermMemory {
305
- get<K extends keyof AgentMemoryContext>(key: K): Promise<AgentMemoryContext[K]>;
306
- append<K extends keyof AgentMemoryContext>(key: K, item: AgentMemoryContext[K][0]): Promise<void>;
307
- set<K extends keyof AgentMemoryContext>(key: K, items: AgentMemoryContext[K]): Promise<void>;
307
+ interface AgentLongTermMemory<TAgent extends AnyAgent> {
308
+ get<K extends keyof AgentMemoryContext<TAgent>>(key: K): Promise<AgentMemoryContext<TAgent>[K]>;
309
+ append<K extends keyof AgentMemoryContext<TAgent>>(key: K, item: AgentMemoryContext<TAgent>[K][0]): Promise<void>;
310
+ set<K extends keyof AgentMemoryContext<TAgent>>(key: K, items: AgentMemoryContext<TAgent>[K]): Promise<void>;
308
311
  }
309
312
  type Compute<A extends any> = {
310
313
  [K in keyof A]: A[K];
311
314
  } & unknown;
312
315
  type MaybePromise<T> = T | Promise<T>;
313
- type EventsFromAgent<T extends AnyAgent> = T extends Agent<infer _, infer __, infer TEvents, infer ___> ? TEvents : never;
316
+ type EventFromAgent<T extends AnyAgent> = T extends Agent<infer _, infer __, infer TEvents, infer ___> ? TEvents : never;
314
317
  type TypesFromAgent<T extends AnyAgent> = T extends Agent<infer TContextSchema, infer TEventSchema> ? {
315
318
  context: ContextFromZodContextMapping<TContextSchema>;
316
319
  events: EventsFromZodEventMapping<TEventSchema>;
317
320
  } : never;
318
321
  type ContextFromAgent<T extends AnyAgent> = T extends Agent<infer TContextSchema, infer _TEventSchema> ? ContextFromZodContextMapping<TContextSchema> : never;
319
322
 
320
- declare function createAgent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>>({ id, description: description, model, events, context, episodeId, strategy, logic, }: {
323
+ declare function createAgent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>, TAgent extends AnyAgent = Agent<TContextSchema, TEventSchemas>>({ id, description: description, model, events, context, episodeId, strategy, logic, }: {
321
324
  /**
322
325
  * The unique identifier for the agent.
323
326
  *
@@ -348,15 +351,15 @@ declare function createAgent<const TContextSchema extends ZodContextMapping, con
348
351
  /**
349
352
  * A function that retrieves the agent's long term memory
350
353
  */
351
- getMemory?: (agent: Agent<TContextSchema, TEventSchemas>) => AgentLongTermMemory;
354
+ getMemory?: (agent: Agent<TContextSchema, TEventSchemas>) => AgentLongTermMemory<TAgent>;
352
355
  /**
353
356
  * Agent logic
354
357
  */
355
- logic?: AgentLogic<TEvents>;
358
+ logic?: AgentLogic<TAgent>;
356
359
  model: LanguageModel;
357
360
  episodeId?: string;
358
361
  }): Agent<TContextSchema, TEventSchemas>;
359
- declare class Agent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>> extends Actor<AgentLogic<TEvents>> {
362
+ declare class Agent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>> extends Actor<AgentLogic<any>> {
360
363
  /**
361
364
  * The name of the agent. All agents with the same name are related and
362
365
  * able to share experiences (observations, feedback) with each other.
@@ -371,10 +374,9 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
371
374
  context?: TContextSchema;
372
375
  strategy: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
373
376
  model: LanguageModel;
374
- memory: AgentLongTermMemory | undefined;
375
- defaultOptions: AgentDecideOptions<AnyAgent> | undefined;
377
+ memory: AgentLongTermMemory<this> | undefined;
376
378
  constructor({ logic, id, name, description, model, events, context, episodeId, strategy, }: {
377
- logic: AgentLogic<TEvents>;
379
+ logic: AgentLogic<any>;
378
380
  id?: string;
379
381
  name?: string;
380
382
  description?: string;
@@ -434,24 +436,36 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
434
436
  };
435
437
  getMessages(): AgentMessage[];
436
438
  addFeedback(feedbackInput: AgentFeedbackInput): {
439
+ comment: string | undefined;
437
440
  attributes: {
438
441
  [x: string]: any;
439
442
  };
440
443
  timestamp: number;
441
444
  episodeId: string;
442
- goal: string;
445
+ score: number;
443
446
  observationId: string;
447
+ decisionId?: never;
448
+ } | {
449
+ comment: string | undefined;
450
+ attributes: {
451
+ [x: string]: any;
452
+ };
453
+ timestamp: number;
454
+ episodeId: string;
455
+ score: number;
456
+ decisionId: string;
457
+ observationId?: never;
444
458
  };
445
459
  /**
446
460
  * Retrieves feedback from the agent's short-term (local) memory.
447
461
  */
448
462
  getFeedback(): AgentFeedback[];
449
- addObservation(observationInput: AgentObservationInput): AgentObservation<any>;
463
+ addObservation(observationInput: AgentObservationInput<this>): AgentObservation<any>;
450
464
  /**
451
465
  * Retrieves observations from the agent's short-term (local) memory.
452
466
  */
453
467
  getObservations(): AgentObservation<any>[];
454
- addDecision(decision: AgentDecision<TEvents>): void;
468
+ addDecision(decision: AgentDecision<this>): void;
455
469
  /**
456
470
  * Retrieves strategies from the agent's short-term (local) memory.
457
471
  */
@@ -511,18 +525,18 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
511
525
  * - The `machine` (e.g. a state machine) that specifies what can happen next
512
526
  * - Additional `context`
513
527
  */
514
- decide(opts: AgentDecideOptions<this>): Promise<AgentDecision<EventsFromAgent<this>> | undefined>;
528
+ decide(input: AgentDecideInput<this>): Promise<AgentDecision<this> | undefined>;
515
529
  }
516
530
 
517
- declare function fromTextStream<T extends AnyAgent>(agent: T, options?: AgentStreamTextOptions): ObservableActorLogic<{
531
+ declare function fromTextStream<TAgent extends AnyAgent>(agent: TAgent, options?: AgentStreamTextOptions<TAgent>): ObservableActorLogic<{
518
532
  textDelta: string;
519
- }, Omit<AgentStreamTextOptions, 'context'> & {
520
- context?: AgentStreamTextOptions['context'];
533
+ }, Omit<AgentStreamTextOptions<TAgent>, 'context'> & {
534
+ context?: Record<string, any>;
521
535
  }>;
522
- declare function fromText<T extends AnyAgent>(agent: T, options?: AgentGenerateTextOptions): PromiseActorLogic<GenerateTextResult<Record<string, CoreTool<any, any>>>, Omit<AgentGenerateTextOptions, 'context'> & {
523
- context?: AgentGenerateTextOptions['context'];
536
+ declare function fromText<TAgent extends AnyAgent>(agent: TAgent, options?: AgentGenerateTextOptions<TAgent>): PromiseActorLogic<GenerateTextResult<Record<string, CoreTool<any, any>>>, Omit<AgentGenerateTextOptions<TAgent>, 'context'> & {
537
+ context?: Record<string, any>;
524
538
  }>;
525
539
 
526
- declare function fromDecision<T extends AnyAgent>(agent: T, defaultInput?: AgentDecideInput<EventsFromAgent<T>>): AgentDecisionLogic<any>;
540
+ declare function fromDecision<T extends AnyAgent>(agent: T, defaultInput?: AgentDecideInput<EventFromAgent<T>>): AgentDecisionLogic<any>;
527
541
 
528
- export { type AgentDecideInput, type AgentDecideOptions, type AgentDecision, type AgentDecisionInput, type AgentDecisionLogic, type AgentEmitted, type AgentFeedback, type AgentFeedbackInput, type AgentGenerateTextOptions, type AgentInteractInput, type AgentLogic, type AgentLongTermMemory, type AgentMemoryContext, type AgentMessage, type AgentMessageInput, type AgentObservation, type AgentObservationInput, type AgentPath, type AgentStep, type AgentStrategy, type AgentStreamTextOptions, type AnyAgent, type CommonTextOptions, type Compute, type ContextFromAgent, type ContextFromZodContextMapping, type CostFunction, type EventsFromAgent, type EventsFromZodEventMapping, type FromAgent, type GenerateTextOptions, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type MaybePromise, type ObservedState, type ObservedStateFrom, type PromptTemplate, type StreamTextOptions, type TransitionData, type TypesFromAgent, createAgent, fromDecision, fromText, fromTextStream };
542
+ export { type AgentDecideInput, type AgentDecision, type AgentDecisionInput, type AgentDecisionLogic, type AgentEmitted, type AgentFeedback, type AgentFeedbackInput, type AgentGenerateTextOptions, type AgentInteractInput, type AgentLogic, type AgentLongTermMemory, type AgentMemoryContext, type AgentMessage, type AgentMessageInput, type AgentObservation, type AgentObservationInput, type AgentPath, type AgentStep, type AgentStrategy, type AgentStreamTextOptions, type AnyAgent, type CommonTextOptions, type Compute, type ContextFromAgent, type ContextFromZodContextMapping, type CostFunction, type EventFromAgent, type EventsFromZodEventMapping, type FromAgent, type GenerateTextOptions, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type MaybePromise, type ObservedState, type ObservedStateFrom, type PromptTemplate, type StreamTextOptions, type TransitionData, type TypesFromAgent, createAgent, fromDecision, fromText, fromTextStream };