@copilotkit/runtime 1.0.5 → 1.0.7
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/.turbo/turbo-build.log +44 -44
- package/CHANGELOG.md +17 -0
- package/dist/{chunk-TEOA3DRE.mjs → chunk-74N2ME6S.mjs} +16 -4
- package/dist/chunk-74N2ME6S.mjs.map +1 -0
- package/dist/{chunk-67DNPQCA.mjs → chunk-JA2IRWRL.mjs} +2 -9
- package/dist/chunk-JA2IRWRL.mjs.map +1 -0
- package/dist/{chunk-ENJUY6YN.mjs → chunk-W7VNHFVP.mjs} +2 -2
- package/dist/{chunk-UPH4KIVR.mjs → chunk-XUJZPK4P.mjs} +3 -3
- package/dist/{chunk-YBYJR245.mjs → chunk-YNH6B4QZ.mjs} +14 -2
- package/dist/chunk-YNH6B4QZ.mjs.map +1 -0
- package/dist/{chunk-LZ6WZIQ3.mjs → chunk-Z2G5OVBH.mjs} +2 -2
- package/dist/index.js +28 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/lib/index.js +28 -11
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -6
- package/dist/lib/integrations/index.js +27 -3
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.js +15 -3
- 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 +15 -3
- 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 +15 -3
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/service-adapters/index.js +1 -8
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -1
- package/package.json +4 -6
- package/src/lib/integrations/nextjs/app-router.ts +6 -0
- package/src/lib/integrations/nextjs/pages-router.ts +6 -0
- package/src/lib/integrations/node-http/index.ts +6 -0
- package/src/lib/integrations/shared.ts +8 -0
- package/src/service-adapters/openai/utils.ts +1 -8
- package/dist/chunk-67DNPQCA.mjs.map +0 -1
- package/dist/chunk-TEOA3DRE.mjs.map +0 -1
- package/dist/chunk-YBYJR245.mjs.map +0 -1
- /package/dist/{chunk-ENJUY6YN.mjs.map → chunk-W7VNHFVP.mjs.map} +0 -0
- /package/dist/{chunk-UPH4KIVR.mjs.map → chunk-XUJZPK4P.mjs.map} +0 -0
- /package/dist/{chunk-LZ6WZIQ3.mjs.map → chunk-Z2G5OVBH.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCommonConfig,
|
|
3
3
|
telemetry_client_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-74N2ME6S.mjs";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-44O2JGUY.mjs";
|
|
@@ -9,12 +9,18 @@ import {
|
|
|
9
9
|
// src/lib/integrations/nextjs/app-router.ts
|
|
10
10
|
import { createYoga } from "graphql-yoga";
|
|
11
11
|
function copilotRuntimeNextJSAppRouterEndpoint(options) {
|
|
12
|
+
var _a;
|
|
12
13
|
const commonConfig = getCommonConfig(options);
|
|
13
14
|
telemetry_client_default.setGlobalProperties({
|
|
14
15
|
runtime: {
|
|
15
16
|
framework: "nextjs-app-router"
|
|
16
17
|
}
|
|
17
18
|
});
|
|
19
|
+
if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
|
|
20
|
+
telemetry_client_default.setGlobalProperties({
|
|
21
|
+
_copilotkit: options.properties._copilotkit
|
|
22
|
+
});
|
|
23
|
+
}
|
|
18
24
|
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
19
25
|
const logger = commonConfig.logging;
|
|
20
26
|
logger.debug("Creating NextJS App Router endpoint");
|
|
@@ -42,12 +48,18 @@ var config = {
|
|
|
42
48
|
}
|
|
43
49
|
};
|
|
44
50
|
function copilotRuntimeNextJSPagesRouterEndpoint(options) {
|
|
51
|
+
var _a;
|
|
45
52
|
const commonConfig = getCommonConfig(options);
|
|
46
53
|
telemetry_client_default.setGlobalProperties({
|
|
47
54
|
runtime: {
|
|
48
55
|
framework: "nextjs-pages-router"
|
|
49
56
|
}
|
|
50
57
|
});
|
|
58
|
+
if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
|
|
59
|
+
telemetry_client_default.setGlobalProperties({
|
|
60
|
+
_copilotkit: options.properties._copilotkit
|
|
61
|
+
});
|
|
62
|
+
}
|
|
51
63
|
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
52
64
|
const logger = commonConfig.logging;
|
|
53
65
|
logger.debug("Creating NextJS Pages Router endpoint");
|
|
@@ -64,4 +76,4 @@ export {
|
|
|
64
76
|
config,
|
|
65
77
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
66
78
|
};
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-YNH6B4QZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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 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(\"oss.runtime.instance_created\", {});\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 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(\"oss.runtime.instance_created\", {});\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,QAAQ,gCAAgC,CAAC,CAAA;AAEnD,QAAMC,SAAST,aAAaU;AAC5BD,SAAOE,MAAM,qCAAA;AAEb,QAAMC,OAAOC,WAAW;IACtB,GAAGb;IACHc,iBAAiBf,QAAQgB;IACzBC,UAAU;MAAEC,UAAUC,WAAWD;IAAS;EAC5C,CAAA;AAEA,SAAO;IACLE,eAAeP;IACfQ,KAAKR;IACLS,MAAMT;IACNU,SAASV;EACX;AACF;AAhCgBd;;;ACJhB,SAA6ByB,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,QAAQ,gCAAgC,CAAC,CAAA;AAEnD,QAAMC,SAAST,aAAaU;AAC5BD,SAAOE,MAAM,uCAAA;AAEb,QAAMC,OAAOC,YAAW;IACtB,GAAGb;IACHc,iBAAiBf,QAAQgB;EAC3B,CAAA;AAEA,SAAOH;AACT;AA5BgBd;","names":["createYoga","copilotRuntimeNextJSAppRouterEndpoint","options","commonConfig","getCommonConfig","telemetry","setGlobalProperties","runtime","framework","properties","_copilotkit","capture","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","logger","logging","debug","yoga","createYoga","graphqlEndpoint","endpoint"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
copilotRuntimeNodeHttpEndpoint,
|
|
3
3
|
telemetry_client_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-74N2ME6S.mjs";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
7
|
} from "./chunk-44O2JGUY.mjs";
|
|
@@ -21,4 +21,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
|
|
|
21
21
|
export {
|
|
22
22
|
copilotRuntimeNodeExpressEndpoint
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-Z2G5OVBH.mjs.map
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
publishConfig: {
|
|
45
45
|
access: "public"
|
|
46
46
|
},
|
|
47
|
-
version: "1.0.
|
|
47
|
+
version: "1.0.7",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -90,14 +90,12 @@ var require_package = __commonJS({
|
|
|
90
90
|
"graphql-scalars": "^1.23.0",
|
|
91
91
|
"graphql-yoga": "^5.3.1",
|
|
92
92
|
"groq-sdk": "^0.5.0",
|
|
93
|
-
"js-tiktoken": "^1.0.8",
|
|
94
93
|
langchain: "^0.1.36",
|
|
95
94
|
openai: "^4.50.0",
|
|
96
95
|
pino: "^9.2.0",
|
|
97
96
|
"pino-pretty": "^11.2.1",
|
|
98
97
|
"reflect-metadata": "^0.2.2",
|
|
99
98
|
rxjs: "^7.8.1",
|
|
100
|
-
tiktoken: "^1.0.15",
|
|
101
99
|
"type-graphql": "2.0.0-rc.1",
|
|
102
100
|
zod: "^3.23.3"
|
|
103
101
|
},
|
|
@@ -203,7 +201,6 @@ var ResultMessage = class extends BaseMessage {
|
|
|
203
201
|
__name(ResultMessage, "ResultMessage");
|
|
204
202
|
|
|
205
203
|
// src/service-adapters/openai/utils.ts
|
|
206
|
-
var import_js_tiktoken = require("js-tiktoken");
|
|
207
204
|
function limitMessagesToTokenCount(messages, tools, model, maxTokens) {
|
|
208
205
|
maxTokens || (maxTokens = maxTokensForOpenAIModel(model));
|
|
209
206
|
const result = [];
|
|
@@ -288,13 +285,7 @@ function countMessageTokens(model, message) {
|
|
|
288
285
|
}
|
|
289
286
|
__name(countMessageTokens, "countMessageTokens");
|
|
290
287
|
function countTokens(model, text) {
|
|
291
|
-
|
|
292
|
-
try {
|
|
293
|
-
enc = (0, import_js_tiktoken.encodingForModel)(model);
|
|
294
|
-
} catch (e) {
|
|
295
|
-
enc = (0, import_js_tiktoken.encodingForModel)("gpt-4");
|
|
296
|
-
}
|
|
297
|
-
return enc.encode(text).length;
|
|
288
|
+
return text.length / 3;
|
|
298
289
|
}
|
|
299
290
|
__name(countTokens, "countTokens");
|
|
300
291
|
function convertActionInputToOpenAITool(action) {
|
|
@@ -2575,6 +2566,7 @@ function buildSchema(options = {}) {
|
|
|
2575
2566
|
}
|
|
2576
2567
|
__name(buildSchema, "buildSchema");
|
|
2577
2568
|
function getCommonConfig(options) {
|
|
2569
|
+
var _a;
|
|
2578
2570
|
const logLevel = process.env.LOG_LEVEL || options.logLevel || "error";
|
|
2579
2571
|
const logger2 = createLogger({
|
|
2580
2572
|
level: logLevel,
|
|
@@ -2589,6 +2581,13 @@ function getCommonConfig(options) {
|
|
|
2589
2581
|
baseUrl: options.cloud.baseUrl
|
|
2590
2582
|
});
|
|
2591
2583
|
}
|
|
2584
|
+
if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
|
|
2585
|
+
telemetry_client_default.setGlobalProperties({
|
|
2586
|
+
_copilotkit: {
|
|
2587
|
+
...options.properties._copilotkit
|
|
2588
|
+
}
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2592
2591
|
telemetry_client_default.setGlobalProperties({
|
|
2593
2592
|
runtime: {
|
|
2594
2593
|
serviceAdapter: options.serviceAdapter.constructor.name
|
|
@@ -2611,12 +2610,18 @@ __name(getCommonConfig, "getCommonConfig");
|
|
|
2611
2610
|
// src/lib/integrations/nextjs/app-router.ts
|
|
2612
2611
|
var import_graphql_yoga2 = require("graphql-yoga");
|
|
2613
2612
|
function copilotRuntimeNextJSAppRouterEndpoint(options) {
|
|
2613
|
+
var _a;
|
|
2614
2614
|
const commonConfig = getCommonConfig(options);
|
|
2615
2615
|
telemetry_client_default.setGlobalProperties({
|
|
2616
2616
|
runtime: {
|
|
2617
2617
|
framework: "nextjs-app-router"
|
|
2618
2618
|
}
|
|
2619
2619
|
});
|
|
2620
|
+
if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
|
|
2621
|
+
telemetry_client_default.setGlobalProperties({
|
|
2622
|
+
_copilotkit: options.properties._copilotkit
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2620
2625
|
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
2621
2626
|
const logger2 = commonConfig.logging;
|
|
2622
2627
|
logger2.debug("Creating NextJS App Router endpoint");
|
|
@@ -2644,12 +2649,18 @@ var config = {
|
|
|
2644
2649
|
}
|
|
2645
2650
|
};
|
|
2646
2651
|
function copilotRuntimeNextJSPagesRouterEndpoint(options) {
|
|
2652
|
+
var _a;
|
|
2647
2653
|
const commonConfig = getCommonConfig(options);
|
|
2648
2654
|
telemetry_client_default.setGlobalProperties({
|
|
2649
2655
|
runtime: {
|
|
2650
2656
|
framework: "nextjs-pages-router"
|
|
2651
2657
|
}
|
|
2652
2658
|
});
|
|
2659
|
+
if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
|
|
2660
|
+
telemetry_client_default.setGlobalProperties({
|
|
2661
|
+
_copilotkit: options.properties._copilotkit
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2653
2664
|
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
2654
2665
|
const logger2 = commonConfig.logging;
|
|
2655
2666
|
logger2.debug("Creating NextJS Pages Router endpoint");
|
|
@@ -2664,12 +2675,18 @@ __name(copilotRuntimeNextJSPagesRouterEndpoint, "copilotRuntimeNextJSPagesRouter
|
|
|
2664
2675
|
// src/lib/integrations/node-http/index.ts
|
|
2665
2676
|
var import_graphql_yoga4 = require("graphql-yoga");
|
|
2666
2677
|
function copilotRuntimeNodeHttpEndpoint(options) {
|
|
2678
|
+
var _a;
|
|
2667
2679
|
const commonConfig = getCommonConfig(options);
|
|
2668
2680
|
telemetry_client_default.setGlobalProperties({
|
|
2669
2681
|
runtime: {
|
|
2670
2682
|
framework: "node-http"
|
|
2671
2683
|
}
|
|
2672
2684
|
});
|
|
2685
|
+
if ((_a = options.properties) == null ? void 0 : _a._copilotkit) {
|
|
2686
|
+
telemetry_client_default.setGlobalProperties({
|
|
2687
|
+
_copilotkit: options.properties._copilotkit
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2673
2690
|
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
2674
2691
|
const logger2 = commonConfig.logging;
|
|
2675
2692
|
logger2.debug("Creating Node HTTP endpoint");
|