@copilotkit/sdk-js 1.56.2 → 1.56.4-canary.1777529757

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 (43) hide show
  1. package/dist/langchain.cjs +3 -0
  2. package/dist/langchain.cjs.map +1 -1
  3. package/dist/langchain.d.cts +3 -2
  4. package/dist/langchain.d.mts +3 -2
  5. package/dist/langchain.mjs +3 -2
  6. package/dist/langchain.mjs.map +1 -1
  7. package/dist/langgraph/middleware.cjs +144 -11
  8. package/dist/langgraph/middleware.cjs.map +1 -1
  9. package/dist/langgraph/middleware.d.cts +68 -1
  10. package/dist/langgraph/middleware.d.cts.map +1 -1
  11. package/dist/langgraph/middleware.d.mts +68 -1
  12. package/dist/langgraph/middleware.d.mts.map +1 -1
  13. package/dist/langgraph/middleware.mjs +143 -12
  14. package/dist/langgraph/middleware.mjs.map +1 -1
  15. package/dist/langgraph/state-schema.cjs +37 -0
  16. package/dist/langgraph/state-schema.cjs.map +1 -0
  17. package/dist/langgraph/state-schema.d.cts +118 -0
  18. package/dist/langgraph/state-schema.d.cts.map +1 -0
  19. package/dist/langgraph/state-schema.d.mts +118 -0
  20. package/dist/langgraph/state-schema.d.mts.map +1 -0
  21. package/dist/langgraph/state-schema.mjs +36 -0
  22. package/dist/langgraph/state-schema.mjs.map +1 -0
  23. package/dist/langgraph/types.cjs +41 -0
  24. package/dist/langgraph/types.cjs.map +1 -1
  25. package/dist/langgraph/types.d.cts +140 -51
  26. package/dist/langgraph/types.d.cts.map +1 -1
  27. package/dist/langgraph/types.d.mts +140 -51
  28. package/dist/langgraph/types.d.mts.map +1 -1
  29. package/dist/langgraph/types.mjs +41 -1
  30. package/dist/langgraph/types.mjs.map +1 -1
  31. package/dist/langgraph.cjs +6 -1
  32. package/dist/langgraph.d.cts +4 -3
  33. package/dist/langgraph.d.mts +4 -3
  34. package/dist/langgraph.mjs +4 -3
  35. package/package.json +6 -6
  36. package/src/langchain.ts +4 -0
  37. package/src/langgraph/__tests__/middleware.test.ts +611 -0
  38. package/src/langgraph/__tests__/state-schema.test.ts +85 -0
  39. package/src/langgraph/__tests__/utils.test.ts +254 -0
  40. package/src/langgraph/index.ts +1 -0
  41. package/src/langgraph/middleware.ts +210 -15
  42. package/src/langgraph/state-schema.ts +34 -0
  43. package/src/langgraph/types.ts +57 -0
@@ -3,231 +3,320 @@ import * as _langchain_core_messages0 from "@langchain/core/messages";
3
3
  import * as langchain from "langchain";
4
4
 
5
5
  //#region src/langgraph/types.d.ts
