@copilotkit/runtime 1.6.0-next.8 → 1.6.0

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 (32) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/{chunk-CC5KHDCV.mjs → chunk-2RP2NR4F.mjs} +2 -2
  3. package/dist/{chunk-C7VKUXWC.mjs → chunk-DUW72ZZB.mjs} +25 -12
  4. package/dist/chunk-DUW72ZZB.mjs.map +1 -0
  5. package/dist/{chunk-LR7HA4X5.mjs → chunk-MPI4JZZR.mjs} +2 -2
  6. package/dist/{chunk-DI2VJM3I.mjs → chunk-WUMAYJP3.mjs} +2 -2
  7. package/dist/index.js +24 -11
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4 -4
  10. package/dist/lib/index.js +24 -11
  11. package/dist/lib/index.js.map +1 -1
  12. package/dist/lib/index.mjs +4 -4
  13. package/dist/lib/integrations/index.js +3 -3
  14. package/dist/lib/integrations/index.js.map +1 -1
  15. package/dist/lib/integrations/index.mjs +4 -4
  16. package/dist/lib/integrations/nest/index.js +3 -3
  17. package/dist/lib/integrations/nest/index.js.map +1 -1
  18. package/dist/lib/integrations/nest/index.mjs +2 -2
  19. package/dist/lib/integrations/node-express/index.js +3 -3
  20. package/dist/lib/integrations/node-express/index.js.map +1 -1
  21. package/dist/lib/integrations/node-express/index.mjs +2 -2
  22. package/dist/lib/integrations/node-http/index.js +3 -3
  23. package/dist/lib/integrations/node-http/index.js.map +1 -1
  24. package/dist/lib/integrations/node-http/index.mjs +1 -1
  25. package/package.json +2 -2
  26. package/src/agents/langgraph/event-source.ts +21 -5
  27. package/src/lib/runtime/copilot-runtime.ts +10 -4
  28. package/src/lib/telemetry-client.ts +3 -1
  29. package/dist/chunk-C7VKUXWC.mjs.map +0 -1
  30. /package/dist/{chunk-CC5KHDCV.mjs.map → chunk-2RP2NR4F.mjs.map} +0 -0
  31. /package/dist/{chunk-LR7HA4X5.mjs.map → chunk-MPI4JZZR.mjs.map} +0 -0
  32. /package/dist/{chunk-DI2VJM3I.mjs.map → chunk-WUMAYJP3.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  copilotRuntimeNodeHttpEndpoint
3
- } from "../../../chunk-C7VKUXWC.mjs";
3
+ } from "../../../chunk-DUW72ZZB.mjs";
4
4
  import "../../../chunk-FZJAYGIR.mjs";
5
5
  import "../../../chunk-5BIEM2UU.mjs";
6
6
  import "../../../chunk-RTFJTJMA.mjs";
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.6.0-next.8",
12
+ "version": "1.6.0",
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.8"
62
+ "@copilotkit/shared": "1.6.0"
63
63
  },
