@copilotkit/runtime 1.50.0-beta.8 → 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 (226) hide show
  1. package/CHANGELOG.md +168 -0
  2. package/dist/chunk-27JKTS6P.mjs +1704 -0
  3. package/dist/chunk-27JKTS6P.mjs.map +1 -0
  4. package/dist/chunk-2GPTVDTO.mjs +25 -0
  5. package/dist/chunk-2GPTVDTO.mjs.map +1 -0
  6. package/dist/chunk-2OZAGFV3.mjs +43 -0
  7. package/dist/chunk-2OZAGFV3.mjs.map +1 -0
  8. package/dist/chunk-3AJVKDZX.mjs +3097 -0
  9. package/dist/chunk-3AJVKDZX.mjs.map +1 -0
  10. package/dist/chunk-45RCC3ZS.mjs +25 -0
  11. package/dist/chunk-45RCC3ZS.mjs.map +1 -0
  12. package/dist/chunk-4EHJ4XFJ.mjs +25 -0
  13. package/dist/chunk-4EHJ4XFJ.mjs.map +1 -0
  14. package/dist/chunk-4IANB4TC.mjs +25 -0
  15. package/dist/chunk-4IANB4TC.mjs.map +1 -0
  16. package/dist/chunk-4KES76K3.mjs +74 -0
  17. package/dist/chunk-4KES76K3.mjs.map +1 -0
  18. package/dist/chunk-4OGE3SLW.mjs +3100 -0
  19. package/dist/chunk-4OGE3SLW.mjs.map +1 -0
  20. package/dist/chunk-54YJBMCP.mjs +3097 -0
  21. package/dist/chunk-54YJBMCP.mjs.map +1 -0
  22. package/dist/chunk-62NE5S6M.mjs +226 -0
  23. package/dist/chunk-62NE5S6M.mjs.map +1 -0
  24. package/dist/chunk-6ER4SZYH.mjs +74 -0
  25. package/dist/chunk-6ER4SZYH.mjs.map +1 -0
  26. package/dist/chunk-6TNSLHVR.mjs +74 -0
  27. package/dist/chunk-6TNSLHVR.mjs.map +1 -0
  28. package/dist/chunk-6XRUR5UK.mjs +1 -0
  29. package/dist/chunk-6XRUR5UK.mjs.map +1 -0
  30. package/dist/chunk-7V4BK7TZ.mjs +25 -0
  31. package/dist/chunk-7V4BK7TZ.mjs.map +1 -0
  32. package/dist/chunk-7YZIEXD2.mjs +74 -0
  33. package/dist/chunk-7YZIEXD2.mjs.map +1 -0
  34. package/dist/chunk-A4XHOAFU.mjs +25 -0
  35. package/dist/chunk-A4XHOAFU.mjs.map +1 -0
  36. package/dist/chunk-A555KEAD.mjs +6020 -0
  37. package/dist/chunk-A555KEAD.mjs.map +1 -0
  38. package/dist/chunk-AF73TFTX.mjs +74 -0
  39. package/dist/chunk-AF73TFTX.mjs.map +1 -0
  40. package/dist/chunk-AMUJQ6IR.mjs +50 -0
  41. package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
  42. package/dist/chunk-AQG2SVCA.mjs +25 -0
  43. package/dist/chunk-AQG2SVCA.mjs.map +1 -0
  44. package/dist/chunk-BJZHMXND.mjs +74 -0
  45. package/dist/chunk-BJZHMXND.mjs.map +1 -0
  46. package/dist/chunk-CB2OJXF6.mjs +25 -0
  47. package/dist/chunk-CB2OJXF6.mjs.map +1 -0
  48. package/dist/chunk-CEOMFPJU.mjs +6020 -0
  49. package/dist/chunk-CEOMFPJU.mjs.map +1 -0
  50. package/dist/chunk-CZVLR7CC.mjs +175 -0
  51. package/dist/chunk-CZVLR7CC.mjs.map +1 -0
  52. package/dist/chunk-DCEEHMLJ.mjs +1127 -0
  53. package/dist/chunk-DCEEHMLJ.mjs.map +1 -0
  54. package/dist/chunk-DE3CLKUG.mjs +25 -0
  55. package/dist/chunk-DE3CLKUG.mjs.map +1 -0
  56. package/dist/chunk-DTPRUTNV.mjs +25 -0
  57. package/dist/chunk-DTPRUTNV.mjs.map +1 -0
  58. package/dist/chunk-ERUOA47O.mjs +626 -0
  59. package/dist/chunk-ERUOA47O.mjs.map +1 -0
  60. package/dist/chunk-ESSRC64W.mjs +74 -0
  61. package/dist/chunk-ESSRC64W.mjs.map +1 -0
  62. package/dist/chunk-FHD4JECV.mjs +33 -0
  63. package/dist/chunk-FHD4JECV.mjs.map +1 -0
  64. package/dist/chunk-GRAN6K6N.mjs +25 -0
  65. package/dist/chunk-GRAN6K6N.mjs.map +1 -0
  66. package/dist/chunk-I27F2UPA.mjs +175 -0
  67. package/dist/chunk-I27F2UPA.mjs.map +1 -0
  68. package/dist/chunk-IAZKTOQW.mjs +25 -0
  69. package/dist/chunk-IAZKTOQW.mjs.map +1 -0
  70. package/dist/chunk-J6XZ5MFB.mjs +25 -0
  71. package/dist/chunk-J6XZ5MFB.mjs.map +1 -0
  72. package/dist/chunk-JJ32MA4C.mjs +73 -0
  73. package/dist/chunk-JJ32MA4C.mjs.map +1 -0
  74. package/dist/chunk-JJY4ZTHQ.mjs +25 -0
  75. package/dist/chunk-JJY4ZTHQ.mjs.map +1 -0
  76. package/dist/chunk-KEYLBFU2.mjs +3117 -0
  77. package/dist/chunk-KEYLBFU2.mjs.map +1 -0
  78. package/dist/chunk-KQ53L4WZ.mjs +3094 -0
  79. package/dist/chunk-KQ53L4WZ.mjs.map +1 -0
  80. package/dist/chunk-KTELVQ67.mjs +3098 -0
  81. package/dist/chunk-KTELVQ67.mjs.map +1 -0
  82. package/dist/chunk-LPEPX6NH.mjs +25 -0
  83. package/dist/chunk-LPEPX6NH.mjs.map +1 -0
  84. package/dist/chunk-MDXE55DK.mjs +3117 -0
  85. package/dist/chunk-MDXE55DK.mjs.map +1 -0
  86. package/dist/chunk-MMFUVOXH.mjs +73 -0
  87. package/dist/chunk-MMFUVOXH.mjs.map +1 -0
  88. package/dist/chunk-N3Y4U66N.mjs +253 -0
  89. package/dist/chunk-N3Y4U66N.mjs.map +1 -0
  90. package/dist/chunk-O7UYB4MH.mjs +25 -0
  91. package/dist/chunk-O7UYB4MH.mjs.map +1 -0
  92. package/dist/chunk-OFNVQHNM.mjs +3089 -0
  93. package/dist/chunk-OFNVQHNM.mjs.map +1 -0
  94. package/dist/chunk-OFSV5GET.mjs +3074 -0
  95. package/dist/chunk-OFSV5GET.mjs.map +1 -0
  96. package/dist/chunk-OMRST67R.mjs +25 -0
  97. package/dist/chunk-OMRST67R.mjs.map +1 -0
  98. package/dist/chunk-OWIGJONH.mjs +275 -0
  99. package/dist/chunk-OWIGJONH.mjs.map +1 -0
  100. package/dist/chunk-PRZHE74A.mjs +25 -0
  101. package/dist/chunk-PRZHE74A.mjs.map +1 -0
  102. package/dist/chunk-PTYRVXXP.mjs +80 -0
  103. package/dist/chunk-PTYRVXXP.mjs.map +1 -0
  104. package/dist/chunk-R22B5CCO.mjs +25 -0
  105. package/dist/chunk-R22B5CCO.mjs.map +1 -0
  106. package/dist/chunk-SHBDMA63.mjs +141 -0
  107. package/dist/chunk-SHBDMA63.mjs.map +1 -0
  108. package/dist/chunk-SPVXBPRA.mjs +74 -0
  109. package/dist/chunk-SPVXBPRA.mjs.map +1 -0
  110. package/dist/chunk-T72G46ME.mjs +25 -0
  111. package/dist/chunk-T72G46ME.mjs.map +1 -0
  112. package/dist/chunk-TGELROPU.mjs +25 -0
  113. package/dist/chunk-TGELROPU.mjs.map +1 -0
  114. package/dist/chunk-UNX4IAAD.mjs +25 -0
  115. package/dist/chunk-UNX4IAAD.mjs.map +1 -0
  116. package/dist/chunk-V4DHVC7M.mjs +3085 -0
  117. package/dist/chunk-V4DHVC7M.mjs.map +1 -0
  118. package/dist/chunk-VVRFOB66.mjs +25 -0
  119. package/dist/chunk-VVRFOB66.mjs.map +1 -0
  120. package/dist/chunk-W6NVBYM6.mjs +80 -0
  121. package/dist/chunk-W6NVBYM6.mjs.map +1 -0
  122. package/dist/chunk-W7MBACGC.mjs +74 -0
  123. package/dist/chunk-W7MBACGC.mjs.map +1 -0
  124. package/dist/chunk-WMD4XZZS.mjs +25 -0
  125. package/dist/chunk-WMD4XZZS.mjs.map +1 -0
  126. package/dist/chunk-WX2ZNCRT.mjs +74 -0
  127. package/dist/chunk-WX2ZNCRT.mjs.map +1 -0
  128. package/dist/chunk-XWBDEXDA.mjs +153 -0
  129. package/dist/chunk-XWBDEXDA.mjs.map +1 -0
  130. package/dist/chunk-Y2Z62E2T.mjs +74 -0
  131. package/dist/chunk-Y2Z62E2T.mjs.map +1 -0
  132. package/dist/chunk-YO4I6RVI.mjs +25 -0
  133. package/dist/chunk-YO4I6RVI.mjs.map +1 -0
  134. package/dist/chunk-Z6Q5IW6I.mjs +3098 -0
  135. package/dist/chunk-Z6Q5IW6I.mjs.map +1 -0
  136. package/dist/chunk-Z726O3G2.mjs +25 -0
  137. package/dist/chunk-Z726O3G2.mjs.map +1 -0
  138. package/dist/chunk-ZE4SMZZR.mjs +3097 -0
  139. package/dist/chunk-ZE4SMZZR.mjs.map +1 -0
  140. package/dist/chunk-ZULZB33C.mjs +73 -0
  141. package/dist/chunk-ZULZB33C.mjs.map +1 -0
  142. package/dist/chunk-ZVRGXMY7.mjs +25 -0
  143. package/dist/chunk-ZVRGXMY7.mjs.map +1 -0
  144. package/dist/chunk-ZZ35WBYQ.mjs +25 -0
  145. package/dist/chunk-ZZ35WBYQ.mjs.map +1 -0
  146. package/dist/graphql/message-conversion/index.d.ts +18 -0
  147. package/dist/graphql/message-conversion/index.js +725 -0
  148. package/dist/graphql/message-conversion/index.js.map +1 -0
  149. package/dist/graphql/message-conversion/index.mjs +245 -0
  150. package/dist/graphql/message-conversion/index.mjs.map +1 -0
  151. package/dist/graphql/types/base/index.d.ts +6 -0
  152. package/dist/graphql/types/base/index.js +63 -0
  153. package/dist/graphql/types/base/index.js.map +1 -0
  154. package/dist/graphql/types/base/index.mjs +8 -0
  155. package/dist/graphql/types/base/index.mjs.map +1 -0
  156. package/dist/graphql/types/converted/index.d.ts +2 -0
  157. package/dist/graphql/types/converted/index.js +200 -0
  158. package/dist/graphql/types/converted/index.js.map +1 -0
  159. package/dist/graphql/types/converted/index.mjs +19 -0
  160. package/dist/graphql/types/converted/index.mjs.map +1 -0
  161. package/dist/groq-adapter-540da9c3.d.ts +331 -0
  162. package/dist/groq-adapter-a6f5e9d2.d.ts +331 -0
  163. package/dist/groq-adapter-c8aec5c5.d.ts +321 -0
  164. package/dist/index-96b330da.d.ts +119 -0
  165. package/dist/index-adbd78f1.d.ts +154 -0
  166. package/dist/index.d.ts +67 -8
  167. package/dist/index.js +118 -28
  168. package/dist/index.js.map +1 -1
  169. package/dist/index.mjs +120 -31
  170. package/dist/index.mjs.map +1 -1
  171. package/dist/langserve-0c6100e3.d.ts +257 -0
  172. package/dist/langserve-978d5790.d.ts +243 -0
  173. package/dist/langserve-9fc76ce5.d.ts +243 -0
  174. package/dist/lib/cloud/index.d.ts +6 -0
  175. package/dist/lib/cloud/index.js +18 -0
  176. package/dist/lib/cloud/index.js.map +1 -0
  177. package/dist/lib/cloud/index.mjs +1 -0
  178. package/dist/lib/cloud/index.mjs.map +1 -0
  179. package/dist/lib/index.d.ts +212 -0
  180. package/dist/lib/index.js +7843 -0
  181. package/dist/lib/index.js.map +1 -0
  182. package/dist/lib/index.mjs +76 -0
  183. package/dist/lib/index.mjs.map +1 -0
  184. package/dist/lib/integrations/index.d.ts +34 -0
  185. package/dist/lib/integrations/index.js +3052 -0
  186. package/dist/lib/integrations/index.js.map +1 -0
  187. package/dist/lib/integrations/index.mjs +37 -0
  188. package/dist/lib/integrations/index.mjs.map +1 -0
  189. package/dist/lib/integrations/nest/index.d.ts +15 -0
  190. package/dist/lib/integrations/nest/index.js +2959 -0
  191. package/dist/lib/integrations/nest/index.js.map +1 -0
  192. package/dist/lib/integrations/nest/index.mjs +14 -0
  193. package/dist/lib/integrations/nest/index.mjs.map +1 -0
  194. package/dist/lib/integrations/node-express/index.d.ts +15 -0
  195. package/dist/lib/integrations/node-express/index.js +2959 -0
  196. package/dist/lib/integrations/node-express/index.js.map +1 -0
  197. package/dist/lib/integrations/node-express/index.mjs +14 -0
  198. package/dist/lib/integrations/node-express/index.mjs.map +1 -0
  199. package/dist/lib/integrations/node-http/index.d.ts +15 -0
  200. package/dist/lib/integrations/node-http/index.js +2945 -0
  201. package/dist/lib/integrations/node-http/index.js.map +1 -0
  202. package/dist/lib/integrations/node-http/index.mjs +13 -0
  203. package/dist/lib/integrations/node-http/index.mjs.map +1 -0
  204. package/dist/service-adapters/index.d.ts +162 -0
  205. package/dist/service-adapters/index.js +1787 -0
  206. package/dist/service-adapters/index.js.map +1 -0
  207. package/dist/service-adapters/index.mjs +34 -0
  208. package/dist/service-adapters/index.mjs.map +1 -0
  209. package/dist/service-adapters/shared/index.d.ts +9 -0
  210. package/dist/service-adapters/shared/index.js +72 -0
  211. package/dist/service-adapters/shared/index.js.map +1 -0
  212. package/dist/service-adapters/shared/index.mjs +8 -0
  213. package/dist/service-adapters/shared/index.mjs.map +1 -0
  214. package/dist/shared-0a7346ce.d.ts +466 -0
  215. package/dist/shared-35c6eb04.d.ts +448 -0
  216. package/dist/shared-9ed1dc31.d.ts +414 -0
  217. package/dist/shared-da5708fe.d.ts +449 -0
  218. package/dist/utils/index.d.ts +65 -0
  219. package/dist/utils/index.js +175 -0
  220. package/dist/utils/index.js.map +1 -0
  221. package/dist/utils/index.mjs +12 -0
  222. package/dist/utils/index.mjs.map +1 -0
  223. package/package.json +14 -20
  224. package/src/lib/index.ts +7 -6
  225. package/src/lib/runtime/copilot-runtime.ts +62 -26
  226. package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