6
+ interface StandardSerializableSchema<Input, Output = Input> {
7
+ readonly "~standard": {
8
+ readonly version: 1;
9
+ readonly vendor: string;
10
+ readonly validate: (value: unknown) => {
11
+ value: Output;
12
+ } | {
13
+ issues: ReadonlyArray<{
14
+ message: string;
15
+ }>;
16
+ };
17
+ readonly types?: {
18
+ readonly input: Input;
19
+ readonly output: Output;
20
+ };
21
+ readonly jsonSchema: {
22
+ readonly input: (options: {
23
+ target: string;
24
+ }) => Record<string, unknown>;
25
+ readonly output: (options: {
26
+ target: string;
27
+ }) => Record<string, unknown>;
28
+ };
29
+ };
30
+ }
6
31
  declare const CopilotKitPropertiesAnnotation: _langchain_langgraph0.AnnotationRoot<{
7
32
  actions: {
33
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
8
34
  (): _langchain_langgraph0.LastValue<any[]>;
9
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
10
35
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
11
36
  };
12
37
  context: {
13
- (): _langchain_langgraph0.LastValue<{
14
- description: string;
15
- value: string;
16
- }[]>;
17
38
  (annotation: _langchain_langgraph0.SingleReducer<{
18
39
  description: string;
19
40
  value: string;
20
41
  }[], {
21
42
  description: string;
22
43
  value: string;
23
- }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
44
+ }[]>): _langchain_langgraph0.BaseChannel<{
24
45
  description: string;
25
46
  value: string;
26
47
  }[], {
27
48
  description: string;
28
49
  value: string;
50
+ }[] | _langchain_langgraph0.OverwriteValue<{
51
+ description: string;
52
+ value: string;
53
+ }[]>, unknown>;
54
+ (): _langchain_langgraph0.LastValue<{
55
+ description: string;
56
+ value: string;
29
57
  }[]>;
30
58
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
31
59
  };
32
60
  interceptedToolCalls: {
61
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
33
62
  (): _langchain_langgraph0.LastValue<any[]>;
34
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
35
63
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
36
64
  };
37
65
  originalAIMessageId: {
66
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BaseChannel<string, string | _langchain_langgraph0.OverwriteValue<string>, unknown>;
38
67
  (): _langchain_langgraph0.LastValue<string>;
39
- (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
40
68
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
41
69
  };
42
70
  }>;
