@copilotkit/sdk-js 1.51.5-next.0 → 1.51.5-next.1

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 (59) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  3. package/dist/index.cjs +0 -0
  4. package/dist/index.d.cts +1 -0
  5. package/dist/index.d.mts +1 -0
  6. package/dist/index.mjs +1 -1
  7. package/dist/langchain.cjs +18 -0
  8. package/dist/langchain.cjs.map +1 -0
  9. package/dist/langchain.d.cts +3 -0
  10. package/dist/langchain.d.mts +4 -0
  11. package/dist/langchain.mjs +6 -23
  12. package/dist/langchain.mjs.map +1 -1
  13. package/dist/langgraph/middleware.cjs +139 -0
  14. package/dist/langgraph/middleware.cjs.map +1 -0
  15. package/dist/langgraph/middleware.d.cts +8 -0
  16. package/dist/langgraph/middleware.d.cts.map +1 -0
  17. package/dist/langgraph/middleware.d.mts +8 -0
  18. package/dist/langgraph/middleware.d.mts.map +1 -0
  19. package/dist/langgraph/middleware.mjs +137 -0
  20. package/dist/langgraph/middleware.mjs.map +1 -0
  21. package/dist/langgraph/types.cjs +19 -0
  22. package/dist/langgraph/types.cjs.map +1 -0
  23. package/dist/langgraph/types.d.cts +246 -0
  24. package/dist/langgraph/types.d.cts.map +1 -0
  25. package/dist/langgraph/types.d.mts +246 -0
  26. package/dist/langgraph/types.d.mts.map +1 -0
  27. package/dist/langgraph/types.mjs +17 -0
  28. package/dist/langgraph/types.mjs.map +1 -0
  29. package/dist/langgraph/utils.cjs +281 -0
  30. package/dist/langgraph/utils.cjs.map +1 -0
  31. package/dist/langgraph/utils.d.cts +192 -0
  32. package/dist/langgraph/utils.d.cts.map +1 -0
  33. package/dist/langgraph/utils.d.mts +192 -0
  34. package/dist/langgraph/utils.d.mts.map +1 -0
  35. package/dist/langgraph/utils.mjs +273 -0
  36. package/dist/langgraph/utils.mjs.map +1 -0
  37. package/dist/langgraph.cjs +16 -0
  38. package/dist/langgraph.d.cts +4 -0
  39. package/dist/langgraph.d.mts +4 -0
  40. package/dist/langgraph.mjs +5 -27
  41. package/package.json +22 -22
  42. package/tsdown.config.ts +17 -0
  43. package/vitest.config.mjs +11 -0
  44. package/dist/chunk-A7ZQHBQI.mjs +0 -505
  45. package/dist/chunk-A7ZQHBQI.mjs.map +0 -1
  46. package/dist/index.d.ts +0 -2
  47. package/dist/index.js +0 -1
  48. package/dist/index.js.map +0 -1
  49. package/dist/index.mjs.map +0 -1
  50. package/dist/langchain-db7cb6cb.d.ts +0 -427
  51. package/dist/langchain.d.ts +0 -6
  52. package/dist/langchain.js +0 -284
  53. package/dist/langchain.js.map +0 -1
  54. package/dist/langgraph/index.d.ts +0 -10
  55. package/dist/langgraph.js +0 -548
  56. package/dist/langgraph.js.map +0 -1
  57. package/dist/langgraph.mjs.map +0 -1
  58. package/jest.config.js +0 -5
  59. package/tsup.config.ts +0 -23
