@copilotkit/runtime 1.6.0-next.7 → 1.6.0-next.9
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 +18 -0
- package/dist/{chunk-LVJSZOFH.mjs → chunk-4HQ5OZXN.mjs} +2 -2
- package/dist/{chunk-LTUE24TH.mjs → chunk-5ZBUMQE2.mjs} +2 -2
- package/dist/{chunk-DV4VS5ER.mjs → chunk-7BCFHZLY.mjs} +2 -2
- package/dist/{chunk-SAHKR6PK.mjs → chunk-L7OTGCAG.mjs} +46 -12
- package/dist/chunk-L7OTGCAG.mjs.map +1 -0
- package/dist/index.js +45 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/lib/index.js +45 -11
- 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/agents/langgraph/event-source.ts +13 -4
- package/src/lib/runtime/copilot-runtime.ts +1 -1
- 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-4HQ5OZXN.mjs.map} +0 -0
- /package/dist/{chunk-LTUE24TH.mjs.map → chunk-5ZBUMQE2.mjs.map} +0 -0
- /package/dist/{chunk-DV4VS5ER.mjs.map → chunk-7BCFHZLY.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
config,
|
|
4
4
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
5
5
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7BCFHZLY.mjs";
|
|
7
7
|
import {
|
|
8
8
|
copilotRuntimeNestEndpoint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-5ZBUMQE2.mjs";
|
|
10
10
|
import {
|
|
11
11
|
copilotRuntimeNodeExpressEndpoint
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4HQ5OZXN.mjs";
|
|
13
13
|
import {
|
|
14
14
|
CopilotRuntime,
|
|
15
15
|
addCustomHeaderPlugin,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
getCommonConfig,
|
|
22
22
|
langGraphPlatformEndpoint,
|
|
23
23
|
resolveEndpointType
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-L7OTGCAG.mjs";
|
|
25
25
|
import {
|
|
26
26
|
AnthropicAdapter,
|
|
27
27
|
EmptyAdapter,
|
package/dist/lib/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
publishConfig: {
|
|
45
45
|
access: "public"
|
|
46
46
|
},
|
|
47
|
-
version: "1.6.0-next.
|
|
47
|
+
version: "1.6.0-next.9",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -1357,10 +1357,15 @@ var RemoteLangGraphEventSource = class {
|
|
|
1357
1357
|
acc.lastMessageId = this.getCurrentMessageId(event) ?? acc.lastMessageId;
|
|
1358
1358
|
const toolCallChunks = this.getCurrentToolCallChunks(event) ?? [];
|
|
1359
1359
|
const responseMetadata = this.getResponseMetadata(event);
|
|
1360
|
+
const toolCallCheck = toolCallChunks && toolCallChunks.length > 0;
|
|
1361
|
+
let isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
|
|
1360
1362
|
acc.isToolCallStart = toolCallChunks.some((chunk) => chunk.name && chunk.id);
|
|
1361
1363
|
acc.isMessageStart = prevMessageId !== acc.lastMessageId && !acc.isToolCallStart;
|
|
1362
|
-
acc.isToolCall
|
|
1363
|
-
|
|
1364
|
+
if (acc.isToolCall && !toolCallCheck) {
|
|
1365
|
+
isToolCallEnd = true;
|
|
1366
|
+
}
|
|
1367
|
+
acc.isToolCall = toolCallCheck;
|
|
1368
|
+
acc.isToolCallEnd = isToolCallEnd;
|
|
1364
1369
|
acc.isMessageEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop";
|
|
1365
1370
|
({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find((chunk) => chunk.name && chunk.id) ?? {
|
|
1366
1371
|
name: acc.lastToolCallName,
|
|
@@ -1408,13 +1413,12 @@ var RemoteLangGraphEventSource = class {
|
|
|
1408
1413
|
});
|
|
1409
1414
|
}
|
|
1410
1415
|
const responseMetadata = this.getResponseMetadata(acc.event);
|
|
1411
|
-
if (
|
|
1416
|
+
if (acc.isToolCallEnd && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
|
|
1412
1417
|
events.push({
|
|
1413
1418
|
type: RuntimeEventTypes.ActionExecutionEnd,
|
|
1414
1419
|
actionExecutionId: acc.lastToolCallId
|
|
1415
1420
|
});
|
|
1416
|
-
}
|
|
1417
|
-
if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
|
|
1421
|
+
} else if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
|
|
1418
1422
|
events.push({
|
|
1419
1423
|
type: RuntimeEventTypes.TextMessageEnd,
|
|
1420
1424
|
messageId: acc.lastMessageId
|
|
@@ -2283,6 +2287,11 @@ async function streamEvents(controller, args) {
|
|
|
2283
2287
|
});
|
|
2284
2288
|
}
|
|
2285
2289
|
const graphInfo = await client.assistants.getGraph(assistantId);
|
|
2290
|
+
const graphSchema = await client.assistants.getSchemas(assistantId);
|
|
2291
|
+
const schemaKeys = getSchemaKeys(graphSchema);
|
|
2292
|
+
if (payload.input && schemaKeys.input) {
|
|
2293
|
+
payload.input = Object.fromEntries(Object.entries(payload.input).filter(([key]) => schemaKeys.input.includes(key)));
|
|
2294
|
+
}
|
|
2286
2295
|
let streamingStateExtractor = new StreamingStateExtractor([]);
|
|
2287
2296
|
let prevNodeName = null;
|
|
2288
2297
|
let emitIntermediateStateUntilEnd = null;
|
|
@@ -2374,7 +2383,8 @@ async function streamEvents(controller, args) {
|
|
|
2374
2383
|
nodeName,
|
|
2375
2384
|
state: manuallyEmittedState,
|
|
2376
2385
|
running: true,
|
|
2377
|
-
active: true
|
|
2386
|
+
active: true,
|
|
2387
|
+
schemaKeys
|
|
2378
2388
|
}));
|
|
2379
2389
|
continue;
|
|
2380
2390
|
}
|
|
@@ -2406,7 +2416,8 @@ async function streamEvents(controller, args) {
|
|
|
2406
2416
|
nodeName,
|
|
2407
2417
|
state,
|
|
2408
2418
|
running: true,
|
|
2409
|
-
active: !exitingNode
|
|
2419
|
+
active: !exitingNode,
|
|
2420
|
+
schemaKeys
|
|
2410
2421
|
}));
|
|
2411
2422
|
}
|
|
2412
2423
|
emit(JSON.stringify(event) + "\n");
|
|
@@ -2424,7 +2435,8 @@ async function streamEvents(controller, args) {
|
|
|
2424
2435
|
state: state.values,
|
|
2425
2436
|
running: !shouldExit,
|
|
2426
2437
|
active: false,
|
|
2427
|
-
includeMessages: true
|
|
2438
|
+
includeMessages: true,
|
|
2439
|
+
schemaKeys
|
|
2428
2440
|
}));
|
|
2429
2441
|
return Promise.resolve();
|
|
2430
2442
|
} catch (e) {
|
|
@@ -2437,7 +2449,7 @@ async function streamEvents(controller, args) {
|
|
|
2437
2449
|
}
|
|
2438
2450
|
}
|
|
2439
2451
|
__name(streamEvents, "streamEvents");
|
|
2440
|
-
function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false }) {
|
|
2452
|
+
function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false, schemaKeys }) {
|
|
2441
2453
|
if (!includeMessages) {
|
|
2442
2454
|
state = Object.keys(state).reduce((acc, key) => {
|
|
2443
2455
|
if (key !== "messages") {
|
|
@@ -2451,6 +2463,9 @@ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, runnin
|
|
|
2451
2463
|
messages: langchainMessagesToCopilotKit(state.messages || [])
|
|
2452
2464
|
};
|
|
2453
2465
|
}
|
|
2466
|
+
if (schemaKeys.output) {
|
|
2467
|
+
state = Object.fromEntries(Object.entries(state).filter(([key]) => schemaKeys.output.includes(key)));
|
|
2468
|
+
}
|
|
2454
2469
|
return JSON.stringify({
|
|
2455
2470
|
event: LangGraphEventTypes.OnCopilotKitStateSync,
|
|
2456
2471
|
thread_id: threadId,
|
|
@@ -2685,6 +2700,25 @@ function copilotkitMessagesToLangChain(messages) {
|
|
|
2685
2700
|
return result;
|
|
2686
2701
|
}
|
|
2687
2702
|
__name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
|
|
2703
|
+
function getSchemaKeys(graphSchema) {
|
|
2704
|
+
const CONSTANT_KEYS = [
|
|
2705
|
+
"messages",
|
|
2706
|
+
"copilotkit"
|
|
2707
|
+
];
|
|
2708
|
+
const inputSchema = Object.keys(graphSchema.input_schema.properties);
|
|
2709
|
+
const outputSchema = Object.keys(graphSchema.output_schema.properties);
|
|
2710
|
+
return {
|
|
2711
|
+
input: inputSchema && inputSchema.length ? [
|
|
2712
|
+
...inputSchema,
|
|
2713
|
+
...CONSTANT_KEYS
|
|
2714
|
+
] : null,
|
|
2715
|
+
output: outputSchema && outputSchema.length ? [
|
|
2716
|
+
...outputSchema,
|
|
2717
|
+
...CONSTANT_KEYS
|
|
2718
|
+
] : null
|
|
2719
|
+
};
|
|
2720
|
+
}
|
|
2721
|
+
__name(getSchemaKeys, "getSchemaKeys");
|
|
2688
2722
|
|
|
2689
2723
|
// src/lib/runtime/remote-action-constructors.ts
|
|
2690
2724
|
var import_shared11 = require("@copilotkit/shared");
|
|
@@ -3931,7 +3965,7 @@ please use an LLM adapter instead.`
|
|
|
3931
3965
|
threadId,
|
|
3932
3966
|
runId: void 0,
|
|
3933
3967
|
eventSource,
|
|
3934
|
-
serverSideActions
|
|
3968
|
+
serverSideActions,
|
|
3935
3969
|
actionInputsWithoutAgents: allAvailableActions
|
|
3936
3970
|
};
|
|
3937
3971
|
} catch (error) {
|