@copilotkit/runtime 1.50.0-beta.13 → 1.50.0-beta.15

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 (180) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/{chunk-45RCC3ZS.mjs → chunk-BJEYMRDD.mjs} +2 -2
  3. package/dist/{chunk-OFSV5GET.mjs → chunk-DZV4ZIAR.mjs} +6 -17
  4. package/dist/chunk-DZV4ZIAR.mjs.map +1 -0
  5. package/dist/{chunk-AQG2SVCA.mjs → chunk-FMU55SEU.mjs} +2 -2
  6. package/dist/{chunk-DCEEHMLJ.mjs → chunk-SBCOROE4.mjs} +1 -16
  7. package/dist/chunk-SBCOROE4.mjs.map +1 -0
  8. package/dist/{chunk-ERUOA47O.mjs → chunk-TTUAEJLD.mjs} +2 -11
  9. package/dist/chunk-TTUAEJLD.mjs.map +1 -0
  10. package/dist/{chunk-4KES76K3.mjs → chunk-Z752VE75.mjs} +2 -2
  11. package/dist/graphql/types/converted/index.d.ts +1 -1
  12. package/dist/graphql/types/converted/index.js +110 -16
  13. package/dist/graphql/types/converted/index.js.map +1 -1
  14. package/dist/graphql/types/converted/index.mjs +3 -2
  15. package/dist/{groq-adapter-a6f5e9d2.d.ts → groq-adapter-50bc6e4a.d.ts} +1 -6
  16. package/dist/index.js +5 -3
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +5 -3
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/{langserve-9fc76ce5.d.ts → langserve-74a52292.d.ts} +0 -1
  21. package/dist/lib/index.d.ts +59 -5
  22. package/dist/lib/index.js +779 -3678
  23. package/dist/lib/index.js.map +1 -1
  24. package/dist/lib/index.mjs +18 -20
  25. package/dist/lib/integrations/index.d.ts +9 -15
  26. package/dist/lib/integrations/index.js +187 -215
  27. package/dist/lib/integrations/index.js.map +1 -1
  28. package/dist/lib/integrations/index.mjs +7 -8
  29. package/dist/lib/integrations/nest/index.d.ts +6 -5
  30. package/dist/lib/integrations/nest/index.js +175 -197
  31. package/dist/lib/integrations/nest/index.js.map +1 -1
  32. package/dist/lib/integrations/nest/index.mjs +5 -6
  33. package/dist/lib/integrations/node-express/index.d.ts +6 -5
  34. package/dist/lib/integrations/node-express/index.js +175 -197
  35. package/dist/lib/integrations/node-express/index.js.map +1 -1
  36. package/dist/lib/integrations/node-express/index.mjs +5 -6
  37. package/dist/lib/integrations/node-http/index.d.ts +6 -5
  38. package/dist/lib/integrations/node-http/index.js +175 -197
  39. package/dist/lib/integrations/node-http/index.js.map +1 -1
  40. package/dist/lib/integrations/node-http/index.mjs +4 -5
  41. package/dist/service-adapters/index.d.ts +11 -7
  42. package/dist/service-adapters/index.js +21 -8
  43. package/dist/service-adapters/index.js.map +1 -1
  44. package/dist/service-adapters/index.mjs +4 -2
  45. package/dist/{shared-35c6eb04.d.ts → shared-f6d43ef8.d.ts} +1 -3
  46. package/package.json +2 -2
  47. package/src/lib/runtime/copilot-runtime.ts +4 -4
  48. package/src/lib/runtime/telemetry-agent-runner.ts +10 -5
  49. package/dist/chunk-27JKTS6P.mjs +0 -1704
  50. package/dist/chunk-27JKTS6P.mjs.map +0 -1
  51. package/dist/chunk-2GPTVDTO.mjs +0 -25
  52. package/dist/chunk-3AJVKDZX.mjs +0 -3097
  53. package/dist/chunk-3AJVKDZX.mjs.map +0 -1
  54. package/dist/chunk-4EHJ4XFJ.mjs +0 -25
  55. package/dist/chunk-4EHJ4XFJ.mjs.map +0 -1
  56. package/dist/chunk-4IANB4TC.mjs +0 -25
  57. package/dist/chunk-4IANB4TC.mjs.map +0 -1
  58. package/dist/chunk-4OGE3SLW.mjs +0 -3100
  59. package/dist/chunk-4OGE3SLW.mjs.map +0 -1
  60. package/dist/chunk-54YJBMCP.mjs +0 -3097
  61. package/dist/chunk-54YJBMCP.mjs.map +0 -1
  62. package/dist/chunk-6ER4SZYH.mjs +0 -74
  63. package/dist/chunk-6ER4SZYH.mjs.map +0 -1
  64. package/dist/chunk-6TNSLHVR.mjs +0 -74
  65. package/dist/chunk-6TNSLHVR.mjs.map +0 -1
  66. package/dist/chunk-7V4BK7TZ.mjs +0 -25
  67. package/dist/chunk-7V4BK7TZ.mjs.map +0 -1
  68. package/dist/chunk-7YZIEXD2.mjs +0 -74
  69. package/dist/chunk-7YZIEXD2.mjs.map +0 -1
  70. package/dist/chunk-A4XHOAFU.mjs +0 -25
  71. package/dist/chunk-A4XHOAFU.mjs.map +0 -1
  72. package/dist/chunk-A555KEAD.mjs +0 -6020
  73. package/dist/chunk-A555KEAD.mjs.map +0 -1
  74. package/dist/chunk-AF73TFTX.mjs +0 -74
  75. package/dist/chunk-AF73TFTX.mjs.map +0 -1
  76. package/dist/chunk-AQG2SVCA.mjs.map +0 -1
  77. package/dist/chunk-BJZHMXND.mjs +0 -74
  78. package/dist/chunk-BJZHMXND.mjs.map +0 -1
  79. package/dist/chunk-CB2OJXF6.mjs +0 -25
  80. package/dist/chunk-CB2OJXF6.mjs.map +0 -1
  81. package/dist/chunk-CEOMFPJU.mjs +0 -6020
  82. package/dist/chunk-CEOMFPJU.mjs.map +0 -1
  83. package/dist/chunk-CZVLR7CC.mjs +0 -175
  84. package/dist/chunk-CZVLR7CC.mjs.map +0 -1
  85. package/dist/chunk-DCEEHMLJ.mjs.map +0 -1
  86. package/dist/chunk-DE3CLKUG.mjs +0 -25
  87. package/dist/chunk-DE3CLKUG.mjs.map +0 -1
  88. package/dist/chunk-DTPRUTNV.mjs +0 -25
  89. package/dist/chunk-DTPRUTNV.mjs.map +0 -1
  90. package/dist/chunk-ERUOA47O.mjs.map +0 -1
  91. package/dist/chunk-ESSRC64W.mjs +0 -74
  92. package/dist/chunk-ESSRC64W.mjs.map +0 -1
  93. package/dist/chunk-GRAN6K6N.mjs +0 -25
  94. package/dist/chunk-GRAN6K6N.mjs.map +0 -1
  95. package/dist/chunk-I27F2UPA.mjs +0 -175
  96. package/dist/chunk-I27F2UPA.mjs.map +0 -1
  97. package/dist/chunk-IAZKTOQW.mjs +0 -25
  98. package/dist/chunk-IAZKTOQW.mjs.map +0 -1
  99. package/dist/chunk-J6XZ5MFB.mjs +0 -25
  100. package/dist/chunk-J6XZ5MFB.mjs.map +0 -1
  101. package/dist/chunk-JJ32MA4C.mjs +0 -73
  102. package/dist/chunk-JJ32MA4C.mjs.map +0 -1
  103. package/dist/chunk-JJY4ZTHQ.mjs +0 -25
  104. package/dist/chunk-JJY4ZTHQ.mjs.map +0 -1
  105. package/dist/chunk-KEYLBFU2.mjs +0 -3117
  106. package/dist/chunk-KEYLBFU2.mjs.map +0 -1
  107. package/dist/chunk-KQ53L4WZ.mjs +0 -3094
  108. package/dist/chunk-KQ53L4WZ.mjs.map +0 -1
  109. package/dist/chunk-KTELVQ67.mjs +0 -3098
  110. package/dist/chunk-KTELVQ67.mjs.map +0 -1
  111. package/dist/chunk-LPEPX6NH.mjs +0 -25
  112. package/dist/chunk-LPEPX6NH.mjs.map +0 -1
  113. package/dist/chunk-MDXE55DK.mjs +0 -3117
  114. package/dist/chunk-MDXE55DK.mjs.map +0 -1
  115. package/dist/chunk-MMFUVOXH.mjs +0 -73
  116. package/dist/chunk-MMFUVOXH.mjs.map +0 -1
  117. package/dist/chunk-N3Y4U66N.mjs +0 -253
  118. package/dist/chunk-N3Y4U66N.mjs.map +0 -1
  119. package/dist/chunk-O7UYB4MH.mjs +0 -25
  120. package/dist/chunk-O7UYB4MH.mjs.map +0 -1
  121. package/dist/chunk-OFNVQHNM.mjs +0 -3089
  122. package/dist/chunk-OFNVQHNM.mjs.map +0 -1
  123. package/dist/chunk-OFSV5GET.mjs.map +0 -1
  124. package/dist/chunk-OMRST67R.mjs +0 -25
  125. package/dist/chunk-OMRST67R.mjs.map +0 -1
  126. package/dist/chunk-PRZHE74A.mjs +0 -25
  127. package/dist/chunk-PRZHE74A.mjs.map +0 -1
  128. package/dist/chunk-PTYRVXXP.mjs +0 -80
  129. package/dist/chunk-PTYRVXXP.mjs.map +0 -1
  130. package/dist/chunk-R22B5CCO.mjs +0 -25
  131. package/dist/chunk-R22B5CCO.mjs.map +0 -1
  132. package/dist/chunk-SHBDMA63.mjs +0 -141
  133. package/dist/chunk-SHBDMA63.mjs.map +0 -1
  134. package/dist/chunk-SPVXBPRA.mjs +0 -74
  135. package/dist/chunk-SPVXBPRA.mjs.map +0 -1
  136. package/dist/chunk-T72G46ME.mjs +0 -25
  137. package/dist/chunk-T72G46ME.mjs.map +0 -1
  138. package/dist/chunk-TGELROPU.mjs +0 -25
  139. package/dist/chunk-TGELROPU.mjs.map +0 -1
  140. package/dist/chunk-UNX4IAAD.mjs +0 -25
  141. package/dist/chunk-UNX4IAAD.mjs.map +0 -1
  142. package/dist/chunk-V4DHVC7M.mjs +0 -3085
  143. package/dist/chunk-V4DHVC7M.mjs.map +0 -1
  144. package/dist/chunk-VVRFOB66.mjs +0 -25
  145. package/dist/chunk-VVRFOB66.mjs.map +0 -1
  146. package/dist/chunk-W6NVBYM6.mjs +0 -80
  147. package/dist/chunk-W6NVBYM6.mjs.map +0 -1
  148. package/dist/chunk-W7MBACGC.mjs +0 -74
  149. package/dist/chunk-W7MBACGC.mjs.map +0 -1
  150. package/dist/chunk-WMD4XZZS.mjs +0 -25
  151. package/dist/chunk-WMD4XZZS.mjs.map +0 -1
  152. package/dist/chunk-WX2ZNCRT.mjs +0 -74
  153. package/dist/chunk-WX2ZNCRT.mjs.map +0 -1
  154. package/dist/chunk-Y2Z62E2T.mjs +0 -74
  155. package/dist/chunk-Y2Z62E2T.mjs.map +0 -1
  156. package/dist/chunk-YO4I6RVI.mjs +0 -25
  157. package/dist/chunk-YO4I6RVI.mjs.map +0 -1
  158. package/dist/chunk-Z6Q5IW6I.mjs +0 -3098
  159. package/dist/chunk-Z6Q5IW6I.mjs.map +0 -1
  160. package/dist/chunk-Z726O3G2.mjs +0 -25
  161. package/dist/chunk-Z726O3G2.mjs.map +0 -1
  162. package/dist/chunk-ZE4SMZZR.mjs +0 -3097
  163. package/dist/chunk-ZE4SMZZR.mjs.map +0 -1
  164. package/dist/chunk-ZULZB33C.mjs +0 -73
  165. package/dist/chunk-ZULZB33C.mjs.map +0 -1
  166. package/dist/chunk-ZVRGXMY7.mjs +0 -25
  167. package/dist/chunk-ZVRGXMY7.mjs.map +0 -1
  168. package/dist/chunk-ZZ35WBYQ.mjs +0 -25
  169. package/dist/chunk-ZZ35WBYQ.mjs.map +0 -1
  170. package/dist/groq-adapter-540da9c3.d.ts +0 -331
  171. package/dist/groq-adapter-c8aec5c5.d.ts +0 -321
  172. package/dist/index-96b330da.d.ts +0 -119
  173. package/dist/langserve-0c6100e3.d.ts +0 -257
  174. package/dist/langserve-978d5790.d.ts +0 -243
  175. package/dist/shared-0a7346ce.d.ts +0 -466
  176. package/dist/shared-9ed1dc31.d.ts +0 -414
  177. package/dist/shared-da5708fe.d.ts +0 -449
  178. /package/dist/{chunk-45RCC3ZS.mjs.map → chunk-BJEYMRDD.mjs.map} +0 -0
  179. /package/dist/{chunk-2GPTVDTO.mjs.map → chunk-FMU55SEU.mjs.map} +0 -0
  180. /package/dist/{chunk-4KES76K3.mjs.map → chunk-Z752VE75.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, from3, except, desc) => {
16
- if (from3 && typeof from3 === "object" || typeof from3 === "function") {
17
- for (let key of __getOwnPropNames(from3))
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
18
  if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
20
  }
21
21
  return to;
22
22
  };
