@copilotkit/runtime 1.9.0 → 1.9.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 +11 -0
- package/dist/{chunk-M3JAEGRU.mjs → chunk-32OC2CBT.mjs} +2 -2
- package/dist/{chunk-GI32PQX6.mjs → chunk-5CY2MEHT.mjs} +3 -3
- package/dist/chunk-5CY2MEHT.mjs.map +1 -0
- package/dist/{chunk-U74GJORZ.mjs → chunk-MKAQQQ7D.mjs} +4 -4
- package/dist/chunk-MKAQQQ7D.mjs.map +1 -0
- package/dist/{chunk-FK4NZL4G.mjs → chunk-T3HIFVU2.mjs} +3 -3
- package/dist/chunk-T3HIFVU2.mjs.map +1 -0
- package/dist/{chunk-YCN5NOAP.mjs → chunk-YVZCIKZM.mjs} +26 -6
- package/dist/chunk-YVZCIKZM.mjs.map +1 -0
- package/dist/index.js +29 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/lib/index.js +29 -9
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.js +29 -9
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.js +26 -6
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +2 -2
- package/dist/lib/integrations/node-express/index.js +26 -6
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +2 -2
- package/dist/lib/integrations/node-http/index.js +25 -5
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/package.json +4 -4
- package/src/graphql/resolvers/copilot.resolver.ts +13 -0
- package/src/lib/integrations/nest/index.ts +1 -4
- package/src/lib/integrations/nextjs/app-router.ts +1 -4
- package/src/lib/integrations/nextjs/pages-router.ts +1 -4
- package/src/lib/integrations/node-express/index.ts +1 -4
- package/src/lib/integrations/node-http/index.ts +1 -4
- package/src/lib/telemetry-client.ts +11 -2
- package/dist/chunk-FK4NZL4G.mjs.map +0 -1
- package/dist/chunk-GI32PQX6.mjs.map +0 -1
- package/dist/chunk-U74GJORZ.mjs.map +0 -1
- package/dist/chunk-YCN5NOAP.mjs.map +0 -1
- /package/dist/{chunk-M3JAEGRU.mjs.map → chunk-32OC2CBT.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.9.0",
|
|
12
|
+
"version": "1.9.1-next.0",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"tsup": "^6.7.0",
|
|
34
34
|
"typescript": "^5.2.3",
|
|
35
35
|
"zod-to-json-schema": "^3.23.5",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"eslint-config-custom": "1.4.6",
|
|
37
|
+
"tsconfig": "1.4.6"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@ag-ui/client": "0.0.28",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"rxjs": "^7.8.1",
|
|
67
67
|
"type-graphql": "2.0.0-rc.1",
|
|
68
68
|
"zod": "^3.23.3",
|
|
69
|
-
"@copilotkit/shared": "1.9.0"
|
|
69
|
+
"@copilotkit/shared": "1.9.1-next.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@ag-ui/client": ">=0.0.28",
|
|
@@ -144,6 +144,19 @@ export class CopilotResolver {
|
|
|
144
144
|
telemetry.capture("oss.runtime.copilot_request_created", {
|
|
145
145
|
"cloud.guardrails.enabled": data.cloud?.guardrails !== undefined,
|
|
146
146
|
requestType: data.metadata.requestType,
|
|
147
|
+
"cloud.api_key_provided": !!ctx.request.headers.get("x-copilotcloud-public-api-key"),
|
|
148
|
+
...(ctx.request.headers.get("x-copilotcloud-public-api-key")
|
|
149
|
+
? {
|
|
150
|
+
"cloud.public_api_key": ctx.request.headers.get("x-copilotcloud-public-api-key"),
|
|
151
|
+
}
|
|
152
|
+
: {}),
|
|
153
|
+
...(ctx._copilotkit.baseUrl
|
|
154
|
+
? {
|
|
155
|
+
"cloud.base_url": ctx._copilotkit.baseUrl,
|
|
156
|
+
}
|
|
157
|
+
: {
|
|
158
|
+
"cloud.base_url": "https://api.cloud.copilotkit.ai",
|
|
159
|
+
}),
|
|
147
160
|
});
|
|
148
161
|
|
|
149
162
|
let logger = ctx.logger.child({ component: "CopilotResolver.generateCopilotResponse" });
|
|
@@ -9,9 +9,6 @@ export function copilotRuntimeNestEndpoint(options: CreateCopilotRuntimeServerOp
|
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
telemetry.capture(
|
|
13
|
-
"oss.runtime.instance_created",
|
|
14
|
-
getRuntimeInstanceTelemetryInfo(options.runtime),
|
|
15
|
-
);
|
|
12
|
+
telemetry.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
16
13
|
return copilotRuntimeNodeHttpEndpoint(options);
|
|
17
14
|
}
|
|
@@ -17,10 +17,7 @@ export function copilotRuntimeNextJSAppRouterEndpoint(options: CreateCopilotRunt
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
telemetry.capture(
|
|
21
|
-
"oss.runtime.instance_created",
|
|
22
|
-
getRuntimeInstanceTelemetryInfo(options.runtime),
|
|
23
|
-
);
|
|
20
|
+
telemetry.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
24
21
|
|
|
25
22
|
const logger = commonConfig.logging;
|
|
26
23
|
logger.debug("Creating NextJS App Router endpoint");
|
|
@@ -32,10 +32,7 @@ export function copilotRuntimeNextJSPagesRouterEndpoint(
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
telemetry.capture(
|
|
36
|
-
"oss.runtime.instance_created",
|
|
37
|
-
getRuntimeInstanceTelemetryInfo(options.runtime),
|
|
38
|
-
);
|
|
35
|
+
telemetry.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
39
36
|
|
|
40
37
|
const logger = commonConfig.logging;
|
|
41
38
|
logger.debug("Creating NextJS Pages Router endpoint");
|
|
@@ -9,9 +9,6 @@ export function copilotRuntimeNodeExpressEndpoint(options: CreateCopilotRuntimeS
|
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
telemetry.capture(
|
|
13
|
-
"oss.runtime.instance_created",
|
|
14
|
-
getRuntimeInstanceTelemetryInfo(options.runtime),
|
|
15
|
-
);
|
|
12
|
+
telemetry.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
16
13
|
return copilotRuntimeNodeHttpEndpoint(options);
|
|
17
14
|
}
|
|
@@ -17,10 +17,7 @@ export function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServ
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
telemetry.capture(
|
|
21
|
-
"oss.runtime.instance_created",
|
|
22
|
-
getRuntimeInstanceTelemetryInfo(options.runtime),
|
|
23
|
-
);
|
|
20
|
+
telemetry.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options));
|
|
24
21
|
|
|
25
22
|
const logger = commonConfig.logging;
|
|
26
23
|
logger.debug("Creating Node HTTP endpoint");
|
|
@@ -3,6 +3,7 @@ import { EndpointType, LangGraphPlatformEndpoint } from "./runtime/remote-action
|
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { CopilotRuntime, resolveEndpointType } from "./runtime/copilot-runtime";
|
|
5
5
|
import { RuntimeInstanceCreatedInfo } from "@copilotkit/shared/src/telemetry/events";
|
|
6
|
+
import { CreateCopilotRuntimeServerOptions } from "./integrations/shared";
|
|
6
7
|
const packageJson = require("../../package.json");
|
|
7
8
|
|
|
8
9
|
const telemetryClient = new TelemetryClient({
|
|
@@ -11,8 +12,9 @@ const telemetryClient = new TelemetryClient({
|
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
export function getRuntimeInstanceTelemetryInfo(
|
|
14
|
-
|
|
15
|
+
options: CreateCopilotRuntimeServerOptions,
|
|
15
16
|
): RuntimeInstanceCreatedInfo {
|
|
17
|
+
const runtime = options.runtime;
|
|
16
18
|
const endpointsInfo = runtime.remoteEndpointDefinitions.reduce(
|
|
17
19
|
(acc, endpoint) => {
|
|
18
20
|
let info = { ...acc };
|
|
@@ -42,13 +44,20 @@ export function getRuntimeInstanceTelemetryInfo(
|
|
|
42
44
|
{ endpointTypes: [], agentsAmount: null, hashedKey: null },
|
|
43
45
|
);
|
|
44
46
|
|
|
47
|
+
// Get public API key from options.cloud.publicApiKey
|
|
48
|
+
const publicApiKey = options.cloud?.publicApiKey;
|
|
49
|
+
const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
|
|
50
|
+
|
|
45
51
|
return {
|
|
46
52
|
actionsAmount: runtime.actions.length,
|
|
47
53
|
endpointsAmount: runtime.remoteEndpointDefinitions.length,
|
|
48
54
|
endpointTypes: endpointsInfo.endpointTypes,
|
|
49
55
|
agentsAmount: endpointsInfo.agentsAmount,
|
|
50
56
|
hashedLgcKey: endpointsInfo.hashedKey,
|
|
51
|
-
|
|
57
|
+
"cloud.api_key_provided": apiKeyProvided,
|
|
58
|
+
...(apiKeyProvided ? { "cloud.public_api_key": publicApiKey } : {}),
|
|
59
|
+
...(options.cloud?.baseUrl ? { "cloud.base_url": options.cloud.baseUrl } : {}),
|
|
60
|
+
} as RuntimeInstanceCreatedInfo;
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
export default telemetryClient;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/integrations/nest/index.ts"],"sourcesContent":["import { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry, { getRuntimeInstanceTelemetryInfo } from \"../../telemetry-client\";\n\nexport function copilotRuntimeNestEndpoint(options: CreateCopilotRuntimeServerOptions) {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"nest\",\n },\n });\n\n telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options.runtime),\n );\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n"],"mappings":";;;;;;;;;;AAIO,SAASA,2BAA2BC,SAA0C;AACnFC,2BAAUC,oBAAoB;IAC5BC,SAAS;MACPC,WAAW;IACb;EACF,CAAA;AAEAH,2BAAUI,QACR,gCACAC,gCAAgCN,QAAQG,OAAO,CAAA;AAEjD,SAAOI,+BAA+BP,OAAAA;AACxC;AAZgBD;","names":["copilotRuntimeNestEndpoint","options","telemetry","setGlobalProperties","runtime","framework","capture","getRuntimeInstanceTelemetryInfo","copilotRuntimeNodeHttpEndpoint"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/integrations/node-express/index.ts"],"sourcesContent":["import { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry, { getRuntimeInstanceTelemetryInfo } from \"../../telemetry-client\";\n\nexport function copilotRuntimeNodeExpressEndpoint(options: CreateCopilotRuntimeServerOptions) {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-express\",\n },\n });\n\n telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options.runtime),\n );\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n"],"mappings":";;;;;;;;;;AAIO,SAASA,kCAAkCC,SAA0C;AAC1FC,2BAAUC,oBAAoB;IAC5BC,SAAS;MACPC,WAAW;IACb;EACF,CAAA;AAEAH,2BAAUI,QACR,gCACAC,gCAAgCN,QAAQG,OAAO,CAAA;AAEjD,SAAOI,+BAA+BP,OAAAA;AACxC;AAZgBD;","names":["copilotRuntimeNodeExpressEndpoint","options","telemetry","setGlobalProperties","runtime","framework","capture","getRuntimeInstanceTelemetryInfo","copilotRuntimeNodeHttpEndpoint"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/integrations/nextjs/app-router.ts","../src/lib/integrations/nextjs/pages-router.ts"],"sourcesContent":["import { createYoga } from \"graphql-yoga\";\nimport { CreateCopilotRuntimeServerOptions, getCommonConfig } from \"../shared\";\nimport telemetry, { getRuntimeInstanceTelemetryInfo } from \"../../telemetry-client\";\n\nexport function copilotRuntimeNextJSAppRouterEndpoint(options: CreateCopilotRuntimeServerOptions) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"nextjs-app-router\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options.runtime),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating NextJS App Router endpoint\");\n\n const yoga = createYoga({\n ...commonConfig,\n graphqlEndpoint: options.endpoint,\n fetchAPI: { Response: globalThis.Response },\n });\n\n return {\n handleRequest: yoga,\n GET: yoga as any,\n POST: yoga as any,\n OPTIONS: yoga as any,\n };\n}\n","import { YogaServerInstance, createYoga } from \"graphql-yoga\";\nimport { CreateCopilotRuntimeServerOptions, GraphQLContext, getCommonConfig } from \"../shared\";\nimport telemetry, { getRuntimeInstanceTelemetryInfo } from \"../../telemetry-client\";\n\nexport const config = {\n api: {\n bodyParser: false,\n },\n};\n\nexport type CopilotRuntimeServerInstance<T> = YogaServerInstance<T, Partial<GraphQLContext>>;\n\n// This import is needed to fix the type error\n// Fix is currently in TypeScript 5.5 beta, waiting for stable version\n// https://github.com/microsoft/TypeScript/issues/42873#issuecomment-2066874644\nexport type {} from \"@whatwg-node/server\";\n\nexport function copilotRuntimeNextJSPagesRouterEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n): CopilotRuntimeServerInstance<GraphQLContext> {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"nextjs-pages-router\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options.runtime),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating NextJS Pages Router endpoint\");\n\n const yoga = createYoga({\n ...commonConfig,\n graphqlEndpoint: options.endpoint,\n });\n\n return yoga;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAASA,kBAAkB;AAIpB,SAASC,sCAAsCC,SAA0C;AAJhG;AAKE,QAAMC,eAAeC,gBAAgBF,OAAAA;AAErCG,2BAAUC,oBAAoB;IAC5BC,SAAS;MACPC,WAAW;IACb;EACF,CAAA;AAEA,OAAIN,aAAQO,eAARP,mBAAoBQ,aAAa;AACnCL,6BAAUC,oBAAoB;MAC5BI,aAAaR,QAAQO,WAAWC;IAClC,CAAA;EACF;AAEAL,2BAAUM,QACR,gCACAC,gCAAgCV,QAAQK,OAAO,CAAA;AAGjD,QAAMM,SAASV,aAAaW;AAC5BD,SAAOE,MAAM,qCAAA;AAEb,QAAMC,OAAOC,WAAW;IACtB,GAAGd;IACHe,iBAAiBhB,QAAQiB;IACzBC,UAAU;MAAEC,UAAUC,WAAWD;IAAS;EAC5C,CAAA;AAEA,SAAO;IACLE,eAAeP;IACfQ,KAAKR;IACLS,MAAMT;IACNU,SAASV;EACX;AACF;AAnCgBf;;;ACJhB,SAA6B0B,cAAAA,mBAAkB;AAIxC,IAAMC,SAAS;EACpBC,KAAK;IACHC,YAAY;EACd;AACF;AASO,SAASC,wCACdC,SAA0C;AAlB5C;AAoBE,QAAMC,eAAeC,gBAAgBF,OAAAA;AAErCG,2BAAUC,oBAAoB;IAC5BC,SAAS;MACPC,WAAW;IACb;EACF,CAAA;AAEA,OAAIN,aAAQO,eAARP,mBAAoBQ,aAAa;AACnCL,6BAAUC,oBAAoB;MAC5BI,aAAaR,QAAQO,WAAWC;IAClC,CAAA;EACF;AAEAL,2BAAUM,QACR,gCACAC,gCAAgCV,QAAQK,OAAO,CAAA;AAGjD,QAAMM,SAASV,aAAaW;AAC5BD,SAAOE,MAAM,uCAAA;AAEb,QAAMC,OAAOC,YAAW;IACtB,GAAGd;IACHe,iBAAiBhB,QAAQiB;EAC3B,CAAA;AAEA,SAAOH;AACT;AA/BgBf;","names":["createYoga","copilotRuntimeNextJSAppRouterEndpoint","options","commonConfig","getCommonConfig","telemetry","setGlobalProperties","runtime","framework","properties","_copilotkit","capture","getRuntimeInstanceTelemetryInfo","logger","logging","debug","yoga","createYoga","graphqlEndpoint","endpoint","fetchAPI","Response","globalThis","handleRequest","GET","POST","OPTIONS","createYoga","config","api","bodyParser","copilotRuntimeNextJSPagesRouterEndpoint","options","commonConfig","getCommonConfig","telemetry","setGlobalProperties","runtime","framework","properties","_copilotkit","capture","getRuntimeInstanceTelemetryInfo","logger","logging","debug","yoga","createYoga","graphqlEndpoint","endpoint"]}
|