64
64
  "keywords": [
65
65
  "copilotkit",
@@ -20,6 +20,7 @@ interface LangGraphEventWithState {
20
20
  lastToolCallId: string | null;
21
21
  lastToolCallName: string | null;
22
22
  currentContent: string | null;
23
+ processedToolCallIds: Set<string>;
23
24
  }
24
25
 
25
26
  export class RemoteLangGraphEventSource {
@@ -87,11 +88,20 @@ export class RemoteLangGraphEventSource {
87
88
  acc.lastMessageId = this.getCurrentMessageId(event) ?? acc.lastMessageId;
88
89
  const toolCallChunks = this.getCurrentToolCallChunks(event) ?? [];
89
90
  const responseMetadata = this.getResponseMetadata(event);
91
+ // Check if a given event is a tool call
92
+ const toolCallCheck = toolCallChunks && toolCallChunks.length > 0;
93
+ let isToolCallEnd = responseMetadata?.finish_reason === "tool_calls";
90
94
 
91
95
  acc.isToolCallStart = toolCallChunks.some((chunk: any) => chunk.name && chunk.id);
92
96
  acc.isMessageStart = prevMessageId !== acc.lastMessageId && !acc.isToolCallStart;
93
- acc.isToolCall = toolCallChunks && toolCallChunks.length > 0;
94
- acc.isToolCallEnd = responseMetadata?.finish_reason === "tool_calls";
97
+
98
+ let previousRoundHadToolCall = acc.isToolCall;
99
+ acc.isToolCall = toolCallCheck;
100
+ // Previous "acc.isToolCall" was set but now it won't pass the check, it means the tool call just ended.
101
+ if (previousRoundHadToolCall && !toolCallCheck) {
102
+ isToolCallEnd = true;
103
+ }
104
+ acc.isToolCallEnd = isToolCallEnd;
95
105
  acc.isMessageEnd = responseMetadata?.finish_reason === "stop";
96
106
  ({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find(
97
107
  (chunk: any) => chunk.name && chunk.id,
@@ -112,6 +122,7 @@ export class RemoteLangGraphEventSource {
112
122
  lastToolCallId: null,
113
123
  lastToolCallName: null,
114
124
  currentContent: null,
125
+ processedToolCallIds: new Set<string>(),
115
126
  } as LangGraphEventWithState,
116
127
  ),
117
128
  mergeMap((acc): RuntimeEvent[] => {
@@ -148,9 +159,13 @@ export class RemoteLangGraphEventSource {
148
159
 
149
160
  // Tool call ended: emit ActionExecutionEnd
150
161
  if (
151
- responseMetadata?.finish_reason === "tool_calls" &&
152
- this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)
162
+ acc.isToolCallEnd &&
163
+ this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName) &&
164
+ acc.lastToolCallId &&
165
+ !acc.processedToolCallIds.has(acc.lastToolCallId)
153
166
  ) {
167
+ acc.processedToolCallIds.add(acc.lastToolCallId);
168
+
154
169
  events.push({
155
170
  type: RuntimeEventTypes.ActionExecutionEnd,
156
171
  actionExecutionId: acc.lastToolCallId,
@@ -158,7 +173,7 @@ export class RemoteLangGraphEventSource {
158
173
  }
159
174
 
160
175
  // Message ended: emit TextMessageEnd
161
- if (responseMetadata?.finish_reason === "stop" && shouldEmitMessages) {
176
+ else if (responseMetadata?.finish_reason === "stop" && shouldEmitMessages) {
162
177
  events.push({
163
178
  type: RuntimeEventTypes.TextMessageEnd,
164
179
  messageId: acc.lastMessageId,
@@ -236,6 +251,7 @@ export class RemoteLangGraphEventSource {
236
251
  }
237
252
  // Message started: emit TextMessageStart
238
253
  else if (acc.isMessageStart && shouldEmitMessages) {
254
+ acc.processedToolCallIds.clear();
239
255
  events.push({
240
256
  type: RuntimeEventTypes.TextMessageStart,
241
257
  messageId: acc.lastMessageId,
@@ -153,7 +153,7 @@ export interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []
153
153
  middleware?: Middleware;
154
154
 
155
155
  /*
156
- * A list of server side actions that can be executed.
156
+ * A list of server side actions that can be executed. Will be ignored when remoteActions are set
157
157
  */
158
158
  actions?: ActionsConfiguration<T>;
159
159
 
@@ -190,7 +190,13 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
190
190
  private delegateAgentProcessingToServiceAdapter: boolean;
191
191
 
192
192
  constructor(params?: CopilotRuntimeConstructorParams<T>) {
193
- this.actions = params?.actions || [];
193
+ // Do not register actions if endpoints are set
194
+ if (params?.actions && params?.remoteEndpoints) {
195
+ console.warn("Actions set in runtime instance will be ignored when remote endpoints are set");
196
+ this.actions = [];
197
+ } else {
198
+ this.actions = params?.actions || [];
199
+ }
194
200
 
195
201
  for (const chain of params?.langserve || []) {
196
202
  const remoteChain = new RemoteChain(chain);
@@ -572,7 +578,7 @@ please use an LLM adapter instead.`,
572
578
  threadId,
573
579
  runId: undefined,
574
580
  eventSource,
575
- serverSideActions: [],
581
+ serverSideActions,
576
582
  actionInputsWithoutAgents: allAvailableActions,
577
583
  };
578
584
  } catch (error) {
@@ -651,7 +657,7 @@ export function langGraphPlatformEndpoint(
651
657
 
652
658
  export function resolveEndpointType(endpoint: EndpointDefinition) {
653
659
  if (!endpoint.type) {
654
- if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
660
+ if ("deploymentUrl" in endpoint && "agents" in endpoint) {
655
661
  return EndpointType.LangGraphPlatform;
656
662
  } else {
657
663
  return EndpointType.CopilotKit;
@@ -31,7 +31,9 @@ export function getRuntimeInstanceTelemetryInfo(
31
31
  info = {
32
32
  ...info,
33
33
  agentsAmount: ep.agents.length,
34
- hashedKey: createHash("sha256").update(ep.langsmithApiKey).digest("hex"),
34
+ hashedKey: ep.langsmithApiKey
35
+ ? createHash("sha256").update(ep.langsmithApiKey).digest("hex")
36
+ : null,
35
37
  };
36
38
  }
37
39