@copilotkit/runtime 1.0.0-beta.0 → 1.0.0-beta.2
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 +79 -65
- package/CHANGELOG.md +16 -0
- package/__snapshots__/schema/schema.graphql +15 -1
- package/dist/chunk-44O2JGUY.mjs +12 -0
- package/dist/{chunk-6YGDE3YI.mjs → chunk-6YZWDFF6.mjs} +154 -19
- package/dist/chunk-6YZWDFF6.mjs.map +1 -0
- package/dist/{chunk-JBDOA7MK.mjs → chunk-7QCEK4DP.mjs} +4 -4
- package/dist/{chunk-FRK6BXXV.mjs → chunk-DVDKD6F5.mjs} +3 -3
- package/dist/{chunk-OZMCHYYR.mjs → chunk-GEIBJJQ4.mjs} +3 -3
- package/dist/chunk-LGRJFIJL.mjs +24 -0
- package/dist/chunk-LGRJFIJL.mjs.map +1 -0
- package/dist/{chunk-6NZ4UMOD.mjs → chunk-RMZWGQ46.mjs} +2 -2
- package/dist/{chunk-2PJG3NAC.mjs → chunk-SVAGAMIO.mjs} +17 -4
- package/dist/chunk-SVAGAMIO.mjs.map +1 -0
- package/dist/{chunk-BYB2LNMK.mjs → chunk-U3V2BCGI.mjs} +2 -2
- package/dist/{chunk-JIKPSUGQ.mjs → chunk-WE6CBBR3.mjs} +5 -5
- package/dist/chunk-X4FJTCSL.mjs +24 -0
- package/dist/chunk-X4FJTCSL.mjs.map +1 -0
- package/dist/graphql/types/base/index.mjs +2 -2
- package/dist/graphql/types/converted/index.mjs +3 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +187 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -9
- package/dist/index.mjs.map +1 -1
- package/dist/lib/index.d.ts +6 -3
- package/dist/lib/index.js +187 -13
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +17 -9
- package/dist/lib/integrations/index.d.ts +6 -3
- package/dist/lib/integrations/index.js +187 -13
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +15 -7
- package/dist/lib/integrations/nest/index.d.ts +14 -0
- package/dist/lib/integrations/nest/index.js +1481 -0
- package/dist/lib/integrations/nest/index.js.map +1 -0
- package/dist/lib/integrations/nest/index.mjs +13 -0
- package/dist/lib/integrations/nest/index.mjs.map +1 -0
- package/dist/lib/integrations/node-express/index.d.ts +14 -0
- package/dist/lib/integrations/node-express/index.js +1481 -0
- package/dist/lib/integrations/node-express/index.js.map +1 -0
- package/dist/lib/integrations/node-express/index.mjs +13 -0
- package/dist/lib/integrations/node-express/index.mjs.map +1 -0
- package/dist/lib/integrations/node-http/index.d.ts +6 -2
- package/dist/lib/integrations/node-http/index.js +147 -13
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +6 -6
- package/dist/{pages-router-e81920d5.d.ts → pages-router-24897543.d.ts} +1 -1
- package/dist/service-adapters/index.mjs +5 -5
- package/dist/{index-0e75acd2.d.ts → shared-48c0f7b8.d.ts} +2 -5
- package/dist/utils/index.mjs +2 -2
- package/package.json +2 -2
- package/src/graphql/inputs/cloud-guardrails.input.ts +2 -2
- package/src/graphql/inputs/generate-copilot-response.input.ts +10 -0
- package/src/graphql/resolvers/copilot.resolver.ts +12 -3
- package/src/graphql/types/enums.ts +13 -0
- package/src/lib/integrations/index.ts +2 -0
- package/src/lib/integrations/nest/index.ts +14 -0
- package/src/lib/integrations/nextjs/app-router.ts +10 -0
- package/src/lib/integrations/nextjs/pages-router.ts +10 -0
- package/src/lib/integrations/node-express/index.ts +14 -0
- package/src/lib/integrations/node-http/index.ts +10 -0
- package/src/lib/integrations/shared.ts +14 -1
- package/src/lib/telemetry-client.ts +9 -0
- package/dist/chunk-2PJG3NAC.mjs.map +0 -1
- package/dist/chunk-6YGDE3YI.mjs.map +0 -1
- package/dist/chunk-RHQLCJGG.mjs +0 -7
- /package/dist/{chunk-RHQLCJGG.mjs.map → chunk-44O2JGUY.mjs.map} +0 -0
- /package/dist/{chunk-JBDOA7MK.mjs.map → chunk-7QCEK4DP.mjs.map} +0 -0
- /package/dist/{chunk-FRK6BXXV.mjs.map → chunk-DVDKD6F5.mjs.map} +0 -0
- /package/dist/{chunk-OZMCHYYR.mjs.map → chunk-GEIBJJQ4.mjs.map} +0 -0
- /package/dist/{chunk-6NZ4UMOD.mjs.map → chunk-RMZWGQ46.mjs.map} +0 -0
- /package/dist/{chunk-BYB2LNMK.mjs.map → chunk-U3V2BCGI.mjs.map} +0 -0
- /package/dist/{chunk-JIKPSUGQ.mjs.map → chunk-WE6CBBR3.mjs.map} +0 -0
package/dist/lib/index.mjs
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotRuntime,
|
|
3
3
|
flattenToolCallsNoDuplicates
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-WE6CBBR3.mjs";
|
|
5
5
|
import {
|
|
6
6
|
GoogleGenerativeAIAdapter,
|
|
7
7
|
LangChainAdapter,
|
|
8
8
|
OpenAIAdapter,
|
|
9
9
|
OpenAIAssistantAdapter
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-7QCEK4DP.mjs";
|
|
11
11
|
import {
|
|
12
12
|
config,
|
|
13
13
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
14
14
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-SVAGAMIO.mjs";
|
|
16
|
+
import {
|
|
17
|
+
copilotRuntimeNestEndpoint
|
|
18
|
+
} from "../chunk-LGRJFIJL.mjs";
|
|
19
|
+
import {
|
|
20
|
+
copilotRuntimeNodeExpressEndpoint
|
|
21
|
+
} from "../chunk-X4FJTCSL.mjs";
|
|
16
22
|
import {
|
|
17
23
|
buildSchema,
|
|
18
24
|
copilotRuntimeNodeHttpEndpoint,
|
|
19
25
|
createContext,
|
|
20
26
|
getCommonConfig
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
25
|
-
import "../chunk-
|
|
26
|
-
import "../chunk-
|
|
27
|
+
} from "../chunk-6YZWDFF6.mjs";
|
|
28
|
+
import "../chunk-DVDKD6F5.mjs";
|
|
29
|
+
import "../chunk-U3V2BCGI.mjs";
|
|
30
|
+
import "../chunk-GEIBJJQ4.mjs";
|
|
31
|
+
import "../chunk-RMZWGQ46.mjs";
|
|
32
|
+
import "../chunk-44O2JGUY.mjs";
|
|
27
33
|
export {
|
|
28
34
|
CopilotRuntime,
|
|
29
35
|
GoogleGenerativeAIAdapter,
|
|
@@ -32,8 +38,10 @@ export {
|
|
|
32
38
|
OpenAIAssistantAdapter,
|
|
33
39
|
buildSchema,
|
|
34
40
|
config,
|
|
41
|
+
copilotRuntimeNestEndpoint,
|
|
35
42
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
36
43
|
copilotRuntimeNextJSPagesRouterEndpoint,
|
|
44
|
+
copilotRuntimeNodeExpressEndpoint,
|
|
37
45
|
copilotRuntimeNodeHttpEndpoint,
|
|
38
46
|
createContext,
|
|
39
47
|
flattenToolCallsNoDuplicates,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export { g as CommonConfig, b as CopilotRequestContextProperties, c as CreateCopilotRuntimeServerOptions, G as GraphQLContext, e as buildSchema,
|
|
2
|
-
export { C as CopilotRuntimeServerInstance, a as config, c as copilotRuntimeNextJSAppRouterEndpoint, b as copilotRuntimeNextJSPagesRouterEndpoint } from '../../pages-router-
|
|
3
|
-
|
|
1
|
+
export { g as CommonConfig, b as CopilotRequestContextProperties, c as CreateCopilotRuntimeServerOptions, G as GraphQLContext, e as buildSchema, d as createContext, h as getCommonConfig } from '../../shared-48c0f7b8.js';
|
|
2
|
+
export { C as CopilotRuntimeServerInstance, a as config, c as copilotRuntimeNextJSAppRouterEndpoint, b as copilotRuntimeNextJSPagesRouterEndpoint } from '../../pages-router-24897543.js';
|
|
3
|
+
export { copilotRuntimeNodeHttpEndpoint } from './node-http/index.js';
|
|
4
|
+
export { copilotRuntimeNodeExpressEndpoint } from './node-express/index.js';
|
|
5
|
+
export { copilotRuntimeNestEndpoint } from './nest/index.js';
|
|
4
6
|
import 'graphql';
|
|
5
7
|
import 'pino';
|
|
8
|
+
import 'graphql-yoga';
|
|
6
9
|
import '@copilotkit/shared';
|
|
7
10
|
import '../../langserve-75ebbc38.js';
|
|
8
11
|
import '../../index-aa091e3c.js';
|
|
@@ -5,6 +5,9 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,13 +30,86 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// package.json
|
|
34
|
+
var require_package = __commonJS({
|
|
35
|
+
"package.json"(exports, module2) {
|
|
36
|
+
module2.exports = {
|
|
37
|
+
name: "@copilotkit/runtime",
|
|
38
|
+
private: false,
|
|
39
|
+
publishConfig: {
|
|
40
|
+
access: "public"
|
|
41
|
+
},
|
|
42
|
+
version: "1.0.0-beta.2",
|
|
43
|
+
sideEffects: false,
|
|
44
|
+
main: "./dist/index.js",
|
|
45
|
+
module: "./dist/index.mjs",
|
|
46
|
+
exports: {
|
|
47
|
+
".": "./dist/index.js"
|
|
48
|
+
},
|
|
49
|
+
types: "./dist/index.d.ts",
|
|
50
|
+
license: "MIT",
|
|
51
|
+
scripts: {
|
|
52
|
+
build: "tsup --clean",
|
|
53
|
+
dev: 'tsup --watch --onSuccess "pnpm run generate-graphql-schema"',
|
|
54
|
+
test: "jest --passWithNoTests",
|
|
55
|
+
"check-types": "tsc --noEmit",
|
|
56
|
+
clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next",
|
|
57
|
+
"generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts"
|
|
58
|
+
},
|
|
59
|
+
devDependencies: {
|
|
60
|
+
"@swc/core": "1.5.28",
|
|
61
|
+
"@types/express": "^4.17.21",
|
|
62
|
+
"@types/jest": "^29.5.4",
|
|
63
|
+
"@types/node": "^18.11.17",
|
|
64
|
+
"@whatwg-node/server": "^0.9.34",
|
|
65
|
+
eslint: "^8.56.0",
|
|
66
|
+
"eslint-config-custom": "workspace:*",
|
|
67
|
+
jest: "^29.6.4",
|
|
68
|
+
nodemon: "^3.1.3",
|
|
69
|
+
"ts-jest": "^29.1.1",
|
|
70
|
+
"ts-node": "^10.9.2",
|
|
71
|
+
tsconfig: "workspace:*",
|
|
72
|
+
tsup: "^6.7.0",
|
|
73
|
+
typescript: "^5.2.3"
|
|
74
|
+
},
|
|
75
|
+
dependencies: {
|
|
76
|
+
"@copilotkit/shared": "workspace:*",
|
|
77
|
+
"@google/generative-ai": "^0.11.2",
|
|
78
|
+
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
79
|
+
"@langchain/community": "^0.0.53",
|
|
80
|
+
"@langchain/core": "^0.1.61",
|
|
81
|
+
"@langchain/openai": "^0.0.28",
|
|
82
|
+
"class-transformer": "^0.5.1",
|
|
83
|
+
express: "^4.19.2",
|
|
84
|
+
graphql: "^16.8.1",
|
|
85
|
+
"graphql-scalars": "^1.23.0",
|
|
86
|
+
"graphql-yoga": "^5.3.1",
|
|
87
|
+
"groq-sdk": "^0.5.0",
|
|
88
|
+
"js-tiktoken": "^1.0.8",
|
|
89
|
+
langchain: "^0.1.36",
|
|
90
|
+
nanoid: "3.3.4",
|
|
91
|
+
openai: "^4.50.0",
|
|
92
|
+
pino: "^9.2.0",
|
|
93
|
+
"pino-pretty": "^11.2.1",
|
|
94
|
+
"reflect-metadata": "^0.2.2",
|
|
95
|
+
rxjs: "^7.8.1",
|
|
96
|
+
tiktoken: "^1.0.15",
|
|
97
|
+
"type-graphql": "2.0.0-rc.1",
|
|
98
|
+
zod: "^3.23.3"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
30
104
|
// src/lib/integrations/index.ts
|
|
31
105
|
var integrations_exports = {};
|
|
32
106
|
__export(integrations_exports, {
|
|
33
107
|
buildSchema: () => buildSchema,
|
|
34
108
|
config: () => config,
|
|
109
|
+
copilotRuntimeNestEndpoint: () => copilotRuntimeNestEndpoint,
|
|
35
110
|
copilotRuntimeNextJSAppRouterEndpoint: () => copilotRuntimeNextJSAppRouterEndpoint,
|
|
36
111
|
copilotRuntimeNextJSPagesRouterEndpoint: () => copilotRuntimeNextJSPagesRouterEndpoint,
|
|
112
|
+
copilotRuntimeNodeExpressEndpoint: () => copilotRuntimeNodeExpressEndpoint,
|
|
37
113
|
copilotRuntimeNodeHttpEndpoint: () => copilotRuntimeNodeHttpEndpoint,
|
|
38
114
|
createContext: () => createContext,
|
|
39
115
|
getCommonConfig: () => getCommonConfig
|
|
@@ -66,6 +142,14 @@ var ActionExecutionScope;
|
|
|
66
142
|
ActionExecutionScope2["server"] = "server";
|
|
67
143
|
ActionExecutionScope2["client"] = "client";
|
|
68
144
|
})(ActionExecutionScope || (ActionExecutionScope = {}));
|
|
145
|
+
var CopilotRequestType;
|
|
146
|
+
(function(CopilotRequestType2) {
|
|
147
|
+
CopilotRequestType2["Chat"] = "Chat";
|
|
148
|
+
CopilotRequestType2["Task"] = "Task";
|
|
149
|
+
CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
|
|
150
|
+
CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
|
|
151
|
+
CopilotRequestType2["Suggestion"] = "Suggestion";
|
|
152
|
+
})(CopilotRequestType || (CopilotRequestType = {}));
|
|
69
153
|
(0, import_type_graphql.registerEnumType)(MessageRole, {
|
|
70
154
|
name: "MessageRole",
|
|
71
155
|
description: "The role of the message"
|
|
@@ -74,6 +158,10 @@ var ActionExecutionScope;
|
|
|
74
158
|
name: "ActionExecutionScope",
|
|
75
159
|
description: "The scope of the action"
|
|
76
160
|
});
|
|
161
|
+
(0, import_type_graphql.registerEnumType)(CopilotRequestType, {
|
|
162
|
+
name: "CopilotRequestType",
|
|
163
|
+
description: "The type of Copilot request"
|
|
164
|
+
});
|
|
77
165
|
|
|
78
166
|
// src/graphql/types/base/index.ts
|
|
79
167
|
var import_type_graphql2 = require("type-graphql");
|
|
@@ -340,15 +428,12 @@ GuardrailsRuleInput = _ts_decorate5([
|
|
|
340
428
|
(0, import_type_graphql6.InputType)()
|
|
341
429
|
], GuardrailsRuleInput);
|
|
342
430
|
var GuardrailsInput = class {
|
|
343
|
-
inputValidationRules
|
|
344
|
-
allowList: [],
|
|
345
|
-
denyList: []
|
|
346
|
-
};
|
|
431
|
+
inputValidationRules;
|
|
347
432
|
};
|
|
348
433
|
__name(GuardrailsInput, "GuardrailsInput");
|
|
349
434
|
_ts_decorate5([
|
|
350
435
|
(0, import_type_graphql6.Field)(() => GuardrailsRuleInput, {
|
|
351
|
-
nullable:
|
|
436
|
+
nullable: false
|
|
352
437
|
}),
|
|
353
438
|
_ts_metadata5("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
|
|
354
439
|
], GuardrailsInput.prototype, "inputValidationRules", void 0);
|
|
@@ -404,7 +489,21 @@ function _ts_metadata7(k, v) {
|
|
|
404
489
|
return Reflect.metadata(k, v);
|
|
405
490
|
}
|
|
406
491
|
__name(_ts_metadata7, "_ts_metadata");
|
|
492
|
+
var GenerateCopilotResponseMetadataInput = class {
|
|
493
|
+
requestType;
|
|
494
|
+
};
|
|
495
|
+
__name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
|
|
496
|
+
_ts_decorate7([
|
|
497
|
+
(0, import_type_graphql8.Field)(() => CopilotRequestType, {
|
|
498
|
+
nullable: true
|
|
499
|
+
}),
|
|
500
|
+
_ts_metadata7("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
|
|
501
|
+
], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
|
|
502
|
+
GenerateCopilotResponseMetadataInput = _ts_decorate7([
|
|
503
|
+
(0, import_type_graphql8.InputType)()
|
|
504
|
+
], GenerateCopilotResponseMetadataInput);
|
|
407
505
|
var GenerateCopilotResponseInput = class {
|
|
506
|
+
metadata;
|
|
408
507
|
threadId;
|
|
409
508
|
runId;
|
|
410
509
|
messages;
|
|
@@ -412,6 +511,12 @@ var GenerateCopilotResponseInput = class {
|
|
|
412
511
|
cloud;
|
|
413
512
|
};
|
|
414
513
|
__name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
|
|
514
|
+
_ts_decorate7([
|
|
515
|
+
(0, import_type_graphql8.Field)(() => GenerateCopilotResponseMetadataInput, {
|
|
516
|
+
nullable: false
|
|
517
|
+
}),
|
|
518
|
+
_ts_metadata7("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
|
|
519
|
+
], GenerateCopilotResponseInput.prototype, "metadata", void 0);
|
|
415
520
|
_ts_decorate7([
|
|
416
521
|
(0, import_type_graphql8.Field)(() => String, {
|
|
417
522
|
nullable: true
|
|
@@ -849,6 +954,15 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
|
849
954
|
};
|
|
850
955
|
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
851
956
|
|
|
957
|
+
// src/lib/telemetry-client.ts
|
|
958
|
+
var import_shared = require("@copilotkit/shared");
|
|
959
|
+
var packageJson = require_package();
|
|
960
|
+
var telemetryClient = new import_shared.TelemetryClient({
|
|
961
|
+
packageName: packageJson.name,
|
|
962
|
+
packageVersion: packageJson.version
|
|
963
|
+
});
|
|
964
|
+
var telemetry_client_default = telemetryClient;
|
|
965
|
+
|
|
852
966
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
853
967
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
854
968
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -874,6 +988,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
874
988
|
__name(_ts_param, "_ts_param");
|
|
875
989
|
var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
|
|
876
990
|
var _a;
|
|
991
|
+
console.log("invokeGuardrails.baseUrl", baseUrl);
|
|
877
992
|
if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
|
|
878
993
|
const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
|
|
879
994
|
role: m.textMessage.role,
|
|
@@ -908,6 +1023,11 @@ var CopilotResolver = class {
|
|
|
908
1023
|
return "Hello World";
|
|
909
1024
|
}
|
|
910
1025
|
async generateCopilotResponse(ctx, data, properties) {
|
|
1026
|
+
var _a, _b, _c;
|
|
1027
|
+
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
1028
|
+
"cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
1029
|
+
requestType: data.metadata.requestType
|
|
1030
|
+
});
|
|
911
1031
|
let logger2 = ctx.logger.child({
|
|
912
1032
|
component: "CopilotResolver.generateCopilotResponse"
|
|
913
1033
|
});
|
|
@@ -940,8 +1060,8 @@ var CopilotResolver = class {
|
|
|
940
1060
|
}
|
|
941
1061
|
if (process.env.COPILOT_CLOUD_BASE_URL) {
|
|
942
1062
|
copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
|
|
943
|
-
} else if (ctx._copilotkit.baseUrl) {
|
|
944
|
-
copilotCloudBaseUrl = ctx._copilotkit.baseUrl;
|
|
1063
|
+
} else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
|
|
1064
|
+
copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
|
|
945
1065
|
} else {
|
|
946
1066
|
copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
|
|
947
1067
|
}
|
|
@@ -977,9 +1097,9 @@ var CopilotResolver = class {
|
|
|
977
1097
|
runId,
|
|
978
1098
|
status: (0, import_rxjs2.firstValueFrom)(responseStatus$),
|
|
979
1099
|
messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
|
|
980
|
-
var
|
|
1100
|
+
var _a2, _b2;
|
|
981
1101
|
logger2.debug("Messages repeater created");
|
|
982
|
-
if ((
|
|
1102
|
+
if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
|
|
983
1103
|
logger2 = logger2.child({
|
|
984
1104
|
guardrails: true
|
|
985
1105
|
});
|
|
@@ -1028,7 +1148,7 @@ var CopilotResolver = class {
|
|
|
1028
1148
|
let eventStreamSubscription;
|
|
1029
1149
|
const eventStream = eventSource.process({
|
|
1030
1150
|
serversideActions: actions,
|
|
1031
|
-
guardrailsResult$: ((
|
|
1151
|
+
guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null
|
|
1032
1152
|
}).pipe(
|
|
1033
1153
|
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
1034
1154
|
// just the events that were emitted after the subscriber was added.
|
|
@@ -1190,9 +1310,9 @@ var CopilotResolver = class {
|
|
|
1190
1310
|
rejectOutputMessagesPromise(err);
|
|
1191
1311
|
},
|
|
1192
1312
|
complete: async () => {
|
|
1193
|
-
var
|
|
1313
|
+
var _a3;
|
|
1194
1314
|
logger2.debug("Event stream completed");
|
|
1195
|
-
if ((
|
|
1315
|
+
if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
|
|
1196
1316
|
logger2.debug("Guardrails is enabled, waiting for guardrails result");
|
|
1197
1317
|
await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
|
|
1198
1318
|
}
|
|
@@ -1301,10 +1421,20 @@ function getCommonConfig(options) {
|
|
|
1301
1421
|
level: logLevel,
|
|
1302
1422
|
component: "getCommonConfig"
|
|
1303
1423
|
});
|
|
1304
|
-
logger2.debug("Getting common config");
|
|
1305
1424
|
const contextLogger = createLogger({
|
|
1306
1425
|
level: logLevel
|
|
1307
1426
|
});
|
|
1427
|
+
if (options.cloud) {
|
|
1428
|
+
telemetry_client_default.setCloudConfiguration({
|
|
1429
|
+
publicApiKey: options.cloud.publicApiKey,
|
|
1430
|
+
baseUrl: options.cloud.baseUrl
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
telemetry_client_default.setGlobalProperties({
|
|
1434
|
+
runtime: {
|
|
1435
|
+
serviceAdapter: options.serviceAdapter.constructor.name
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1308
1438
|
return {
|
|
1309
1439
|
logging: createLogger({
|
|
1310
1440
|
component: "Yoga GraphQL",
|
|
@@ -1323,6 +1453,12 @@ __name(getCommonConfig, "getCommonConfig");
|
|
|
1323
1453
|
var import_graphql_yoga2 = require("graphql-yoga");
|
|
1324
1454
|
function copilotRuntimeNextJSAppRouterEndpoint(options) {
|
|
1325
1455
|
const commonConfig = getCommonConfig(options);
|
|
1456
|
+
telemetry_client_default.setGlobalProperties({
|
|
1457
|
+
runtime: {
|
|
1458
|
+
framework: "nextjs-app-router"
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
1326
1462
|
const logger2 = commonConfig.logging;
|
|
1327
1463
|
logger2.debug("Creating NextJS App Router endpoint");
|
|
1328
1464
|
const yoga = (0, import_graphql_yoga2.createYoga)({
|
|
@@ -1350,6 +1486,12 @@ var config = {
|
|
|
1350
1486
|
};
|
|
1351
1487
|
function copilotRuntimeNextJSPagesRouterEndpoint(options) {
|
|
1352
1488
|
const commonConfig = getCommonConfig(options);
|
|
1489
|
+
telemetry_client_default.setGlobalProperties({
|
|
1490
|
+
runtime: {
|
|
1491
|
+
framework: "nextjs-pages-router"
|
|
1492
|
+
}
|
|
1493
|
+
});
|
|
1494
|
+
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
1353
1495
|
const logger2 = commonConfig.logging;
|
|
1354
1496
|
logger2.debug("Creating NextJS Pages Router endpoint");
|
|
1355
1497
|
const yoga = (0, import_graphql_yoga3.createYoga)({
|
|
@@ -1364,6 +1506,12 @@ __name(copilotRuntimeNextJSPagesRouterEndpoint, "copilotRuntimeNextJSPagesRouter
|
|
|
1364
1506
|
var import_graphql_yoga4 = require("graphql-yoga");
|
|
1365
1507
|
function copilotRuntimeNodeHttpEndpoint(options) {
|
|
1366
1508
|
const commonConfig = getCommonConfig(options);
|
|
1509
|
+
telemetry_client_default.setGlobalProperties({
|
|
1510
|
+
runtime: {
|
|
1511
|
+
framework: "node-http"
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
1367
1515
|
const logger2 = commonConfig.logging;
|
|
1368
1516
|
logger2.debug("Creating Node HTTP endpoint");
|
|
1369
1517
|
const yoga = (0, import_graphql_yoga4.createYoga)({
|
|
@@ -1373,12 +1521,38 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
1373
1521
|
return yoga;
|
|
1374
1522
|
}
|
|
1375
1523
|
__name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
|
|
1524
|
+
|
|
1525
|
+
// src/lib/integrations/node-express/index.ts
|
|
1526
|
+
function copilotRuntimeNodeExpressEndpoint(options) {
|
|
1527
|
+
telemetry_client_default.setGlobalProperties({
|
|
1528
|
+
runtime: {
|
|
1529
|
+
framework: "node-express"
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
1533
|
+
return copilotRuntimeNodeHttpEndpoint(options);
|
|
1534
|
+
}
|
|
1535
|
+
__name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
|
|
1536
|
+
|
|
1537
|
+
// src/lib/integrations/nest/index.ts
|
|
1538
|
+
function copilotRuntimeNestEndpoint(options) {
|
|
1539
|
+
telemetry_client_default.setGlobalProperties({
|
|
1540
|
+
runtime: {
|
|
1541
|
+
framework: "nest"
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
1545
|
+
return copilotRuntimeNodeHttpEndpoint(options);
|
|
1546
|
+
}
|
|
1547
|
+
__name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
1376
1548
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1377
1549
|
0 && (module.exports = {
|
|
1378
1550
|
buildSchema,
|
|
1379
1551
|
config,
|
|
1552
|
+
copilotRuntimeNestEndpoint,
|
|
1380
1553
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
1381
1554
|
copilotRuntimeNextJSPagesRouterEndpoint,
|
|
1555
|
+
copilotRuntimeNodeExpressEndpoint,
|
|
1382
1556
|
copilotRuntimeNodeHttpEndpoint,
|
|
1383
1557
|
createContext,
|
|
1384
1558
|
getCommonConfig
|