@copilotkit/runtime 1.50.0 → 1.50.1-next.1

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