@copilotkit/runtime 1.6.0-next.9 → 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 +38 -0
  2. package/dist/{chunk-4HQ5OZXN.mjs → chunk-2RP2NR4F.mjs} +2 -2
  3. package/dist/{chunk-L7OTGCAG.mjs → chunk-DUW72ZZB.mjs} +18 -9
  4. package/dist/chunk-DUW72ZZB.mjs.map +1 -0
  5. package/dist/{chunk-5ZBUMQE2.mjs → chunk-MPI4JZZR.mjs} +2 -2
  6. package/dist/{chunk-7BCFHZLY.mjs → chunk-WUMAYJP3.mjs} +2 -2
  7. package/dist/index.js +17 -8
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4 -4
  10. package/dist/lib/index.js +17 -8
  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 +11 -4
  27. package/src/lib/runtime/copilot-runtime.ts +9 -3
  28. package/src/lib/telemetry-client.ts +3 -1
  29. package/dist/chunk-L7OTGCAG.mjs.map +0 -1
  30. /package/dist/{chunk-4HQ5OZXN.mjs.map → chunk-2RP2NR4F.mjs.map} +0 -0
  31. /package/dist/{chunk-5ZBUMQE2.mjs.map → chunk-MPI4JZZR.mjs.map} +0 -0
  32. /package/dist/{chunk-7BCFHZLY.mjs.map → chunk-WUMAYJP3.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  copilotRuntimeNodeHttpEndpoint
3
- } from "../../../chunk-L7OTGCAG.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.9",
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.9"
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 {
@@ -94,12 +95,12 @@ export class RemoteLangGraphEventSource {
94
95
  acc.isToolCallStart = toolCallChunks.some((chunk: any) => chunk.name && chunk.id);
95
96
  acc.isMessageStart = prevMessageId !== acc.lastMessageId && !acc.isToolCallStart;
96
97
 
98
+ let previousRoundHadToolCall = acc.isToolCall;
99
+ acc.isToolCall = toolCallCheck;
97
100
  // Previous "acc.isToolCall" was set but now it won't pass the check, it means the tool call just ended.
98
- if (acc.isToolCall && !toolCallCheck) {
101
+ if (previousRoundHadToolCall && !toolCallCheck) {
99
102
  isToolCallEnd = true;
100
103
  }
101
-
102
- acc.isToolCall = toolCallCheck;
103
104
  acc.isToolCallEnd = isToolCallEnd;
104
105
  acc.isMessageEnd = responseMetadata?.finish_reason === "stop";
105
106
  ({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find(
@@ -121,6 +122,7 @@ export class RemoteLangGraphEventSource {
121
122
  lastToolCallId: null,
122
123
  lastToolCallName: null,
123
124
  currentContent: null,
125
+ processedToolCallIds: new Set<string>(),
124
126
  } as LangGraphEventWithState,
125
127
  ),
126
128
  mergeMap((acc): RuntimeEvent[] => {
@@ -158,8 +160,12 @@ export class RemoteLangGraphEventSource {
158
160
  // Tool call ended: emit ActionExecutionEnd
159
161
  if (
160
162
  acc.isToolCallEnd &&
161
- this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)
163
+ this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName) &&
164
+ acc.lastToolCallId &&
165
+ !acc.processedToolCallIds.has(acc.lastToolCallId)
162
166
  ) {
167
+ acc.processedToolCallIds.add(acc.lastToolCallId);
168
+
163
169
  events.push({
164
170
  type: RuntimeEventTypes.ActionExecutionEnd,
165
171
  actionExecutionId: acc.lastToolCallId,
@@ -245,6 +251,7 @@ export class RemoteLangGraphEventSource {
245
251
  }
246
252
  // Message started: emit TextMessageStart
247
253
  else if (acc.isMessageStart && shouldEmitMessages) {
254
+ acc.processedToolCallIds.clear();
248
255
  events.push({
249
256
  type: RuntimeEventTypes.TextMessageStart,
250
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);
@@ -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