@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
package/dist/index.mjs CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  config,
4
4
  copilotRuntimeNextJSAppRouterEndpoint,
5
5
  copilotRuntimeNextJSPagesRouterEndpoint
6
- } from "./chunk-DI2VJM3I.mjs";
6
+ } from "./chunk-WUMAYJP3.mjs";
7
7
  import {
8
8
  copilotRuntimeNestEndpoint
9
- } from "./chunk-LR7HA4X5.mjs";
9
+ } from "./chunk-MPI4JZZR.mjs";
10
10
  import {
11
11
  copilotRuntimeNodeExpressEndpoint
12
- } from "./chunk-CC5KHDCV.mjs";
12
+ } from "./chunk-2RP2NR4F.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-C7VKUXWC.mjs";
24
+ } from "./chunk-DUW72ZZB.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.8",
47
+ version: "1.6.0",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -1357,10 +1357,16 @@ 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 = toolCallChunks && toolCallChunks.length > 0;
1363
- acc.isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
1364
+ let previousRoundHadToolCall = acc.isToolCall;
1365
+ acc.isToolCall = toolCallCheck;
1366
+ if (previousRoundHadToolCall && !toolCallCheck) {
1367
+ isToolCallEnd = true;
1368
+ }
1369
+ acc.isToolCallEnd = isToolCallEnd;
1364
1370
  acc.isMessageEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop";
1365
1371
  ({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find((chunk) => chunk.name && chunk.id) ?? {
1366
1372
  name: acc.lastToolCallName,
@@ -1380,7 +1386,8 @@ var RemoteLangGraphEventSource = class {
1380
1386
  lastMessageId: null,
1381
1387
  lastToolCallId: null,
1382
1388
  lastToolCallName: null,
1383
- currentContent: null
1389
+ currentContent: null,
1390
+ processedToolCallIds: /* @__PURE__ */ new Set()
1384
1391
  }), (0, import_rxjs.mergeMap)((acc) => {
1385
1392
  const events = [];
1386
1393
  let shouldEmitMessages = true;
@@ -1408,13 +1415,13 @@ var RemoteLangGraphEventSource = class {
1408
1415
  });
1409
1416
  }
1410
1417
  const responseMetadata = this.getResponseMetadata(acc.event);
1411
- if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls" && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
1418
+ if (acc.isToolCallEnd && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName) && acc.lastToolCallId && !acc.processedToolCallIds.has(acc.lastToolCallId)) {
1419
+ acc.processedToolCallIds.add(acc.lastToolCallId);
1412
1420
  events.push({
1413
1421
  type: RuntimeEventTypes.ActionExecutionEnd,
1414
1422
  actionExecutionId: acc.lastToolCallId
1415
1423
  });
1416
- }
1417
- if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
1424
+ } else if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
1418
1425
  events.push({
1419
1426
  type: RuntimeEventTypes.TextMessageEnd,
1420
1427
  messageId: acc.lastMessageId
@@ -1476,6 +1483,7 @@ var RemoteLangGraphEventSource = class {
1476
1483
  parentMessageId: acc.lastMessageId
1477
1484
  });
1478
1485
  } else if (acc.isMessageStart && shouldEmitMessages) {
1486
+ acc.processedToolCallIds.clear();
1479
1487
  events.push({
1480
1488
  type: RuntimeEventTypes.TextMessageStart,
1481
1489
  messageId: acc.lastMessageId
@@ -3134,7 +3142,7 @@ function getRuntimeInstanceTelemetryInfo(runtime) {
3134
3142
  info = {
3135
3143
  ...info,
3136
3144
  agentsAmount: ep.agents.length,
3137
- hashedKey: (0, import_node_crypto3.createHash)("sha256").update(ep.langsmithApiKey).digest("hex")
3145
+ hashedKey: ep.langsmithApiKey ? (0, import_node_crypto3.createHash)("sha256").update(ep.langsmithApiKey).digest("hex") : null
3138
3146
  };
3139
3147
  }
3140
3148
  return info;
@@ -3649,7 +3657,12 @@ var CopilotRuntime = class {
3649
3657
  delegateAgentProcessingToServiceAdapter;
3650
3658
  constructor(params) {
3651
3659
  var _a, _b;
3652
- this.actions = (params == null ? void 0 : params.actions) || [];
3660
+ if ((params == null ? void 0 : params.actions) && (params == null ? void 0 : params.remoteEndpoints)) {
3661
+ console.warn("Actions set in runtime instance will be ignored when remote endpoints are set");
3662
+ this.actions = [];
3663
+ } else {
3664
+ this.actions = (params == null ? void 0 : params.actions) || [];
3665
+ }
3653
3666
  for (const chain of (params == null ? void 0 : params.langserve) || []) {
3654
3667
  const remoteChain = new RemoteChain(chain);
3655
3668
  this.langserve.push(remoteChain.toAction());
@@ -3961,7 +3974,7 @@ please use an LLM adapter instead.`
3961
3974
  threadId,
3962
3975
  runId: void 0,
3963
3976
  eventSource,
3964
- serverSideActions: [],
3977
+ serverSideActions,
3965
3978
  actionInputsWithoutAgents: allAvailableActions
3966
3979
  };
3967
3980
  } catch (error) {
@@ -4032,7 +4045,7 @@ function langGraphPlatformEndpoint(config2) {
4032
4045
  __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
4033
4046
  function resolveEndpointType(endpoint) {
4034
4047
  if (!endpoint.type) {
4035
- if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
4048
+ if ("deploymentUrl" in endpoint && "agents" in endpoint) {
4036
4049
  return EndpointType.LangGraphPlatform;
4037
4050
  } else {
4038
4051
  return EndpointType.CopilotKit;