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

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 (51) hide show
  1. package/.changeset/cyan-carpets-perform.md +5 -0
  2. package/.changeset/fast-donkeys-argue.md +5 -0
  3. package/.changeset/grumpy-dolphins-think.md +17 -0
  4. package/.changeset/old-jobs-check.md +5 -0
  5. package/.changeset/old-teachers-tap.md +5 -0
  6. package/.changeset/pre.json +7 -1
  7. package/.changeset/smart-yaks-pull.md +23 -0
  8. package/CHANGELOG.md +52 -0
  9. package/dist/index.d.mts +69 -66
  10. package/dist/index.d.ts +69 -66
  11. package/dist/index.js +111 -79
  12. package/dist/index.mjs +114 -82
  13. package/examples/chatbot-alt.ts +1 -1
  14. package/examples/chatbot.ts +3 -3
  15. package/examples/cot.ts +7 -25
  16. package/examples/customer-service-sim.ts +7 -7
  17. package/examples/email.ts +37 -35
  18. package/examples/example.ts +3 -3
  19. package/examples/goal.ts +3 -3
  20. package/examples/joke.ts +3 -3
  21. package/examples/jugs.ts +5 -8
  22. package/examples/learn-from-feedback.ts +100 -0
  23. package/examples/multi.ts +1 -1
  24. package/examples/number.ts +3 -3
  25. package/examples/raffle.ts +3 -3
  26. package/examples/river-crossing.ts +5 -8
  27. package/examples/simple.ts +14 -11
  28. package/examples/summary.ts +3 -6
  29. package/examples/support.ts +43 -39
  30. package/examples/ticTacToe.ts +48 -6
  31. package/examples/todo.ts +3 -3
  32. package/examples/tutor.ts +4 -4
  33. package/examples/verify.ts +3 -3
  34. package/examples/weather-agent.ts +141 -0
  35. package/examples/weather.ts +24 -24
  36. package/examples/wiki.ts +1 -1
  37. package/examples/word.ts +9 -7
  38. package/package.json +6 -3
  39. package/src/agent.test.ts +161 -19
  40. package/src/agent.ts +66 -250
  41. package/src/decide.test.ts +172 -3
  42. package/src/decide.ts +50 -30
  43. package/src/middleware.ts +2 -14
  44. package/src/strategies/chainOfThought.ts +48 -0
  45. package/src/strategies/shortestPath.test.ts +91 -0
  46. package/src/{planners/shortestPathPlanner.ts → strategies/shortestPath.ts} +32 -19
  47. package/src/{planners/simplePlanner.ts → strategies/simple.ts} +28 -24
  48. package/src/types.ts +75 -34
  49. package/src/utils.ts +23 -0
  50. package/vitest.config.ts +9 -3
  51. package/src/strategies/chain-of-note.ts +0 -106
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@statelyai/agent': patch
3
+ ---
4
+
5
+ The `name` field in `createAgent({ name: '...' })` has been renamed to `id`.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@statelyai/agent": patch
3
+ ---
4
+
5
+ The `description` field in `createAgent({ description: '...' })` is now used for the `system` prompt in agent decision making when a `system` prompt is not provided.
@@ -0,0 +1,17 @@
1
+ ---
2
+ '@statelyai/agent': minor
3
+ ---
4
+
5
+ planner -> strategy
6
+ agent.addPlan -> agent.addDecision
7
+ agent.getPlans -> agent.getDecisions
8
+
9
+ The word "strategy" is now used instead of "planner" to make it more clear what the agent is doing: it uses a strategy to make decisions. The method `agent.addPlan(…)` has been renamed to `agent.addDecision(…)` and `agent.getPlans(…)` has been renamed to `agent.getDecisions(…)` to reflect this change. Additionally, you specify the `strategy` instead of the `planner` when creating an agent:
10
+
11
+ ```diff
12
+ const agent = createAgent({
13
+ - planner: createSimplePlanner(),
14
+ + strategy: createSimpleStrategy(),
15
+ ...
16
+ });
17
+ ```
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@statelyai/agent': minor
3
+ ---
4
+
5
+ You can specify `maxAttempts` in `agent.decide({ maxAttempts: 5 })`. This will allow the agent to attempt to make a decision up to the specified number of `maxAttempts` before giving up. The default value is `2`.
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@statelyai/agent': minor
3
+ ---
4
+
5
+ For feedback, the `goal`, `observationId`, and `attributes` are now required, and `feedback` and `reward` are removed since they are redundant.
@@ -5,6 +5,12 @@
5
5
  "@statelyai/agent": "1.1.6"
