@copilotkit/runtime 1.50.0-beta.9 → 1.50.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 (182) hide show
  1. package/CHANGELOG.md +157 -0
  2. package/dist/chunk-27JKTS6P.mjs +1704 -0
  3. package/dist/chunk-27JKTS6P.mjs.map +1 -0
  4. package/dist/{chunk-FMU55SEU.mjs → chunk-2GPTVDTO.mjs} +2 -2
  5. package/dist/chunk-3AJVKDZX.mjs +3097 -0
  6. package/dist/chunk-3AJVKDZX.mjs.map +1 -0
  7. package/dist/{chunk-BJEYMRDD.mjs → chunk-45RCC3ZS.mjs} +2 -2
  8. package/dist/chunk-4EHJ4XFJ.mjs +25 -0
  9. package/dist/chunk-4EHJ4XFJ.mjs.map +1 -0
  10. package/dist/chunk-4IANB4TC.mjs +25 -0
  11. package/dist/chunk-4IANB4TC.mjs.map +1 -0
  12. package/dist/{chunk-Z752VE75.mjs → chunk-4KES76K3.mjs} +2 -2
  13. package/dist/chunk-4OGE3SLW.mjs +3100 -0
  14. package/dist/chunk-4OGE3SLW.mjs.map +1 -0
  15. package/dist/chunk-54YJBMCP.mjs +3097 -0
  16. package/dist/chunk-54YJBMCP.mjs.map +1 -0
  17. package/dist/chunk-6ER4SZYH.mjs +74 -0
  18. package/dist/chunk-6ER4SZYH.mjs.map +1 -0
  19. package/dist/chunk-6TNSLHVR.mjs +74 -0
  20. package/dist/chunk-6TNSLHVR.mjs.map +1 -0
  21. package/dist/chunk-7V4BK7TZ.mjs +25 -0
  22. package/dist/chunk-7V4BK7TZ.mjs.map +1 -0
  23. package/dist/chunk-7YZIEXD2.mjs +74 -0
  24. package/dist/chunk-7YZIEXD2.mjs.map +1 -0
  25. package/dist/chunk-A4XHOAFU.mjs +25 -0
  26. package/dist/chunk-A4XHOAFU.mjs.map +1 -0
  27. package/dist/chunk-A555KEAD.mjs +6020 -0
  28. package/dist/chunk-A555KEAD.mjs.map +1 -0
  29. package/dist/chunk-AF73TFTX.mjs +74 -0
  30. package/dist/chunk-AF73TFTX.mjs.map +1 -0
  31. package/dist/chunk-AQG2SVCA.mjs +25 -0
  32. package/dist/chunk-AQG2SVCA.mjs.map +1 -0
  33. package/dist/chunk-BJZHMXND.mjs +74 -0
  34. package/dist/chunk-BJZHMXND.mjs.map +1 -0
  35. package/dist/chunk-CB2OJXF6.mjs +25 -0
  36. package/dist/chunk-CB2OJXF6.mjs.map +1 -0
  37. package/dist/chunk-CEOMFPJU.mjs +6020 -0
  38. package/dist/chunk-CEOMFPJU.mjs.map +1 -0
  39. package/dist/chunk-CZVLR7CC.mjs +175 -0
  40. package/dist/chunk-CZVLR7CC.mjs.map +1 -0
  41. package/dist/{chunk-SBCOROE4.mjs → chunk-DCEEHMLJ.mjs} +16 -1
  42. package/dist/chunk-DCEEHMLJ.mjs.map +1 -0
  43. package/dist/chunk-DE3CLKUG.mjs +25 -0
  44. package/dist/chunk-DE3CLKUG.mjs.map +1 -0
  45. package/dist/chunk-DTPRUTNV.mjs +25 -0
  46. package/dist/chunk-DTPRUTNV.mjs.map +1 -0
  47. package/dist/{chunk-TTUAEJLD.mjs → chunk-ERUOA47O.mjs} +11 -2
  48. package/dist/chunk-ERUOA47O.mjs.map +1 -0
  49. package/dist/chunk-ESSRC64W.mjs +74 -0
  50. package/dist/chunk-ESSRC64W.mjs.map +1 -0
  51. package/dist/chunk-GRAN6K6N.mjs +25 -0
  52. package/dist/chunk-GRAN6K6N.mjs.map +1 -0
  53. package/dist/chunk-I27F2UPA.mjs +175 -0
  54. package/dist/chunk-I27F2UPA.mjs.map +1 -0
  55. package/dist/chunk-IAZKTOQW.mjs +25 -0
  56. package/dist/chunk-IAZKTOQW.mjs.map +1 -0
  57. package/dist/chunk-J6XZ5MFB.mjs +25 -0
  58. package/dist/chunk-J6XZ5MFB.mjs.map +1 -0
  59. package/dist/chunk-JJ32MA4C.mjs +73 -0
  60. package/dist/chunk-JJ32MA4C.mjs.map +1 -0
  61. package/dist/chunk-JJY4ZTHQ.mjs +25 -0
  62. package/dist/chunk-JJY4ZTHQ.mjs.map +1 -0
  63. package/dist/chunk-KEYLBFU2.mjs +3117 -0
  64. package/dist/chunk-KEYLBFU2.mjs.map +1 -0
  65. package/dist/chunk-KQ53L4WZ.mjs +3094 -0
  66. package/dist/chunk-KQ53L4WZ.mjs.map +1 -0
  67. package/dist/chunk-KTELVQ67.mjs +3098 -0
  68. package/dist/chunk-KTELVQ67.mjs.map +1 -0
  69. package/dist/chunk-LPEPX6NH.mjs +25 -0
  70. package/dist/chunk-LPEPX6NH.mjs.map +1 -0
  71. package/dist/chunk-MDXE55DK.mjs +3117 -0
  72. package/dist/chunk-MDXE55DK.mjs.map +1 -0
  73. package/dist/chunk-MMFUVOXH.mjs +73 -0
  74. package/dist/chunk-MMFUVOXH.mjs.map +1 -0
  75. package/dist/chunk-N3Y4U66N.mjs +253 -0
  76. package/dist/chunk-N3Y4U66N.mjs.map +1 -0
  77. package/dist/chunk-O7UYB4MH.mjs +25 -0
  78. package/dist/chunk-O7UYB4MH.mjs.map +1 -0
  79. package/dist/chunk-OFNVQHNM.mjs +3089 -0
  80. package/dist/chunk-OFNVQHNM.mjs.map +1 -0
  81. package/dist/{chunk-DZV4ZIAR.mjs → chunk-OFSV5GET.mjs} +17 -6
  82. package/dist/chunk-OFSV5GET.mjs.map +1 -0
  83. package/dist/chunk-OMRST67R.mjs +25 -0
  84. package/dist/chunk-OMRST67R.mjs.map +1 -0
  85. package/dist/chunk-PRZHE74A.mjs +25 -0
  86. package/dist/chunk-PRZHE74A.mjs.map +1 -0
  87. package/dist/chunk-PTYRVXXP.mjs +80 -0
  88. package/dist/chunk-PTYRVXXP.mjs.map +1 -0
  89. package/dist/chunk-R22B5CCO.mjs +25 -0
  90. package/dist/chunk-R22B5CCO.mjs.map +1 -0
  91. package/dist/chunk-SHBDMA63.mjs +141 -0
  92. package/dist/chunk-SHBDMA63.mjs.map +1 -0
  93. package/dist/chunk-SPVXBPRA.mjs +74 -0
  94. package/dist/chunk-SPVXBPRA.mjs.map +1 -0
  95. package/dist/chunk-T72G46ME.mjs +25 -0
  96. package/dist/chunk-T72G46ME.mjs.map +1 -0
  97. package/dist/chunk-TGELROPU.mjs +25 -0
  98. package/dist/chunk-TGELROPU.mjs.map +1 -0
  99. package/dist/chunk-UNX4IAAD.mjs +25 -0
  100. package/dist/chunk-UNX4IAAD.mjs.map +1 -0
  101. package/dist/chunk-V4DHVC7M.mjs +3085 -0
  102. package/dist/chunk-V4DHVC7M.mjs.map +1 -0
  103. package/dist/chunk-VVRFOB66.mjs +25 -0
  104. package/dist/chunk-VVRFOB66.mjs.map +1 -0
  105. package/dist/chunk-W6NVBYM6.mjs +80 -0
  106. package/dist/chunk-W6NVBYM6.mjs.map +1 -0
  107. package/dist/chunk-W7MBACGC.mjs +74 -0
  108. package/dist/chunk-W7MBACGC.mjs.map +1 -0
  109. package/dist/chunk-WMD4XZZS.mjs +25 -0
  110. package/dist/chunk-WMD4XZZS.mjs.map +1 -0
  111. package/dist/chunk-WX2ZNCRT.mjs +74 -0
  112. package/dist/chunk-WX2ZNCRT.mjs.map +1 -0
  113. package/dist/chunk-Y2Z62E2T.mjs +74 -0
  114. package/dist/chunk-Y2Z62E2T.mjs.map +1 -0
  115. package/dist/chunk-YO4I6RVI.mjs +25 -0
  116. package/dist/chunk-YO4I6RVI.mjs.map +1 -0
  117. package/dist/chunk-Z6Q5IW6I.mjs +3098 -0
  118. package/dist/chunk-Z6Q5IW6I.mjs.map +1 -0
  119. package/dist/chunk-Z726O3G2.mjs +25 -0
  120. package/dist/chunk-Z726O3G2.mjs.map +1 -0
  121. package/dist/chunk-ZE4SMZZR.mjs +3097 -0
  122. package/dist/chunk-ZE4SMZZR.mjs.map +1 -0
  123. package/dist/chunk-ZULZB33C.mjs +73 -0
  124. package/dist/chunk-ZULZB33C.mjs.map +1 -0
  125. package/dist/chunk-ZVRGXMY7.mjs +25 -0
  126. package/dist/chunk-ZVRGXMY7.mjs.map +1 -0
  127. package/dist/chunk-ZZ35WBYQ.mjs +25 -0
  128. package/dist/chunk-ZZ35WBYQ.mjs.map +1 -0
  129. package/dist/graphql/types/converted/index.d.ts +1 -1
  130. package/dist/graphql/types/converted/index.js +16 -110
  131. package/dist/graphql/types/converted/index.js.map +1 -1
  132. package/dist/graphql/types/converted/index.mjs +2 -3
  133. package/dist/{groq-adapter-50bc6e4a.d.ts → groq-adapter-540da9c3.d.ts} +6 -1
  134. package/dist/groq-adapter-a6f5e9d2.d.ts +331 -0
  135. package/dist/groq-adapter-c8aec5c5.d.ts +321 -0
  136. package/dist/index-96b330da.d.ts +119 -0
  137. package/dist/index.d.ts +67 -8
  138. package/dist/index.js +118 -28
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.mjs +120 -31
  141. package/dist/index.mjs.map +1 -1
  142. package/dist/langserve-0c6100e3.d.ts +257 -0
  143. package/dist/langserve-978d5790.d.ts +243 -0
  144. package/dist/{langserve-74a52292.d.ts → langserve-9fc76ce5.d.ts} +1 -0
  145. package/dist/lib/index.d.ts +5 -59
  146. package/dist/lib/index.js +3702 -803
  147. package/dist/lib/index.js.map +1 -1
  148. package/dist/lib/index.mjs +20 -18
  149. package/dist/lib/integrations/index.d.ts +15 -9
  150. package/dist/lib/integrations/index.js +215 -187
  151. package/dist/lib/integrations/index.js.map +1 -1
  152. package/dist/lib/integrations/index.mjs +8 -7
  153. package/dist/lib/integrations/nest/index.d.ts +5 -6
  154. package/dist/lib/integrations/nest/index.js +197 -175
  155. package/dist/lib/integrations/nest/index.js.map +1 -1
  156. package/dist/lib/integrations/nest/index.mjs +6 -5
  157. package/dist/lib/integrations/node-express/index.d.ts +5 -6
  158. package/dist/lib/integrations/node-express/index.js +197 -175
  159. package/dist/lib/integrations/node-express/index.js.map +1 -1
  160. package/dist/lib/integrations/node-express/index.mjs +6 -5
  161. package/dist/lib/integrations/node-http/index.d.ts +5 -6
  162. package/dist/lib/integrations/node-http/index.js +197 -175
  163. package/dist/lib/integrations/node-http/index.js.map +1 -1
  164. package/dist/lib/integrations/node-http/index.mjs +5 -4
  165. package/dist/service-adapters/index.d.ts +7 -11
  166. package/dist/service-adapters/index.js +8 -21
  167. package/dist/service-adapters/index.js.map +1 -1
  168. package/dist/service-adapters/index.mjs +2 -4
  169. package/dist/shared-0a7346ce.d.ts +466 -0
  170. package/dist/{shared-f6d43ef8.d.ts → shared-35c6eb04.d.ts} +3 -1
  171. package/dist/shared-9ed1dc31.d.ts +414 -0
  172. package/dist/shared-da5708fe.d.ts +449 -0
  173. package/package.json +14 -20
  174. package/src/lib/index.ts +7 -6
  175. package/src/lib/runtime/copilot-runtime.ts +62 -26
  176. package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
  177. package/dist/chunk-DZV4ZIAR.mjs.map +0 -1
  178. package/dist/chunk-SBCOROE4.mjs.map +0 -1
  179. package/dist/chunk-TTUAEJLD.mjs.map +0 -1
  180. /package/dist/{chunk-FMU55SEU.mjs.map → chunk-2GPTVDTO.mjs.map} +0 -0
  181. /package/dist/{chunk-BJEYMRDD.mjs.map → chunk-45RCC3ZS.mjs.map} +0 -0
  182. /package/dist/{chunk-Z752VE75.mjs.map → chunk-4KES76K3.mjs.map} +0 -0