@@ -79,11 +79,14 @@ 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",
82
83
  "zod-to-json-schema": "^3.23.5"
83
84
  },
84
85
  dependencies: {
85
86
  "@anthropic-ai/sdk": "^0.57.0",
86
87
  "@copilotkit/shared": "workspace:*",
88
+ "@copilotkitnext/agent": "^0.0.17",
89
+ "@copilotkitnext/runtime": "^0.0.17",
87
90
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
88
91
  "@langchain/aws": "^0.1.9",
89
92
  "@langchain/community": "^0.3.29",
@@ -153,7 +156,7 @@ var import_type_graphql27 = require("type-graphql");
153
156
 
154
157
  // src/graphql/resolvers/copilot.resolver.ts
155
158
  var import_type_graphql21 = require("type-graphql");
156
- var import_rxjs3 = require("rxjs");
159
+ var import_rxjs2 = require("rxjs");
157
160
 
158
161
  // src/graphql/inputs/generate-copilot-response.input.ts
159
162
  var import_type_graphql19 = require("type-graphql");
@@ -165,11 +168,11 @@ var import_type_graphql3 = require("type-graphql");
165
168
  var import_type_graphql = require("type-graphql");
166
169
  var MessageRole;
167
170
  (function(MessageRole2) {
168
- MessageRole2["user"] = "user";
169
171
  MessageRole2["assistant"] = "assistant";
172
+ MessageRole2["developer"] = "developer";
170
173
  MessageRole2["system"] = "system";
171
174
  MessageRole2["tool"] = "tool";
172
- MessageRole2["developer"] = "developer";
175
+ MessageRole2["user"] = "user";
173
176
  })(MessageRole || (MessageRole = {}));
174
177
  var CopilotRequestType;
175
178
  (function(CopilotRequestType2) {
@@ -876,9 +879,10 @@ var MessageStatusCode;
876
879
  (0, import_type_graphql12.registerEnumType)(MessageStatusCode, {
877
880
  name: "MessageStatusCode"
878
881
  });
879
- var BaseMessageStatus = /* @__PURE__ */ __name(class BaseMessageStatus2 {
882
+ var BaseMessageStatus = class {
880
883
  code;
881
- }, "BaseMessageStatus");
884
+ };
885
+ __name(BaseMessageStatus, "BaseMessageStatus");
882
886
  _ts_decorate11([
883
887
  (0, import_type_graphql12.Field)(() => MessageStatusCode),
884
888
  _ts_metadata11("design:type", String)
@@ -1685,13 +1689,24 @@ GenerateCopilotResponseInput = _ts_decorate18([
1685
1689
  var import_graphql_yoga = require("graphql-yoga");
1686
1690
 
1687
1691
  // src/service-adapters/events.ts
1688
- var import_shared5 = require("@copilotkit/shared");
1689
- var import_class_transformer = require("class-transformer");
1690
- var import_rxjs2 = require("rxjs");
1692
+ var import_shared2 = require("@copilotkit/shared");
1693
+ var import_rxjs = require("rxjs");
1691
1694
 
1692
1695
  // src/graphql/types/converted/index.ts
1693
- var Message = class extends BaseMessageInput {
1696
+ var import_shared = require("@copilotkit/shared");
1697
+ var Message = class {
1694
1698
  type;
1699
+ id;
1700
+ createdAt;
1701
+ status;
1702
+ constructor(props) {
1703
+ props.id ?? (props.id = (0, import_shared.randomId)());
1704
+ props.status ?? (props.status = {
1705
+ code: MessageStatusCode.Success
1706
+ });
1707
+ props.createdAt ?? (props.createdAt = /* @__PURE__ */ new Date());
1708
+ Object.assign(this, props);
1709
+ }
1695
1710
  isTextMessage() {
1696
1711
  return this.type === "TextMessage";
1697
1712
  }
@@ -1710,10 +1725,14 @@ var Message = class extends BaseMessageInput {
1710
1725
  };
1711
1726
  __name(Message, "Message");
1712
1727
  var TextMessage = class extends Message {
1713
- type = "TextMessage";
1714
1728
  content;
1715
- role;
1716
1729
  parentMessageId;
1730
+ role;
1731
+ type = "TextMessage";
1732
+ constructor(props) {
1733
+ super(props);
1734
+ this.type = "TextMessage";
1735
+ }
1717
1736
  };
1718
1737
  __name(TextMessage, "TextMessage");
1719
1738
  var ActionExecutionMessage = class extends Message {
@@ -1806,17 +1825,80 @@ var AgentStateMessage = class extends Message {
1806
1825
  };
1807
1826
  __name(AgentStateMessage, "AgentStateMessage");
1808
1827
 
1809
- // src/lib/runtime/remote-actions.ts
1810
- var import_shared3 = require("@copilotkit/shared");
1828
+ // src/service-adapters/events.ts
1829
+ var RuntimeEventTypes;
1830
+ (function(RuntimeEventTypes2) {
1831
+ RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
1832
+ RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
1833
+ RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
1834
+ RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
1835
+ RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1836
+ RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1837
+ RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1838
+ RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1839
+ RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
1840
+ RuntimeEventTypes2["RunError"] = "RunError";
1841
+ })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1842
+ var RuntimeMetaEventName;
1843
+ (function(RuntimeMetaEventName2) {
1844
+ RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1845
+ RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
1846
+ RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1847
+ })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
1848
+
1849
+ // src/graphql/resolvers/copilot.resolver.ts
1850
+ var import_graphql_scalars2 = require("graphql-scalars");
1851
+ var import_class_transformer = require("class-transformer");
1852
+ var import_graphql = require("graphql");
1853
+
1854
+ // src/utils/failed-response-status-reasons.ts
1855
+ var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
1856
+ reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
1857
+ constructor({ guardrailsReason }) {
1858
+ super();
1859
+ this.details = {
1860
+ guardrailsReason
1861
+ };
1862
+ }
1863
+ };
1864
+ __name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
1865
+ var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
1866
+ reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
1867
+ constructor({ messageId }) {
1868
+ super();
1869
+ this.details = {
1870
+ messageId,
1871
+ description: "Check the message for mode details"
1872
+ };
1873
+ }
1874
+ };
1875
+ __name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
1876
+ var UnknownErrorResponse = class extends FailedResponseStatus {
1877
+ reason = FailedResponseStatusReason.UNKNOWN_ERROR;
1878
+ constructor({ description, originalError }) {
1879
+ super();
1880
+ this.details = {
1881
+ description,
1882
+ originalError
1883
+ };
1884
+ }
1885
+ };
1886
+ __name(UnknownErrorResponse, "UnknownErrorResponse");
1811
1887
 
1812
1888
  // src/lib/telemetry-client.ts
1813
- var import_shared2 = require("@copilotkit/shared");
1889
+ var import_shared4 = require("@copilotkit/shared");
1814
1890
  var import_node_crypto = require("crypto");
1815
1891
 
1816
1892
  // src/lib/runtime/copilot-runtime.ts
1817
- var import_shared = require("@copilotkit/shared");
1818
- var import_rxjs = require("rxjs");
1819
- var import_langgraph_sdk = require("@langchain/langgraph-sdk");
1893
+ var import_shared3 = require("@copilotkit/shared");
1894
+ var import_runtime22 = require("@copilotkitnext/runtime");
1895
+
1896
+ // src/lib/runtime/types.ts
1897
+ var EndpointType;
1898
+ (function(EndpointType2) {
1899
+ EndpointType2["CopilotKit"] = "copilotKit";
1900
+ EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1901
+ })(EndpointType || (EndpointType = {}));
1820
1902
 
1821
1903
  // src/agents/langgraph/events.ts
1822
1904
  var LangGraphEventTypes;
@@ -1851,6 +1933,7 @@ var CustomEventNames;
1851
1933
  })(CustomEventNames || (CustomEventNames = {}));
1852
1934
 
1853
1935
  // src/lib/runtime/copilot-runtime.ts
1936
+ var import_agent = require("@copilotkitnext/agent");
1854
1937
  function resolveEndpointType(endpoint) {
1855
1938
  if (!endpoint.type) {
1856
1939
  if ("deploymentUrl" in endpoint && "agents" in endpoint) {
@@ -1865,14 +1948,15 @@ __name(resolveEndpointType, "resolveEndpointType");
1865
1948
 
1866
1949
  // src/lib/telemetry-client.ts
1867
1950
  var packageJson = require_package();
1868
- var telemetryClient = new import_shared2.TelemetryClient({
1951
+ var telemetryClient = new import_shared4.TelemetryClient({
1869
1952
  packageName: packageJson.name,
1870
1953
  packageVersion: packageJson.version
1871
1954
  });
1872
1955
  function getRuntimeInstanceTelemetryInfo(options) {
1873
- var _a, _b;
1956
+ var _a, _b, _c, _d, _e;
1874
1957
  const runtime = options.runtime;
1875
- const endpointsInfo = runtime.remoteEndpointDefinitions.reduce((acc, endpoint) => {
1958
+ const remoteEndpoints = ((_a = runtime.params) == null ? void 0 : _a.remoteEndpoints) ?? [];
1959
+ const endpointsInfo = remoteEndpoints.reduce((acc, endpoint) => {
1876
1960
  let info = {
1877
1961
  ...acc
1878
1962
  };
@@ -1900,19 +1984,19 @@ function getRuntimeInstanceTelemetryInfo(options) {
1900
1984
  agentsAmount: null,
1901
1985
  hashedKey: null
1902
1986
  });
1903
- const publicApiKey = (_a = options.cloud) == null ? void 0 : _a.publicApiKey;
1987
+ const publicApiKey = (_b = options.cloud) == null ? void 0 : _b.publicApiKey;
1904
1988
  const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
1905
1989
  return {
1906
- actionsAmount: runtime.actions.length,
1907
- endpointsAmount: runtime.remoteEndpointDefinitions.length,
1990
+ actionsAmount: ((_d = (_c = runtime.params) == null ? void 0 : _c.actions) == null ? void 0 : _d.length) ?? 0,
1991
+ endpointsAmount: remoteEndpoints.length,
1908
1992
  endpointTypes: endpointsInfo.endpointTypes,
1909
- agentsAmount: endpointsInfo.agentsAmount,
1993
+ agentsAmount: Object.keys(runtime.instance.agents).length,
1910
1994
  hashedLgcKey: endpointsInfo.hashedKey,
1911
1995
  "cloud.api_key_provided": apiKeyProvided,
1912
1996
  ...apiKeyProvided ? {
1913
1997
  "cloud.public_api_key": publicApiKey
1914
1998
  } : {},
1915
- ...((_b = options.cloud) == null ? void 0 : _b.baseUrl) ? {
1999
+ ...((_e = options.cloud) == null ? void 0 : _e.baseUrl) ? {
1916
2000
  "cloud.base_url": options.cloud.baseUrl
1917
2001
  } : {}
1918
2002
  };
@@ -1920,76 +2004,8 @@ function getRuntimeInstanceTelemetryInfo(options) {
1920
2004
  __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
1921
2005
  var telemetry_client_default = telemetryClient;
1922
2006
 
1923
- // src/lib/runtime/remote-actions.ts
1924
- var import_shared4 = require("@copilotkit/shared");
1925
- var EndpointType;
1926
- (function(EndpointType2) {
1927
- EndpointType2["CopilotKit"] = "copilotKit";
1928
- EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1929
- })(EndpointType || (EndpointType = {}));
1930
-
1931
- // src/service-adapters/events.ts
1932
- var RuntimeEventTypes;
1933
- (function(RuntimeEventTypes2) {
1934
- RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
1935
- RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
1936
- RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
1937
- RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
1938
- RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1939
- RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1940
- RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1941
- RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1942
- RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
1943
- RuntimeEventTypes2["RunError"] = "RunError";
1944
- })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1945
- var RuntimeMetaEventName;
1946
- (function(RuntimeMetaEventName2) {
1947
- RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1948
- RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
1949
- RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1950
- })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
1951
-
1952
- // src/graphql/resolvers/copilot.resolver.ts
1953
- var import_graphql_scalars2 = require("graphql-scalars");
1954
- var import_class_transformer2 = require("class-transformer");
1955
- var import_graphql = require("graphql");
1956
-
1957
- // src/utils/failed-response-status-reasons.ts
1958
- var GuardrailsValidationFailureResponse = class extends FailedResponseStatus {
1959
- reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;
1960
- constructor({ guardrailsReason }) {
1961
- super();
1962
- this.details = {
1963
- guardrailsReason
1964
- };
1965
- }
1966
- };
1967
- __name(GuardrailsValidationFailureResponse, "GuardrailsValidationFailureResponse");
1968
- var MessageStreamInterruptedResponse = class extends FailedResponseStatus {
1969
- reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;
1970
- constructor({ messageId }) {
1971
- super();
1972
- this.details = {
1973
- messageId,
1974
- description: "Check the message for mode details"
1975
- };
1976
- }
1977
- };
1978
- __name(MessageStreamInterruptedResponse, "MessageStreamInterruptedResponse");
1979
- var UnknownErrorResponse = class extends FailedResponseStatus {
1980
- reason = FailedResponseStatusReason.UNKNOWN_ERROR;
1981
- constructor({ description, originalError }) {
1982
- super();
1983
- this.details = {
1984
- description,
1985
- originalError
1986
- };
1987
- }
1988
- };
1989
- __name(UnknownErrorResponse, "UnknownErrorResponse");
1990
-
1991
2007
  // src/graphql/resolvers/copilot.resolver.ts
1992
- var import_shared6 = require("@copilotkit/shared");
2008
+ var import_shared5 = require("@copilotkit/shared");
1993
2009
 
1994
2010
  // src/graphql/types/agents-response.type.ts
1995
2011
  var import_type_graphql20 = require("type-graphql");
@@ -2045,7 +2061,7 @@ AgentsResponse = _ts_decorate19([
2045
2061
  ], AgentsResponse);
2046
2062
 
2047
2063
  // src/graphql/resolvers/copilot.resolver.ts
2048
- var import_shared7 = require("@copilotkit/shared");
2064
+ var import_shared6 = require("@copilotkit/shared");
2049
2065
  function _ts_decorate20(decorators, target, key, desc) {
2050
2066
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2051
2067
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2108,14 +2124,14 @@ var CopilotResolver = class {
2108
2124
  component: "CopilotResolver.availableAgents"
2109
2125
  });
2110
2126
  logger2.debug("Processing");
2111
- const agentsWithEndpoints = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
2127
+ const agentsWithEndpoints = [];
2112
2128
  logger2.debug("Event source created, creating response");
2113
2129
  return {
2114
2130
  agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
2115
2131
  };
2116
2132
  }
2117
2133
  async generateCopilotResponse(ctx, data, properties) {
2118
- var _a, _b, _c, _d, _e, _f, _g;
2134
+ var _a, _b, _c, _d;
2119
2135
  telemetry_client_default.capture("oss.runtime.copilot_request_created", {
2120
2136
  "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
2121
2137
  requestType: data.metadata.requestType,
@@ -2157,21 +2173,12 @@ var CopilotResolver = class {
2157
2173
  logger2.debug("Cloud configuration provided, checking for public API key in headers");
2158
2174
  if (!copilotCloudPublicApiKey) {
2159
2175
  logger2.error("Public API key not found in headers");
2160
- await copilotRuntime.errorGraphQLError({
2161
- message: "X-CopilotCloud-Public-API-Key header is required",
2162
- code: "MISSING_PUBLIC_API_KEY",
2163
- type: "GraphQLError"
2164
- }, {
2165
- operation: "generateCopilotResponse",
2166
- cloudConfigPresent: Boolean(data.cloud),
2167
- guardrailsEnabled: Boolean((_b = data.cloud) == null ? void 0 : _b.guardrails)
2168
- });
2169
2176
  throw new import_graphql.GraphQLError("X-CopilotCloud-Public-API-Key header is required");
2170
2177
  }
2171
2178
  if (process.env.COPILOT_CLOUD_BASE_URL) {
2172
2179
  copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
2173
- } else if ((_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl) {
2174
- copilotCloudBaseUrl = (_d = ctx._copilotkit.cloud) == null ? void 0 : _d.baseUrl;
2180
+ } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
2181
+ copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
2175
2182
  } else {
2176
2183
  copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
2177
2184
  }
@@ -2180,9 +2187,9 @@ var CopilotResolver = class {
2180
2187
  });
2181
2188
  }
2182
2189
  logger2.debug("Setting up subjects");
2183
- const responseStatus$ = new import_rxjs3.ReplaySubject();
2184
- const interruptStreaming$ = new import_rxjs3.ReplaySubject();
2185
- const guardrailsResult$ = new import_rxjs3.ReplaySubject();
2190
+ const responseStatus$ = new import_rxjs2.ReplaySubject();
2191
+ const interruptStreaming$ = new import_rxjs2.ReplaySubject();
2192
+ const guardrailsResult$ = new import_rxjs2.ReplaySubject();
2186
2193
  let outputMessages = [];
2187
2194
  let resolveOutputMessagesPromise;
2188
2195
  let rejectOutputMessagesPromise;
@@ -2195,41 +2202,11 @@ var CopilotResolver = class {
2195
2202
  }
2196
2203
  logger2.debug("Processing");
2197
2204
  let runtimeResponse;
2198
- try {
2199
- runtimeResponse = await copilotRuntime.processRuntimeRequest({
2200
- serviceAdapter,
2201
- messages: data.messages,
2202
- actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
2203
- threadId: data.threadId,
2204
- runId: data.runId,
2205
- publicApiKey: copilotCloudPublicApiKey,
2206
- outputMessagesPromise,
2207
- graphqlContext: ctx,
2208
- forwardedParameters: data.forwardedParameters,
2209
- agentSession: data.agentSession,
2210
- agentStates: data.agentStates,
2211
- url: data.frontend.url,
2212
- extensions: data.extensions,
2213
- metaEvents: data.metaEvents,
2214
- context: data.context
2215
- });
2216
- } catch (error) {
2217
- if ((0, import_shared7.isStructuredCopilotKitError)(error) || ((_e = error == null ? void 0 : error.extensions) == null ? void 0 : _e.visibility)) {
2218
- throw new import_graphql.GraphQLError(error.message || "Agent error occurred", {
2219
- extensions: {
2220
- ...error.extensions,
2221
- code: error.code || ((_f = error.extensions) == null ? void 0 : _f.code) || "AGENT_ERROR",
2222
- originalError: error
2223
- }
2224
- });
2225
- }
2226
- throw error;
2227
- }
2228
- const { eventSource, threadId = (0, import_shared6.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
2205
+ const { eventSource, threadId = (0, import_shared5.randomId)(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
2229
2206
  logger2.debug("Event source created, creating response");
2230
2207
  const eventStream = eventSource.processRuntimeEvents({
2231
2208
  serverSideActions,
2232
- guardrailsResult$: ((_g = data.cloud) == null ? void 0 : _g.guardrails) ? guardrailsResult$ : null,
2209
+ guardrailsResult$: ((_d = data.cloud) == null ? void 0 : _d.guardrails) ? guardrailsResult$ : null,
2233
2210
  actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
2234
2211
  // TODO-AGENTS: do not exclude ALL server side actions
2235
2212
  (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
@@ -2238,15 +2215,15 @@ var CopilotResolver = class {
2238
2215
  }).pipe(
2239
2216
  // shareReplay() ensures that later subscribers will see the whole stream instead of
2240
2217
  // just the events that were emitted after the subscriber was added.
2241
- (0, import_rxjs3.shareReplay)(),
2242
- (0, import_rxjs3.finalize)(() => {
2218
+ (0, import_rxjs2.shareReplay)(),
2219
+ (0, import_rxjs2.finalize)(() => {
2243
2220
  logger2.debug("Event stream finalized");
2244
2221
  })
2245
2222
  );
2246
2223
  const response = {
2247
2224
  threadId,
2248
2225
  runId,
2249
- status: (0, import_rxjs3.firstValueFrom)(responseStatus$),
2226
+ status: (0, import_rxjs2.firstValueFrom)(responseStatus$),
2250
2227
  extensions,
2251
2228
  metaEvents: new import_graphql_yoga.Repeater(async (push, stop) => {
2252
2229
  let eventStreamSubscription;
@@ -2257,7 +2234,7 @@ var CopilotResolver = class {
2257
2234
  }
2258
2235
  switch (event.name) {
2259
2236
  case LangGraphEventTypes.OnInterrupt:
2260
- push((0, import_class_transformer2.plainToInstance)(LangGraphInterruptEvent, {
2237
+ push((0, import_class_transformer.plainToInstance)(LangGraphInterruptEvent, {
2261
2238
  // @ts-ignore
2262
2239
  type: event.type,
2263
2240
  // @ts-ignore
@@ -2267,21 +2244,21 @@ var CopilotResolver = class {
2267
2244
  }));
2268
2245
  break;
2269
2246
  case RuntimeMetaEventName.LangGraphInterruptEvent:
2270
- push((0, import_class_transformer2.plainToInstance)(LangGraphInterruptEvent, {
2247
+ push((0, import_class_transformer.plainToInstance)(LangGraphInterruptEvent, {
2271
2248
  type: event.type,
2272
2249
  name: event.name,
2273
2250
  value: event.value
2274
2251
  }));
2275
2252
  break;
2276
2253
  case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
2277
- push((0, import_class_transformer2.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
2254
+ push((0, import_class_transformer.plainToInstance)(CopilotKitLangGraphInterruptEvent, {
2278
2255
  type: event.type,
2279
2256
  name: event.name,
2280
2257
  data: {
2281
2258
  value: event.data.value,
2282
2259
  messages: event.data.messages.map((message) => {
2283
2260
  if (message.type === "TextMessage" || "content" in message && "role" in message) {
2284
- return (0, import_class_transformer2.plainToInstance)(TextMessage, {
2261
+ return (0, import_class_transformer.plainToInstance)(TextMessage, {
2285
2262
  id: message.id,
2286
2263
  createdAt: /* @__PURE__ */ new Date(),
2287
2264
  content: [
@@ -2292,7 +2269,7 @@ var CopilotResolver = class {
2292
2269
  });
2293
2270
  }
2294
2271
  if ("arguments" in message) {
2295
- return (0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
2272
+ return (0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
2296
2273
  name: message.name,
2297
2274
  id: message.id,
2298
2275
  arguments: [
@@ -2356,8 +2333,8 @@ var CopilotResolver = class {
2356
2333
  reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
2357
2334
  });
2358
2335
  outputMessages = [
2359
- (0, import_class_transformer2.plainToInstance)(TextMessage, {
2360
- id: (0, import_shared6.randomId)(),
2336
+ (0, import_class_transformer.plainToInstance)(TextMessage, {
2337
+ id: (0, import_shared5.randomId)(),
2361
2338
  createdAt: /* @__PURE__ */ new Date(),
2362
2339
  content: result.reason,
2363
2340
  role: MessageRole.assistant
@@ -2390,30 +2367,30 @@ var CopilotResolver = class {
2390
2367
  case RuntimeEventTypes.TextMessageStart:
2391
2368
  const textMessageContentStream = eventStream.pipe(
2392
2369
  // skip until this message start event
2393
- (0, import_rxjs3.skipWhile)((e) => e !== event),
2370
+ (0, import_rxjs2.skipWhile)((e) => e !== event),
2394
2371
  // take until the message end event
2395
- (0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
2372
+ (0, import_rxjs2.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
2396
2373
  // filter out any other message events or message ids
2397
- (0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
2374
+ (0, import_rxjs2.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
2398
2375
  );
2399
- const streamingTextStatus = new import_rxjs3.Subject();
2376
+ const streamingTextStatus = new import_rxjs2.Subject();
2400
2377
  const messageId = event.messageId;
2401
2378
  pushMessage({
2402
2379
  id: messageId,
2403
2380
  parentMessageId: event.parentMessageId,
2404
- status: (0, import_rxjs3.firstValueFrom)(streamingTextStatus),
2381
+ status: (0, import_rxjs2.firstValueFrom)(streamingTextStatus),
2405
2382
  createdAt: /* @__PURE__ */ new Date(),
2406
2383
  role: MessageRole.assistant,
2407
2384
  content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
2408
2385
  logger2.debug("Text message content repeater created");
2409
2386
  const textChunks = [];
2410
2387
  let textSubscription;
2411
- interruptStreaming$.pipe((0, import_rxjs3.shareReplay)(), (0, import_rxjs3.take)(1), (0, import_rxjs3.tap)(({ reason, messageId: messageId2 }) => {
2388
+ interruptStreaming$.pipe((0, import_rxjs2.shareReplay)(), (0, import_rxjs2.take)(1), (0, import_rxjs2.tap)(({ reason, messageId: messageId2 }) => {
2412
2389
  logger2.debug({
2413
2390
  reason,
2414
2391
  messageId: messageId2
2415
2392
  }, "Text streaming interrupted");
2416
- streamingTextStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
2393
+ streamingTextStatus.next((0, import_class_transformer.plainToInstance)(FailedMessageStatus, {
2417
2394
  reason
2418
2395
  }));
2419
2396
  responseStatus$.next(new MessageStreamInterruptedResponse({
@@ -2446,7 +2423,7 @@ var CopilotResolver = class {
2446
2423
  streamingTextStatus.next(new SuccessMessageStatus());
2447
2424
  stopStreamingText();
2448
2425
  textSubscription == null ? void 0 : textSubscription.unsubscribe();
2449
- outputMessages.push((0, import_class_transformer2.plainToInstance)(TextMessage, {
2426
+ outputMessages.push((0, import_class_transformer.plainToInstance)(TextMessage, {
2450
2427
  id: messageId,
2451
2428
  createdAt: /* @__PURE__ */ new Date(),
2452
2429
  content: textChunks.join(""),
@@ -2460,17 +2437,17 @@ var CopilotResolver = class {
2460
2437
  case RuntimeEventTypes.ActionExecutionStart:
2461
2438
  logger2.debug("Action execution start event received");
2462
2439
  const actionExecutionArgumentStream = eventStream.pipe(
2463
- (0, import_rxjs3.skipWhile)((e) => e !== event),
2440
+ (0, import_rxjs2.skipWhile)((e) => e !== event),
2464
2441
  // take until the action execution end event
2465
- (0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
2442
+ (0, import_rxjs2.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
2466
2443
  // filter out any other action execution events or action execution ids
2467
- (0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
2444
+ (0, import_rxjs2.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
2468
2445
  );
2469
- const streamingArgumentsStatus = new import_rxjs3.Subject();
2446
+ const streamingArgumentsStatus = new import_rxjs2.Subject();
2470
2447
  pushMessage({
2471
2448
  id: event.actionExecutionId,
2472
2449
  parentMessageId: event.parentMessageId,
2473
- status: (0, import_rxjs3.firstValueFrom)(streamingArgumentsStatus),
2450
+ status: (0, import_rxjs2.firstValueFrom)(streamingArgumentsStatus),
2474
2451
  createdAt: /* @__PURE__ */ new Date(),
2475
2452
  name: event.actionName,
2476
2453
  arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
@@ -2488,7 +2465,7 @@ var CopilotResolver = class {
2488
2465
  logger2.error({
2489
2466
  err
2490
2467
  }, "Error in action execution argument stream");
2491
- streamingArgumentsStatus.next((0, import_class_transformer2.plainToInstance)(FailedMessageStatus, {
2468
+ streamingArgumentsStatus.next((0, import_class_transformer.plainToInstance)(FailedMessageStatus, {
2492
2469
  reason: "An unknown error has occurred in the action execution argument stream"
2493
2470
  }));
2494
2471
  stopStreamingArguments();
@@ -2499,7 +2476,7 @@ var CopilotResolver = class {
2499
2476
  streamingArgumentsStatus.next(new SuccessMessageStatus());
2500
2477
  stopStreamingArguments();
2501
2478
  actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
2502
- outputMessages.push((0, import_class_transformer2.plainToInstance)(ActionExecutionMessage, {
2479
+ outputMessages.push((0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
2503
2480
  id: event.actionExecutionId,
2504
2481
  createdAt: /* @__PURE__ */ new Date(),
2505
2482
  name: event.actionName,
@@ -2522,7 +2499,7 @@ var CopilotResolver = class {
2522
2499
  actionName: event.actionName,
2523
2500
  result: event.result
2524
2501
  });
2525
- outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
2502
+ outputMessages.push((0, import_class_transformer.plainToInstance)(ResultMessage, {
2526
2503
  id: "result-" + event.actionExecutionId,
2527
2504
  createdAt: /* @__PURE__ */ new Date(),
2528
2505
  actionExecutionId: event.actionExecutionId,
@@ -2535,7 +2512,7 @@ var CopilotResolver = class {
2535
2512
  event
2536
2513
  }, "Agent message event received");
2537
2514
  pushMessage({
2538
- id: (0, import_shared6.randomId)(),
2515
+ id: (0, import_shared5.randomId)(),
2539
2516
  status: new SuccessMessageStatus(),
2540
2517
  threadId: event.threadId,
2541
2518
  agentName: event.agentName,
@@ -2547,8 +2524,8 @@ var CopilotResolver = class {
2547
2524
  role: MessageRole.assistant,
2548
2525
  createdAt: /* @__PURE__ */ new Date()
2549
2526
  });
2550
- outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
2551
- id: (0, import_shared6.randomId)(),
2527
+ outputMessages.push((0, import_class_transformer.plainToInstance)(AgentStateMessage, {
2528
+ id: (0, import_shared5.randomId)(),
2552
2529
  threadId: event.threadId,
2553
2530
  agentName: event.agentName,
2554
2531
  nodeName: event.nodeName,
@@ -2563,8 +2540,8 @@ var CopilotResolver = class {
2563
2540
  }
2564
2541
  },
2565
2542
  error: (err) => {
2566
- var _a3, _b2, _c2, _d2, _e2, _f2;
2567
- 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)) {
2543
+ var _a3, _b2, _c2, _d2, _e, _f;
2544
+ 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)) {
2568
2545
  responseStatus$.next(new UnknownErrorResponse({
2569
2546
  description: err.message || "Agent error occurred",
2570
2547
  // Include original error information for frontend to extract
@@ -2572,8 +2549,8 @@ var CopilotResolver = class {
2572
2549
  code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
2573
2550
  statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
2574
2551
  severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
2575
- visibility: err.visibility || ((_e2 = err.extensions) == null ? void 0 : _e2.visibility),
2576
- originalErrorType: err.originalErrorType || ((_f2 = err.extensions) == null ? void 0 : _f2.originalErrorType),
2552
+ visibility: err.visibility || ((_e = err.extensions) == null ? void 0 : _e.visibility),
2553
+ originalErrorType: err.originalErrorType || ((_f = err.extensions) == null ? void 0 : _f.originalErrorType),
2577
2554
  extensions: err.extensions
2578
2555
  }
2579
2556
  }));
@@ -2594,7 +2571,7 @@ var CopilotResolver = class {
2594
2571
  logger2.debug("Event stream completed");
2595
2572
  if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
2596
2573
  logger2.debug("Guardrails is enabled, waiting for guardrails result");
2597
- await (0, import_rxjs3.firstValueFrom)(guardrailsResult$);
2574
+ await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
2598
2575
  }
2599
2576
  responseStatus$.next(new SuccessResponseStatus());
2600
2577
  eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
@@ -2759,7 +2736,7 @@ LoadAgentStateInput = _ts_decorate22([
2759
2736
  ], LoadAgentStateInput);
2760
2737
 
2761
2738
  // src/graphql/resolvers/state.resolver.ts
2762
- var import_shared8 = require("@copilotkit/shared");
2739
+ var import_shared7 = require("@copilotkit/shared");
2763
2740
  function _ts_decorate23(decorators, target, key, desc) {
2764
2741
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2765
2742
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -2784,10 +2761,10 @@ function _ts_param2(paramIndex, decorator) {
2784
2761
  __name(_ts_param2, "_ts_param");
2785
2762
  var StateResolver = class {
2786
2763
  async loadAgentState(ctx, data) {
2787
- const agents = await ctx._copilotkit.runtime.getAllAgents(ctx);
2764
+ const agents = [];
2788
2765
  const hasAgent = agents.some((agent) => agent.name === data.agentName);
2789
2766
  if (!hasAgent) {
2790
- throw new import_shared8.CopilotKitAgentDiscoveryError({
2767
+ throw new import_shared7.CopilotKitAgentDiscoveryError({
2791
2768
  agentName: data.agentName,
2792
2769
  availableAgents: agents.map((a) => ({
2793
2770
  name: a.name,
@@ -2795,7 +2772,7 @@ var StateResolver = class {
2795
2772
  }))
2796
2773
  });
2797
2774
  }
2798
- const state = await ctx._copilotkit.runtime.loadAgentState(ctx, data.threadId, data.agentName);
2775
+ const state = {};
2799
2776
  return state;
2800
2777
  }
2801
2778
  };
@@ -2817,7 +2794,7 @@ StateResolver = _ts_decorate23([
2817
2794
 
2818
2795
  // src/lib/integrations/shared.ts
2819
2796
  var packageJson2 = __toESM(require_package());
2820
- var import_shared9 = require("@copilotkit/shared");
2797
+ var import_shared8 = require("@copilotkit/shared");
2821
2798
  var logger = createLogger();
2822
2799
  var addCustomHeaderPlugin = {
2823
2800
  onResponse({ response }) {
@@ -2883,11 +2860,11 @@ function getCommonConfig(options) {
2883
2860
  }
2884
2861
  });
2885
2862
  const userErrorCodes = [
2886
- import_shared9.CopilotKitErrorCode.AGENT_NOT_FOUND,
2887
- import_shared9.CopilotKitErrorCode.API_NOT_FOUND,
2888
- import_shared9.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,
2889
- import_shared9.CopilotKitErrorCode.CONFIGURATION_ERROR,
2890
- import_shared9.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR
2863
+ import_shared8.CopilotKitErrorCode.AGENT_NOT_FOUND,
2864
+ import_shared8.CopilotKitErrorCode.API_NOT_FOUND,
2865
+ import_shared8.CopilotKitErrorCode.REMOTE_ENDPOINT_NOT_FOUND,
2866
+ import_shared8.CopilotKitErrorCode.CONFIGURATION_ERROR,
2867
+ import_shared8.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR
2891
2868
  ];
2892
2869
  return {
2893
2870
  logging: createLogger({
@@ -2910,7 +2887,7 @@ function getCommonConfig(options) {
2910
2887
  console.debug("User configuration error:", error.message);
2911
2888
  return error;
2912
2889
  }
2913
- if (originalError instanceof import_shared9.CopilotKitError && userErrorCodes.includes(originalError.code)) {
2890
+ if (originalError instanceof import_shared8.CopilotKitError && userErrorCodes.includes(originalError.code)) {
2914
2891
  console.debug("User configuration error:", error.message);
2915
2892
  return error;
2916
2893
  }
@@ -2923,7 +2900,7 @@ function getCommonConfig(options) {
2923
2900
  __name(getCommonConfig, "getCommonConfig");
2924
2901
 
2925
2902
  // src/lib/integrations/nextjs/app-router.ts
2926
- var import_graphql_yoga2 = require("graphql-yoga");
2903
+ var import_runtime32 = require("@copilotkitnext/runtime");
2927
2904
  function copilotRuntimeNextJSAppRouterEndpoint(options) {
2928
2905
  var _a;
2929
2906
  const commonConfig = getCommonConfig(options);
@@ -2940,24 +2917,17 @@ function copilotRuntimeNextJSAppRouterEndpoint(options) {
2940
2917
  telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
2941
2918
  const logger2 = commonConfig.logging;
2942
2919
  logger2.debug("Creating NextJS App Router endpoint");
2943
- const yoga = (0, import_graphql_yoga2.createYoga)({
2944
- ...commonConfig,
2945
- graphqlEndpoint: options.endpoint,
2946
- fetchAPI: {
2947
- Response: globalThis.Response
2948
- }
2920
+ const serviceAdapter = options.serviceAdapter;
2921
+ options.runtime.handleServiceAdapter(serviceAdapter);
2922
+ return (0, import_runtime32.createCopilotEndpoint)({
2923
+ runtime: options.runtime.instance,
2924
+ basePath: options.endpoint
2949
2925
  });
2950
- return {
2951
- handleRequest: yoga,
2952
- GET: yoga,
2953
- POST: yoga,
2954
- OPTIONS: yoga
2955
- };
2956
2926
  }
2957
2927
  __name(copilotRuntimeNextJSAppRouterEndpoint, "copilotRuntimeNextJSAppRouterEndpoint");
2958
2928
 
2959
2929
  // src/lib/integrations/nextjs/pages-router.ts
2960
- var import_graphql_yoga3 = require("graphql-yoga");
2930
+ var import_runtime34 = require("@copilotkitnext/runtime");
2961
2931
  var config = {
2962
2932
  api: {
2963
2933
  bodyParser: false
@@ -2979,16 +2949,17 @@ function copilotRuntimeNextJSPagesRouterEndpoint(options) {
2979
2949
  telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
2980
2950
  const logger2 = commonConfig.logging;
2981
2951
  logger2.debug("Creating NextJS Pages Router endpoint");
2982
- const yoga = (0, import_graphql_yoga3.createYoga)({
2983
- ...commonConfig,
2984
- graphqlEndpoint: options.endpoint
2952
+ const serviceAdapter = options.serviceAdapter;
2953
+ options.runtime.handleServiceAdapter(serviceAdapter);
2954
+ return (0, import_runtime34.createCopilotEndpoint)({
2955
+ runtime: options.runtime.instance,
2956
+ basePath: options.baseUrl
2985
2957
  });
2986
- return yoga;
2987
2958
  }
2988
2959
  __name(copilotRuntimeNextJSPagesRouterEndpoint, "copilotRuntimeNextJSPagesRouterEndpoint");
2989
2960
 
2990
2961
  // src/lib/integrations/node-http/index.ts
2991
- var import_graphql_yoga4 = require("graphql-yoga");
2962
+ var import_runtime36 = require("@copilotkitnext/runtime");
2992
2963
  function copilotRuntimeNodeHttpEndpoint(options) {
2993
2964
  var _a;
2994
2965
  const commonConfig = getCommonConfig(options);
@@ -3005,11 +2976,12 @@ function copilotRuntimeNodeHttpEndpoint(options) {
3005
2976
  telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
3006
2977
  const logger2 = commonConfig.logging;
3007
2978
  logger2.debug("Creating Node HTTP endpoint");
3008
- const yoga = (0, import_graphql_yoga4.createYoga)({
3009
- ...commonConfig,
3010
- graphqlEndpoint: options.endpoint
2979
+ const serviceAdapter = options.serviceAdapter;
2980
+ options.runtime.handleServiceAdapter(serviceAdapter);
2981
+ return (0, import_runtime36.createCopilotEndpoint)({
2982
+ runtime: options.runtime.instance,
2983
+ basePath: options.baseUrl
3011
2984
  });
3012
- return yoga;
3013
2985
  }
3014
2986
  __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
3015
2987