@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
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-C7VKUXWC.mjs";
5
+ } from "./chunk-DUW72ZZB.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
22
22
  export {
23
23
  copilotRuntimeNestEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-LR7HA4X5.mjs.map
25
+ //# sourceMappingURL=chunk-MPI4JZZR.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-C7VKUXWC.mjs";
5
+ } from "./chunk-DUW72ZZB.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -77,4 +77,4 @@ export {
77
77
  config,
78
78
  copilotRuntimeNextJSPagesRouterEndpoint
79
79
  };
80
- //# sourceMappingURL=chunk-DI2VJM3I.mjs.map
80
+ //# sourceMappingURL=chunk-WUMAYJP3.mjs.map
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.8",
47
+ version: "1.6.0",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -1693,10 +1693,16 @@ 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 = toolCallChunks && toolCallChunks.length > 0;
1699
- acc.isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
1700
+ let previousRoundHadToolCall = acc.isToolCall;
1701
+ acc.isToolCall = toolCallCheck;
1702
+ if (previousRoundHadToolCall && !toolCallCheck) {
1703
+ isToolCallEnd = true;
1704
+ }
1705
+ acc.isToolCallEnd = isToolCallEnd;
1700
1706
  acc.isMessageEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop";
1701
1707
  ({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find((chunk) => chunk.name && chunk.id) ?? {
1702
1708
  name: acc.lastToolCallName,
@@ -1716,7 +1722,8 @@ var RemoteLangGraphEventSource = class {
1716
1722
  lastMessageId: null,
1717
1723
  lastToolCallId: null,
1718
1724
  lastToolCallName: null,
1719
- currentContent: null
1725
+ currentContent: null,
1726
+ processedToolCallIds: /* @__PURE__ */ new Set()
1720
1727
  }), (0, import_rxjs.mergeMap)((acc) => {
1721
1728
  const events = [];
1722
1729
  let shouldEmitMessages = true;
@@ -1744,13 +1751,13 @@ var RemoteLangGraphEventSource = class {
1744
1751
  });
1745
1752
  }
1746
1753
  const responseMetadata = this.getResponseMetadata(acc.event);
1747
- if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls" && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
1754
+ if (acc.isToolCallEnd && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName) && acc.lastToolCallId && !acc.processedToolCallIds.has(acc.lastToolCallId)) {
1755
+ acc.processedToolCallIds.add(acc.lastToolCallId);
1748
1756
  events.push({
1749
1757
  type: RuntimeEventTypes.ActionExecutionEnd,
1750
1758
  actionExecutionId: acc.lastToolCallId
1751
1759
  });
1752
- }
1753
- if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
1760
+ } else if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
1754
1761
  events.push({
1755
1762
  type: RuntimeEventTypes.TextMessageEnd,
1756
1763
  messageId: acc.lastMessageId
@@ -1812,6 +1819,7 @@ var RemoteLangGraphEventSource = class {
1812
1819
  parentMessageId: acc.lastMessageId
1813
1820
  });
1814
1821
  } else if (acc.isMessageStart && shouldEmitMessages) {
1822
+ acc.processedToolCallIds.clear();
1815
1823
  events.push({
1816
1824
  type: RuntimeEventTypes.TextMessageStart,
1817
1825
  messageId: acc.lastMessageId
@@ -3470,7 +3478,7 @@ function getRuntimeInstanceTelemetryInfo(runtime) {
3470
3478
  info = {
3471
3479
  ...info,
3472
3480
  agentsAmount: ep.agents.length,
3473
- hashedKey: (0, import_node_crypto3.createHash)("sha256").update(ep.langsmithApiKey).digest("hex")
3481
+ hashedKey: ep.langsmithApiKey ? (0, import_node_crypto3.createHash)("sha256").update(ep.langsmithApiKey).digest("hex") : null
3474
3482
  };
3475
3483
  }
3476
3484
  return info;
@@ -3985,7 +3993,12 @@ var CopilotRuntime = class {
3985
3993
  delegateAgentProcessingToServiceAdapter;
3986
3994
  constructor(params) {
3987
3995
  var _a, _b;
3988
- this.actions = (params == null ? void 0 : params.actions) || [];
3996
+ if ((params == null ? void 0 : params.actions) && (params == null ? void 0 : params.remoteEndpoints)) {
3997
+ console.warn("Actions set in runtime instance will be ignored when remote endpoints are set");
3998
+ this.actions = [];
3999
+ } else {
4000
+ this.actions = (params == null ? void 0 : params.actions) || [];
4001
+ }
3989
4002
  for (const chain of (params == null ? void 0 : params.langserve) || []) {
3990
4003
  const remoteChain = new RemoteChain(chain);
3991
4004
  this.langserve.push(remoteChain.toAction());
@@ -4297,7 +4310,7 @@ please use an LLM adapter instead.`
4297
4310
  threadId,
4298
4311
  runId: void 0,
4299
4312
  eventSource,
4300
- serverSideActions: [],
4313
+ serverSideActions,
4301
4314
  actionInputsWithoutAgents: allAvailableActions
4302
4315
  };
4303
4316
  } catch (error) {
@@ -4368,7 +4381,7 @@ function langGraphPlatformEndpoint(config2) {
4368
4381
  __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
4369
4382
  function resolveEndpointType(endpoint) {
4370
4383
  if (!endpoint.type) {
4371
- if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
4384
+ if ("deploymentUrl" in endpoint && "agents" in endpoint) {
4372
4385
  return EndpointType.LangGraphPlatform;
4373
4386
  } else {
4374
4387
  return EndpointType.CopilotKit;