6
6
  },
7
7
  "changesets": [
8
- "light-hats-drive"
8
+ "cyan-carpets-perform",
9
+ "fast-donkeys-argue",
10
+ "grumpy-dolphins-think",
11
+ "light-hats-drive",
12
+ "old-jobs-check",
13
+ "old-teachers-tap",
14
+ "smart-yaks-pull"
9
15
  ]
10
16
  }
@@ -0,0 +1,23 @@
1
+ ---
2
+ '@statelyai/agent': minor
3
+ ---
4
+
5
+ You can specify `allowedEvents` in `agent.decide(...)` to allow from a list of specific events to be sent to the agent. This is useful when using `agent.decide(...)` without a state machine.
6
+
7
+ ```ts
8
+ const agent = createAgent({
9
+ // ...
10
+ events: {
11
+ PLAY: z.object({}).describe('Play a move'),
12
+ SKIP: z.object({}).describe('Skip a move'),
13
+ FORFEIT: z.object({}).describe('Forfeit the game'),
14
+ },
15
+ });
16
+
17
+ // ...
18
+ const decision = await agent.decide({
19
+ // Don't allow the agent to send `FORFEIT` or other events
20
+ allowedEvents: ['PLAY', 'SKIP'],
21
+ // ...
22
+ });
23
+ ```
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @statelyai/agent
2
2
 