@@ -12,11 +12,11 @@ var __export = (target, all) => {
12
12
  for (var name in all)
13
13
  __defProp(target, name, { get: all[name], enumerable: true });
14
14
  };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
15
+ var __copyProps = (to, from3, except, desc) => {
16
+ if (from3 && typeof from3 === "object" || typeof from3 === "function") {
17
+ for (let key of __getOwnPropNames(from3))
18
18
  if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ __defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
20
20
  }
21
21
  return to;
22
22
  };
@@ -79,14 +79,11 @@ var require_package = __commonJS({
79
79
  tsconfig: "workspace:*",
80
80
  tsup: "^6.7.0",
81
81
  typescript: "^5.2.3",
82
- vitest: "^3.2.4",
83
82
  "zod-to-json-schema": "^3.23.5"
84
83
  },
85
84
  dependencies: {
86
85
  "@anthropic-ai/sdk": "^0.57.0",
87
86
  "@copilotkit/shared": "workspace:*",
88
- "@copilotkitnext/agent": "^0.0.17",
89
- "@copilotkitnext/runtime": "^0.0.17",
90
87
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
91
88
  "@langchain/aws": "^0.1.9",
92
89
  "@langchain/community": "^0.3.29",
@@ -143,14 +140,14 @@ __export(nest_exports, {
143
140
  module.exports = __toCommonJS(nest_exports);
144
141
 
145
142
  // src/lib/integrations/node-http/index.ts
146
- var import_runtime32 = require("@copilotkitnext/runtime");
143
+ var import_graphql_yoga2 = require("graphql-yoga");
147
144
 
148
145
  // src/lib/integrations/shared.ts
149
146
  var import_type_graphql27 = require("type-graphql");
150
147
 
151
148
  // src/graphql/resolvers/copilot.resolver.ts
152
149
  var import_type_graphql21 = require("type-graphql");
153
- var import_rxjs2 = require("rxjs");
150
+ var import_rxjs3 = require("rxjs");
154
151
 
155
152
  // src/graphql/inputs/generate-copilot-response.input.ts
156
153
  var import_type_graphql19 = require("type-graphql");
@@ -162,11 +159,11 @@ var import_type_graphql3 = require("type-graphql");
162
159
  var import_type_graphql = require("type-graphql");
163
160
  var MessageRole;
164
161
  (function(MessageRole2) {
162
+ MessageRole2["user"] = "user";
165
163
  MessageRole2["assistant"] = "assistant";
166
- MessageRole2["developer"] = "developer";
167
164
  MessageRole2["system"] = "system";
168
165
  MessageRole2["tool"] = "tool";
169
- MessageRole2["user"] = "user";
166
+ MessageRole2["developer"] = "developer";
170
167
  })(MessageRole || (MessageRole = {}));
171
168
  var CopilotRequestType;
172
169
  (function(CopilotRequestType2) {
@@ -873,10 +870,9 @@ var MessageStatusCode;
873
870
  (0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
874
871
  name: "MessageStatusCode"
875
872
  });
876
- var BaseMessageStatus = class {
873
+ var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
877
874
  code;
878
- };
879
- __name(BaseMessageStatus, "BaseMessageStatus");
875
+ }, "BaseMessageStatus");
880
876
  _ts_decorate11([
881
877
  (0, import_type_graphql12.Field)(() => MessageStatusCode),
882
878
  _ts_metadata11("design:type", String)
@@ -1683,24 +1679,13 @@ GenerateCopilotResponseInput = _ts_decorate18([
1683
1679
  var import_graphql_yoga = require("graphql-yoga");
1684
1680
 
1685
1681
  // src/service-adapters/events.ts
1686
- var import_shared2 = require("@copilotkit/shared");
1687
- var import_rxjs = require("rxjs");
1682
+ var import_shared5 = require("@copilotkit/shared");
1683
+ var import_class_transformer = require("class-transformer");
1684
+ var import_rxjs2 = require("rxjs");
1688
1685
 
1689
1686
  // src/graphql/types/converted/index.ts
1690
- var import_shared = require("@copilotkit/shared");
1691
- var Message = class {
1687
+ var Message = class extends BaseMessageInput {
1692
1688
  type;
1693
- id;
1694
- createdAt;
1695
- status;
1696
- constructor(props) {
1697
- props.id ?? (props.id = (0, import_shared.randomId)());
1698
- props.status ?? (props.status = {
1699
- code: MessageStatusCode.Success
1700
- });
1701
- props.createdAt ?? (props.createdAt = /* @__PURE__ */ new Date());
1702
- Object.assign(this, props);
1703
- }
1704
1689
  isTextMessage() {
1705
1690
  return this.type === "TextMessage";
1706
1691
  }
@@ -1719,14 +1704,10 @@ var Message = class {
1719
1704
  };
1720
1705
  __name(Message, "Message");
1721
1706
  var TextMessage = class extends Message {
1707
+ type = "TextMessage";
1722
1708
  content;
1723
- parentMessageId;
1724
1709
  role;
1725
- type = "TextMessage";
1726
- constructor(props) {
1727
- super(props);
1728
- this.type = "TextMessage";
1729
- }
1710
+ parentMessageId;
1730
1711
  };
1731
1712
  __name(TextMessage, "TextMessage");
1732
1713
  var ActionExecutionMessage = class extends Message {
@@ -1819,80 +1800,17 @@ var AgentStateMessage = class extends Message {
1819
1800
  };
1820
1801
  __name(AgentStateMessage, "AgentStateMessage");
1821
1802
 
1822
- // src/service-adapters/events.ts
1823
- var RuntimeEventTypes;
1824
- (function(RuntimeEventTypes2) {
1825
- RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
1826
- RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
1827
- RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
1828
- RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
1829
- RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1830
- RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1831
- RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1832
- RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1833
- RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
1834
- RuntimeEventTypes2["RunError"] = "RunError";
1835
- })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1836
- var RuntimeMetaEventName;
1837
- (function(RuntimeMetaEventName2) {
1838
- RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1839
- RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
1840
- RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1841
- })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
1842
-
1843
- // src/graphql/resolvers/copilot.resolver.ts
1844
- var import_graphql_scalars2 = require("graphql-scalars");
1845
- var import_class_transformer = require("class-transformer");
1846
- var import_graphql = require("graphql");
1847
-
1848
- // src/utils/failed-response-status-reasons.ts
1849
- var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
1850
- reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
1851
- constructor({ guardrailsReason }) {
1852
- super();
1853
- this.details = {
1854
- guardrailsReason
1855
- };
1856
- }
1857
- };
1858
- __name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
1859
- var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
1860
- reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
1861
- constructor({ messageId }) {
1862
- super();
1863
- this.details = {
1864
- messageId,
1865
- description: "Check the message for mode details"
1866
- };
1867
- }
1868
- };
1869
- __name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
1870
- var UnknownErrorResponse = class extends FailedResponseStatus {
1871
- reason = FailedResponseStatusReason.UNKNOWN_ERROR;
1872
- constructor({ description, originalError }) {
1873
- super();
1874
- this.details = {
1875
- description,
1876
- originalError
1877
- };
1878
- }
1879
- };
1880
- __name(UnknownErrorResponse, "UnknownErrorResponse");
1803
+ // src/lib/runtime/remote-actions.ts
1804
+ var import_shared3 = require("@copilotkit/shared");
1881
1805
 
1882
1806
  // src/lib/telemetry-client.ts
1883
- var import_shared4 = require("@copilotkit/shared");
1807
+ var import_shared2 = require("@copilotkit/shared");
1884
1808
  var import_node_crypto = require("crypto");
1885
1809
 
1886
1810
  // src/lib/runtime/copilot-runtime.ts
1887
- var import_shared3 = require("@copilotkit/shared");
1888
- var import_runtime22 = require("@copilotkitnext/runtime");
1889
-
1890
- // src/lib/runtime/types.ts
1891
- var EndpointType;
1892
- (function(EndpointType2) {
1893
- EndpointType2["CopilotKit"] = "copilotKit";
1894
- EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1895
- })(EndpointType || (EndpointType = {}));
1811
+ var import_shared = require("@copilotkit/shared");
1812
+ var import_rxjs = require("rxjs");
1813
+ var import_langgraph_sdk = require("@langchain/langgraph-sdk");
1896
1814
 
1897
1815
  // src/agents/langgraph/events.ts
1898
1816
  var LangGraphEventTypes;
@@ -1927,7 +1845,6 @@ var CustomEventNames;
1927
1845
  })(CustomEventNames || (CustomEventNames = {}));
1928
1846
 
1929
1847
  // src/lib/runtime/copilot-runtime.ts
1930
- var import_agent = require("@copilotkitnext/agent");
1931
1848
  function resolveEndpointType(endpoint) {
1932
1849
  if (!endpoint.type) {
1933
1850
  if ("deploymentUrl" in endpoint && "agents" in endpoint) {
@@ -1942,15 +1859,14 @@ __name(resolveEndpointType, "resolveEndpointType");
1942
1859
 
1943
1860
  // src/lib/telemetry-client.ts
1944
1861
  var packageJson = require_package();
1945
- var telemetryClient = new import_shared4.TelemetryClient({
1862
+ var telemetryClient = new import_shared2.TelemetryClient({
1946
1863
  packageName: packageJson.name,
1947
1864
  packageVersion: packageJson.version
1948
1865
  });
1949
1866
  function getRuntimeInstanceTelemetryInfo(options) {
1950
- var _a, _b, _c, _d, _e;
1867
+ var _a, _b;
1951
1868
  const runtime = options.runtime;
1952
- const remoteEndpoints = ((_a = runtime.params) == null ? void 0 : _a.remoteEndpoints) ?? [];
1953
- const endpointsInfo = remoteEndpoints.reduce((acc, endpoint) => {
1869
+ const endpointsInfo = runtime.remoteEndpointDefinitions.reduce((acc, endpoint) => {
1954
1870
  let info = {
1955
1871
  ...acc
1956
1872
  };
@@ -1978,19 +1894,19 @@ function getRuntimeInstanceTelemetryInfo(options) {
1978
1894
  agentsAmount: null,
1979
1895
  hashedKey: null
1980
1896
  });
1981
- const publicApiKey = (_b = options.cloud) == null ? void 0 : _b.publicApiKey;
1897
+ const publicApiKey = (_a = options.cloud) == null ? void 0 : _a.publicApiKey;
1982
1898
  const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
1983
1899
  return {
1984
- actionsAmount: ((_d = (_c = runtime.params) == null ? void 0 : _c.actions) == null ? void 0 : _d.length) ?? 0,
1985
- endpointsAmount: remoteEndpoints.length,
1900
+ actionsAmount: runtime.actions.length,
1901
+ endpointsAmount: runtime.remoteEndpointDefinitions.length,
1986
1902
  endpointTypes: endpointsInfo.endpointTypes,
1987
- agentsAmount: Object.keys(runtime.instance.agents).length,
1903
+ agentsAmount: endpointsInfo.agentsAmount,
1988
1904
  hashedLgcKey: endpointsInfo.hashedKey,
1989
1905
  "cloud.api_key_provided": apiKeyProvided,
1990
1906
  ...apiKeyProvided ? {
1991
1907
  "cloud.public_api_key": publicApiKey
1992
1908
  } : {},
1993
- ...((_e = options.cloud) == null ? void 0 : _e.baseUrl) ? {
1909
+ ...((_b = options.cloud) == null ? void 0 : _b.baseUrl) ? {
1994
1910
  "cloud.base_url": options.cloud.baseUrl
1995
1911
  } : {}
1996
1912
  };
@@ -1998,8 +1914,76 @@ function getRuntimeInstanceTelemetryInfo(options) {
1998
1914
  __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
1999
1915
  var telemetry_client_default = telemetryClient;
2000
1916
 
1917
+ // src/lib/runtime/remote-actions.ts
1918
+ var import_shared4 = require("@copilotkit/shared");
1919
+ var EndpointType;
1920
+ (function(EndpointType2) {
1921
+ EndpointType2["CopilotKit"] = "copilotKit";
1922
+ EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1923
+ })(EndpointType || (EndpointType = {}));
1924
+
1925
+ // src/service-adapters/events.ts
1926
+ var RuntimeEventTypes;
1927
+ (function(RuntimeEventTypes2) {
1928
+ RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
1929
+ RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
1930
+ RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
1931
+ RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
1932
+ RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1933
+ RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1934
+ RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1935
+ RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1936
+ RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
1937
+ RuntimeEventTypes2["RunError"] = "RunError";
1938
+ })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1939
+ var RuntimeMetaEventName;
1940
+ (function(RuntimeMetaEventName2) {
1941
+ RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1942
+ RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
1943
+ RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1944
+ })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
1945
+
2001
1946
  // src/graphql/resolvers/copilot.resolver.ts
2002
- var import_shared5 = require("@copilotkit/shared");
1947
+ var import_graphql_scalars2 = require("graphql-scalars");
1948
+ var import_class_transformer2 = require("class-transformer");
1949
+ var import_graphql = require("graphql");
1950
+
1951
+ // src/utils/failed-response-status-reasons.ts
1952
+ var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
1953
+ reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
1954
+ constructor({ guardrailsReason }) {
1955
+ super();
1956
+ this.details = {
1957
+ guardrailsReason
1958
+ };
1959
+ }
1960
+ };
1961
+ __name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
1962
+ var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
1963
+ reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
1964
+ constructor({ messageId }) {
1965
+ super();
1966
+ this.details = {
1967
+ messageId,
1968
+ description: "Check the message for mode details"
1969
+ };
1970
+ }
1971
+ };
1972
+ __name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
1973
+ var UnknownErrorResponse = class extends FailedResponseStatus {
1974
+ reason = FailedResponseStatusReason.UNKNOWN_ERROR;
1975
+ constructor({ description, originalError }) {
1976
+ super();
1977
+ this.details = {
1978
+ description,
1979
+ originalError
1980
+ };
1981
+ }
1982
+ };
1983
+ __name(UnknownErrorResponse, "UnknownErrorResponse");
1984
+
1985
+ // src/graphql/resolvers/copilot.resolver.ts
1986
+ var import_shared6 = require("@copilotkit/shared");
2003
1987
 
2004
1988
  // src/graphql/types/agents-response.type.ts
2005
1989
  var import_type_graphql20 = require("type-graphql");
@@ -2055,7 +2039,7 @@ AgentsResponse = _ts_decorate19([
2055
2039
  ], AgentsResponse);
2056
2040
 
2057
2041
  // src/graphql/resolvers/copilot.resolver.ts
2058
- var import_shared6 = require("@copilotkit/shared");
2042
+ var import_shared7 = require("@copilotkit/shared");
2059
2043
  function _ts_decorate20(decorators, target, key, desc) {
2060
2044
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2061
2045
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2118,14 +2102,14 @@ var CopilotResolver = class {
2118
2102
  component: "CopilotResolver.availableAgents"
2119
2103
  });
2120
2104
  logger2.debug("Processing");
2121
- const agentsWithEndpoints = [];
2105
+ const agentsWithEndpoints = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
2122
2106
  logger2.debug("Event source created, creating response");
2123
2107
  return {
2124
2108
  agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
2125
2109
  };
2126
2110
  }
2127
2111
  async generateCopilotResponse(ctx, data, properties) {
2128
- var _a, _b, _c, _d;
2112
+ var _a, _b, _c, _d, _e, _f, _g;
2129
2113
  telemetry_client_default.capture("oss.runtime.copilot_request_created", {
2130
2114
  "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
2131
2115
  requestType: data.metadata.requestType,
@@ -2167,12 +2151,21 @@ var CopilotResolver = class {
2167
2151
  logger2.debug("Cloud configuration provided, checking for public API key in headers");
2168
2152
  if (!copilotCloudPublicApiKey) {
2169
2153
  logger2.error("Public API key not found in headers");
2154
+ await copilotRuntime.errorGraphQLError({
2155
+ message: "X-CopilotCloud-Public-API-Key header is required",
2156
+ code: "MISSING_PUBLIC_API_KEY",
2157
+ type: "GraphQLError"
2158
+ }, {
2159
+ operation: "generateCopilotResponse",
2160
+ cloudConfigPresent: Boolean(data.cloud),
2161
+ guardrailsEnabled: Boolean((_b = data.cloud) == null ? void 0 : _b.guardrails)
2162
+ });
2170
2163
  throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
2171
2164
  }
2172
2165
  if (process.env.COPILOT_CLOUD_BASE_URL) {
2173
2166
  copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
2174
- } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
2175
- copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
2167
+ } else if ((_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl) {
2168
+ copilotCloudBaseUrl = (_d = ctx._copilotkit.cloud) == null ? void 0 : _d.baseUrl;
2176
2169
  } else {
2177
2170
  copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
2178
2171
  }
@@ -2181,9 +2174,9 @@ var CopilotResolver = class {
2181
2174
  });
2182
2175
  }
2183
2176
  logger2.debug("Setting up subjects");
2184
- const responseStatus$ = new import_rxjs2.ReplaySubject();
2185
- const interruptStreaming$ = new import_rxjs2.ReplaySubject();
2186
- const guardrailsResult$ = new import_rxjs2.ReplaySubject();
2177
+ const responseStatus$ = new import_rxjs3.ReplaySubject();
2178
+ const interruptStreaming$ = new import_rxjs3.ReplaySubject();
2179
+ const guardrailsResult$ = new import_rxjs3.ReplaySubject();
2187
2180
  let outputMessages = [];
2188
2181
  let resolveOutputMessagesPromise;
2189
2182
  let rejectOutputMessagesPromise;
@@ -2196,11 +2189,41 @@ var CopilotResolver = class {
2196
2189
  }
2197
2190
  logger2.debug("Processing");
2198
2191
  let runtimeResponse;
2199
- const { eventSource, threadId = (0, import_shared5.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
2192
+ try {
2193
+ runtimeResponse = await copilotRuntime.processRuntimeRequest({
2194
+ serviceAdapter,
2195
+ messages: data.messages,
2196
+ actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
2197
+ threadId: data.threadId,
2198
+ runId: data.runId,
2199
+ publicApiKey: copilotCloudPublicApiKey,
2200
+ outputMessagesPromise,
2201
+ graphqlContext: ctx,
2202
+ forwardedParameters: data.forwardedParameters,
2203
+ agentSession: data.agentSession,
2204
+ agentStates: data.agentStates,
2205
+ url: data.frontend.url,
2206
+ extensions: data.extensions,
2207
+ metaEvents: data.metaEvents,
2208
+ context: data.context
2209
+ });
2210
+ } catch (error) {
2211
+ if ((0, import_shared7.isStructuredCopilotKitError)(error) || ((_e = error == null ? void 0 : error.extensions) == null ? void 0 : _e.visibility)) {
2212
+ throw new import_graphql.GraphQLError(error.message || "Agent error occurred", {
2213
+ extensions: {
2214
+ ...error.extensions,
2215
+ code: error.code || ((_f = error.extensions) == null ? void 0 : _f.code) || "AGENT_ERROR",
2216
+ originalError: error
2217
+ }
2218
+ });
2219
+ }
2220
+ throw error;
2221
+ }
2222
+ const { eventSource, threadId = (0, import_shared6.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
2200
2223
  logger2.debug("Event source created, creating response");
2201
2224
  const eventStream = eventSource.processRuntimeEvents({
2202
2225
  serverSideActions,
2203
- guardrailsResult$: ((_d = data.cloud) == null ? void 0 : _d.guardrails) ? guardrailsResult$ : null,
2226
+ guardrailsResult$: ((_g = data.cloud) == null ? void 0 : _g.guardrails) ? guardrailsResult$ : null,
2204
2227
  actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
2205
2228
  // TODO-AGENTS: do not exclude ALL server side actions
2206
2229
  (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
@@ -2209,15 +2232,15 @@ var CopilotResolver = class {
2209
2232
  }).pipe(
2210
2233
  // shareReplay() ensures that later subscribers will see the whole stream instead of
2211
2234
  // just the events that were emitted after the subscriber was added.
2212
- (0, import_rxjs2.shareReplay)(),
2213
- (0, import_rxjs2.finalize)(() => {
2235
+ (0, import_rxjs3.shareReplay)(),
2236
+ (0, import_rxjs3.finalize)(() => {
2214
2237
  logger2.debug("Event stream finalized");
2215
2238
  })
2216
2239
  );
2217
2240
  const response = {
2218
2241
  threadId,
2219
2242
  runId,
2220
- status: (0, import_rxjs2.firstValueFrom)(responseStatus$),
2243
+ status: (0, import_rxjs3.firstValueFrom)(responseStatus$),
2221
2244
  extensions,
2222
2245
  metaEvents: new import_graphql_yoga.Repeater(async (push, stop) => {
2223
2246
  let eventStreamSubscription;
@@ -2228,7 +2251,7 @@ var CopilotResolver = class {
2228
2251
  }
2229
2252
  switch (event.name) {
2230
2253
  case LangGraphEventTypes.OnInterrupt:
2231
- push((0, import_class_transformer.plainToInstance)(LangGraphInterruptEvent, {
2254
+ push((0, import_class_transformer2.plainToInstance)(LangGraphInterruptEvent, {
2232
2255
  // @ts-ignore
2233
2256
  type: event.type,
2234
2257
  // @ts-ignore
@@ -2238,21 +2261,21 @@ var CopilotResolver = class {
2238
2261
  }));
2239
2262
  break;
2240
2263
  case RuntimeMetaEventName.LangGraphInterruptEvent:
2241
- push((0, import_class_transformer.plainToInstance)(LangGraphInterruptEvent, {
2264
+ push((0, import_class_transformer2.plainToInstance)(LangGraphInterruptEvent, {
2242
2265
  type: event.type,
2243
2266
  name: event.name,
2244
2267
  value: event.value
2245
2268
  }));
2246
2269
  break;
2247
2270
  case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
2248
- push((0, import_class_transformer.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
2271
+ push((0, import_class_transformer2.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
2249
2272
  type: event.type,
2250
2273
  name: event.name,
2251
2274
  data: {
2252
2275
  value: event.data.value,
2253
2276
  messages: event.data.messages.map((message) => {
2254
2277
  if (message.type === "TextMessage" || "content" in message && "role" in message) {
2255
- return (0, import_class_transformer.plainToInstance)(TextMessage, {
2278
+ return (0, import_class_transformer2.plainToInstance)(TextMessage, {
2256
2279
  id: message.id,
2257
2280
  createdAt: /* @__PURE__ */ new Date(),
2258
2281
  content: [
@@ -2263,7 +2286,7 @@ var CopilotResolver = class {
2263
2286
  });
2264
2287
  }
2265
2288
  if ("arguments" in message) {
2266
- return (0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
2289
+ return (0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
2267
2290
  name: message.name,
2268
2291
  id: message.id,
2269
2292
  arguments: [
@@ -2327,8 +2350,8 @@ var CopilotResolver = class {
2327
2350
  reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
2328
2351
  });
2329
2352
  outputMessages = [
2330
- (0, import_class_transformer.plainToInstance)(TextMessage, {
2331
- id: (0, import_shared5.randomId)(),
2353
+ (0, import_class_transformer2.plainToInstance)(TextMessage, {
2354
+ id: (0, import_shared6.randomId)(),
2332
2355
  createdAt: /* @__PURE__ */ new Date(),
2333
2356
  content: result.reason,
2334
2357
  role: MessageRole.assistant
@@ -2361,30 +2384,30 @@ var CopilotResolver = class {
2361
2384
  case RuntimeEventTypes.TextMessageStart:
2362
2385
  const textMessageContentStream = eventStream.pipe(
2363
2386
  // skip until this message start event
2364
- (0, import_rxjs2.skipWhile)((e) => e !== event),
2387
+ (0, import_rxjs3.skipWhile)((e) => e !== event),
2365
2388
  // take until the message end event
2366
- (0, import_rxjs2.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
2389
+ (0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
2367
2390
  // filter out any other message events or message ids
2368
- (0, import_rxjs2.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
2391
+ (0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
2369
2392
  );
2370
- const streamingTextStatus = new import_rxjs2.Subject();
2393
+ const streamingTextStatus = new import_rxjs3.Subject();
2371
2394
  const messageId = event.messageId;
2372
2395
  pushMessage({
2373
2396
  id: messageId,
2374
2397
  parentMessageId: event.parentMessageId,
2375
- status: (0, import_rxjs2.firstValueFrom)(streamingTextStatus),
2398
+ status: (0, import_rxjs3.firstValueFrom)(streamingTextStatus),
2376
2399
  createdAt: /* @__PURE__ */ new Date(),
2377
2400
  role: MessageRole.assistant,
2378
2401
  content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
2379
2402
  logger2.debug("Text message content repeater created");
2380
2403
  const textChunks = [];
2381
2404
  let textSubscription;
2382
- interruptStreaming$.pipe((0, import_rxjs2.shareReplay)(), (0, import_rxjs2.take)(1), (0, import_rxjs2.tap)(({ reason, messageId: messageId2 }) => {
2405
+ interruptStreaming$.pipe((0, import_rxjs3.shareReplay)(), (0, import_rxjs3.take)(1), (0, import_rxjs3.tap)(({ reason, messageId: messageId2 }) => {
2383
2406
  logger2.debug({
2384
2407
  reason,
2385
2408
  messageId: messageId2
2386
2409
  }, "Text streaming interrupted");
2387
- streamingTextStatus.next((0, import_class_transformer.plainToInstance)(FailedMessageStatus, {
2410
+ streamingTextStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
2388
2411
  reason
2389
2412
  }));
2390
2413
  responseStatus$.next(new MessageStreamInterruptedResponse({
@@ -2417,7 +2440,7 @@ var CopilotResolver = class {
2417
2440
  streamingTextStatus.next(new SuccessMessageStatus());
2418
2441
  stopStreamingText();
2419
2442
  textSubscription == null ? void 0 : textSubscription.unsubscribe();
2420
- outputMessages.push((0, import_class_transformer.plainToInstance)(TextMessage, {
2443
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(TextMessage, {
2421
2444
  id: messageId,
2422
2445
  createdAt: /* @__PURE__ */ new Date(),
2423
2446
  content: textChunks.join(""),
@@ -2431,17 +2454,17 @@ var CopilotResolver = class {
2431
2454
  case RuntimeEventTypes.ActionExecutionStart:
2432
2455
  logger2.debug("Action execution start event received");
2433
2456
  const actionExecutionArgumentStream = eventStream.pipe(
2434
- (0, import_rxjs2.skipWhile)((e) => e !== event),
2457
+ (0, import_rxjs3.skipWhile)((e) => e !== event),
2435
2458
  // take until the action execution end event
2436
- (0, import_rxjs2.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
2459
+ (0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
2437
2460
  // filter out any other action execution events or action execution ids
2438
- (0, import_rxjs2.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
2461
+ (0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
2439
2462
  );
2440
- const streamingArgumentsStatus = new import_rxjs2.Subject();
2463
+ const streamingArgumentsStatus = new import_rxjs3.Subject();
2441
2464
  pushMessage({
2442
2465
  id: event.actionExecutionId,
2443
2466
  parentMessageId: event.parentMessageId,
2444
- status: (0, import_rxjs2.firstValueFrom)(streamingArgumentsStatus),
2467
+ status: (0, import_rxjs3.firstValueFrom)(streamingArgumentsStatus),
2445
2468
  createdAt: /* @__PURE__ */ new Date(),
2446
2469
  name: event.actionName,
2447
2470
  arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
@@ -2459,7 +2482,7 @@ var CopilotResolver = class {
2459
2482
  logger2.error({
2460
2483
  err
2461
2484
  }, "Error in action execution argument stream");
2462
- streamingArgumentsStatus.next((0, import_class_transformer.plainToInstance)(FailedMessageStatus, {
2485
+ streamingArgumentsStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
2463
2486
  reason: "An unknown error has occurred in the action execution argument stream"
2464
2487
  }));
2465
2488
  stopStreamingArguments();
@@ -2470,7 +2493,7 @@ var CopilotResolver = class {
2470
2493
  streamingArgumentsStatus.next(new SuccessMessageStatus());
2471
2494
  stopStreamingArguments();
2472
2495
  actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
2473
- outputMessages.push((0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
2496
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
2474
2497
  id: event.actionExecutionId,
2475
2498
  createdAt: /* @__PURE__ */ new Date(),
2476
2499
  name: event.actionName,
@@ -2493,7 +2516,7 @@ var CopilotResolver = class {
2493
2516
  actionName: event.actionName,
2494
2517
  result: event.result
2495
2518
  });
2496
- outputMessages.push((0, import_class_transformer.plainToInstance)(ResultMessage, {
2519
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
2497
2520
  id: "result-" + event.actionExecutionId,
2498
2521
  createdAt: /* @__PURE__ */ new Date(),
2499
2522
  actionExecutionId: event.actionExecutionId,
@@ -2506,7 +2529,7 @@ var CopilotResolver = class {
2506
2529
  event
2507
2530
  }, "Agent message event received");
2508
2531
  pushMessage({
2509
- id: (0, import_shared5.randomId)(),
2532
+ id: (0, import_shared6.randomId)(),
2510
2533
  status: new SuccessMessageStatus(),
2511
2534
  threadId: event.threadId,
2512
2535
  agentName: event.agentName,
@@ -2518,8 +2541,8 @@ var CopilotResolver = class {
2518
2541
  role: MessageRole.assistant,
2519
2542
  createdAt: /* @__PURE__ */ new Date()
2520
2543
  });
2521
- outputMessages.push((0, import_class_transformer.plainToInstance)(AgentStateMessage, {
2522
- id: (0, import_shared5.randomId)(),
2544
+ outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
2545
+ id: (0, import_shared6.randomId)(),
2523
2546
  threadId: event.threadId,
2524
2547
  agentName: event.agentName,
2525
2548
  nodeName: event.nodeName,
@@ -2534,8 +2557,8 @@ var CopilotResolver = class {
2534
2557
  }
2535
2558
  },
2536
2559
  error: (err) => {
2537
- var _a3, _b2, _c2, _d2, _e, _f;
2538
- if (err instanceof import_shared6.CopilotKitError || err instanceof import_shared6.CopilotKitLowLevelError || err instanceof Error && err.name && err.name.includes("CopilotKit") || ((_a3 = err == null ? void 0 : err.extensions) == null ? void 0 : _a3.visibility)) {
2560
+ var _a3, _b2, _c2, _d2, _e2, _f2;
2561
+ if (err instanceof import_shared7.CopilotKitError || err instanceof import_shared7.CopilotKitLowLevelError || err instanceof Error && err.name && err.name.includes("CopilotKit") || ((_a3 = err == null ? void 0 : err.extensions) == null ? void 0 : _a3.visibility)) {
2539
2562
  responseStatus$.next(new UnknownErrorResponse({
2540
2563
  description: err.message || "Agent error occurred",
2541
2564
  // Include original error information for frontend to extract
@@ -2543,8 +2566,8 @@ var CopilotResolver = class {
2543
2566
  code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
2544
2567
  statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
2545
2568
  severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
2546
- visibility: err.visibility || ((_e = err.extensions) == null ? void 0 : _e.visibility),
2547
- originalErrorType: err.originalErrorType || ((_f = err.extensions) == null ? void 0 : _f.originalErrorType),
2569
+ visibility: err.visibility || ((_e2 = err.extensions) == null ? void 0 : _e2.visibility),
2570
+ originalErrorType: err.originalErrorType || ((_f2 = err.extensions) == null ? void 0 : _f2.originalErrorType),
2548
2571
  extensions: err.extensions
2549
2572
  }
2550
2573
  }));
@@ -2565,7 +2588,7 @@ var CopilotResolver = class {
2565
2588
  logger2.debug("Event stream completed");
2566
2589
  if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
2567
2590
  logger2.debug("Guardrails is enabled, waiting for guardrails result");
2568
- await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
2591
+ await (0, import_rxjs3.firstValueFrom)(guardrailsResult$);
2569
2592
  }
2570
2593
  responseStatus$.next(new SuccessResponseStatus());
2571
2594
  eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
@@ -2730,7 +2753,7 @@ LoadAgentStateInput = _ts_decorate22([
2730
2753
  ], LoadAgentStateInput);
2731
2754
 
2732
2755
  // src/graphql/resolvers/state.resolver.ts
2733
- var import_shared7 = require("@copilotkit/shared");
2756
+ var import_shared8 = require("@copilotkit/shared");
2734
2757
  function _ts_decorate23(decorators, target, key, desc) {
2735
2758
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2736
2759
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2755,10 +2778,10 @@ function _ts_param2(paramIndex, decorator) {
2755
2778
  __name(_ts_param2, "_ts_param");
2756
2779
  var StateResolver = class {
2757
2780
  async loadAgentState(ctx, data) {
2758
- const agents = [];
2781
+ const agents = await ctx._copilotkit.runtime.getAllAgents(ctx);
2759
2782
  const hasAgent = agents.some((agent) => agent.name === data.agentName);
2760
2783
  if (!hasAgent) {
2761
- throw new import_shared7.CopilotKitAgentDiscoveryError({
2784
+ throw new import_shared8.CopilotKitAgentDiscoveryError({
2762
2785
  agentName: data.agentName,
2763
2786
  availableAgents: agents.map((a) => ({
2764
2787
  name: a.name,
@@ -2766,7 +2789,7 @@ var StateResolver = class {
2766
2789
  }))
2767
2790
  });
2768
2791
  }
2769
- const state = {};
2792
+ const state = await ctx._copilotkit.runtime.loadAgentState(ctx, data.threadId, data.agentName);
2770
2793
  return state;
2771
2794
  }
2772
2795
  };
@@ -2788,7 +2811,7 @@ StateResolver = _ts_decorate23([
2788
2811
 
2789
2812
  // src/lib/integrations/shared.ts
2790
2813
  var packageJson2 = __toESM(require_package());
2791
- var import_shared8 = require("@copilotkit/shared");
2814
+ var import_shared9 = require("@copilotkit/shared");
2792
2815
  var logger = createLogger();
2793
2816
  var addCustomHeaderPlugin = {
2794
2817
  onResponse({ response }) {
@@ -2854,11 +2877,11 @@ function getCommonConfig(options) {
2854
2877
  }
2855
2878
  });
2856
2879
  const userErrorCodes = [
2857
- import_shared8.CopilotKitErrorCode.AGENT_NOT_FOUND,
2858
- import_shared8.CopilotKitErrorCode.API_NOT_FOUND,
2859
- import_shared8.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,
2860
- import_shared8.CopilotKitErrorCode.CONFIGURATION_ERROR,
2861
- import_shared8.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR
2880
+ import_shared9.CopilotKitErrorCode.AGENT_NOT_FOUND,
2881
+ import_shared9.CopilotKitErrorCode.API_NOT_FOUND,
2882
+ import_shared9.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,
2883
+ import_shared9.CopilotKitErrorCode.CONFIGURATION_ERROR,
2884
+ import_shared9.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR
2862
2885
  ];
2863
2886
  return {
2864
2887
  logging: createLogger({
@@ -2881,7 +2904,7 @@ function getCommonConfig(options) {
2881
2904
  console.debug("User configuration error:", error.message);
2882
2905
  return error;
2883
2906
  }
2884
- if (originalError instanceof import_shared8.CopilotKitError && userErrorCodes.includes(originalError.code)) {
2907
+ if (originalError instanceof import_shared9.CopilotKitError && userErrorCodes.includes(originalError.code)) {
2885
2908
  console.debug("User configuration error:", error.message);
2886
2909
  return error;
2887
2910
  }
@@ -2910,12 +2933,11 @@ function copilotRuntimeNodeHttpEndpoint(options) {
2910
2933
  telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
2911
2934
  const logger2 = commonConfig.logging;
2912
2935
  logger2.debug("Creating Node HTTP endpoint");
2913
- const serviceAdapter = options.serviceAdapter;
2914
- options.runtime.handleServiceAdapter(serviceAdapter);
2915
- return (0, import_runtime32.createCopilotEndpoint)({
2916
- runtime: options.runtime.instance,
2917
- basePath: options.baseUrl
2936
+ const yoga = (0, import_graphql_yoga2.createYoga)({
2937
+ ...commonConfig,
2938
+ graphqlEndpoint: options.endpoint
2918
2939
  });
2940
+ return yoga;
2919
2941
  }
2920
2942
  __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
2921
2943