@copilotkit/runtime 1.3.16-mme-reset-chat.10 → 1.3.16-mme-reset-chat.11

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 (46) hide show
  1. package/CHANGELOG.md +21 -43
  2. package/dist/{chunk-2S6JGN2A.mjs → chunk-NJH4ZBXT.mjs} +2 -2
  3. package/dist/{chunk-TBNMKEWV.mjs → chunk-T2MGJXW2.mjs} +2 -2
  4. package/dist/{chunk-3XICZ4K2.mjs → chunk-XR3QOJ47.mjs} +2 -2
  5. package/dist/{chunk-ODOSADGH.mjs → chunk-YILXJQFD.mjs} +78 -57
  6. package/dist/chunk-YILXJQFD.mjs.map +1 -0
  7. package/dist/{copilot-runtime-b9715bd4.d.ts → copilot-runtime-335a610d.d.ts} +8 -8
  8. package/dist/{groq-adapter-dbfba3eb.d.ts → groq-adapter-2f8fd767.d.ts} +1 -1
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +80 -59
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +6 -6
  13. package/dist/{langserve-f00629d2.d.ts → langserve-cc06e76e.d.ts} +1 -0
  14. package/dist/lib/index.d.ts +3 -3
  15. package/dist/lib/index.js +80 -59
  16. package/dist/lib/index.js.map +1 -1
  17. package/dist/lib/index.mjs +6 -6
  18. package/dist/lib/integrations/index.d.ts +3 -3
  19. package/dist/lib/integrations/index.js +12 -11
  20. package/dist/lib/integrations/index.js.map +1 -1
  21. package/dist/lib/integrations/index.mjs +4 -4
  22. package/dist/lib/integrations/nest/index.d.ts +2 -2
  23. package/dist/lib/integrations/nest/index.js +12 -11
  24. package/dist/lib/integrations/nest/index.js.map +1 -1
  25. package/dist/lib/integrations/nest/index.mjs +2 -2
  26. package/dist/lib/integrations/node-express/index.d.ts +2 -2
  27. package/dist/lib/integrations/node-express/index.js +12 -11
  28. package/dist/lib/integrations/node-express/index.js.map +1 -1
  29. package/dist/lib/integrations/node-express/index.mjs +2 -2
  30. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  31. package/dist/lib/integrations/node-http/index.js +12 -11
  32. package/dist/lib/integrations/node-http/index.js.map +1 -1
  33. package/dist/lib/integrations/node-http/index.mjs +1 -1
  34. package/dist/service-adapters/index.d.ts +3 -3
  35. package/package.json +4 -4
  36. package/src/agents/langgraph/event-source.ts +2 -2
  37. package/src/lib/runtime/copilot-runtime.ts +40 -33
  38. package/src/lib/runtime/remote-action-constructors.ts +7 -7
  39. package/src/lib/runtime/remote-actions.ts +9 -9
  40. package/src/lib/runtime/{remote-lg-cloud-action.ts → remote-lg-action.ts} +34 -31
  41. package/src/lib/telemetry-client.ts +3 -3
  42. package/src/service-adapters/events.ts +13 -1
  43. package/dist/chunk-ODOSADGH.mjs.map +0 -1
  44. /package/dist/{chunk-2S6JGN2A.mjs.map → chunk-NJH4ZBXT.mjs.map} +0 -0
  45. /package/dist/{chunk-TBNMKEWV.mjs.map → chunk-T2MGJXW2.mjs.map} +0 -0
  46. /package/dist/{chunk-3XICZ4K2.mjs.map → chunk-XR3QOJ47.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,19 +1,31 @@
1
1
  # @copilotkit/runtime
2
2
 
3
- ## 1.3.16-mme-reset-chat.10
3
+ ## 1.3.16-mme-reset-chat.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 164ce73: Add reset and threadId to useCopilotChat
8
+ - f3ce10a: Add custom stop/reload
9
+ - Merge main
10
+ - c7df09a: Move threadId to context
11
+ - Updated dependencies [164ce73]
12
+ - Updated dependencies [f3ce10a]
13
+ - Updated dependencies
14
+ - Updated dependencies [c7df09a]
15
+ - @copilotkit/shared@1.3.16-mme-reset-chat.11
16
+
17
+ ## 1.3.16-mme-revert-rxjs-changes.10
4
18
 
5
19
  ### Patch Changes
6
20
 
7
21
  - f6fab28: update tsup config
8
22
  - f6fab28: update entry
9
23
  - f6fab28: export langchain module
10
- - c4b9f95: Improve LangSmith support
11
- - 164ce73: Add reset and threadId to useCopilotChat
24
+ - 8a77944: Improve LangSmith support
12
25
  - f6fab28: Ensure intermediate state config is sent as snake case
13
26
  - f6fab28: update entry in tsup config
14
- - Add custom stop/reload
15
- - af119bf: Ensure the last message is sent to LangSmith
16
- - c7df09a: Move threadId to context
27
+ - 8a77944: Ensure the last message is sent to LangSmith
28
+ - Revert rxjs changes
17
29
  - f6fab28: update entry
18
30
  - f6fab28: Update exports
19
31
  - f6fab28: Update exports
@@ -23,52 +35,18 @@
23
35
  - Updated dependencies [f6fab28]
24
36
  - Updated dependencies [f6fab28]
25
37
  - Updated dependencies [f6fab28]
26
- - Updated dependencies [c4b9f95]
27
- - Updated dependencies [164ce73]
38
+ - Updated dependencies [8a77944]
28
39
  - Updated dependencies [f6fab28]
29
40
  - Updated dependencies [f6fab28]
41
+ - Updated dependencies [8a77944]
30
42
  - Updated dependencies
31
- - Updated dependencies [af119bf]
32
- - Updated dependencies [c7df09a]
33
43
  - Updated dependencies [f6fab28]
34
44
  - Updated dependencies [f6fab28]
35
45
  - Updated dependencies [f6fab28]
36
46
  - Updated dependencies [332d744]
37
47
  - Updated dependencies [f6fab28]
38
48
  - Updated dependencies [f6fab28]
39
- - @copilotkit/shared@1.3.16-mme-reset-chat.10
40
-
41
- ## 1.3.16-mme-reset-chat.3
42
-
43
- ### Patch Changes
44
-
45
- - Move threadId to context
46
- - Updated dependencies
47
- - @copilotkit/shared@1.3.16-mme-reset-chat.3
48
-
49
- ## 1.3.16-mme-reset-chat.2
50
-
51
- ### Patch Changes
52
-
53
- - Add reset and threadId to useCopilotChat
54
- - Updated dependencies
55
- - @copilotkit/shared@1.3.16-mme-reset-chat.2
56
-
57
- ## 1.3.16-mme-improve-langsmith.1
58
-
59
- ### Patch Changes
60
-
61
- - Ensure the last message is sent to LangSmith
62
- - Updated dependencies
63
- - @copilotkit/shared@1.3.16-mme-improve-langsmith.1
64
-
65
- ## 1.3.16-mme-improve-langsmith.0
66
-
67
- ### Patch Changes
68
-
69
- - Improve LangSmith support
70
- - Updated dependencies
71
- - @copilotkit/shared@1.3.16-mme-improve-langsmith.0
49
+ - @copilotkit/shared@1.3.16-mme-revert-rxjs-changes.10
72
50
 
73
51
  ## 1.3.15
74
52
 
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-ODOSADGH.mjs";
5
+ } from "./chunk-YILXJQFD.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-44O2JGUY.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
22
22
  export {
23
23
  copilotRuntimeNodeExpressEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-2S6JGN2A.mjs.map
25
+ //# sourceMappingURL=chunk-NJH4ZBXT.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-ODOSADGH.mjs";
5
+ } from "./chunk-YILXJQFD.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-44O2JGUY.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
22
22
  export {
23
23
  copilotRuntimeNestEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-TBNMKEWV.mjs.map
25
+ //# sourceMappingURL=chunk-T2MGJXW2.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-ODOSADGH.mjs";
5
+ } from "./chunk-YILXJQFD.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-44O2JGUY.mjs";
@@ -77,4 +77,4 @@ export {
77
77
  config,
78
78
  copilotRuntimeNextJSPagesRouterEndpoint
79
79
  };
