@copilotkit/runtime 1.4.0-pre-1-4-0.11 → 1.4.0-pre-1-4-0.12
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 +45 -0
- package/dist/{chunk-BNQDVBQH.mjs → chunk-56IQ6PGC.mjs} +449 -75
- package/dist/chunk-56IQ6PGC.mjs.map +1 -0
- package/dist/chunk-DFOKBSIS.mjs +1 -0
- package/dist/chunk-DFOKBSIS.mjs.map +1 -0
- package/dist/{chunk-V2YEM4Z5.mjs → chunk-JFIBAURX.mjs} +4 -3
- package/dist/chunk-JFIBAURX.mjs.map +1 -0
- package/dist/{chunk-3DNY5YTL.mjs → chunk-JFLWUR62.mjs} +5 -4
- package/dist/chunk-JFLWUR62.mjs.map +1 -0
- package/dist/{chunk-677K33J7.mjs → chunk-TZ7RGXQ6.mjs} +4 -3
- package/dist/chunk-TZ7RGXQ6.mjs.map +1 -0
- package/dist/{chunk-VBGS6IWV.mjs → chunk-YZ3VKKSM.mjs} +483 -71
- package/dist/chunk-YZ3VKKSM.mjs.map +1 -0
- package/dist/{copilot-runtime-8d3f40c7.d.ts → copilot-runtime-dbe5fa02.d.ts} +4 -4
- package/dist/{groq-adapter-dbfba3eb.d.ts → groq-adapter-192d2413.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +486 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -22
- package/dist/index.mjs.map +1 -1
- package/dist/{langserve-f00629d2.d.ts → langserve-878c62b9.d.ts} +46 -9
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +465 -163
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +21 -21
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +161 -85
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +5 -5
- package/dist/lib/integrations/nest/index.d.ts +2 -2
- package/dist/lib/integrations/nest/index.js +158 -82
- package/dist/lib/integrations/nest/index.js.map +1 -1
- package/dist/lib/integrations/nest/index.mjs +3 -3
- package/dist/lib/integrations/node-express/index.d.ts +2 -2
- package/dist/lib/integrations/node-express/index.js +158 -82
- package/dist/lib/integrations/node-express/index.js.map +1 -1
- package/dist/lib/integrations/node-express/index.mjs +3 -3
- package/dist/lib/integrations/node-http/index.d.ts +2 -2
- package/dist/lib/integrations/node-http/index.js +157 -81
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +2 -2
- package/dist/service-adapters/index.d.ts +3 -3
- package/dist/service-adapters/index.js +243 -73
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +1 -2
- package/package.json +4 -4
- package/src/agents/langgraph/event-source.ts +12 -0
- package/src/agents/langgraph/events.ts +2 -0
- package/src/graphql/resolvers/copilot.resolver.ts +28 -2
- package/src/lib/integrations/nest/index.ts +5 -2
- package/src/lib/integrations/nextjs/app-router.ts +5 -2
- package/src/lib/integrations/nextjs/pages-router.ts +5 -2
- package/src/lib/integrations/node-express/index.ts +5 -2
- package/src/lib/integrations/node-http/index.ts +5 -2
- package/src/lib/runtime/copilot-runtime.ts +48 -42
- package/src/lib/runtime/remote-action-constructors.ts +17 -3
- package/src/lib/runtime/remote-lg-cloud-action.ts +41 -15
- package/src/lib/telemetry-client.ts +43 -0
- package/src/service-adapters/anthropic/anthropic-adapter.ts +15 -6
- package/src/service-adapters/events.ts +86 -36
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +7 -3
- package/src/service-adapters/google/google-genai-adapter.ts +2 -2
- package/src/service-adapters/groq/groq-adapter.ts +22 -8
- package/src/service-adapters/langchain/langchain-adapter.ts +22 -16
- package/src/service-adapters/langchain/utils.ts +47 -31
- package/src/service-adapters/openai/openai-adapter.ts +25 -8
- package/src/service-adapters/openai/openai-assistant-adapter.ts +21 -8
- package/src/service-adapters/unify/unify-adapter.ts +28 -11
- package/dist/chunk-3DNY5YTL.mjs.map +0 -1
- package/dist/chunk-677K33J7.mjs.map +0 -1
- package/dist/chunk-BNQDVBQH.mjs.map +0 -1
- package/dist/chunk-FL67XJAX.mjs +0 -288
- package/dist/chunk-FL67XJAX.mjs.map +0 -1
- package/dist/chunk-MXXPWWBF.mjs +0 -218
- package/dist/chunk-MXXPWWBF.mjs.map +0 -1
- package/dist/chunk-V2YEM4Z5.mjs.map +0 -1
- package/dist/chunk-VBGS6IWV.mjs.map +0 -1
package/dist/lib/index.mjs
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
CopilotRuntime,
|
|
3
|
-
copilotKitEndpoint,
|
|
4
|
-
flattenToolCallsNoDuplicates,
|
|
5
|
-
langGraphCloudEndpoint
|
|
6
|
-
} from "../chunk-FL67XJAX.mjs";
|
|
7
|
-
import {
|
|
8
|
-
GoogleGenerativeAIAdapter,
|
|
9
|
-
GroqAdapter,
|
|
10
|
-
LangChainAdapter,
|
|
11
|
-
OpenAIAdapter,
|
|
12
|
-
OpenAIAssistantAdapter,
|
|
13
|
-
UnifyAdapter
|
|
14
|
-
} from "../chunk-BNQDVBQH.mjs";
|
|
1
|
+
import "../chunk-DFOKBSIS.mjs";
|
|
15
2
|
import {
|
|
16
3
|
config,
|
|
17
4
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
18
5
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
19
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-JFLWUR62.mjs";
|
|
20
7
|
import {
|
|
21
8
|
copilotRuntimeNestEndpoint
|
|
22
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-TZ7RGXQ6.mjs";
|
|
23
10
|
import {
|
|
24
11
|
copilotRuntimeNodeExpressEndpoint
|
|
25
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-JFIBAURX.mjs";
|
|
26
13
|
import {
|
|
14
|
+
CopilotRuntime,
|
|
27
15
|
buildSchema,
|
|
16
|
+
copilotKitEndpoint,
|
|
28
17
|
copilotRuntimeNodeHttpEndpoint,
|
|
29
18
|
createContext,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
flattenToolCallsNoDuplicates,
|
|
20
|
+
getCommonConfig,
|
|
21
|
+
langGraphCloudEndpoint,
|
|
22
|
+
resolveEndpointType
|
|
23
|
+
} from "../chunk-YZ3VKKSM.mjs";
|
|
24
|
+
import {
|
|
25
|
+
GoogleGenerativeAIAdapter,
|
|
26
|
+
GroqAdapter,
|
|
27
|
+
LangChainAdapter,
|
|
28
|
+
OpenAIAdapter,
|
|
29
|
+
OpenAIAssistantAdapter,
|
|
30
|
+
UnifyAdapter
|
|
31
|
+
} from "../chunk-56IQ6PGC.mjs";
|
|
33
32
|
import "../chunk-U3V2BCGI.mjs";
|
|
34
33
|
import "../chunk-B74M7FXG.mjs";
|
|
35
34
|
import "../chunk-D2WLFQS6.mjs";
|
|
@@ -53,6 +52,7 @@ export {
|
|
|
53
52
|
createContext,
|
|
54
53
|
flattenToolCallsNoDuplicates,
|
|
55
54
|
getCommonConfig,
|
|
56
|
-
langGraphCloudEndpoint
|
|
55
|
+
langGraphCloudEndpoint,
|
|
56
|
+
resolveEndpointType
|
|
57
57
|
};
|
|
58
58
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { d as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../copilot-runtime-
|
|
2
|
-
export { h as CommonConfig, b as CopilotRequestContextProperties, g as buildSchema, e as createContext, i as getCommonConfig } from '../../copilot-runtime-
|
|
1
|
+
import { d as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../copilot-runtime-dbe5fa02.js';
|
|
2
|
+
export { h as CommonConfig, b as CopilotRequestContextProperties, g as buildSchema, e as createContext, i as getCommonConfig } from '../../copilot-runtime-dbe5fa02.js';
|
|
3
3
|
import * as graphql_yoga from 'graphql-yoga';
|
|
4
4
|
import { YogaServerInstance } from 'graphql-yoga';
|
|
5
5
|
export { copilotRuntimeNodeHttpEndpoint } from './node-http/index.js';
|
|
6
6
|
export { copilotRuntimeNodeExpressEndpoint } from './node-express/index.js';
|
|
7
7
|
export { copilotRuntimeNestEndpoint } from './nest/index.js';
|
|
8
8
|
import '@copilotkit/shared';
|
|
9
|
-
import '../../langserve-
|
|
9
|
+
import '../../langserve-878c62b9.js';
|
|
10
10
|
import '../../index-83ee522f.js';
|
|
11
11
|
import '../../graphql/types/base/index.js';
|
|
12
12
|
import 'rxjs';
|
|
@@ -12,11 +12,11 @@ var __export = (target, all) => {
|
|
|
12
12
|
for (var name in all)
|
|
13
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
14
|
};
|
|
15
|
-
var __copyProps = (to,
|
|
16
|
-
if (
|
|
17
|
-
for (let key of __getOwnPropNames(
|
|
15
|
+
var __copyProps = (to, from3, except, desc) => {
|
|
16
|
+
if (from3 && typeof from3 === "object" || typeof from3 === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from3))
|
|
18
18
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () =>
|
|
19
|
+
__defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
publishConfig: {
|
|
45
45
|
access: "public"
|
|
46
46
|
},
|
|
47
|
-
version: "1.4.0-pre-1-4-0.
|
|
47
|
+
version: "1.4.0-pre-1-4-0.12",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -141,7 +141,7 @@ var import_type_graphql16 = require("type-graphql");
|
|
|
141
141
|
|
|
142
142
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
143
143
|
var import_type_graphql15 = require("type-graphql");
|
|
144
|
-
var
|
|
144
|
+
var import_rxjs3 = require("rxjs");
|
|
145
145
|
|
|
146
146
|
// src/graphql/inputs/generate-copilot-response.input.ts
|
|
147
147
|
var import_type_graphql11 = require("type-graphql");
|
|
@@ -1185,15 +1185,133 @@ CopilotResponse = _ts_decorate13([
|
|
|
1185
1185
|
var import_graphql_yoga = require("graphql-yoga");
|
|
1186
1186
|
|
|
1187
1187
|
// src/service-adapters/events.ts
|
|
1188
|
-
var
|
|
1188
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
1189
|
+
var import_rxjs2 = require("rxjs");
|
|
1190
|
+
|
|
1191
|
+
// src/lib/telemetry-client.ts
|
|
1192
|
+
var import_shared2 = require("@copilotkit/shared");
|
|
1193
|
+
|
|
1194
|
+
// src/lib/runtime/remote-actions.ts
|
|
1195
|
+
var EndpointType;
|
|
1196
|
+
(function(EndpointType2) {
|
|
1197
|
+
EndpointType2["CopilotKit"] = "copilotKit";
|
|
1198
|
+
EndpointType2["LangGraphCloud"] = "langgraph-cloud";
|
|
1199
|
+
})(EndpointType || (EndpointType = {}));
|
|
1189
1200
|
|
|
1190
1201
|
// src/lib/telemetry-client.ts
|
|
1202
|
+
var import_node_crypto = require("crypto");
|
|
1203
|
+
|
|
1204
|
+
// src/lib/runtime/copilot-runtime.ts
|
|
1191
1205
|
var import_shared = require("@copilotkit/shared");
|
|
1206
|
+
|
|
1207
|
+
// src/graphql/types/converted/index.ts
|
|
1208
|
+
var Message = class extends BaseMessageInput {
|
|
1209
|
+
type;
|
|
1210
|
+
isTextMessage() {
|
|
1211
|
+
return this.type === "TextMessage";
|
|
1212
|
+
}
|
|
1213
|
+
isActionExecutionMessage() {
|
|
1214
|
+
return this.type === "ActionExecutionMessage";
|
|
1215
|
+
}
|
|
1216
|
+
isResultMessage() {
|
|
1217
|
+
return this.type === "ResultMessage";
|
|
1218
|
+
}
|
|
1219
|
+
isAgentStateMessage() {
|
|
1220
|
+
return this.type === "AgentStateMessage";
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
__name(Message, "Message");
|
|
1224
|
+
var TextMessage = class extends Message {
|
|
1225
|
+
type = "TextMessage";
|
|
1226
|
+
content;
|
|
1227
|
+
role;
|
|
1228
|
+
};
|
|
1229
|
+
__name(TextMessage, "TextMessage");
|
|
1230
|
+
var ActionExecutionMessage = class extends Message {
|
|
1231
|
+
type = "ActionExecutionMessage";
|
|
1232
|
+
name;
|
|
1233
|
+
arguments;
|
|
1234
|
+
scope;
|
|
1235
|
+
};
|
|
1236
|
+
__name(ActionExecutionMessage, "ActionExecutionMessage");
|
|
1237
|
+
var ResultMessage = class extends Message {
|
|
1238
|
+
type = "ResultMessage";
|
|
1239
|
+
actionExecutionId;
|
|
1240
|
+
actionName;
|
|
1241
|
+
result;
|
|
1242
|
+
};
|
|
1243
|
+
__name(ResultMessage, "ResultMessage");
|
|
1244
|
+
var AgentStateMessage = class extends Message {
|
|
1245
|
+
type = "AgentStateMessage";
|
|
1246
|
+
threadId;
|
|
1247
|
+
agentName;
|
|
1248
|
+
nodeName;
|
|
1249
|
+
runId;
|
|
1250
|
+
active;
|
|
1251
|
+
role;
|
|
1252
|
+
state;
|
|
1253
|
+
running;
|
|
1254
|
+
};
|
|
1255
|
+
__name(AgentStateMessage, "AgentStateMessage");
|
|
1256
|
+
|
|
1257
|
+
// src/lib/runtime/copilot-runtime.ts
|
|
1258
|
+
var import_rxjs = require("rxjs");
|
|
1259
|
+
function resolveEndpointType(endpoint) {
|
|
1260
|
+
if (!endpoint.type) {
|
|
1261
|
+
if ("langsmithApiKey" in endpoint && "deploymentUrl" in endpoint && "agents" in endpoint) {
|
|
1262
|
+
return EndpointType.LangGraphCloud;
|
|
1263
|
+
} else {
|
|
1264
|
+
return EndpointType.CopilotKit;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
return endpoint.type;
|
|
1268
|
+
}
|
|
1269
|
+
__name(resolveEndpointType, "resolveEndpointType");
|
|
1270
|
+
|
|
1271
|
+
// src/lib/telemetry-client.ts
|
|
1192
1272
|
var packageJson = require_package();
|
|
1193
|
-
var telemetryClient = new
|
|
1273
|
+
var telemetryClient = new import_shared2.TelemetryClient({
|
|
1194
1274
|
packageName: packageJson.name,
|
|
1195
1275
|
packageVersion: packageJson.version
|
|
1196
1276
|
});
|
|
1277
|
+
function getRuntimeInstanceTelemetryInfo(runtime) {
|
|
1278
|
+
const endpointsInfo = runtime.remoteEndpointDefinitions.reduce((acc, endpoint) => {
|
|
1279
|
+
let info = {
|
|
1280
|
+
...acc
|
|
1281
|
+
};
|
|
1282
|
+
const endpointType = resolveEndpointType(endpoint);
|
|
1283
|
+
if (!info.endpointTypes.includes(endpointType)) {
|
|
1284
|
+
info = {
|
|
1285
|
+
...info,
|
|
1286
|
+
endpointTypes: [
|
|
1287
|
+
...info.endpointTypes,
|
|
1288
|
+
endpointType
|
|
1289
|
+
]
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
if (endpointType === EndpointType.LangGraphCloud) {
|
|
1293
|
+
const ep = endpoint;
|
|
1294
|
+
info = {
|
|
1295
|
+
...info,
|
|
1296
|
+
agentsAmount: ep.agents.length,
|
|
1297
|
+
hashedKey: (0, import_node_crypto.createHash)("sha256").update(ep.langsmithApiKey).digest("hex")
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
return info;
|
|
1301
|
+
}, {
|
|
1302
|
+
endpointTypes: [],
|
|
1303
|
+
agentsAmount: null,
|
|
1304
|
+
hashedKey: null
|
|
1305
|
+
});
|
|
1306
|
+
return {
|
|
1307
|
+
actionsAmount: runtime.actions.length,
|
|
1308
|
+
endpointsAmount: runtime.remoteEndpointDefinitions.length,
|
|
1309
|
+
endpointTypes: endpointsInfo.endpointTypes,
|
|
1310
|
+
agentsAmount: endpointsInfo.agentsAmount,
|
|
1311
|
+
hashedLgcKey: endpointsInfo.hashedKey
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
__name(getRuntimeInstanceTelemetryInfo, "getRuntimeInstanceTelemetryInfo");
|
|
1197
1315
|
var telemetry_client_default = telemetryClient;
|
|
1198
1316
|
|
|
1199
1317
|
// src/service-adapters/events.ts
|
|
@@ -1247,58 +1365,8 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
|
1247
1365
|
};
|
|
1248
1366
|
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
1249
1367
|
|
|
1250
|
-
// src/graphql/types/converted/index.ts
|
|
1251
|
-
var Message = class extends BaseMessageInput {
|
|
1252
|
-
type;
|
|
1253
|
-
isTextMessage() {
|
|
1254
|
-
return this.type === "TextMessage";
|
|
1255
|
-
}
|
|
1256
|
-
isActionExecutionMessage() {
|
|
1257
|
-
return this.type === "ActionExecutionMessage";
|
|
1258
|
-
}
|
|
1259
|
-
isResultMessage() {
|
|
1260
|
-
return this.type === "ResultMessage";
|
|
1261
|
-
}
|
|
1262
|
-
isAgentStateMessage() {
|
|
1263
|
-
return this.type === "AgentStateMessage";
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
__name(Message, "Message");
|
|
1267
|
-
var TextMessage = class extends Message {
|
|
1268
|
-
type = "TextMessage";
|
|
1269
|
-
content;
|
|
1270
|
-
role;
|
|
1271
|
-
};
|
|
1272
|
-
__name(TextMessage, "TextMessage");
|
|
1273
|
-
var ActionExecutionMessage = class extends Message {
|
|
1274
|
-
type = "ActionExecutionMessage";
|
|
1275
|
-
name;
|
|
1276
|
-
arguments;
|
|
1277
|
-
scope;
|
|
1278
|
-
};
|
|
1279
|
-
__name(ActionExecutionMessage, "ActionExecutionMessage");
|
|
1280
|
-
var ResultMessage = class extends Message {
|
|
1281
|
-
type = "ResultMessage";
|
|
1282
|
-
actionExecutionId;
|
|
1283
|
-
actionName;
|
|
1284
|
-
result;
|
|
1285
|
-
};
|
|
1286
|
-
__name(ResultMessage, "ResultMessage");
|
|
1287
|
-
var AgentStateMessage = class extends Message {
|
|
1288
|
-
type = "AgentStateMessage";
|
|
1289
|
-
threadId;
|
|
1290
|
-
agentName;
|
|
1291
|
-
nodeName;
|
|
1292
|
-
runId;
|
|
1293
|
-
active;
|
|
1294
|
-
role;
|
|
1295
|
-
state;
|
|
1296
|
-
running;
|
|
1297
|
-
};
|
|
1298
|
-
__name(AgentStateMessage, "AgentStateMessage");
|
|
1299
|
-
|
|
1300
1368
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
1301
|
-
var
|
|
1369
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
1302
1370
|
function _ts_decorate14(decorators, target, key, desc) {
|
|
1303
1371
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1304
1372
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -1404,9 +1472,9 @@ var CopilotResolver = class {
|
|
|
1404
1472
|
});
|
|
1405
1473
|
}
|
|
1406
1474
|
logger2.debug("Setting up subjects");
|
|
1407
|
-
const responseStatus$ = new
|
|
1408
|
-
const interruptStreaming$ = new
|
|
1409
|
-
const guardrailsResult$ = new
|
|
1475
|
+
const responseStatus$ = new import_rxjs3.ReplaySubject();
|
|
1476
|
+
const interruptStreaming$ = new import_rxjs3.ReplaySubject();
|
|
1477
|
+
const guardrailsResult$ = new import_rxjs3.ReplaySubject();
|
|
1410
1478
|
let outputMessages = [];
|
|
1411
1479
|
let resolveOutputMessagesPromise;
|
|
1412
1480
|
let rejectOutputMessagesPromise;
|
|
@@ -1415,7 +1483,7 @@ var CopilotResolver = class {
|
|
|
1415
1483
|
rejectOutputMessagesPromise = reject;
|
|
1416
1484
|
});
|
|
1417
1485
|
logger2.debug("Processing");
|
|
1418
|
-
const { eventSource, threadId = (0,
|
|
1486
|
+
const { eventSource, threadId = (0, import_shared4.randomId)(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
|
|
1419
1487
|
serviceAdapter,
|
|
1420
1488
|
messages: data.messages,
|
|
1421
1489
|
actions: data.frontend.actions,
|
|
@@ -1433,7 +1501,7 @@ var CopilotResolver = class {
|
|
|
1433
1501
|
const response = {
|
|
1434
1502
|
threadId,
|
|
1435
1503
|
runId,
|
|
1436
|
-
status: (0,
|
|
1504
|
+
status: (0, import_rxjs3.firstValueFrom)(responseStatus$),
|
|
1437
1505
|
messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
|
|
1438
1506
|
var _a2, _b2;
|
|
1439
1507
|
logger2.debug("Messages repeater created");
|
|
@@ -1460,7 +1528,7 @@ var CopilotResolver = class {
|
|
|
1460
1528
|
});
|
|
1461
1529
|
outputMessages = [
|
|
1462
1530
|
(0, import_class_transformer.plainToInstance)(TextMessage, {
|
|
1463
|
-
id: (0,
|
|
1531
|
+
id: (0, import_shared4.randomId)(),
|
|
1464
1532
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1465
1533
|
content: result.reason,
|
|
1466
1534
|
role: MessageRole.assistant
|
|
@@ -1494,8 +1562,8 @@ var CopilotResolver = class {
|
|
|
1494
1562
|
}).pipe(
|
|
1495
1563
|
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
1496
1564
|
// just the events that were emitted after the subscriber was added.
|
|
1497
|
-
(0,
|
|
1498
|
-
(0,
|
|
1565
|
+
(0, import_rxjs3.shareReplay)(),
|
|
1566
|
+
(0, import_rxjs3.finalize)(() => {
|
|
1499
1567
|
logger2.debug("Event stream finalized");
|
|
1500
1568
|
})
|
|
1501
1569
|
);
|
|
@@ -1506,22 +1574,24 @@ var CopilotResolver = class {
|
|
|
1506
1574
|
case RuntimeEventTypes.TextMessageStart:
|
|
1507
1575
|
const textMessageContentStream = eventStream.pipe(
|
|
1508
1576
|
// skip until this message start event
|
|
1509
|
-
(0,
|
|
1577
|
+
(0, import_rxjs3.skipWhile)((e) => e !== event),
|
|
1510
1578
|
// take until the message end event
|
|
1511
|
-
(0,
|
|
1579
|
+
(0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.TextMessageEnd && e.messageId == event.messageId)),
|
|
1580
|
+
// filter out any other message events or message ids
|
|
1581
|
+
(0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.TextMessageContent && e.messageId == event.messageId)
|
|
1512
1582
|
);
|
|
1513
|
-
const streamingTextStatus = new
|
|
1583
|
+
const streamingTextStatus = new import_rxjs3.Subject();
|
|
1514
1584
|
const messageId = event.messageId;
|
|
1515
1585
|
pushMessage({
|
|
1516
1586
|
id: messageId,
|
|
1517
|
-
status: (0,
|
|
1587
|
+
status: (0, import_rxjs3.firstValueFrom)(streamingTextStatus),
|
|
1518
1588
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1519
1589
|
role: MessageRole.assistant,
|
|
1520
1590
|
content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
|
|
1521
1591
|
logger2.debug("Text message content repeater created");
|
|
1522
1592
|
const textChunks = [];
|
|
1523
1593
|
let textSubscription;
|
|
1524
|
-
interruptStreaming$.pipe((0,
|
|
1594
|
+
interruptStreaming$.pipe((0, import_rxjs3.shareReplay)(), (0, import_rxjs3.take)(1), (0, import_rxjs3.tap)(({ reason, messageId: messageId2 }) => {
|
|
1525
1595
|
logger2.debug({
|
|
1526
1596
|
reason,
|
|
1527
1597
|
messageId: messageId2
|
|
@@ -1572,11 +1642,17 @@ var CopilotResolver = class {
|
|
|
1572
1642
|
break;
|
|
1573
1643
|
case RuntimeEventTypes.ActionExecutionStart:
|
|
1574
1644
|
logger2.debug("Action execution start event received");
|
|
1575
|
-
const actionExecutionArgumentStream = eventStream.pipe(
|
|
1576
|
-
|
|
1645
|
+
const actionExecutionArgumentStream = eventStream.pipe(
|
|
1646
|
+
(0, import_rxjs3.skipWhile)((e) => e !== event),
|
|
1647
|
+
// take until the action execution end event
|
|
1648
|
+
(0, import_rxjs3.takeWhile)((e) => !(e.type === RuntimeEventTypes.ActionExecutionEnd && e.actionExecutionId == event.actionExecutionId)),
|
|
1649
|
+
// filter out any other action execution events or action execution ids
|
|
1650
|
+
(0, import_rxjs3.filter)((e) => e.type == RuntimeEventTypes.ActionExecutionArgs && e.actionExecutionId == event.actionExecutionId)
|
|
1651
|
+
);
|
|
1652
|
+
const streamingArgumentsStatus = new import_rxjs3.Subject();
|
|
1577
1653
|
pushMessage({
|
|
1578
1654
|
id: event.actionExecutionId,
|
|
1579
|
-
status: (0,
|
|
1655
|
+
status: (0, import_rxjs3.firstValueFrom)(streamingArgumentsStatus),
|
|
1580
1656
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1581
1657
|
name: event.actionName,
|
|
1582
1658
|
scope: event.scope,
|
|
@@ -1623,7 +1699,7 @@ var CopilotResolver = class {
|
|
|
1623
1699
|
result: event.result
|
|
1624
1700
|
}, "Action execution result event received");
|
|
1625
1701
|
pushMessage({
|
|
1626
|
-
id: (0,
|
|
1702
|
+
id: (0, import_shared4.randomId)(),
|
|
1627
1703
|
status: new SuccessMessageStatus(),
|
|
1628
1704
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1629
1705
|
actionExecutionId: event.actionExecutionId,
|
|
@@ -1631,7 +1707,7 @@ var CopilotResolver = class {
|
|
|
1631
1707
|
result: event.result
|
|
1632
1708
|
});
|
|
1633
1709
|
outputMessages.push((0, import_class_transformer.plainToInstance)(ResultMessage, {
|
|
1634
|
-
id: (0,
|
|
1710
|
+
id: (0, import_shared4.randomId)(),
|
|
1635
1711
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1636
1712
|
actionExecutionId: event.actionExecutionId,
|
|
1637
1713
|
actionName: event.actionName,
|
|
@@ -1643,7 +1719,7 @@ var CopilotResolver = class {
|
|
|
1643
1719
|
event
|
|
1644
1720
|
}, "Agent message event received");
|
|
1645
1721
|
pushMessage({
|
|
1646
|
-
id: (0,
|
|
1722
|
+
id: (0, import_shared4.randomId)(),
|
|
1647
1723
|
status: new SuccessMessageStatus(),
|
|
1648
1724
|
threadId: event.threadId,
|
|
1649
1725
|
agentName: event.agentName,
|
|
@@ -1656,7 +1732,7 @@ var CopilotResolver = class {
|
|
|
1656
1732
|
createdAt: /* @__PURE__ */ new Date()
|
|
1657
1733
|
});
|
|
1658
1734
|
outputMessages.push((0, import_class_transformer.plainToInstance)(AgentStateMessage, {
|
|
1659
|
-
id: (0,
|
|
1735
|
+
id: (0, import_shared4.randomId)(),
|
|
1660
1736
|
threadId: event.threadId,
|
|
1661
1737
|
agentName: event.agentName,
|
|
1662
1738
|
nodeName: event.nodeName,
|
|
@@ -1686,7 +1762,7 @@ var CopilotResolver = class {
|
|
|
1686
1762
|
logger2.debug("Event stream completed");
|
|
1687
1763
|
if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
|
|
1688
1764
|
logger2.debug("Guardrails is enabled, waiting for guardrails result");
|
|
1689
|
-
await (0,
|
|
1765
|
+
await (0, import_rxjs3.firstValueFrom)(guardrailsResult$);
|
|
1690
1766
|
}
|
|
1691
1767
|
responseStatus$.next(new SuccessResponseStatus());
|
|
1692
1768
|
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
@@ -1844,7 +1920,7 @@ function copilotRuntimeNextJSAppRouterEndpoint(options) {
|
|
|
1844
1920
|
_copilotkit: options.properties._copilotkit
|
|
1845
1921
|
});
|
|
1846
1922
|
}
|
|
1847
|
-
telemetry_client_default.capture("oss.runtime.instance_created",
|
|
1923
|
+
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
|
|
1848
1924
|
const logger2 = commonConfig.logging;
|
|
1849
1925
|
logger2.debug("Creating NextJS App Router endpoint");
|
|
1850
1926
|
const yoga = (0, import_graphql_yoga2.createYoga)({
|
|
@@ -1883,7 +1959,7 @@ function copilotRuntimeNextJSPagesRouterEndpoint(options) {
|
|
|
1883
1959
|
_copilotkit: options.properties._copilotkit
|
|
1884
1960
|
});
|
|
1885
1961
|
}
|
|
1886
|
-
telemetry_client_default.capture("oss.runtime.instance_created",
|
|
1962
|
+
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
|
|
1887
1963
|
const logger2 = commonConfig.logging;
|
|
1888
1964
|
logger2.debug("Creating NextJS Pages Router endpoint");
|
|
1889
1965
|
const yoga = (0, import_graphql_yoga3.createYoga)({
|
|
@@ -1909,7 +1985,7 @@ function copilotRuntimeNodeHttpEndpoint(options) {
|
|
|
1909
1985
|
_copilotkit: options.properties._copilotkit
|
|
1910
1986
|
});
|
|
1911
1987
|
}
|
|
1912
|
-
telemetry_client_default.capture("oss.runtime.instance_created",
|
|
1988
|
+
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
|
|
1913
1989
|
const logger2 = commonConfig.logging;
|
|
1914
1990
|
logger2.debug("Creating Node HTTP endpoint");
|
|
1915
1991
|
const yoga = (0, import_graphql_yoga4.createYoga)({
|
|
@@ -1927,7 +2003,7 @@ function copilotRuntimeNodeExpressEndpoint(options) {
|
|
|
1927
2003
|
framework: "node-express"
|
|
1928
2004
|
}
|
|
1929
2005
|
});
|
|
1930
|
-
telemetry_client_default.capture("oss.runtime.instance_created",
|
|
2006
|
+
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
|
|
1931
2007
|
return copilotRuntimeNodeHttpEndpoint(options);
|
|
1932
2008
|
}
|
|
1933
2009
|
__name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
|
|
@@ -1939,7 +2015,7 @@ function copilotRuntimeNestEndpoint(options) {
|
|
|
1939
2015
|
framework: "nest"
|
|
1940
2016
|
}
|
|
1941
2017
|
});
|
|
1942
|
-
telemetry_client_default.capture("oss.runtime.instance_created",
|
|
2018
|
+
telemetry_client_default.capture("oss.runtime.instance_created", getRuntimeInstanceTelemetryInfo(options.runtime));
|
|
1943
2019
|
return copilotRuntimeNodeHttpEndpoint(options);
|
|
1944
2020
|
}
|
|
1945
2021
|
__name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|