@@ -0,0 +1,3100 @@
1
+ import {
2
+ BaseMessageInput
3
+ } from "./chunk-2OZAGFV3.mjs";
4
+ import {
5
+ GuardrailsValidationFailureResponse,
6
+ MessageStreamInterruptedResponse,
7
+ ResponseStatusUnion,
8
+ SuccessResponseStatus,
9
+ UnknownErrorResponse
10
+ } from "./chunk-XWBDEXDA.mjs";
11
+ import {
12
+ aguiToGQL
13
+ } from "./chunk-62NE5S6M.mjs";
14
+ import {
15
+ ActionExecutionMessage,
16
+ ActionInputAvailability,
17
+ AgentStateMessage,
18
+ CopilotRequestType,
19
+ FailedMessageStatus,
20
+ MessageRole,
21
+ MessageStatusUnion,
22
+ ResultMessage,
23
+ SuccessMessageStatus,
24
+ TextMessage
25
+ } from "./chunk-OWIGJONH.mjs";
26
+ import {
27
+ __commonJS,
28
+ __name,
29
+ __toESM
30
+ } from "./chunk-FHD4JECV.mjs";
31
+
32
+ // package.json
33
+ var require_package = __commonJS({
34
+ "package.json"(exports, module) {
35
+ module.exports = {
36
+ name: "@copilotkit/runtime",
37
+ private: false,
38
+ homepage: "https://github.com/CopilotKit/CopilotKit",
39
+ repository: {
40
+ type: "git",
41
+ url: "https://github.com/CopilotKit/CopilotKit.git"
42
+ },
43
+ publishConfig: {
44
+ access: "public"
45
+ },
46
+ version: "1.10.6",
47
+ sideEffects: false,
48
+ main: "./dist/index.js",
49
+ module: "./dist/index.mjs",
50
+ exports: {
51
+ ".": {
52
+ import: "./dist/index.mjs",
53
+ require: "./dist/index.js",
54
+ types: "./dist/index.d.ts"
55
+ },
56
+ "./v2": {
57
+ import: "./dist/v2/index.mjs",
58
+ require: "./dist/v2/index.js",
59
+ types: "./dist/v2/index.d.ts"
60
+ }
61
+ },
62
+ types: "./dist/index.d.ts",
63
+ license: "MIT",
64
+ scripts: {
65
+ build: 'tsup --onSuccess "pnpm run generate-graphql-schema"',
66
+ dev: 'tsup --watch --onSuccess "pnpm run generate-graphql-schema"',
67
+ test: "jest --passWithNoTests",
68
+ "check-types": "tsc --noEmit",
69
+ clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next && rm -rf __snapshots__",
70
+ "generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts",
71
+ "link:global": "pnpm link --global",
72
+ "unlink:global": "pnpm unlink --global"
73
+ },
74
+ devDependencies: {
75
+ "@jest/globals": "^29.7.0",
76
+ "@swc/core": "1.5.28",
77
+ "@types/express": "^4.17.21",
78
+ "@types/jest": "^29.5.12",
79
+ "@types/node": "^18.11.17",
80
+ "@whatwg-node/server": "^0.9.34",
81
+ eslint: "^8.56.0",
82
+ "eslint-config-custom": "workspace:*",
83
+ jest: "^29.6.4",
84
+ nodemon: "^3.1.3",
85
+ "ts-jest": "^29.1.1",
86
+ "ts-node": "^10.9.2",
87
+ tsconfig: "workspace:*",
88
+ tsup: "^6.7.0",
89
+ typescript: "^5.2.3",
90
+ vitest: "^3.2.4",
91
+ "zod-to-json-schema": "^3.23.5"
92
+ },
93
+ dependencies: {
94
+ "@anthropic-ai/sdk": "^0.57.0",
95
+ "@copilotkit/shared": "workspace:*",
96
+ "@copilotkitnext/agent": "0.0.22-alpha.8",
97
+ "@copilotkitnext/runtime": "0.0.22-alpha.8",
98
+ "@graphql-yoga/plugin-defer-stream": "^3.3.1",
99
+ "@langchain/aws": "^0.1.9",
100
+ "@langchain/community": "^0.3.29",
101
+ "@langchain/core": "^0.3.38",
102
+ "@langchain/google-gauth": "^0.1.0",
103
+ "@langchain/langgraph-sdk": "^0.0.70",
104
+ "@langchain/openai": "^0.4.2",
105
+ "@scarf/scarf": "^1.3.0",
106
+ "class-transformer": "^0.5.1",
107
+ "class-validator": "^0.14.1",
108
+ graphql: "^16.8.1",
109
+ "graphql-scalars": "^1.23.0",
110
+ "graphql-yoga": "^5.3.1",
111
+ "groq-sdk": "^0.5.0",
112
+ hono: "^4.10.3",
113
+ langchain: "^0.3.3",
114
+ openai: "^4.85.1",
115
+ "partial-json": "^0.1.7",
116
+ pino: "^9.2.0",
117
+ "pino-pretty": "^11.2.1",
118
+ "reflect-metadata": "^0.2.2",
119
+ rxjs: "7.8.1",
120
+ "type-graphql": "2.0.0-rc.1",
121
+ zod: "^3.23.3"
122
+ },
123
+ peerDependencies: {
124
+ "@ag-ui/client": ">=0.0.39",
125
+ "@ag-ui/core": ">=0.0.39",
126
+ "@ag-ui/encoder": ">=0.0.39",
127
+ "@ag-ui/langgraph": ">=0.0.18",
128
+ "@ag-ui/proto": ">=0.0.39",
129
+ express: "^4.19.2"
130
+ },
131
+ peerDependenciesMeta: {
132
+ express: { optional: true }
133
+ },
134
+ keywords: [
135
+ "copilotkit",
136
+ "copilot",
137
+ "react",
138
+ "nextjs",
139
+ "nodejs",
140
+ "ai",
141
+ "assistant",
142
+ "javascript",
143
+ "automation",
144
+ "textarea"
145
+ ]
146
+ };
147
+ }
148
+ });
149
+
150
+ // src/lib/integrations/shared.ts
151
+ import { buildSchemaSync } from "type-graphql";
152
+
153
+ // src/graphql/resolvers/copilot.resolver.ts
154
+ import { Arg, Ctx, Mutation, Query, Resolver } from "type-graphql";
155
+ import { ReplaySubject as ReplaySubject2, Subject, filter, finalize, firstValueFrom, shareReplay, skipWhile, take, takeWhile, tap } from "rxjs";
156
+
157
+ // src/graphql/inputs/generate-copilot-response.input.ts
158
+ import { Field as Field15, InputType as InputType12 } from "type-graphql";
159
+
160
+ // src/graphql/inputs/message.input.ts
161
+ import { Field, InputType } from "type-graphql";
162
+ function _ts_decorate(decorators, target, key, desc) {
163
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
164
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
165
+ r = Reflect.decorate(decorators, target, key, desc);
166
+ else
167
+ for (var i = decorators.length - 1; i >= 0; i--)
168
+ if (d = decorators[i])
169
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
170
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
171
+ }
172
+ __name(_ts_decorate, "_ts_decorate");
173
+ function _ts_metadata(k, v) {
174
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
175
+ return Reflect.metadata(k, v);
176
+ }
177
+ __name(_ts_metadata, "_ts_metadata");
178
+ var MessageInput = class extends BaseMessageInput {
179
+ textMessage;
180
+ actionExecutionMessage;
181
+ resultMessage;
182
+ agentStateMessage;
183
+ imageMessage;
184
+ };
185
+ __name(MessageInput, "MessageInput");
186
+ _ts_decorate([
187
+ Field(() => TextMessageInput, {
188
+ nullable: true
189
+ }),
190
+ _ts_metadata("design:type", typeof TextMessageInput === "undefined" ? Object : TextMessageInput)
191
+ ], MessageInput.prototype, "textMessage", void 0);
192
+ _ts_decorate([
193
+ Field(() => ActionExecutionMessageInput, {
194
+ nullable: true
195
+ }),
196
+ _ts_metadata("design:type", typeof ActionExecutionMessageInput === "undefined" ? Object : ActionExecutionMessageInput)
197
+ ], MessageInput.prototype, "actionExecutionMessage", void 0);
198
+ _ts_decorate([
199
+ Field(() => ResultMessageInput, {
200
+ nullable: true
201
+ }),
202
+ _ts_metadata("design:type", typeof ResultMessageInput === "undefined" ? Object : ResultMessageInput)
203
+ ], MessageInput.prototype, "resultMessage", void 0);
204
+ _ts_decorate([
205
+ Field(() => AgentStateMessageInput, {
206
+ nullable: true
207
+ }),
208
+ _ts_metadata("design:type", typeof AgentStateMessageInput === "undefined" ? Object : AgentStateMessageInput)
209
+ ], MessageInput.prototype, "agentStateMessage", void 0);
210
+ _ts_decorate([
211
+ Field(() => ImageMessageInput, {
212
+ nullable: true
213
+ }),
214
+ _ts_metadata("design:type", typeof ImageMessageInput === "undefined" ? Object : ImageMessageInput)
215
+ ], MessageInput.prototype, "imageMessage", void 0);
216
+ MessageInput = _ts_decorate([
217
+ InputType()
218
+ ], MessageInput);
219
+ var TextMessageInput = class {
220
+ content;
221
+ parentMessageId;
222
+ role;
223
+ };
224
+ __name(TextMessageInput, "TextMessageInput");
225
+ _ts_decorate([
226
+ Field(() => String),
227
+ _ts_metadata("design:type", String)
228
+ ], TextMessageInput.prototype, "content", void 0);
229
+ _ts_decorate([
230
+ Field(() => String, {
231
+ nullable: true
232
+ }),
233
+ _ts_metadata("design:type", String)
234
+ ], TextMessageInput.prototype, "parentMessageId", void 0);
235
+ _ts_decorate([
236
+ Field(() => MessageRole),
237
+ _ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
238
+ ], TextMessageInput.prototype, "role", void 0);
239
+ TextMessageInput = _ts_decorate([
240
+ InputType()
241
+ ], TextMessageInput);
242
+ var ActionExecutionMessageInput = class {
243
+ name;
244
+ arguments;
245
+ parentMessageId;
246
+ scope;
247
+ };
248
+ __name(ActionExecutionMessageInput, "ActionExecutionMessageInput");
249
+ _ts_decorate([
250
+ Field(() => String),
251
+ _ts_metadata("design:type", String)
252
+ ], ActionExecutionMessageInput.prototype, "name", void 0);
253
+ _ts_decorate([
254
+ Field(() => String),
255
+ _ts_metadata("design:type", String)
256
+ ], ActionExecutionMessageInput.prototype, "arguments", void 0);
257
+ _ts_decorate([
258
+ Field(() => String, {
259
+ nullable: true
260
+ }),
261
+ _ts_metadata("design:type", String)
262
+ ], ActionExecutionMessageInput.prototype, "parentMessageId", void 0);
263
+ _ts_decorate([
264
+ Field(() => String, {
265
+ nullable: true,
266
+ deprecationReason: "This field will be removed in a future version"
267
+ }),
268
+ _ts_metadata("design:type", typeof String === "undefined" ? Object : String)
269
+ ], ActionExecutionMessageInput.prototype, "scope", void 0);
270
+ ActionExecutionMessageInput = _ts_decorate([
271
+ InputType()
272
+ ], ActionExecutionMessageInput);
273
+ var ResultMessageInput = class {
274
+ actionExecutionId;
275
+ actionName;
276
+ parentMessageId;
277
+ result;
278
+ };
279
+ __name(ResultMessageInput, "ResultMessageInput");
280
+ _ts_decorate([
281
+ Field(() => String),
282
+ _ts_metadata("design:type", String)
283
+ ], ResultMessageInput.prototype, "actionExecutionId", void 0);
284
+ _ts_decorate([
285
+ Field(() => String),
286
+ _ts_metadata("design:type", String)
287
+ ], ResultMessageInput.prototype, "actionName", void 0);
288
+ _ts_decorate([
289
+ Field(() => String, {
290
+ nullable: true
291
+ }),
292
+ _ts_metadata("design:type", String)
293
+ ], ResultMessageInput.prototype, "parentMessageId", void 0);
294
+ _ts_decorate([
295
+ Field(() => String),
296
+ _ts_metadata("design:type", String)
297
+ ], ResultMessageInput.prototype, "result", void 0);
298
+ ResultMessageInput = _ts_decorate([
299
+ InputType()
300
+ ], ResultMessageInput);
301
+ var AgentStateMessageInput = class {
302
+ threadId;
303
+ agentName;
304
+ role;
305
+ state;
306
+ running;
307
+ nodeName;
308
+ runId;
309
+ active;
310
+ };
311
+ __name(AgentStateMessageInput, "AgentStateMessageInput");
312
+ _ts_decorate([
313
+ Field(() => String),
314
+ _ts_metadata("design:type", String)
315
+ ], AgentStateMessageInput.prototype, "threadId", void 0);
316
+ _ts_decorate([
317
+ Field(() => String),
318
+ _ts_metadata("design:type", String)
319
+ ], AgentStateMessageInput.prototype, "agentName", void 0);
320
+ _ts_decorate([
321
+ Field(() => MessageRole),
322
+ _ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
323
+ ], AgentStateMessageInput.prototype, "role", void 0);
324
+ _ts_decorate([
325
+ Field(() => String),
326
+ _ts_metadata("design:type", String)
327
+ ], AgentStateMessageInput.prototype, "state", void 0);
328
+ _ts_decorate([
329
+ Field(() => Boolean),
330
+ _ts_metadata("design:type", Boolean)
331
+ ], AgentStateMessageInput.prototype, "running", void 0);
332
+ _ts_decorate([
333
+ Field(() => String),
334
+ _ts_metadata("design:type", String)
335
+ ], AgentStateMessageInput.prototype, "nodeName", void 0);
336
+ _ts_decorate([
337
+ Field(() => String),
338
+ _ts_metadata("design:type", String)
339
+ ], AgentStateMessageInput.prototype, "runId", void 0);
340
+ _ts_decorate([
341
+ Field(() => Boolean),
342
+ _ts_metadata("design:type", Boolean)
343
+ ], AgentStateMessageInput.prototype, "active", void 0);
344
+ AgentStateMessageInput = _ts_decorate([
345
+ InputType()
346
+ ], AgentStateMessageInput);
347
+ var ImageMessageInput = class {
348
+ format;
349
+ bytes;
350
+ parentMessageId;
351
+ role;
352
+ };
353
+ __name(ImageMessageInput, "ImageMessageInput");
354
+ _ts_decorate([
355
+ Field(() => String),
356
+ _ts_metadata("design:type", String)
357
+ ], ImageMessageInput.prototype, "format", void 0);
358
+ _ts_decorate([
359
+ Field(() => String),
360
+ _ts_metadata("design:type", String)
361
+ ], ImageMessageInput.prototype, "bytes", void 0);
362
+ _ts_decorate([
363
+ Field(() => String, {
364
+ nullable: true
365
+ }),
366
+ _ts_metadata("design:type", String)
367
+ ], ImageMessageInput.prototype, "parentMessageId", void 0);
368
+ _ts_decorate([
369
+ Field(() => MessageRole),
370
+ _ts_metadata("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
371
+ ], ImageMessageInput.prototype, "role", void 0);
372
+ ImageMessageInput = _ts_decorate([
373
+ InputType()
374
+ ], ImageMessageInput);
375
+
376
+ // src/graphql/inputs/frontend.input.ts
377
+ import { Field as Field3, InputType as InputType3 } from "type-graphql";
378
+
379
+ // src/graphql/inputs/action.input.ts
380
+ import { Field as Field2, InputType as InputType2 } from "type-graphql";
381
+ function _ts_decorate2(decorators, target, key, desc) {
382
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
383
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
384
+ r = Reflect.decorate(decorators, target, key, desc);
385
+ else
386
+ for (var i = decorators.length - 1; i >= 0; i--)
387
+ if (d = decorators[i])
388
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
389
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
390
+ }
391
+ __name(_ts_decorate2, "_ts_decorate");
392
+ function _ts_metadata2(k, v) {
393
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
394
+ return Reflect.metadata(k, v);
395
+ }
396
+ __name(_ts_metadata2, "_ts_metadata");
397
+ var ActionInput = class {
398
+ name;
399
+ description;
400
+ jsonSchema;
401
+ available;
402
+ };
403
+ __name(ActionInput, "ActionInput");
404
+ _ts_decorate2([
405
+ Field2(() => String),
406
+ _ts_metadata2("design:type", String)
407
+ ], ActionInput.prototype, "name", void 0);
408
+ _ts_decorate2([
409
+ Field2(() => String),
410
+ _ts_metadata2("design:type", String)
411
+ ], ActionInput.prototype, "description", void 0);
412
+ _ts_decorate2([
413
+ Field2(() => String),
414
+ _ts_metadata2("design:type", String)
415
+ ], ActionInput.prototype, "jsonSchema", void 0);
416
+ _ts_decorate2([
417
+ Field2(() => ActionInputAvailability, {
418
+ nullable: true
419
+ }),
420
+ _ts_metadata2("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
421
+ ], ActionInput.prototype, "available", void 0);
422
+ ActionInput = _ts_decorate2([
423
+ InputType2()
424
+ ], ActionInput);
425
+
426
+ // src/graphql/inputs/frontend.input.ts
427
+ function _ts_decorate3(decorators, target, key, desc) {
428
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
429
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
430
+ r = Reflect.decorate(decorators, target, key, desc);
431
+ else
432
+ for (var i = decorators.length - 1; i >= 0; i--)
433
+ if (d = decorators[i])
434
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
435
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
436
+ }
437
+ __name(_ts_decorate3, "_ts_decorate");
438
+ function _ts_metadata3(k, v) {
439
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
440
+ return Reflect.metadata(k, v);
441
+ }
442
+ __name(_ts_metadata3, "_ts_metadata");
443
+ var FrontendInput = class {
444
+ toDeprecate_fullContext;
445
+ actions;
446
+ url;
447
+ };
448
+ __name(FrontendInput, "FrontendInput");
449
+ _ts_decorate3([
450
+ Field3(() => String, {
451
+ nullable: true
452
+ }),
453
+ _ts_metadata3("design:type", String)
454
+ ], FrontendInput.prototype, "toDeprecate_fullContext", void 0);
455
+ _ts_decorate3([
456
+ Field3(() => [
457
+ ActionInput
458
+ ]),
459
+ _ts_metadata3("design:type", Array)
460
+ ], FrontendInput.prototype, "actions", void 0);
461
+ _ts_decorate3([
462
+ Field3(() => String, {
463
+ nullable: true
464
+ }),
465
+ _ts_metadata3("design:type", String)
466
+ ], FrontendInput.prototype, "url", void 0);
467
+ FrontendInput = _ts_decorate3([
468
+ InputType3()
469
+ ], FrontendInput);
470
+
471
+ // src/graphql/inputs/cloud.input.ts
472
+ import { Field as Field5, InputType as InputType5 } from "type-graphql";
473
+
474
+ // src/graphql/inputs/cloud-guardrails.input.ts
475
+ import { Field as Field4, InputType as InputType4 } from "type-graphql";
476
+ function _ts_decorate4(decorators, target, key, desc) {
477
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
478
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
479
+ r = Reflect.decorate(decorators, target, key, desc);
480
+ else
481
+ for (var i = decorators.length - 1; i >= 0; i--)
482
+ if (d = decorators[i])
483
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
484
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
485
+ }
486
+ __name(_ts_decorate4, "_ts_decorate");
487
+ function _ts_metadata4(k, v) {
488
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
489
+ return Reflect.metadata(k, v);
490
+ }
491
+ __name(_ts_metadata4, "_ts_metadata");
492
+ var GuardrailsRuleInput = class {
493
+ allowList = [];
494
+ denyList = [];
495
+ };
496
+ __name(GuardrailsRuleInput, "GuardrailsRuleInput");
497
+ _ts_decorate4([
498
+ Field4(() => [
499
+ String
500
+ ], {
501
+ nullable: true
502
+ }),
503
+ _ts_metadata4("design:type", Array)
504
+ ], GuardrailsRuleInput.prototype, "allowList", void 0);
505
+ _ts_decorate4([
506
+ Field4(() => [
507
+ String
508
+ ], {
509
+ nullable: true
510
+ }),
511
+ _ts_metadata4("design:type", Array)
512
+ ], GuardrailsRuleInput.prototype, "denyList", void 0);
513
+ GuardrailsRuleInput = _ts_decorate4([
514
+ InputType4()
515
+ ], GuardrailsRuleInput);
516
+ var GuardrailsInput = class {
517
+ inputValidationRules;
518
+ };
519
+ __name(GuardrailsInput, "GuardrailsInput");
520
+ _ts_decorate4([
521
+ Field4(() => GuardrailsRuleInput, {
522
+ nullable: false
523
+ }),
524
+ _ts_metadata4("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
525
+ ], GuardrailsInput.prototype, "inputValidationRules", void 0);
526
+ GuardrailsInput = _ts_decorate4([
527
+ InputType4()
528
+ ], GuardrailsInput);
529
+
530
+ // src/graphql/inputs/cloud.input.ts
531
+ function _ts_decorate5(decorators, target, key, desc) {
532
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
533
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
534
+ r = Reflect.decorate(decorators, target, key, desc);
535
+ else
536
+ for (var i = decorators.length - 1; i >= 0; i--)
537
+ if (d = decorators[i])
538
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
539
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
540
+ }
541
+ __name(_ts_decorate5, "_ts_decorate");
542
+ function _ts_metadata5(k, v) {
543
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
544
+ return Reflect.metadata(k, v);
545
+ }
546
+ __name(_ts_metadata5, "_ts_metadata");
547
+ var CloudInput = class {
548
+ guardrails;
549
+ };
550
+ __name(CloudInput, "CloudInput");
551
+ _ts_decorate5([
552
+ Field5(() => GuardrailsInput, {
553
+ nullable: true
554
+ }),
555
+ _ts_metadata5("design:type", typeof GuardrailsInput === "undefined" ? Object : GuardrailsInput)
556
+ ], CloudInput.prototype, "guardrails", void 0);
557
+ CloudInput = _ts_decorate5([
558
+ InputType5()
559
+ ], CloudInput);
560
+
561
+ // src/graphql/inputs/forwarded-parameters.input.ts
562
+ import { Field as Field6, InputType as InputType6 } from "type-graphql";
563
+ function _ts_decorate6(decorators, target, key, desc) {
564
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
565
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
566
+ r = Reflect.decorate(decorators, target, key, desc);
567
+ else
568
+ for (var i = decorators.length - 1; i >= 0; i--)
569
+ if (d = decorators[i])
570
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
571
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
572
+ }
573
+ __name(_ts_decorate6, "_ts_decorate");
574
+ function _ts_metadata6(k, v) {
575
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
576
+ return Reflect.metadata(k, v);
577
+ }
578
+ __name(_ts_metadata6, "_ts_metadata");
579
+ var ForwardedParametersInput = class {
580
+ model;
581
+ maxTokens;
582
+ stop;
583
+ toolChoice;
584
+ toolChoiceFunctionName;
585
+ temperature;
586
+ };
587
+ __name(ForwardedParametersInput, "ForwardedParametersInput");
588
+ _ts_decorate6([
589
+ Field6(() => String, {
590
+ nullable: true
591
+ }),
592
+ _ts_metadata6("design:type", String)
593
+ ], ForwardedParametersInput.prototype, "model", void 0);
594
+ _ts_decorate6([
595
+ Field6(() => Number, {
596
+ nullable: true
597
+ }),
598
+ _ts_metadata6("design:type", Number)
599
+ ], ForwardedParametersInput.prototype, "maxTokens", void 0);
600
+ _ts_decorate6([
601
+ Field6(() => [
602
+ String
603
+ ], {
604
+ nullable: true
605
+ }),
606
+ _ts_metadata6("design:type", Array)
607
+ ], ForwardedParametersInput.prototype, "stop", void 0);
608
+ _ts_decorate6([
609
+ Field6(() => String, {
610
+ nullable: true
611
+ }),
612
+ _ts_metadata6("design:type", typeof String === "undefined" ? Object : String)
613
+ ], ForwardedParametersInput.prototype, "toolChoice", void 0);
614
+ _ts_decorate6([
615
+ Field6(() => String, {
616
+ nullable: true
617
+ }),
618
+ _ts_metadata6("design:type", String)
619
+ ], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
620
+ _ts_decorate6([
621
+ Field6(() => Number, {
622
+ nullable: true
623
+ }),
624
+ _ts_metadata6("design:type", Number)
625
+ ], ForwardedParametersInput.prototype, "temperature", void 0);
626
+ ForwardedParametersInput = _ts_decorate6([
627
+ InputType6()
628
+ ], ForwardedParametersInput);
629
+
630
+ // src/graphql/inputs/agent-session.input.ts
631
+ import { Field as Field7, InputType as InputType7 } from "type-graphql";
632
+ function _ts_decorate7(decorators, target, key, desc) {
633
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
634
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
635
+ r = Reflect.decorate(decorators, target, key, desc);
636
+ else
637
+ for (var i = decorators.length - 1; i >= 0; i--)
638
+ if (d = decorators[i])
639
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
640
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
641
+ }
642
+ __name(_ts_decorate7, "_ts_decorate");
643
+ function _ts_metadata7(k, v) {
644
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
645
+ return Reflect.metadata(k, v);
646
+ }
647
+ __name(_ts_metadata7, "_ts_metadata");
648
+ var AgentSessionInput = class {
649
+ agentName;
650
+ threadId;
651
+ nodeName;
652
+ };
653
+ __name(AgentSessionInput, "AgentSessionInput");
654
+ _ts_decorate7([
655
+ Field7(() => String),
656
+ _ts_metadata7("design:type", String)
657
+ ], AgentSessionInput.prototype, "agentName", void 0);
658
+ _ts_decorate7([
659
+ Field7(() => String, {
660
+ nullable: true
661
+ }),
662
+ _ts_metadata7("design:type", String)
663
+ ], AgentSessionInput.prototype, "threadId", void 0);
664
+ _ts_decorate7([
665
+ Field7(() => String, {
666
+ nullable: true
667
+ }),
668
+ _ts_metadata7("design:type", String)
669
+ ], AgentSessionInput.prototype, "nodeName", void 0);
670
+ AgentSessionInput = _ts_decorate7([
671
+ InputType7()
672
+ ], AgentSessionInput);
673
+
674
+ // src/graphql/inputs/agent-state.input.ts
675
+ import { Field as Field8, InputType as InputType8 } from "type-graphql";
676
+ function _ts_decorate8(decorators, target, key, desc) {
677
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
678
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
679
+ r = Reflect.decorate(decorators, target, key, desc);
680
+ else
681
+ for (var i = decorators.length - 1; i >= 0; i--)
682
+ if (d = decorators[i])
683
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
684
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
685
+ }
686
+ __name(_ts_decorate8, "_ts_decorate");
687
+ function _ts_metadata8(k, v) {
688
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
689
+ return Reflect.metadata(k, v);
690
+ }
691
+ __name(_ts_metadata8, "_ts_metadata");
692
+ var AgentStateInput = class {
693
+ agentName;
694
+ state;
695
+ config;
696
+ };
697
+ __name(AgentStateInput, "AgentStateInput");
698
+ _ts_decorate8([
699
+ Field8(() => String),
700
+ _ts_metadata8("design:type", String)
701
+ ], AgentStateInput.prototype, "agentName", void 0);
702
+ _ts_decorate8([
703
+ Field8(() => String),
704
+ _ts_metadata8("design:type", String)
705
+ ], AgentStateInput.prototype, "state", void 0);
706
+ _ts_decorate8([
707
+ Field8(() => String, {
708
+ nullable: true
709
+ }),
710
+ _ts_metadata8("design:type", String)
711
+ ], AgentStateInput.prototype, "config", void 0);
712
+ AgentStateInput = _ts_decorate8([
713
+ InputType8()
714
+ ], AgentStateInput);
715
+
716
+ // src/graphql/inputs/extensions.input.ts
717
+ import { Field as Field9, InputType as InputType9 } from "type-graphql";
718
+ function _ts_decorate9(decorators, target, key, desc) {
719
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
720
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
721
+ r = Reflect.decorate(decorators, target, key, desc);
722
+ else
723
+ for (var i = decorators.length - 1; i >= 0; i--)
724
+ if (d = decorators[i])
725
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
726
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
727
+ }
728
+ __name(_ts_decorate9, "_ts_decorate");
729
+ function _ts_metadata9(k, v) {
730
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
731
+ return Reflect.metadata(k, v);
732
+ }
733
+ __name(_ts_metadata9, "_ts_metadata");
734
+ var ExtensionsInput = class {
735
+ openaiAssistantAPI;
736
+ };
737
+ __name(ExtensionsInput, "ExtensionsInput");
738
+ _ts_decorate9([
739
+ Field9(() => OpenAIApiAssistantAPIInput, {
740
+ nullable: true
741
+ }),
742
+ _ts_metadata9("design:type", typeof OpenAIApiAssistantAPIInput === "undefined" ? Object : OpenAIApiAssistantAPIInput)
743
+ ], ExtensionsInput.prototype, "openaiAssistantAPI", void 0);
744
+ ExtensionsInput = _ts_decorate9([
745
+ InputType9()
746
+ ], ExtensionsInput);
747
+ var OpenAIApiAssistantAPIInput = class {
748
+ runId;
749
+ threadId;
750
+ };
751
+ __name(OpenAIApiAssistantAPIInput, "OpenAIApiAssistantAPIInput");
752
+ _ts_decorate9([
753
+ Field9(() => String, {
754
+ nullable: true
755
+ }),
756
+ _ts_metadata9("design:type", String)
757
+ ], OpenAIApiAssistantAPIInput.prototype, "runId", void 0);
758
+ _ts_decorate9([
759
+ Field9(() => String, {
760
+ nullable: true
761
+ }),
762
+ _ts_metadata9("design:type", String)
763
+ ], OpenAIApiAssistantAPIInput.prototype, "threadId", void 0);
764
+ OpenAIApiAssistantAPIInput = _ts_decorate9([
765
+ InputType9()
766
+ ], OpenAIApiAssistantAPIInput);
767
+
768
+ // src/graphql/inputs/meta-event.input.ts
769
+ import { Field as Field13, InputType as InputType10 } from "type-graphql";
770
+
771
+ // src/graphql/types/meta-events.type.ts
772
+ import { Field as Field12, InterfaceType as InterfaceType2, ObjectType as ObjectType3, registerEnumType } from "type-graphql";
773
+
774
+ // src/graphql/types/copilot-response.type.ts
775
+ import { Field as Field11, InterfaceType, ObjectType as ObjectType2 } from "type-graphql";
776
+
777
+ // src/graphql/types/extensions-response.type.ts
778
+ import { Field as Field10, ObjectType } from "type-graphql";
779
+ function _ts_decorate10(decorators, target, key, desc) {
780
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
781
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
782
+ r = Reflect.decorate(decorators, target, key, desc);
783
+ else
784
+ for (var i = decorators.length - 1; i >= 0; i--)
785
+ if (d = decorators[i])
786
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
787
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
788
+ }
789
+ __name(_ts_decorate10, "_ts_decorate");
790
+ function _ts_metadata10(k, v) {
791
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
792
+ return Reflect.metadata(k, v);
793
+ }
794
+ __name(_ts_metadata10, "_ts_metadata");
795
+ var ExtensionsResponse = class {
796
+ openaiAssistantAPI;
797
+ };
798
+ __name(ExtensionsResponse, "ExtensionsResponse");
799
+ _ts_decorate10([
800
+ Field10(() => OpenAIApiAssistantAPIResponse, {
801
+ nullable: true
802
+ }),
803
+ _ts_metadata10("design:type", typeof OpenAIApiAssistantAPIResponse === "undefined" ? Object : OpenAIApiAssistantAPIResponse)
804
+ ], ExtensionsResponse.prototype, "openaiAssistantAPI", void 0);
805
+ ExtensionsResponse = _ts_decorate10([
806
+ ObjectType()
807
+ ], ExtensionsResponse);
808
+ var OpenAIApiAssistantAPIResponse = class {
809
+ runId;
810
+ threadId;
811
+ };
812
+ __name(OpenAIApiAssistantAPIResponse, "OpenAIApiAssistantAPIResponse");
813
+ _ts_decorate10([
814
+ Field10(() => String, {
815
+ nullable: true
816
+ }),
817
+ _ts_metadata10("design:type", String)
818
+ ], OpenAIApiAssistantAPIResponse.prototype, "runId", void 0);
819
+ _ts_decorate10([
820
+ Field10(() => String, {
821
+ nullable: true
822
+ }),
823
+ _ts_metadata10("design:type", String)
824
+ ], OpenAIApiAssistantAPIResponse.prototype, "threadId", void 0);
825
+ OpenAIApiAssistantAPIResponse = _ts_decorate10([
826
+ ObjectType()
827
+ ], OpenAIApiAssistantAPIResponse);
828
+
829
+ // src/graphql/types/copilot-response.type.ts
830
+ function _ts_decorate11(decorators, target, key, desc) {
831
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
832
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
833
+ r = Reflect.decorate(decorators, target, key, desc);
834
+ else
835
+ for (var i = decorators.length - 1; i >= 0; i--)
836
+ if (d = decorators[i])
837
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
838
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
839
+ }
840
+ __name(_ts_decorate11, "_ts_decorate");
841
+ function _ts_metadata11(k, v) {
842
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
843
+ return Reflect.metadata(k, v);
844
+ }
845
+ __name(_ts_metadata11, "_ts_metadata");
846
+ var BaseMessageOutput = class {
847
+ id;
848
+ createdAt;
849
+ status;
850
+ };
851
+ __name(BaseMessageOutput, "BaseMessageOutput");
852
+ _ts_decorate11([
853
+ Field11(() => String),
854
+ _ts_metadata11("design:type", String)
855
+ ], BaseMessageOutput.prototype, "id", void 0);
856
+ _ts_decorate11([
857
+ Field11(() => Date),
858
+ _ts_metadata11("design:type", typeof Date === "undefined" ? Object : Date)
859
+ ], BaseMessageOutput.prototype, "createdAt", void 0);
860
+ _ts_decorate11([
861
+ Field11(() => MessageStatusUnion),
862
+ _ts_metadata11("design:type", Object)
863
+ ], BaseMessageOutput.prototype, "status", void 0);
864
+ BaseMessageOutput = _ts_decorate11([
865
+ InterfaceType({
866
+ resolveType(value) {
867
+ if (value.hasOwnProperty("content")) {
868
+ return TextMessageOutput;
869
+ } else if (value.hasOwnProperty("name")) {
870
+ return ActionExecutionMessageOutput;
871
+ } else if (value.hasOwnProperty("result")) {
872
+ return ResultMessageOutput;
873
+ } else if (value.hasOwnProperty("state")) {
874
+ return AgentStateMessageOutput;
875
+ } else if (value.hasOwnProperty("format") && value.hasOwnProperty("bytes")) {
876
+ return ImageMessageOutput;
877
+ }
878
+ return void 0;
879
+ }
880
+ })
881
+ ], BaseMessageOutput);
882
+ var TextMessageOutput = class {
883
+ role;
884
+ content;
885
+ parentMessageId;
886
+ };
887
+ __name(TextMessageOutput, "TextMessageOutput");
888
+ _ts_decorate11([
889
+ Field11(() => MessageRole),
890
+ _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
891
+ ], TextMessageOutput.prototype, "role", void 0);
892
+ _ts_decorate11([
893
+ Field11(() => [
894
+ String
895
+ ]),
896
+ _ts_metadata11("design:type", Array)
897
+ ], TextMessageOutput.prototype, "content", void 0);
898
+ _ts_decorate11([
899
+ Field11(() => String, {
900
+ nullable: true
901
+ }),
902
+ _ts_metadata11("design:type", String)
903
+ ], TextMessageOutput.prototype, "parentMessageId", void 0);
904
+ TextMessageOutput = _ts_decorate11([
905
+ ObjectType2({
906
+ implements: BaseMessageOutput
907
+ })
908
+ ], TextMessageOutput);
909
+ var ActionExecutionMessageOutput = class {
910
+ name;
911
+ scope;
912
+ arguments;
913
+ parentMessageId;
914
+ };
915
+ __name(ActionExecutionMessageOutput, "ActionExecutionMessageOutput");
916
+ _ts_decorate11([
917
+ Field11(() => String),
918
+ _ts_metadata11("design:type", String)
919
+ ], ActionExecutionMessageOutput.prototype, "name", void 0);
920
+ _ts_decorate11([
921
+ Field11(() => String, {
922
+ nullable: true,
923
+ deprecationReason: "This field will be removed in a future version"
924
+ }),
925
+ _ts_metadata11("design:type", String)
926
+ ], ActionExecutionMessageOutput.prototype, "scope", void 0);
927
+ _ts_decorate11([
928
+ Field11(() => [
929
+ String
930
+ ]),
931
+ _ts_metadata11("design:type", Array)
932
+ ], ActionExecutionMessageOutput.prototype, "arguments", void 0);
933
+ _ts_decorate11([
934
+ Field11(() => String, {
935
+ nullable: true
936
+ }),
937
+ _ts_metadata11("design:type", String)
938
+ ], ActionExecutionMessageOutput.prototype, "parentMessageId", void 0);
939
+ ActionExecutionMessageOutput = _ts_decorate11([
940
+ ObjectType2({
941
+ implements: BaseMessageOutput
942
+ })
943
+ ], ActionExecutionMessageOutput);
944
+ var ResultMessageOutput = class {
945
+ actionExecutionId;
946
+ actionName;
947
+ result;
948
+ };
949
+ __name(ResultMessageOutput, "ResultMessageOutput");
950
+ _ts_decorate11([
951
+ Field11(() => String),
952
+ _ts_metadata11("design:type", String)
953
+ ], ResultMessageOutput.prototype, "actionExecutionId", void 0);
954
+ _ts_decorate11([
955
+ Field11(() => String),
956
+ _ts_metadata11("design:type", String)
957
+ ], ResultMessageOutput.prototype, "actionName", void 0);
958
+ _ts_decorate11([
959
+ Field11(() => String),
960
+ _ts_metadata11("design:type", String)
961
+ ], ResultMessageOutput.prototype, "result", void 0);
962
+ ResultMessageOutput = _ts_decorate11([
963
+ ObjectType2({
964
+ implements: BaseMessageOutput
965
+ })
966
+ ], ResultMessageOutput);
967
+ var AgentStateMessageOutput = class {
968
+ threadId;
969
+ agentName;
970
+ nodeName;
971
+ runId;
972
+ active;
973
+ role;
974
+ state;
975
+ running;
976
+ };
977
+ __name(AgentStateMessageOutput, "AgentStateMessageOutput");
978
+ _ts_decorate11([
979
+ Field11(() => String),
980
+ _ts_metadata11("design:type", String)
981
+ ], AgentStateMessageOutput.prototype, "threadId", void 0);
982
+ _ts_decorate11([
983
+ Field11(() => String),
984
+ _ts_metadata11("design:type", String)
985
+ ], AgentStateMessageOutput.prototype, "agentName", void 0);
986
+ _ts_decorate11([
987
+ Field11(() => String),
988
+ _ts_metadata11("design:type", String)
989
+ ], AgentStateMessageOutput.prototype, "nodeName", void 0);
990
+ _ts_decorate11([
991
+ Field11(() => String),
992
+ _ts_metadata11("design:type", String)
993
+ ], AgentStateMessageOutput.prototype, "runId", void 0);
994
+ _ts_decorate11([
995
+ Field11(() => Boolean),
996
+ _ts_metadata11("design:type", Boolean)
997
+ ], AgentStateMessageOutput.prototype, "active", void 0);
998
+ _ts_decorate11([
999
+ Field11(() => MessageRole),
1000
+ _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1001
+ ], AgentStateMessageOutput.prototype, "role", void 0);
1002
+ _ts_decorate11([
1003
+ Field11(() => String),
1004
+ _ts_metadata11("design:type", String)
1005
+ ], AgentStateMessageOutput.prototype, "state", void 0);
1006
+ _ts_decorate11([
1007
+ Field11(() => Boolean),
1008
+ _ts_metadata11("design:type", Boolean)
1009
+ ], AgentStateMessageOutput.prototype, "running", void 0);
1010
+ AgentStateMessageOutput = _ts_decorate11([
1011
+ ObjectType2({
1012
+ implements: BaseMessageOutput
1013
+ })
1014
+ ], AgentStateMessageOutput);
1015
+ var ImageMessageOutput = class {
1016
+ format;
1017
+ bytes;
1018
+ role;
1019
+ parentMessageId;
1020
+ };
1021
+ __name(ImageMessageOutput, "ImageMessageOutput");
1022
+ _ts_decorate11([
1023
+ Field11(() => String),
1024
+ _ts_metadata11("design:type", String)
1025
+ ], ImageMessageOutput.prototype, "format", void 0);
1026
+ _ts_decorate11([
1027
+ Field11(() => String),
1028
+ _ts_metadata11("design:type", String)
1029
+ ], ImageMessageOutput.prototype, "bytes", void 0);
1030
+ _ts_decorate11([
1031
+ Field11(() => MessageRole),
1032
+ _ts_metadata11("design:type", typeof MessageRole === "undefined" ? Object : MessageRole)
1033
+ ], ImageMessageOutput.prototype, "role", void 0);
1034
+ _ts_decorate11([
1035
+ Field11(() => String, {
1036
+ nullable: true
1037
+ }),
1038
+ _ts_metadata11("design:type", String)
1039
+ ], ImageMessageOutput.prototype, "parentMessageId", void 0);
1040
+ ImageMessageOutput = _ts_decorate11([
1041
+ ObjectType2({
1042
+ implements: BaseMessageOutput
1043
+ })
1044
+ ], ImageMessageOutput);
1045
+ var CopilotResponse = class {
1046
+ threadId;
1047
+ status;
1048
+ runId;
1049
+ messages;
1050
+ extensions;
1051
+ metaEvents;
1052
+ };
1053
+ __name(CopilotResponse, "CopilotResponse");
1054
+ _ts_decorate11([
1055
+ Field11(() => String),
1056
+ _ts_metadata11("design:type", String)
1057
+ ], CopilotResponse.prototype, "threadId", void 0);
1058
+ _ts_decorate11([
1059
+ Field11(() => ResponseStatusUnion),
1060
+ _ts_metadata11("design:type", Object)
1061
+ ], CopilotResponse.prototype, "status", void 0);
1062
+ _ts_decorate11([
1063
+ Field11({
1064
+ nullable: true
1065
+ }),
1066
+ _ts_metadata11("design:type", String)
1067
+ ], CopilotResponse.prototype, "runId", void 0);
1068
+ _ts_decorate11([
1069
+ Field11(() => [
1070
+ BaseMessageOutput
1071
+ ]),
1072
+ _ts_metadata11("design:type", Array)
1073
+ ], CopilotResponse.prototype, "messages", void 0);
1074
+ _ts_decorate11([
1075
+ Field11(() => ExtensionsResponse, {
1076
+ nullable: true
1077
+ }),
1078
+ _ts_metadata11("design:type", typeof ExtensionsResponse === "undefined" ? Object : ExtensionsResponse)
1079
+ ], CopilotResponse.prototype, "extensions", void 0);
1080
+ _ts_decorate11([
1081
+ Field11(() => [
1082
+ BaseMetaEvent
1083
+ ], {
1084
+ nullable: true
1085
+ }),
1086
+ _ts_metadata11("design:type", Array)
1087
+ ], CopilotResponse.prototype, "metaEvents", void 0);
1088
+ CopilotResponse = _ts_decorate11([
1089
+ ObjectType2()
1090
+ ], CopilotResponse);
1091
+
1092
+ // src/graphql/types/meta-events.type.ts
1093
+ function _ts_decorate12(decorators, target, key, desc) {
1094
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1095
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1096
+ r = Reflect.decorate(decorators, target, key, desc);
1097
+ else
1098
+ for (var i = decorators.length - 1; i >= 0; i--)
1099
+ if (d = decorators[i])
1100
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1101
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1102
+ }
1103
+ __name(_ts_decorate12, "_ts_decorate");
1104
+ function _ts_metadata12(k, v) {
1105
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1106
+ return Reflect.metadata(k, v);
1107
+ }
1108
+ __name(_ts_metadata12, "_ts_metadata");
1109
+ var MetaEventName;
1110
+ (function(MetaEventName2) {
1111
+ MetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1112
+ MetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1113
+ })(MetaEventName || (MetaEventName = {}));
1114
+ registerEnumType(MetaEventName, {
1115
+ name: "MetaEventName",
1116
+ description: "Meta event types"
1117
+ });
1118
+ var BaseMetaEvent = class {
1119
+ type = "MetaEvent";
1120
+ name;
1121
+ };
1122
+ __name(BaseMetaEvent, "BaseMetaEvent");
1123
+ _ts_decorate12([
1124
+ Field12(() => String),
1125
+ _ts_metadata12("design:type", String)
1126
+ ], BaseMetaEvent.prototype, "type", void 0);
1127
+ _ts_decorate12([
1128
+ Field12(() => MetaEventName),
1129
+ _ts_metadata12("design:type", String)
1130
+ ], BaseMetaEvent.prototype, "name", void 0);
1131
+ BaseMetaEvent = _ts_decorate12([
1132
+ InterfaceType2({
1133
+ resolveType(value) {
1134
+ if (value.name === "LangGraphInterruptEvent") {
1135
+ return LangGraphInterruptEvent;
1136
+ } else if (value.name === "CopilotKitLangGraphInterruptEvent") {
1137
+ return CopilotKitLangGraphInterruptEvent;
1138
+ }
1139
+ return void 0;
1140
+ }
1141
+ }),
1142
+ InterfaceType2()
1143
+ ], BaseMetaEvent);
1144
+ var CopilotKitLangGraphInterruptEventData = class {
1145
+ value;
1146
+ messages;
1147
+ };
1148
+ __name(CopilotKitLangGraphInterruptEventData, "CopilotKitLangGraphInterruptEventData");
1149
+ _ts_decorate12([
1150
+ Field12(() => String),
1151
+ _ts_metadata12("design:type", String)
1152
+ ], CopilotKitLangGraphInterruptEventData.prototype, "value", void 0);
1153
+ _ts_decorate12([
1154
+ Field12(() => [
1155
+ BaseMessageOutput
1156
+ ]),
1157
+ _ts_metadata12("design:type", Array)
1158
+ ], CopilotKitLangGraphInterruptEventData.prototype, "messages", void 0);
1159
+ CopilotKitLangGraphInterruptEventData = _ts_decorate12([
1160
+ ObjectType3()
1161
+ ], CopilotKitLangGraphInterruptEventData);
1162
+ var LangGraphInterruptEvent = class {
1163
+ name = "LangGraphInterruptEvent";
1164
+ value;
1165
+ response;
1166
+ };
1167
+ __name(LangGraphInterruptEvent, "LangGraphInterruptEvent");
1168
+ _ts_decorate12([
1169
+ Field12(() => MetaEventName),
1170
+ _ts_metadata12("design:type", typeof MetaEventName === "undefined" || false ? Object : "LangGraphInterruptEvent")
1171
+ ], LangGraphInterruptEvent.prototype, "name", void 0);
1172
+ _ts_decorate12([
1173
+ Field12(() => String),
1174
+ _ts_metadata12("design:type", String)
1175
+ ], LangGraphInterruptEvent.prototype, "value", void 0);
1176
+ _ts_decorate12([
1177
+ Field12(() => String, {
1178
+ nullable: true
1179
+ }),
1180
+ _ts_metadata12("design:type", String)
1181
+ ], LangGraphInterruptEvent.prototype, "response", void 0);
1182
+ LangGraphInterruptEvent = _ts_decorate12([
1183
+ ObjectType3({
1184
+ implements: BaseMetaEvent
1185
+ })
1186
+ ], LangGraphInterruptEvent);
1187
+ var CopilotKitLangGraphInterruptEvent = class {
1188
+ name = "CopilotKitLangGraphInterruptEvent";
1189
+ data;
1190
+ response;
1191
+ };
1192
+ __name(CopilotKitLangGraphInterruptEvent, "CopilotKitLangGraphInterruptEvent");
1193
+ _ts_decorate12([
1194
+ Field12(() => MetaEventName),
1195
+ _ts_metadata12("design:type", typeof MetaEventName === "undefined" || false ? Object : "CopilotKitLangGraphInterruptEvent")
1196
+ ], CopilotKitLangGraphInterruptEvent.prototype, "name", void 0);
1197
+ _ts_decorate12([
1198
+ Field12(() => CopilotKitLangGraphInterruptEventData),
1199
+ _ts_metadata12("design:type", typeof CopilotKitLangGraphInterruptEventData === "undefined" ? Object : CopilotKitLangGraphInterruptEventData)
1200
+ ], CopilotKitLangGraphInterruptEvent.prototype, "data", void 0);
1201
+ _ts_decorate12([
1202
+ Field12(() => String, {
1203
+ nullable: true
1204
+ }),
1205
+ _ts_metadata12("design:type", String)
1206
+ ], CopilotKitLangGraphInterruptEvent.prototype, "response", void 0);
1207
+ CopilotKitLangGraphInterruptEvent = _ts_decorate12([
1208
+ ObjectType3({
1209
+ implements: BaseMetaEvent
1210
+ })
1211
+ ], CopilotKitLangGraphInterruptEvent);
1212
+
1213
+ // src/graphql/inputs/meta-event.input.ts
1214
+ function _ts_decorate13(decorators, target, key, desc) {
1215
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1216
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1217
+ r = Reflect.decorate(decorators, target, key, desc);
1218
+ else
1219
+ for (var i = decorators.length - 1; i >= 0; i--)
1220
+ if (d = decorators[i])
1221
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1222
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1223
+ }
1224
+ __name(_ts_decorate13, "_ts_decorate");
1225
+ function _ts_metadata13(k, v) {
1226
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1227
+ return Reflect.metadata(k, v);
1228
+ }
1229
+ __name(_ts_metadata13, "_ts_metadata");
1230
+ var MetaEventInput = class {
1231
+ name;
1232
+ value;
1233
+ response;
1234
+ messages;
1235
+ };
1236
+ __name(MetaEventInput, "MetaEventInput");
1237
+ _ts_decorate13([
1238
+ Field13(() => MetaEventName),
1239
+ _ts_metadata13("design:type", typeof MetaEventName === "undefined" ? Object : MetaEventName)
1240
+ ], MetaEventInput.prototype, "name", void 0);
1241
+ _ts_decorate13([
1242
+ Field13(() => String),
1243
+ _ts_metadata13("design:type", String)
1244
+ ], MetaEventInput.prototype, "value", void 0);
1245
+ _ts_decorate13([
1246
+ Field13(() => String, {
1247
+ nullable: true
1248
+ }),
1249
+ _ts_metadata13("design:type", String)
1250
+ ], MetaEventInput.prototype, "response", void 0);
1251
+ _ts_decorate13([
1252
+ Field13(() => [
1253
+ MessageInput
1254
+ ], {
1255
+ nullable: true
1256
+ }),
1257
+ _ts_metadata13("design:type", Array)
1258
+ ], MetaEventInput.prototype, "messages", void 0);
1259
+ MetaEventInput = _ts_decorate13([
1260
+ InputType10()
1261
+ ], MetaEventInput);
1262
+
1263
+ // src/graphql/inputs/copilot-context.input.ts
1264
+ import { Field as Field14, InputType as InputType11 } from "type-graphql";
1265
+ function _ts_decorate14(decorators, target, key, desc) {
1266
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1267
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1268
+ r = Reflect.decorate(decorators, target, key, desc);
1269
+ else
1270
+ for (var i = decorators.length - 1; i >= 0; i--)
1271
+ if (d = decorators[i])
1272
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1273
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1274
+ }
1275
+ __name(_ts_decorate14, "_ts_decorate");
1276
+ function _ts_metadata14(k, v) {
1277
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1278
+ return Reflect.metadata(k, v);
1279
+ }
1280
+ __name(_ts_metadata14, "_ts_metadata");
1281
+ var CopilotContextInput = class {
1282
+ description;
1283
+ value;
1284
+ };
1285
+ __name(CopilotContextInput, "CopilotContextInput");
1286
+ _ts_decorate14([
1287
+ Field14(() => String),
1288
+ _ts_metadata14("design:type", String)
1289
+ ], CopilotContextInput.prototype, "description", void 0);
1290
+ _ts_decorate14([
1291
+ Field14(() => String),
1292
+ _ts_metadata14("design:type", String)
1293
+ ], CopilotContextInput.prototype, "value", void 0);
1294
+ CopilotContextInput = _ts_decorate14([
1295
+ InputType11()
1296
+ ], CopilotContextInput);
1297
+
1298
+ // src/graphql/inputs/generate-copilot-response.input.ts
1299
+ function _ts_decorate15(decorators, target, key, desc) {
1300
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1301
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1302
+ r = Reflect.decorate(decorators, target, key, desc);
1303
+ else
1304
+ for (var i = decorators.length - 1; i >= 0; i--)
1305
+ if (d = decorators[i])
1306
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1307
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1308
+ }
1309
+ __name(_ts_decorate15, "_ts_decorate");
1310
+ function _ts_metadata15(k, v) {
1311
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1312
+ return Reflect.metadata(k, v);
1313
+ }
1314
+ __name(_ts_metadata15, "_ts_metadata");
1315
+ var GenerateCopilotResponseMetadataInput = class {
1316
+ requestType;
1317
+ };
1318
+ __name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
1319
+ _ts_decorate15([
1320
+ Field15(() => CopilotRequestType, {
1321
+ nullable: true
1322
+ }),
1323
+ _ts_metadata15("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
1324
+ ], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
1325
+ GenerateCopilotResponseMetadataInput = _ts_decorate15([
1326
+ InputType12()
1327
+ ], GenerateCopilotResponseMetadataInput);
1328
+ var GenerateCopilotResponseInput = class {
1329
+ metadata;
1330
+ threadId;
1331
+ runId;
1332
+ messages;
1333
+ frontend;
1334
+ cloud;
1335
+ forwardedParameters;
1336
+ agentSession;
1337
+ agentState;
1338
+ agentStates;
1339
+ extensions;
1340
+ metaEvents;
1341
+ context;
1342
+ };
1343
+ __name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
1344
+ _ts_decorate15([
1345
+ Field15(() => GenerateCopilotResponseMetadataInput, {
1346
+ nullable: false
1347
+ }),
1348
+ _ts_metadata15("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
1349
+ ], GenerateCopilotResponseInput.prototype, "metadata", void 0);
1350
+ _ts_decorate15([
1351
+ Field15(() => String, {
1352
+ nullable: true
1353
+ }),
1354
+ _ts_metadata15("design:type", String)
1355
+ ], GenerateCopilotResponseInput.prototype, "threadId", void 0);
1356
+ _ts_decorate15([
1357
+ Field15(() => String, {
1358
+ nullable: true
1359
+ }),
1360
+ _ts_metadata15("design:type", String)
1361
+ ], GenerateCopilotResponseInput.prototype, "runId", void 0);
1362
+ _ts_decorate15([
1363
+ Field15(() => [
1364
+ MessageInput
1365
+ ]),
1366
+ _ts_metadata15("design:type", Array)
1367
+ ], GenerateCopilotResponseInput.prototype, "messages", void 0);
1368
+ _ts_decorate15([
1369
+ Field15(() => FrontendInput),
1370
+ _ts_metadata15("design:type", typeof FrontendInput === "undefined" ? Object : FrontendInput)
1371
+ ], GenerateCopilotResponseInput.prototype, "frontend", void 0);
1372
+ _ts_decorate15([
1373
+ Field15(() => CloudInput, {
1374
+ nullable: true
1375
+ }),
1376
+ _ts_metadata15("design:type", typeof CloudInput === "undefined" ? Object : CloudInput)
1377
+ ], GenerateCopilotResponseInput.prototype, "cloud", void 0);
1378
+ _ts_decorate15([
1379
+ Field15(() => ForwardedParametersInput, {
1380
+ nullable: true
1381
+ }),
1382
+ _ts_metadata15("design:type", typeof ForwardedParametersInput === "undefined" ? Object : ForwardedParametersInput)
1383
+ ], GenerateCopilotResponseInput.prototype, "forwardedParameters", void 0);
1384
+ _ts_decorate15([
1385
+ Field15(() => AgentSessionInput, {
1386
+ nullable: true
1387
+ }),
1388
+ _ts_metadata15("design:type", typeof AgentSessionInput === "undefined" ? Object : AgentSessionInput)
1389
+ ], GenerateCopilotResponseInput.prototype, "agentSession", void 0);
1390
+ _ts_decorate15([
1391
+ Field15(() => AgentStateInput, {
1392
+ nullable: true
1393
+ }),
1394
+ _ts_metadata15("design:type", typeof AgentStateInput === "undefined" ? Object : AgentStateInput)
1395
+ ], GenerateCopilotResponseInput.prototype, "agentState", void 0);
1396
+ _ts_decorate15([
1397
+ Field15(() => [
1398
+ AgentStateInput
1399
+ ], {
1400
+ nullable: true
1401
+ }),
1402
+ _ts_metadata15("design:type", Array)
1403
+ ], GenerateCopilotResponseInput.prototype, "agentStates", void 0);
1404
+ _ts_decorate15([
1405
+ Field15(() => ExtensionsInput, {
1406
+ nullable: true
1407
+ }),
1408
+ _ts_metadata15("design:type", typeof ExtensionsInput === "undefined" ? Object : ExtensionsInput)
1409
+ ], GenerateCopilotResponseInput.prototype, "extensions", void 0);
1410
+ _ts_decorate15([
1411
+ Field15(() => [
1412
+ MetaEventInput
1413
+ ], {
1414
+ nullable: true
1415
+ }),
1416
+ _ts_metadata15("design:type", Array)
1417
+ ], GenerateCopilotResponseInput.prototype, "metaEvents", void 0);
1418
+ _ts_decorate15([
1419
+ Field15(() => [
1420
+ CopilotContextInput
1421
+ ], {
1422
+ nullable: true
1423
+ }),
1424
+ _ts_metadata15("design:type", Array)
1425
+ ], GenerateCopilotResponseInput.prototype, "context", void 0);
1426
+ GenerateCopilotResponseInput = _ts_decorate15([
1427
+ InputType12()
1428
+ ], GenerateCopilotResponseInput);
1429
+
1430
+ // src/graphql/resolvers/copilot.resolver.ts
1431
+ import { Repeater } from "graphql-yoga";
1432
+
1433
+ // src/service-adapters/events.ts
1434
+ import { CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, Severity } from "@copilotkit/shared";
1435
+ import { ReplaySubject } from "rxjs";
1436
+ var RuntimeEventTypes;
1437
+ (function(RuntimeEventTypes2) {
1438
+ RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
1439
+ RuntimeEventTypes2["TextMessageContent"] = "TextMessageContent";
1440
+ RuntimeEventTypes2["TextMessageEnd"] = "TextMessageEnd";
1441
+ RuntimeEventTypes2["ActionExecutionStart"] = "ActionExecutionStart";
1442
+ RuntimeEventTypes2["ActionExecutionArgs"] = "ActionExecutionArgs";
1443
+ RuntimeEventTypes2["ActionExecutionEnd"] = "ActionExecutionEnd";
1444
+ RuntimeEventTypes2["ActionExecutionResult"] = "ActionExecutionResult";
1445
+ RuntimeEventTypes2["AgentStateMessage"] = "AgentStateMessage";
1446
+ RuntimeEventTypes2["MetaEvent"] = "MetaEvent";
1447
+ RuntimeEventTypes2["RunError"] = "RunError";
1448
+ })(RuntimeEventTypes || (RuntimeEventTypes = {}));
1449
+ var RuntimeMetaEventName;
1450
+ (function(RuntimeMetaEventName2) {
1451
+ RuntimeMetaEventName2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1452
+ RuntimeMetaEventName2["LangGraphInterruptResumeEvent"] = "LangGraphInterruptResumeEvent";
1453
+ RuntimeMetaEventName2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1454
+ })(RuntimeMetaEventName || (RuntimeMetaEventName = {}));
1455
+
1456
+ // src/graphql/resolvers/copilot.resolver.ts
1457
+ import { GraphQLJSONObject } from "graphql-scalars";
1458
+ import { plainToInstance } from "class-transformer";
1459
+ import { GraphQLError } from "graphql";
1460
+
1461
+ // src/lib/telemetry-client.ts
1462
+ import { TelemetryClient } from "@copilotkit/shared";
1463
+ import { createHash } from "crypto";
1464
+
1465
+ // src/lib/runtime/copilot-runtime.ts
1466
+ import { CopilotKitMisuseError, readBody, getZodParameters } from "@copilotkit/shared";
1467
+ import { CopilotRuntime as CopilotRuntimeVNext, InMemoryAgentRunner as InMemoryAgentRunnerVNext } from "@copilotkitnext/runtime";
1468
+
1469
+ // src/lib/runtime/types.ts
1470
+ var EndpointType;
1471
+ (function(EndpointType2) {
1472
+ EndpointType2["CopilotKit"] = "copilotKit";
1473
+ EndpointType2["LangGraphPlatform"] = "langgraph-platform";
1474
+ })(EndpointType || (EndpointType = {}));
1475
+
1476
+ // src/lib/runtime/mcp-tools-utils.ts
1477
+ function extractParametersFromSchema(toolOrSchema) {
1478
+ var _a;
1479
+ const parameters = [];
1480
+ const schema = "schema" in (toolOrSchema || {}) ? toolOrSchema.schema : toolOrSchema;
1481
+ const toolParameters = ((_a = schema == null ? void 0 : schema.parameters) == null ? void 0 : _a.jsonSchema) || (schema == null ? void 0 : schema.parameters);
1482
+ const properties = toolParameters == null ? void 0 : toolParameters.properties;
1483
+ const requiredParams = new Set((toolParameters == null ? void 0 : toolParameters.required) || []);
1484
+ if (!properties) {
1485
+ return parameters;
1486
+ }
1487
+ for (const paramName in properties) {
1488
+ if (Object.prototype.hasOwnProperty.call(properties, paramName)) {
1489
+ const paramDef = properties[paramName];
1490
+ let type = paramDef.type || "string";
1491
+ let description = paramDef.description || "";
1492
+ if (type === "array" && paramDef.items) {
1493
+ const itemType = paramDef.items.type || "object";
1494
+ if (itemType === "object" && paramDef.items.properties) {
1495
+ const itemProperties = Object.keys(paramDef.items.properties).join(", ");
1496
+ description = description + (description ? " " : "") + `Array of objects with properties: ${itemProperties}`;
1497
+ } else {
1498
+ type = `array<${itemType}>`;
1499
+ }
1500
+ }
1501
+ if (paramDef.enum && Array.isArray(paramDef.enum)) {
1502
+ const enumValues = paramDef.enum.join(" | ");
1503
+ description = description + (description ? " " : "") + `Allowed values: ${enumValues}`;
1504
+ }
1505
+ if (type === "object" && paramDef.properties) {
1506
+ const objectProperties = Object.keys(paramDef.properties).join(", ");
1507
+ description = description + (description ? " " : "") + `Object with properties: ${objectProperties}`;
1508
+ }
1509
+ parameters.push({
1510
+ name: paramName,
1511
+ type,
1512
+ description,
1513
+ required: requiredParams.has(paramName)
1514
+ });
1515
+ }
1516
+ }
1517
+ return parameters;
1518
+ }
1519
+ __name(extractParametersFromSchema, "extractParametersFromSchema");
1520
+ function convertMCPToolsToActions(mcpTools, mcpEndpoint) {
1521
+ const actions = [];
1522
+ for (const [toolName, tool] of Object.entries(mcpTools)) {
1523
+ const parameters = extractParametersFromSchema(tool);
1524
+ const handler = /* @__PURE__ */ __name(async (params) => {
1525
+ try {
1526
+ const result = await tool.execute(params);
1527
+ return typeof result === "string" ? result : JSON.stringify(result);
1528
+ } catch (error) {
1529
+ console.error(`Error executing MCP tool '${toolName}' from endpoint ${mcpEndpoint}:`, error);
1530
+ throw new Error(`Execution failed for MCP tool '${toolName}': ${error instanceof Error ? error.message : String(error)}`);
1531
+ }
1532
+ }, "handler");
1533
+ actions.push({
1534
+ name: toolName,
1535
+ description: tool.description || `MCP tool: ${toolName} (from ${mcpEndpoint})`,
1536
+ parameters,
1537
+ handler,
1538
+ // Add metadata for easier identification/debugging
1539
+ _isMCPTool: true,
1540
+ _mcpEndpoint: mcpEndpoint
1541
+ });
1542
+ }
1543
+ return actions;
1544
+ }
1545
+ __name(convertMCPToolsToActions, "convertMCPToolsToActions");
1546
+ function generateMcpToolInstructions(toolsMap) {
1547
+ if (!toolsMap || Object.keys(toolsMap).length === 0) {
1548
+ return "";
1549
+ }
1550
+ const toolEntries = Object.entries(toolsMap);
1551
+ const toolsDoc = toolEntries.map(([name, tool]) => {
1552
+ var _a;
1553
+ let paramsDoc = " No parameters required";
1554
+ try {
1555
+ if (tool.schema && typeof tool.schema === "object") {
1556
+ const schema = tool.schema;
1557
+ const toolParameters = ((_a = schema.parameters) == null ? void 0 : _a.jsonSchema) || schema.parameters;
1558
+ const properties = (toolParameters == null ? void 0 : toolParameters.properties) || schema.properties;
1559
+ const requiredParams = (toolParameters == null ? void 0 : toolParameters.required) || schema.required || [];
1560
+ if (properties) {
1561
+ const paramsList = Object.entries(properties).map(([paramName, propSchema]) => {
1562
+ const propDetails = propSchema;
1563
+ const requiredMark = requiredParams.includes(paramName) ? "*" : "";
1564
+ let typeInfo = propDetails.type || "any";
1565
+ let description = propDetails.description ? ` - ${propDetails.description}` : "";
1566
+ if (typeInfo === "array" && propDetails.items) {
1567
+ const itemType = propDetails.items.type || "object";
1568
+ if (itemType === "object" && propDetails.items.properties) {
1569
+ const itemProps = Object.keys(propDetails.items.properties).join(", ");
1570
+ typeInfo = `array<object>`;
1571
+ description = description + (description ? " " : " - ") + `Array of objects with properties: ${itemProps}`;
1572
+ } else {
1573
+ typeInfo = `array<${itemType}>`;
1574
+ }
1575
+ }
1576
+ if (propDetails.enum && Array.isArray(propDetails.enum)) {
1577
+ const enumValues = propDetails.enum.join(" | ");
1578
+ description = description + (description ? " " : " - ") + `Allowed values: ${enumValues}`;
1579
+ }
1580
+ if (typeInfo === "object" && propDetails.properties) {
1581
+ const objectProps = Object.keys(propDetails.properties).join(", ");
1582
+ description = description + (description ? " " : " - ") + `Object with properties: ${objectProps}`;
1583
+ }
1584
+ return ` - ${paramName}${requiredMark} (${typeInfo})${description}`;
1585
+ });
1586
+ if (paramsList.length > 0) {
1587
+ paramsDoc = paramsList.join("\n");
1588
+ }
1589
+ }
1590
+ }
1591
+ } catch (e) {
1592
+ console.error(`Error parsing schema for tool ${name}:`, e);
1593
+ }
1594
+ return `- ${name}: ${tool.description || ""}
1595
+ ${paramsDoc}`;
1596
+ }).join("\n\n");
1597
+ return `You have access to the following external tools provided by Model Context Protocol (MCP) servers:
1598
+
1599
+ ${toolsDoc}
1600
+
1601
+ When using these tools:
1602
+ 1. Only provide valid parameters according to their type requirements
1603
+ 2. Required parameters are marked with *
1604
+ 3. For array parameters, provide data in the correct array format
1605
+ 4. For object parameters, include all required nested properties
1606
+ 5. For enum parameters, use only the allowed values listed
1607
+ 6. Format API calls correctly with the expected parameter structure
1608
+ 7. Always check tool responses to determine your next action`;
1609
+ }
1610
+ __name(generateMcpToolInstructions, "generateMcpToolInstructions");
1611
+
1612
+ // src/lib/runtime/agent-integrations/langgraph.agent.ts
1613
+ import { EventType } from "@ag-ui/client";
1614
+ import { map } from "rxjs";
1615
+
1616
+ // src/agents/langgraph/events.ts
1617
+ var LangGraphEventTypes;
1618
+ (function(LangGraphEventTypes2) {
1619
+ LangGraphEventTypes2["OnChainStart"] = "on_chain_start";
1620
+ LangGraphEventTypes2["OnChainStream"] = "on_chain_stream";
1621
+ LangGraphEventTypes2["OnChainEnd"] = "on_chain_end";
1622
+ LangGraphEventTypes2["OnChatModelStart"] = "on_chat_model_start";
1623
+ LangGraphEventTypes2["OnChatModelStream"] = "on_chat_model_stream";
1624
+ LangGraphEventTypes2["OnChatModelEnd"] = "on_chat_model_end";
1625
+ LangGraphEventTypes2["OnToolStart"] = "on_tool_start";
1626
+ LangGraphEventTypes2["OnToolEnd"] = "on_tool_end";
1627
+ LangGraphEventTypes2["OnCopilotKitStateSync"] = "on_copilotkit_state_sync";
1628
+ LangGraphEventTypes2["OnCopilotKitEmitMessage"] = "on_copilotkit_emit_message";
1629
+ LangGraphEventTypes2["OnCopilotKitEmitToolCall"] = "on_copilotkit_emit_tool_call";
1630
+ LangGraphEventTypes2["OnCustomEvent"] = "on_custom_event";
1631
+ LangGraphEventTypes2["OnInterrupt"] = "on_interrupt";
1632
+ LangGraphEventTypes2["OnCopilotKitInterrupt"] = "on_copilotkit_interrupt";
1633
+ LangGraphEventTypes2["OnCopilotKitError"] = "on_copilotkit_error";
1634
+ })(LangGraphEventTypes || (LangGraphEventTypes = {}));
1635
+ var MetaEventNames;
1636
+ (function(MetaEventNames2) {
1637
+ MetaEventNames2["LangGraphInterruptEvent"] = "LangGraphInterruptEvent";
1638
+ MetaEventNames2["CopilotKitLangGraphInterruptEvent"] = "CopilotKitLangGraphInterruptEvent";
1639
+ })(MetaEventNames || (MetaEventNames = {}));
1640
+ var CustomEventNames;
1641
+ (function(CustomEventNames3) {
1642
+ CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
1643
+ CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
1644
+ CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
1645
+ CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
1646
+ })(CustomEventNames || (CustomEventNames = {}));
1647
+
1648
+ // src/lib/runtime/agent-integrations/langgraph.agent.ts
1649
+ import { LangGraphAgent as AGUILangGraphAgent, LangGraphHttpAgent } from "@ag-ui/langgraph";
1650
+ var CustomEventNames2;
1651
+ (function(CustomEventNames3) {
1652
+ CustomEventNames3["CopilotKitManuallyEmitMessage"] = "copilotkit_manually_emit_message";
1653
+ CustomEventNames3["CopilotKitManuallyEmitToolCall"] = "copilotkit_manually_emit_tool_call";
1654
+ CustomEventNames3["CopilotKitManuallyEmitIntermediateState"] = "copilotkit_manually_emit_intermediate_state";
1655
+ CustomEventNames3["CopilotKitExit"] = "copilotkit_exit";
1656
+ })(CustomEventNames2 || (CustomEventNames2 = {}));
1657
+ var LangGraphAgent = class extends AGUILangGraphAgent {
1658
+ constructor(config) {
1659
+ super(config);
1660
+ }
1661
+ // @ts-ignore
1662
+ clone() {
1663
+ return new LangGraphAgent(this.config);
1664
+ }
1665
+ dispatchEvent(event) {
1666
+ if (event.type === EventType.CUSTOM) {
1667
+ const customEvent = event;
1668
+ if (customEvent.name === "copilotkit_manually_emit_message") {
1669
+ this.subscriber.next({
1670
+ type: EventType.TEXT_MESSAGE_START,
1671
+ role: "assistant",
1672
+ messageId: customEvent.value.message_id,
1673
+ rawEvent: event
1674
+ });
1675
+ this.subscriber.next({
1676
+ type: EventType.TEXT_MESSAGE_CONTENT,
1677
+ messageId: customEvent.value.message_id,
1678
+ delta: customEvent.value.message,
1679
+ rawEvent: event
1680
+ });
1681
+ this.subscriber.next({
1682
+ type: EventType.TEXT_MESSAGE_END,
1683
+ messageId: customEvent.value.message_id,
1684
+ rawEvent: event
1685
+ });
1686
+ return true;
1687
+ }
1688
+ if (customEvent.name === "copilotkit_manually_emit_tool_call") {
1689
+ this.subscriber.next({
1690
+ type: EventType.TOOL_CALL_START,
1691
+ toolCallId: customEvent.value.id,
1692
+ toolCallName: customEvent.value.name,
1693
+ parentMessageId: customEvent.value.id,
1694
+ rawEvent: event
1695
+ });
1696
+ this.subscriber.next({
1697
+ type: EventType.TOOL_CALL_ARGS,
1698
+ toolCallId: customEvent.value.id,
1699
+ delta: customEvent.value.args,
1700
+ rawEvent: event
1701
+ });
1702
+ this.subscriber.next({
1703
+ type: EventType.TOOL_CALL_END,
1704
+ toolCallId: customEvent.value.id,
1705
+ rawEvent: event
1706
+ });
1707
+ return true;
1708
+ }
1709
+ if (customEvent.name === "copilotkit_manually_emit_intermediate_state") {
1710
+ this.activeRun.manuallyEmittedState = customEvent.value;
1711
+ this.dispatchEvent({
1712
+ type: EventType.STATE_SNAPSHOT,
1713
+ snapshot: this.getStateSnapshot({
1714
+ values: this.activeRun.manuallyEmittedState
1715
+ }),
1716
+ rawEvent: event
1717
+ });
1718
+ return true;
1719
+ }
1720
+ if (customEvent.name === "copilotkit_exit") {
1721
+ this.subscriber.next({
1722
+ type: EventType.CUSTOM,
1723
+ name: "Exit",
1724
+ value: true
1725
+ });
1726
+ return true;
1727
+ }
1728
+ }
1729
+ const rawEvent = event.rawEvent;
1730
+ if (!rawEvent) {
1731
+ this.subscriber.next(event);
1732
+ return true;
1733
+ }
1734
+ const isMessageEvent = event.type === EventType.TEXT_MESSAGE_START || event.type === EventType.TEXT_MESSAGE_CONTENT || event.type === EventType.TEXT_MESSAGE_END;
1735
+ const isToolEvent = event.type === EventType.TOOL_CALL_START || event.type === EventType.TOOL_CALL_ARGS || event.type === EventType.TOOL_CALL_END;
1736
+ if ("copilotkit:emit-tool-calls" in (rawEvent.metadata || {})) {
1737
+ if (rawEvent.metadata["copilotkit:emit-tool-calls"] === false && isToolEvent) {
1738
+ return false;
1739
+ }
1740
+ }
1741
+ if ("copilotkit:emit-messages" in (rawEvent.metadata || {})) {
1742
+ if (rawEvent.metadata["copilotkit:emit-messages"] === false && isMessageEvent) {
1743
+ return false;
1744
+ }
1745
+ }
1746
+ this.subscriber.next(event);
1747
+ return true;
1748
+ }
1749
+ // @ts-ignore
1750
+ run(input) {
1751
+ return super.run(input).pipe(map((processedEvent) => {
1752
+ var _a, _b, _c, _d, _e;
1753
+ if (processedEvent.type === EventType.RAW) {
1754
+ const event = processedEvent.event ?? processedEvent.rawEvent;
1755
+ const eventType = event.event;
1756
+ const toolCallData = (_c = (_b = (_a = event.data) == null ? void 0 : _a.chunk) == null ? void 0 : _b.tool_call_chunks) == null ? void 0 : _c[0];
1757
+ const toolCallUsedToPredictState = (_e = (_d = event.metadata) == null ? void 0 : _d["copilotkit:emit-intermediate-state"]) == null ? void 0 : _e.some((predictStateTool) => predictStateTool.tool === (toolCallData == null ? void 0 : toolCallData.name));
1758
+ if (eventType === LangGraphEventTypes.OnChatModelStream && toolCallUsedToPredictState) {
1759
+ return {
1760
+ type: EventType.CUSTOM,
1761
+ name: "PredictState",
1762
+ value: event.metadata["copilotkit:emit-intermediate-state"]
1763
+ };
1764
+ }
1765
+ }
1766
+ return processedEvent;
1767
+ }));
1768
+ }
1769
+ langGraphDefaultMergeState(state, messages, input) {
1770
+ const aguiMergedState = super.langGraphDefaultMergeState(state, messages, input);
1771
+ const { tools: returnedTools, "ag-ui": agui } = aguiMergedState;
1772
+ const rawCombinedTools = [
1773
+ ...returnedTools ?? [],
1774
+ ...(agui == null ? void 0 : agui.tools) ?? []
1775
+ ];
1776
+ const combinedTools = Array.from(new Map(rawCombinedTools.map((t) => [
1777
+ (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.name) ?? (t == null ? void 0 : t.key) ?? JSON.stringify(t),
1778
+ t
1779
+ ])).values());
1780
+ return {
1781
+ ...aguiMergedState,
1782
+ copilotkit: {
1783
+ actions: combinedTools,
1784
+ context: (agui == null ? void 0 : agui.context) ?? []
1785
+ }
1786
+ };
1787
+ }
1788
+ async getSchemaKeys() {
1789
+ const CONSTANT_KEYS = [
1790
+ "copilotkit"
1791
+ ];
1792
+ const schemaKeys = await super.getSchemaKeys();
1793
+ return {
1794
+ config: schemaKeys.config,
1795
+ input: schemaKeys.input ? [
1796
+ ...schemaKeys.input,
1797
+ ...CONSTANT_KEYS
1798
+ ] : null,
1799
+ output: schemaKeys.output ? [
1800
+ ...schemaKeys.output,
1801
+ ...CONSTANT_KEYS
1802
+ ] : null,
1803
+ context: schemaKeys.context ? [
1804
+ ...schemaKeys.context,
1805
+ ...CONSTANT_KEYS
1806
+ ] : null
1807
+ };
1808
+ }
1809
+ };
1810
+ __name(LangGraphAgent, "LangGraphAgent");
1811
+
1812
+ // src/lib/runtime/copilot-runtime.ts
1813
+ import { BasicAgent } from "@copilotkitnext/agent";
1814
+ var CopilotRuntime = class {
1815
+ params;
1816
+ observability;
1817
+ // Cache MCP tools per endpoint to avoid re-fetching repeatedly
1818
+ mcpToolsCache = /* @__PURE__ */ new Map();
1819
+ runtimeArgs;
1820
+ _instance;
1821
+ constructor(params) {
1822
+ const agents = (params == null ? void 0 : params.agents) ?? {};
1823
+ this.runtimeArgs = {
1824
+ agents: {
1825
+ ...this.assignEndpointsToAgents((params == null ? void 0 : params.remoteEndpoints) ?? []),
1826
+ ...agents
1827
+ },
1828
+ runner: (params == null ? void 0 : params.runner) ?? new InMemoryAgentRunnerVNext(),
1829
+ // TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
1830
+ // transcriptionService: params?.transcriptionService,
1831
+ beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
1832
+ afterRequestMiddleware: this.createOnAfterRequestHandler(params).bind(this)
1833
+ };
1834
+ this.params = params;
1835
+ this.observability = params == null ? void 0 : params.observability_c;
1836
+ }
1837
+ get instance() {
1838
+ if (!this._instance) {
1839
+ this._instance = new CopilotRuntimeVNext(this.runtimeArgs);
1840
+ }
1841
+ return this._instance;
1842
+ }
1843
+ assignEndpointsToAgents(endpoints) {
1844
+ return endpoints.reduce((acc, endpoint) => {
1845
+ if (resolveEndpointType(endpoint) == EndpointType.LangGraphPlatform) {
1846
+ let lgAgents = {};
1847
+ const lgEndpoint = endpoint;
1848
+ lgEndpoint.agents.forEach((agent) => {
1849
+ const graphId = agent.assistantId ?? agent.name;
1850
+ lgAgents[graphId] = new LangGraphAgent({
1851
+ deploymentUrl: lgEndpoint.deploymentUrl,
1852
+ langsmithApiKey: lgEndpoint.langsmithApiKey,
1853
+ graphId
1854
+ });
1855
+ });
1856
+ return {
1857
+ ...acc,
1858
+ ...lgAgents
1859
+ };
1860
+ }
1861
+ return acc;
1862
+ }, {});
1863
+ }
1864
+ handleServiceAdapter(serviceAdapter) {
1865
+ this.runtimeArgs.agents = Promise.resolve(this.runtimeArgs.agents ?? {}).then(async (agents) => {
1866
+ var _a;
1867
+ let agentsList = agents;
1868
+ const isAgentsListEmpty = !Object.keys(agents).length;
1869
+ const hasServiceAdapter = Boolean(serviceAdapter);
1870
+ const illegalServiceAdapterNames = [
1871
+ "EmptyAdapter"
1872
+ ];
1873
+ const serviceAdapterCanBeUsedForAgent = !illegalServiceAdapterNames.includes(serviceAdapter.name);
1874
+ if (isAgentsListEmpty && (!hasServiceAdapter || !serviceAdapterCanBeUsedForAgent)) {
1875
+ throw new CopilotKitMisuseError({
1876
+ message: "No default agent provided. Please provide a default agent in the runtime config."
1877
+ });
1878
+ }
1879
+ if (isAgentsListEmpty) {
1880
+ agentsList.default = new BasicAgent({
1881
+ model: `${serviceAdapter.provider}/${serviceAdapter.model}`
1882
+ });
1883
+ }
1884
+ if ((_a = this.params.actions) == null ? void 0 : _a.length) {
1885
+ const mcpTools = await this.getToolsFromMCP();
1886
+ agentsList = this.assignToolsToAgents(agents, [
1887
+ ...this.getToolsFromActions(this.params.actions),
1888
+ ...mcpTools
1889
+ ]);
1890
+ }
1891
+ return agentsList;
1892
+ });
1893
+ }
1894
+ // Receive this.params.action and turn it into the AbstractAgent tools
1895
+ getToolsFromActions(actions) {
1896
+ const actionsArray = typeof actions === "function" ? actions({
1897
+ properties: {},
1898
+ url: void 0
1899
+ }) : actions;
1900
+ return actionsArray.map((action) => {
1901
+ const zodSchema = getZodParameters(action.parameters || []);
1902
+ return {
1903
+ name: action.name,
1904
+ description: action.description || "",
1905
+ parameters: zodSchema
1906
+ };
1907
+ });
1908
+ }
1909
+ assignToolsToAgents(agents, tools) {
1910
+ if (!(tools == null ? void 0 : tools.length)) {
1911
+ return agents;
1912
+ }
1913
+ const enrichedAgents = {
1914
+ ...agents
1915
+ };
1916
+ for (const [agentId, agent] of Object.entries(enrichedAgents)) {
1917
+ const existingConfig = Reflect.get(agent, "config") ?? {};
1918
+ const existingTools = existingConfig.tools ?? [];
1919
+ const updatedConfig = {
1920
+ ...existingConfig,
1921
+ tools: [
1922
+ ...existingTools,
1923
+ ...tools
1924
+ ]
1925
+ };
1926
+ Reflect.set(agent, "config", updatedConfig);
1927
+ enrichedAgents[agentId] = agent;
1928
+ }
1929
+ return enrichedAgents;
1930
+ }
1931
+ createOnBeforeRequestHandler(params) {
1932
+ return async (hookParams) => {
1933
+ var _a, _b;
1934
+ (_a = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _a.call(params, hookParams);
1935
+ if ((_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onBeforeRequest) {
1936
+ const { request, runtime, path } = hookParams;
1937
+ const body = await readBody(request);
1938
+ const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
1939
+ if ("role" in msg && msg.role === "user") {
1940
+ acc.inputMessages.push(msg);
1941
+ } else {
1942
+ acc.outputMessages.push(msg);
1943
+ }
1944
+ return acc;
1945
+ }, {
1946
+ inputMessages: [],
1947
+ outputMessages: []
1948
+ });
1949
+ const { inputMessages, outputMessages } = gqlMessages;
1950
+ params.middleware.onBeforeRequest({
1951
+ threadId: body.threadId,
1952
+ runId: body.runId,
1953
+ inputMessages,
1954
+ properties: body.forwardedProps,
1955
+ url: request.url
1956
+ });
1957
+ }
1958
+ };
1959
+ }
1960
+ createOnAfterRequestHandler(params) {
1961
+ return async (hookParams) => {
1962
+ var _a, _b;
1963
+ (_a = params == null ? void 0 : params.afterRequestMiddleware) == null ? void 0 : _a.call(params, hookParams);
1964
+ if ((_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest) {
1965
+ params.middleware.onAfterRequest({});
1966
+ }
1967
+ };
1968
+ }
1969
+ // Observability Methods
1970
+ /**
1971
+ * Log LLM request if observability is enabled
1972
+ */
1973
+ async logObservabilityBeforeRequest(requestData) {
1974
+ try {
1975
+ await this.observability.hooks.handleRequest(requestData);
1976
+ } catch (error) {
1977
+ console.error("Error logging LLM request:", error);
1978
+ }
1979
+ }
1980
+ /**
1981
+ * Log final LLM response after request completes
1982
+ */
1983
+ logObservabilityAfterRequest(outputMessagesPromise, baseData, streamedChunks, requestStartTime, publicApiKey) {
1984
+ try {
1985
+ outputMessagesPromise.then((outputMessages) => {
1986
+ const responseData = {
1987
+ threadId: baseData.threadId,
1988
+ runId: baseData.runId,
1989
+ model: baseData.model,
1990
+ // Use collected chunks for progressive mode or outputMessages for regular mode
1991
+ output: this.observability.progressive ? streamedChunks : outputMessages,
1992
+ latency: Date.now() - requestStartTime,
1993
+ timestamp: Date.now(),
1994
+ provider: baseData.provider,
1995
+ isFinalResponse: true,
1996
+ agentName: baseData.agentName,
1997
+ nodeName: baseData.nodeName
1998
+ };
1999
+ try {
2000
+ this.observability.hooks.handleResponse(responseData);
2001
+ } catch (logError) {
2002
+ console.error("Error logging LLM response:", logError);
2003
+ }
2004
+ }).catch((error) => {
2005
+ console.error("Failed to get output messages for logging:", error);
2006
+ });
2007
+ } catch (error) {
2008
+ console.error("Error setting up logging for LLM response:", error);
2009
+ }
2010
+ }
2011
+ // Resolve MCP tools to BasicAgent tool definitions
2012
+ // Optionally accepts request-scoped properties to merge request-provided mcpServers
2013
+ async getToolsFromMCP(options) {
2014
+ var _a, _b, _c, _d;
2015
+ const runtimeMcpServers = ((_a = this.params) == null ? void 0 : _a.mcpServers) ?? [];
2016
+ const createMCPClient = (_b = this.params) == null ? void 0 : _b.createMCPClient;
2017
+ const requestMcpServers = ((_c = options == null ? void 0 : options.properties) == null ? void 0 : _c.mcpServers) ?? ((_d = options == null ? void 0 : options.properties) == null ? void 0 : _d.mcpEndpoints) ?? [];
2018
+ const hasAnyServers = ((runtimeMcpServers == null ? void 0 : runtimeMcpServers.length) ?? 0) > 0 || ((requestMcpServers == null ? void 0 : requestMcpServers.length) ?? 0) > 0;
2019
+ if (!hasAnyServers) {
2020
+ return [];
2021
+ }
2022
+ if (!createMCPClient) {
2023
+ throw new CopilotKitMisuseError({
2024
+ message: "MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
2025
+ });
2026
+ }
2027
+ const effectiveEndpoints = (() => {
2028
+ const byUrl = /* @__PURE__ */ new Map();
2029
+ for (const ep of runtimeMcpServers) {
2030
+ if (ep == null ? void 0 : ep.endpoint)
2031
+ byUrl.set(ep.endpoint, ep);
2032
+ }
2033
+ for (const ep of requestMcpServers) {
2034
+ if (ep == null ? void 0 : ep.endpoint)
2035
+ byUrl.set(ep.endpoint, ep);
2036
+ }
2037
+ return Array.from(byUrl.values());
2038
+ })();
2039
+ const allTools = [];
2040
+ for (const config of effectiveEndpoints) {
2041
+ const endpointUrl = config.endpoint;
2042
+ const cached = this.mcpToolsCache.get(endpointUrl);
2043
+ if (cached) {
2044
+ allTools.push(...cached);
2045
+ continue;
2046
+ }
2047
+ try {
2048
+ const client = await createMCPClient(config);
2049
+ const toolsMap = await client.tools();
2050
+ const toolDefs = Object.entries(toolsMap).map(([toolName, tool]) => {
2051
+ const params = extractParametersFromSchema(tool);
2052
+ const zodSchema = getZodParameters(params);
2053
+ return {
2054
+ name: toolName,
2055
+ description: tool.description || `MCP tool: ${toolName} (from ${endpointUrl})`,
2056
+ parameters: zodSchema
2057
+ };
2058
+ });
2059
+ this.mcpToolsCache.set(endpointUrl, toolDefs);
2060
+ allTools.push(...toolDefs);
2061
+ } catch (error) {
2062
+ console.error(`MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`, error);
2063
+ this.mcpToolsCache.set(endpointUrl, []);
2064
+ }
2065
+ }
2066
+ const dedupedByName = /* @__PURE__ */ new Map();
2067
+ for (const tool of allTools) {
2068
+ dedupedByName.set(tool.name, tool);
2069
+ }
2070
+ return Array.from(dedupedByName.values());
2071
+ }
2072
+ };
2073
+ __name(CopilotRuntime, "CopilotRuntime");
2074
+ function copilotKitEndpoint(config) {
2075
+ return {
2076
+ ...config,
2077
+ type: EndpointType.CopilotKit
2078
+ };
2079
+ }
2080
+ __name(copilotKitEndpoint, "copilotKitEndpoint");
2081
+ function langGraphPlatformEndpoint(config) {
2082
+ return {
2083
+ ...config,
2084
+ type: EndpointType.LangGraphPlatform
2085
+ };
2086
+ }
2087
+ __name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
2088
+ function resolveEndpointType(endpoint) {
2089
+ if (!endpoint.type) {
2090
+ if ("deploymentUrl" in endpoint && "agents" in endpoint) {
2091
+ return EndpointType.LangGraphPlatform;
2092
+ } else {
2093
+ return EndpointType.CopilotKit;
2094
+ }
2095
+ }
2096
+ return endpoint.type;
2097
+ }
2098
+ __name(resolveEndpointType, "resolveEndpointType");
2099
+
2100
+ // src/lib/telemetry-client.ts
2101
+ var packageJson = require_package();
2102
+ var telemetryClient = new TelemetryClient({
2103
+ packageName: packageJson.name,
2104
+ packageVersion: packageJson.version
2105
+ });
2106
+ function getRuntimeInstanceTelemetryInfo(options) {
2107
+ var _a, _b, _c, _d, _e;
2108
+ const runtime = options.runtime;
2109
+ const remoteEndpoints = ((_a = runtime.params) == null ? void 0 : _a.remoteEndpoints) ?? [];
2110
+ const endpointsInfo = remoteEndpoints.reduce((acc, endpoint) => {
2111
+ let info = {
2112
+ ...acc
2113
+ };
2114
+ const endpointType = resolveEndpointType(endpoint);
2115
+ if (!info.endpointTypes.includes(endpointType)) {
2116
+ info = {
2117
+ ...info,
2118
+ endpointTypes: [
2119
+ ...info.endpointTypes,
2120
+ endpointType
2121
+ ]
2122
+ };
2123
+ }
2124
+ if (endpointType === EndpointType.LangGraphPlatform) {
2125
+ const ep = endpoint;
2126
+ info = {
2127
+ ...info,
2128
+ agentsAmount: ep.agents.length,
2129
+ hashedKey: ep.langsmithApiKey ? createHash("sha256").update(ep.langsmithApiKey).digest("hex") : null
2130
+ };
2131
+ }
2132
+ return info;
2133
+ }, {
2134
+ endpointTypes: [],
2135
+ agentsAmount: null,
2136
+ hashedKey: null
2137
+ });
2138
+ const publicApiKey = (_b = options.cloud) == null ? void 0 : _b.publicApiKey;
2139
+ const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
2140
+ return {
2141
+ actionsAmount: ((_d = (_c = runtime.params) == null ? void 0 : _c.actions) == null ? void 0 : _d.length) ?? 0,
2142
+ endpointsAmount: remoteEndpoints.length,
2143
+ endpointTypes: endpointsInfo.endpointTypes,
2144
+ agentsAmount: Object.keys(runtime.instance.agents).length,
2145
+ hashedLgcKey: endpointsInfo.hashedKey,
2146
+ "cloud.api_key_provided": apiKeyProvided,
2147
+ ...apiKeyProvided ? {
2148
+ "cloud.public_api_key": publicApiKey
2149
+ } : {},
2150
+ ...((_e = options.cloud) == null ? void 0 : _e.baseUrl) ? {
2151
+ "cloud.base_url": options.cloud.baseUrl
2152
+ } : {}
2153
+ };
2154
+ }
2155
+ __name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
2156
+ var telemetry_client_default = telemetryClient;
2157
+
2158
+ // src/graphql/resolvers/copilot.resolver.ts
2159
+ import { randomId } from "@copilotkit/shared";
2160
+
2161
+ // src/graphql/types/agents-response.type.ts
2162
+ import { Field as Field16, ObjectType as ObjectType4 } from "type-graphql";
2163
+ function _ts_decorate16(decorators, target, key, desc) {
2164
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2165
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2166
+ r = Reflect.decorate(decorators, target, key, desc);
2167
+ else
2168
+ for (var i = decorators.length - 1; i >= 0; i--)
2169
+ if (d = decorators[i])
2170
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2171
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2172
+ }
2173
+ __name(_ts_decorate16, "_ts_decorate");
2174
+ function _ts_metadata16(k, v) {
2175
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2176
+ return Reflect.metadata(k, v);
2177
+ }
2178
+ __name(_ts_metadata16, "_ts_metadata");
2179
+ var Agent = class {
2180
+ id;
2181
+ name;
2182
+ description;
2183
+ };
2184
+ __name(Agent, "Agent");
2185
+ _ts_decorate16([
2186
+ Field16(() => String),
2187
+ _ts_metadata16("design:type", String)
2188
+ ], Agent.prototype, "id", void 0);
2189
+ _ts_decorate16([
2190
+ Field16(() => String),
2191
+ _ts_metadata16("design:type", String)
2192
+ ], Agent.prototype, "name", void 0);
2193
+ _ts_decorate16([
2194
+ Field16(() => String),
2195
+ _ts_metadata16("design:type", String)
2196
+ ], Agent.prototype, "description", void 0);
2197
+ Agent = _ts_decorate16([
2198
+ ObjectType4()
2199
+ ], Agent);
2200
+ var AgentsResponse = class {
2201
+ agents;
2202
+ };
2203
+ __name(AgentsResponse, "AgentsResponse");
2204
+ _ts_decorate16([
2205
+ Field16(() => [
2206
+ Agent
2207
+ ]),
2208
+ _ts_metadata16("design:type", Array)
2209
+ ], AgentsResponse.prototype, "agents", void 0);
2210
+ AgentsResponse = _ts_decorate16([
2211
+ ObjectType4()
2212
+ ], AgentsResponse);
2213
+
2214
+ // src/graphql/resolvers/copilot.resolver.ts
2215
+ import { CopilotKitError as CopilotKitError2, CopilotKitLowLevelError as CopilotKitLowLevelError2 } from "@copilotkit/shared";
2216
+ function _ts_decorate17(decorators, target, key, desc) {
2217
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2218
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2219
+ r = Reflect.decorate(decorators, target, key, desc);
2220
+ else
2221
+ for (var i = decorators.length - 1; i >= 0; i--)
2222
+ if (d = decorators[i])
2223
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2224
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2225
+ }
2226
+ __name(_ts_decorate17, "_ts_decorate");
2227
+ function _ts_metadata17(k, v) {
2228
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2229
+ return Reflect.metadata(k, v);
2230
+ }
2231
+ __name(_ts_metadata17, "_ts_metadata");
2232
+ function _ts_param(paramIndex, decorator) {
2233
+ return function(target, key) {
2234
+ decorator(target, key, paramIndex);
2235
+ };
2236
+ }
2237
+ __name(_ts_param, "_ts_param");
2238
+ var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
2239
+ var _a;
2240
+ if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
2241
+ const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
2242
+ role: m.textMessage.role,
2243
+ content: m.textMessage.content
2244
+ }));
2245
+ const lastMessage = messages[messages.length - 1];
2246
+ const restOfMessages = messages.slice(0, -1);
2247
+ const body = {
2248
+ input: lastMessage.content,
2249
+ validTopics: data.cloud.guardrails.inputValidationRules.allowList,
2250
+ invalidTopics: data.cloud.guardrails.inputValidationRules.denyList,
2251
+ messages: restOfMessages
2252
+ };
2253
+ const guardrailsResult = await fetch(`${baseUrl}/guardrails/validate`, {
2254
+ method: "POST",
2255
+ headers: {
2256
+ "Content-Type": "application/json",
2257
+ "X-CopilotCloud-Public-API-Key": copilotCloudPublicApiKey
2258
+ },
2259
+ body: JSON.stringify(body)
2260
+ });
2261
+ if (guardrailsResult.ok) {
2262
+ const resultJson = await guardrailsResult.json();
2263
+ onResult(resultJson);
2264
+ } else {
2265
+ onError(await guardrailsResult.json());
2266
+ }
2267
+ }
2268
+ }, "invokeGuardrails");
2269
+ var CopilotResolver = class {
2270
+ async hello() {
2271
+ return "Hello World";
2272
+ }
2273
+ async availableAgents(ctx) {
2274
+ let logger2 = ctx.logger.child({
2275
+ component: "CopilotResolver.availableAgents"
2276
+ });
2277
+ logger2.debug("Processing");
2278
+ const agentsWithEndpoints = [];
2279
+ logger2.debug("Event source created, creating response");
2280
+ return {
2281
+ agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
2282
+ };
2283
+ }
2284
+ async generateCopilotResponse(ctx, data, properties) {
2285
+ var _a, _b, _c, _d;
2286
+ telemetry_client_default.capture("oss.runtime.copilot_request_created", {
2287
+ "cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
2288
+ requestType: data.metadata.requestType,
2289
+ "cloud.api_key_provided": !!ctx.request.headers.get("x-copilotcloud-public-api-key"),
2290
+ ...ctx.request.headers.get("x-copilotcloud-public-api-key") ? {
2291
+ "cloud.public_api_key": ctx.request.headers.get("x-copilotcloud-public-api-key")
2292
+ } : {},
2293
+ ...ctx._copilotkit.baseUrl ? {
2294
+ "cloud.base_url": ctx._copilotkit.baseUrl
2295
+ } : {
2296
+ "cloud.base_url": "https://api.cloud.copilotkit.ai"
2297
+ }
2298
+ });
2299
+ let logger2 = ctx.logger.child({
2300
+ component: "CopilotResolver.generateCopilotResponse"
2301
+ });
2302
+ logger2.debug({
2303
+ data
2304
+ }, "Generating Copilot response");
2305
+ if (properties) {
2306
+ logger2.debug("Properties provided, merging with context properties");
2307
+ ctx.properties = {
2308
+ ...ctx.properties,
2309
+ ...properties
2310
+ };
2311
+ }
2312
+ const copilotRuntime = ctx._copilotkit.runtime;
2313
+ const serviceAdapter = ctx._copilotkit.serviceAdapter;
2314
+ let copilotCloudPublicApiKey = null;
2315
+ let copilotCloudBaseUrl;
2316
+ const publicApiKeyFromHeaders = ctx.request.headers.get("x-copilotcloud-public-api-key");
2317
+ if (publicApiKeyFromHeaders) {
2318
+ copilotCloudPublicApiKey = publicApiKeyFromHeaders;
2319
+ }
2320
+ if (data.cloud) {
2321
+ logger2 = logger2.child({
2322
+ cloud: true
2323
+ });
2324
+ logger2.debug("Cloud configuration provided, checking for public API key in headers");
2325
+ if (!copilotCloudPublicApiKey) {
2326
+ logger2.error("Public API key not found in headers");
2327
+ throw new GraphQLError("X-CopilotCloud-Public-API-Key header is required");
2328
+ }
2329
+ if (process.env.COPILOT_CLOUD_BASE_URL) {
2330
+ copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
2331
+ } else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
2332
+ copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
2333
+ } else {
2334
+ copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
2335
+ }
2336
+ logger2 = logger2.child({
2337
+ copilotCloudBaseUrl
2338
+ });
2339
+ }
2340
+ logger2.debug("Setting up subjects");
2341
+ const responseStatus$ = new ReplaySubject2();
2342
+ const interruptStreaming$ = new ReplaySubject2();
2343
+ const guardrailsResult$ = new ReplaySubject2();
2344
+ let outputMessages = [];
2345
+ let resolveOutputMessagesPromise;
2346
+ let rejectOutputMessagesPromise;
2347
+ const outputMessagesPromise = new Promise((resolve, reject) => {
2348
+ resolveOutputMessagesPromise = resolve;
2349
+ rejectOutputMessagesPromise = reject;
2350
+ });
2351
+ if (copilotCloudPublicApiKey) {
2352
+ ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
2353
+ }
2354
+ logger2.debug("Processing");
2355
+ let runtimeResponse;
2356
+ const { eventSource, threadId = randomId(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
2357
+ logger2.debug("Event source created, creating response");
2358
+ const eventStream = eventSource.processRuntimeEvents({
2359
+ serverSideActions,
2360
+ guardrailsResult$: ((_d = data.cloud) == null ? void 0 : _d.guardrails) ? guardrailsResult$ : null,
2361
+ actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
2362
+ // TODO-AGENTS: do not exclude ALL server side actions
2363
+ (action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
2364
+ ),
2365
+ threadId
2366
+ }).pipe(
2367
+ // shareReplay() ensures that later subscribers will see the whole stream instead of
2368
+ // just the events that were emitted after the subscriber was added.
2369
+ shareReplay(),
2370
+ finalize(() => {
2371
+ logger2.debug("Event stream finalized");
2372
+ })
2373
+ );
2374
+ const response = {
2375
+ threadId,
2376
+ runId,
2377
+ status: firstValueFrom(responseStatus$),
2378
+ extensions,
2379
+ metaEvents: new Repeater(async (push, stop) => {
2380
+ let eventStreamSubscription;
2381
+ eventStreamSubscription = eventStream.subscribe({
2382
+ next: async (event) => {
2383
+ if (event.type != RuntimeEventTypes.MetaEvent) {
2384
+ return;
2385
+ }
2386
+ switch (event.name) {
2387
+ case LangGraphEventTypes.OnInterrupt:
2388
+ push(plainToInstance(LangGraphInterruptEvent, {
2389
+ // @ts-ignore
2390
+ type: event.type,
2391
+ // @ts-ignore
2392
+ name: RuntimeMetaEventName.LangGraphInterruptEvent,
2393
+ // @ts-ignore
2394
+ value: event.value
2395
+ }));
2396
+ break;
2397
+ case RuntimeMetaEventName.LangGraphInterruptEvent:
2398
+ push(plainToInstance(LangGraphInterruptEvent, {
2399
+ type: event.type,
2400
+ name: event.name,
2401
+ value: event.value
2402
+ }));
2403
+ break;
2404
+ case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
2405
+ push(plainToInstance(CopilotKitLangGraphInterruptEvent, {
2406
+ type: event.type,
2407
+ name: event.name,
2408
+ data: {
2409
+ value: event.data.value,
2410
+ messages: event.data.messages.map((message) => {
2411
+ if (message.type === "TextMessage" || "content" in message && "role" in message) {
2412
+ return plainToInstance(TextMessage, {
2413
+ id: message.id,
2414
+ createdAt: /* @__PURE__ */ new Date(),
2415
+ content: [
2416
+ message.content
2417
+ ],
2418
+ role: message.role,
2419
+ status: new SuccessMessageStatus()
2420
+ });
2421
+ }
2422
+ if ("arguments" in message) {
2423
+ return plainToInstance(ActionExecutionMessage, {
2424
+ name: message.name,
2425
+ id: message.id,
2426
+ arguments: [
2427
+ JSON.stringify(message.arguments)
2428
+ ],
2429
+ createdAt: /* @__PURE__ */ new Date(),
2430
+ status: new SuccessMessageStatus()
2431
+ });
2432
+ }
2433
+ throw new Error("Unknown message in metaEvents copilot resolver");
2434
+ })
2435
+ }
2436
+ }));
2437
+ break;
2438
+ }
2439
+ },
2440
+ error: (err) => {
2441
+ var _a2, _b2;
2442
+ if (((_a2 = err == null ? void 0 : err.name) == null ? void 0 : _a2.includes("CopilotKit")) || ((_b2 = err == null ? void 0 : err.extensions) == null ? void 0 : _b2.visibility)) {
2443
+ responseStatus$.next(new UnknownErrorResponse({
2444
+ description: err.message || "Agent error occurred"
2445
+ }));
2446
+ } else {
2447
+ responseStatus$.next(new UnknownErrorResponse({
2448
+ description: `An unknown error has occurred in the event stream`
2449
+ }));
2450
+ }
2451
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2452
+ stop();
2453
+ },
2454
+ complete: async () => {
2455
+ logger2.debug("Meta events stream completed");
2456
+ responseStatus$.next(new SuccessResponseStatus());
2457
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2458
+ stop();
2459
+ }
2460
+ });
2461
+ }),
2462
+ messages: new Repeater(async (pushMessage, stopStreamingMessages) => {
2463
+ var _a2;
2464
+ logger2.debug("Messages repeater created");
2465
+ if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
2466
+ logger2 = logger2.child({
2467
+ guardrails: true
2468
+ });
2469
+ logger2.debug("Guardrails is enabled, validating input");
2470
+ invokeGuardrails({
2471
+ baseUrl: copilotCloudBaseUrl,
2472
+ copilotCloudPublicApiKey,
2473
+ data,
2474
+ onResult: (result) => {
2475
+ logger2.debug({
2476
+ status: result.status
2477
+ }, "Guardrails validation done");
2478
+ guardrailsResult$.next(result);
2479
+ if (result.status === "denied") {
2480
+ responseStatus$.next(new GuardrailsValidationFailureResponse({
2481
+ guardrailsReason: result.reason
2482
+ }));
2483
+ interruptStreaming$.next({
2484
+ reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
2485
+ });
2486
+ outputMessages = [
2487
+ plainToInstance(TextMessage, {
2488
+ id: randomId(),
2489
+ createdAt: /* @__PURE__ */ new Date(),
2490
+ content: result.reason,
2491
+ role: MessageRole.assistant
2492
+ })
2493
+ ];
2494
+ resolveOutputMessagesPromise(outputMessages);
2495
+ }
2496
+ },
2497
+ onError: (err) => {
2498
+ logger2.error({
2499
+ err
2500
+ }, "Error in guardrails validation");
2501
+ responseStatus$.next(new UnknownErrorResponse({
2502
+ description: `An unknown error has occurred in the guardrails validation`
2503
+ }));
2504
+ interruptStreaming$.next({
2505
+ reason: `Interrupted due to unknown error in guardrails validation`
2506
+ });
2507
+ rejectOutputMessagesPromise(err);
2508
+ }
2509
+ });
2510
+ }
2511
+ let eventStreamSubscription;
2512
+ logger2.debug("Event stream created, subscribing to event stream");
2513
+ eventStreamSubscription = eventStream.subscribe({
2514
+ next: async (event) => {
2515
+ switch (event.type) {
2516
+ case RuntimeEventTypes.MetaEvent:
2517
+ break;
2518
+ case RuntimeEventTypes.TextMessageStart:
2519
+ const textMessageContentStream = eventStream.pipe(
2520
+ // skip until this message start event
2521
+ skipWhile((e) => e !== event),
2522
+ // take until the message end event
2523
+ takeWhile((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
2524
+ // filter out any other message events or message ids
2525
+ filter((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
2526
+ );
2527
+ const streamingTextStatus = new Subject();
2528
+ const messageId = event.messageId;
2529
+ pushMessage({
2530
+ id: messageId,
2531
+ parentMessageId: event.parentMessageId,
2532
+ status: firstValueFrom(streamingTextStatus),
2533
+ createdAt: /* @__PURE__ */ new Date(),
2534
+ role: MessageRole.assistant,
2535
+ content: new Repeater(async (pushTextChunk, stopStreamingText) => {
2536
+ logger2.debug("Text message content repeater created");
2537
+ const textChunks = [];
2538
+ let textSubscription;
2539
+ interruptStreaming$.pipe(shareReplay(), take(1), tap(({ reason, messageId: messageId2 }) => {
2540
+ logger2.debug({
2541
+ reason,
2542
+ messageId: messageId2
2543
+ }, "Text streaming interrupted");
2544
+ streamingTextStatus.next(plainToInstance(FailedMessageStatus, {
2545
+ reason
2546
+ }));
2547
+ responseStatus$.next(new MessageStreamInterruptedResponse({
2548
+ messageId: messageId2
2549
+ }));
2550
+ stopStreamingText();
2551
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2552
+ })).subscribe();
2553
+ logger2.debug("Subscribing to text message content stream");
2554
+ textSubscription = textMessageContentStream.subscribe({
2555
+ next: async (e) => {
2556
+ if (e.type == RuntimeEventTypes.TextMessageContent) {
2557
+ await pushTextChunk(e.content);
2558
+ textChunks.push(e.content);
2559
+ }
2560
+ },
2561
+ error: (err) => {
2562
+ logger2.error({
2563
+ err
2564
+ }, "Error in text message content stream");
2565
+ interruptStreaming$.next({
2566
+ reason: "Error streaming message content",
2567
+ messageId
2568
+ });
2569
+ stopStreamingText();
2570
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2571
+ },
2572
+ complete: () => {
2573
+ logger2.debug("Text message content stream completed");
2574
+ streamingTextStatus.next(new SuccessMessageStatus());
2575
+ stopStreamingText();
2576
+ textSubscription == null ? void 0 : textSubscription.unsubscribe();
2577
+ outputMessages.push(plainToInstance(TextMessage, {
2578
+ id: messageId,
2579
+ createdAt: /* @__PURE__ */ new Date(),
2580
+ content: textChunks.join(""),
2581
+ role: MessageRole.assistant
2582
+ }));
2583
+ }
2584
+ });
2585
+ })
2586
+ });
2587
+ break;
2588
+ case RuntimeEventTypes.ActionExecutionStart:
2589
+ logger2.debug("Action execution start event received");
2590
+ const actionExecutionArgumentStream = eventStream.pipe(
2591
+ skipWhile((e) => e !== event),
2592
+ // take until the action execution end event
2593
+ takeWhile((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
2594
+ // filter out any other action execution events or action execution ids
2595
+ filter((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
2596
+ );
2597
+ const streamingArgumentsStatus = new Subject();
2598
+ pushMessage({
2599
+ id: event.actionExecutionId,
2600
+ parentMessageId: event.parentMessageId,
2601
+ status: firstValueFrom(streamingArgumentsStatus),
2602
+ createdAt: /* @__PURE__ */ new Date(),
2603
+ name: event.actionName,
2604
+ arguments: new Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
2605
+ logger2.debug("Action execution argument stream created");
2606
+ const argumentChunks = [];
2607
+ let actionExecutionArgumentSubscription;
2608
+ actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
2609
+ next: async (e) => {
2610
+ if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
2611
+ await pushArgumentsChunk(e.args);
2612
+ argumentChunks.push(e.args);
2613
+ }
2614
+ },
2615
+ error: (err) => {
2616
+ logger2.error({
2617
+ err
2618
+ }, "Error in action execution argument stream");
2619
+ streamingArgumentsStatus.next(plainToInstance(FailedMessageStatus, {
2620
+ reason: "An unknown error has occurred in the action execution argument stream"
2621
+ }));
2622
+ stopStreamingArguments();
2623
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
2624
+ },
2625
+ complete: () => {
2626
+ logger2.debug("Action execution argument stream completed");
2627
+ streamingArgumentsStatus.next(new SuccessMessageStatus());
2628
+ stopStreamingArguments();
2629
+ actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
2630
+ outputMessages.push(plainToInstance(ActionExecutionMessage, {
2631
+ id: event.actionExecutionId,
2632
+ createdAt: /* @__PURE__ */ new Date(),
2633
+ name: event.actionName,
2634
+ arguments: argumentChunks.join("")
2635
+ }));
2636
+ }
2637
+ });
2638
+ })
2639
+ });
2640
+ break;
2641
+ case RuntimeEventTypes.ActionExecutionResult:
2642
+ logger2.debug({
2643
+ result: event.result
2644
+ }, "Action execution result event received");
2645
+ pushMessage({
2646
+ id: "result-" + event.actionExecutionId,
2647
+ status: new SuccessMessageStatus(),
2648
+ createdAt: /* @__PURE__ */ new Date(),
2649
+ actionExecutionId: event.actionExecutionId,
2650
+ actionName: event.actionName,
2651
+ result: event.result
2652
+ });
2653
+ outputMessages.push(plainToInstance(ResultMessage, {
2654
+ id: "result-" + event.actionExecutionId,
2655
+ createdAt: /* @__PURE__ */ new Date(),
2656
+ actionExecutionId: event.actionExecutionId,
2657
+ actionName: event.actionName,
2658
+ result: event.result
2659
+ }));
2660
+ break;
2661
+ case RuntimeEventTypes.AgentStateMessage:
2662
+ logger2.debug({
2663
+ event
2664
+ }, "Agent message event received");
2665
+ pushMessage({
2666
+ id: randomId(),
2667
+ status: new SuccessMessageStatus(),
2668
+ threadId: event.threadId,
2669
+ agentName: event.agentName,
2670
+ nodeName: event.nodeName,
2671
+ runId: event.runId,
2672
+ active: event.active,
2673
+ state: event.state,
2674
+ running: event.running,
2675
+ role: MessageRole.assistant,
2676
+ createdAt: /* @__PURE__ */ new Date()
2677
+ });
2678
+ outputMessages.push(plainToInstance(AgentStateMessage, {
2679
+ id: randomId(),
2680
+ threadId: event.threadId,
2681
+ agentName: event.agentName,
2682
+ nodeName: event.nodeName,
2683
+ runId: event.runId,
2684
+ active: event.active,
2685
+ state: event.state,
2686
+ running: event.running,
2687
+ role: MessageRole.assistant,
2688
+ createdAt: /* @__PURE__ */ new Date()
2689
+ }));
2690
+ break;
2691
+ }
2692
+ },
2693
+ error: (err) => {
2694
+ var _a3, _b2, _c2, _d2, _e, _f;
2695
+ if (err instanceof CopilotKitError2 || err instanceof CopilotKitLowLevelError2 || err instanceof Error && err.name && err.name.includes("CopilotKit") || ((_a3 = err == null ? void 0 : err.extensions) == null ? void 0 : _a3.visibility)) {
2696
+ responseStatus$.next(new UnknownErrorResponse({
2697
+ description: err.message || "Agent error occurred",
2698
+ // Include original error information for frontend to extract
2699
+ originalError: {
2700
+ code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
2701
+ statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
2702
+ severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
2703
+ visibility: err.visibility || ((_e = err.extensions) == null ? void 0 : _e.visibility),
2704
+ originalErrorType: err.originalErrorType || ((_f = err.extensions) == null ? void 0 : _f.originalErrorType),
2705
+ extensions: err.extensions
2706
+ }
2707
+ }));
2708
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2709
+ rejectOutputMessagesPromise(err);
2710
+ stopStreamingMessages();
2711
+ return;
2712
+ }
2713
+ responseStatus$.next(new UnknownErrorResponse({
2714
+ description: `An unknown error has occurred in the event stream`
2715
+ }));
2716
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2717
+ stopStreamingMessages();
2718
+ rejectOutputMessagesPromise(err);
2719
+ },
2720
+ complete: async () => {
2721
+ var _a3;
2722
+ logger2.debug("Event stream completed");
2723
+ if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
2724
+ logger2.debug("Guardrails is enabled, waiting for guardrails result");
2725
+ await firstValueFrom(guardrailsResult$);
2726
+ }
2727
+ responseStatus$.next(new SuccessResponseStatus());
2728
+ eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
2729
+ stopStreamingMessages();
2730
+ resolveOutputMessagesPromise(outputMessages);
2731
+ }
2732
+ });
2733
+ })
2734
+ };
2735
+ return response;
2736
+ }
2737
+ };
2738
+ __name(CopilotResolver, "CopilotResolver");
2739
+ _ts_decorate17([
2740
+ Query(() => String),
2741
+ _ts_metadata17("design:type", Function),
2742
+ _ts_metadata17("design:paramtypes", []),
2743
+ _ts_metadata17("design:returntype", Promise)
2744
+ ], CopilotResolver.prototype, "hello", null);
2745
+ _ts_decorate17([
2746
+ Query(() => AgentsResponse),
2747
+ _ts_param(0, Ctx()),
2748
+ _ts_metadata17("design:type", Function),
2749
+ _ts_metadata17("design:paramtypes", [
2750
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext
2751
+ ]),
2752
+ _ts_metadata17("design:returntype", Promise)
2753
+ ], CopilotResolver.prototype, "availableAgents", null);
2754
+ _ts_decorate17([
2755
+ Mutation(() => CopilotResponse),
2756
+ _ts_param(0, Ctx()),
2757
+ _ts_param(1, Arg("data")),
2758
+ _ts_param(2, Arg("properties", () => GraphQLJSONObject, {
2759
+ nullable: true
2760
+ })),
2761
+ _ts_metadata17("design:type", Function),
2762
+ _ts_metadata17("design:paramtypes", [
2763
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
2764
+ typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
2765
+ typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
2766
+ ]),
2767
+ _ts_metadata17("design:returntype", Promise)
2768
+ ], CopilotResolver.prototype, "generateCopilotResponse", null);
2769
+ CopilotResolver = _ts_decorate17([
2770
+ Resolver(() => CopilotResponse)
2771
+ ], CopilotResolver);
2772
+
2773
+ // src/lib/integrations/shared.ts
2774
+ import { useDeferStream } from "@graphql-yoga/plugin-defer-stream";
2775
+
2776
+ // src/lib/logger.ts
2777
+ import createPinoLogger from "pino";
2778
+ import pretty from "pino-pretty";
2779
+ function createLogger(options) {
2780
+ const { level, component } = options || {};
2781
+ const stream = pretty({
2782
+ colorize: true
2783
+ });
2784
+ const logger2 = createPinoLogger({
2785
+ level: process.env.LOG_LEVEL || level || "error",
2786
+ redact: {
2787
+ paths: [
2788
+ "pid",
2789
+ "hostname"
2790
+ ],
2791
+ remove: true
2792
+ }
2793
+ }, stream);
2794
+ if (component) {
2795
+ return logger2.child({
2796
+ component
2797
+ });
2798
+ } else {
2799
+ return logger2;
2800
+ }
2801
+ }
2802
+ __name(createLogger, "createLogger");
2803
+
2804
+ // src/graphql/resolvers/state.resolver.ts
2805
+ import { Arg as Arg2, Resolver as Resolver2 } from "type-graphql";
2806
+ import { Ctx as Ctx2 } from "type-graphql";
2807
+ import { Query as Query2 } from "type-graphql";
2808
+
2809
+ // src/graphql/types/load-agent-state-response.type.ts
2810
+ import { Field as Field17, ObjectType as ObjectType5 } from "type-graphql";
2811
+ function _ts_decorate18(decorators, target, key, desc) {
2812
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2813
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2814
+ r = Reflect.decorate(decorators, target, key, desc);
2815
+ else
2816
+ for (var i = decorators.length - 1; i >= 0; i--)
2817
+ if (d = decorators[i])
2818
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2819
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2820
+ }
2821
+ __name(_ts_decorate18, "_ts_decorate");
2822
+ function _ts_metadata18(k, v) {
2823
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2824
+ return Reflect.metadata(k, v);
2825
+ }
2826
+ __name(_ts_metadata18, "_ts_metadata");
2827
+ var LoadAgentStateResponse = class {
2828
+ threadId;
2829
+ threadExists;
2830
+ state;
2831
+ messages;
2832
+ };
2833
+ __name(LoadAgentStateResponse, "LoadAgentStateResponse");
2834
+ _ts_decorate18([
2835
+ Field17(() => String),
2836
+ _ts_metadata18("design:type", String)
2837
+ ], LoadAgentStateResponse.prototype, "threadId", void 0);
2838
+ _ts_decorate18([
2839
+ Field17(() => Boolean),
2840
+ _ts_metadata18("design:type", Boolean)
2841
+ ], LoadAgentStateResponse.prototype, "threadExists", void 0);
2842
+ _ts_decorate18([
2843
+ Field17(() => String),
2844
+ _ts_metadata18("design:type", String)
2845
+ ], LoadAgentStateResponse.prototype, "state", void 0);
2846
+ _ts_decorate18([
2847
+ Field17(() => String),
2848
+ _ts_metadata18("design:type", String)
2849
+ ], LoadAgentStateResponse.prototype, "messages", void 0);
2850
+ LoadAgentStateResponse = _ts_decorate18([
2851
+ ObjectType5()
2852
+ ], LoadAgentStateResponse);
2853
+
2854
+ // src/graphql/inputs/load-agent-state.input.ts
2855
+ import { Field as Field18, InputType as InputType13 } from "type-graphql";
2856
+ function _ts_decorate19(decorators, target, key, desc) {
2857
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2858
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2859
+ r = Reflect.decorate(decorators, target, key, desc);
2860
+ else
2861
+ for (var i = decorators.length - 1; i >= 0; i--)
2862
+ if (d = decorators[i])
2863
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2864
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2865
+ }
2866
+ __name(_ts_decorate19, "_ts_decorate");
2867
+ function _ts_metadata19(k, v) {
2868
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2869
+ return Reflect.metadata(k, v);
2870
+ }
2871
+ __name(_ts_metadata19, "_ts_metadata");
2872
+ var LoadAgentStateInput = class {
2873
+ threadId;
2874
+ agentName;
2875
+ };
2876
+ __name(LoadAgentStateInput, "LoadAgentStateInput");
2877
+ _ts_decorate19([
2878
+ Field18(() => String),
2879
+ _ts_metadata19("design:type", String)
2880
+ ], LoadAgentStateInput.prototype, "threadId", void 0);
2881
+ _ts_decorate19([
2882
+ Field18(() => String),
2883
+ _ts_metadata19("design:type", String)
2884
+ ], LoadAgentStateInput.prototype, "agentName", void 0);
2885
+ LoadAgentStateInput = _ts_decorate19([
2886
+ InputType13()
2887
+ ], LoadAgentStateInput);
2888
+
2889
+ // src/graphql/resolvers/state.resolver.ts
2890
+ import { CopilotKitAgentDiscoveryError } from "@copilotkit/shared";
2891
+ function _ts_decorate20(decorators, target, key, desc) {
2892
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2893
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2894
+ r = Reflect.decorate(decorators, target, key, desc);
2895
+ else
2896
+ for (var i = decorators.length - 1; i >= 0; i--)
2897
+ if (d = decorators[i])
2898
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2899
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2900
+ }
2901
+ __name(_ts_decorate20, "_ts_decorate");
2902
+ function _ts_metadata20(k, v) {
2903
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
2904
+ return Reflect.metadata(k, v);
2905
+ }
2906
+ __name(_ts_metadata20, "_ts_metadata");
2907
+ function _ts_param2(paramIndex, decorator) {
2908
+ return function(target, key) {
2909
+ decorator(target, key, paramIndex);
2910
+ };
2911
+ }
2912
+ __name(_ts_param2, "_ts_param");
2913
+ var StateResolver = class {
2914
+ async loadAgentState(ctx, data) {
2915
+ const agents = [];
2916
+ const hasAgent = agents.some((agent) => agent.name === data.agentName);
2917
+ if (!hasAgent) {
2918
+ throw new CopilotKitAgentDiscoveryError({
2919
+ agentName: data.agentName,
2920
+ availableAgents: agents.map((a) => ({
2921
+ name: a.name,
2922
+ id: a.name
2923
+ }))
2924
+ });
2925
+ }
2926
+ const state = {};
2927
+ return state;
2928
+ }
2929
+ };
2930
+ __name(StateResolver, "StateResolver");
2931
+ _ts_decorate20([
2932
+ Query2(() => LoadAgentStateResponse),
2933
+ _ts_param2(0, Ctx2()),
2934
+ _ts_param2(1, Arg2("data")),
2935
+ _ts_metadata20("design:type", Function),
2936
+ _ts_metadata20("design:paramtypes", [
2937
+ typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
2938
+ typeof LoadAgentStateInput === "undefined" ? Object : LoadAgentStateInput
2939
+ ]),
2940
+ _ts_metadata20("design:returntype", Promise)
2941
+ ], StateResolver.prototype, "loadAgentState", null);
2942
+ StateResolver = _ts_decorate20([
2943
+ Resolver2(() => LoadAgentStateResponse)
2944
+ ], StateResolver);
2945
+
2946
+ // src/lib/integrations/shared.ts
2947
+ var packageJson2 = __toESM(require_package());
2948
+ import { CopilotKitError as CopilotKitError3, CopilotKitErrorCode as CopilotKitErrorCode2 } from "@copilotkit/shared";
2949
+ var logger = createLogger();
2950
+ var addCustomHeaderPlugin = {
2951
+ onResponse({ response }) {
2952
+ response.headers.set("X-CopilotKit-Runtime-Version", packageJson2.version);
2953
+ }
2954
+ };
2955
+ async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
2956
+ logger.debug({
2957
+ copilotKitContext
2958
+ }, "Creating GraphQL context");
2959
+ const ctx = {
2960
+ ...initialContext,
2961
+ _copilotkit: {
2962
+ ...copilotKitContext
2963
+ },
2964
+ properties: {
2965
+ ...properties
2966
+ },
2967
+ logger: contextLogger
2968
+ };
2969
+ return ctx;
2970
+ }
2971
+ __name(createContext, "createContext");
2972
+ function buildSchema(options = {}) {
2973
+ logger.debug("Building GraphQL schema...");
2974
+ const schema = buildSchemaSync({
2975
+ resolvers: [
2976
+ CopilotResolver,
2977
+ StateResolver
2978
+ ],
2979
+ emitSchemaFile: options.emitSchemaFile
2980
+ });
2981
+ logger.debug("GraphQL schema built successfully");
2982
+ return schema;
2983
+ }
2984
+ __name(buildSchema, "buildSchema");
2985
+ function getCommonConfig(options) {
2986
+ var _a;
2987
+ const logLevel = process.env.LOG_LEVEL || options.logLevel || "error";
2988
+ const logger2 = createLogger({
2989
+ level: logLevel,
2990
+ component: "getCommonConfig"
2991
+ });
2992
+ const contextLogger = createLogger({
2993
+ level: logLevel
2994
+ });
2995
+ if (options.cloud) {
2996
+ telemetry_client_default.setCloudConfiguration({
2997
+ publicApiKey: options.cloud.publicApiKey,
2998
+ baseUrl: options.cloud.baseUrl
2999
+ });
3000
+ }
3001
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
3002
+ telemetry_client_default.setGlobalProperties({
3003
+ _copilotkit: {
3004
+ ...options.properties._copilotkit
3005
+ }
3006
+ });
3007
+ }
3008
+ telemetry_client_default.setGlobalProperties({
3009
+ runtime: {
3010
+ serviceAdapter: options.serviceAdapter.constructor.name
3011
+ }
3012
+ });
3013
+ const userErrorCodes = [
3014
+ CopilotKitErrorCode2.AGENT_NOT_FOUND,
3015
+ CopilotKitErrorCode2.API_NOT_FOUND,
3016
+ CopilotKitErrorCode2.REMOTE_ENDPOINT_NOT_FOUND,
3017
+ CopilotKitErrorCode2.CONFIGURATION_ERROR,
3018
+ CopilotKitErrorCode2.MISSING_PUBLIC_API_KEY_ERROR
3019
+ ];
3020
+ return {
3021
+ logging: createLogger({
3022
+ component: "Yoga GraphQL",
3023
+ level: logLevel
3024
+ }),
3025
+ schema: buildSchema(),
3026
+ plugins: [
3027
+ useDeferStream(),
3028
+ addCustomHeaderPlugin
3029
+ ],
3030
+ context: (ctx) => createContext(ctx, options, contextLogger, options.properties),
3031
+ // Suppress logging for user configuration errors
3032
+ maskedErrors: {
3033
+ maskError: (error, message, isDev) => {
3034
+ const originalError = error.originalError || error;
3035
+ const extensions = error.extensions;
3036
+ const errorCode = extensions == null ? void 0 : extensions.code;
3037
+ if (errorCode && userErrorCodes.includes(errorCode)) {
3038
+ console.debug("User configuration error:", error.message);
3039
+ return error;
3040
+ }
3041
+ if (originalError instanceof CopilotKitError3 && userErrorCodes.includes(originalError.code)) {
3042
+ console.debug("User configuration error:", error.message);
3043
+ return error;
3044
+ }
3045
+ console.error("Application error:", error);
3046
+ return error;
3047
+ }
3048
+ }
3049
+ };
3050
+ }
3051
+ __name(getCommonConfig, "getCommonConfig");
3052
+
3053
+ // src/lib/integrations/node-http/index.ts
3054
+ import { createCopilotEndpointSingleRouteExpress } from "@copilotkitnext/runtime/express";
3055
+ function copilotRuntimeNodeHttpEndpoint(options) {
3056
+ var _a;
3057
+ const commonConfig = getCommonConfig(options);
3058
+ telemetry_client_default.setGlobalProperties({
3059
+ runtime: {
3060
+ framework: "node-http"
3061
+ }
3062
+ });
3063
+ if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
3064
+ telemetry_client_default.setGlobalProperties({
3065
+ _copilotkit: options.properties._copilotkit
3066
+ });
3067
+ }
3068
+ telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
3069
+ const logger2 = commonConfig.logging;
3070
+ logger2.debug("Creating Node HTTP endpoint");
3071
+ const serviceAdapter = options.serviceAdapter;
3072
+ options.runtime.handleServiceAdapter(serviceAdapter);
3073
+ return createCopilotEndpointSingleRouteExpress({
3074
+ runtime: options.runtime.instance,
3075
+ basePath: options.baseUrl ?? options.endpoint
3076
+ });
3077
+ }
3078
+ __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
3079
+
3080
+ export {
3081
+ extractParametersFromSchema,
3082
+ convertMCPToolsToActions,
3083
+ generateMcpToolInstructions,
3084
+ LangGraphHttpAgent,
3085
+ CustomEventNames2 as CustomEventNames,
3086
+ LangGraphAgent,
3087
+ CopilotRuntime,
3088
+ copilotKitEndpoint,
3089
+ langGraphPlatformEndpoint,
3090
+ resolveEndpointType,
3091
+ getRuntimeInstanceTelemetryInfo,
3092
+ telemetry_client_default,
3093
+ createLogger,
3094
+ addCustomHeaderPlugin,
3095
+ createContext,
3096
+ buildSchema,
3097
+ getCommonConfig,
3098
+ copilotRuntimeNodeHttpEndpoint
3099
+ };
3100
+ //# sourceMappingURL=chunk-4OGE3SLW.mjs.map