@copilotkit/runtime 1.6.0-next.7 → 1.6.0-next.8
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 +11 -0
- package/dist/{chunk-SAHKR6PK.mjs → chunk-C7VKUXWC.mjs} +36 -6
- package/dist/chunk-C7VKUXWC.mjs.map +1 -0
- package/dist/{chunk-LVJSZOFH.mjs → chunk-CC5KHDCV.mjs} +2 -2
- package/dist/{chunk-DV4VS5ER.mjs → chunk-DI2VJM3I.mjs} +2 -2
- package/dist/{chunk-LTUE24TH.mjs → chunk-LR7HA4X5.mjs} +2 -2
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/lib/index.js +35 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +4 -4
- package/dist/lib/integrations/index.js +1 -1
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.js +1 -1
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +2 -2
- package/dist/lib/integrations/node-express/index.js +1 -1
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +2 -2
- package/dist/lib/integrations/node-http/index.js +1 -1
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/package.json +2 -2
- package/src/lib/runtime/remote-lg-action.ts +33 -1
- package/dist/chunk-SAHKR6PK.mjs.map +0 -1
- /package/dist/{chunk-LVJSZOFH.mjs.map → chunk-CC5KHDCV.mjs.map} +0 -0
- /package/dist/{chunk-DV4VS5ER.mjs.map → chunk-DI2VJM3I.mjs.map} +0 -0
- /package/dist/{chunk-LTUE24TH.mjs.map → chunk-LR7HA4X5.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.6.0-next.
|
|
12
|
+
"version": "1.6.0-next.8",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"rxjs": "^7.8.1",
|
|
60
60
|
"type-graphql": "2.0.0-rc.1",
|
|
61
61
|
"zod": "^3.23.3",
|
|
62
|
-
"@copilotkit/shared": "1.6.0-next.
|
|
62
|
+
"@copilotkit/shared": "1.6.0-next.8"
|
|
63
63
|
},
|
|
64
64
|
"keywords": [
|
|
65
65
|
"copilotkit",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client as LangGraphClient } from "@langchain/langgraph-sdk";
|
|
1
|
+
import { AssistantGraph, Client as LangGraphClient, GraphSchema } from "@langchain/langgraph-sdk";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { isValidUUID, randomUUID } from "@copilotkit/shared";
|
|
4
4
|
import { parse as parsePartialJson } from "partial-json";
|
|
@@ -204,6 +204,15 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
204
204
|
await client.assistants.update(assistantId, { config: { configurable } });
|
|
205
205
|
}
|
|
206
206
|
const graphInfo = await client.assistants.getGraph(assistantId);
|
|
207
|
+
const graphSchema = await client.assistants.getSchemas(assistantId);
|
|
208
|
+
const schemaKeys = getSchemaKeys(graphSchema);
|
|
209
|
+
|
|
210
|
+
// Do not input keys that are not part of the input schema
|
|
211
|
+
if (payload.input && schemaKeys.input) {
|
|
212
|
+
payload.input = Object.fromEntries(
|
|
213
|
+
Object.entries(payload.input).filter(([key]) => schemaKeys.input.includes(key)),
|
|
214
|
+
);
|
|
215
|
+
}
|
|
207
216
|
|
|
208
217
|
let streamingStateExtractor = new StreamingStateExtractor([]);
|
|
209
218
|
let prevNodeName = null;
|
|
@@ -330,6 +339,7 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
330
339
|
state: manuallyEmittedState,
|
|
331
340
|
running: true,
|
|
332
341
|
active: true,
|
|
342
|
+
schemaKeys,
|
|
333
343
|
}),
|
|
334
344
|
);
|
|
335
345
|
continue;
|
|
@@ -380,6 +390,7 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
380
390
|
state,
|
|
381
391
|
running: true,
|
|
382
392
|
active: !exitingNode,
|
|
393
|
+
schemaKeys,
|
|
383
394
|
}),
|
|
384
395
|
);
|
|
385
396
|
}
|
|
@@ -404,6 +415,7 @@ async function streamEvents(controller: ReadableStreamDefaultController, args: E
|
|
|
404
415
|
running: !shouldExit,
|
|
405
416
|
active: false,
|
|
406
417
|
includeMessages: true,
|
|
418
|
+
schemaKeys,
|
|
407
419
|
}),
|
|
408
420
|
);
|
|
409
421
|
|
|
@@ -427,6 +439,7 @@ function getStateSyncEvent({
|
|
|
427
439
|
running,
|
|
428
440
|
active,
|
|
429
441
|
includeMessages = false,
|
|
442
|
+
schemaKeys,
|
|
430
443
|
}: {
|
|
431
444
|
threadId: string;
|
|
432
445
|
runId: string;
|
|
@@ -436,6 +449,7 @@ function getStateSyncEvent({
|
|
|
436
449
|
running: boolean;
|
|
437
450
|
active: boolean;
|
|
438
451
|
includeMessages?: boolean;
|
|
452
|
+
schemaKeys: { input: string[] | null; output: string[] | null };
|
|
439
453
|
}): string {
|
|
440
454
|
if (!includeMessages) {
|
|
441
455
|
state = Object.keys(state).reduce((acc, key) => {
|
|
@@ -451,6 +465,13 @@ function getStateSyncEvent({
|
|
|
451
465
|
};
|
|
452
466
|
}
|
|
453
467
|
|
|
468
|
+
// Do not emit state keys that are not part of the output schema
|
|
469
|
+
if (schemaKeys.output) {
|
|
470
|
+
state = Object.fromEntries(
|
|
471
|
+
Object.entries(state).filter(([key]) => schemaKeys.output.includes(key)),
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
|
|
454
475
|
return (
|
|
455
476
|
JSON.stringify({
|
|
456
477
|
event: LangGraphEventTypes.OnCopilotKitStateSync,
|
|
@@ -739,3 +760,14 @@ function copilotkitMessagesToLangChain(messages: Message[]): LangGraphPlatformMe
|
|
|
739
760
|
|
|
740
761
|
return result;
|
|
741
762
|
}
|
|
763
|
+
|
|
764
|
+
function getSchemaKeys(graphSchema: GraphSchema) {
|
|
765
|
+
const CONSTANT_KEYS = ["messages", "copilotkit"];
|
|
766
|
+
const inputSchema = Object.keys(graphSchema.input_schema.properties);
|
|
767
|
+
const outputSchema = Object.keys(graphSchema.output_schema.properties);
|
|
768
|
+
|
|
769
|
+
return {
|
|
770
|
+
input: inputSchema && inputSchema.length ? [...inputSchema, ...CONSTANT_KEYS] : null,
|
|
771
|
+
output: outputSchema && outputSchema.length ? [...outputSchema, ...CONSTANT_KEYS] : null,
|
|
772
|
+
};
|
|
773
|
+
}
|