43
71
  declare const CopilotKitStateAnnotation: _langchain_langgraph0.AnnotationRoot<{
44
- messages: _langchain_langgraph0.BinaryOperatorAggregate<langchain.BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], _langchain_langgraph0.Messages>;
72
+ messages: _langchain_langgraph0.BaseChannel<langchain.BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], _langchain_langgraph0.OverwriteValue<langchain.BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | _langchain_langgraph0.Messages, unknown>;
45
73
  copilotkit: {
46
- (): _langchain_langgraph0.LastValue<_langchain_langgraph0.StateType<{
74
+ (annotation: _langchain_langgraph0.SingleReducer<_langchain_langgraph0.StateType<{
47
75
  actions: {
76
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
48
77
  (): _langchain_langgraph0.LastValue<any[]>;
49
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
50
78
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
51
79
  };
52
80
  context: {
53
- (): _langchain_langgraph0.LastValue<{
54
- description: string;
55
- value: string;
56
- }[]>;
57
81
  (annotation: _langchain_langgraph0.SingleReducer<{
58
82
  description: string;
59
83
  value: string;
60
84
  }[], {
61
85
  description: string;
62
86
  value: string;
63
- }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
87
+ }[]>): _langchain_langgraph0.BaseChannel<{
64
88
  description: string;
65
89
  value: string;
66
90
  }[], {
67
91
  description: string;
68
92
  value: string;
93
+ }[] | _langchain_langgraph0.OverwriteValue<{
94
+ description: string;
95
+ value: string;
96
+ }[]>, unknown>;
97
+ (): _langchain_langgraph0.LastValue<{
98
+ description: string;
99
+ value: string;
69
100
  }[]>;
70
101
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
71
102
  };
72
103
  interceptedToolCalls: {
104
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
73
105
  (): _langchain_langgraph0.LastValue<any[]>;
74
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
75
106
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
76
107
  };
77
108
  originalAIMessageId: {
109
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BaseChannel<string, string | _langchain_langgraph0.OverwriteValue<string>, unknown>;
78
110
  (): _langchain_langgraph0.LastValue<string>;
79
- (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
80
111
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
81
112
  };
82
- }>>;
83
- (annotation: _langchain_langgraph0.SingleReducer<_langchain_langgraph0.StateType<{
113
+ }>, _langchain_langgraph0.StateType<{
84
114
  actions: {
115
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
85
116
  (): _langchain_langgraph0.LastValue<any[]>;
86
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
87
117
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
88
118
  };
89
119
  context: {
120
+ (annotation: _langchain_langgraph0.SingleReducer<{
121
+ description: string;
122
+ value: string;
123
+ }[], {
124
+ description: string;
125
+ value: string;
126
+ }[]>): _langchain_langgraph0.BaseChannel<{
127
+ description: string;
128
+ value: string;
129
+ }[], {
130
+ description: string;
131
+ value: string;
132
+ }[] | _langchain_langgraph0.OverwriteValue<{
133
+ description: string;
134
+ value: string;
135
+ }[]>, unknown>;
90
136
  (): _langchain_langgraph0.LastValue<{
91
137
  description: string;
92
138
  value: string;
93
139
  }[]>;
140
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
141
+ };
142
+ interceptedToolCalls: {
143
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
144
+ (): _langchain_langgraph0.LastValue<any[]>;
145
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
146
+ };
147
+ originalAIMessageId: {
148
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BaseChannel<string, string | _langchain_langgraph0.OverwriteValue<string>, unknown>;
149
+ (): _langchain_langgraph0.LastValue<string>;
150
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
151
+ };
152
+ }>>): _langchain_langgraph0.BaseChannel<_langchain_langgraph0.StateType<{
153
+ actions: {
154
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
155
+ (): _langchain_langgraph0.LastValue<any[]>;
156
+ Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
157
+ };
158
+ context: {
94
159
  (annotation: _langchain_langgraph0.SingleReducer<{
95
160
  description: string;
96
161
  value: string;
97
162
  }[], {
98
163
  description: string;
99
164
  value: string;
100
- }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
165
+ }[]>): _langchain_langgraph0.BaseChannel<{
101
166
  description: string;
102
167
  value: string;
103
168
  }[], {
104
169
  description: string;
105
170
  value: string;
171
+ }[] | _langchain_langgraph0.OverwriteValue<{
172
+ description: string;
173
+ value: string;
174
+ }[]>, unknown>;
175
+ (): _langchain_langgraph0.LastValue<{
176
+ description: string;
177
+ value: string;
106
178
  }[]>;
107
179
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
108
180
  };
109
181
  interceptedToolCalls: {
182
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
110
183
  (): _langchain_langgraph0.LastValue<any[]>;
111
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
112
184
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
113
185
  };
114
186
  originalAIMessageId: {
187
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BaseChannel<string, string | _langchain_langgraph0.OverwriteValue<string>, unknown>;
115
188
  (): _langchain_langgraph0.LastValue<string>;
116
- (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
117
189
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
118
190
  };
119
191
  }>, _langchain_langgraph0.StateType<{
120
192
  actions: {
193
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
121
194
  (): _langchain_langgraph0.LastValue<any[]>;
122
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
123
195
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
124
196
  };
125
197
  context: {
126
- (): _langchain_langgraph0.LastValue<{
127
- description: string;
128
- value: string;
129
- }[]>;
130
198
  (annotation: _langchain_langgraph0.SingleReducer<{
131
199
  description: string;
132
200
  value: string;
133
201
  }[], {
134
202
  description: string;
135
203
  value: string;
136
- }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
204
+ }[]>): _langchain_langgraph0.BaseChannel<{
137
205
  description: string;
138
206
  value: string;
139
207
  }[], {
140
208
  description: string;
141
209
  value: string;
210
+ }[] | _langchain_langgraph0.OverwriteValue<{
211
+ description: string;
212
+ value: string;
213
+ }[]>, unknown>;
214
+ (): _langchain_langgraph0.LastValue<{
215
+ description: string;
216
+ value: string;
142
217
  }[]>;
143
218
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
144
219
  };
145
220
  interceptedToolCalls: {
221
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
146
222
  (): _langchain_langgraph0.LastValue<any[]>;
147
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
148
223
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
149
224
  };
150
225
  originalAIMessageId: {
226
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BaseChannel<string, string | _langchain_langgraph0.OverwriteValue<string>, unknown>;
151
227
  (): _langchain_langgraph0.LastValue<string>;
152
- (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
153
228
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
154
229
  };
155
- }>>): _langchain_langgraph0.BinaryOperatorAggregate<_langchain_langgraph0.StateType<{
230
+ }> | _langchain_langgraph0.OverwriteValue<_langchain_langgraph0.StateType<{
156
231
  actions: {
232
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
157
233
  (): _langchain_langgraph0.LastValue<any[]>;
158
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
159
234
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
160
235
  };
161
236
  context: {
162
- (): _langchain_langgraph0.LastValue<{
163
- description: string;
164
- value: string;
165
- }[]>;
166
237
  (annotation: _langchain_langgraph0.SingleReducer<{
167
238
  description: string;
168
239
  value: string;
169
240
  }[], {
170
241
  description: string;
171
242
  value: string;
172
- }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
243
+ }[]>): _langchain_langgraph0.BaseChannel<{
173
244
  description: string;
174
245
  value: string;
175
246
  }[], {
176
247
  description: string;
177
248
  value: string;
249
+ }[] | _langchain_langgraph0.OverwriteValue<{
250
+ description: string;
251
+ value: string;
252
+ }[]>, unknown>;
253
+ (): _langchain_langgraph0.LastValue<{
254
+ description: string;
255
+ value: string;
178
256
  }[]>;
179
257
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
180
258
  };
181
259
  interceptedToolCalls: {
260
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
182
261
  (): _langchain_langgraph0.LastValue<any[]>;
183
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
184
262
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
185
263
  };
186
264
  originalAIMessageId: {
265
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BaseChannel<string, string | _langchain_langgraph0.OverwriteValue<string>, unknown>;
187
266
  (): _langchain_langgraph0.LastValue<string>;
188
- (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
189
267
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
190
268
  };
191
- }>, _langchain_langgraph0.StateType<{
269
+ }>>, unknown>;
270
+ (): _langchain_langgraph0.LastValue<_langchain_langgraph0.StateType<{
192
271
  actions: {
272
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
193
273
  (): _langchain_langgraph0.LastValue<any[]>;
194
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
195
274
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
196
275
  };
197
276
  context: {
198
- (): _langchain_langgraph0.LastValue<{
199
- description: string;
200
- value: string;
201
- }[]>;
202
277
  (annotation: _langchain_langgraph0.SingleReducer<{
203
278
  description: string;
204
279
  value: string;
205
280
  }[], {
206
281
  description: string;
207
282
  value: string;
208
- }[]>): _langchain_langgraph0.BinaryOperatorAggregate<{
283
+ }[]>): _langchain_langgraph0.BaseChannel<{
209
284
  description: string;
210
285
  value: string;
211
286
  }[], {
212
287
  description: string;
213
288
  value: string;
289
+ }[] | _langchain_langgraph0.OverwriteValue<{
290
+ description: string;
291
+ value: string;
292
+ }[]>, unknown>;
293
+ (): _langchain_langgraph0.LastValue<{
294
+ description: string;
295
+ value: string;
214
296
  }[]>;
215
297
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
216
298
  };
217
299
  interceptedToolCalls: {
300
+ (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BaseChannel<any[], any[] | _langchain_langgraph0.OverwriteValue<any[]>, unknown>;
218
301
  (): _langchain_langgraph0.LastValue<any[]>;
219
- (annotation: _langchain_langgraph0.SingleReducer<any[], any[]>): _langchain_langgraph0.BinaryOperatorAggregate<any[], any[]>;
220
302
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
221
303
  };
222
304
  originalAIMessageId: {
305
+ (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BaseChannel<string, string | _langchain_langgraph0.OverwriteValue<string>, unknown>;
223
306
  (): _langchain_langgraph0.LastValue<string>;
224
- (annotation: _langchain_langgraph0.SingleReducer<string, string>): _langchain_langgraph0.BinaryOperatorAggregate<string, string>;
225
307
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
226
308
  };
227
309
  }>>;
228
310
  Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => _langchain_langgraph0.AnnotationRoot<S>;
229
311
  };
230
312
  }>;
313
+ /**
314
+ * Standard Schema describing the `copilotkit` field on agent state.
315
+ *
316
+ * CopilotKit populates these fields at runtime, so the schema accepts any
317
+ * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.
318
+ */
319
+ declare const CopilotKitPropertiesSchema: StandardSerializableSchema<typeof CopilotKitPropertiesAnnotation.State>;
231
320
  interface IntermediateStateConfig {
232
321
  stateKey: string;
233
322
  tool: string;
@@ -242,5 +331,5 @@ interface OptionsConfig {
242
331
  type CopilotKitState = typeof CopilotKitStateAnnotation.State;
243
332
  type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;
244
333
  //#endregion
245
- export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig };
334
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema };
246
335
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/langgraph/types.ts"],"mappings":";;;;;cAEa,8BAAA,wBAA8B,cAAA;;QAKzC,qBAAA,CAAA,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,yBAAA,wBAAyB,cAAA;2HAGpC,yBAAA,CAAA,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAEe,uBAAA;EACf,QAAA;EACA,IAAA;EACA,YAAA;AAAA;AAAA,UAGe,aAAA;EACf,aAAA;EACA,YAAA;EACA,OAAA;EACA,qBAAA,GAAwB,uBAAA;AAAA;AAAA,KAGd,eAAA,UAAyB,yBAAA,CAA0B,KAAA;AAAA,KACnD,oBAAA,UAA8B,8BAAA,CAA+B,KAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/langgraph/types.ts"],"mappings":";;;;;UAEiB,0BAAA,iBAA2C,KAAA;EAAA,SACjD,WAAA;IAAA,SACE,OAAA;IAAA,SACA,MAAA;IAAA,SACA,QAAA,GACP,KAAA;MACK,KAAA,EAAO,MAAA;IAAA;MAAa,MAAA,EAAQ,aAAA;QAAgB,OAAA;MAAA;IAAA;IAAA,SAC1C,KAAA;MAAA,SAAmB,KAAA,EAAO,KAAA;MAAA,SAAgB,MAAA,EAAQ,MAAA;IAAA;IAAA,SAClD,UAAA;MAAA,SACE,KAAA,GAAQ,OAAA;QAAW,MAAA;MAAA,MAAqB,MAAA;MAAA,SACxC,MAAA,GAAS,OAAA;QAAW,MAAA;MAAA,MAAqB,MAAA;IAAA;EAAA;AAAA;AAAA,cAK3C,8BAAA,wBAA8B,cAAA;;iBAKzC,qBAAA,CAAA,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,yBAAA,wBAAyB,cAAA;+GAGpC,yBAAA,CAAA,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4BW,0BAAA,EAA4B,0BAAA,QAChC,8BAAA,CAA+B,KAAA;AAAA,UAevB,uBAAA;EACf,QAAA;EACA,IAAA;EACA,YAAA;AAAA;AAAA,UAGe,aAAA;EACf,aAAA;EACA,YAAA;EACA,OAAA;EACA,qBAAA,GAAwB,uBAAA;AAAA;AAAA,KAGd,eAAA,UAAyB,yBAAA,CAA0B,KAAA;AAAA,KACnD,oBAAA,UAA8B,8BAAA,CAA+B,KAAA"}
@@ -11,7 +11,47 @@ const CopilotKitStateAnnotation = Annotation.Root({
11
11
  copilotkit: Annotation,
12
12
  ...MessagesAnnotation.spec
13
13
  });
14
+ const COPILOTKIT_PROPERTIES_JSON_SCHEMA = {
15
+ type: "object",
16
+ properties: {
17
+ actions: {
18
+ type: "array",
19
+ items: {}
20
+ },
21
+ context: {
22
+ type: "array",
23
+ items: {
24
+ type: "object",
25
+ properties: {
26
+ description: { type: "string" },
27
+ value: { type: "string" }
28
+ },
29
+ required: ["description", "value"]
30
+ }
31
+ },
32
+ interceptedToolCalls: {
33
+ type: "array",
34
+ items: {}
35
+ },
36
+ originalAIMessageId: { type: "string" }
37
+ }
38
+ };
39
+ /**
40
+ * Standard Schema describing the `copilotkit` field on agent state.
41
+ *
42
+ * CopilotKit populates these fields at runtime, so the schema accepts any
43
+ * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.
44
+ */
45
+ const CopilotKitPropertiesSchema = { "~standard": {
46
+ version: 1,
47
+ vendor: "@copilotkit/sdk-js",
48
+ validate: (value) => ({ value }),
49
+ jsonSchema: {
50
+ input: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,
51
+ output: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA
52
+ }
53
+ } };
14
54
 
15
55
  //#endregion
16
- export { CopilotKitPropertiesAnnotation, CopilotKitStateAnnotation };
56
+ export { CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitStateAnnotation };
17
57
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","names":[],"sources":["../../src/langgraph/types.ts"],"sourcesContent":["import { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n context: Annotation<{ description: string; value: string }[]>,\n interceptedToolCalls: Annotation<any[]>,\n originalAIMessageId: Annotation<string>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,\n ...MessagesAnnotation.spec,\n});\n\nexport interface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\nexport interface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport type CopilotKitState = typeof CopilotKitStateAnnotation.State;\nexport type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;\n"],"mappings":";;;AAEA,MAAa,iCAAiC,WAAW,KAAK;CAC5D,SAAS;CACT,SAAS;CACT,sBAAsB;CACtB,qBAAqB;CACtB,CAAC;AAEF,MAAa,4BAA4B,WAAW,KAAK;CACvD,YAAY;CACZ,GAAG,mBAAmB;CACvB,CAAC"}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../../src/langgraph/types.ts"],"sourcesContent":["import { Annotation, MessagesAnnotation } from \"@langchain/langgraph\";\n\nexport interface StandardSerializableSchema<Input, Output = Input> {\n readonly \"~standard\": {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: unknown,\n ) => { value: Output } | { issues: ReadonlyArray<{ message: string }> };\n readonly types?: { readonly input: Input; readonly output: Output };\n readonly jsonSchema: {\n readonly input: (options: { target: string }) => Record<string, unknown>;\n readonly output: (options: { target: string }) => Record<string, unknown>;\n };\n };\n}\n\nexport const CopilotKitPropertiesAnnotation = Annotation.Root({\n actions: Annotation<any[]>,\n context: Annotation<{ description: string; value: string }[]>,\n interceptedToolCalls: Annotation<any[]>,\n originalAIMessageId: Annotation<string>,\n});\n\nexport const CopilotKitStateAnnotation = Annotation.Root({\n copilotkit: Annotation<typeof CopilotKitPropertiesAnnotation.State>,\n ...MessagesAnnotation.spec,\n});\n\nconst COPILOTKIT_PROPERTIES_JSON_SCHEMA = {\n type: \"object\",\n properties: {\n actions: { type: \"array\", items: {} },\n context: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n description: { type: \"string\" },\n value: { type: \"string\" },\n },\n required: [\"description\", \"value\"],\n },\n },\n interceptedToolCalls: { type: \"array\", items: {} },\n originalAIMessageId: { type: \"string\" },\n },\n};\n\n/**\n * Standard Schema describing the `copilotkit` field on agent state.\n *\n * CopilotKit populates these fields at runtime, so the schema accepts any\n * input shape. Use it with `new StateSchema({ ...CopilotKitStateSchema.fields })`.\n */\nexport const CopilotKitPropertiesSchema: StandardSerializableSchema<\n typeof CopilotKitPropertiesAnnotation.State\n> = {\n \"~standard\": {\n version: 1,\n vendor: \"@copilotkit/sdk-js\",\n validate: (value) => ({\n value: value as typeof CopilotKitPropertiesAnnotation.State,\n }),\n jsonSchema: {\n input: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,\n output: () => COPILOTKIT_PROPERTIES_JSON_SCHEMA,\n },\n },\n};\n\nexport interface IntermediateStateConfig {\n stateKey: string;\n tool: string;\n toolArgument?: string;\n}\n\nexport interface OptionsConfig {\n emitToolCalls?: boolean | string | string[];\n emitMessages?: boolean;\n emitAll?: boolean;\n emitIntermediateState?: IntermediateStateConfig[];\n}\n\nexport type CopilotKitState = typeof CopilotKitStateAnnotation.State;\nexport type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;\n"],"mappings":";;;AAiBA,MAAa,iCAAiC,WAAW,KAAK;CAC5D,SAAS;CACT,SAAS;CACT,sBAAsB;CACtB,qBAAqB;CACtB,CAAC;AAEF,MAAa,4BAA4B,WAAW,KAAK;CACvD,YAAY;CACZ,GAAG,mBAAmB;CACvB,CAAC;AAEF,MAAM,oCAAoC;CACxC,MAAM;CACN,YAAY;EACV,SAAS;GAAE,MAAM;GAAS,OAAO,EAAE;GAAE;EACrC,SAAS;GACP,MAAM;GACN,OAAO;IACL,MAAM;IACN,YAAY;KACV,aAAa,EAAE,MAAM,UAAU;KAC/B,OAAO,EAAE,MAAM,UAAU;KAC1B;IACD,UAAU,CAAC,eAAe,QAAQ;IACnC;GACF;EACD,sBAAsB;GAAE,MAAM;GAAS,OAAO,EAAE;GAAE;EAClD,qBAAqB,EAAE,MAAM,UAAU;EACxC;CACF;;;;;;;AAQD,MAAa,6BAET,EACF,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,WAAW,EACb,OACR;CACD,YAAY;EACV,aAAa;EACb,cAAc;EACf;CACF,EACF"}
@@ -2,9 +2,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_types = require('./langgraph/types.cjs');
3
3
  const require_utils = require('./langgraph/utils.cjs');
