@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.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",
|
|
@@ -1693,10 +1693,15 @@ var RemoteLangGraphEventSource = class {
|
|
|
1693
1693
|
acc.lastMessageId = this.getCurrentMessageId(event) ?? acc.lastMessageId;
|
|
1694
1694
|
const toolCallChunks = this.getCurrentToolCallChunks(event) ?? [];
|
|
1695
1695
|
const responseMetadata = this.getResponseMetadata(event);
|
|
1696
|
+
const toolCallCheck = toolCallChunks && toolCallChunks.length > 0;
|
|
1697
|
+
let isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
|
|
1696
1698
|
acc.isToolCallStart = toolCallChunks.some((chunk) => chunk.name && chunk.id);
|
|
1697
1699
|
acc.isMessageStart = prevMessageId !== acc.lastMessageId && !acc.isToolCallStart;
|
|
1698
|
-
acc.isToolCall
|
|
1699
|
-
|
|
1700
|
+
if (acc.isToolCall && !toolCallCheck) {
|
|
1701
|
+
isToolCallEnd = true;
|
|
1702
|
+
}
|
|
1703
|
+
acc.isToolCall = toolCallCheck;
|
|
1704
|
+
acc.isToolCallEnd = isToolCallEnd;
|
|
1700
1705
|
acc.isMessageEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop";
|
|
1701
1706
|
({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find((chunk) => chunk.name && chunk.id) ?? {
|
|
1702
1707
|
name: acc.lastToolCallName,
|
|
@@ -1744,13 +1749,12 @@ var RemoteLangGraphEventSource = class {
|
|
|
1744
1749
|
});
|
|
1745
1750
|
}
|
|
1746
1751
|
const responseMetadata = this.getResponseMetadata(acc.event);
|
|
1747
|
-
if (
|
|
1752
|
+
if (acc.isToolCallEnd && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
|
|
1748
1753
|
events.push({
|
|
1749
1754
|
type: RuntimeEventTypes.ActionExecutionEnd,
|
|
1750
1755
|
actionExecutionId: acc.lastToolCallId
|
|
1751
1756
|
});
|
|
1752
|
-
}
|
|
1753
|
-
if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
|
|
1757
|
+
} else if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
|
|
1754
1758
|
events.push({
|
|
1755
1759
|
type: RuntimeEventTypes.TextMessageEnd,
|
|
1756
1760
|
messageId: acc.lastMessageId
|
|
@@ -2619,6 +2623,11 @@ async function streamEvents(controller, args) {
|
|
|
2619
2623
|
});
|
|
2620
2624
|
}
|
|
2621
2625
|
const graphInfo = await client.assistants.getGraph(assistantId);
|
|
2626
|
+
const graphSchema = await client.assistants.getSchemas(assistantId);
|
|
2627
|
+
const schemaKeys = getSchemaKeys(graphSchema);
|
|
2628
|
+
if (payload.input && schemaKeys.input) {
|
|
2629
|
+
payload.input = Object.fromEntries(Object.entries(payload.input).filter(([key]) => schemaKeys.input.includes(key)));
|
|
2630
|
+
}
|
|
2622
2631
|
let streamingStateExtractor = new StreamingStateExtractor([]);
|
|
2623
2632
|
let prevNodeName = null;
|
|
2624
2633
|
let emitIntermediateStateUntilEnd = null;
|
|
@@ -2710,7 +2719,8 @@ async function streamEvents(controller, args) {
|
|
|
2710
2719
|
nodeName,
|
|
2711
2720
|
state: manuallyEmittedState,
|
|
2712
2721
|
running: true,
|
|
2713
|
-
active: true
|
|
2722
|
+
active: true,
|
|
2723
|
+
schemaKeys
|
|
2714
2724
|
}));
|
|
2715
2725
|
continue;
|
|
2716
2726
|
}
|
|
@@ -2742,7 +2752,8 @@ async function streamEvents(controller, args) {
|
|
|
2742
2752
|
nodeName,
|
|
2743
2753
|
state,
|
|
2744
2754
|
running: true,
|
|
2745
|
-
active: !exitingNode
|
|
2755
|
+
active: !exitingNode,
|
|
2756
|
+
schemaKeys
|
|
2746
2757
|
}));
|
|
2747
2758
|
}
|
|
2748
2759
|
emit(JSON.stringify(event) + "\n");
|
|
@@ -2760,7 +2771,8 @@ async function streamEvents(controller, args) {
|
|
|
2760
2771
|
state: state.values,
|
|
2761
2772
|
running: !shouldExit,
|
|
2762
2773
|
active: false,
|
|
2763
|
-
includeMessages: true
|
|
2774
|
+
includeMessages: true,
|
|
2775
|
+
schemaKeys
|
|
2764
2776
|
}));
|
|
2765
2777
|
return Promise.resolve();
|
|
2766
2778
|
} catch (e) {
|
|
@@ -2773,7 +2785,7 @@ async function streamEvents(controller, args) {
|
|
|
2773
2785
|
}
|
|
2774
2786
|
}
|
|
2775
2787
|
__name(streamEvents, "streamEvents");
|
|
2776
|
-
function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false }) {
|
|
2788
|
+
function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false, schemaKeys }) {
|
|
2777
2789
|
if (!includeMessages) {
|
|
2778
2790
|
state = Object.keys(state).reduce((acc, key) => {
|
|
2779
2791
|
if (key !== "messages") {
|
|
@@ -2787,6 +2799,9 @@ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, runnin
|
|
|
2787
2799
|
messages: langchainMessagesToCopilotKit(state.messages || [])
|
|
2788
2800
|
};
|
|
2789
2801
|
}
|
|
2802
|
+
if (schemaKeys.output) {
|
|
2803
|
+
state = Object.fromEntries(Object.entries(state).filter(([key]) => schemaKeys.output.includes(key)));
|
|
2804
|
+
}
|
|
2790
2805
|
return JSON.stringify({
|
|
2791
2806
|
event: LangGraphEventTypes.OnCopilotKitStateSync,
|
|
2792
2807
|
thread_id: threadId,
|
|
@@ -3021,6 +3036,25 @@ function copilotkitMessagesToLangChain(messages) {
|
|
|
3021
3036
|
return result;
|
|
3022
3037
|
}
|
|
3023
3038
|
__name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
|
|
3039
|
+
function getSchemaKeys(graphSchema) {
|
|
3040
|
+
const CONSTANT_KEYS = [
|
|
3041
|
+
"messages",
|
|
3042
|
+
"copilotkit"
|
|
3043
|
+
];
|
|
3044
|
+
const inputSchema = Object.keys(graphSchema.input_schema.properties);
|
|
3045
|
+
const outputSchema = Object.keys(graphSchema.output_schema.properties);
|
|
3046
|
+
return {
|
|
3047
|
+
input: inputSchema && inputSchema.length ? [
|
|
3048
|
+
...inputSchema,
|
|
3049
|
+
...CONSTANT_KEYS
|
|
3050
|
+
] : null,
|
|
3051
|
+
output: outputSchema && outputSchema.length ? [
|
|
3052
|
+
...outputSchema,
|
|
3053
|
+
...CONSTANT_KEYS
|
|
3054
|
+
] : null
|
|
3055
|
+
};
|
|
3056
|
+
}
|
|
3057
|
+
__name(getSchemaKeys, "getSchemaKeys");
|
|
3024
3058
|
|
|
3025
3059
|
// src/lib/runtime/remote-action-constructors.ts
|
|
3026
3060
|
var import_shared13 = require("@copilotkit/shared");
|
|
@@ -4267,7 +4301,7 @@ please use an LLM adapter instead.`
|
|
|
4267
4301
|
threadId,
|
|
4268
4302
|
runId: void 0,
|
|
4269
4303
|
eventSource,
|
|
4270
|
-
serverSideActions
|
|
4304
|
+
serverSideActions,
|
|
4271
4305
|
actionInputsWithoutAgents: allAvailableActions
|
|
4272
4306
|
};
|
|
4273
4307
|
} catch (error) {
|