@copilotkit/runtime 1.50.0-beta.9 → 1.50.0

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