4
4
  const require_middleware = require('./langgraph/middleware.cjs');
5
+ const require_state_schema = require('./langgraph/state-schema.cjs');
5
6
 
6
7
  exports.CopilotKitPropertiesAnnotation = require_types.CopilotKitPropertiesAnnotation;
8
+ exports.CopilotKitPropertiesSchema = require_types.CopilotKitPropertiesSchema;
7
9
  exports.CopilotKitStateAnnotation = require_types.CopilotKitStateAnnotation;
10
+ exports.CopilotKitStateSchema = require_state_schema.CopilotKitStateSchema;
8
11
  exports.convertActionToDynamicStructuredTool = require_utils.convertActionToDynamicStructuredTool;
9
12
  exports.convertActionsToDynamicStructuredTools = require_utils.convertActionsToDynamicStructuredTools;
10
13
  exports.copilotKitInterrupt = require_utils.copilotKitInterrupt;
@@ -13,4 +16,6 @@ exports.copilotkitEmitMessage = require_utils.copilotkitEmitMessage;
13
16
  exports.copilotkitEmitState = require_utils.copilotkitEmitState;
14
17
  exports.copilotkitEmitToolCall = require_utils.copilotkitEmitToolCall;
15
18
  exports.copilotkitExit = require_utils.copilotkitExit;
