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