@statelyai/agent 2.0.0-next.3 → 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.
@@ -0,0 +1,10 @@
1
+ ---
2
+ '@statelyai/agent': major
3
+ ---
4
+
5
+ - The `machine` and `machineHash` properties were removed from `AgentObservation` and `AgentObservationInput`
6
+ - The `defaultOptions` property was removed from `Agent`
7
+ - `AgentDecideOptions` was renamed to `AgentDecideInput`
8
+ - The `execute` property was removed from `AgentDecideInput`
9
+ - The `episodeId` optional property was added to `AgentDecideInput`, `AgentObservationInput`, and `AgentFeedbackInput`
10
+ - `decisionId` was added to `AgentObservationInput` and `AgentFeedbackInput`
@@ -9,6 +9,7 @@
9
9
  "fast-donkeys-argue",
10
10
  "grumpy-dolphins-think",
11
11
  "light-hats-drive",
12
+ "nice-pants-rule",
12
13
  "old-jobs-check",
13
14
  "old-teachers-tap",
14
15
  "pink-eagles-deliver",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @statelyai/agent
2
2
 
3
+ ## 2.0.0-next.4
4
+
5
+ ### Major Changes
6
+
7
+ - [`4a79bac`](https://github.com/statelyai/agent/commit/4a79bacbda33340b34a4b6271c2bd0fa2673ce25) Thanks [@davidkpiano](https://github.com/davidkpiano)! - - The `machine` and `machineHash` properties were removed from `AgentObservation` and `AgentObservationInput`
8
+ - The `defaultOptions` property was removed from `Agent`
9
+ - `AgentDecideOptions` was renamed to `AgentDecideInput`
10
+ - The `execute` property was removed from `AgentDecideInput`
11
+ - The `episodeId` optional property was added to `AgentDecideInput`, `AgentObservationInput`, and `AgentFeedbackInput`
12
+ - `decisionId` was added to `AgentObservationInput` and `AgentFeedbackInput`
13
+
3
14
  ## 2.0.0-next.3
4
15
 
5
16
  ### Major Changes
@@ -0,0 +1,175 @@
1
+ {
2
+ "tldrawFileFormatVersion": 1,
3
+ "schema": {
4
+ "schemaVersion": 2,
5
+ "sequences": {
6
+ "com.tldraw.store": 4,
7
+ "com.tldraw.asset": 1,
8
+ "com.tldraw.camera": 1,
9
+ "com.tldraw.document": 2,
10
+ "com.tldraw.instance": 25,
11
+ "com.tldraw.instance_page_state": 5,
12
+ "com.tldraw.page": 1,
13
+ "com.tldraw.instance_presence": 5,
14
+ "com.tldraw.pointer": 1,
15
+ "com.tldraw.shape": 4,
16
+ "com.tldraw.asset.bookmark": 2,
17
+ "com.tldraw.asset.image": 5,
18
+ "com.tldraw.asset.video": 5,
19
+ "com.tldraw.shape.group": 0,
20
+ "com.tldraw.shape.text": 2,
21
+ "com.tldraw.shape.bookmark": 2,
22
+ "com.tldraw.shape.draw": 2,
23
+ "com.tldraw.shape.geo": 9,
24
+ "com.tldraw.shape.note": 8,
25
+ "com.tldraw.shape.line": 5,
26
+ "com.tldraw.shape.frame": 0,
27
+ "com.tldraw.shape.arrow": 5,
28
+ "com.tldraw.shape.highlight": 1,
29
+ "com.tldraw.shape.embed": 4,
30
+ "com.tldraw.shape.image": 4,
31
+ "com.tldraw.shape.video": 2,
32
+ "com.tldraw.binding.arrow": 0
33
+ }
34
+ },
35
+ "records": [
36
+ {
37
+ "gridSize": 10,
38
+ "name": "",
39
+ "meta": {},
40
+ "id": "document:document",
41
+ "typeName": "document"
42
+ },
43
+ {
44
+ "meta": {},
45
+ "id": "page:page",
46
+ "name": "Page 1",
47
+ "index": "a1",
48
+ "typeName": "page"
49
+ },
50
+ {
51
+ "id": "pointer:pointer",
52
+ "typeName": "pointer",
53
+ "x": 369.44140625,
54
+ "y": 256.55078125,
55
+ "lastActivityTimestamp": 1732900622027,
56
+ "meta": {}
57
+ },
58
+ {
59
+ "followingUserId": null,
60
+ "opacityForNextShape": 1,
61
+ "stylesForNextShape": {
62
+ "tldraw:size": "s"
63
+ },
64
+ "brush": null,
65
+ "scribbles": [],
66
+ "cursor": {
67
+ "type": "default",
68
+ "rotation": 0
69
+ },
70
+ "isFocusMode": false,
71
+ "exportBackground": true,
72
+ "isDebugMode": false,
73
+ "isToolLocked": false,
74
+ "screenBounds": {
75
+ "x": 0,
76
+ "y": 0,
77
+ "w": 1361,
78
+ "h": 684
79
+ },
80
+ "insets": [
81
+ false,
82
+ false,
83
+ true,
84
+ false
85
+ ],
86
+ "zoomBrush": null,
87
+ "isGridMode": false,
88
+ "isPenMode": false,
89
+ "chatMessage": "",
90
+ "isChatting": false,
91
+ "highlightedUserIds": [],
92
+ "isFocused": true,
93
+ "devicePixelRatio": 2,
94
+ "isCoarsePointer": false,
95
+ "isHoveringCanvas": true,
96
+ "openMenus": [],
97
+ "isChangingStyle": false,
98
+ "isReadonly": false,
99
+ "meta": {},
100
+ "duplicateProps": null,
101
+ "id": "instance:instance",
102
+ "currentPageId": "page:page",
103
+ "typeName": "instance"
104
+ },
105
+ {
106
+ "editingShapeId": null,
107
+ "croppingShapeId": null,
108
+ "selectedShapeIds": [
109
+ "shape:iFECnSIn2r2wJYVAgyVIm"
110
+ ],
111
+ "hoveredShapeId": "shape:iFECnSIn2r2wJYVAgyVIm",
112
+ "erasingShapeIds": [],
113
+ "hintingShapeIds": [],
114
+ "focusedGroupId": null,
115
+ "meta": {},
116
+ "id": "instance_page_state:page:page",
117
+ "pageId": "page:page",
118
+ "typeName": "instance_page_state"
119
+ },
120
+ {
121
+ "x": 0,
122
+ "y": 0,
123
+ "z": 1,
124
+ "meta": {},
125
+ "id": "camera:page:page",
126
+ "typeName": "camera"
127
+ },
128
+ {
129
+ "x": 326.71875,
130
+ "y": 152.83984375,
131
+ "rotation": 0,
132
+ "isLocked": false,
133
+ "opacity": 1,
134
+ "meta": {},
135
+ "id": "shape:Az6bLzi8VaAX36Icv2AmG",
136
+ "type": "text",
137
+ "props": {
138
+ "color": "black",
139
+ "size": "m",
140
+ "w": 81.3828125,
141
+ "text": "decide",
142
+ "font": "draw",
143
+ "textAlign": "start",
144
+ "autoSize": true,
145
+ "scale": 1
146
+ },
147
+ "parentId": "page:page",
148
+ "index": "a1",
149
+ "typeName": "shape"
150
+ },
151
+ {
152
+ "x": 338.31640625,
153
+ "y": 193.2578125,
154
+ "rotation": 0,
155
+ "isLocked": false,
156
+ "opacity": 1,
157
+ "meta": {},
158
+ "id": "shape:iFECnSIn2r2wJYVAgyVIm",
159
+ "type": "text",
160
+ "props": {
161
+ "color": "black",
162
+ "size": "s",
163
+ "w": 93.2890625,
164
+ "text": "episodeId\nstate\ngoal\ncontext",
165
+ "font": "draw",
166
+ "textAlign": "start",
167
+ "autoSize": true,
168
+ "scale": 1
169
+ },
170
+ "parentId": "page:page",
171
+ "index": "a290f",
172
+ "typeName": "shape"
173
+ }
174
+ ]
175
+ }
package/dist/index.d.mts 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 { AnyStateMachine, AnyEventObject, ActorRefLike, SnapshotFrom, EventFrom, PromiseActorLogic, ActorLogic, TransitionSnapshot, Values, StateValue, EventObject, 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 = {
@@ -13,7 +13,8 @@ type ZodContextMapping = {
13
13
  type GenerateTextOptions = Parameters<typeof generateText>[0];
14
14
  type StreamTextOptions = Parameters<typeof streamText>[0];
15
15
  type CostFunction<TAgent extends AnyAgent> = (path: AgentPath<TAgent>) => number;
16
- type AgentDecideInput<TAgent extends AnyAgent> = Omit<AgentGenerateTextOptions<TAgent>, 'prompt' | 'tools'> & {
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
  */
@@ -31,7 +32,8 @@ type AgentDecideInput<TAgent extends AnyAgent> = Omit<AgentGenerateTextOptions<T
31
32
  * The events that the agent can trigger. This is a mapping of
32
33
  * event types to Zod event schemas.
33
34
  */
34
- events: ZodEventMapping;
35
+ events?: ZodEventMapping;
36
+ allowedEvents?: Array<EventFromAgent<TAgent>['type']>;
35
37
  /**
36
38
  * The state machine that represents the environment the agent
37
39
  * is interacting with.
@@ -46,6 +48,8 @@ type AgentDecideInput<TAgent extends AnyAgent> = Omit<AgentGenerateTextOptions<T
46
48
  * Defaults to 2.
47
49
  */
48
50
  maxAttempts?: number;
51
+ strategy?: AgentStrategy<TAgent>;
52
+ model?: LanguageModel;
49
53
  };
50
54
  type AgentStep<TAgent extends AnyAgent> = {
51
55
  /** The event to take */
@@ -117,46 +121,35 @@ type PromptTemplate<TAgent extends AnyAgent> = (data: {
117
121
  decisions?: AgentDecision<TAgent>[];
118
122
  }) => string;
119
123
  type AgentStrategy<TAgent extends AnyAgent> = (agent: TAgent, input: AgentDecideInput<EventFromAgent<TAgent>>) => Promise<AgentDecision<TAgent> | undefined>;
120
- type AgentInteractInput<T extends AnyAgent> = Omit<AgentDecideOptions<T>, 'state'> & {
124
+ type AgentInteractInput<T extends AnyAgent> = Omit<AgentDecideInput<T>, 'state'> & {
121
125
  state?: never;
122
126
  };
123
- type AgentDecideOptions<TAgent extends AnyAgent> = {
124
- goal: string;
125
- state: ObservedState<TAgent>;
126
- /**
127
- * The context to provide in the prompt to the agent. This overrides the `state.context`.
128
- */
129
- context?: Record<string, any>;
130
- machine?: AnyStateMachine;
131
- model?: LanguageModel;
132
- execute?: (event: AnyEventObject) => Promise<void>;
133
- strategy?: AgentStrategy<TAgent>;
134
- events?: ZodEventMapping;
135
- allowedEvents?: Array<EventFromAgent<TAgent>['type']>;
136
- /**
137
- * The maximum number of times the agent will attempt to make a decision.
138
- * Defaults to 2.
139
- */
140
- maxAttempts?: number;
141
- } & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;
142
- interface AgentFeedback {
143
- observationId: string;
127
+ type AgentFeedback = {
144
128
  score: number;
145
129
  comment: string | undefined;
146
- /**
147
- * The message correlation that the feedback is relevant for
148
- */
149
130
  attributes: Record<string, any>;
150
131
  timestamp: number;
151
132
  episodeId: string;
152
- }
153
- interface AgentFeedbackInput {
133
+ } & ({
154
134
  observationId: string;
135
+ decisionId?: never;
136
+ } | {
137
+ decisionId: string;
138
+ observationId?: never;
139
+ });
140
+ type AgentFeedbackInput = {
141
+ episodeId?: string;
155
142
  score: number;
156
143
  comment?: string;
157
144
  attributes?: Record<string, any>;
158
145
  timestamp?: number;
159
- }
146
+ } & ({
147
+ observationId: string;
148
+ decisionId?: never;
149
+ } | {
150
+ decisionId: string;
151
+ observationId?: never;
152
+ });
160
153
  type AgentMessage = CoreMessage & {
161
154
  timestamp: number;
162
155
  id: string;
@@ -220,22 +213,26 @@ type AgentMessageInput = CoreMessage & {
220
213
  };
221
214
  interface AgentObservation<TActor extends ActorRefLike> {
222
215
  id: string;
216
+ decisionId?: string | undefined;
223
217
  goal?: string;
224
218
  prevState: SnapshotFrom<TActor> | undefined;
225
219
  event: EventFrom<TActor> | undefined;
226
220
  state: SnapshotFrom<TActor>;
227
- machineHash: string | undefined;
228
221
  episodeId: string;
229
222
  timestamp: number;
230
223
  }
231
224
  interface AgentObservationInput<TAgent extends AnyAgent> {
232
225
  id?: string;
226
+ episodeId?: string;
227
+ /**
228
+ * The agent decision that the observation is relevant for
229
+ */
230
+ decisionId?: string | undefined;
233
231
  prevState?: ObservedState<TAgent>;
234
232
  event?: AnyEventObject;
235
233
  state: ObservedState<TAgent>;
236
- machine?: AnyStateMachine;
237
234
  timestamp?: number;
238
- goal: string | undefined;
235
+ goal?: string | undefined;
239
236
  }
240
237
  type AgentDecisionInput = {
241
238
  goal: string;
@@ -378,7 +375,6 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
378
375
  strategy: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
379
376
  model: LanguageModel;
380
377
  memory: AgentLongTermMemory<this> | undefined;
381
- defaultOptions: AgentDecideOptions<AnyAgent> | undefined;
382
378
  constructor({ logic, id, name, description, model, events, context, episodeId, strategy, }: {
383
379
  logic: AgentLogic<any>;
384
380
  id?: string;
@@ -446,8 +442,19 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
446
442
  };
447
443
  timestamp: number;
448
444
  episodeId: string;
445
+ score: number;
449
446
  observationId: string;
447
+ decisionId?: never;
448
+ } | {
449
+ comment: string | undefined;
450
+ attributes: {
451
+ [x: string]: any;
452
+ };
453
+ timestamp: number;
454
+ episodeId: string;
450
455
  score: number;
456
+ decisionId: string;
457
+ observationId?: never;
451
458
  };
452
459
  /**
453
460
  * Retrieves feedback from the agent's short-term (local) memory.
@@ -518,7 +525,7 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
518
525
  * - The `machine` (e.g. a state machine) that specifies what can happen next
519
526
  * - Additional `context`
520
527
  */
521
- decide(opts: AgentDecideOptions<this>): Promise<AgentDecision<this> | undefined>;
528
+ decide(input: AgentDecideInput<this>): Promise<AgentDecision<this> | undefined>;
522
529
  }
523
530
 
524
531
  declare function fromTextStream<TAgent extends AnyAgent>(agent: TAgent, options?: AgentStreamTextOptions<TAgent>): ObservableActorLogic<{
@@ -532,4 +539,4 @@ declare function fromText<TAgent extends AnyAgent>(agent: TAgent, options?: Agen
532
539
 
533
540
  declare function fromDecision<T extends AnyAgent>(agent: T, defaultInput?: AgentDecideInput<EventFromAgent<T>>): AgentDecisionLogic<any>;
534
541
 
535
- 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 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 };
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 };
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 { AnyStateMachine, AnyEventObject, ActorRefLike, SnapshotFrom, EventFrom, PromiseActorLogic, ActorLogic, TransitionSnapshot, Values, StateValue, EventObject, 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 = {
@@ -13,7 +13,8 @@ type ZodContextMapping = {
13
13
  type GenerateTextOptions = Parameters<typeof generateText>[0];
14
14
  type StreamTextOptions = Parameters<typeof streamText>[0];
15
15
  type CostFunction<TAgent extends AnyAgent> = (path: AgentPath<TAgent>) => number;
16
- type AgentDecideInput<TAgent extends AnyAgent> = Omit<AgentGenerateTextOptions<TAgent>, 'prompt' | 'tools'> & {
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
  */
@@ -31,7 +32,8 @@ type AgentDecideInput<TAgent extends AnyAgent> = Omit<AgentGenerateTextOptions<T
31
32
  * The events that the agent can trigger. This is a mapping of
32
33
  * event types to Zod event schemas.
33
34
  */
34
- events: ZodEventMapping;
35
+ events?: ZodEventMapping;
36
+ allowedEvents?: Array<EventFromAgent<TAgent>['type']>;
35
37
  /**
36
38
  * The state machine that represents the environment the agent
37
39
  * is interacting with.
@@ -46,6 +48,8 @@ type AgentDecideInput<TAgent extends AnyAgent> = Omit<AgentGenerateTextOptions<T
46
48
  * Defaults to 2.
47
49
  */
48
50
  maxAttempts?: number;
51
+ strategy?: AgentStrategy<TAgent>;
52
+ model?: LanguageModel;
49
53
  };
50
54
  type AgentStep<TAgent extends AnyAgent> = {
51
55
  /** The event to take */
@@ -117,46 +121,35 @@ type PromptTemplate<TAgent extends AnyAgent> = (data: {
117
121
  decisions?: AgentDecision<TAgent>[];
118
122
  }) => string;
119
123
  type AgentStrategy<TAgent extends AnyAgent> = (agent: TAgent, input: AgentDecideInput<EventFromAgent<TAgent>>) => Promise<AgentDecision<TAgent> | undefined>;
120
- type AgentInteractInput<T extends AnyAgent> = Omit<AgentDecideOptions<T>, 'state'> & {
124
+ type AgentInteractInput<T extends AnyAgent> = Omit<AgentDecideInput<T>, 'state'> & {
121
125
  state?: never;
122
126
  };
123
- type AgentDecideOptions<TAgent extends AnyAgent> = {
124
- goal: string;
125
- state: ObservedState<TAgent>;
126
- /**
127
- * The context to provide in the prompt to the agent. This overrides the `state.context`.
128
- */
129
- context?: Record<string, any>;
130
- machine?: AnyStateMachine;
131
- model?: LanguageModel;
132
- execute?: (event: AnyEventObject) => Promise<void>;
133
- strategy?: AgentStrategy<TAgent>;
134
- events?: ZodEventMapping;
135
- allowedEvents?: Array<EventFromAgent<TAgent>['type']>;
136
- /**
137
- * The maximum number of times the agent will attempt to make a decision.
138
- * Defaults to 2.
139
- */
140
- maxAttempts?: number;
141
- } & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;
142
- interface AgentFeedback {
143
- observationId: string;
127
+ type AgentFeedback = {
144
128
  score: number;
145
129
  comment: string | undefined;
146
- /**
147
- * The message correlation that the feedback is relevant for
148
- */
149
130
  attributes: Record<string, any>;
150
131
  timestamp: number;
151
132
  episodeId: string;
152
- }
153
- interface AgentFeedbackInput {
133
+ } & ({
154
134
  observationId: string;
135
+ decisionId?: never;
136
+ } | {
137
+ decisionId: string;
138
+ observationId?: never;
139
+ });
140
+ type AgentFeedbackInput = {
141
+ episodeId?: string;
155
142
  score: number;
156
143
  comment?: string;
157
144
  attributes?: Record<string, any>;
158
145
  timestamp?: number;
159
- }
146
+ } & ({
147
+ observationId: string;
148
+ decisionId?: never;
149
+ } | {
150
+ decisionId: string;
151
+ observationId?: never;
152
+ });
160
153
  type AgentMessage = CoreMessage & {
161
154
  timestamp: number;
162
155
  id: string;
@@ -220,22 +213,26 @@ type AgentMessageInput = CoreMessage & {
220
213
  };
221
214
  interface AgentObservation<TActor extends ActorRefLike> {
222
215
  id: string;
216
+ decisionId?: string | undefined;
223
217
  goal?: string;
224
218
  prevState: SnapshotFrom<TActor> | undefined;
225
219
  event: EventFrom<TActor> | undefined;
226
220
  state: SnapshotFrom<TActor>;
227
- machineHash: string | undefined;
228
221
  episodeId: string;
229
222
  timestamp: number;
230
223
  }
231
224
  interface AgentObservationInput<TAgent extends AnyAgent> {
232
225
  id?: string;
226
+ episodeId?: string;
227
+ /**
228
+ * The agent decision that the observation is relevant for
229
+ */
230
+ decisionId?: string | undefined;
233
231
  prevState?: ObservedState<TAgent>;
234
232
  event?: AnyEventObject;
235
233
  state: ObservedState<TAgent>;
236
- machine?: AnyStateMachine;
237
234
  timestamp?: number;
238
- goal: string | undefined;
235
+ goal?: string | undefined;
239
236
  }
240
237
  type AgentDecisionInput = {
241
238
  goal: string;
@@ -378,7 +375,6 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
378
375
  strategy: AgentStrategy<Agent<TContextSchema, TEventSchemas>>;
379
376
  model: LanguageModel;
380
377
  memory: AgentLongTermMemory<this> | undefined;
381
- defaultOptions: AgentDecideOptions<AnyAgent> | undefined;
382
378
  constructor({ logic, id, name, description, model, events, context, episodeId, strategy, }: {
383
379
  logic: AgentLogic<any>;
384
380
  id?: string;
@@ -446,8 +442,19 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
446
442
  };
447
443
  timestamp: number;
448
444
  episodeId: string;
445
+ score: number;
449
446
  observationId: string;
447
+ decisionId?: never;
448
+ } | {
449
+ comment: string | undefined;
450
+ attributes: {
451
+ [x: string]: any;
452
+ };
453
+ timestamp: number;
454
+ episodeId: string;
450
455
  score: number;
456
+ decisionId: string;
457
+ observationId?: never;
451
458
  };
452
459
  /**
453
460
  * Retrieves feedback from the agent's short-term (local) memory.
@@ -518,7 +525,7 @@ declare class Agent<const TContextSchema extends ZodContextMapping, const TEvent
518
525
  * - The `machine` (e.g. a state machine) that specifies what can happen next
519
526
  * - Additional `context`
520
527
  */
521
- decide(opts: AgentDecideOptions<this>): Promise<AgentDecision<this> | undefined>;
528
+ decide(input: AgentDecideInput<this>): Promise<AgentDecision<this> | undefined>;
522
529
  }
523
530
 
524
531
  declare function fromTextStream<TAgent extends AnyAgent>(agent: TAgent, options?: AgentStreamTextOptions<TAgent>): ObservableActorLogic<{
@@ -532,4 +539,4 @@ declare function fromText<TAgent extends AnyAgent>(agent: TAgent, options?: Agen
532
539
 
533
540
  declare function fromDecision<T extends AnyAgent>(agent: T, defaultInput?: AgentDecideInput<EventFromAgent<T>>): AgentDecisionLogic<any>;
534
541
 
535
- 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 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 };
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 };