@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
@@ -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`
@@ -0,0 +1,13 @@
1
+ ---
2
+ '@statelyai/agent': patch
3
+ ---
4
+
5
+ The `score` is now required for feedback:
6
+
7
+ ```ts
8
+ agent.addFeedback({
9
+ score: 0.5,
10
+ goal: 'Win the game',
11
+ observationId: '...',
12
+ });
13
+ ```
@@ -9,8 +9,14 @@
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
- "smart-yaks-pull"
15
+ "pink-eagles-deliver",
16
+ "quiet-turtles-do",
17
+ "smart-yaks-pull",
18
+ "sweet-clouds-mix",
19
+ "swift-mangos-rush",
20
+ "tough-ways-rhyme"
15
21
  ]
16
22
  }
@@ -0,0 +1,7 @@
1
+ ---
2
+ '@statelyai/agent': major
3
+ ---
4
+
5
+ The `state` can no longer be specified in `agent.interact(...)`, since the actual state value is already observed and passed to the `strategy` function.
6
+
7
+ The `context` provided to agent decision functions, like `agent.decide({ context })` and in `agent.interact(...)`, is now used solely to override the `state.context` provided to the prompt template.
@@ -0,0 +1,16 @@
1
+ ---
2
+ '@statelyai/agent': patch
3
+ ---
4
+
5
+ The entire observed `state` must be provided, instead of only `context`, for any agent decision making functions:
6
+
7
+ ```ts
8
+ agent.interact(actor, (obs) => {
9
+ // ...
10
+ return {
11
+ goal: 'Some goal',
12
+ // instead of context
13
+ state: obs.state,
14
+ };
15
+ });
16
+ ```
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@statelyai/agent": patch
3
+ ---
4
+
5
+ Remove `goal` from feedback input
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@statelyai/agent": minor
3
+ ---
4
+
5
+ Add `score` and `comment` fields for feedback
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
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
+
14
+ ## 2.0.0-next.3
15
+
16
+ ### Major Changes
17
+
18
+ - [`bf6b468`](https://github.com/statelyai/agent/commit/bf6b468d66d58bf53629d70d1b2a273948c9ba1e) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The `state` can no longer be specified in `agent.interact(...)`, since the actual state value is already observed and passed to the `strategy` function.
19
+
20
+ The `context` provided to agent decision functions, like `agent.decide({ context })` and in `agent.interact(...)`, is now used solely to override the `state.context` provided to the prompt template.
21
+
22
+ ### Minor Changes
23
+
24
+ - [`1287a6d`](https://github.com/statelyai/agent/commit/1287a6d405ed3bd6be37a61aaa9d54d963b5b1cd) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Add `score` and `comment` fields for feedback
25
+
26
+ ### Patch Changes
27
+
28
+ - [`5b5a8e7`](https://github.com/statelyai/agent/commit/5b5a8e7012d550f5b05d0fefc9eade7731202577) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The `score` is now required for feedback:
29
+
30
+ ```ts
31
+ agent.addFeedback({
32
+ score: 0.5,
33
+ goal: "Win the game",
34
+ observationId: "...",
35
+ });
36
+ ```
37
+
38
+ - [`5b5a8e7`](https://github.com/statelyai/agent/commit/5b5a8e7012d550f5b05d0fefc9eade7731202577) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The entire observed `state` must be provided, instead of only `context`, for any agent decision making functions:
39
+
40
+ ```ts
41
+ agent.interact(actor, (obs) => {
42
+ // ...
43
+ return {
44
+ goal: "Some goal",
45
+ // instead of context
46
+ state: obs.state,
47
+ };
48
+ });
49
+ ```
50
+
51
+ - [`9d65d71`](https://github.com/statelyai/agent/commit/9d65d71e41f9f0f84f637ea7e0a0e22ccf67f264) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Remove `goal` from feedback input
52
+
3
53
  ## 2.0.0-next.2
4
54
 
5
55
  ### Minor 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
+ }