@copilotkit/runtime 1.50.0-beta.9 → 1.50.1-next.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 +165 -0
- package/dist/chunk-27JKTS6P.mjs +1704 -0
- package/dist/chunk-27JKTS6P.mjs.map +1 -0
- package/dist/{chunk-FMU55SEU.mjs → chunk-2GPTVDTO.mjs} +2 -2
- package/dist/chunk-3AJVKDZX.mjs +3097 -0
- package/dist/chunk-3AJVKDZX.mjs.map +1 -0
- package/dist/{chunk-BJEYMRDD.mjs → chunk-45RCC3ZS.mjs} +2 -2
- 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-Z752VE75.mjs → chunk-4KES76K3.mjs} +2 -2
- 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-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-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-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-SBCOROE4.mjs → chunk-DCEEHMLJ.mjs} +16 -1
- 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-TTUAEJLD.mjs → chunk-ERUOA47O.mjs} +11 -2
- 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-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-DZV4ZIAR.mjs → chunk-OFSV5GET.mjs} +17 -6
- 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-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-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/types/converted/index.d.ts +1 -1
- package/dist/graphql/types/converted/index.js +16 -110
- package/dist/graphql/types/converted/index.js.map +1 -1
- package/dist/graphql/types/converted/index.mjs +2 -3
- package/dist/{groq-adapter-50bc6e4a.d.ts → groq-adapter-540da9c3.d.ts} +6 -1
- 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.d.ts +72 -9
- package/dist/index.js +127 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -34
- 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-74a52292.d.ts → langserve-9fc76ce5.d.ts} +1 -0
- package/dist/lib/index.d.ts +5 -59
- package/dist/lib/index.js +3702 -803
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +20 -18
- package/dist/lib/integrations/index.d.ts +15 -9
- package/dist/lib/integrations/index.js +215 -187
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +8 -7
- package/dist/lib/integrations/nest/index.d.ts +5 -6
- package/dist/lib/integrations/nest/index.js +197 -175
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +6 -5
- package/dist/lib/integrations/node-express/index.d.ts +5 -6
- package/dist/lib/integrations/node-express/index.js +197 -175
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +6 -5
- package/dist/lib/integrations/node-http/index.d.ts +5 -6
- package/dist/lib/integrations/node-http/index.js +197 -175
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +5 -4
- package/dist/service-adapters/index.d.ts +7 -11
- package/dist/service-adapters/index.js +8 -21
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +2 -4
- package/dist/shared-0a7346ce.d.ts +466 -0
- package/dist/{shared-f6d43ef8.d.ts → shared-35c6eb04.d.ts} +3 -1
- package/dist/shared-9ed1dc31.d.ts +414 -0
- package/dist/shared-da5708fe.d.ts +449 -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
- package/src/service-adapters/google/google-genai-adapter.ts +19 -4
- package/dist/chunk-DZV4ZIAR.mjs.map +0 -1
- package/dist/chunk-SBCOROE4.mjs.map +0 -1
- package/dist/chunk-TTUAEJLD.mjs.map +0 -1
- /package/dist/{chunk-FMU55SEU.mjs.map → chunk-2GPTVDTO.mjs.map} +0 -0
- /package/dist/{chunk-BJEYMRDD.mjs.map → chunk-45RCC3ZS.mjs.map} +0 -0
- /package/dist/{chunk-Z752VE75.mjs.map → chunk-4KES76K3.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { TelemetryClient, CopilotKitLowLevelError, CopilotKitErrorCode, randomUUID, randomId, CopilotKitMisuseError, getZodParameters, readBody, CopilotKitError, CopilotKitAgentDiscoveryError, parseJson, convertJsonSchemaToZodSchema } from '@copilotkit/shared';
|
|
2
|
+
import { TelemetryClient, CopilotKitLowLevelError, CopilotKitErrorCode, randomUUID, randomId, isTelemetryDisabled, CopilotKitMisuseError, getZodParameters, readBody, CopilotKitError, CopilotKitAgentDiscoveryError, parseJson, convertJsonSchemaToZodSchema } from '@copilotkit/shared';
|
|
3
3
|
import { HumanMessage, AIMessage, SystemMessage, ToolMessage } from '@langchain/core/messages';
|
|
4
4
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
5
5
|
import { registerEnumType, Field, InputType, ObjectType, createUnionType, InterfaceType, Query, Ctx, Mutation, Arg, Resolver, buildSchemaSync } from 'type-graphql';
|
|
6
|
-
import {
|
|
6
|
+
import { tap, catchError, finalize, ReplaySubject, shareReplay, firstValueFrom, skipWhile, takeWhile, filter, Subject, take } from 'rxjs';
|
|
7
7
|
import { GraphQLJSON, GraphQLJSONObject } from 'graphql-scalars';
|
|
8
8
|
import { Repeater } from 'graphql-yoga';
|
|
9
9
|
import { plainToInstance } from 'class-transformer';
|
|
@@ -65,7 +65,7 @@ var require_package = __commonJS({
|
|
|
65
65
|
publishConfig: {
|
|
66
66
|
access: "public"
|
|
67
67
|
},
|
|
68
|
-
version: "1.50.
|
|
68
|
+
version: "1.50.1-next.0",
|
|
69
69
|
sideEffects: false,
|
|
70
70
|
main: "./dist/index.js",
|
|
71
71
|
module: "./dist/index.mjs",
|
|
@@ -116,12 +116,14 @@ var require_package = __commonJS({
|
|
|
116
116
|
vitest: "^3.2.4"
|
|
117
117
|
},
|
|
118
118
|
dependencies: {
|
|
119
|
+
"@ag-ui/client": "^0.0.42",
|
|
120
|
+
"@ag-ui/core": "^0.0.42",
|
|
121
|
+
"@ag-ui/langgraph": "^0.0.20",
|
|
119
122
|
"@copilotkit/shared": "workspace:*",
|
|
120
|
-
"@copilotkitnext/agent": "0.0.
|
|
121
|
-
"@copilotkitnext/runtime": "0.0.
|
|
123
|
+
"@copilotkitnext/agent": "0.0.31",
|
|
124
|
+
"@copilotkitnext/runtime": "0.0.31",
|
|
122
125
|
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
123
126
|
"@hono/node-server": "^1.13.5",
|
|
124
|
-
"@langchain/core": "^0.3.38",
|
|
125
127
|
"@scarf/scarf": "^1.3.0",
|
|
126
128
|
"class-transformer": "^0.5.1",
|
|
127
129
|
"class-validator": "^0.14.1",
|
|
@@ -129,7 +131,6 @@ var require_package = __commonJS({
|
|
|
129
131
|
"graphql-scalars": "^1.23.0",
|
|
130
132
|
"graphql-yoga": "^5.3.1",
|
|
131
133
|
hono: "^4.10.3",
|
|
132
|
-
langchain: "^0.3.3",
|
|
133
134
|
openai: "^4.85.1",
|
|
134
135
|
"partial-json": "^0.1.7",
|
|
135
136
|
pino: "^9.2.0",
|
|
@@ -141,27 +142,20 @@ var require_package = __commonJS({
|
|
|
141
142
|
},
|
|
142
143
|
peerDependencies: {
|
|
143
144
|
"@anthropic-ai/sdk": "^0.57.0",
|
|
144
|
-
"@
|
|
145
|
-
"@
|
|
146
|
-
"@
|
|
147
|
-
"@
|
|
148
|
-
"@
|
|
149
|
-
"@langchain/
|
|
150
|
-
"@langchain/community": "^0.3.58",
|
|
151
|
-
"@langchain/google-gauth": "^0.1.0",
|
|
152
|
-
"@langchain/langgraph-sdk": "^0.0.70",
|
|
153
|
-
"@langchain/openai": "^0.4.2",
|
|
145
|
+
"@langchain/aws": ">=0.1.9",
|
|
146
|
+
"@langchain/core": ">=0.3.66",
|
|
147
|
+
"@langchain/community": ">=0.3.58",
|
|
148
|
+
"@langchain/google-gauth": ">=0.1.0",
|
|
149
|
+
"@langchain/langgraph-sdk": ">=0.1.2",
|
|
150
|
+
"@langchain/openai": ">=0.4.2",
|
|
154
151
|
"groq-sdk": ">=0.3.0 <1.0.0",
|
|
155
|
-
langchain: "
|
|
152
|
+
langchain: ">=0.3.3",
|
|
156
153
|
openai: "^4.85.1"
|
|
157
154
|
},
|
|
158
155
|
peerDependenciesMeta: {
|
|
159
156
|
"@anthropic-ai/sdk": {
|
|
160
157
|
optional: true
|
|
161
158
|
},
|
|
162
|
-
"@ag-ui/langgraph": {
|
|
163
|
-
optional: true
|
|
164
|
-
},
|
|
165
159
|
"@langchain/aws": {
|
|
166
160
|
optional: true
|
|
167
161
|
},
|
|
@@ -855,11 +849,17 @@ var LangChainAdapter = class {
|
|
|
855
849
|
__name(LangChainAdapter, "LangChainAdapter");
|
|
856
850
|
|
|
857
851
|
// src/service-adapters/google/google-genai-adapter.ts
|
|
858
|
-
var DEFAULT_MODEL2 = "gemini-
|
|
852
|
+
var DEFAULT_MODEL2 = "gemini-2.5-flash";
|
|
853
|
+
var DEFAULT_API_VERSION = "v1";
|
|
854
|
+
var hasWarnedDefaultGoogleModel = false;
|
|
859
855
|
var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
860
856
|
provider = "google";
|
|
861
857
|
model = DEFAULT_MODEL2;
|
|
862
858
|
constructor(options) {
|
|
859
|
+
if (!hasWarnedDefaultGoogleModel && !(options == null ? void 0 : options.model) && !(options == null ? void 0 : options.apiVersion)) {
|
|
860
|
+
console.warn(`You are using the GoogleGenerativeAIAdapter without explicitly setting a model or apiVersion. CopilotKit will default to apiVersion="v1" and model="${DEFAULT_MODEL2}". To silence this warning, pass model and apiVersion when constructing the adapter.`);
|
|
861
|
+
hasWarnedDefaultGoogleModel = true;
|
|
862
|
+
}
|
|
863
863
|
super({
|
|
864
864
|
chainFn: async ({ messages, tools, threadId }) => {
|
|
865
865
|
const { ChatGoogle } = __require("@langchain/google-gauth");
|
|
@@ -871,11 +871,11 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
|
|
|
871
871
|
const aiMsg = message;
|
|
872
872
|
return aiMsg.content && String(aiMsg.content).trim().length > 0 || aiMsg.tool_calls && aiMsg.tool_calls.length > 0;
|
|
873
873
|
});
|
|
874
|
-
this.model = (options == null ? void 0 : options.model) ??
|
|
874
|
+
this.model = (options == null ? void 0 : options.model) ?? DEFAULT_MODEL2;
|
|
875
875
|
const model = new ChatGoogle({
|
|
876
876
|
apiKey: (options == null ? void 0 : options.apiKey) ?? process.env.GOOGLE_API_KEY,
|
|
877
877
|
modelName: this.model,
|
|
878
|
-
apiVersion:
|
|
878
|
+
apiVersion: (options == null ? void 0 : options.apiVersion) ?? DEFAULT_API_VERSION
|
|
879
879
|
}).bindTools(tools);
|
|
880
880
|
return model.stream(filteredMessages, {
|
|
881
881
|
metadata: {
|
|
@@ -3233,6 +3233,82 @@ function aguiMessageWithImageToGQLMessage(message) {
|
|
|
3233
3233
|
});
|
|
3234
3234
|
}
|
|
3235
3235
|
__name(aguiMessageWithImageToGQLMessage, "aguiMessageWithImageToGQLMessage");
|
|
3236
|
+
var TelemetryAgentRunner = class {
|
|
3237
|
+
_runner;
|
|
3238
|
+
hashedLgcKey;
|
|
3239
|
+
constructor(config2) {
|
|
3240
|
+
this._runner = (config2 == null ? void 0 : config2.runner) ?? new InMemoryAgentRunner();
|
|
3241
|
+
this.hashedLgcKey = (config2 == null ? void 0 : config2.langsmithApiKey) ? createHash("sha256").update(config2.langsmithApiKey).digest("hex") : void 0;
|
|
3242
|
+
}
|
|
3243
|
+
/**
|
|
3244
|
+
* Runs an agent with telemetry tracking.
|
|
3245
|
+
* Wraps the underlying runner's Observable stream with telemetry events.
|
|
3246
|
+
*/
|
|
3247
|
+
run(...args) {
|
|
3248
|
+
const streamInfo = {
|
|
3249
|
+
hashedLgcKey: this.hashedLgcKey
|
|
3250
|
+
};
|
|
3251
|
+
let streamErrored = false;
|
|
3252
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
|
|
3253
|
+
hashedLgcKey: this.hashedLgcKey
|
|
3254
|
+
});
|
|
3255
|
+
return this._runner.run(...args).pipe(
|
|
3256
|
+
// Extract metadata from events if available
|
|
3257
|
+
tap((event) => {
|
|
3258
|
+
var _a;
|
|
3259
|
+
const rawEvent = event.rawEvent;
|
|
3260
|
+
if (rawEvent == null ? void 0 : rawEvent.data) {
|
|
3261
|
+
const data = rawEvent.data;
|
|
3262
|
+
if ((_a = data == null ? void 0 : data.output) == null ? void 0 : _a.model) {
|
|
3263
|
+
streamInfo.model = data.output.model;
|
|
3264
|
+
streamInfo.provider = data.output.model;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
if (rawEvent == null ? void 0 : rawEvent.metadata) {
|
|
3268
|
+
const metadata = rawEvent.metadata;
|
|
3269
|
+
if (metadata == null ? void 0 : metadata.langgraph_host) {
|
|
3270
|
+
streamInfo.langGraphHost = metadata.langgraph_host;
|
|
3271
|
+
}
|
|
3272
|
+
if (metadata == null ? void 0 : metadata.langgraph_version) {
|
|
3273
|
+
streamInfo.langGraphVersion = metadata.langgraph_version;
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
}),
|
|
3277
|
+
catchError((error) => {
|
|
3278
|
+
streamErrored = true;
|
|
3279
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
|
|
3280
|
+
...streamInfo,
|
|
3281
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3282
|
+
});
|
|
3283
|
+
throw error;
|
|
3284
|
+
}),
|
|
3285
|
+
finalize(() => {
|
|
3286
|
+
if (!streamErrored) {
|
|
3287
|
+
telemetry_client_default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
|
|
3288
|
+
}
|
|
3289
|
+
})
|
|
3290
|
+
);
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* Delegates to the underlying runner's connect method
|
|
3294
|
+
*/
|
|
3295
|
+
connect(...args) {
|
|
3296
|
+
return this._runner.connect(...args);
|
|
3297
|
+
}
|
|
3298
|
+
/**
|
|
3299
|
+
* Delegates to the underlying runner's isRunning method
|
|
3300
|
+
*/
|
|
3301
|
+
isRunning(...args) {
|
|
3302
|
+
return this._runner.isRunning(...args);
|
|
3303
|
+
}
|
|
3304
|
+
/**
|
|
3305
|
+
* Delegates to the underlying runner's stop method
|
|
3306
|
+
*/
|
|
3307
|
+
stop(...args) {
|
|
3308
|
+
return this._runner.stop(...args);
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
__name(TelemetryAgentRunner, "TelemetryAgentRunner");
|
|
3236
3312
|
|
|
3237
3313
|
// src/lib/runtime/types.ts
|
|
3238
3314
|
var EndpointType;
|
|
@@ -3386,12 +3462,16 @@ var CopilotRuntime = class {
|
|
|
3386
3462
|
constructor(params) {
|
|
3387
3463
|
const agents = (params == null ? void 0 : params.agents) ?? {};
|
|
3388
3464
|
const endpointAgents = this.assignEndpointsToAgents((params == null ? void 0 : params.remoteEndpoints) ?? []);
|
|
3465
|
+
const baseRunner = (params == null ? void 0 : params.runner) ?? new InMemoryAgentRunner();
|
|
3466
|
+
const runner = isTelemetryDisabled() ? baseRunner : new TelemetryAgentRunner({
|
|
3467
|
+
runner: baseRunner
|
|
3468
|
+
});
|
|
3389
3469
|
this.runtimeArgs = {
|
|
3390
3470
|
agents: {
|
|
3391
3471
|
...endpointAgents,
|
|
3392
3472
|
...agents
|
|
3393
3473
|
},
|
|
3394
|
-
runner
|
|
3474
|
+
runner,
|
|
3395
3475
|
// TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready
|
|
3396
3476
|
// transcriptionService: params?.transcriptionService,
|
|
3397
3477
|
beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
|
|
@@ -3417,6 +3497,7 @@ var CopilotRuntime = class {
|
|
|
3417
3497
|
}
|
|
3418
3498
|
handleServiceAdapter(serviceAdapter) {
|
|
3419
3499
|
this.runtimeArgs.agents = Promise.resolve(this.runtimeArgs.agents ?? {}).then(async (agents) => {
|
|
3500
|
+
var _a;
|
|
3420
3501
|
let agentsList = agents;
|
|
3421
3502
|
const isAgentsListEmpty = !Object.keys(agents).length;
|
|
3422
3503
|
const hasServiceAdapter = Boolean(serviceAdapter);
|
|
@@ -3434,10 +3515,11 @@ var CopilotRuntime = class {
|
|
|
3434
3515
|
model: `${serviceAdapter.provider}/${serviceAdapter.model}`
|
|
3435
3516
|
});
|
|
3436
3517
|
}
|
|
3437
|
-
|
|
3518
|
+
const actions = (_a = this.params) == null ? void 0 : _a.actions;
|
|
3519
|
+
if (actions) {
|
|
3438
3520
|
const mcpTools = await this.getToolsFromMCP();
|
|
3439
3521
|
agentsList = this.assignToolsToAgents(agents, [
|
|
3440
|
-
...this.getToolsFromActions(
|
|
3522
|
+
...this.getToolsFromActions(actions),
|
|
3441
3523
|
...mcpTools
|
|
3442
3524
|
]);
|
|
3443
3525
|
}
|
|
@@ -3484,11 +3566,24 @@ var CopilotRuntime = class {
|
|
|
3484
3566
|
}
|
|
3485
3567
|
createOnBeforeRequestHandler(params) {
|
|
3486
3568
|
return async (hookParams) => {
|
|
3487
|
-
var _a, _b;
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3569
|
+
var _a, _b, _c, _d;
|
|
3570
|
+
const { request } = hookParams;
|
|
3571
|
+
const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
|
|
3572
|
+
const body = await readBody(request);
|
|
3573
|
+
const forwardedProps = body.forwardedProps;
|
|
3574
|
+
const cloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
|
|
3575
|
+
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
3576
|
+
"cloud.guardrails.enabled": ((_a = forwardedProps == null ? void 0 : forwardedProps.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
3577
|
+
requestType: ((_b = forwardedProps == null ? void 0 : forwardedProps.metadata) == null ? void 0 : _b.requestType) ?? "unknown",
|
|
3578
|
+
"cloud.api_key_provided": !!publicApiKey,
|
|
3579
|
+
...publicApiKey ? {
|
|
3580
|
+
"cloud.public_api_key": publicApiKey
|
|
3581
|
+
} : {},
|
|
3582
|
+
"cloud.base_url": cloudBaseUrl
|
|
3583
|
+
});
|
|
3584
|
+
(_c = params == null ? void 0 : params.beforeRequestMiddleware) == null ? void 0 : _c.call(params, hookParams);
|
|
3585
|
+
if ((_d = params == null ? void 0 : params.middleware) == null ? void 0 : _d.onBeforeRequest) {
|
|
3586
|
+
const { request: request2, runtime, path } = hookParams;
|
|
3492
3587
|
const gqlMessages = aguiToGQL(body.messages).reduce((acc, msg) => {
|
|
3493
3588
|
if ("role" in msg && msg.role === "user") {
|
|
3494
3589
|
acc.inputMessages.push(msg);
|
|
@@ -3506,7 +3601,7 @@ var CopilotRuntime = class {
|
|
|
3506
3601
|
runId: body.runId,
|
|
3507
3602
|
inputMessages,
|
|
3508
3603
|
properties: body.forwardedProps,
|
|
3509
|
-
url:
|
|
3604
|
+
url: request2.url
|
|
3510
3605
|
});
|
|
3511
3606
|
}
|
|
3512
3607
|
};
|
|
@@ -5469,6 +5564,6 @@ var EmptyAdapter = class {
|
|
|
5469
5564
|
__name(EmptyAdapter, "EmptyAdapter");
|
|
5470
5565
|
var ExperimentalEmptyAdapter = EmptyAdapter;
|
|
5471
5566
|
|
|
5472
|
-
export { AnthropicAdapter, BedrockAdapter, CopilotRuntime, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GroqAdapter, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAssistantAdapter, RemoteChain, UnifyAdapter, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };
|
|
5567
|
+
export { AnthropicAdapter, BedrockAdapter, CopilotRuntime, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GroqAdapter, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAssistantAdapter, RemoteChain, TelemetryAgentRunner, UnifyAdapter, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };
|
|
5473
5568
|
//# sourceMappingURL=out.js.map
|
|
5474
5569
|
//# sourceMappingURL=index.mjs.map
|