16
- exports.copilotkitMiddleware = require_middleware.copilotkitMiddleware;
19
+ exports.copilotkitMiddleware = require_middleware.copilotkitMiddleware;
20
+ exports.createCopilotkitMiddleware = require_middleware.createCopilotkitMiddleware;
21
+ exports.zodState = require_middleware.zodState;
@@ -1,4 +1,5 @@
1
- import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig } from "./langgraph/types.cjs";
1
+ import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema } from "./langgraph/types.cjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.cjs";
3
- import { copilotkitMiddleware } from "./langgraph/middleware.cjs";
4
- export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
3
+ import { ExposeStateOption, copilotkitMiddleware, createCopilotkitMiddleware, zodState } from "./langgraph/middleware.cjs";
4
+ import { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema } from "./langgraph/state-schema.cjs";
5
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitState, CopilotKitStateAnnotation, CopilotKitStateSchema, ExposeStateOption, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware, createCopilotkitMiddleware, zodState };
@@ -1,4 +1,5 @@
1
- import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig } from "./langgraph/types.mjs";
1
+ import { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema } from "./langgraph/types.mjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.mjs";
3
- import { copilotkitMiddleware } from "./langgraph/middleware.mjs";
4
- export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitState, CopilotKitStateAnnotation, IntermediateStateConfig, OptionsConfig, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
3
+ import { ExposeStateOption, copilotkitMiddleware, createCopilotkitMiddleware, zodState } from "./langgraph/middleware.mjs";
4
+ import { CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitStateSchema } from "./langgraph/state-schema.mjs";
5
+ export { CopilotKitProperties, CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitSchemaState, CopilotKitSchemaUpdate, CopilotKitState, CopilotKitStateAnnotation, CopilotKitStateSchema, ExposeStateOption, IntermediateStateConfig, OptionsConfig, StandardSerializableSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware, createCopilotkitMiddleware, zodState };
@@ -1,5 +1,6 @@
1
- import { CopilotKitPropertiesAnnotation, CopilotKitStateAnnotation } from "./langgraph/types.mjs";
1
+ import { CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitStateAnnotation } from "./langgraph/types.mjs";
2
2
  import { convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit } from "./langgraph/utils.mjs";