@@ -1,427 +0,0 @@
1
- import * as langchain from 'langchain';
2
- import * as _langchain_core_messages from '@langchain/core/messages';
3
- import * as _langchain_langgraph from '@langchain/langgraph';
4
- import { RunnableConfig } from '@langchain/core/runnables';
5
- import { DynamicStructuredTool } from '@langchain/core/tools';
6
-
7
- declare const CopilotKitPropertiesAnnotation: _langchain_langgraph.AnnotationRoot<{
8
- actions: {
9
- (): _langchain_langgraph.LastValue<any[]>;
10
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
11
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
12
- };
13
- context: {
14
- (): _langchain_langgraph.LastValue<{
15
- description: string;
16
- value: string;
17
- }[]>;
18
- (annotation: _langchain_langgraph.SingleReducer<{
19
- description: string;
20
- value: string;
21
- }[], {
22
- description: string;
23
- value: string;
24
- }[]>): _langchain_langgraph.BinaryOperatorAggregate<{
25
- description: string;
26
- value: string;
27
- }[], {
28
- description: string;
29
- value: string;
30
- }[]>;
31
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
32
- };
33
- interceptedToolCalls: {
34
- (): _langchain_langgraph.LastValue<any[]>;
35
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
36
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
37
- };
38
- originalAIMessageId: {
39
- (): _langchain_langgraph.LastValue<string>;
40
- (annotation: _langchain_langgraph.SingleReducer<string, string>): _langchain_langgraph.BinaryOperatorAggregate<string, string>;
41
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
42
- };
43
- }>;
44
- declare const CopilotKitStateAnnotation: _langchain_langgraph.AnnotationRoot<{
45
- messages: _langchain_langgraph.BinaryOperatorAggregate<langchain.BaseMessage<_langchain_core_messages.MessageStructure<_langchain_core_messages.MessageToolSet>, _langchain_core_messages.MessageType>[], _langchain_langgraph.Messages>;
46
- copilotkit: {
47
- (): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{
48
- actions: {
49
- (): _langchain_langgraph.LastValue<any[]>;
50
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
51
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
52
- };
53
- context: {
54
- (): _langchain_langgraph.LastValue<{
55
- description: string;
56
- value: string;
57
- }[]>;
58
- (annotation: _langchain_langgraph.SingleReducer<{
59
- description: string;
60
- value: string;
61
- }[], {
62
- description: string;
63
- value: string;
64
- }[]>): _langchain_langgraph.BinaryOperatorAggregate<{
65
- description: string;
66
- value: string;
67
- }[], {
68
- description: string;
69
- value: string;
70
- }[]>;
71
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
72
- };
73
- interceptedToolCalls: {
74
- (): _langchain_langgraph.LastValue<any[]>;
75
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
76
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
77
- };
78
- originalAIMessageId: {
79
- (): _langchain_langgraph.LastValue<string>;
80
- (annotation: _langchain_langgraph.SingleReducer<string, string>): _langchain_langgraph.BinaryOperatorAggregate<string, string>;
81
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
82
- };
83
- }>>;
84
- (annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{
85
- actions: {
86
- (): _langchain_langgraph.LastValue<any[]>;
87
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
88
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
89
- };
90
- context: {
91
- (): _langchain_langgraph.LastValue<{
92
- description: string;
93
- value: string;
94
- }[]>;
95
- (annotation: _langchain_langgraph.SingleReducer<{
96
- description: string;
97
- value: string;
98
- }[], {
99
- description: string;
100
- value: string;
101
- }[]>): _langchain_langgraph.BinaryOperatorAggregate<{
102
- description: string;
103
- value: string;
104
- }[], {
105
- description: string;
106
- value: string;
107
- }[]>;
108
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
109
- };
110
- interceptedToolCalls: {
111
- (): _langchain_langgraph.LastValue<any[]>;
112
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
113
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
114
- };
115
- originalAIMessageId: {
116
- (): _langchain_langgraph.LastValue<string>;
117
- (annotation: _langchain_langgraph.SingleReducer<string, string>): _langchain_langgraph.BinaryOperatorAggregate<string, string>;
118
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
119
- };
120
- }>, _langchain_langgraph.StateType<{
121
- actions: {
122
- (): _langchain_langgraph.LastValue<any[]>;
123
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
124
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
125
- };
126
- context: {
127
- (): _langchain_langgraph.LastValue<{
128
- description: string;
129
- value: string;
130
- }[]>;
131
- (annotation: _langchain_langgraph.SingleReducer<{
132
- description: string;
133
- value: string;
134
- }[], {
135
- description: string;
136
- value: string;
137
- }[]>): _langchain_langgraph.BinaryOperatorAggregate<{
138
- description: string;
139
- value: string;
140
- }[], {
141
- description: string;
142
- value: string;
143
- }[]>;
144
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
145
- };
146
- interceptedToolCalls: {
147
- (): _langchain_langgraph.LastValue<any[]>;
148
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
149
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
150
- };
151
- originalAIMessageId: {
152
- (): _langchain_langgraph.LastValue<string>;
153
- (annotation: _langchain_langgraph.SingleReducer<string, string>): _langchain_langgraph.BinaryOperatorAggregate<string, string>;
154
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
155
- };
156
- }>>): _langchain_langgraph.BinaryOperatorAggregate<_langchain_langgraph.StateType<{
157
- actions: {
158
- (): _langchain_langgraph.LastValue<any[]>;
159
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
160
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
161
- };
162
- context: {
163
- (): _langchain_langgraph.LastValue<{
164
- description: string;
165
- value: string;
166
- }[]>;
167
- (annotation: _langchain_langgraph.SingleReducer<{
168
- description: string;
169
- value: string;
170
- }[], {
171
- description: string;
172
- value: string;
173
- }[]>): _langchain_langgraph.BinaryOperatorAggregate<{
174
- description: string;
175
- value: string;
176
- }[], {
177
- description: string;
178
- value: string;
179
- }[]>;
180
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
181
- };
182
- interceptedToolCalls: {
183
- (): _langchain_langgraph.LastValue<any[]>;
184
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
185
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
186
- };
187
- originalAIMessageId: {
188
- (): _langchain_langgraph.LastValue<string>;
189
- (annotation: _langchain_langgraph.SingleReducer<string, string>): _langchain_langgraph.BinaryOperatorAggregate<string, string>;
190
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
191
- };
192
- }>, _langchain_langgraph.StateType<{
193
- actions: {
194
- (): _langchain_langgraph.LastValue<any[]>;
195
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
196
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
197
- };
198
- context: {
199
- (): _langchain_langgraph.LastValue<{
200
- description: string;
201
- value: string;
202
- }[]>;
203
- (annotation: _langchain_langgraph.SingleReducer<{
204
- description: string;
205
- value: string;
206
- }[], {
207
- description: string;
208
- value: string;
209
- }[]>): _langchain_langgraph.BinaryOperatorAggregate<{
210
- description: string;
211
- value: string;
212
- }[], {
213
- description: string;
214
- value: string;
215
- }[]>;
216
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
217
- };
218
- interceptedToolCalls: {
219
- (): _langchain_langgraph.LastValue<any[]>;
220
- (annotation: _langchain_langgraph.SingleReducer<any[], any[]>): _langchain_langgraph.BinaryOperatorAggregate<any[], any[]>;
221
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
222
- };
223
- originalAIMessageId: {
224
- (): _langchain_langgraph.LastValue<string>;
225
- (annotation: _langchain_langgraph.SingleReducer<string, string>): _langchain_langgraph.BinaryOperatorAggregate<string, string>;
226
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
227
- };
228
- }>>;
229
- Root: <S extends _langchain_langgraph.StateDefinition>(sd: S) => _langchain_langgraph.AnnotationRoot<S>;
230
- };
231
- }>;
232
- interface IntermediateStateConfig {
233
- stateKey: string;
234
- tool: string;
235
- toolArgument?: string;
236
- }
237
- interface OptionsConfig {
238
- emitToolCalls?: boolean | string | string[];
239
- emitMessages?: boolean;
240
- emitAll?: boolean;
241
- emitIntermediateState?: IntermediateStateConfig[];
242
- }
243
- type CopilotKitState = typeof CopilotKitStateAnnotation.State;
244
- type CopilotKitProperties = typeof CopilotKitPropertiesAnnotation.State;
245
-
246
- /**
247
- * Customize the LangGraph configuration for use in CopilotKit.
248
- *
249
- * To the CopilotKit SDK, run:
250
- *
251
- * ```bash
252
- * npm install @copilotkit/sdk-js
253
- * ```
254
- *
255
- * ### Examples
256
- *
257
- * Disable emitting messages and tool calls:
258
- *
259
- * ```typescript
260
- * import { copilotkitCustomizeConfig } from "@copilotkit/sdk-js";
261
- *
262
- * config = copilotkitCustomizeConfig(
263
- * config,
264
- * emitMessages=false,
265
- * emitToolCalls=false
266
- * )
267
- * ```
268
- *
269
- * To emit a tool call as streaming LangGraph state, pass the destination key in state,
270
- * the tool name and optionally the tool argument. (If you don't pass the argument name,
271
- * all arguments are emitted under the state key.)
272
- *
273
- * ```typescript
274
- * import { copilotkitCustomizeConfig } from "@copilotkit/sdk-js";
275
- *
276
- * config = copilotkitCustomizeConfig(
277
- * config,
278
- * emitIntermediateState=[
279
- * {
280
- * "stateKey": "steps",
281
- * "tool": "SearchTool",
282
- * "toolArgument": "steps",
283
- * },
284
- * ],
285
- * )
286
- * ```
287
- */
288
- declare function copilotkitCustomizeConfig(
289
- /**
290
- * The LangChain/LangGraph configuration to customize.
291
- */
292
- baseConfig: RunnableConfig,
293
- /**
294
- * Configuration options:
295
- * - `emitMessages: boolean?`
296
- * Configure how messages are emitted. By default, all messages are emitted. Pass false to
297
- * disable emitting messages.
298
- * - `emitToolCalls: boolean | string | string[]?`
299
- * Configure how tool calls are emitted. By default, all tool calls are emitted. Pass false to
300
- * disable emitting tool calls. Pass a string or list of strings to emit only specific tool calls.
301
- * - `emitIntermediateState: IntermediateStateConfig[]?`
302
- * Lets you emit tool calls as streaming LangGraph state.
303
- */
304
- options?: OptionsConfig): RunnableConfig;
305
- /**
306
- * Exits the current agent after the run completes. Calling copilotkit_exit() will
307
- * not immediately stop the agent. Instead, it signals to CopilotKit to stop the agent after
308
- * the run completes.
309
- *
310
- * ### Examples
311
- *
312
- * ```typescript
313
- * import { copilotkitExit } from "@copilotkit/sdk-js";
314
- *
315
- * async function myNode(state: Any):
316
- * await copilotkitExit(config)
317
- * return state
318
- * ```
319
- */
320
- declare function copilotkitExit(
321
- /**
322
- * The LangChain/LangGraph configuration.
323
- */
324
- config: RunnableConfig): Promise<void>;
325
- /**
326
- * Emits intermediate state to CopilotKit. Useful if you have a longer running node and you want to
327
- * update the user with the current state of the node.
328
- *
329
- * ### Examples
330
- *
331
- * ```typescript
332
- * import { copilotkitEmitState } from "@copilotkit/sdk-js";
333
- *
334
- * for (let i = 0; i < 10; i++) {
335
- * await someLongRunningOperation(i);
336
- * await copilotkitEmitState(config, { progress: i });
337
- * }
338
- * ```
339
- */
340
- declare function copilotkitEmitState(
341
- /**
342
- * The LangChain/LangGraph configuration.
343
- */
344
- config: RunnableConfig,
345
- /**
346
- * The state to emit.
347
- */
348
- state: any): Promise<void>;
349
- /**
350
- * Manually emits a message to CopilotKit. Useful in longer running nodes to update the user.
351
- * Important: You still need to return the messages from the node.
352
- *
353
- * ### Examples
354
- *
355
- * ```typescript
356
- * import { copilotkitEmitMessage } from "@copilotkit/sdk-js";
357
- *
358
- * const message = "Step 1 of 10 complete";
359
- * await copilotkitEmitMessage(config, message);
360
- *
361
- * // Return the message from the node
362
- * return {
363
- * "messages": [AIMessage(content=message)]
364
- * }
365
- * ```
366
- */
367
- declare function copilotkitEmitMessage(
368
- /**
369
- * The LangChain/LangGraph configuration.
370
- */
371
- config: RunnableConfig,
372
- /**
373
- * The message to emit.
374
- */
375
- message: string): Promise<void>;
376
- /**
377
- * Manually emits a tool call to CopilotKit.
378
- *
379
- * ### Examples
380
- *
381
- * ```typescript
382
- * import { copilotkitEmitToolCall } from "@copilotkit/sdk-js";
383
- *
384
- * await copilotkitEmitToolCall(config, name="SearchTool", args={"steps": 10})
385
- * ```
386
- */
387
- declare function copilotkitEmitToolCall(
388
- /**
389
- * The LangChain/LangGraph configuration.
390
- */
391
- config: RunnableConfig,
392
- /**
393
- * The name of the tool to emit.
394
- */
395
- name: string,
396
- /**
397
- * The arguments to emit.
398
- */
399
- args: any): Promise<void>;
400
- declare function convertActionToDynamicStructuredTool(actionInput: any): DynamicStructuredTool<any>;
401
- /**
402
- * Use this function to convert a list of actions you get from state
403
- * to a list of dynamic structured tools.
404
- *
405
- * ### Examples
406
- *
407
- * ```typescript
408
- * import { convertActionsToDynamicStructuredTools } from "@copilotkit/sdk-js";
409
- *
410
- * const tools = convertActionsToDynamicStructuredTools(state.copilotkit.actions);
411
- * ```
412
- */
413
- declare function convertActionsToDynamicStructuredTools(
414
- /**
415
- * The list of actions to convert.
416
- */
417
- actions: any[]): DynamicStructuredTool<any>[];
418
- declare function copilotKitInterrupt({ message, action, args, }: {
419
- message?: string;
420
- action?: string;
421
- args?: Record<string, any>;
422
- }): {
423
- answer: any;
424
- messages: any;
425
- };
426
-
427
- export { CopilotKitPropertiesAnnotation as C, IntermediateStateConfig as I, OptionsConfig as O, CopilotKitStateAnnotation as a, CopilotKitState as b, CopilotKitProperties as c, copilotkitCustomizeConfig as d, copilotkitExit as e, copilotkitEmitState as f, copilotkitEmitMessage as g, copilotkitEmitToolCall as h, convertActionToDynamicStructuredTool as i, convertActionsToDynamicStructuredTools as j, copilotKitInterrupt as k };
@@ -1,6 +0,0 @@
1
- export { c as CopilotKitProperties, C as CopilotKitPropertiesAnnotation, b as CopilotKitState, a as CopilotKitStateAnnotation, i as convertActionToDynamicStructuredTool, j as convertActionsToDynamicStructuredTools, d as copilotKitCustomizeConfig, g as copilotKitEmitMessage, f as copilotKitEmitState, h as copilotKitEmitToolCall, e as copilotKitExit } from './langchain-db7cb6cb.js';
2
- import 'langchain';
3
- import '@langchain/core/messages';
4
- import '@langchain/langgraph';
5
- import '@langchain/core/runnables';
6
- import '@langchain/core/tools';