3
+ ## 2.0.0-next.2
4
+
5
+ ### Minor Changes
6
+
7
+ - [`4d870fe`](https://github.com/statelyai/agent/commit/4d870fe38ad0c906bafb2e0f6b2dabb745900ad3) Thanks [@davidkpiano](https://github.com/davidkpiano)! - planner -> strategy
8
+ agent.addPlan -> agent.addDecision
9
+ agent.getPlans -> agent.getDecisions
10
+
11
+ The word "strategy" is now used instead of "planner" to make it more clear what the agent is doing: it uses a strategy to make decisions. The method `agent.addPlan(…)` has been renamed to `agent.addDecision(…)` and `agent.getPlans(…)` has been renamed to `agent.getDecisions(…)` to reflect this change. Additionally, you specify the `strategy` instead of the `planner` when creating an agent:
12
+
13
+ ```diff
14
+ const agent = createAgent({
15
+ - planner: createSimplePlanner(),
16
+ + strategy: createSimpleStrategy(),
17
+ ...
18
+ });
19
+ ```
20
+
21
+ - [`f1189cb`](https://github.com/statelyai/agent/commit/f1189cb980e52fa909888d27d3300dcd913ea47f) Thanks [@davidkpiano](https://github.com/davidkpiano)! - For feedback, the `goal`, `observationId`, and `attributes` are now required, and `feedback` and `reward` are removed since they are redundant.
22
+
23
+ - [`7b16326`](https://github.com/statelyai/agent/commit/7b163266c61bfc8125ed4d00924680d932001e27) Thanks [@davidkpiano](https://github.com/davidkpiano)! - You can specify `allowedEvents` in `agent.decide(...)` to allow from a list of specific events to be sent to the agent. This is useful when using `agent.decide(...)` without a state machine.
24
+
25
+ ```ts
26
+ const agent = createAgent({
27
+ // ...
28
+ events: {
29
+ PLAY: z.object({}).describe("Play a move"),
30
+ SKIP: z.object({}).describe("Skip a move"),
31
+ FORFEIT: z.object({}).describe("Forfeit the game"),
32
+ },
33
+ });
34
+
35
+ // ...
36
+ const decision = await agent.decide({
37
+ // Don't allow the agent to send `FORFEIT` or other events
38
+ allowedEvents: ["PLAY", "SKIP"],
39
+ // ...
40
+ });
41
+ ```
42
+
43
+ ## 2.0.0-next.1
44
+
45
+ ### Minor Changes
46
+
47
+ - [`6a9861d`](https://github.com/statelyai/agent/commit/6a9861d959ce295114f53c95c5bdaa097348bacb) Thanks [@davidkpiano](https://github.com/davidkpiano)! - You can specify `maxAttempts` in `agent.decide({ maxAttempts: 5 })`. This will allow the agent to attempt to make a decision up to the specified number of `maxAttempts` before giving up. The default value is `2`.
48
+
49
+ ### Patch Changes
50
+
51
+ - [`8c3eab8`](https://github.com/statelyai/agent/commit/8c3eab8950cb85e662c6afb5d8cefb1d5ef54dd8) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The `name` field in `createAgent({ name: '...' })` has been renamed to `id`.
52
+
53
+ - [`8c3eab8`](https://github.com/statelyai/agent/commit/8c3eab8950cb85e662c6afb5d8cefb1d5ef54dd8) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The `description` field in `createAgent({ description: '...' })` is now used for the `system` prompt in agent decision making when a `system` prompt is not provided.
54
+
3
55
  ## 2.0.0-next.0
4
56
 
5
57
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -13,14 +13,14 @@ type ZodContextMapping = {
13
13
  type GenerateTextOptions = Parameters<typeof generateText>[0];
14
14
  type StreamTextOptions = Parameters<typeof streamText>[0];
15
15
  type CostFunction<TEvent extends EventObject> = (path: AgentPath<TEvent>) => number;
16
- type AgentPlanInput<TEvent extends EventObject> = Omit<GenerateTextOptions, 'prompt' | 'tools'> & {
16
+ type AgentDecideInput<TEvent extends EventObject> = Omit<AgentGenerateTextOptions, 'prompt' | 'tools'> & {
17
17
  /**
18
18
  * The currently observed state.
19
19
  */
20
20
  state: ObservedState;
21
21
  /**
22
22
  * The goal for the agent to accomplish.
23
- * The agent will create a plan based on this goal.
23
+ * The agent will make a decision based on this goal.
24
24
  */
25
25
  goal: string;
26
26
  /**
@@ -34,13 +34,18 @@ type AgentPlanInput<TEvent extends EventObject> = Omit<GenerateTextOptions, 'pro
34
34
  */
35
35
  machine?: AnyStateMachine;
36
36
  /**
37
- * The previous plan.
37
+ * The previous decision made by the agent.
38
38
  */
39
- previousPlan?: AgentPlan<TEvent>;
39
+ prevDecision?: AgentDecision<TEvent>;
40
40
  /**
41
41
  * The total cost of the path to the goal state.
42
42
  */
43
43
  costFunction?: CostFunction<TEvent>;
44
+ /**
45
+ * The maximum number of attempts to make a decision.
46
+ * Defaults to 2.
47
+ */
48
+ maxAttempts?: number;
44
49
  };
45
50
  type AgentStep<TEvent extends EventObject> = {
46
51
  /** The event to take */
@@ -55,14 +60,14 @@ type AgentPath<TEvent extends EventObject> = {
55
60
  steps: Array<AgentStep<TEvent>>;
56
61
  weight?: number;
57
62
  };
58
- type AgentPlan<TEvent extends EventObject> = {
63
+ type AgentDecision<TEvent extends EventObject> = {
59
64
  /**
60
- * The planner used to generate the plan
65
+ * The strategy used to generate the decision
61
66
  */
62
- planner: string;
67
+ strategy: string;
63
68
  goal: string;
64
69
  /**
65
- * The ending state of the plan.
70
+ * The ending state of the decision.
66
71
  */
67
72
  goalState: ObservedState | undefined;
68
73
  /**
@@ -112,37 +117,41 @@ type PromptTemplate<TEvents extends EventObject> = (data: {
112
117
  observations?: AgentObservation<any>[];
113
118
  feedback?: AgentFeedback[];
114
119
  messages?: AgentMessage[];
115
- plans?: AgentPlan<TEvents>[];
120
+ decisions?: AgentDecision<TEvents>[];
116
121
  }) => string;
117
- type AgentPlanner<T extends AnyAgent> = (agent: T, input: AgentPlanInput<T['types']['events']>) => Promise<AgentPlan<T['types']['events']> | undefined>;
118
- type AgentDecideOptions = {
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> = {
119
125
  goal: string;
120
- model?: LanguageModel;
121
126
  state: ObservedState;
127
+ context?: Record<string, any>;
122
128
  machine?: AnyStateMachine;
129
+ model?: LanguageModel;
123
130
  execute?: (event: AnyEventObject) => Promise<void>;
124
- planner?: AgentPlanner<any>;
131
+ strategy?: AgentStrategy<T>;
125
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;
126
139
  } & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;
127
140
  interface AgentFeedback {
128
- goal?: string;
129
- observationId?: string;
141
+ goal: string;
142
+ observationId: string;
130
143
  /**
131
144
  * The message correlation that the feedback is relevant for
132
145
  */
133
- correlationId?: string;
134
146
  attributes: Record<string, any>;
135
- reward: number;
136
147
  timestamp: number;
137
148
  episodeId: string;
138
149
  }
139
150
  interface AgentFeedbackInput {
140
- goal?: string;
141
- observationId?: string;
142
- correlationId?: string;
143
- attributes?: Record<string, any>;
151
+ goal: string;
152
+ observationId: string;
153
+ attributes: Record<string, any>;
144
154
  timestamp?: number;
145
- reward?: number;
146
155
  }
147
156
  type AgentMessage = CoreMessage & {
148
157
  timestamp: number;
@@ -203,8 +212,6 @@ type AgentMessageInput = CoreMessage & {
203
212
  * which message this message is responding to, if any.
204
213
  */
205
214
  responseId?: string;
206
- correlationId?: string;
207
- parentCorrelationId?: string;
208
215
  result?: GenerateTextResult<any>;
209
216
  };
210
217
  interface AgentObservation<TActor extends ActorRefLike> {
@@ -229,7 +236,7 @@ type AgentDecisionInput = {
229
236
  model?: LanguageModel;
230
237
  context?: Record<string, any>;
231
238
  } & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;
232
- type AgentDecisionLogic<TEvents extends EventObject> = PromiseActorLogic<AgentPlan<TEvents> | undefined, AgentDecisionInput | string>;
239
+ type AgentDecisionLogic<TEvents extends EventObject> = PromiseActorLogic<AgentDecision<TEvents> | undefined, AgentDecisionInput | string>;
233
240
  type AgentEmitted<TEvents extends EventObject> = {
234
241
  type: 'feedback';
235
242
  feedback: AgentFeedback;
@@ -240,8 +247,8 @@ type AgentEmitted<TEvents extends EventObject> = {
240
247
  type: 'message';
241
248
  message: AgentMessage;
242
249
  } | {
243
- type: 'plan';
244
- plan: AgentPlan<TEvents>;
250
+ type: 'decision';
251
+ decision: AgentDecision<TEvents>;
245
252
  };
246
253
  type AgentLogic<TEvents extends EventObject> = ActorLogic<TransitionSnapshot<AgentMemoryContext>, {
247
254
  type: 'agent.feedback';
@@ -253,8 +260,8 @@ type AgentLogic<TEvents extends EventObject> = ActorLogic<TransitionSnapshot<Age
253
260
  type: 'agent.message';
254
261
  message: AgentMessage;
255
262
  } | {
256
- type: 'agent.plan';
257
- plan: AgentPlan<TEvents>;
263
+ type: 'agent.decision';
264
+ decision: AgentDecision<TEvents>;
258
265
  }, any, // TODO: input
259
266
  any, AgentEmitted<TEvents>>;
260
267
  type EventsFromZodEventMapping<TEventSchemas extends ZodEventMapping> = Values<{
@@ -265,7 +272,7 @@ type EventsFromZodEventMapping<TEventSchemas extends ZodEventMapping> = Values<{
265
272
  type ContextFromZodContextMapping<TContextSchema extends ZodContextMapping> = {
266
273
  [K in keyof TContextSchema & string]: TypeOf<TContextSchema[K]>;
267
274
  };
268
- type AnyAgent = Agent<any, any>;
275
+ type AnyAgent = Agent<any, any, any, any>;
269
276
  type FromAgent<T> = T | ((agent: AnyAgent) => T | Promise<T>);
270
277
  type CommonTextOptions = {
271
278
  prompt: FromAgent<string>;
@@ -291,7 +298,7 @@ type ObservedStateFrom<TActor extends ActorRefLike> = Pick<SnapshotFrom<TActor>,
291
298
  type AgentMemoryContext = {
292
299
  observations: AgentObservation<any>[];
293
300
  messages: AgentMessage[];
294
- plans: AgentPlan<any>[];
301
+ decisions: AgentDecision<any>[];
295
302
  feedback: AgentFeedback[];
296
303
  };
297
304
  interface AgentLongTermMemory {
@@ -302,13 +309,20 @@ interface AgentLongTermMemory {
302
309
  type Compute<A extends any> = {
303
310
  [K in keyof A]: A[K];
304
311
  } & unknown;
312
+ type MaybePromise<T> = T | Promise<T>;
313
+ type EventsFromAgent<T extends AnyAgent> = T extends Agent<infer _, infer __, infer TEvents, infer ___> ? TEvents : never;
314
+ type TypesFromAgent<T extends AnyAgent> = T extends Agent<infer TContextSchema, infer TEventSchema> ? {
315
+ context: ContextFromZodContextMapping<TContextSchema>;
316
+ events: EventsFromZodEventMapping<TEventSchema>;
317
+ } : never;
318
+ type ContextFromAgent<T extends AnyAgent> = T extends Agent<infer TContextSchema, infer _TEventSchema> ? ContextFromZodContextMapping<TContextSchema> : never;
305
319
 
306
- declare function createAgent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>>({ id, name, description, model, events, context, planner, stringify, getMemory, logic, ...generateTextOptions }: {
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, }: {
307
321
  /**
308
322
  * The unique identifier for the agent.
309
323
  *
310
324
  * This should be the same across all sessions of a specific agent, as it can be
311
- * used to retrieve memory for this agent.
325
+ * used to retrieve memory for previous episodes of this agent.
312
326
  *
313
327
  * @example
314
328
  * ```ts
@@ -319,10 +333,6 @@ declare function createAgent<const TContextSchema extends ZodContextMapping, con
319
333
  * ```
320
334
  */
321
335
  id?: string;
322
- /**
323
- * The name of the agent
324
- */
325
- name?: string;
326
336
  /**
327
337
  * A description of the role of the agent
328
338
  */
@@ -333,7 +343,7 @@ declare function createAgent<const TContextSchema extends ZodContextMapping, con
333
343
  */
334
344
  events: TEventSchemas;
335
345
  context?: TContextSchema;
336
- planner?: AgentPlanner<Agent<TContextSchema, TEventSchemas>>;
346
+ strategy?: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
337
347
  stringify?: typeof JSON.stringify;
338
348
  /**
339
349
  * A function that retrieves the agent's long term memory
@@ -343,7 +353,9 @@ declare function createAgent<const TContextSchema extends ZodContextMapping, con
343
353
  * Agent logic
344
354
  */
345
355
  logic?: AgentLogic<TEvents>;
346
- } & GenerateTextOptions): Agent<TContextSchema, TEventSchemas>;
356
+ model: LanguageModel;
357
+ episodeId?: string;
358
+ }): Agent<TContextSchema, TEventSchemas>;
347
359
  declare class Agent<const TContextSchema extends ZodContextMapping, const TEventSchemas extends ZodEventMapping, TEvents extends EventObject = EventsFromZodEventMapping<TEventSchemas>, TContext = ContextFromZodContextMapping<TContextSchema>> extends Actor<AgentLogic<TEvents>> {
348
360
  /**
349
361
  * The name of the agent. All agents with the same name are related and
@@ -357,15 +369,11 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
357
369
  description?: string;
358
370
  events: TEventSchemas;
359
371
  context?: TContextSchema;
360
- planner?: AgentPlanner<Agent<TContextSchema, TEventSchemas>>;
361
- types: {
362
- events: TEvents;
363
- context: Compute<TContext>;
364
- };
372
+ strategy: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
365
373
  model: LanguageModel;
366
374
  memory: AgentLongTermMemory | undefined;
367
- defaultOptions: any;
368
- constructor({ logic, id, name, description, model, events, context, planner, }: {
375
+ defaultOptions: AgentDecideOptions<AnyAgent> | undefined;
376
+ constructor({ logic, id, name, description, model, events, context, episodeId, strategy, }: {
369
377
  logic: AgentLogic<TEvents>;
370
378
  id?: string;
371
379
  name?: string;
@@ -373,12 +381,17 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
373
381
  model: GenerateTextOptions['model'];
374
382
  events: TEventSchemas;
375
383
  context?: TContextSchema;
376
- planner?: AgentPlanner<Agent<TContextSchema, TEventSchemas>>;
384
+ strategy?: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
385
+ episodeId?: string;
377
386
  });
378
387
  /**
379
388
  * Called whenever the agent (LLM assistant) receives or sends a message.
380
389
  */
381
390
  onMessage(fn: (message: AgentMessage) => void): Subscription;
391
+ /**
392
+ * Called whenever the agent (LLM assistant) receives some feedback.
393
+ */
394
+ onFeedback(fn: (feedback: AgentFeedback) => void): Subscription;
382
395
  /**
383
396
  * Retrieves messages from the agent's short-term (local) memory.
384
397
  */
@@ -390,8 +403,6 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
390
403
  content: ai.AssistantContent;
391
404
  experimental_providerMetadata?: ai.ProviderMetadata;
392
405
  responseId?: string;
393
- correlationId?: string;
394
- parentCorrelationId?: string;
395
406
  result?: ai.GenerateTextResult<any>;
396
407
  } | {
397
408
  id: string;
@@ -401,8 +412,6 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
401
412
  content: ai.ToolContent;
402
413
  experimental_providerMetadata?: ai.ProviderMetadata;
403
414
  responseId?: string;
404
- correlationId?: string;
405
- parentCorrelationId?: string;
406
415
  result?: ai.GenerateTextResult<any>;
407
416
  } | {
408
417
  id: string;
@@ -412,8 +421,6 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
412
421
  content: string;
413
422
  experimental_providerMetadata?: ai.ProviderMetadata;
414
423
  responseId?: string;
415
- correlationId?: string;
416
- parentCorrelationId?: string;
417
424
  result?: ai.GenerateTextResult<any>;
418
425
  } | {
419
426
  id: string;
@@ -423,8 +430,6 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
423
430
  content: ai.UserContent;
424
431
  experimental_providerMetadata?: ai.ProviderMetadata;
425
432
  responseId?: string;
426
- correlationId?: string;
427
- parentCorrelationId?: string;
428
433
  result?: ai.GenerateTextResult<any>;
429
434
  };
430
435
  getMessages(): AgentMessage[];
@@ -432,12 +437,10 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
432
437
  attributes: {
433
438
  [x: string]: any;
434
439
  };
435
- reward: number;
436
440
  timestamp: number;
437
441
  episodeId: string;
438
- goal?: string;
439
- observationId?: string;
440
- correlationId?: string;
442
+ goal: string;
443
+ observationId: string;
441
444
  };
442
445
  /**
443
446
  * Retrieves feedback from the agent's short-term (local) memory.
@@ -448,11 +451,11 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
448
451
  * Retrieves observations from the agent's short-term (local) memory.
449
452
  */
450
453
  getObservations(): AgentObservation<any>[];
451
- addPlan(plan: AgentPlan<TEvents>): void;
454
+ addDecision(decision: AgentDecision<TEvents>): void;
452
455
  /**
453
456
  * Retrieves strategies from the agent's short-term (local) memory.
454
457
  */
455
- getPlans(): AgentPlan<any>[];
458
+ getDecisions(): AgentDecision<any>[];
456
459
  /**
457
460
  * Interacts with this state machine actor by inspecting state transitions and storing them as observations.
458
461
  *
@@ -497,18 +500,18 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
497
500
  * actor.start();
498
501
  * ```
499
502
  */
500
- interact<TActor extends ActorRefLike>(actorRef: TActor, getInput: (observation: AgentObservation<TActor>) => AgentDecisionInput | undefined): Subscription;
503
+ interact<TActor extends ActorRefLike>(actorRef: TActor, getInput: (observation: AgentObservation<TActor>) => AgentInteractInput<this> | void): Subscription;
501
504
  observe<TActor extends ActorRefLike>(actorRef: TActor): Subscription;
502
505
  wrap(modelToWrap: LanguageModelV1): LanguageModelV1;
503
506
  /**
504
- * Resolves with an `AgentPlan` based on the information provided in the `options`, including:
507
+ * Resolves with an `AgentDecision` based on the information provided in the `options`, including:
505
508
  *
506
509
  * - The `goal` for the agent to achieve
507
510
  * - The observed current `state`
508
511
  * - The `machine` (e.g. a state machine) that specifies what can happen next
509
512
  * - Additional `context`
510
513
  */
511
- decide(opts: AgentDecideOptions): Promise<AgentPlan<EventsFromZodEventMapping<this["events"]>> | undefined>;
514
+ decide(opts: AgentDecideOptions<this>): Promise<AgentDecision<EventsFromAgent<this>> | undefined>;
512
515
  }
513
516
 
514
517
  declare function fromTextStream<T extends AnyAgent>(agent: T, options?: AgentStreamTextOptions): ObservableActorLogic<{
@@ -520,6 +523,6 @@ declare function fromText<T extends AnyAgent>(agent: T, options?: AgentGenerateT
520
523
  context?: AgentGenerateTextOptions['context'];
521
524
  }>;
522
525
 
523
- declare function fromDecision(agent: AnyAgent, defaultInput?: AgentDecisionInput): AgentDecisionLogic<any>;
526
+ declare function fromDecision<T extends AnyAgent>(agent: T, defaultInput?: AgentDecideInput<EventsFromAgent<T>>): AgentDecisionLogic<any>;
524
527
 
525
- export { type AgentDecideOptions, type AgentDecisionInput, type AgentDecisionLogic, type AgentEmitted, type AgentFeedback, type AgentFeedbackInput, type AgentGenerateTextOptions, type AgentLogic, type AgentLongTermMemory, type AgentMemoryContext, type AgentMessage, type AgentMessageInput, type AgentObservation, type AgentObservationInput, type AgentPath, type AgentPlan, type AgentPlanInput, type AgentPlanner, type AgentStep, type AgentStreamTextOptions, type AnyAgent, type CommonTextOptions, type Compute, type ContextFromZodContextMapping, type CostFunction, type EventsFromZodEventMapping, type FromAgent, type GenerateTextOptions, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type ObservedState, type ObservedStateFrom, type PromptTemplate, type StreamTextOptions, type TransitionData, createAgent, fromDecision, fromText, fromTextStream };
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 };