@copilotkit/runtime 1.50.0-beta.8 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +168 -0
- package/dist/chunk-27JKTS6P.mjs +1704 -0
- package/dist/chunk-27JKTS6P.mjs.map +1 -0
- package/dist/chunk-2GPTVDTO.mjs +25 -0
- package/dist/chunk-2GPTVDTO.mjs.map +1 -0
- package/dist/chunk-2OZAGFV3.mjs +43 -0
- package/dist/chunk-2OZAGFV3.mjs.map +1 -0
- package/dist/chunk-3AJVKDZX.mjs +3097 -0
- package/dist/chunk-3AJVKDZX.mjs.map +1 -0
- package/dist/chunk-45RCC3ZS.mjs +25 -0
- package/dist/chunk-45RCC3ZS.mjs.map +1 -0
- package/dist/chunk-4EHJ4XFJ.mjs +25 -0
- package/dist/chunk-4EHJ4XFJ.mjs.map +1 -0
- package/dist/chunk-4IANB4TC.mjs +25 -0
- package/dist/chunk-4IANB4TC.mjs.map +1 -0
- package/dist/chunk-4KES76K3.mjs +74 -0
- package/dist/chunk-4KES76K3.mjs.map +1 -0
- package/dist/chunk-4OGE3SLW.mjs +3100 -0
- package/dist/chunk-4OGE3SLW.mjs.map +1 -0
- package/dist/chunk-54YJBMCP.mjs +3097 -0
- package/dist/chunk-54YJBMCP.mjs.map +1 -0
- package/dist/chunk-62NE5S6M.mjs +226 -0
- package/dist/chunk-62NE5S6M.mjs.map +1 -0
- package/dist/chunk-6ER4SZYH.mjs +74 -0
- package/dist/chunk-6ER4SZYH.mjs.map +1 -0
- package/dist/chunk-6TNSLHVR.mjs +74 -0
- package/dist/chunk-6TNSLHVR.mjs.map +1 -0
- package/dist/chunk-6XRUR5UK.mjs +1 -0
- package/dist/chunk-6XRUR5UK.mjs.map +1 -0
- package/dist/chunk-7V4BK7TZ.mjs +25 -0
- package/dist/chunk-7V4BK7TZ.mjs.map +1 -0
- package/dist/chunk-7YZIEXD2.mjs +74 -0
- package/dist/chunk-7YZIEXD2.mjs.map +1 -0
- package/dist/chunk-A4XHOAFU.mjs +25 -0
- package/dist/chunk-A4XHOAFU.mjs.map +1 -0
- package/dist/chunk-A555KEAD.mjs +6020 -0
- package/dist/chunk-A555KEAD.mjs.map +1 -0
- package/dist/chunk-AF73TFTX.mjs +74 -0
- package/dist/chunk-AF73TFTX.mjs.map +1 -0
- package/dist/chunk-AMUJQ6IR.mjs +50 -0
- package/dist/chunk-AMUJQ6IR.mjs.map +1 -0
- package/dist/chunk-AQG2SVCA.mjs +25 -0
- package/dist/chunk-AQG2SVCA.mjs.map +1 -0
- package/dist/chunk-BJZHMXND.mjs +74 -0
- package/dist/chunk-BJZHMXND.mjs.map +1 -0
- package/dist/chunk-CB2OJXF6.mjs +25 -0
- package/dist/chunk-CB2OJXF6.mjs.map +1 -0
- package/dist/chunk-CEOMFPJU.mjs +6020 -0
- package/dist/chunk-CEOMFPJU.mjs.map +1 -0
- package/dist/chunk-CZVLR7CC.mjs +175 -0
- package/dist/chunk-CZVLR7CC.mjs.map +1 -0
- package/dist/chunk-DCEEHMLJ.mjs +1127 -0
- package/dist/chunk-DCEEHMLJ.mjs.map +1 -0
- package/dist/chunk-DE3CLKUG.mjs +25 -0
- package/dist/chunk-DE3CLKUG.mjs.map +1 -0
- package/dist/chunk-DTPRUTNV.mjs +25 -0
- package/dist/chunk-DTPRUTNV.mjs.map +1 -0
- package/dist/chunk-ERUOA47O.mjs +626 -0
- package/dist/chunk-ERUOA47O.mjs.map +1 -0
- package/dist/chunk-ESSRC64W.mjs +74 -0
- package/dist/chunk-ESSRC64W.mjs.map +1 -0
- package/dist/chunk-FHD4JECV.mjs +33 -0
- package/dist/chunk-FHD4JECV.mjs.map +1 -0
- package/dist/chunk-GRAN6K6N.mjs +25 -0
- package/dist/chunk-GRAN6K6N.mjs.map +1 -0
- package/dist/chunk-I27F2UPA.mjs +175 -0
- package/dist/chunk-I27F2UPA.mjs.map +1 -0
- package/dist/chunk-IAZKTOQW.mjs +25 -0
- package/dist/chunk-IAZKTOQW.mjs.map +1 -0
- package/dist/chunk-J6XZ5MFB.mjs +25 -0
- package/dist/chunk-J6XZ5MFB.mjs.map +1 -0
- package/dist/chunk-JJ32MA4C.mjs +73 -0
- package/dist/chunk-JJ32MA4C.mjs.map +1 -0
- package/dist/chunk-JJY4ZTHQ.mjs +25 -0
- package/dist/chunk-JJY4ZTHQ.mjs.map +1 -0
- package/dist/chunk-KEYLBFU2.mjs +3117 -0
- package/dist/chunk-KEYLBFU2.mjs.map +1 -0
- package/dist/chunk-KQ53L4WZ.mjs +3094 -0
- package/dist/chunk-KQ53L4WZ.mjs.map +1 -0
- package/dist/chunk-KTELVQ67.mjs +3098 -0
- package/dist/chunk-KTELVQ67.mjs.map +1 -0
- package/dist/chunk-LPEPX6NH.mjs +25 -0
- package/dist/chunk-LPEPX6NH.mjs.map +1 -0
- package/dist/chunk-MDXE55DK.mjs +3117 -0
- package/dist/chunk-MDXE55DK.mjs.map +1 -0
- package/dist/chunk-MMFUVOXH.mjs +73 -0
- package/dist/chunk-MMFUVOXH.mjs.map +1 -0
- package/dist/chunk-N3Y4U66N.mjs +253 -0
- package/dist/chunk-N3Y4U66N.mjs.map +1 -0
- package/dist/chunk-O7UYB4MH.mjs +25 -0
- package/dist/chunk-O7UYB4MH.mjs.map +1 -0
- package/dist/chunk-OFNVQHNM.mjs +3089 -0
- package/dist/chunk-OFNVQHNM.mjs.map +1 -0
- package/dist/chunk-OFSV5GET.mjs +3074 -0
- package/dist/chunk-OFSV5GET.mjs.map +1 -0
- package/dist/chunk-OMRST67R.mjs +25 -0
- package/dist/chunk-OMRST67R.mjs.map +1 -0
- package/dist/chunk-OWIGJONH.mjs +275 -0
- package/dist/chunk-OWIGJONH.mjs.map +1 -0
- package/dist/chunk-PRZHE74A.mjs +25 -0
- package/dist/chunk-PRZHE74A.mjs.map +1 -0
- package/dist/chunk-PTYRVXXP.mjs +80 -0
- package/dist/chunk-PTYRVXXP.mjs.map +1 -0
- package/dist/chunk-R22B5CCO.mjs +25 -0
- package/dist/chunk-R22B5CCO.mjs.map +1 -0
- package/dist/chunk-SHBDMA63.mjs +141 -0
- package/dist/chunk-SHBDMA63.mjs.map +1 -0
- package/dist/chunk-SPVXBPRA.mjs +74 -0
- package/dist/chunk-SPVXBPRA.mjs.map +1 -0
- package/dist/chunk-T72G46ME.mjs +25 -0
- package/dist/chunk-T72G46ME.mjs.map +1 -0
- package/dist/chunk-TGELROPU.mjs +25 -0
- package/dist/chunk-TGELROPU.mjs.map +1 -0
- package/dist/chunk-UNX4IAAD.mjs +25 -0
- package/dist/chunk-UNX4IAAD.mjs.map +1 -0
- package/dist/chunk-V4DHVC7M.mjs +3085 -0
- package/dist/chunk-V4DHVC7M.mjs.map +1 -0
- package/dist/chunk-VVRFOB66.mjs +25 -0
- package/dist/chunk-VVRFOB66.mjs.map +1 -0
- package/dist/chunk-W6NVBYM6.mjs +80 -0
- package/dist/chunk-W6NVBYM6.mjs.map +1 -0
- package/dist/chunk-W7MBACGC.mjs +74 -0
- package/dist/chunk-W7MBACGC.mjs.map +1 -0
- package/dist/chunk-WMD4XZZS.mjs +25 -0
- package/dist/chunk-WMD4XZZS.mjs.map +1 -0
- package/dist/chunk-WX2ZNCRT.mjs +74 -0
- package/dist/chunk-WX2ZNCRT.mjs.map +1 -0
- package/dist/chunk-XWBDEXDA.mjs +153 -0
- package/dist/chunk-XWBDEXDA.mjs.map +1 -0
- package/dist/chunk-Y2Z62E2T.mjs +74 -0
- package/dist/chunk-Y2Z62E2T.mjs.map +1 -0
- package/dist/chunk-YO4I6RVI.mjs +25 -0
- package/dist/chunk-YO4I6RVI.mjs.map +1 -0
- package/dist/chunk-Z6Q5IW6I.mjs +3098 -0
- package/dist/chunk-Z6Q5IW6I.mjs.map +1 -0
- package/dist/chunk-Z726O3G2.mjs +25 -0
- package/dist/chunk-Z726O3G2.mjs.map +1 -0
- package/dist/chunk-ZE4SMZZR.mjs +3097 -0
- package/dist/chunk-ZE4SMZZR.mjs.map +1 -0
- package/dist/chunk-ZULZB33C.mjs +73 -0
- package/dist/chunk-ZULZB33C.mjs.map +1 -0
- package/dist/chunk-ZVRGXMY7.mjs +25 -0
- package/dist/chunk-ZVRGXMY7.mjs.map +1 -0
- package/dist/chunk-ZZ35WBYQ.mjs +25 -0
- package/dist/chunk-ZZ35WBYQ.mjs.map +1 -0
- package/dist/graphql/message-conversion/index.d.ts +18 -0
- package/dist/graphql/message-conversion/index.js +725 -0
- package/dist/graphql/message-conversion/index.js.map +1 -0
- package/dist/graphql/message-conversion/index.mjs +245 -0
- package/dist/graphql/message-conversion/index.mjs.map +1 -0
- package/dist/graphql/types/base/index.d.ts +6 -0
- package/dist/graphql/types/base/index.js +63 -0
- package/dist/graphql/types/base/index.js.map +1 -0
- package/dist/graphql/types/base/index.mjs +8 -0
- package/dist/graphql/types/base/index.mjs.map +1 -0
- package/dist/graphql/types/converted/index.d.ts +2 -0
- package/dist/graphql/types/converted/index.js +200 -0
- package/dist/graphql/types/converted/index.js.map +1 -0
- package/dist/graphql/types/converted/index.mjs +19 -0
- package/dist/graphql/types/converted/index.mjs.map +1 -0
- package/dist/groq-adapter-540da9c3.d.ts +331 -0
- package/dist/groq-adapter-a6f5e9d2.d.ts +331 -0
- package/dist/groq-adapter-c8aec5c5.d.ts +321 -0
- package/dist/index-96b330da.d.ts +119 -0
- package/dist/index-adbd78f1.d.ts +154 -0
- package/dist/index.d.ts +67 -8
- package/dist/index.js +118 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -31
- package/dist/index.mjs.map +1 -1
- package/dist/langserve-0c6100e3.d.ts +257 -0
- package/dist/langserve-978d5790.d.ts +243 -0
- package/dist/langserve-9fc76ce5.d.ts +243 -0
- package/dist/lib/cloud/index.d.ts +6 -0
- package/dist/lib/cloud/index.js +18 -0
- package/dist/lib/cloud/index.js.map +1 -0
- package/dist/lib/cloud/index.mjs +1 -0
- package/dist/lib/cloud/index.mjs.map +1 -0
- package/dist/lib/index.d.ts +212 -0
- package/dist/lib/index.js +7843 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +76 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/integrations/index.d.ts +34 -0
- package/dist/lib/integrations/index.js +3052 -0
- package/dist/lib/integrations/index.js.map +1 -0
- package/dist/lib/integrations/index.mjs +37 -0
- package/dist/lib/integrations/index.mjs.map +1 -0
- package/dist/lib/integrations/nest/index.d.ts +15 -0
- package/dist/lib/integrations/nest/index.js +2959 -0
- package/dist/lib/integrations/nest/index.js.map +1 -0
- package/dist/lib/integrations/nest/index.mjs +14 -0
- package/dist/lib/integrations/nest/index.mjs.map +1 -0
- package/dist/lib/integrations/node-express/index.d.ts +15 -0
- package/dist/lib/integrations/node-express/index.js +2959 -0
- package/dist/lib/integrations/node-express/index.js.map +1 -0
- package/dist/lib/integrations/node-express/index.mjs +14 -0
- package/dist/lib/integrations/node-express/index.mjs.map +1 -0
- package/dist/lib/integrations/node-http/index.d.ts +15 -0
- package/dist/lib/integrations/node-http/index.js +2945 -0
- package/dist/lib/integrations/node-http/index.js.map +1 -0
- package/dist/lib/integrations/node-http/index.mjs +13 -0
- package/dist/lib/integrations/node-http/index.mjs.map +1 -0
- package/dist/service-adapters/index.d.ts +162 -0
- package/dist/service-adapters/index.js +1787 -0
- package/dist/service-adapters/index.js.map +1 -0
- package/dist/service-adapters/index.mjs +34 -0
- package/dist/service-adapters/index.mjs.map +1 -0
- package/dist/service-adapters/shared/index.d.ts +9 -0
- package/dist/service-adapters/shared/index.js +72 -0
- package/dist/service-adapters/shared/index.js.map +1 -0
- package/dist/service-adapters/shared/index.mjs +8 -0
- package/dist/service-adapters/shared/index.mjs.map +1 -0
- package/dist/shared-0a7346ce.d.ts +466 -0
- package/dist/shared-35c6eb04.d.ts +448 -0
- package/dist/shared-9ed1dc31.d.ts +414 -0
- package/dist/shared-da5708fe.d.ts +449 -0
- package/dist/utils/index.d.ts +65 -0
- package/dist/utils/index.js +175 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +14 -20
- package/src/lib/index.ts +7 -6
- package/src/lib/runtime/copilot-runtime.ts +62 -26
- package/src/lib/runtime/telemetry-agent-runner.ts +139 -0
|
@@ -0,0 +1,3074 @@
|
|
|
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
|
+
this.instance = new CopilotRuntimeVNext(this.runtimeArgs);
|
|
1827
|
+
}
|
|
1828
|
+
assignEndpointsToAgents(endpoints) {
|
|
1829
|
+
return endpoints.reduce((acc, endpoint) => {
|
|
1830
|
+
if (resolveEndpointType(endpoint) == EndpointType.LangGraphPlatform) {
|
|
1831
|
+
let lgAgents = {};
|
|
1832
|
+
const lgEndpoint = endpoint;
|
|
1833
|
+
lgEndpoint.agents.forEach((agent) => {
|
|
1834
|
+
const graphId = agent.assistantId ?? agent.name;
|
|
1835
|
+
lgAgents[graphId] = new LangGraphAgent({
|
|
1836
|
+
deploymentUrl: lgEndpoint.deploymentUrl,
|
|
1837
|
+
langsmithApiKey: lgEndpoint.langsmithApiKey,
|
|
1838
|
+
graphId
|
|
1839
|
+
});
|
|
1840
|
+
});
|
|
1841
|
+
return {
|
|
1842
|
+
...acc,
|
|
1843
|
+
...lgAgents
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
return acc;
|
|
1847
|
+
}, {});
|
|
1848
|
+
}
|
|
1849
|
+
async handleServiceAdapter(serviceAdapter) {
|
|
1850
|
+
var _a;
|
|
1851
|
+
let agents = await this.runtimeArgs.agents ?? {};
|
|
1852
|
+
const isAgentsListEmpty = !Object.keys(agents).length;
|
|
1853
|
+
const hasServiceAdapter = Boolean(serviceAdapter);
|
|
1854
|
+
const illegalServiceAdapterNames = [
|
|
1855
|
+
"EmptyAdapter"
|
|
1856
|
+
];
|
|
1857
|
+
const serviceAdapterCanBeUsedForAgent = !illegalServiceAdapterNames.includes(serviceAdapter.name);
|
|
1858
|
+
if (isAgentsListEmpty && (!hasServiceAdapter || !serviceAdapterCanBeUsedForAgent)) {
|
|
1859
|
+
throw new CopilotKitMisuseError({
|
|
1860
|
+
message: "No default agent provided. Please provide a default agent in the runtime config."
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
if (isAgentsListEmpty) {
|
|
1864
|
+
agents.default = new BasicAgent({
|
|
1865
|
+
model: `${serviceAdapter.provider}/${serviceAdapter.model}`
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
if ((_a = this.params.actions) == null ? void 0 : _a.length) {
|
|
1869
|
+
const mcpTools = await this.getToolsFromMCP();
|
|
1870
|
+
agents = this.assignToolsToAgents(agents, [
|
|
1871
|
+
...this.getToolsFromActions(this.params.actions),
|
|
1872
|
+
...mcpTools
|
|
1873
|
+
]);
|
|
1874
|
+
}
|
|
1875
|
+
this.instance.agents = agents;
|
|
1876
|
+
}
|
|
1877
|
+
// Receive this.params.action and turn it into the AbstractAgent tools
|
|
1878
|
+
getToolsFromActions(actions) {
|
|
1879
|
+
const actionsArray = typeof actions === "function" ? actions({
|
|
1880
|
+
properties: {},
|
|
1881
|
+
url: void 0
|
|
1882
|
+
}) : actions;
|
|
1883
|
+
return actionsArray.map((action) => {
|
|
1884
|
+
const zodSchema = getZodParameters(action.parameters || []);
|
|
1885
|
+
return {
|
|
1886
|
+
name: action.name,
|
|
1887
|
+
description: action.description || "",
|
|
1888
|
+
parameters: zodSchema
|
|
1889
|
+
};
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
assignToolsToAgents(agents, tools) {
|
|
1893
|
+
const enrichedAgents = {
|
|
1894
|
+
...agents
|
|
1895
|
+
};
|
|
1896
|
+
for (const existingAgent of Object.values(enrichedAgents)) {
|
|
1897
|
+
const config = existingAgent.config ?? {};
|
|
1898
|
+
const existingTools = config.tools ?? [];
|
|
1899
|
+
config.tools = [
|
|
1900
|
+
...existingTools,
|
|
1901
|
+
...tools
|
|
1902
|
+
];
|
|
1903
|
+
}
|
|
1904
|
+
return enrichedAgents;
|
|
1905
|
+
}
|
|
1906
|
+
createOnBeforeRequestHandler(params) {
|
|
1907
|
+
return async (hookParams) => {
|
|
1908
|
+
var _a, _b;
|
|
1909
|
+
(_a = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _a.call(params, hookParams);
|
|
1910
|
+
if ((_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onBeforeRequest) {
|
|
1911
|
+
const { request, runtime, path } = hookParams;
|
|
1912
|
+
const body = await readBody(request);
|
|
1913
|
+
const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
|
|
1914
|
+
if ("role" in msg && msg.role === "user") {
|
|
1915
|
+
acc.inputMessages.push(msg);
|
|
1916
|
+
} else {
|
|
1917
|
+
acc.outputMessages.push(msg);
|
|
1918
|
+
}
|
|
1919
|
+
return acc;
|
|
1920
|
+
}, {
|
|
1921
|
+
inputMessages: [],
|
|
1922
|
+
outputMessages: []
|
|
1923
|
+
});
|
|
1924
|
+
const { inputMessages, outputMessages } = gqlMessages;
|
|
1925
|
+
params.middleware.onBeforeRequest({
|
|
1926
|
+
threadId: body.threadId,
|
|
1927
|
+
runId: body.runId,
|
|
1928
|
+
inputMessages,
|
|
1929
|
+
properties: body.forwardedProps,
|
|
1930
|
+
url: request.url
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
createOnAfterRequestHandler(params) {
|
|
1936
|
+
return async (hookParams) => {
|
|
1937
|
+
var _a, _b;
|
|
1938
|
+
(_a = params == null ? void 0 : params.afterRequestMiddleware) == null ? void 0 : _a.call(params, hookParams);
|
|
1939
|
+
if ((_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest) {
|
|
1940
|
+
params.middleware.onAfterRequest({});
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
// Observability Methods
|
|
1945
|
+
/**
|
|
1946
|
+
* Log LLM request if observability is enabled
|
|
1947
|
+
*/
|
|
1948
|
+
async logObservabilityBeforeRequest(requestData) {
|
|
1949
|
+
try {
|
|
1950
|
+
await this.observability.hooks.handleRequest(requestData);
|
|
1951
|
+
} catch (error) {
|
|
1952
|
+
console.error("Error logging LLM request:", error);
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* Log final LLM response after request completes
|
|
1957
|
+
*/
|
|
1958
|
+
logObservabilityAfterRequest(outputMessagesPromise, baseData, streamedChunks, requestStartTime, publicApiKey) {
|
|
1959
|
+
try {
|
|
1960
|
+
outputMessagesPromise.then((outputMessages) => {
|
|
1961
|
+
const responseData = {
|
|
1962
|
+
threadId: baseData.threadId,
|
|
1963
|
+
runId: baseData.runId,
|
|
1964
|
+
model: baseData.model,
|
|
1965
|
+
// Use collected chunks for progressive mode or outputMessages for regular mode
|
|
1966
|
+
output: this.observability.progressive ? streamedChunks : outputMessages,
|
|
1967
|
+
latency: Date.now() - requestStartTime,
|
|
1968
|
+
timestamp: Date.now(),
|
|
1969
|
+
provider: baseData.provider,
|
|
1970
|
+
isFinalResponse: true,
|
|
1971
|
+
agentName: baseData.agentName,
|
|
1972
|
+
nodeName: baseData.nodeName
|
|
1973
|
+
};
|
|
1974
|
+
try {
|
|
1975
|
+
this.observability.hooks.handleResponse(responseData);
|
|
1976
|
+
} catch (logError) {
|
|
1977
|
+
console.error("Error logging LLM response:", logError);
|
|
1978
|
+
}
|
|
1979
|
+
}).catch((error) => {
|
|
1980
|
+
console.error("Failed to get output messages for logging:", error);
|
|
1981
|
+
});
|
|
1982
|
+
} catch (error) {
|
|
1983
|
+
console.error("Error setting up logging for LLM response:", error);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
// Resolve MCP tools to BasicAgent tool definitions
|
|
1987
|
+
// Optionally accepts request-scoped properties to merge request-provided mcpServers
|
|
1988
|
+
async getToolsFromMCP(options) {
|
|
1989
|
+
var _a, _b, _c, _d;
|
|
1990
|
+
const runtimeMcpServers = ((_a = this.params) == null ? void 0 : _a.mcpServers) ?? [];
|
|
1991
|
+
const createMCPClient = (_b = this.params) == null ? void 0 : _b.createMCPClient;
|
|
1992
|
+
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) ?? [];
|
|
1993
|
+
const hasAnyServers = ((runtimeMcpServers == null ? void 0 : runtimeMcpServers.length) ?? 0) > 0 || ((requestMcpServers == null ? void 0 : requestMcpServers.length) ?? 0) > 0;
|
|
1994
|
+
if (!hasAnyServers) {
|
|
1995
|
+
return [];
|
|
1996
|
+
}
|
|
1997
|
+
if (!createMCPClient) {
|
|
1998
|
+
throw new CopilotKitMisuseError({
|
|
1999
|
+
message: "MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
const effectiveEndpoints = (() => {
|
|
2003
|
+
const byUrl = /* @__PURE__ */ new Map();
|
|
2004
|
+
for (const ep of runtimeMcpServers) {
|
|
2005
|
+
if (ep == null ? void 0 : ep.endpoint)
|
|
2006
|
+
byUrl.set(ep.endpoint, ep);
|
|
2007
|
+
}
|
|
2008
|
+
for (const ep of requestMcpServers) {
|
|
2009
|
+
if (ep == null ? void 0 : ep.endpoint)
|
|
2010
|
+
byUrl.set(ep.endpoint, ep);
|
|
2011
|
+
}
|
|
2012
|
+
return Array.from(byUrl.values());
|
|
2013
|
+
})();
|
|
2014
|
+
const allTools = [];
|
|
2015
|
+
for (const config of effectiveEndpoints) {
|
|
2016
|
+
const endpointUrl = config.endpoint;
|
|
2017
|
+
const cached = this.mcpToolsCache.get(endpointUrl);
|
|
2018
|
+
if (cached) {
|
|
2019
|
+
allTools.push(...cached);
|
|
2020
|
+
continue;
|
|
2021
|
+
}
|
|
2022
|
+
try {
|
|
2023
|
+
const client = await createMCPClient(config);
|
|
2024
|
+
const toolsMap = await client.tools();
|
|
2025
|
+
const toolDefs = Object.entries(toolsMap).map(([toolName, tool]) => {
|
|
2026
|
+
const params = extractParametersFromSchema(tool);
|
|
2027
|
+
const zodSchema = getZodParameters(params);
|
|
2028
|
+
return {
|
|
2029
|
+
name: toolName,
|
|
2030
|
+
description: tool.description || `MCP tool: ${toolName} (from ${endpointUrl})`,
|
|
2031
|
+
parameters: zodSchema
|
|
2032
|
+
};
|
|
2033
|
+
});
|
|
2034
|
+
this.mcpToolsCache.set(endpointUrl, toolDefs);
|
|
2035
|
+
allTools.push(...toolDefs);
|
|
2036
|
+
} catch (error) {
|
|
2037
|
+
console.error(`MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`, error);
|
|
2038
|
+
this.mcpToolsCache.set(endpointUrl, []);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
const dedupedByName = /* @__PURE__ */ new Map();
|
|
2042
|
+
for (const tool of allTools) {
|
|
2043
|
+
dedupedByName.set(tool.name, tool);
|
|
2044
|
+
}
|
|
2045
|
+
return Array.from(dedupedByName.values());
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
__name(CopilotRuntime, "CopilotRuntime");
|
|
2049
|
+
function copilotKitEndpoint(config) {
|
|
2050
|
+
return {
|
|
2051
|
+
...config,
|
|
2052
|
+
type: EndpointType.CopilotKit
|
|
2053
|
+
};
|
|
2054
|
+
}
|
|
2055
|
+
__name(copilotKitEndpoint, "copilotKitEndpoint");
|
|
2056
|
+
function langGraphPlatformEndpoint(config) {
|
|
2057
|
+
return {
|
|
2058
|
+
...config,
|
|
2059
|
+
type: EndpointType.LangGraphPlatform
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
__name(langGraphPlatformEndpoint, "langGraphPlatformEndpoint");
|
|
2063
|
+
function resolveEndpointType(endpoint) {
|
|
2064
|
+
if (!endpoint.type) {
|
|
2065
|
+
if ("deploymentUrl" in endpoint && "agents" in endpoint) {
|
|
2066
|
+
return EndpointType.LangGraphPlatform;
|
|
2067
|
+
} else {
|
|
2068
|
+
return EndpointType.CopilotKit;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
return endpoint.type;
|
|
2072
|
+
}
|
|
2073
|
+
__name(resolveEndpointType, "resolveEndpointType");
|
|
2074
|
+
|
|
2075
|
+
// src/lib/telemetry-client.ts
|
|
2076
|
+
var packageJson = require_package();
|
|
2077
|
+
var telemetryClient = new TelemetryClient({
|
|
2078
|
+
packageName: packageJson.name,
|
|
2079
|
+
packageVersion: packageJson.version
|
|
2080
|
+
});
|
|
2081
|
+
function getRuntimeInstanceTelemetryInfo(options) {
|
|
2082
|
+
var _a, _b, _c, _d, _e;
|
|
2083
|
+
const runtime = options.runtime;
|
|
2084
|
+
const remoteEndpoints = ((_a = runtime.params) == null ? void 0 : _a.remoteEndpoints) ?? [];
|
|
2085
|
+
const endpointsInfo = remoteEndpoints.reduce((acc, endpoint) => {
|
|
2086
|
+
let info = {
|
|
2087
|
+
...acc
|
|
2088
|
+
};
|
|
2089
|
+
const endpointType = resolveEndpointType(endpoint);
|
|
2090
|
+
if (!info.endpointTypes.includes(endpointType)) {
|
|
2091
|
+
info = {
|
|
2092
|
+
...info,
|
|
2093
|
+
endpointTypes: [
|
|
2094
|
+
...info.endpointTypes,
|
|
2095
|
+
endpointType
|
|
2096
|
+
]
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
if (endpointType === EndpointType.LangGraphPlatform) {
|
|
2100
|
+
const ep = endpoint;
|
|
2101
|
+
info = {
|
|
2102
|
+
...info,
|
|
2103
|
+
agentsAmount: ep.agents.length,
|
|
2104
|
+
hashedKey: ep.langsmithApiKey ? createHash("sha256").update(ep.langsmithApiKey).digest("hex") : null
|
|
2105
|
+
};
|
|
2106
|
+
}
|
|
2107
|
+
return info;
|
|
2108
|
+
}, {
|
|
2109
|
+
endpointTypes: [],
|
|
2110
|
+
agentsAmount: null,
|
|
2111
|
+
hashedKey: null
|
|
2112
|
+
});
|
|
2113
|
+
const publicApiKey = (_b = options.cloud) == null ? void 0 : _b.publicApiKey;
|
|
2114
|
+
const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
|
|
2115
|
+
return {
|
|
2116
|
+
actionsAmount: ((_d = (_c = runtime.params) == null ? void 0 : _c.actions) == null ? void 0 : _d.length) ?? 0,
|
|
2117
|
+
endpointsAmount: remoteEndpoints.length,
|
|
2118
|
+
endpointTypes: endpointsInfo.endpointTypes,
|
|
2119
|
+
agentsAmount: Object.keys(runtime.instance.agents).length,
|
|
2120
|
+
hashedLgcKey: endpointsInfo.hashedKey,
|
|
2121
|
+
"cloud.api_key_provided": apiKeyProvided,
|
|
2122
|
+
...apiKeyProvided ? {
|
|
2123
|
+
"cloud.public_api_key": publicApiKey
|
|
2124
|
+
} : {},
|
|
2125
|
+
...((_e = options.cloud) == null ? void 0 : _e.baseUrl) ? {
|
|
2126
|
+
"cloud.base_url": options.cloud.baseUrl
|
|
2127
|
+
} : {}
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
__name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
|
|
2131
|
+
var telemetry_client_default = telemetryClient;
|
|
2132
|
+
|
|
2133
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
2134
|
+
import { randomId } from "@copilotkit/shared";
|
|
2135
|
+
|
|
2136
|
+
// src/graphql/types/agents-response.type.ts
|
|
2137
|
+
import { Field as Field16, ObjectType as ObjectType4 } from "type-graphql";
|
|
2138
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2139
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2140
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2141
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2142
|
+
else
|
|
2143
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2144
|
+
if (d = decorators[i])
|
|
2145
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2146
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2147
|
+
}
|
|
2148
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2149
|
+
function _ts_metadata16(k, v) {
|
|
2150
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2151
|
+
return Reflect.metadata(k, v);
|
|
2152
|
+
}
|
|
2153
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2154
|
+
var Agent = class {
|
|
2155
|
+
id;
|
|
2156
|
+
name;
|
|
2157
|
+
description;
|
|
2158
|
+
};
|
|
2159
|
+
__name(Agent, "Agent");
|
|
2160
|
+
_ts_decorate16([
|
|
2161
|
+
Field16(() => String),
|
|
2162
|
+
_ts_metadata16("design:type", String)
|
|
2163
|
+
], Agent.prototype, "id", void 0);
|
|
2164
|
+
_ts_decorate16([
|
|
2165
|
+
Field16(() => String),
|
|
2166
|
+
_ts_metadata16("design:type", String)
|
|
2167
|
+
], Agent.prototype, "name", void 0);
|
|
2168
|
+
_ts_decorate16([
|
|
2169
|
+
Field16(() => String),
|
|
2170
|
+
_ts_metadata16("design:type", String)
|
|
2171
|
+
], Agent.prototype, "description", void 0);
|
|
2172
|
+
Agent = _ts_decorate16([
|
|
2173
|
+
ObjectType4()
|
|
2174
|
+
], Agent);
|
|
2175
|
+
var AgentsResponse = class {
|
|
2176
|
+
agents;
|
|
2177
|
+
};
|
|
2178
|
+
__name(AgentsResponse, "AgentsResponse");
|
|
2179
|
+
_ts_decorate16([
|
|
2180
|
+
Field16(() => [
|
|
2181
|
+
Agent
|
|
2182
|
+
]),
|
|
2183
|
+
_ts_metadata16("design:type", Array)
|
|
2184
|
+
], AgentsResponse.prototype, "agents", void 0);
|
|
2185
|
+
AgentsResponse = _ts_decorate16([
|
|
2186
|
+
ObjectType4()
|
|
2187
|
+
], AgentsResponse);
|
|
2188
|
+
|
|
2189
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
2190
|
+
import { CopilotKitError as CopilotKitError2, CopilotKitLowLevelError as CopilotKitLowLevelError2 } from "@copilotkit/shared";
|
|
2191
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2192
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2193
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2194
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2195
|
+
else
|
|
2196
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2197
|
+
if (d = decorators[i])
|
|
2198
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2199
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2200
|
+
}
|
|
2201
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2202
|
+
function _ts_metadata17(k, v) {
|
|
2203
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2204
|
+
return Reflect.metadata(k, v);
|
|
2205
|
+
}
|
|
2206
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
2207
|
+
function _ts_param(paramIndex, decorator) {
|
|
2208
|
+
return function(target, key) {
|
|
2209
|
+
decorator(target, key, paramIndex);
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
__name(_ts_param, "_ts_param");
|
|
2213
|
+
var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
|
|
2214
|
+
var _a;
|
|
2215
|
+
if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
|
|
2216
|
+
const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
|
|
2217
|
+
role: m.textMessage.role,
|
|
2218
|
+
content: m.textMessage.content
|
|
2219
|
+
}));
|
|
2220
|
+
const lastMessage = messages[messages.length - 1];
|
|
2221
|
+
const restOfMessages = messages.slice(0, -1);
|
|
2222
|
+
const body = {
|
|
2223
|
+
input: lastMessage.content,
|
|
2224
|
+
validTopics: data.cloud.guardrails.inputValidationRules.allowList,
|
|
2225
|
+
invalidTopics: data.cloud.guardrails.inputValidationRules.denyList,
|
|
2226
|
+
messages: restOfMessages
|
|
2227
|
+
};
|
|
2228
|
+
const guardrailsResult = await fetch(`${baseUrl}/guardrails/validate`, {
|
|
2229
|
+
method: "POST",
|
|
2230
|
+
headers: {
|
|
2231
|
+
"Content-Type": "application/json",
|
|
2232
|
+
"X-CopilotCloud-Public-API-Key": copilotCloudPublicApiKey
|
|
2233
|
+
},
|
|
2234
|
+
body: JSON.stringify(body)
|
|
2235
|
+
});
|
|
2236
|
+
if (guardrailsResult.ok) {
|
|
2237
|
+
const resultJson = await guardrailsResult.json();
|
|
2238
|
+
onResult(resultJson);
|
|
2239
|
+
} else {
|
|
2240
|
+
onError(await guardrailsResult.json());
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}, "invokeGuardrails");
|
|
2244
|
+
var CopilotResolver = class {
|
|
2245
|
+
async hello() {
|
|
2246
|
+
return "Hello World";
|
|
2247
|
+
}
|
|
2248
|
+
async availableAgents(ctx) {
|
|
2249
|
+
let logger2 = ctx.logger.child({
|
|
2250
|
+
component: "CopilotResolver.availableAgents"
|
|
2251
|
+
});
|
|
2252
|
+
logger2.debug("Processing");
|
|
2253
|
+
const agentsWithEndpoints = [];
|
|
2254
|
+
logger2.debug("Event source created, creating response");
|
|
2255
|
+
return {
|
|
2256
|
+
agents: agentsWithEndpoints.map(({ endpoint, ...agentWithoutEndpoint }) => agentWithoutEndpoint)
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
2259
|
+
async generateCopilotResponse(ctx, data, properties) {
|
|
2260
|
+
var _a, _b, _c, _d;
|
|
2261
|
+
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
2262
|
+
"cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
2263
|
+
requestType: data.metadata.requestType,
|
|
2264
|
+
"cloud.api_key_provided": !!ctx.request.headers.get("x-copilotcloud-public-api-key"),
|
|
2265
|
+
...ctx.request.headers.get("x-copilotcloud-public-api-key") ? {
|
|
2266
|
+
"cloud.public_api_key": ctx.request.headers.get("x-copilotcloud-public-api-key")
|
|
2267
|
+
} : {},
|
|
2268
|
+
...ctx._copilotkit.baseUrl ? {
|
|
2269
|
+
"cloud.base_url": ctx._copilotkit.baseUrl
|
|
2270
|
+
} : {
|
|
2271
|
+
"cloud.base_url": "https://api.cloud.copilotkit.ai"
|
|
2272
|
+
}
|
|
2273
|
+
});
|
|
2274
|
+
let logger2 = ctx.logger.child({
|
|
2275
|
+
component: "CopilotResolver.generateCopilotResponse"
|
|
2276
|
+
});
|
|
2277
|
+
logger2.debug({
|
|
2278
|
+
data
|
|
2279
|
+
}, "Generating Copilot response");
|
|
2280
|
+
if (properties) {
|
|
2281
|
+
logger2.debug("Properties provided, merging with context properties");
|
|
2282
|
+
ctx.properties = {
|
|
2283
|
+
...ctx.properties,
|
|
2284
|
+
...properties
|
|
2285
|
+
};
|
|
2286
|
+
}
|
|
2287
|
+
const copilotRuntime = ctx._copilotkit.runtime;
|
|
2288
|
+
const serviceAdapter = ctx._copilotkit.serviceAdapter;
|
|
2289
|
+
let copilotCloudPublicApiKey = null;
|
|
2290
|
+
let copilotCloudBaseUrl;
|
|
2291
|
+
const publicApiKeyFromHeaders = ctx.request.headers.get("x-copilotcloud-public-api-key");
|
|
2292
|
+
if (publicApiKeyFromHeaders) {
|
|
2293
|
+
copilotCloudPublicApiKey = publicApiKeyFromHeaders;
|
|
2294
|
+
}
|
|
2295
|
+
if (data.cloud) {
|
|
2296
|
+
logger2 = logger2.child({
|
|
2297
|
+
cloud: true
|
|
2298
|
+
});
|
|
2299
|
+
logger2.debug("Cloud configuration provided, checking for public API key in headers");
|
|
2300
|
+
if (!copilotCloudPublicApiKey) {
|
|
2301
|
+
logger2.error("Public API key not found in headers");
|
|
2302
|
+
throw new GraphQLError("X-CopilotCloud-Public-API-Key header is required");
|
|
2303
|
+
}
|
|
2304
|
+
if (process.env.COPILOT_CLOUD_BASE_URL) {
|
|
2305
|
+
copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
|
|
2306
|
+
} else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
|
|
2307
|
+
copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
|
|
2308
|
+
} else {
|
|
2309
|
+
copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
|
|
2310
|
+
}
|
|
2311
|
+
logger2 = logger2.child({
|
|
2312
|
+
copilotCloudBaseUrl
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
logger2.debug("Setting up subjects");
|
|
2316
|
+
const responseStatus$ = new ReplaySubject2();
|
|
2317
|
+
const interruptStreaming$ = new ReplaySubject2();
|
|
2318
|
+
const guardrailsResult$ = new ReplaySubject2();
|
|
2319
|
+
let outputMessages = [];
|
|
2320
|
+
let resolveOutputMessagesPromise;
|
|
2321
|
+
let rejectOutputMessagesPromise;
|
|
2322
|
+
const outputMessagesPromise = new Promise((resolve, reject) => {
|
|
2323
|
+
resolveOutputMessagesPromise = resolve;
|
|
2324
|
+
rejectOutputMessagesPromise = reject;
|
|
2325
|
+
});
|
|
2326
|
+
if (copilotCloudPublicApiKey) {
|
|
2327
|
+
ctx.properties["copilotCloudPublicApiKey"] = copilotCloudPublicApiKey;
|
|
2328
|
+
}
|
|
2329
|
+
logger2.debug("Processing");
|
|
2330
|
+
let runtimeResponse;
|
|
2331
|
+
const { eventSource, threadId = randomId(), runId, serverSideActions, actionInputsWithoutAgents, extensions } = runtimeResponse;
|
|
2332
|
+
logger2.debug("Event source created, creating response");
|
|
2333
|
+
const eventStream = eventSource.processRuntimeEvents({
|
|
2334
|
+
serverSideActions,
|
|
2335
|
+
guardrailsResult$: ((_d = data.cloud) == null ? void 0 : _d.guardrails) ? guardrailsResult$ : null,
|
|
2336
|
+
actionInputsWithoutAgents: actionInputsWithoutAgents.filter(
|
|
2337
|
+
// TODO-AGENTS: do not exclude ALL server side actions
|
|
2338
|
+
(action) => !serverSideActions.find((serverSideAction) => serverSideAction.name == action.name)
|
|
2339
|
+
),
|
|
2340
|
+
threadId
|
|
2341
|
+
}).pipe(
|
|
2342
|
+
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
2343
|
+
// just the events that were emitted after the subscriber was added.
|
|
2344
|
+
shareReplay(),
|
|
2345
|
+
finalize(() => {
|
|
2346
|
+
logger2.debug("Event stream finalized");
|
|
2347
|
+
})
|
|
2348
|
+
);
|
|
2349
|
+
const response = {
|
|
2350
|
+
threadId,
|
|
2351
|
+
runId,
|
|
2352
|
+
status: firstValueFrom(responseStatus$),
|
|
2353
|
+
extensions,
|
|
2354
|
+
metaEvents: new Repeater(async (push, stop) => {
|
|
2355
|
+
let eventStreamSubscription;
|
|
2356
|
+
eventStreamSubscription = eventStream.subscribe({
|
|
2357
|
+
next: async (event) => {
|
|
2358
|
+
if (event.type != RuntimeEventTypes.MetaEvent) {
|
|
2359
|
+
return;
|
|
2360
|
+
}
|
|
2361
|
+
switch (event.name) {
|
|
2362
|
+
case LangGraphEventTypes.OnInterrupt:
|
|
2363
|
+
push(plainToInstance(LangGraphInterruptEvent, {
|
|
2364
|
+
// @ts-ignore
|
|
2365
|
+
type: event.type,
|
|
2366
|
+
// @ts-ignore
|
|
2367
|
+
name: RuntimeMetaEventName.LangGraphInterruptEvent,
|
|
2368
|
+
// @ts-ignore
|
|
2369
|
+
value: event.value
|
|
2370
|
+
}));
|
|
2371
|
+
break;
|
|
2372
|
+
case RuntimeMetaEventName.LangGraphInterruptEvent:
|
|
2373
|
+
push(plainToInstance(LangGraphInterruptEvent, {
|
|
2374
|
+
type: event.type,
|
|
2375
|
+
name: event.name,
|
|
2376
|
+
value: event.value
|
|
2377
|
+
}));
|
|
2378
|
+
break;
|
|
2379
|
+
case RuntimeMetaEventName.CopilotKitLangGraphInterruptEvent:
|
|
2380
|
+
push(plainToInstance(CopilotKitLangGraphInterruptEvent, {
|
|
2381
|
+
type: event.type,
|
|
2382
|
+
name: event.name,
|
|
2383
|
+
data: {
|
|
2384
|
+
value: event.data.value,
|
|
2385
|
+
messages: event.data.messages.map((message) => {
|
|
2386
|
+
if (message.type === "TextMessage" || "content" in message && "role" in message) {
|
|
2387
|
+
return plainToInstance(TextMessage, {
|
|
2388
|
+
id: message.id,
|
|
2389
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2390
|
+
content: [
|
|
2391
|
+
message.content
|
|
2392
|
+
],
|
|
2393
|
+
role: message.role,
|
|
2394
|
+
status: new SuccessMessageStatus()
|
|
2395
|
+
});
|
|
2396
|
+
}
|
|
2397
|
+
if ("arguments" in message) {
|
|
2398
|
+
return plainToInstance(ActionExecutionMessage, {
|
|
2399
|
+
name: message.name,
|
|
2400
|
+
id: message.id,
|
|
2401
|
+
arguments: [
|
|
2402
|
+
JSON.stringify(message.arguments)
|
|
2403
|
+
],
|
|
2404
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2405
|
+
status: new SuccessMessageStatus()
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
throw new Error("Unknown message in metaEvents copilot resolver");
|
|
2409
|
+
})
|
|
2410
|
+
}
|
|
2411
|
+
}));
|
|
2412
|
+
break;
|
|
2413
|
+
}
|
|
2414
|
+
},
|
|
2415
|
+
error: (err) => {
|
|
2416
|
+
var _a2, _b2;
|
|
2417
|
+
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)) {
|
|
2418
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
2419
|
+
description: err.message || "Agent error occurred"
|
|
2420
|
+
}));
|
|
2421
|
+
} else {
|
|
2422
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
2423
|
+
description: `An unknown error has occurred in the event stream`
|
|
2424
|
+
}));
|
|
2425
|
+
}
|
|
2426
|
+
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
2427
|
+
stop();
|
|
2428
|
+
},
|
|
2429
|
+
complete: async () => {
|
|
2430
|
+
logger2.debug("Meta events stream completed");
|
|
2431
|
+
responseStatus$.next(new SuccessResponseStatus());
|
|
2432
|
+
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
2433
|
+
stop();
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
}),
|
|
2437
|
+
messages: new Repeater(async (pushMessage, stopStreamingMessages) => {
|
|
2438
|
+
var _a2;
|
|
2439
|
+
logger2.debug("Messages repeater created");
|
|
2440
|
+
if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
|
|
2441
|
+
logger2 = logger2.child({
|
|
2442
|
+
guardrails: true
|
|
2443
|
+
});
|
|
2444
|
+
logger2.debug("Guardrails is enabled, validating input");
|
|
2445
|
+
invokeGuardrails({
|
|
2446
|
+
baseUrl: copilotCloudBaseUrl,
|
|
2447
|
+
copilotCloudPublicApiKey,
|
|
2448
|
+
data,
|
|
2449
|
+
onResult: (result) => {
|
|
2450
|
+
logger2.debug({
|
|
2451
|
+
status: result.status
|
|
2452
|
+
}, "Guardrails validation done");
|
|
2453
|
+
guardrailsResult$.next(result);
|
|
2454
|
+
if (result.status === "denied") {
|
|
2455
|
+
responseStatus$.next(new GuardrailsValidationFailureResponse({
|
|
2456
|
+
guardrailsReason: result.reason
|
|
2457
|
+
}));
|
|
2458
|
+
interruptStreaming$.next({
|
|
2459
|
+
reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
|
|
2460
|
+
});
|
|
2461
|
+
outputMessages = [
|
|
2462
|
+
plainToInstance(TextMessage, {
|
|
2463
|
+
id: randomId(),
|
|
2464
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2465
|
+
content: result.reason,
|
|
2466
|
+
role: MessageRole.assistant
|
|
2467
|
+
})
|
|
2468
|
+
];
|
|
2469
|
+
resolveOutputMessagesPromise(outputMessages);
|
|
2470
|
+
}
|
|
2471
|
+
},
|
|
2472
|
+
onError: (err) => {
|
|
2473
|
+
logger2.error({
|
|
2474
|
+
err
|
|
2475
|
+
}, "Error in guardrails validation");
|
|
2476
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
2477
|
+
description: `An unknown error has occurred in the guardrails validation`
|
|
2478
|
+
}));
|
|
2479
|
+
interruptStreaming$.next({
|
|
2480
|
+
reason: `Interrupted due to unknown error in guardrails validation`
|
|
2481
|
+
});
|
|
2482
|
+
rejectOutputMessagesPromise(err);
|
|
2483
|
+
}
|
|
2484
|
+
});
|
|
2485
|
+
}
|
|
2486
|
+
let eventStreamSubscription;
|
|
2487
|
+
logger2.debug("Event stream created, subscribing to event stream");
|
|
2488
|
+
eventStreamSubscription = eventStream.subscribe({
|
|
2489
|
+
next: async (event) => {
|
|
2490
|
+
switch (event.type) {
|
|
2491
|
+
case RuntimeEventTypes.MetaEvent:
|
|
2492
|
+
break;
|
|
2493
|
+
case RuntimeEventTypes.TextMessageStart:
|
|
2494
|
+
const textMessageContentStream = eventStream.pipe(
|
|
2495
|
+
// skip until this message start event
|
|
2496
|
+
skipWhile((e) => e !== event),
|
|
2497
|
+
// take until the message end event
|
|
2498
|
+
takeWhile((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
|
|
2499
|
+
// filter out any other message events or message ids
|
|
2500
|
+
filter((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
|
|
2501
|
+
);
|
|
2502
|
+
const streamingTextStatus = new Subject();
|
|
2503
|
+
const messageId = event.messageId;
|
|
2504
|
+
pushMessage({
|
|
2505
|
+
id: messageId,
|
|
2506
|
+
parentMessageId: event.parentMessageId,
|
|
2507
|
+
status: firstValueFrom(streamingTextStatus),
|
|
2508
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2509
|
+
role: MessageRole.assistant,
|
|
2510
|
+
content: new Repeater(async (pushTextChunk, stopStreamingText) => {
|
|
2511
|
+
logger2.debug("Text message content repeater created");
|
|
2512
|
+
const textChunks = [];
|
|
2513
|
+
let textSubscription;
|
|
2514
|
+
interruptStreaming$.pipe(shareReplay(), take(1), tap(({ reason, messageId: messageId2 }) => {
|
|
2515
|
+
logger2.debug({
|
|
2516
|
+
reason,
|
|
2517
|
+
messageId: messageId2
|
|
2518
|
+
}, "Text streaming interrupted");
|
|
2519
|
+
streamingTextStatus.next(plainToInstance(FailedMessageStatus, {
|
|
2520
|
+
reason
|
|
2521
|
+
}));
|
|
2522
|
+
responseStatus$.next(new MessageStreamInterruptedResponse({
|
|
2523
|
+
messageId: messageId2
|
|
2524
|
+
}));
|
|
2525
|
+
stopStreamingText();
|
|
2526
|
+
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
2527
|
+
})).subscribe();
|
|
2528
|
+
logger2.debug("Subscribing to text message content stream");
|
|
2529
|
+
textSubscription = textMessageContentStream.subscribe({
|
|
2530
|
+
next: async (e) => {
|
|
2531
|
+
if (e.type == RuntimeEventTypes.TextMessageContent) {
|
|
2532
|
+
await pushTextChunk(e.content);
|
|
2533
|
+
textChunks.push(e.content);
|
|
2534
|
+
}
|
|
2535
|
+
},
|
|
2536
|
+
error: (err) => {
|
|
2537
|
+
logger2.error({
|
|
2538
|
+
err
|
|
2539
|
+
}, "Error in text message content stream");
|
|
2540
|
+
interruptStreaming$.next({
|
|
2541
|
+
reason: "Error streaming message content",
|
|
2542
|
+
messageId
|
|
2543
|
+
});
|
|
2544
|
+
stopStreamingText();
|
|
2545
|
+
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
2546
|
+
},
|
|
2547
|
+
complete: () => {
|
|
2548
|
+
logger2.debug("Text message content stream completed");
|
|
2549
|
+
streamingTextStatus.next(new SuccessMessageStatus());
|
|
2550
|
+
stopStreamingText();
|
|
2551
|
+
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
2552
|
+
outputMessages.push(plainToInstance(TextMessage, {
|
|
2553
|
+
id: messageId,
|
|
2554
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2555
|
+
content: textChunks.join(""),
|
|
2556
|
+
role: MessageRole.assistant
|
|
2557
|
+
}));
|
|
2558
|
+
}
|
|
2559
|
+
});
|
|
2560
|
+
})
|
|
2561
|
+
});
|
|
2562
|
+
break;
|
|
2563
|
+
case RuntimeEventTypes.ActionExecutionStart:
|
|
2564
|
+
logger2.debug("Action execution start event received");
|
|
2565
|
+
const actionExecutionArgumentStream = eventStream.pipe(
|
|
2566
|
+
skipWhile((e) => e !== event),
|
|
2567
|
+
// take until the action execution end event
|
|
2568
|
+
takeWhile((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
|
|
2569
|
+
// filter out any other action execution events or action execution ids
|
|
2570
|
+
filter((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
|
|
2571
|
+
);
|
|
2572
|
+
const streamingArgumentsStatus = new Subject();
|
|
2573
|
+
pushMessage({
|
|
2574
|
+
id: event.actionExecutionId,
|
|
2575
|
+
parentMessageId: event.parentMessageId,
|
|
2576
|
+
status: firstValueFrom(streamingArgumentsStatus),
|
|
2577
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2578
|
+
name: event.actionName,
|
|
2579
|
+
arguments: new Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
|
|
2580
|
+
logger2.debug("Action execution argument stream created");
|
|
2581
|
+
const argumentChunks = [];
|
|
2582
|
+
let actionExecutionArgumentSubscription;
|
|
2583
|
+
actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
|
|
2584
|
+
next: async (e) => {
|
|
2585
|
+
if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
|
|
2586
|
+
await pushArgumentsChunk(e.args);
|
|
2587
|
+
argumentChunks.push(e.args);
|
|
2588
|
+
}
|
|
2589
|
+
},
|
|
2590
|
+
error: (err) => {
|
|
2591
|
+
logger2.error({
|
|
2592
|
+
err
|
|
2593
|
+
}, "Error in action execution argument stream");
|
|
2594
|
+
streamingArgumentsStatus.next(plainToInstance(FailedMessageStatus, {
|
|
2595
|
+
reason: "An unknown error has occurred in the action execution argument stream"
|
|
2596
|
+
}));
|
|
2597
|
+
stopStreamingArguments();
|
|
2598
|
+
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
2599
|
+
},
|
|
2600
|
+
complete: () => {
|
|
2601
|
+
logger2.debug("Action execution argument stream completed");
|
|
2602
|
+
streamingArgumentsStatus.next(new SuccessMessageStatus());
|
|
2603
|
+
stopStreamingArguments();
|
|
2604
|
+
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
2605
|
+
outputMessages.push(plainToInstance(ActionExecutionMessage, {
|
|
2606
|
+
id: event.actionExecutionId,
|
|
2607
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2608
|
+
name: event.actionName,
|
|
2609
|
+
arguments: argumentChunks.join("")
|
|
2610
|
+
}));
|
|
2611
|
+
}
|
|
2612
|
+
});
|
|
2613
|
+
})
|
|
2614
|
+
});
|
|
2615
|
+
break;
|
|
2616
|
+
case RuntimeEventTypes.ActionExecutionResult:
|
|
2617
|
+
logger2.debug({
|
|
2618
|
+
result: event.result
|
|
2619
|
+
}, "Action execution result event received");
|
|
2620
|
+
pushMessage({
|
|
2621
|
+
id: "result-" + event.actionExecutionId,
|
|
2622
|
+
status: new SuccessMessageStatus(),
|
|
2623
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2624
|
+
actionExecutionId: event.actionExecutionId,
|
|
2625
|
+
actionName: event.actionName,
|
|
2626
|
+
result: event.result
|
|
2627
|
+
});
|
|
2628
|
+
outputMessages.push(plainToInstance(ResultMessage, {
|
|
2629
|
+
id: "result-" + event.actionExecutionId,
|
|
2630
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2631
|
+
actionExecutionId: event.actionExecutionId,
|
|
2632
|
+
actionName: event.actionName,
|
|
2633
|
+
result: event.result
|
|
2634
|
+
}));
|
|
2635
|
+
break;
|
|
2636
|
+
case RuntimeEventTypes.AgentStateMessage:
|
|
2637
|
+
logger2.debug({
|
|
2638
|
+
event
|
|
2639
|
+
}, "Agent message event received");
|
|
2640
|
+
pushMessage({
|
|
2641
|
+
id: randomId(),
|
|
2642
|
+
status: new SuccessMessageStatus(),
|
|
2643
|
+
threadId: event.threadId,
|
|
2644
|
+
agentName: event.agentName,
|
|
2645
|
+
nodeName: event.nodeName,
|
|
2646
|
+
runId: event.runId,
|
|
2647
|
+
active: event.active,
|
|
2648
|
+
state: event.state,
|
|
2649
|
+
running: event.running,
|
|
2650
|
+
role: MessageRole.assistant,
|
|
2651
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
2652
|
+
});
|
|
2653
|
+
outputMessages.push(plainToInstance(AgentStateMessage, {
|
|
2654
|
+
id: randomId(),
|
|
2655
|
+
threadId: event.threadId,
|
|
2656
|
+
agentName: event.agentName,
|
|
2657
|
+
nodeName: event.nodeName,
|
|
2658
|
+
runId: event.runId,
|
|
2659
|
+
active: event.active,
|
|
2660
|
+
state: event.state,
|
|
2661
|
+
running: event.running,
|
|
2662
|
+
role: MessageRole.assistant,
|
|
2663
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
2664
|
+
}));
|
|
2665
|
+
break;
|
|
2666
|
+
}
|
|
2667
|
+
},
|
|
2668
|
+
error: (err) => {
|
|
2669
|
+
var _a3, _b2, _c2, _d2, _e, _f;
|
|
2670
|
+
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)) {
|
|
2671
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
2672
|
+
description: err.message || "Agent error occurred",
|
|
2673
|
+
// Include original error information for frontend to extract
|
|
2674
|
+
originalError: {
|
|
2675
|
+
code: err.code || ((_b2 = err.extensions) == null ? void 0 : _b2.code),
|
|
2676
|
+
statusCode: err.statusCode || ((_c2 = err.extensions) == null ? void 0 : _c2.statusCode),
|
|
2677
|
+
severity: err.severity || ((_d2 = err.extensions) == null ? void 0 : _d2.severity),
|
|
2678
|
+
visibility: err.visibility || ((_e = err.extensions) == null ? void 0 : _e.visibility),
|
|
2679
|
+
originalErrorType: err.originalErrorType || ((_f = err.extensions) == null ? void 0 : _f.originalErrorType),
|
|
2680
|
+
extensions: err.extensions
|
|
2681
|
+
}
|
|
2682
|
+
}));
|
|
2683
|
+
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
2684
|
+
rejectOutputMessagesPromise(err);
|
|
2685
|
+
stopStreamingMessages();
|
|
2686
|
+
return;
|
|
2687
|
+
}
|
|
2688
|
+
responseStatus$.next(new UnknownErrorResponse({
|
|
2689
|
+
description: `An unknown error has occurred in the event stream`
|
|
2690
|
+
}));
|
|
2691
|
+
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
2692
|
+
stopStreamingMessages();
|
|
2693
|
+
rejectOutputMessagesPromise(err);
|
|
2694
|
+
},
|
|
2695
|
+
complete: async () => {
|
|
2696
|
+
var _a3;
|
|
2697
|
+
logger2.debug("Event stream completed");
|
|
2698
|
+
if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
|
|
2699
|
+
logger2.debug("Guardrails is enabled, waiting for guardrails result");
|
|
2700
|
+
await firstValueFrom(guardrailsResult$);
|
|
2701
|
+
}
|
|
2702
|
+
responseStatus$.next(new SuccessResponseStatus());
|
|
2703
|
+
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
2704
|
+
stopStreamingMessages();
|
|
2705
|
+
resolveOutputMessagesPromise(outputMessages);
|
|
2706
|
+
}
|
|
2707
|
+
});
|
|
2708
|
+
})
|
|
2709
|
+
};
|
|
2710
|
+
return response;
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
__name(CopilotResolver, "CopilotResolver");
|
|
2714
|
+
_ts_decorate17([
|
|
2715
|
+
Query(() => String),
|
|
2716
|
+
_ts_metadata17("design:type", Function),
|
|
2717
|
+
_ts_metadata17("design:paramtypes", []),
|
|
2718
|
+
_ts_metadata17("design:returntype", Promise)
|
|
2719
|
+
], CopilotResolver.prototype, "hello", null);
|
|
2720
|
+
_ts_decorate17([
|
|
2721
|
+
Query(() => AgentsResponse),
|
|
2722
|
+
_ts_param(0, Ctx()),
|
|
2723
|
+
_ts_metadata17("design:type", Function),
|
|
2724
|
+
_ts_metadata17("design:paramtypes", [
|
|
2725
|
+
typeof GraphQLContext === "undefined" ? Object : GraphQLContext
|
|
2726
|
+
]),
|
|
2727
|
+
_ts_metadata17("design:returntype", Promise)
|
|
2728
|
+
], CopilotResolver.prototype, "availableAgents", null);
|
|
2729
|
+
_ts_decorate17([
|
|
2730
|
+
Mutation(() => CopilotResponse),
|
|
2731
|
+
_ts_param(0, Ctx()),
|
|
2732
|
+
_ts_param(1, Arg("data")),
|
|
2733
|
+
_ts_param(2, Arg("properties", () => GraphQLJSONObject, {
|
|
2734
|
+
nullable: true
|
|
2735
|
+
})),
|
|
2736
|
+
_ts_metadata17("design:type", Function),
|
|
2737
|
+
_ts_metadata17("design:paramtypes", [
|
|
2738
|
+
typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
|
|
2739
|
+
typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
|
|
2740
|
+
typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
|
|
2741
|
+
]),
|
|
2742
|
+
_ts_metadata17("design:returntype", Promise)
|
|
2743
|
+
], CopilotResolver.prototype, "generateCopilotResponse", null);
|
|
2744
|
+
CopilotResolver = _ts_decorate17([
|
|
2745
|
+
Resolver(() => CopilotResponse)
|
|
2746
|
+
], CopilotResolver);
|
|
2747
|
+
|
|
2748
|
+
// src/lib/integrations/shared.ts
|
|
2749
|
+
import { useDeferStream } from "@graphql-yoga/plugin-defer-stream";
|
|
2750
|
+
|
|
2751
|
+
// src/lib/logger.ts
|
|
2752
|
+
import createPinoLogger from "pino";
|
|
2753
|
+
import pretty from "pino-pretty";
|
|
2754
|
+
function createLogger(options) {
|
|
2755
|
+
const { level, component } = options || {};
|
|
2756
|
+
const stream = pretty({
|
|
2757
|
+
colorize: true
|
|
2758
|
+
});
|
|
2759
|
+
const logger2 = createPinoLogger({
|
|
2760
|
+
level: process.env.LOG_LEVEL || level || "error",
|
|
2761
|
+
redact: {
|
|
2762
|
+
paths: [
|
|
2763
|
+
"pid",
|
|
2764
|
+
"hostname"
|
|
2765
|
+
],
|
|
2766
|
+
remove: true
|
|
2767
|
+
}
|
|
2768
|
+
}, stream);
|
|
2769
|
+
if (component) {
|
|
2770
|
+
return logger2.child({
|
|
2771
|
+
component
|
|
2772
|
+
});
|
|
2773
|
+
} else {
|
|
2774
|
+
return logger2;
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
__name(createLogger, "createLogger");
|
|
2778
|
+
|
|
2779
|
+
// src/graphql/resolvers/state.resolver.ts
|
|
2780
|
+
import { Arg as Arg2, Resolver as Resolver2 } from "type-graphql";
|
|
2781
|
+
import { Ctx as Ctx2 } from "type-graphql";
|
|
2782
|
+
import { Query as Query2 } from "type-graphql";
|
|
2783
|
+
|
|
2784
|
+
// src/graphql/types/load-agent-state-response.type.ts
|
|
2785
|
+
import { Field as Field17, ObjectType as ObjectType5 } from "type-graphql";
|
|
2786
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2787
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2788
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2789
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2790
|
+
else
|
|
2791
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2792
|
+
if (d = decorators[i])
|
|
2793
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2794
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2795
|
+
}
|
|
2796
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
2797
|
+
function _ts_metadata18(k, v) {
|
|
2798
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2799
|
+
return Reflect.metadata(k, v);
|
|
2800
|
+
}
|
|
2801
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
2802
|
+
var LoadAgentStateResponse = class {
|
|
2803
|
+
threadId;
|
|
2804
|
+
threadExists;
|
|
2805
|
+
state;
|
|
2806
|
+
messages;
|
|
2807
|
+
};
|
|
2808
|
+
__name(LoadAgentStateResponse, "LoadAgentStateResponse");
|
|
2809
|
+
_ts_decorate18([
|
|
2810
|
+
Field17(() => String),
|
|
2811
|
+
_ts_metadata18("design:type", String)
|
|
2812
|
+
], LoadAgentStateResponse.prototype, "threadId", void 0);
|
|
2813
|
+
_ts_decorate18([
|
|
2814
|
+
Field17(() => Boolean),
|
|
2815
|
+
_ts_metadata18("design:type", Boolean)
|
|
2816
|
+
], LoadAgentStateResponse.prototype, "threadExists", void 0);
|
|
2817
|
+
_ts_decorate18([
|
|
2818
|
+
Field17(() => String),
|
|
2819
|
+
_ts_metadata18("design:type", String)
|
|
2820
|
+
], LoadAgentStateResponse.prototype, "state", void 0);
|
|
2821
|
+
_ts_decorate18([
|
|
2822
|
+
Field17(() => String),
|
|
2823
|
+
_ts_metadata18("design:type", String)
|
|
2824
|
+
], LoadAgentStateResponse.prototype, "messages", void 0);
|
|
2825
|
+
LoadAgentStateResponse = _ts_decorate18([
|
|
2826
|
+
ObjectType5()
|
|
2827
|
+
], LoadAgentStateResponse);
|
|
2828
|
+
|
|
2829
|
+
// src/graphql/inputs/load-agent-state.input.ts
|
|
2830
|
+
import { Field as Field18, InputType as InputType13 } from "type-graphql";
|
|
2831
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
2832
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2833
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2834
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2835
|
+
else
|
|
2836
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2837
|
+
if (d = decorators[i])
|
|
2838
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2839
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2840
|
+
}
|
|
2841
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
2842
|
+
function _ts_metadata19(k, v) {
|
|
2843
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2844
|
+
return Reflect.metadata(k, v);
|
|
2845
|
+
}
|
|
2846
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
2847
|
+
var LoadAgentStateInput = class {
|
|
2848
|
+
threadId;
|
|
2849
|
+
agentName;
|
|
2850
|
+
};
|
|
2851
|
+
__name(LoadAgentStateInput, "LoadAgentStateInput");
|
|
2852
|
+
_ts_decorate19([
|
|
2853
|
+
Field18(() => String),
|
|
2854
|
+
_ts_metadata19("design:type", String)
|
|
2855
|
+
], LoadAgentStateInput.prototype, "threadId", void 0);
|
|
2856
|
+
_ts_decorate19([
|
|
2857
|
+
Field18(() => String),
|
|
2858
|
+
_ts_metadata19("design:type", String)
|
|
2859
|
+
], LoadAgentStateInput.prototype, "agentName", void 0);
|
|
2860
|
+
LoadAgentStateInput = _ts_decorate19([
|
|
2861
|
+
InputType13()
|
|
2862
|
+
], LoadAgentStateInput);
|
|
2863
|
+
|
|
2864
|
+
// src/graphql/resolvers/state.resolver.ts
|
|
2865
|
+
import { CopilotKitAgentDiscoveryError } from "@copilotkit/shared";
|
|
2866
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
2867
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2868
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2869
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2870
|
+
else
|
|
2871
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2872
|
+
if (d = decorators[i])
|
|
2873
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2874
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2875
|
+
}
|
|
2876
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
2877
|
+
function _ts_metadata20(k, v) {
|
|
2878
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2879
|
+
return Reflect.metadata(k, v);
|
|
2880
|
+
}
|
|
2881
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
2882
|
+
function _ts_param2(paramIndex, decorator) {
|
|
2883
|
+
return function(target, key) {
|
|
2884
|
+
decorator(target, key, paramIndex);
|
|
2885
|
+
};
|
|
2886
|
+
}
|
|
2887
|
+
__name(_ts_param2, "_ts_param");
|
|
2888
|
+
var StateResolver = class {
|
|
2889
|
+
async loadAgentState(ctx, data) {
|
|
2890
|
+
const agents = [];
|
|
2891
|
+
const hasAgent = agents.some((agent) => agent.name === data.agentName);
|
|
2892
|
+
if (!hasAgent) {
|
|
2893
|
+
throw new CopilotKitAgentDiscoveryError({
|
|
2894
|
+
agentName: data.agentName,
|
|
2895
|
+
availableAgents: agents.map((a) => ({
|
|
2896
|
+
name: a.name,
|
|
2897
|
+
id: a.name
|
|
2898
|
+
}))
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
const state = {};
|
|
2902
|
+
return state;
|
|
2903
|
+
}
|
|
2904
|
+
};
|
|
2905
|
+
__name(StateResolver, "StateResolver");
|
|
2906
|
+
_ts_decorate20([
|
|
2907
|
+
Query2(() => LoadAgentStateResponse),
|
|
2908
|
+
_ts_param2(0, Ctx2()),
|
|
2909
|
+
_ts_param2(1, Arg2("data")),
|
|
2910
|
+
_ts_metadata20("design:type", Function),
|
|
2911
|
+
_ts_metadata20("design:paramtypes", [
|
|
2912
|
+
typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
|
|
2913
|
+
typeof LoadAgentStateInput === "undefined" ? Object : LoadAgentStateInput
|
|
2914
|
+
]),
|
|
2915
|
+
_ts_metadata20("design:returntype", Promise)
|
|
2916
|
+
], StateResolver.prototype, "loadAgentState", null);
|
|
2917
|
+
StateResolver = _ts_decorate20([
|
|
2918
|
+
Resolver2(() => LoadAgentStateResponse)
|
|
2919
|
+
], StateResolver);
|
|
2920
|
+
|
|
2921
|
+
// src/lib/integrations/shared.ts
|
|
2922
|
+
var packageJson2 = __toESM(require_package());
|
|
2923
|
+
import { CopilotKitError as CopilotKitError3, CopilotKitErrorCode as CopilotKitErrorCode2 } from "@copilotkit/shared";
|
|
2924
|
+
var logger = createLogger();
|
|
2925
|
+
var addCustomHeaderPlugin = {
|
|
2926
|
+
onResponse({ response }) {
|
|
2927
|
+
response.headers.set("X-CopilotKit-Runtime-Version", packageJson2.version);
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2930
|
+
async function createContext(initialContext, copilotKitContext, contextLogger, properties = {}) {
|
|
2931
|
+
logger.debug({
|
|
2932
|
+
copilotKitContext
|
|
2933
|
+
}, "Creating GraphQL context");
|
|
2934
|
+
const ctx = {
|
|
2935
|
+
...initialContext,
|
|
2936
|
+
_copilotkit: {
|
|
2937
|
+
...copilotKitContext
|
|
2938
|
+
},
|
|
2939
|
+
properties: {
|
|
2940
|
+
...properties
|
|
2941
|
+
},
|
|
2942
|
+
logger: contextLogger
|
|
2943
|
+
};
|
|
2944
|
+
return ctx;
|
|
2945
|
+
}
|
|
2946
|
+
__name(createContext, "createContext");
|
|
2947
|
+
function buildSchema(options = {}) {
|
|
2948
|
+
logger.debug("Building GraphQL schema...");
|
|
2949
|
+
const schema = buildSchemaSync({
|
|
2950
|
+
resolvers: [
|
|
2951
|
+
CopilotResolver,
|
|
2952
|
+
StateResolver
|
|
2953
|
+
],
|
|
2954
|
+
emitSchemaFile: options.emitSchemaFile
|
|
2955
|
+
});
|
|
2956
|
+
logger.debug("GraphQL schema built successfully");
|
|
2957
|
+
return schema;
|
|
2958
|
+
}
|
|
2959
|
+
__name(buildSchema, "buildSchema");
|
|
2960
|
+
function getCommonConfig(options) {
|
|
2961
|
+
var _a;
|
|
2962
|
+
const logLevel = process.env.LOG_LEVEL || options.logLevel || "error";
|
|
2963
|
+
const logger2 = createLogger({
|
|
2964
|
+
level: logLevel,
|
|
2965
|
+
component: "getCommonConfig"
|
|
2966
|
+
});
|
|
2967
|
+
const contextLogger = createLogger({
|
|
2968
|
+
level: logLevel
|
|
2969
|
+
});
|
|
2970
|
+
if (options.cloud) {
|
|
2971
|
+
telemetry_client_default.setCloudConfiguration({
|
|
2972
|
+
publicApiKey: options.cloud.publicApiKey,
|
|
2973
|
+
baseUrl: options.cloud.baseUrl
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2976
|
+
if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
|
|
2977
|
+
telemetry_client_default.setGlobalProperties({
|
|
2978
|
+
_copilotkit: {
|
|
2979
|
+
...options.properties._copilotkit
|
|
2980
|
+
}
|
|
2981
|
+
});
|
|
2982
|
+
}
|
|
2983
|
+
telemetry_client_default.setGlobalProperties({
|
|
2984
|
+
runtime: {
|
|
2985
|
+
serviceAdapter: options.serviceAdapter.constructor.name
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
2988
|
+
const userErrorCodes = [
|
|
2989
|
+
CopilotKitErrorCode2.AGENT_NOT_FOUND,
|
|
2990
|
+
CopilotKitErrorCode2.API_NOT_FOUND,
|
|
2991
|
+
CopilotKitErrorCode2.REMOTE_ENDPOINT_NOT_FOUND,
|
|
2992
|
+
CopilotKitErrorCode2.CONFIGURATION_ERROR,
|
|
2993
|
+
CopilotKitErrorCode2.MISSING_PUBLIC_API_KEY_ERROR
|
|
2994
|
+
];
|
|
2995
|
+
return {
|
|
2996
|
+
logging: createLogger({
|
|
2997
|
+
component: "Yoga GraphQL",
|
|
2998
|
+
level: logLevel
|
|
2999
|
+
}),
|
|
3000
|
+
schema: buildSchema(),
|
|
3001
|
+
plugins: [
|
|
3002
|
+
useDeferStream(),
|
|
3003
|
+
addCustomHeaderPlugin
|
|
3004
|
+
],
|
|
3005
|
+
context: (ctx) => createContext(ctx, options, contextLogger, options.properties),
|
|
3006
|
+
// Suppress logging for user configuration errors
|
|
3007
|
+
maskedErrors: {
|
|
3008
|
+
maskError: (error, message, isDev) => {
|
|
3009
|
+
const originalError = error.originalError || error;
|
|
3010
|
+
const extensions = error.extensions;
|
|
3011
|
+
const errorCode = extensions == null ? void 0 : extensions.code;
|
|
3012
|
+
if (errorCode && userErrorCodes.includes(errorCode)) {
|
|
3013
|
+
console.debug("User configuration error:", error.message);
|
|
3014
|
+
return error;
|
|
3015
|
+
}
|
|
3016
|
+
if (originalError instanceof CopilotKitError3 && userErrorCodes.includes(originalError.code)) {
|
|
3017
|
+
console.debug("User configuration error:", error.message);
|
|
3018
|
+
return error;
|
|
3019
|
+
}
|
|
3020
|
+
console.error("Application error:", error);
|
|
3021
|
+
return error;
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
};
|
|
3025
|
+
}
|
|
3026
|
+
__name(getCommonConfig, "getCommonConfig");
|
|
3027
|
+
|
|
3028
|
+
// src/lib/integrations/node-http/index.ts
|
|
3029
|
+
function copilotRuntimeNodeHttpEndpoint(options) {
|
|
3030
|
+
var _a;
|
|
3031
|
+
const commonConfig = getCommonConfig(options);
|
|
3032
|
+
telemetry_client_default.setGlobalProperties({
|
|
3033
|
+
runtime: {
|
|
3034
|
+
framework: "node-http"
|
|
3035
|
+
}
|
|
3036
|
+
});
|
|
3037
|
+
if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
|
|
3038
|
+
telemetry_client_default.setGlobalProperties({
|
|
3039
|
+
_copilotkit: options.properties._copilotkit
|
|
3040
|
+
});
|
|
3041
|
+
}
|
|
3042
|
+
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
3043
|
+
const logger2 = commonConfig.logging;
|
|
3044
|
+
logger2.debug("Creating Node HTTP endpoint");
|
|
3045
|
+
const serviceAdapter = options.serviceAdapter;
|
|
3046
|
+
options.runtime.handleServiceAdapter(serviceAdapter);
|
|
3047
|
+
return createCopilotEndpoint({
|
|
3048
|
+
runtime: options.runtime.instance,
|
|
3049
|
+
basePath: options.baseUrl
|
|
3050
|
+
});
|
|
3051
|
+
}
|
|
3052
|
+
__name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
|
|
3053
|
+
|
|
3054
|
+
export {
|
|
3055
|
+
extractParametersFromSchema,
|
|
3056
|
+
convertMCPToolsToActions,
|
|
3057
|
+
generateMcpToolInstructions,
|
|
3058
|
+
LangGraphHttpAgent,
|
|
3059
|
+
CustomEventNames2 as CustomEventNames,
|
|
3060
|
+
LangGraphAgent,
|
|
3061
|
+
CopilotRuntime,
|
|
3062
|
+
copilotKitEndpoint,
|
|
3063
|
+
langGraphPlatformEndpoint,
|
|
3064
|
+
resolveEndpointType,
|
|
3065
|
+
getRuntimeInstanceTelemetryInfo,
|
|
3066
|
+
telemetry_client_default,
|
|
3067
|
+
createLogger,
|
|
3068
|
+
addCustomHeaderPlugin,
|
|
3069
|
+
createContext,
|
|
3070
|
+
buildSchema,
|
|
3071
|
+
getCommonConfig,
|
|
3072
|
+
copilotRuntimeNodeHttpEndpoint
|
|
3073
|
+
};
|
|
3074
|
+
//# sourceMappingURL=chunk-OFSV5GET.mjs.map
|