@copilotkit/runtime 1.6.0-next.1 → 1.6.0-next.10

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 (61) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/__snapshots__/schema/schema.graphql +1 -0
  3. package/dist/{chunk-CCQ73DAH.mjs → chunk-3ORZOFAL.mjs} +2 -2
  4. package/dist/{chunk-CHDIEE43.mjs → chunk-5NJDGEB3.mjs} +87 -44
  5. package/dist/chunk-5NJDGEB3.mjs.map +1 -0
  6. package/dist/{chunk-A25FIW7J.mjs → chunk-6XDMOAOM.mjs} +2 -2
  7. package/dist/{chunk-OS5YD32G.mjs → chunk-FZJAYGIR.mjs} +45 -12
  8. package/dist/chunk-FZJAYGIR.mjs.map +1 -0
  9. package/dist/{chunk-C7GTLEVO.mjs → chunk-JUWN34MZ.mjs} +2 -2
  10. package/dist/{copilot-runtime-67033bfa.d.ts → copilot-runtime-15bfc4f4.d.ts} +2 -2
  11. package/dist/graphql/types/converted/index.d.ts +1 -1
  12. package/dist/{groq-adapter-9d15c927.d.ts → groq-adapter-fb9aa3ab.d.ts} +1 -1
  13. package/dist/{index-f6d1f30b.d.ts → index-5bec5424.d.ts} +2 -1
  14. package/dist/index.d.ts +4 -4
  15. package/dist/index.js +199 -123
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +5 -5
  18. package/dist/{langserve-7cc5be48.d.ts → langserve-6f7af8d3.d.ts} +1 -1
  19. package/dist/lib/index.d.ts +4 -4
  20. package/dist/lib/index.js +192 -116
  21. package/dist/lib/index.js.map +1 -1
  22. package/dist/lib/index.mjs +5 -5
  23. package/dist/lib/integrations/index.d.ts +4 -4
  24. package/dist/lib/integrations/index.js +5 -3
  25. package/dist/lib/integrations/index.js.map +1 -1
  26. package/dist/lib/integrations/index.mjs +5 -5
  27. package/dist/lib/integrations/nest/index.d.ts +3 -3
  28. package/dist/lib/integrations/nest/index.js +5 -3
  29. package/dist/lib/integrations/nest/index.js.map +1 -1
  30. package/dist/lib/integrations/nest/index.mjs +3 -3
  31. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  32. package/dist/lib/integrations/node-express/index.js +5 -3
  33. package/dist/lib/integrations/node-express/index.js.map +1 -1
  34. package/dist/lib/integrations/node-express/index.mjs +3 -3
  35. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  36. package/dist/lib/integrations/node-http/index.js +5 -3
  37. package/dist/lib/integrations/node-http/index.js.map +1 -1
  38. package/dist/lib/integrations/node-http/index.mjs +2 -2
  39. package/dist/service-adapters/index.d.ts +4 -4
  40. package/dist/service-adapters/index.js +70 -37
  41. package/dist/service-adapters/index.js.map +1 -1
  42. package/dist/service-adapters/index.mjs +1 -1
  43. package/package.json +5 -4
  44. package/src/agents/langgraph/event-source.ts +21 -5
  45. package/src/graphql/types/enums.ts +1 -0
  46. package/src/lib/runtime/__tests__/remote-action-constructors.test.ts +236 -0
  47. package/src/lib/runtime/copilot-runtime.ts +9 -3
  48. package/src/lib/runtime/remote-action-constructors.ts +9 -7
  49. package/src/lib/runtime/remote-lg-action.ts +35 -7
  50. package/src/service-adapters/conversion.ts +39 -46
  51. package/src/service-adapters/groq/groq-adapter.ts +6 -3
  52. package/src/service-adapters/openai/openai-adapter.ts +1 -1
  53. package/src/service-adapters/openai/openai-assistant-adapter.ts +1 -1
  54. package/src/service-adapters/openai/utils.ts +39 -13
  55. package/src/service-adapters/unify/unify-adapter.ts +1 -1
  56. package/tsconfig.json +3 -2
  57. package/dist/chunk-CHDIEE43.mjs.map +0 -1
  58. package/dist/chunk-OS5YD32G.mjs.map +0 -1
  59. /package/dist/{chunk-CCQ73DAH.mjs.map → chunk-3ORZOFAL.mjs.map} +0 -0
  60. /package/dist/{chunk-A25FIW7J.mjs.map → chunk-6XDMOAOM.mjs.map} +0 -0
  61. /package/dist/{chunk-C7GTLEVO.mjs.map → chunk-JUWN34MZ.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.6.0-next.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 543f703: - fix: refrain from processing same tool end several times
8
+ - fix: do not register runtime set action when there are remote endpoints
9
+ - @copilotkit/shared@1.6.0-next.10
10
+
11
+ ## 1.6.0-next.9
12
+
13
+ ### Patch Changes
14
+
15
+ - d07f49c: - fix(runtime): fix execution of runtime set backend action handlers
16
+ - @copilotkit/shared@1.6.0-next.9
17
+
18
+ ## 1.6.0-next.8
19
+
20
+ ### Minor Changes
21
+
22
+ - fea916f: - feat: support input and output schema of langgraph
23
+ - docs: add input output schema docs
24
+
25
+ ### Patch Changes
26
+
27
+ - @copilotkit/shared@1.6.0-next.8
28
+
29
+ ## 1.6.0-next.7
30
+
31
+ ### Patch Changes
32
+
33
+ - @copilotkit/shared@1.6.0-next.7
34
+
35
+ ## 1.6.0-next.6
36
+
37
+ ### Patch Changes
38
+
39
+ - 45a3e10: - feat: support latest openai api
40
+ - chore: update all openai dependencies to use latest
41
+ - feat: update adapters using openai API
42
+ - @copilotkit/shared@1.6.0-next.6
43
+
44
+ ## 1.6.0-next.5
45
+
46
+ ### Patch Changes
47
+
48
+ - 090203d: - fix: use tryMap method to filter out possibly invalid items
49
+ - Updated dependencies [090203d]
50
+ - @copilotkit/shared@1.6.0-next.5
51
+
52
+ ## 1.6.0-next.4
53
+
54
+ ### Patch Changes
55
+
56
+ - 68f7b65: - handle parsing in fail-safe fashion
57
+ - @copilotkit/shared@1.6.0-next.4
58
+
59
+ ## 1.6.0-next.3
60
+
61
+ ### Patch Changes
62
+
63
+ - 4ddb6d2: - fix: add class validator to dependencies
64
+ - @copilotkit/shared@1.6.0-next.3
65
+
66
+ ## 1.6.0-next.2
67
+
68
+ ### Patch Changes
69
+
70
+ - @copilotkit/shared@1.6.0-next.2
71
+
3
72
  ## 1.6.0-next.1
4
73
 
5
74
  ### Patch Changes
@@ -244,6 +244,7 @@ input MessageInput {
244
244
  """The role of the message"""
245
245
  enum MessageRole {
246
246
  assistant
247
+ developer
247
248
  system
248
249
  tool
249
250
  user
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-CHDIEE43.mjs";
5
+ } from "./chunk-5NJDGEB3.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-CCQ73DAH.mjs.map
80
+ //# sourceMappingURL=chunk-3ORZOFAL.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  EmptyAdapter,
3
3
  RemoteChain,
4
4
  streamLangChainResponse
5
- } from "./chunk-OS5YD32G.mjs";
5
+ } from "./chunk-FZJAYGIR.mjs";
6
6
  import {
7
7
  GuardrailsValidationFailureResponse,
8
8
  MessageStreamInterruptedResponse,
@@ -39,7 +39,7 @@ var require_package = __commonJS({
39
39
  publishConfig: {
40
40
  access: "public"
41
41
  },
42
- version: "1.6.0-next.1",
42
+ version: "1.6.0-next.10",
43
43
  sideEffects: false,
44
44
  main: "./dist/index.js",
45
45
  module: "./dist/index.mjs",
@@ -61,7 +61,7 @@ var require_package = __commonJS({
61
61
  devDependencies: {
62
62
  "@swc/core": "1.5.28",
63
63
  "@types/express": "^4.17.21",
64
- "@types/jest": "^29.5.4",
64
+ "@types/jest": "^29.5.12",
65
65
  "@types/node": "^18.11.17",
66
66
  "@whatwg-node/server": "^0.9.34",
67
67
  eslint: "^8.56.0",
@@ -85,13 +85,14 @@ var require_package = __commonJS({
85
85
  "@langchain/langgraph-sdk": "^0.0.36",
86
86
  "@langchain/openai": "^0.4.2",
87
87
  "class-transformer": "^0.5.1",
88
+ "class-validator": "^0.14.1",
88
89
  express: "^4.19.2",
89
90
  graphql: "^16.8.1",
90
91
  "graphql-scalars": "^1.23.0",
91
92
  "graphql-yoga": "^5.3.1",
92
93
  "groq-sdk": "^0.5.0",
93
94
  langchain: "^0.3.3",
94
- openai: "^4.50.0",
95
+ openai: "^4.85.1",
95
96
  "partial-json": "^0.1.7",
96
97
  pino: "^9.2.0",
97
98
  "pino-pretty": "^11.2.1",
@@ -140,6 +141,7 @@ var MessageRole;
140
141
  MessageRole2["assistant"] = "assistant";
141
142
  MessageRole2["system"] = "system";
142
143
  MessageRole2["tool"] = "tool";
144
+ MessageRole2["developer"] = "developer";
143
145
  })(MessageRole || (MessageRole = {}));
144
146
  var CopilotRequestType;
145
147
  (function(CopilotRequestType2) {
@@ -1497,10 +1499,16 @@ var RemoteLangGraphEventSource = class {
1497
1499
  acc.lastMessageId = this.getCurrentMessageId(event) ?? acc.lastMessageId;
1498
1500
  const toolCallChunks = this.getCurrentToolCallChunks(event) ?? [];
1499
1501
  const responseMetadata = this.getResponseMetadata(event);
1502
+ const toolCallCheck = toolCallChunks && toolCallChunks.length > 0;
1503
+ let isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
1500
1504
  acc.isToolCallStart = toolCallChunks.some((chunk) => chunk.name && chunk.id);
1501
1505
  acc.isMessageStart = prevMessageId !== acc.lastMessageId && !acc.isToolCallStart;
1502
- acc.isToolCall = toolCallChunks && toolCallChunks.length > 0;
1503
- acc.isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
1506
+ let previousRoundHadToolCall = acc.isToolCall;
1507
+ acc.isToolCall = toolCallCheck;
1508
+ if (previousRoundHadToolCall && !toolCallCheck) {
1509
+ isToolCallEnd = true;
1510
+ }
1511
+ acc.isToolCallEnd = isToolCallEnd;
1504
1512
  acc.isMessageEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop";
1505
1513
  ({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find((chunk) => chunk.name && chunk.id) ?? {
1506
1514
  name: acc.lastToolCallName,
@@ -1520,7 +1528,8 @@ var RemoteLangGraphEventSource = class {
1520
1528
  lastMessageId: null,
1521
1529
  lastToolCallId: null,
1522
1530
  lastToolCallName: null,
1523
- currentContent: null
1531
+ currentContent: null,
1532
+ processedToolCallIds: /* @__PURE__ */ new Set()
1524
1533
  }), mergeMap((acc) => {
1525
1534
  const events = [];
1526
1535
  let shouldEmitMessages = true;
@@ -1548,13 +1557,13 @@ var RemoteLangGraphEventSource = class {
1548
1557
  });
1549
1558
  }
1550
1559
  const responseMetadata = this.getResponseMetadata(acc.event);
1551
- if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls" && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
1560
+ if (acc.isToolCallEnd && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName) && acc.lastToolCallId && !acc.processedToolCallIds.has(acc.lastToolCallId)) {
1561
+ acc.processedToolCallIds.add(acc.lastToolCallId);
1552
1562
  events.push({
1553
1563
  type: RuntimeEventTypes.ActionExecutionEnd,
1554
1564
  actionExecutionId: acc.lastToolCallId
1555
1565
  });
1556
- }
1557
- if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
1566
+ } else if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
1558
1567
  events.push({
1559
1568
  type: RuntimeEventTypes.TextMessageEnd,
1560
1569
  messageId: acc.lastMessageId
@@ -1616,6 +1625,7 @@ var RemoteLangGraphEventSource = class {
1616
1625
  parentMessageId: acc.lastMessageId
1617
1626
  });
1618
1627
  } else if (acc.isMessageStart && shouldEmitMessages) {
1628
+ acc.processedToolCallIds.clear();
1619
1629
  events.push({
1620
1630
  type: RuntimeEventTypes.TextMessageStart,
1621
1631
  messageId: acc.lastMessageId
@@ -1677,6 +1687,7 @@ import { Client as LangGraphClient } from "@langchain/langgraph-sdk";
1677
1687
  import { createHash } from "crypto";
1678
1688
  import { isValidUUID, randomUUID } from "@copilotkit/shared";
1679
1689
  import { parse as parsePartialJson } from "partial-json";
1690
+ import { parseJson } from "@copilotkit/shared";
1680
1691
  var activeInterruptEvent = false;
1681
1692
  async function execute(args) {
1682
1693
  return new ReadableStream({
@@ -1756,15 +1767,9 @@ async function streamEvents(controller, args) {
1756
1767
  }
1757
1768
  if (lgInterruptMetaEvent == null ? void 0 : lgInterruptMetaEvent.response) {
1758
1769
  let response = lgInterruptMetaEvent.response;
1759
- try {
1760
- payload.command = {
1761
- resume: JSON.parse(response)
1762
- };
1763
- } catch (e) {
1764
- payload.command = {
1765
- resume: response
1766
- };
1767
- }
1770
+ payload.command = {
1771
+ resume: parseJson(response, response)
1772
+ };
1768
1773
  }
1769
1774
  if (mode === "continue" && !activeInterruptEvent) {
1770
1775
  await client.threads.updateState(threadId, {
@@ -1800,6 +1805,11 @@ async function streamEvents(controller, args) {
1800
1805
  });
1801
1806
  }
1802
1807
  const graphInfo = await client.assistants.getGraph(assistantId);
1808
+ const graphSchema = await client.assistants.getSchemas(assistantId);
1809
+ const schemaKeys = getSchemaKeys(graphSchema);
1810
+ if (payload.input && schemaKeys.input) {
1811
+ payload.input = Object.fromEntries(Object.entries(payload.input).filter(([key]) => schemaKeys.input.includes(key)));
1812
+ }
1803
1813
  let streamingStateExtractor = new StreamingStateExtractor([]);
1804
1814
  let prevNodeName = null;
1805
1815
  let emitIntermediateStateUntilEnd = null;
@@ -1891,7 +1901,8 @@ async function streamEvents(controller, args) {
1891
1901
  nodeName,
1892
1902
  state: manuallyEmittedState,
1893
1903
  running: true,
1894
- active: true
1904
+ active: true,
1905
+ schemaKeys
1895
1906
  }));
1896
1907
  continue;
1897
1908
  }
@@ -1923,7 +1934,8 @@ async function streamEvents(controller, args) {
1923
1934
  nodeName,
1924
1935
  state,
1925
1936
  running: true,
1926
- active: !exitingNode
1937
+ active: !exitingNode,
1938
+ schemaKeys
1927
1939
  }));
1928
1940
  }
1929
1941
  emit(JSON.stringify(event) + "\n");
@@ -1941,7 +1953,8 @@ async function streamEvents(controller, args) {
1941
1953
  state: state.values,
1942
1954
  running: !shouldExit,
1943
1955
  active: false,
1944
- includeMessages: true
1956
+ includeMessages: true,
1957
+ schemaKeys
1945
1958
  }));
1946
1959
  return Promise.resolve();
1947
1960
  } catch (e) {
@@ -1954,7 +1967,7 @@ async function streamEvents(controller, args) {
1954
1967
  }
1955
1968
  }
1956
1969
  __name(streamEvents, "streamEvents");
1957
- function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false }) {
1970
+ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false, schemaKeys }) {
1958
1971
  if (!includeMessages) {
1959
1972
  state = Object.keys(state).reduce((acc, key) => {
1960
1973
  if (key !== "messages") {
@@ -1968,6 +1981,9 @@ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, runnin
1968
1981
  messages: langchainMessagesToCopilotKit(state.messages || [])
1969
1982
  };
1970
1983
  }
1984
+ if (schemaKeys.output) {
1985
+ state = Object.fromEntries(Object.entries(state).filter(([key]) => schemaKeys.output.includes(key)));
1986
+ }
1971
1987
  return JSON.stringify({
1972
1988
  event: LangGraphEventTypes.OnCopilotKitStateSync,
1973
1989
  thread_id: threadId,
@@ -2202,10 +2218,30 @@ function copilotkitMessagesToLangChain(messages) {
2202
2218
  return result;
2203
2219
  }
2204
2220
  __name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
2221
+ function getSchemaKeys(graphSchema) {
2222
+ const CONSTANT_KEYS = [
2223
+ "messages",
2224
+ "copilotkit"
2225
+ ];
2226
+ const inputSchema = Object.keys(graphSchema.input_schema.properties);
2227
+ const outputSchema = Object.keys(graphSchema.output_schema.properties);
2228
+ return {
2229
+ input: inputSchema && inputSchema.length ? [
2230
+ ...inputSchema,
2231
+ ...CONSTANT_KEYS
2232
+ ] : null,
2233
+ output: outputSchema && outputSchema.length ? [
2234
+ ...outputSchema,
2235
+ ...CONSTANT_KEYS
2236
+ ] : null
2237
+ };
2238
+ }
2239
+ __name(getSchemaKeys, "getSchemaKeys");
2205
2240
 
2206
2241
  // src/lib/runtime/remote-action-constructors.ts
2207
2242
  import { CopilotKitError, CopilotKitLowLevelError } from "@copilotkit/shared";
2208
2243
  import { CopilotKitApiDiscoveryError, ResolvedCopilotKitError } from "@copilotkit/shared";
2244
+ import { parseJson as parseJson2, tryMap } from "@copilotkit/shared";
2209
2245
  function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
2210
2246
  const agents = endpoint.agents.map((agent) => ({
2211
2247
  name: agent.name,
@@ -2228,8 +2264,8 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
2228
2264
  if (agentStates) {
2229
2265
  const jsonState = agentStates.find((state2) => state2.agentName === name);
2230
2266
  if (jsonState) {
2231
- state = JSON.parse(jsonState.state);
2232
- configurable = JSON.parse(jsonState.configurable);
2267
+ state = parseJson2(jsonState.state, {});
2268
+ configurable = parseJson2(jsonState.configurable, {});
2233
2269
  }
2234
2270
  }
2235
2271
  try {
@@ -2249,7 +2285,7 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
2249
2285
  state,
2250
2286
  configurable,
2251
2287
  properties: graphqlContext.properties,
2252
- actions: actionInputsWithoutAgents.map((action) => ({
2288
+ actions: tryMap(actionInputsWithoutAgents, (action) => ({
2253
2289
  name: action.name,
2254
2290
  description: action.description,
2255
2291
  parameters: JSON.parse(action.jsonSchema)
@@ -2358,8 +2394,8 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2358
2394
  if (agentStates) {
2359
2395
  const jsonState = agentStates.find((state2) => state2.agentName === name);
2360
2396
  if (jsonState) {
2361
- state = JSON.parse(jsonState.state);
2362
- configurable = JSON.parse(jsonState.configurable);
2397
+ state = parseJson2(jsonState.state, {});
2398
+ configurable = parseJson2(jsonState.configurable, {});
2363
2399
  }
2364
2400
  }
2365
2401
  const fetchUrl = `${url}/agents/execute`;
@@ -2378,7 +2414,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2378
2414
  state,
2379
2415
  configurable,
2380
2416
  properties: graphqlContext.properties,
2381
- actions: actionInputsWithoutAgents.map((action) => ({
2417
+ actions: tryMap(actionInputsWithoutAgents, (action) => ({
2382
2418
  name: action.name,
2383
2419
  description: action.description,
2384
2420
  parameters: JSON.parse(action.jsonSchema)
@@ -2601,35 +2637,35 @@ import { actionParametersToJsonSchema, ResolvedCopilotKitError as ResolvedCopilo
2601
2637
 
2602
2638
  // src/service-adapters/conversion.ts
2603
2639
  import { plainToInstance } from "class-transformer";
2640
+ import { tryMap as tryMap2 } from "@copilotkit/shared";
2604
2641
  function convertGqlInputToMessages(inputMessages) {
2605
- const messages = [];
2606
- for (const message of inputMessages) {
2642
+ const messages = tryMap2(inputMessages, (message) => {
2607
2643
  if (message.textMessage) {
2608
- messages.push(plainToInstance(TextMessage, {
2644
+ return plainToInstance(TextMessage, {
2609
2645
  id: message.id,
2610
2646
  createdAt: message.createdAt,
2611
2647
  role: message.textMessage.role,
2612
2648
  content: message.textMessage.content,
2613
2649
  parentMessageId: message.textMessage.parentMessageId
2614
- }));
2650
+ });
2615
2651
  } else if (message.actionExecutionMessage) {
2616
- messages.push(plainToInstance(ActionExecutionMessage, {
2652
+ return plainToInstance(ActionExecutionMessage, {
2617
2653
  id: message.id,
2618
2654
  createdAt: message.createdAt,
2619
2655
  name: message.actionExecutionMessage.name,
2620
2656
  arguments: JSON.parse(message.actionExecutionMessage.arguments),
2621
2657
  parentMessageId: message.actionExecutionMessage.parentMessageId
2622
- }));
2658
+ });
2623
2659
  } else if (message.resultMessage) {
2624
- messages.push(plainToInstance(ResultMessage, {
2660
+ return plainToInstance(ResultMessage, {
2625
2661
  id: message.id,
2626
2662
  createdAt: message.createdAt,
2627
2663
  actionExecutionId: message.resultMessage.actionExecutionId,
2628
2664
  actionName: message.resultMessage.actionName,
2629
2665
  result: message.resultMessage.result
2630
- }));
2666
+ });
2631
2667
  } else if (message.agentStateMessage) {
2632
- messages.push(plainToInstance(AgentStateMessage, {
2668
+ return plainToInstance(AgentStateMessage, {
2633
2669
  id: message.id,
2634
2670
  threadId: message.agentStateMessage.threadId,
2635
2671
  createdAt: message.createdAt,
@@ -2640,10 +2676,12 @@ function convertGqlInputToMessages(inputMessages) {
2640
2676
  role: message.agentStateMessage.role,
2641
2677
  state: JSON.parse(message.agentStateMessage.state),
2642
2678
  running: message.agentStateMessage.running
2643
- }));
2679
+ });
2680
+ } else {
2681
+ return null;
2644
2682
  }
2645
- }
2646
- return messages;
2683
+ });
2684
+ return messages.filter((m) => m);
2647
2685
  }
2648
2686
  __name(convertGqlInputToMessages, "convertGqlInputToMessages");
2649
2687
 
@@ -2659,7 +2697,12 @@ var CopilotRuntime = class {
2659
2697
  delegateAgentProcessingToServiceAdapter;
2660
2698
  constructor(params) {
2661
2699
  var _a, _b;
2662
- this.actions = (params == null ? void 0 : params.actions) || [];
2700
+ if ((params == null ? void 0 : params.actions) && (params == null ? void 0 : params.remoteEndpoints)) {
2701
+ console.warn("Actions set in runtime instance will be ignored when remote endpoints are set");
2702
+ this.actions = [];
2703
+ } else {
2704
+ this.actions = (params == null ? void 0 : params.actions) || [];
2705
+ }
2663
2706
  for (const chain of (params == null ? void 0 : params.langserve) || []) {
2664
2707
  const remoteChain = new RemoteChain(chain);
2665
2708
  this.langserve.push(remoteChain.toAction());
@@ -2971,7 +3014,7 @@ please use an LLM adapter instead.`
2971
3014
  threadId,
2972
3015
  runId: void 0,
2973
3016
  eventSource,
2974
- serverSideActions: [],
3017
+ serverSideActions,
2975
3018
  actionInputsWithoutAgents: allAvailableActions
2976
3019
  };
2977
3020
  } catch (error) {
@@ -4262,4 +4305,4 @@ export {
4262
4305
  getCommonConfig,
4263
4306
  copilotRuntimeNodeHttpEndpoint
4264
4307
  };
4265
- //# sourceMappingURL=chunk-CHDIEE43.mjs.map
4308
+ //# sourceMappingURL=chunk-5NJDGEB3.mjs.map