3
- import { copilotkitMiddleware } from "./langgraph/middleware.mjs";
3
+ import { copilotkitMiddleware, createCopilotkitMiddleware, zodState } from "./langgraph/middleware.mjs";
4
+ import { CopilotKitStateSchema } from "./langgraph/state-schema.mjs";
4
5
 
5
- export { CopilotKitPropertiesAnnotation, CopilotKitStateAnnotation, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware };
6
+ export { CopilotKitPropertiesAnnotation, CopilotKitPropertiesSchema, CopilotKitStateAnnotation, CopilotKitStateSchema, convertActionToDynamicStructuredTool, convertActionsToDynamicStructuredTools, copilotKitInterrupt, copilotkitCustomizeConfig, copilotkitEmitMessage, copilotkitEmitState, copilotkitEmitToolCall, copilotkitExit, copilotkitMiddleware, createCopilotkitMiddleware, zodState };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/sdk-js",
3
- "version": "1.56.2",
3
+ "version": "1.56.4-canary.1777529757",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "ai",
@@ -48,18 +48,18 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@ag-ui/langgraph": "0.0.29",
52
- "@copilotkit/shared": "1.56.2"
51
+ "@ag-ui/langgraph": "0.0.31",
52
+ "@copilotkit/shared": "1.56.4-canary.1777529757"
53
53
  },