80
- //# sourceMappingURL=chunk-3XICZ4K2.mjs.map
80
+ //# sourceMappingURL=chunk-XR3QOJ47.mjs.map
@@ -37,7 +37,7 @@ var require_package = __commonJS({
37
37
  publishConfig: {
38
38
  access: "public"
39
39
  },
40
- version: "1.3.16-mme-reset-chat.10",
40
+ version: "1.3.16-mme-reset-chat.11",
41
41
  sideEffects: false,
42
42
  main: "./dist/index.js",
43
43
  module: "./dist/index.mjs",
@@ -1024,6 +1024,7 @@ CopilotResponse = _ts_decorate11([
1024
1024
  import { Repeater } from "graphql-yoga";
1025
1025
 
1026
1026
  // src/service-adapters/events.ts
1027
+ import { randomId as randomId3 } from "@copilotkit/shared";
1027
1028
  import { of, concat, map, scan as scan2, concatMap, ReplaySubject as ReplaySubject2, firstValueFrom, from as from2 } from "rxjs";
1028
1029
 
1029
1030
  // src/lib/telemetry-client.ts
@@ -1086,7 +1087,7 @@ var RemoteLangGraphEventSource = class {
1086
1087
  acc.content = null;
1087
1088
  }
1088
1089
  const toolCallChunks = (
1089
- // @ts-expect-error -- LangGraph Cloud implementation stores data outside of kwargs
1090
+ // @ts-expect-error -- LangGraph Platform implementation stores data outside of kwargs
1090
1091
  ((_h = (_g = (_f = event.data) == null ? void 0 : _f.chunk) == null ? void 0 : _g.kwargs) == null ? void 0 : _h.tool_call_chunks) ?? ((_j = (_i = event.data) == null ? void 0 : _i.chunk) == null ? void 0 : _j.tool_call_chunks)
1091
1092
  );
1092
1093
  const toolCallMessageId = ((_m = (_l = (_k = event.data) == null ? void 0 : _k.chunk) == null ? void 0 : _l.kwargs) == null ? void 0 : _m.id) ?? ((_o = (_n = event.data) == null ? void 0 : _n.chunk) == null ? void 0 : _o.id);
@@ -1264,7 +1265,7 @@ var RemoteLangGraphEventSource = class {
1264
1265
  };
1265
1266
  __name(RemoteLangGraphEventSource, "RemoteLangGraphEventSource");
1266
1267
 
1267
- // src/lib/runtime/remote-lg-cloud-action.ts
1268
+ // src/lib/runtime/remote-lg-action.ts
1268
1269
  import { Client } from "@langchain/langgraph-sdk";
1269
1270
  import { createHash, randomUUID } from "crypto";
1270
1271
  import { parse as parsePartialJson } from "partial-json";
@@ -1331,7 +1332,7 @@ async function streamEvents(controller, args) {
1331
1332
  if (!assistantId) {
1332
1333
  console.error(`
1333
1334
  No agent found for the agent name specified in CopilotKit provider
1334
- Please check your available agents or provide an agent ID in the LangGraph Cloud endpoint definition.
1335
+ Please check your available agents or provide an agent ID in the LangGraph Platform endpoint definition.
1335
1336
 
1336
1337
 
1337
1338
  These are the available agents: [${assistants.map((a) => `${a.name} (ID: ${a.assistant_id})`).join(", ")}]
@@ -1355,6 +1356,7 @@ async function streamEvents(controller, args) {
1355
1356
  const emit = /* @__PURE__ */ __name((message) => controller.enqueue(new TextEncoder().encode(message)), "emit");
1356
1357
  let latestStateValues = {};
1357
1358
  let updatedState = state;
1359
+ let manuallyEmittedState = null;
1358
1360
  let streamInfo = {
1359
1361
  hashedLgcKey: createHash("sha256").update(langsmithApiKey).digest("hex")
1360
1362
  };
@@ -1395,23 +1397,25 @@ async function streamEvents(controller, args) {
1395
1397
  shouldExit = shouldExit || eventType === LangGraphEventTypes.OnCustomEvent && event.name === CustomEventNames.CopilotKitExit;
1396
1398
  const emitIntermediateState = metadata["copilotkit:emit-intermediate-state"];
1397
1399
  const manuallyEmitIntermediateState = eventType === LangGraphEventTypes.OnCustomEvent && event.name === CustomEventNames.CopilotKitManuallyEmitIntermediateState;
1400
+ const exitingNode = nodeName === currentNodeName && eventType === LangGraphEventTypes.OnChainEnd;
1401
+ if (exitingNode) {
1402
+ manuallyEmittedState = null;
1403
+ }
1398
1404
  if (graphInfo["nodes"].some((node) => node.id === currentNodeName)) {
1399
1405
  nodeName = currentNodeName;
1400
- if (eventType === LangGraphEventTypes.OnChainStart || eventType === LangGraphEventTypes.OnChainEnd) {
1401
- updatedState = latestStateValues;
1402
- }
1403
1406
  }
1407
+ updatedState = manuallyEmittedState ?? latestStateValues;
1404
1408
  if (!nodeName) {
1405
1409
  continue;
1406
1410
  }
1407
1411
  if (manuallyEmitIntermediateState) {
1408
- updatedState = event.data;
1412
+ manuallyEmittedState = event.data;
1409
1413
  emit(getStateSyncEvent({
1410
1414
  threadId,
1411
1415
  runId,
1412
1416
  agentName: agent.name,
1413
1417
  nodeName,
1414
- state: updatedState,
1418
+ state: manuallyEmittedState,
1415
1419
  running: true,
1416
1420
  active: true
1417
1421
  }));
@@ -1435,7 +1439,6 @@ async function streamEvents(controller, args) {
1435
1439
  if (!emitIntermediateState && currentNodeName === emitIntermediateStateUntilEnd && eventType === LangGraphEventTypes.OnChainEnd) {
1436
1440
  emitIntermediateStateUntilEnd = null;
1437
1441
  }
1438
- const exitingNode = nodeName === currentNodeName && eventType === LangGraphEventTypes.OnChainEnd;
1439
1442
  if (JSON.stringify(updatedState) !== JSON.stringify(state) || prevNodeName != nodeName || exitingNode) {
1440
1443
  state = updatedState;
1441
1444
  prevNodeName = nodeName;
@@ -1701,10 +1704,10 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
1701
1704
  var _a;
1702
1705
  logger2.debug({
1703
1706
  actionName: agent.name
1704
- }, "Executing LangGraph Cloud agent");
1707
+ }, "Executing LangGraph Platform agent");
1705
1708
  telemetry_client_default.capture("oss.runtime.remote_action_executed", {
1706
1709
  agentExecution: true,
1707
- type: "langgraph-cloud",
1710
+ type: "langgraph-platform",
1708
1711
  agentsAmount: endpoint.agents.length,
1709
1712
  hashedLgcKey: createHash2("sha256").update(endpoint.langsmithApiKey).digest("hex")
1710
1713
  });
@@ -1740,8 +1743,8 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
1740
1743
  url: endpoint.deploymentUrl,
1741
1744
  status: 500,
1742
1745
  body: error.message
1743
- }, "Failed to execute LangGraph Cloud agent");
1744
- throw new Error("Failed to execute LangGraph Cloud agent");
1746
+ }, "Failed to execute LangGraph Platform agent");
1747
+ throw new Error("Failed to execute LangGraph Platform agent");
1745
1748
  }
1746
1749
  }
1747
1750
  }));
@@ -1923,7 +1926,7 @@ __name(createHeaders, "createHeaders");
1923
1926
  var EndpointType;
1924
1927
  (function(EndpointType2) {
1925
1928
  EndpointType2["CopilotKit"] = "copilotKit";
1926
- EndpointType2["LangGraphCloud"] = "langgraph-cloud";
1929
+ EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1927
1930
  })(EndpointType || (EndpointType = {}));
1928
1931
  function isLangGraphAgentAction(action) {
1929
1932
  if (!action) {
@@ -1981,13 +1984,13 @@ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, m
1981
1984
  remoteEndpointDefinitions
1982
1985
  }, "Fetching from remote endpoints");
1983
1986
  const filtered = remoteEndpointDefinitions.filter((value, index, self) => {
1984
- if (value.type === "langgraph-cloud") {
1987
+ if (value.type === "langgraph-platform") {
1985
1988
  return value;
1986
1989
  }
1987
1990
  return index === self.findIndex((t) => t.url === value.url);
1988
1991
  });
1989
1992
  const result = await Promise.all(filtered.map(async (endpoint) => {
1990
- if (endpoint.type === "langgraph-cloud") {
1993
+ if (endpoint.type === "langgraph-platform") {
1991
1994
  return constructLGCRemoteAction({
1992
1995
  endpoint,
1993
1996
  messages,
@@ -2030,7 +2033,7 @@ __name(setupRemoteActions, "setupRemoteActions");
2030
2033
  import { createHash as createHash3 } from "crypto";
2031
2034
 
2032
2035
  // src/lib/runtime/copilot-runtime.ts
2033
- import { actionParametersToJsonSchema } from "@copilotkit/shared";
2036
+ import { actionParametersToJsonSchema, randomId as randomId2 } from "@copilotkit/shared";
2034
2037
 
2035
2038
  // src/service-adapters/conversion.ts
2036
2039
  import { plainToInstance } from "class-transformer";
@@ -2094,37 +2097,37 @@ var CopilotRuntime = class {
2094
2097
  const remoteChain = new RemoteChain(chain);
2095
2098
  this.langserve.push(remoteChain.toAction());
2096
2099
  }
2097
- this.remoteEndpointDefinitions = (params == null ? void 0 : params.remoteEndpoints) || [];
2100
+ this.remoteEndpointDefinitions = (params == null ? void 0 : params.remoteEndpoints) ?? (params == null ? void 0 : params.remoteActions) ?? [];
2098
2101
  this.onBeforeRequest = (_a = params == null ? void 0 : params.middleware) == null ? void 0 : _a.onBeforeRequest;
2099
2102
  this.onAfterRequest = (_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest;
2100
2103
  }
2101
2104
  async processRuntimeRequest(request) {
2102
2105
  var _a;
2103
2106
  const { serviceAdapter, messages: rawMessages, actions: clientSideActionsInput, threadId, runId, outputMessagesPromise, graphqlContext, forwardedParameters, agentSession, url } = request;
2104
- if (agentSession) {
2105
- return this.processAgentRequest(request);
2106
- }
2107
- const messages = rawMessages.filter((message) => !message.agentStateMessage);
2108
- const inputMessages = convertGqlInputToMessages(messages);
2109
- const serverSideActions = await this.getServerSideActions(request);
2110
- const serverSideActionsInput = serverSideActions.map((action) => ({
2111
- name: action.name,
2112
- description: action.description,
2113
- jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters))
2114
- }));
2115
- const actionInputs = flattenToolCallsNoDuplicates([
2116
- ...serverSideActionsInput,
2117
- ...clientSideActionsInput
2118
- ]);
2119
- await ((_a = this.onBeforeRequest) == null ? void 0 : _a.call(this, {
2120
- threadId,
2121
- runId,
2122
- inputMessages,
2123
- properties: graphqlContext.properties,
2124
- url
2125
- }));
2107
+ const eventSource = new RuntimeEventSource();
2126
2108
  try {
2127
- const eventSource = new RuntimeEventSource();
2109
+ if (agentSession) {
2110
+ return await this.processAgentRequest(request);
2111
+ }
2112
+ const messages = rawMessages.filter((message) => !message.agentStateMessage);
2113
+ const inputMessages = convertGqlInputToMessages(messages);
2114
+ const serverSideActions = await this.getServerSideActions(request);
2115
+ const serverSideActionsInput = serverSideActions.map((action) => ({
2116
+ name: action.name,
2117
+ description: action.description,
2118
+ jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters))
2119
+ }));
2120
+ const actionInputs = flattenToolCallsNoDuplicates([
2121
+ ...serverSideActionsInput,
2122
+ ...clientSideActionsInput
2123
+ ]);
2124
+ await ((_a = this.onBeforeRequest) == null ? void 0 : _a.call(this, {
2125
+ threadId,
2126
+ runId,
2127
+ inputMessages,
2128
+ properties: graphqlContext.properties,
2129
+ url
2130
+ }));
2128
2131
  const result = await serviceAdapter.process({
2129
2132
  messages: inputMessages,
2130
2133
  actions: actionInputs,
@@ -2157,7 +2160,14 @@ var CopilotRuntime = class {
2157
2160
  };
2158
2161
  } catch (error) {
2159
2162
  console.error("Error getting response:", error);
2160
- throw error;
2163
+ eventSource.sendErrorMessageToChat();
2164
+ return {
2165
+ threadId: threadId || randomId2(),
2166
+ runId: runId || randomId2(),
2167
+ eventSource,
2168
+ serverSideActions: [],
2169
+ actionInputsWithoutAgents: []
2170
+ };
2161
2171
  }
2162
2172
  }
2163
2173
  async processAgentRequest(request) {
@@ -2277,17 +2287,17 @@ function copilotKitEndpoint(config) {
2277
2287
  };
2278
2288
  }
2279
2289
  __name(copilotKitEndpoint, "copilotKitEndpoint");
2280
- function langGraphCloudEndpoint(config) {
2290
+ function langGraphPlatformEndpoint(config) {
2281
2291
  return {
2282
2292
  ...config,
2283
- type: EndpointType.LangGraphCloud
2293
+ type: EndpointType.LangGraphPlatform
2284
2294
  };
2285
2295
  }
2286
- __name(langGraphCloudEndpoint, "langGraphCloudEndpoint");
2296
+ __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
2287
2297
  function resolveEndpointType(endpoint) {
2288
2298
  if (!endpoint.type) {
2289
2299
  if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
2290
- return EndpointType.LangGraphCloud;
2300
+ return EndpointType.LangGraphPlatform;
2291
2301
  } else {
2292
2302
  return EndpointType.CopilotKit;
2293
2303
  }
@@ -2317,7 +2327,7 @@ function getRuntimeInstanceTelemetryInfo(runtime) {
2317
2327
  ]
2318
2328
  };
2319
2329
  }
2320
- if (endpointType === EndpointType.LangGraphCloud) {
2330
+ if (endpointType === EndpointType.LangGraphPlatform) {
2321
2331
  const ep = endpoint;
2322
2332
  info = {
2323
2333
  ...info,
@@ -2432,9 +2442,20 @@ var RuntimeEventSource = class {
2432
2442
  async stream(callback) {
2433
2443
  this.callback = callback;
2434
2444
  }
2445
+ sendErrorMessageToChat() {
2446
+ const errorMessage = "\u274C An error occurred. Please try again.";
2447
+ if (!this.callback) {
2448
+ this.stream(async (eventStream$) => {
2449
+ eventStream$.sendTextMessage(randomId3(), errorMessage);
2450
+ });
2451
+ } else {
2452
+ this.eventStream$.sendTextMessage(randomId3(), errorMessage);
2453
+ }
2454
+ }
2435
2455
  processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
2436
2456
  this.callback(this.eventStream$).catch((error) => {
2437
2457
  console.error("Error in event source callback", error);
2458
+ this.sendErrorMessageToChat();
2438
2459
  });
2439
2460
  return this.eventStream$.pipe(
2440
2461
  // mark tools for server side execution
@@ -2534,7 +2555,7 @@ __name(executeAction, "executeAction");
2534
2555
  import { GraphQLJSONObject } from "graphql-scalars";
2535
2556
  import { plainToInstance as plainToInstance2 } from "class-transformer";
2536
2557
  import { GraphQLError } from "graphql";
2537
- import { randomId as randomId2 } from "@copilotkit/shared";
2558
+ import { randomId as randomId4 } from "@copilotkit/shared";
2538
2559
  function _ts_decorate12(decorators, target, key, desc) {
2539
2560
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2540
2561
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2651,7 +2672,7 @@ var CopilotResolver = class {
2651
2672
  rejectOutputMessagesPromise = reject;
2652
2673
  });
2653
2674
  logger2.debug("Processing");
2654
- const { eventSource, threadId = randomId2(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
2675
+ const { eventSource, threadId = randomId4(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
2655
2676
  serviceAdapter,
2656
2677
  messages: data.messages,
2657
2678
  actions: data.frontend.actions,
@@ -2696,7 +2717,7 @@ var CopilotResolver = class {
2696
2717
  });
2697
2718
  outputMessages = [
2698
2719
  plainToInstance2(TextMessage, {
2699
- id: randomId2(),
2720
+ id: randomId4(),
2700
2721
  createdAt: /* @__PURE__ */ new Date(),
2701
2722
  content: result.reason,
2702
2723
  role: MessageRole.assistant
@@ -2859,7 +2880,7 @@ var CopilotResolver = class {
2859
2880
  result: event.result
2860
2881
  }, "Action execution result event received");
2861
2882
  pushMessage({
2862
- id: randomId2(),
2883
+ id: randomId4(),
2863
2884
  status: new SuccessMessageStatus(),
2864
2885
  createdAt: /* @__PURE__ */ new Date(),
2865
2886
  actionExecutionId: event.actionExecutionId,
@@ -2867,7 +2888,7 @@ var CopilotResolver = class {
2867
2888
  result: event.result
2868
2889
  });
2869
2890
  outputMessages.push(plainToInstance2(ResultMessage, {
2870
- id: randomId2(),
2891
+ id: randomId4(),
2871
2892
  createdAt: /* @__PURE__ */ new Date(),
2872
2893
  actionExecutionId: event.actionExecutionId,
2873
2894
  actionName: event.actionName,
@@ -2879,7 +2900,7 @@ var CopilotResolver = class {
2879
2900
  event
2880
2901
  }, "Agent message event received");
2881
2902
  pushMessage({
2882
- id: randomId2(),
2903
+ id: randomId4(),
2883
2904
  status: new SuccessMessageStatus(),
2884
2905
  threadId: event.threadId,
2885
2906
  agentName: event.agentName,
@@ -2892,7 +2913,7 @@ var CopilotResolver = class {
2892
2913
  createdAt: /* @__PURE__ */ new Date()
2893
2914
  });
2894
2915
  outputMessages.push(plainToInstance2(AgentStateMessage, {
2895
- id: randomId2(),
2916
+ id: randomId4(),
2896
2917
  threadId: event.threadId,
2897
2918
  agentName: event.agentName,
2898
2919
  nodeName: event.nodeName,
@@ -3096,11 +3117,11 @@ export {
3096
3117
  CopilotRuntime,
3097
3118
  flattenToolCallsNoDuplicates,
3098
3119
  copilotKitEndpoint,
3099
- langGraphCloudEndpoint,
3120
+ langGraphPlatformEndpoint,
3100
3121
  resolveEndpointType,
3101
3122
  createContext,
3102
3123
  buildSchema,
3103
3124
  getCommonConfig,
3104
3125
  copilotRuntimeNodeHttpEndpoint
3105
3126
  };
3106
- //# sourceMappingURL=chunk-ODOSADGH.mjs.map
3127
+ //# sourceMappingURL=chunk-YILXJQFD.mjs.map