@cloudbase/agent-examples-langgraph-human-in-the-loop 0.0.2 → 0.0.6
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/CHANGELOG.md +70 -0
- package/dist/index.d.mts +40 -40
- package/dist/index.d.ts +40 -40
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/agent.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# @cloudbase/agent-examples-langgraph-human-in-the-loop
|
|
2
2
|
|
|
3
|
+
## 0.0.11-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- alpha release 0.0.10-alpha.2
|
|
8
|
+
- Update all public packages to version 0.0.10-alpha.2
|
|
9
|
+
- Trigger automated alpha release workflow
|
|
10
|
+
- Includes latest features and improvements
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @cloudbase/agent-agents@0.0.11-alpha.3
|
|
14
|
+
- @cloudbase/agent-adapter-langgraph@0.0.11-alpha.3
|
|
15
|
+
|
|
16
|
+
## 0.0.11-alpha.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- alpha release 0.0.10-alpha.2
|
|
21
|
+
- Update all public packages to version 0.0.10-alpha.2
|
|
22
|
+
- Trigger automated alpha release workflow
|
|
23
|
+
- Includes latest features and improvements
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @cloudbase/agent-agents@0.0.11-alpha.2
|
|
27
|
+
- @cloudbase/agent-adapter-langgraph@0.0.11-alpha.2
|
|
28
|
+
|
|
29
|
+
## 0.0.11-alpha.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- alpha release 0.0.10-alpha.2
|
|
34
|
+
- Update all public packages to version 0.0.10-alpha.2
|
|
35
|
+
- Trigger automated alpha release workflow
|
|
36
|
+
- Includes latest features and improvements
|
|
37
|
+
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @cloudbase/agent-agents@0.0.11-alpha.1
|
|
40
|
+
- @cloudbase/agent-adapter-langgraph@0.0.11-alpha.1
|
|
41
|
+
|
|
42
|
+
## 0.0.11-alpha.0
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- 97b2740: alpha release 0.0.10-alpha.2
|
|
47
|
+
- Update all public packages to version 0.0.10-alpha.2
|
|
48
|
+
- Trigger automated alpha release workflow
|
|
49
|
+
- Includes latest features and improvements
|
|
50
|
+
|
|
51
|
+
- fd4c62a: alpha release 0.0.10-alpha.2
|
|
52
|
+
- Update all public packages to version 0.0.10-alpha.2
|
|
53
|
+
- Trigger automated alpha release workflow
|
|
54
|
+
- Includes latest features and improvements
|
|
55
|
+
|
|
56
|
+
- da3388c: alpha release 0.0.10-alpha.2
|
|
57
|
+
- Update all public packages to version 0.0.10-alpha.2
|
|
58
|
+
- Trigger automated alpha release workflow
|
|
59
|
+
- Includes latest features and improvements
|
|
60
|
+
|
|
61
|
+
- alpha release 0.0.10-alpha.2
|
|
62
|
+
- Update all public packages to version 0.0.10-alpha.2
|
|
63
|
+
- Trigger automated alpha release workflow
|
|
64
|
+
- Includes latest features and improvements
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [97b2740]
|
|
67
|
+
- Updated dependencies [fd4c62a]
|
|
68
|
+
- Updated dependencies [da3388c]
|
|
69
|
+
- Updated dependencies
|
|
70
|
+
- @cloudbase/agent-agents@0.0.11-alpha.0
|
|
71
|
+
- @cloudbase/agent-adapter-langgraph@0.0.11-alpha.0
|
|
72
|
+
|
|
3
73
|
## 0.0.10
|
|
4
74
|
|
|
5
75
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -6,34 +6,34 @@ import * as _langchain_core_messages from '@langchain/core/messages';
|
|
|
6
6
|
*/
|
|
7
7
|
declare const AgentStateAnnotation: _langchain_langgraph.AnnotationRoot<{
|
|
8
8
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
9
|
-
|
|
9
|
+
client: {
|
|
10
10
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
11
|
-
|
|
11
|
+
tools: {
|
|
12
12
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
13
13
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
14
14
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
15
15
|
};
|
|
16
16
|
}>>;
|
|
17
17
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
18
|
-
|
|
18
|
+
tools: {
|
|
19
19
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
20
20
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
21
21
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
22
22
|
};
|
|
23
23
|
}>, _langchain_langgraph.StateType<{
|
|
24
|
-
|
|
24
|
+
tools: {
|
|
25
25
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
26
26
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
27
27
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
28
28
|
};
|
|
29
29
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
30
|
-
|
|
30
|
+
tools: {
|
|
31
31
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
32
32
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
33
33
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
34
34
|
};
|
|
35
35
|
}>, _langchain_langgraph.StateType<{
|
|
36
|
-
|
|
36
|
+
tools: {
|
|
37
37
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
38
38
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
39
39
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -53,8 +53,8 @@ declare const AgentStateAnnotation: _langchain_langgraph.AnnotationRoot<{
|
|
|
53
53
|
type AgentState = typeof AgentStateAnnotation.State;
|
|
54
54
|
declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
55
55
|
messages: _langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[];
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
client: _langchain_langgraph.StateType<{
|
|
57
|
+
tools: {
|
|
58
58
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
59
59
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
60
60
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -67,8 +67,8 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
67
67
|
user_response: string | undefined;
|
|
68
68
|
}, {
|
|
69
69
|
messages?: _langchain_langgraph.Messages | undefined;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
client?: _langchain_langgraph.StateType<{
|
|
71
|
+
tools: {
|
|
72
72
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
73
73
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
74
74
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -81,34 +81,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
81
81
|
user_response?: string | undefined;
|
|
82
82
|
}, "chat_node" | "process_steps_node" | "__start__" | "start_flow", {
|
|
83
83
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
84
|
-
|
|
84
|
+
client: {
|
|
85
85
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
86
|
-
|
|
86
|
+
tools: {
|
|
87
87
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
88
88
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
89
89
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
90
90
|
};
|
|
91
91
|
}>>;
|
|
92
92
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
93
|
-
|
|
93
|
+
tools: {
|
|
94
94
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
95
95
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
96
96
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
97
97
|
};
|
|
98
98
|
}>, _langchain_langgraph.StateType<{
|
|
99
|
-
|
|
99
|
+
tools: {
|
|
100
100
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
101
101
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
102
102
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
103
103
|
};
|
|
104
104
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
105
|
-
|
|
105
|
+
tools: {
|
|
106
106
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
107
107
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
108
108
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
109
109
|
};
|
|
110
110
|
}>, _langchain_langgraph.StateType<{
|
|
111
|
-
|
|
111
|
+
tools: {
|
|
112
112
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
113
113
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
114
114
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -126,34 +126,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
126
126
|
user_response: _langchain_langgraph.BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
127
127
|
}, {
|
|
128
128
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
129
|
-
|
|
129
|
+
client: {
|
|
130
130
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
131
|
-
|
|
131
|
+
tools: {
|
|
132
132
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
133
133
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
134
134
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
135
135
|
};
|
|
136
136
|
}>>;
|
|
137
137
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
138
|
-
|
|
138
|
+
tools: {
|
|
139
139
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
140
140
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
141
141
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
142
142
|
};
|
|
143
143
|
}>, _langchain_langgraph.StateType<{
|
|
144
|
-
|
|
144
|
+
tools: {
|
|
145
145
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
146
146
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
147
147
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
148
148
|
};
|
|
149
149
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
150
|
-
|
|
150
|
+
tools: {
|
|
151
151
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
152
152
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
153
153
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
154
154
|
};
|
|
155
155
|
}>, _langchain_langgraph.StateType<{
|
|
156
|
-
|
|
156
|
+
tools: {
|
|
157
157
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
158
158
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
159
159
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -172,34 +172,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
172
172
|
}, _langchain_langgraph.StateDefinition, {
|
|
173
173
|
start_flow: _langchain_langgraph.UpdateType<{
|
|
174
174
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
175
|
-
|
|
175
|
+
client: {
|
|
176
176
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
177
|
-
|
|
177
|
+
tools: {
|
|
178
178
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
179
179
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
180
180
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
181
181
|
};
|
|
182
182
|
}>>;
|
|
183
183
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
184
|
-
|
|
184
|
+
tools: {
|
|
185
185
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
186
186
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
187
187
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
188
188
|
};
|
|
189
189
|
}>, _langchain_langgraph.StateType<{
|
|
190
|
-
|
|
190
|
+
tools: {
|
|
191
191
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
192
192
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
193
193
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
194
194
|
};
|
|
195
195
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
196
|
-
|
|
196
|
+
tools: {
|
|
197
197
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
198
198
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
199
199
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
200
200
|
};
|
|
201
201
|
}>, _langchain_langgraph.StateType<{
|
|
202
|
-
|
|
202
|
+
tools: {
|
|
203
203
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
204
204
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
205
205
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -218,34 +218,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
218
218
|
}>;
|
|
219
219
|
chat_node: _langchain_langgraph.UpdateType<{
|
|
220
220
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
221
|
-
|
|
221
|
+
client: {
|
|
222
222
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
223
|
-
|
|
223
|
+
tools: {
|
|
224
224
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
225
225
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
226
226
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
227
227
|
};
|
|
228
228
|
}>>;
|
|
229
229
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
230
|
-
|
|
230
|
+
tools: {
|
|
231
231
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
232
232
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
233
233
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
234
234
|
};
|
|
235
235
|
}>, _langchain_langgraph.StateType<{
|
|
236
|
-
|
|
236
|
+
tools: {
|
|
237
237
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
238
238
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
239
239
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
240
240
|
};
|
|
241
241
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
242
|
-
|
|
242
|
+
tools: {
|
|
243
243
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
244
244
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
245
245
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
246
246
|
};
|
|
247
247
|
}>, _langchain_langgraph.StateType<{
|
|
248
|
-
|
|
248
|
+
tools: {
|
|
249
249
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
250
250
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
251
251
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -264,34 +264,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
264
264
|
}>;
|
|
265
265
|
process_steps_node: _langchain_langgraph.UpdateType<{
|
|
266
266
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
267
|
-
|
|
267
|
+
client: {
|
|
268
268
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
269
|
-
|
|
269
|
+
tools: {
|
|
270
270
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
271
271
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
272
272
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
273
273
|
};
|
|
274
274
|
}>>;
|
|
275
275
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
276
|
-
|
|
276
|
+
tools: {
|
|
277
277
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
278
278
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
279
279
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
280
280
|
};
|
|
281
281
|
}>, _langchain_langgraph.StateType<{
|
|
282
|
-
|
|
282
|
+
tools: {
|
|
283
283
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
284
284
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
285
285
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
286
286
|
};
|
|
287
287
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
288
|
-
|
|
288
|
+
tools: {
|
|
289
289
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
290
290
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
291
291
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
292
292
|
};
|
|
293
293
|
}>, _langchain_langgraph.StateType<{
|
|
294
|
-
|
|
294
|
+
tools: {
|
|
295
295
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
296
296
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
297
297
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,34 +6,34 @@ import * as _langchain_core_messages from '@langchain/core/messages';
|
|
|
6
6
|
*/
|
|
7
7
|
declare const AgentStateAnnotation: _langchain_langgraph.AnnotationRoot<{
|
|
8
8
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
9
|
-
|
|
9
|
+
client: {
|
|
10
10
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
11
|
-
|
|
11
|
+
tools: {
|
|
12
12
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
13
13
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
14
14
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
15
15
|
};
|
|
16
16
|
}>>;
|
|
17
17
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
18
|
-
|
|
18
|
+
tools: {
|
|
19
19
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
20
20
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
21
21
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
22
22
|
};
|
|
23
23
|
}>, _langchain_langgraph.StateType<{
|
|
24
|
-
|
|
24
|
+
tools: {
|
|
25
25
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
26
26
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
27
27
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
28
28
|
};
|
|
29
29
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
30
|
-
|
|
30
|
+
tools: {
|
|
31
31
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
32
32
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
33
33
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
34
34
|
};
|
|
35
35
|
}>, _langchain_langgraph.StateType<{
|
|
36
|
-
|
|
36
|
+
tools: {
|
|
37
37
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
38
38
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
39
39
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -53,8 +53,8 @@ declare const AgentStateAnnotation: _langchain_langgraph.AnnotationRoot<{
|
|
|
53
53
|
type AgentState = typeof AgentStateAnnotation.State;
|
|
54
54
|
declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
55
55
|
messages: _langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[];
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
client: _langchain_langgraph.StateType<{
|
|
57
|
+
tools: {
|
|
58
58
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
59
59
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
60
60
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -67,8 +67,8 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
67
67
|
user_response: string | undefined;
|
|
68
68
|
}, {
|
|
69
69
|
messages?: _langchain_langgraph.Messages | undefined;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
client?: _langchain_langgraph.StateType<{
|
|
71
|
+
tools: {
|
|
72
72
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
73
73
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
74
74
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -81,34 +81,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
81
81
|
user_response?: string | undefined;
|
|
82
82
|
}, "chat_node" | "process_steps_node" | "__start__" | "start_flow", {
|
|
83
83
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
84
|
-
|
|
84
|
+
client: {
|
|
85
85
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
86
|
-
|
|
86
|
+
tools: {
|
|
87
87
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
88
88
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
89
89
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
90
90
|
};
|
|
91
91
|
}>>;
|
|
92
92
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
93
|
-
|
|
93
|
+
tools: {
|
|
94
94
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
95
95
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
96
96
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
97
97
|
};
|
|
98
98
|
}>, _langchain_langgraph.StateType<{
|
|
99
|
-
|
|
99
|
+
tools: {
|
|
100
100
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
101
101
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
102
102
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
103
103
|
};
|
|
104
104
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
105
|
-
|
|
105
|
+
tools: {
|
|
106
106
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
107
107
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
108
108
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
109
109
|
};
|
|
110
110
|
}>, _langchain_langgraph.StateType<{
|
|
111
|
-
|
|
111
|
+
tools: {
|
|
112
112
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
113
113
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
114
114
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -126,34 +126,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
126
126
|
user_response: _langchain_langgraph.BinaryOperatorAggregate<string | undefined, string | undefined>;
|
|
127
127
|
}, {
|
|
128
128
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
129
|
-
|
|
129
|
+
client: {
|
|
130
130
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
131
|
-
|
|
131
|
+
tools: {
|
|
132
132
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
133
133
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
134
134
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
135
135
|
};
|
|
136
136
|
}>>;
|
|
137
137
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
138
|
-
|
|
138
|
+
tools: {
|
|
139
139
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
140
140
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
141
141
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
142
142
|
};
|
|
143
143
|
}>, _langchain_langgraph.StateType<{
|
|
144
|
-
|
|
144
|
+
tools: {
|
|
145
145
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
146
146
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
147
147
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
148
148
|
};
|
|
149
149
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
150
|
-
|
|
150
|
+
tools: {
|
|
151
151
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
152
152
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
153
153
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
154
154
|
};
|
|
155
155
|
}>, _langchain_langgraph.StateType<{
|
|
156
|
-
|
|
156
|
+
tools: {
|
|
157
157
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
158
158
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
159
159
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -172,34 +172,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
172
172
|
}, _langchain_langgraph.StateDefinition, {
|
|
173
173
|
start_flow: _langchain_langgraph.UpdateType<{
|
|
174
174
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
175
|
-
|
|
175
|
+
client: {
|
|
176
176
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
177
|
-
|
|
177
|
+
tools: {
|
|
178
178
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
179
179
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
180
180
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
181
181
|
};
|
|
182
182
|
}>>;
|
|
183
183
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
184
|
-
|
|
184
|
+
tools: {
|
|
185
185
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
186
186
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
187
187
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
188
188
|
};
|
|
189
189
|
}>, _langchain_langgraph.StateType<{
|
|
190
|
-
|
|
190
|
+
tools: {
|
|
191
191
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
192
192
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
193
193
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
194
194
|
};
|
|
195
195
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
196
|
-
|
|
196
|
+
tools: {
|
|
197
197
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
198
198
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
199
199
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
200
200
|
};
|
|
201
201
|
}>, _langchain_langgraph.StateType<{
|
|
202
|
-
|
|
202
|
+
tools: {
|
|
203
203
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
204
204
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
205
205
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -218,34 +218,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
218
218
|
}>;
|
|
219
219
|
chat_node: _langchain_langgraph.UpdateType<{
|
|
220
220
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
221
|
-
|
|
221
|
+
client: {
|
|
222
222
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
223
|
-
|
|
223
|
+
tools: {
|
|
224
224
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
225
225
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
226
226
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
227
227
|
};
|
|
228
228
|
}>>;
|
|
229
229
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
230
|
-
|
|
230
|
+
tools: {
|
|
231
231
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
232
232
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
233
233
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
234
234
|
};
|
|
235
235
|
}>, _langchain_langgraph.StateType<{
|
|
236
|
-
|
|
236
|
+
tools: {
|
|
237
237
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
238
238
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
239
239
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
240
240
|
};
|
|
241
241
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
242
|
-
|
|
242
|
+
tools: {
|
|
243
243
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
244
244
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
245
245
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
246
246
|
};
|
|
247
247
|
}>, _langchain_langgraph.StateType<{
|
|
248
|
-
|
|
248
|
+
tools: {
|
|
249
249
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
250
250
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
251
251
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
@@ -264,34 +264,34 @@ declare const humanInTheLoopGraph: _langchain_langgraph.CompiledStateGraph<{
|
|
|
264
264
|
}>;
|
|
265
265
|
process_steps_node: _langchain_langgraph.UpdateType<{
|
|
266
266
|
messages: _langchain_langgraph.BinaryOperatorAggregate<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
|
|
267
|
-
|
|
267
|
+
client: {
|
|
268
268
|
(): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
|
|
269
|
-
|
|
269
|
+
tools: {
|
|
270
270
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
271
271
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
272
272
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
273
273
|
};
|
|
274
274
|
}>>;
|
|
275
275
|
(annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
|
|
276
|
-
|
|
276
|
+
tools: {
|
|
277
277
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
278
278
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
279
279
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
280
280
|
};
|
|
281
281
|
}>, _langchain_langgraph.StateType<{
|
|
282
|
-
|
|
282
|
+
tools: {
|
|
283
283
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
284
284
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
285
285
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
286
286
|
};
|
|
287
287
|
}>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
|
|
288
|
-
|
|
288
|
+
tools: {
|
|
289
289
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
290
290
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
291
291
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
|
292
292
|
};
|
|
293
293
|
}>, _langchain_langgraph.StateType<{
|
|
294
|
-
|
|
294
|
+
tools: {
|
|
295
295
|
(): _langchain_langgraph.LastValue<any[]>;
|
|
296
296
|
(annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
|
|
297
297
|
Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ var AgentStateAnnotation = import_langgraph.Annotation.Root({
|
|
|
71
71
|
reducer: (x, y) => y ?? x,
|
|
72
72
|
default: () => void 0
|
|
73
73
|
}),
|
|
74
|
-
...import_agent_adapter_langgraph.
|
|
74
|
+
...import_agent_adapter_langgraph.ClientStateAnnotation.spec
|
|
75
75
|
});
|
|
76
76
|
async function startFlow(state, config) {
|
|
77
77
|
if (!state.steps) {
|
|
@@ -110,7 +110,7 @@ async function chatNode(state, config) {
|
|
|
110
110
|
}
|
|
111
111
|
];
|
|
112
112
|
const modelWithTools = model.bindTools(
|
|
113
|
-
[...state.
|
|
113
|
+
[...state.client.tools || [], DEFINE_TASK_TOOL],
|
|
114
114
|
{
|
|
115
115
|
// Disable parallel tool calls to avoid race conditions
|
|
116
116
|
parallel_tool_calls: false
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/agent.ts"],"sourcesContent":["export * from \"./agent\";\n","/**\n * A LangGraph implementation of the human-in-the-loop agent.\n */\n\nimport { ChatOpenAI } from \"@langchain/openai\";\nimport { SystemMessage } from \"@langchain/core/messages\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n Command,\n interrupt,\n Annotation,\n StateGraph,\n END,\n START,\n MemorySaver,\n} from \"@langchain/langgraph\";\nimport { AGKitStateAnnotation } from \"@cloudbase/agent-adapter-langgraph\";\nimport { ToolCall } from \"@langchain/core/messages/tool\";\n\nconst DEFINE_TASK_TOOL = {\n type: \"function\",\n function: {\n name: \"plan_execution_steps\",\n description:\n \"Make up 10 steps (only a couple of words per step) that are required for a task. The step should be in imperative form (i.e. Dig hole, Open door, ...)\",\n parameters: {\n type: \"object\",\n properties: {\n steps: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n description: {\n type: \"string\",\n description: \"The text of the step in imperative form\",\n },\n status: {\n type: \"string\",\n enum: [\"enabled\"],\n description: \"The status of the step, always 'enabled'\",\n },\n },\n required: [\"description\", \"status\"],\n },\n description:\n \"An array of 10 step objects, each containing text and status\",\n },\n },\n required: [\"steps\"],\n },\n },\n};\n\nexport const AgentStateAnnotation = Annotation.Root({\n steps: Annotation<Array<{ description: string; status: string }>>({\n reducer: (x, y) => y ?? x,\n default: () => [],\n }),\n user_response: Annotation<string | undefined>({\n reducer: (x, y) => y ?? x,\n default: () => undefined,\n }),\n ...AGKitStateAnnotation.spec,\n});\nexport type AgentState = typeof AgentStateAnnotation.State;\n\nasync function startFlow(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * This is the entry point for the flow.\n */\n\n // Initialize steps list if not exists\n if (!state.steps) {\n state.steps = [];\n }\n\n return new Command({\n goto: \"chat_node\",\n update: {\n messages: state.messages,\n steps: state.steps,\n },\n });\n}\n\nasync function chatNode(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * Standard chat node where the agent processes messages and generates responses.\n * If task steps are defined, the user can enable/disable them using interrupts.\n */\n const systemPrompt = `\n You are a helpful assistant that can perform any task.\n You MUST call the \\`plan_execution_steps\\` function when the user asks you to perform a task.\n Always make sure you will provide tasks based on the user query\n `;\n\n // Define the model\n const model = new ChatOpenAI({\n model: process.env.OPENAI_MODEL || \"gpt-4o-mini\",\n apiKey: process.env.OPENAI_API_KEY,\n configuration: {\n baseURL: process.env.OPENAI_BASE_URL,\n },\n });\n\n // Define config for the model\n if (!config) {\n config = { recursionLimit: 25 };\n }\n\n // Use \"predict_state\" metadata to set up streaming for the write_document tool\n if (!config.metadata) config.metadata = {};\n config.metadata.predict_state = [\n {\n state_key: \"steps\",\n tool: \"plan_execution_steps\",\n tool_argument: \"steps\",\n },\n ];\n\n // Bind the tools to the model\n const modelWithTools = model.bindTools(\n [...(state.agKit.actions || []), DEFINE_TASK_TOOL],\n {\n // Disable parallel tool calls to avoid race conditions\n parallel_tool_calls: false,\n }\n );\n\n // Run the model and generate a response\n const response = await modelWithTools.invoke(\n [new SystemMessage({ content: systemPrompt }), ...state.messages],\n config\n );\n\n // Update messages with the response\n const messages = [...state.messages, response];\n\n const toolCalls: ToolCall[] = [\n ...(response.tool_calls || []),\n ...(response.additional_kwargs.tool_calls?.map((tool) => ({\n name: tool.function.name,\n args: JSON.parse(tool.function.arguments),\n id: tool.id,\n type: \"tool_call\" as const,\n })) || []),\n ];\n\n // Handle tool calls\n if (toolCalls.length > 0) {\n const toolCall = toolCalls[0]!;\n\n if (toolCall.name === \"plan_execution_steps\") {\n // Get the steps from the tool call\n const stepsRaw = toolCall.args.steps || [];\n\n // Set initial status to \"enabled\" for all steps\n const stepsData: Array<{ description: string; status: string }> = [];\n\n // Handle different potential formats of steps data\n if (Array.isArray(stepsRaw)) {\n for (const step of stepsRaw) {\n if (typeof step === \"object\" && step.description) {\n stepsData.push({\n description: step.description,\n status: \"enabled\",\n });\n } else if (typeof step === \"string\") {\n stepsData.push({\n description: step,\n status: \"enabled\",\n });\n }\n }\n }\n\n // If no steps were processed correctly, return to END with the updated messages\n if (stepsData.length === 0) {\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n }\n\n // Update steps in state and emit to frontend\n state.steps = stepsData;\n\n // Add a tool response to satisfy OpenAI's requirements\n const toolResponse = {\n role: \"tool\" as const,\n content: \"Task steps generated.\",\n tool_call_id: toolCall.id,\n };\n\n const updatedMessages = [...messages, toolResponse];\n\n // Move to the process_steps_node which will handle the interrupt and final response\n return new Command({\n goto: \"process_steps_node\",\n update: {\n messages: updatedMessages,\n steps: state.steps,\n },\n });\n }\n }\n\n // If no tool calls or not plan_execution_steps, return to END with the updated messages\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n}\n\nasync function processStepsNode(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * This node handles the user interrupt for step customization and generates the final response.\n */\n\n let userResponse: string;\n\n // Check if we already have a user_response in the state\n // This happens when the node restarts after an interrupt\n if (state.user_response) {\n userResponse = state.user_response;\n } else {\n // Use LangGraph interrupt to get user input on steps\n // This will pause execution and wait for user input in the frontend\n userResponse = interrupt({ steps: state.steps });\n // Store the user response in state for when the node restarts\n state.user_response = userResponse;\n }\n\n // Generate the creative completion response\n const finalPrompt = `\n Provide a textual description of how you are performing the task.\n If the user has disabled a step, you are not allowed to perform that step.\n However, you should find a creative workaround to perform the task, and if an essential step is disabled, you can even use\n some humor in the description of how you are performing the task.\n Don't just repeat a list of steps, come up with a creative but short description (3 sentences max) of how you are performing the task.\n `;\n\n const finalResponse = await new ChatOpenAI({\n model: process.env.OPENAI_MODEL || \"gpt-4o-mini\",\n apiKey: process.env.OPENAI_API_KEY,\n configuration: {\n baseURL: process.env.OPENAI_BASE_URL,\n },\n }).invoke(\n [\n new SystemMessage({ content: finalPrompt }),\n { role: \"user\", content: userResponse },\n ],\n config\n );\n\n // Add the final response to messages\n const messages = [...state.messages, finalResponse];\n\n // Clear the user_response from state to prepare for future interactions\n const newState = { ...state };\n delete newState.user_response;\n\n // Return to END with the updated messages\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n}\n\n// Define the graph\nconst workflow = new StateGraph(AgentStateAnnotation)\n .addNode(\"start_flow\", startFlow)\n .addNode(\"chat_node\", chatNode)\n .addNode(\"process_steps_node\", processStepsNode)\n .addEdge(START, \"start_flow\")\n .addEdge(\"start_flow\", \"chat_node\")\n .addEdge(\"process_steps_node\", END)\n .addConditionalEdges(\n \"chat_node\",\n (state: AgentState) => {\n // This would be determined by the Command returned from chat_node\n // For now, we'll assume the logic is handled in the Command's goto property\n return \"continue\";\n },\n {\n process_steps_node: \"process_steps_node\",\n continue: END,\n }\n );\n\n// Compile the graph\nexport const humanInTheLoopGraph = workflow.compile({\n checkpointer: new MemorySaver(),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,oBAA2B;AAC3B,sBAA8B;AAE9B,uBAQO;AACP,qCAAqC;AAGrC,IAAM,mBAAmB;AAAA,EACvB,MAAM;AAAA,EACN,UAAU;AAAA,IACR,MAAM;AAAA,IACN,aACE;AAAA,IACF,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,QACV,OAAO;AAAA,UACL,MAAM;AAAA,UACN,OAA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;AAGlD,QAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,SAAO,SAAS;AAGhB,SAAO,IAAI,yBAAQ;AAAA,IACjB,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,MACA,OAAO,MAAM;AAAA,IACf;AAAA,EACF,CAAC;AACH;AAGA,IAAM,WAAW,IAAI,4BAAW,oBAAoB,EACjD,QAAQ,cAAc,SAAS,EAC/B,QAAQ,aAAa,QAAQ,EAC7B,QAAQ,sBAAsB,gBAAgB,EAC9C,QAAQ,wBAAO,YAAY,EAC3B,QAAQ,cAAc,WAAW,EACjC,QAAQ,sBAAsB,oBAAG,EACjC;AAAA,EACC;AAAA,EACA,CAAC,UAAsB;AAGrB,WAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,oBAAoB;AAAA,IACpB,UAAU;AAAA,EACZ;AACF;AAGK,IAAM,sBAAsB,SAAS,QAAQ;AAAA,EAClD,cAAc,IAAI,6BAAY;AAChC,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/agent.ts"],"sourcesContent":["export * from \"./agent\";\n","/**\n * A LangGraph implementation of the human-in-the-loop agent.\n */\n\nimport { ChatOpenAI } from \"@langchain/openai\";\nimport { SystemMessage } from \"@langchain/core/messages\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n Command,\n interrupt,\n Annotation,\n StateGraph,\n END,\n START,\n MemorySaver,\n} from \"@langchain/langgraph\";\nimport { ClientStateAnnotation } from \"@cloudbase/agent-adapter-langgraph\";\nimport { ToolCall } from \"@langchain/core/messages/tool\";\n\nconst DEFINE_TASK_TOOL = {\n type: \"function\",\n function: {\n name: \"plan_execution_steps\",\n description:\n \"Make up 10 steps (only a couple of words per step) that are required for a task. The step should be in imperative form (i.e. Dig hole, Open door, ...)\",\n parameters: {\n type: \"object\",\n properties: {\n steps: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n description: {\n type: \"string\",\n description: \"The text of the step in imperative form\",\n },\n status: {\n type: \"string\",\n enum: [\"enabled\"],\n description: \"The status of the step, always 'enabled'\",\n },\n },\n required: [\"description\", \"status\"],\n },\n description:\n \"An array of 10 step objects, each containing text and status\",\n },\n },\n required: [\"steps\"],\n },\n },\n};\n\nexport const AgentStateAnnotation = Annotation.Root({\n steps: Annotation<Array<{ description: string; status: string }>>({\n reducer: (x, y) => y ?? x,\n default: () => [],\n }),\n user_response: Annotation<string | undefined>({\n reducer: (x, y) => y ?? x,\n default: () => undefined,\n }),\n ...ClientStateAnnotation.spec,\n});\nexport type AgentState = typeof AgentStateAnnotation.State;\n\nasync function startFlow(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * This is the entry point for the flow.\n */\n\n // Initialize steps list if not exists\n if (!state.steps) {\n state.steps = [];\n }\n\n return new Command({\n goto: \"chat_node\",\n update: {\n messages: state.messages,\n steps: state.steps,\n },\n });\n}\n\nasync function chatNode(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * Standard chat node where the agent processes messages and generates responses.\n * If task steps are defined, the user can enable/disable them using interrupts.\n */\n const systemPrompt = `\n You are a helpful assistant that can perform any task.\n You MUST call the \\`plan_execution_steps\\` function when the user asks you to perform a task.\n Always make sure you will provide tasks based on the user query\n `;\n\n // Define the model\n const model = new ChatOpenAI({\n model: process.env.OPENAI_MODEL || \"gpt-4o-mini\",\n apiKey: process.env.OPENAI_API_KEY,\n configuration: {\n baseURL: process.env.OPENAI_BASE_URL,\n },\n });\n\n // Define config for the model\n if (!config) {\n config = { recursionLimit: 25 };\n }\n\n // Use \"predict_state\" metadata to set up streaming for the write_document tool\n if (!config.metadata) config.metadata = {};\n config.metadata.predict_state = [\n {\n state_key: \"steps\",\n tool: \"plan_execution_steps\",\n tool_argument: \"steps\",\n },\n ];\n\n // Bind the tools to the model\n const modelWithTools = model.bindTools(\n [...(state.client.tools || []), DEFINE_TASK_TOOL],\n {\n // Disable parallel tool calls to avoid race conditions\n parallel_tool_calls: false,\n }\n );\n\n // Run the model and generate a response\n const response = await modelWithTools.invoke(\n [new SystemMessage({ content: systemPrompt }), ...state.messages],\n config\n );\n\n // Update messages with the response\n const messages = [...state.messages, response];\n\n const toolCalls: ToolCall[] = [\n ...(response.tool_calls || []),\n ...(response.additional_kwargs.tool_calls?.map((tool) => ({\n name: tool.function.name,\n args: JSON.parse(tool.function.arguments),\n id: tool.id,\n type: \"tool_call\" as const,\n })) || []),\n ];\n\n // Handle tool calls\n if (toolCalls.length > 0) {\n const toolCall = toolCalls[0]!;\n\n if (toolCall.name === \"plan_execution_steps\") {\n // Get the steps from the tool call\n const stepsRaw = toolCall.args.steps || [];\n\n // Set initial status to \"enabled\" for all steps\n const stepsData: Array<{ description: string; status: string }> = [];\n\n // Handle different potential formats of steps data\n if (Array.isArray(stepsRaw)) {\n for (const step of stepsRaw) {\n if (typeof step === \"object\" && step.description) {\n stepsData.push({\n description: step.description,\n status: \"enabled\",\n });\n } else if (typeof step === \"string\") {\n stepsData.push({\n description: step,\n status: \"enabled\",\n });\n }\n }\n }\n\n // If no steps were processed correctly, return to END with the updated messages\n if (stepsData.length === 0) {\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n }\n\n // Update steps in state and emit to frontend\n state.steps = stepsData;\n\n // Add a tool response to satisfy OpenAI's requirements\n const toolResponse = {\n role: \"tool\" as const,\n content: \"Task steps generated.\",\n tool_call_id: toolCall.id,\n };\n\n const updatedMessages = [...messages, toolResponse];\n\n // Move to the process_steps_node which will handle the interrupt and final response\n return new Command({\n goto: \"process_steps_node\",\n update: {\n messages: updatedMessages,\n steps: state.steps,\n },\n });\n }\n }\n\n // If no tool calls or not plan_execution_steps, return to END with the updated messages\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n}\n\nasync function processStepsNode(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * This node handles the user interrupt for step customization and generates the final response.\n */\n\n let userResponse: string;\n\n // Check if we already have a user_response in the state\n // This happens when the node restarts after an interrupt\n if (state.user_response) {\n userResponse = state.user_response;\n } else {\n // Use LangGraph interrupt to get user input on steps\n // This will pause execution and wait for user input in the frontend\n userResponse = interrupt({ steps: state.steps });\n // Store the user response in state for when the node restarts\n state.user_response = userResponse;\n }\n\n // Generate the creative completion response\n const finalPrompt = `\n Provide a textual description of how you are performing the task.\n If the user has disabled a step, you are not allowed to perform that step.\n However, you should find a creative workaround to perform the task, and if an essential step is disabled, you can even use\n some humor in the description of how you are performing the task.\n Don't just repeat a list of steps, come up with a creative but short description (3 sentences max) of how you are performing the task.\n `;\n\n const finalResponse = await new ChatOpenAI({\n model: process.env.OPENAI_MODEL || \"gpt-4o-mini\",\n apiKey: process.env.OPENAI_API_KEY,\n configuration: {\n baseURL: process.env.OPENAI_BASE_URL,\n },\n }).invoke(\n [\n new SystemMessage({ content: finalPrompt }),\n { role: \"user\", content: userResponse },\n ],\n config\n );\n\n // Add the final response to messages\n const messages = [...state.messages, finalResponse];\n\n // Clear the user_response from state to prepare for future interactions\n const newState = { ...state };\n delete newState.user_response;\n\n // Return to END with the updated messages\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n}\n\n// Define the graph\nconst workflow = new StateGraph(AgentStateAnnotation)\n .addNode(\"start_flow\", startFlow)\n .addNode(\"chat_node\", chatNode)\n .addNode(\"process_steps_node\", processStepsNode)\n .addEdge(START, \"start_flow\")\n .addEdge(\"start_flow\", \"chat_node\")\n .addEdge(\"process_steps_node\", END)\n .addConditionalEdges(\n \"chat_node\",\n (state: AgentState) => {\n // This would be determined by the Command returned from chat_node\n // For now, we'll assume the logic is handled in the Command's goto property\n return \"continue\";\n },\n {\n process_steps_node: \"process_steps_node\",\n continue: END,\n }\n );\n\n// Compile the graph\nexport const humanInTheLoopGraph = workflow.compile({\n checkpointer: new MemorySaver(),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA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b,SAAS,QAAQ,IAAI;AAAA,IACvB;AAAA,EACF,CAAC,EAAE;AAAA,IACD;AAAA,MACE,IAAI,8BAAc,EAAE,SAAS,YAAY,CAAC;AAAA,MAC1C,EAAE,MAAM,QAAQ,SAAS,aAAa;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAGA,QAAM,WAAW,CAAC,GAAG,MAAM,UAAU,aAAa;AAGlD,QAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,SAAO,SAAS;AAGhB,SAAO,IAAI,yBAAQ;AAAA,IACjB,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,MACA,OAAO,MAAM;AAAA,IACf;AAAA,EACF,CAAC;AACH;AAGA,IAAM,WAAW,IAAI,4BAAW,oBAAoB,EACjD,QAAQ,cAAc,SAAS,EAC/B,QAAQ,aAAa,QAAQ,EAC7B,QAAQ,sBAAsB,gBAAgB,EAC9C,QAAQ,wBAAO,YAAY,EAC3B,QAAQ,cAAc,WAAW,EACjC,QAAQ,sBAAsB,oBAAG,EACjC;AAAA,EACC;AAAA,EACA,CAAC,UAAsB;AAGrB,WAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,oBAAoB;AAAA,IACpB,UAAU;AAAA,EACZ;AACF;AAGK,IAAM,sBAAsB,SAAS,QAAQ;AAAA,EAClD,cAAc,IAAI,6BAAY;AAChC,CAAC;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
START,
|
|
11
11
|
MemorySaver
|
|
12
12
|
} from "@langchain/langgraph";
|
|
13
|
-
import {
|
|
13
|
+
import { ClientStateAnnotation } from "@cloudbase/agent-adapter-langgraph";
|
|
14
14
|
var DEFINE_TASK_TOOL = {
|
|
15
15
|
type: "function",
|
|
16
16
|
function: {
|
|
@@ -52,7 +52,7 @@ var AgentStateAnnotation = Annotation.Root({
|
|
|
52
52
|
reducer: (x, y) => y ?? x,
|
|
53
53
|
default: () => void 0
|
|
54
54
|
}),
|
|
55
|
-
...
|
|
55
|
+
...ClientStateAnnotation.spec
|
|
56
56
|
});
|
|
57
57
|
async function startFlow(state, config) {
|
|
58
58
|
if (!state.steps) {
|
|
@@ -91,7 +91,7 @@ async function chatNode(state, config) {
|
|
|
91
91
|
}
|
|
92
92
|
];
|
|
93
93
|
const modelWithTools = model.bindTools(
|
|
94
|
-
[...state.
|
|
94
|
+
[...state.client.tools || [], DEFINE_TASK_TOOL],
|
|
95
95
|
{
|
|
96
96
|
// Disable parallel tool calls to avoid race conditions
|
|
97
97
|
parallel_tool_calls: false
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/agent.ts"],"sourcesContent":["/**\n * A LangGraph implementation of the human-in-the-loop agent.\n */\n\nimport { ChatOpenAI } from \"@langchain/openai\";\nimport { SystemMessage } from \"@langchain/core/messages\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n Command,\n interrupt,\n Annotation,\n StateGraph,\n END,\n START,\n MemorySaver,\n} from \"@langchain/langgraph\";\nimport { AGKitStateAnnotation } from \"@cloudbase/agent-adapter-langgraph\";\nimport { ToolCall } from \"@langchain/core/messages/tool\";\n\nconst DEFINE_TASK_TOOL = {\n type: \"function\",\n function: {\n name: \"plan_execution_steps\",\n description:\n \"Make up 10 steps (only a couple of words per step) that are required for a task. The step should be in imperative form (i.e. Dig hole, Open door, ...)\",\n parameters: {\n type: \"object\",\n properties: {\n steps: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n description: {\n type: \"string\",\n description: \"The text of the step in imperative form\",\n },\n status: {\n type: \"string\",\n enum: [\"enabled\"],\n description: \"The status of the step, always 'enabled'\",\n },\n },\n required: [\"description\", \"status\"],\n },\n description:\n \"An array of 10 step objects, each containing text and status\",\n },\n },\n required: [\"steps\"],\n },\n },\n};\n\nexport const AgentStateAnnotation = Annotation.Root({\n steps: Annotation<Array<{ description: string; status: string }>>({\n reducer: (x, y) => y ?? x,\n default: () => [],\n }),\n user_response: Annotation<string | undefined>({\n reducer: (x, y) => y ?? x,\n default: () => undefined,\n }),\n ...AGKitStateAnnotation.spec,\n});\nexport type AgentState = typeof AgentStateAnnotation.State;\n\nasync function startFlow(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * This is the entry point for the flow.\n */\n\n // Initialize steps list if not exists\n if (!state.steps) {\n state.steps = [];\n }\n\n return new Command({\n goto: \"chat_node\",\n update: {\n messages: state.messages,\n steps: state.steps,\n },\n });\n}\n\nasync function chatNode(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * Standard chat node where the agent processes messages and generates responses.\n * If task steps are defined, the user can enable/disable them using interrupts.\n */\n const systemPrompt = `\n You are a helpful assistant that can perform any task.\n You MUST call the \\`plan_execution_steps\\` function when the user asks you to perform a task.\n Always make sure you will provide tasks based on the user query\n `;\n\n // Define the model\n const model = new ChatOpenAI({\n model: process.env.OPENAI_MODEL || \"gpt-4o-mini\",\n apiKey: process.env.OPENAI_API_KEY,\n configuration: {\n baseURL: process.env.OPENAI_BASE_URL,\n },\n });\n\n // Define config for the model\n if (!config) {\n config = { recursionLimit: 25 };\n }\n\n // Use \"predict_state\" metadata to set up streaming for the write_document tool\n if (!config.metadata) config.metadata = {};\n config.metadata.predict_state = [\n {\n state_key: \"steps\",\n tool: \"plan_execution_steps\",\n tool_argument: \"steps\",\n },\n ];\n\n // Bind the tools to the model\n const modelWithTools = model.bindTools(\n [...(state.agKit.actions || []), DEFINE_TASK_TOOL],\n {\n // Disable parallel tool calls to avoid race conditions\n parallel_tool_calls: false,\n }\n );\n\n // Run the model and generate a response\n const response = await modelWithTools.invoke(\n [new SystemMessage({ content: systemPrompt }), ...state.messages],\n config\n );\n\n // Update messages with the response\n const messages = [...state.messages, response];\n\n const toolCalls: ToolCall[] = [\n ...(response.tool_calls || []),\n ...(response.additional_kwargs.tool_calls?.map((tool) => ({\n name: tool.function.name,\n args: JSON.parse(tool.function.arguments),\n id: tool.id,\n type: \"tool_call\" as const,\n })) || []),\n ];\n\n // Handle tool calls\n if (toolCalls.length > 0) {\n const toolCall = toolCalls[0]!;\n\n if (toolCall.name === \"plan_execution_steps\") {\n // Get the steps from the tool call\n const stepsRaw = toolCall.args.steps || [];\n\n // Set initial status to \"enabled\" for all steps\n const stepsData: Array<{ description: string; status: string }> = [];\n\n // Handle different potential formats of steps data\n if (Array.isArray(stepsRaw)) {\n for (const step of stepsRaw) {\n if (typeof step === \"object\" && step.description) {\n stepsData.push({\n description: step.description,\n status: \"enabled\",\n });\n } else if (typeof step === \"string\") {\n stepsData.push({\n description: step,\n status: \"enabled\",\n });\n }\n }\n }\n\n // If no steps were processed correctly, return to END with the updated messages\n if (stepsData.length === 0) {\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n }\n\n // Update steps in state and emit to frontend\n state.steps = stepsData;\n\n // Add a tool response to satisfy OpenAI's requirements\n const toolResponse = {\n role: \"tool\" as const,\n content: \"Task steps generated.\",\n tool_call_id: toolCall.id,\n };\n\n const updatedMessages = [...messages, toolResponse];\n\n // Move to the process_steps_node which will handle the interrupt and final response\n return new Command({\n goto: \"process_steps_node\",\n update: {\n messages: updatedMessages,\n steps: state.steps,\n },\n });\n }\n }\n\n // If no tool calls or not plan_execution_steps, return to END with the updated messages\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n}\n\nasync function processStepsNode(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * This node handles the user interrupt for step customization and generates the final response.\n */\n\n let userResponse: string;\n\n // Check if we already have a user_response in the state\n // This happens when the node restarts after an interrupt\n if (state.user_response) {\n userResponse = state.user_response;\n } else {\n // Use LangGraph interrupt to get user input on steps\n // This will pause execution and wait for user input in the frontend\n userResponse = interrupt({ steps: state.steps });\n // Store the user response in state for when the node restarts\n state.user_response = userResponse;\n }\n\n // Generate the creative completion response\n const finalPrompt = `\n Provide a textual description of how you are performing the task.\n If the user has disabled a step, you are not allowed to perform that step.\n However, you should find a creative workaround to perform the task, and if an essential step is disabled, you can even use\n some humor in the description of how you are performing the task.\n Don't just repeat a list of steps, come up with a creative but short description (3 sentences max) of how you are performing the task.\n `;\n\n const finalResponse = await new ChatOpenAI({\n model: process.env.OPENAI_MODEL || \"gpt-4o-mini\",\n apiKey: process.env.OPENAI_API_KEY,\n configuration: {\n baseURL: process.env.OPENAI_BASE_URL,\n },\n }).invoke(\n [\n new SystemMessage({ content: finalPrompt }),\n { role: \"user\", content: userResponse },\n ],\n config\n );\n\n // Add the final response to messages\n const messages = [...state.messages, finalResponse];\n\n // Clear the user_response from state to prepare for future interactions\n const newState = { ...state };\n delete newState.user_response;\n\n // Return to END with the updated messages\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n}\n\n// Define the graph\nconst workflow = new StateGraph(AgentStateAnnotation)\n .addNode(\"start_flow\", startFlow)\n .addNode(\"chat_node\", chatNode)\n .addNode(\"process_steps_node\", processStepsNode)\n .addEdge(START, \"start_flow\")\n .addEdge(\"start_flow\", \"chat_node\")\n .addEdge(\"process_steps_node\", END)\n .addConditionalEdges(\n \"chat_node\",\n (state: AgentState) => {\n // This would be determined by the Command returned from chat_node\n // For now, we'll assume the logic is handled in the Command's goto property\n return \"continue\";\n },\n {\n process_steps_node: \"process_steps_node\",\n continue: END,\n }\n );\n\n// Compile the graph\nexport const humanInTheLoopGraph = workflow.compile({\n checkpointer: new MemorySaver(),\n});\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAE9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AAGrC,IAAM,mBAAmB;AAAA,EACvB,MAAM;AAAA,EACN,UAAU;AAAA,IACR,MAAM;AAAA,IACN,aACE;AAAA,IACF,YAAY;AAAA,MACV,MAAM;AAAA,MACN,YAAY;AAAA,QACV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GAAG,MAAM,UAAU,aAAa;AAGlD,QAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,SAAO,SAAS;AAGhB,SAAO,IAAI,QAAQ;AAAA,IACjB,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,MACA,OAAO,MAAM;AAAA,IACf;AAAA,EACF,CAAC;AACH;AAGA,IAAM,WAAW,IAAI,WAAW,oBAAoB,EACjD,QAAQ,cAAc,SAAS,EAC/B,QAAQ,aAAa,QAAQ,EAC7B,QAAQ,sBAAsB,gBAAgB,EAC9C,QAAQ,OAAO,YAAY,EAC3B,QAAQ,cAAc,WAAW,EACjC,QAAQ,sBAAsB,GAAG,EACjC;AAAA,EACC;AAAA,EACA,CAAC,UAAsB;AAGrB,WAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,oBAAoB;AAAA,IACpB,UAAU;AAAA,EACZ;AACF;AAGK,IAAM,sBAAsB,SAAS,QAAQ;AAAA,EAClD,cAAc,IAAI,YAAY;AAChC,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/agent.ts"],"sourcesContent":["/**\n * A LangGraph implementation of the human-in-the-loop agent.\n */\n\nimport { ChatOpenAI } from \"@langchain/openai\";\nimport { SystemMessage } from \"@langchain/core/messages\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n Command,\n interrupt,\n Annotation,\n StateGraph,\n END,\n START,\n MemorySaver,\n} from \"@langchain/langgraph\";\nimport { ClientStateAnnotation } from \"@cloudbase/agent-adapter-langgraph\";\nimport { ToolCall } from \"@langchain/core/messages/tool\";\n\nconst DEFINE_TASK_TOOL = {\n type: \"function\",\n function: {\n name: \"plan_execution_steps\",\n description:\n \"Make up 10 steps (only a couple of words per step) that are required for a task. The step should be in imperative form (i.e. Dig hole, Open door, ...)\",\n parameters: {\n type: \"object\",\n properties: {\n steps: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n description: {\n type: \"string\",\n description: \"The text of the step in imperative form\",\n },\n status: {\n type: \"string\",\n enum: [\"enabled\"],\n description: \"The status of the step, always 'enabled'\",\n },\n },\n required: [\"description\", \"status\"],\n },\n description:\n \"An array of 10 step objects, each containing text and status\",\n },\n },\n required: [\"steps\"],\n },\n },\n};\n\nexport const AgentStateAnnotation = Annotation.Root({\n steps: Annotation<Array<{ description: string; status: string }>>({\n reducer: (x, y) => y ?? x,\n default: () => [],\n }),\n user_response: Annotation<string | undefined>({\n reducer: (x, y) => y ?? x,\n default: () => undefined,\n }),\n ...ClientStateAnnotation.spec,\n});\nexport type AgentState = typeof AgentStateAnnotation.State;\n\nasync function startFlow(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * This is the entry point for the flow.\n */\n\n // Initialize steps list if not exists\n if (!state.steps) {\n state.steps = [];\n }\n\n return new Command({\n goto: \"chat_node\",\n update: {\n messages: state.messages,\n steps: state.steps,\n },\n });\n}\n\nasync function chatNode(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * Standard chat node where the agent processes messages and generates responses.\n * If task steps are defined, the user can enable/disable them using interrupts.\n */\n const systemPrompt = `\n You are a helpful assistant that can perform any task.\n You MUST call the \\`plan_execution_steps\\` function when the user asks you to perform a task.\n Always make sure you will provide tasks based on the user query\n `;\n\n // Define the model\n const model = new ChatOpenAI({\n model: process.env.OPENAI_MODEL || \"gpt-4o-mini\",\n apiKey: process.env.OPENAI_API_KEY,\n configuration: {\n baseURL: process.env.OPENAI_BASE_URL,\n },\n });\n\n // Define config for the model\n if (!config) {\n config = { recursionLimit: 25 };\n }\n\n // Use \"predict_state\" metadata to set up streaming for the write_document tool\n if (!config.metadata) config.metadata = {};\n config.metadata.predict_state = [\n {\n state_key: \"steps\",\n tool: \"plan_execution_steps\",\n tool_argument: \"steps\",\n },\n ];\n\n // Bind the tools to the model\n const modelWithTools = model.bindTools(\n [...(state.client.tools || []), DEFINE_TASK_TOOL],\n {\n // Disable parallel tool calls to avoid race conditions\n parallel_tool_calls: false,\n }\n );\n\n // Run the model and generate a response\n const response = await modelWithTools.invoke(\n [new SystemMessage({ content: systemPrompt }), ...state.messages],\n config\n );\n\n // Update messages with the response\n const messages = [...state.messages, response];\n\n const toolCalls: ToolCall[] = [\n ...(response.tool_calls || []),\n ...(response.additional_kwargs.tool_calls?.map((tool) => ({\n name: tool.function.name,\n args: JSON.parse(tool.function.arguments),\n id: tool.id,\n type: \"tool_call\" as const,\n })) || []),\n ];\n\n // Handle tool calls\n if (toolCalls.length > 0) {\n const toolCall = toolCalls[0]!;\n\n if (toolCall.name === \"plan_execution_steps\") {\n // Get the steps from the tool call\n const stepsRaw = toolCall.args.steps || [];\n\n // Set initial status to \"enabled\" for all steps\n const stepsData: Array<{ description: string; status: string }> = [];\n\n // Handle different potential formats of steps data\n if (Array.isArray(stepsRaw)) {\n for (const step of stepsRaw) {\n if (typeof step === \"object\" && step.description) {\n stepsData.push({\n description: step.description,\n status: \"enabled\",\n });\n } else if (typeof step === \"string\") {\n stepsData.push({\n description: step,\n status: \"enabled\",\n });\n }\n }\n }\n\n // If no steps were processed correctly, return to END with the updated messages\n if (stepsData.length === 0) {\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n }\n\n // Update steps in state and emit to frontend\n state.steps = stepsData;\n\n // Add a tool response to satisfy OpenAI's requirements\n const toolResponse = {\n role: \"tool\" as const,\n content: \"Task steps generated.\",\n tool_call_id: toolCall.id,\n };\n\n const updatedMessages = [...messages, toolResponse];\n\n // Move to the process_steps_node which will handle the interrupt and final response\n return new Command({\n goto: \"process_steps_node\",\n update: {\n messages: updatedMessages,\n steps: state.steps,\n },\n });\n }\n }\n\n // If no tool calls or not plan_execution_steps, return to END with the updated messages\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n}\n\nasync function processStepsNode(\n state: AgentState,\n config?: RunnableConfig\n): Promise<Command> {\n /**\n * This node handles the user interrupt for step customization and generates the final response.\n */\n\n let userResponse: string;\n\n // Check if we already have a user_response in the state\n // This happens when the node restarts after an interrupt\n if (state.user_response) {\n userResponse = state.user_response;\n } else {\n // Use LangGraph interrupt to get user input on steps\n // This will pause execution and wait for user input in the frontend\n userResponse = interrupt({ steps: state.steps });\n // Store the user response in state for when the node restarts\n state.user_response = userResponse;\n }\n\n // Generate the creative completion response\n const finalPrompt = `\n Provide a textual description of how you are performing the task.\n If the user has disabled a step, you are not allowed to perform that step.\n However, you should find a creative workaround to perform the task, and if an essential step is disabled, you can even use\n some humor in the description of how you are performing the task.\n Don't just repeat a list of steps, come up with a creative but short description (3 sentences max) of how you are performing the task.\n `;\n\n const finalResponse = await new ChatOpenAI({\n model: process.env.OPENAI_MODEL || \"gpt-4o-mini\",\n apiKey: process.env.OPENAI_API_KEY,\n configuration: {\n baseURL: process.env.OPENAI_BASE_URL,\n },\n }).invoke(\n [\n new SystemMessage({ content: finalPrompt }),\n { role: \"user\", content: userResponse },\n ],\n config\n );\n\n // Add the final response to messages\n const messages = [...state.messages, finalResponse];\n\n // Clear the user_response from state to prepare for future interactions\n const newState = { ...state };\n delete newState.user_response;\n\n // Return to END with the updated messages\n return new Command({\n goto: END,\n update: {\n messages: messages,\n steps: state.steps,\n },\n });\n}\n\n// Define the graph\nconst workflow = new StateGraph(AgentStateAnnotation)\n .addNode(\"start_flow\", startFlow)\n .addNode(\"chat_node\", chatNode)\n .addNode(\"process_steps_node\", processStepsNode)\n .addEdge(START, \"start_flow\")\n .addEdge(\"start_flow\", \"chat_node\")\n .addEdge(\"process_steps_node\", END)\n .addConditionalEdges(\n \"chat_node\",\n (state: AgentState) => {\n // This would be determined by the Command returned from chat_node\n // For now, we'll assume the logic is handled in the Command's goto property\n return \"continue\";\n },\n {\n process_steps_node: \"process_steps_node\",\n continue: END,\n }\n );\n\n// Compile the graph\nexport const humanInTheLoopGraph = workflow.compile({\n checkpointer: new MemorySaver(),\n});\n"],"mappings":";AAIA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAE9B;AAAA,EACE;AAAA,EACA;AAA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AAe;AAAA,MACb,SAAS,QAAQ,IAAI;AAAA,IACvB;AAAA,EACF,CAAC,EAAE;AAAA,IACD;AAAA,MACE,IAAI,cAAc,EAAE,SAAS,YAAY,CAAC;AAAA,MAC1C,EAAE,MAAM,QAAQ,SAAS,aAAa;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAGA,QAAM,WAAW,CAAC,GAAG,MAAM,UAAU,aAAa;AAGlD,QAAM,WAAW,EAAE,GAAG,MAAM;AAC5B,SAAO,SAAS;AAGhB,SAAO,IAAI,QAAQ;AAAA,IACjB,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,MACA,OAAO,MAAM;AAAA,IACf;AAAA,EACF,CAAC;AACH;AAGA,IAAM,WAAW,IAAI,WAAW,oBAAoB,EACjD,QAAQ,cAAc,SAAS,EAC/B,QAAQ,aAAa,QAAQ,EAC7B,QAAQ,sBAAsB,gBAAgB,EAC9C,QAAQ,OAAO,YAAY,EAC3B,QAAQ,cAAc,WAAW,EACjC,QAAQ,sBAAsB,GAAG,EACjC;AAAA,EACC;AAAA,EACA,CAAC,UAAsB;AAGrB,WAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,oBAAoB;AAAA,IACpB,UAAU;AAAA,EACZ;AACF;AAGK,IAAM,sBAAsB,SAAS,QAAQ;AAAA,EAClD,cAAc,IAAI,YAAY;AAChC,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/agent-examples-langgraph-human-in-the-loop",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"@langchain/core": "^1.0.2",
|
|
14
14
|
"@langchain/langgraph": "^1.0.1",
|
|
15
15
|
"@langchain/openai": "^1.0.0",
|
|
16
|
-
"@cloudbase/agent-agents": "^0.0.
|
|
17
|
-
"@cloudbase/agent-adapter-langgraph": "^0.0.
|
|
16
|
+
"@cloudbase/agent-agents": "^0.0.6",
|
|
17
|
+
"@cloudbase/agent-adapter-langgraph": "^0.0.6"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsup --config tsup.config.ts"
|
package/src/agent.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
START,
|
|
15
15
|
MemorySaver,
|
|
16
16
|
} from "@langchain/langgraph";
|
|
17
|
-
import {
|
|
17
|
+
import { ClientStateAnnotation } from "@cloudbase/agent-adapter-langgraph";
|
|
18
18
|
import { ToolCall } from "@langchain/core/messages/tool";
|
|
19
19
|
|
|
20
20
|
const DEFINE_TASK_TOOL = {
|
|
@@ -61,7 +61,7 @@ export const AgentStateAnnotation = Annotation.Root({
|
|
|
61
61
|
reducer: (x, y) => y ?? x,
|
|
62
62
|
default: () => undefined,
|
|
63
63
|
}),
|
|
64
|
-
...
|
|
64
|
+
...ClientStateAnnotation.spec,
|
|
65
65
|
});
|
|
66
66
|
export type AgentState = typeof AgentStateAnnotation.State;
|
|
67
67
|
|
|
@@ -127,7 +127,7 @@ async function chatNode(
|
|
|
127
127
|
|
|
128
128
|
// Bind the tools to the model
|
|
129
129
|
const modelWithTools = model.bindTools(
|
|
130
|
-
[...(state.
|
|
130
|
+
[...(state.client.tools || []), DEFINE_TASK_TOOL],
|
|
131
131
|
{
|
|
132
132
|
// Disable parallel tool calls to avoid race conditions
|
|
133
133
|
parallel_tool_calls: false,
|