54
54
  "devDependencies": {
55
- "@langchain/core": "^1.1.8",
56
- "@langchain/langgraph": "^1.0.7",
55
+ "@langchain/core": "^1.1.41",
56
+ "@langchain/langgraph": "^1.2.9",
57
57
  "@swc/core": "1.5.28",
58
58
  "@types/express": "^4.17.21",
59
59
  "@types/node": "^18.11.17",
60
60
  "@whatwg-node/server": "^0.9.34",
61
61
  "eslint": "^8.56.0",
62
- "langchain": "^1.2.3",
62
+ "langchain": "^1.3.4",
63
63
  "nodemon": "^3.1.3",
64
64
  "ts-node": "^10.9.2",
65
65
  "tsdown": "^0.20.3",
package/src/langchain.ts CHANGED
@@ -4,8 +4,12 @@ console.warn(
4
4
 
5
5
  export {
6
6
  CopilotKitPropertiesAnnotation,
7
+ CopilotKitPropertiesSchema,
7
8
  CopilotKitStateAnnotation,
9
+ CopilotKitStateSchema,
8
10
  type CopilotKitState,
11
+ type CopilotKitSchemaState,
12
+ type CopilotKitSchemaUpdate,
9
13
  type CopilotKitProperties,
10
14
  copilotkitCustomizeConfig as copilotKitCustomizeConfig,
11
15
  copilotkitExit as copilotKitExit,