@copilotkit/runtime 1.4.8-next.0 → 1.4.8-next.1
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 +9 -0
- package/__snapshots__/schema/schema.graphql +1 -0
- package/dist/{chunk-U6LFW34R.mjs → chunk-5KJYPVQJ.mjs} +16 -8
- package/dist/chunk-5KJYPVQJ.mjs.map +1 -0
- package/dist/{chunk-CDXNOPUW.mjs → chunk-CGGI46KC.mjs} +2 -2
- package/dist/{chunk-DOQSOWZS.mjs → chunk-EU52BTKR.mjs} +2 -2
- package/dist/{chunk-3KW7FFG5.mjs → chunk-KO4QCMY4.mjs} +2 -2
- package/dist/{chunk-OKQVDDJ2.mjs → chunk-W7GP2EOT.mjs} +50 -2
- package/dist/chunk-W7GP2EOT.mjs.map +1 -0
- package/dist/{copilot-runtime-12e7ac40.d.ts → copilot-runtime-1c5bf72b.d.ts} +1 -1
- package/dist/{groq-adapter-24abe931.d.ts → groq-adapter-b6a40422.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +83 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{langserve-f021ab9c.d.ts → langserve-6245df39.d.ts} +2 -1
- package/dist/lib/index.d.ts +3 -3
- package/dist/lib/index.js +14 -6
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +5 -5
- package/dist/lib/integrations/index.d.ts +3 -3
- package/dist/lib/integrations/index.js +10 -3
- 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 +10 -3
- 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 +10 -3
- 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 +10 -3
- 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 +35 -4
- package/dist/service-adapters/index.js +50 -0
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +5 -1
- package/package.json +2 -2
- package/src/graphql/inputs/forwarded-parameters.input.ts +3 -0
- package/src/lib/logger.ts +1 -1
- package/src/lib/runtime/remote-action-constructors.ts +61 -57
- package/src/service-adapters/experimental/empty/empty-adapter.ts +33 -0
- package/src/service-adapters/index.ts +7 -1
- package/dist/chunk-OKQVDDJ2.mjs.map +0 -1
- package/dist/chunk-U6LFW34R.mjs.map +0 -1
- /package/dist/{chunk-CDXNOPUW.mjs.map → chunk-CGGI46KC.mjs.map} +0 -0
- /package/dist/{chunk-DOQSOWZS.mjs.map → chunk-EU52BTKR.mjs.map} +0 -0
- /package/dist/{chunk-3KW7FFG5.mjs.map → chunk-KO4QCMY4.mjs.map} +0 -0
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.4.8-next.
|
|
47
|
+
version: "1.4.8-next.1",
|
|
48
48
|
sideEffects: false,
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -126,6 +126,8 @@ var src_exports = {};
|
|
|
126
126
|
__export(src_exports, {
|
|
127
127
|
AnthropicAdapter: () => AnthropicAdapter,
|
|
128
128
|
CopilotRuntime: () => CopilotRuntime,
|
|
129
|
+
ExperimentalEmptyAdapter: () => ExperimentalEmptyAdapter,
|
|
130
|
+
ExperimentalOllamaAdapter: () => ExperimentalOllamaAdapter,
|
|
129
131
|
GoogleGenerativeAIAdapter: () => GoogleGenerativeAIAdapter,
|
|
130
132
|
GroqAdapter: () => GroqAdapter,
|
|
131
133
|
GuardrailsValidationFailureResponse: () => GuardrailsValidationFailureResponse,
|
|
@@ -154,7 +156,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
154
156
|
var import_reflect_metadata = require("reflect-metadata");
|
|
155
157
|
|
|
156
158
|
// src/lib/runtime/copilot-runtime.ts
|
|
157
|
-
var
|
|
159
|
+
var import_shared12 = require("@copilotkit/shared");
|
|
158
160
|
|
|
159
161
|
// src/service-adapters/langchain/langserve.ts
|
|
160
162
|
var import_remote = require("langchain/runnables/remote");
|
|
@@ -1313,12 +1315,58 @@ var FilterThinkingTextBuffer = /* @__PURE__ */ __name(class FilterThinkingTextBu
|
|
|
1313
1315
|
}
|
|
1314
1316
|
}, "FilterThinkingTextBuffer");
|
|
1315
1317
|
|
|
1318
|
+
// src/service-adapters/experimental/ollama/ollama-adapter.ts
|
|
1319
|
+
var import_ollama = require("@langchain/community/llms/ollama");
|
|
1320
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
1321
|
+
var DEFAULT_MODEL4 = "llama3:latest";
|
|
1322
|
+
var ExperimentalOllamaAdapter = class {
|
|
1323
|
+
model;
|
|
1324
|
+
constructor(options) {
|
|
1325
|
+
if (options == null ? void 0 : options.model) {
|
|
1326
|
+
this.model = options.model;
|
|
1327
|
+
} else {
|
|
1328
|
+
this.model = DEFAULT_MODEL4;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
async process(request) {
|
|
1332
|
+
const { messages, actions, eventSource } = request;
|
|
1333
|
+
const ollama = new import_ollama.Ollama({
|
|
1334
|
+
model: this.model
|
|
1335
|
+
});
|
|
1336
|
+
const contents = messages.filter((m) => m.isTextMessage()).map((m) => m.content);
|
|
1337
|
+
const _stream = await ollama.stream(contents);
|
|
1338
|
+
eventSource.stream(async (eventStream$) => {
|
|
1339
|
+
eventStream$.sendTextMessageStart((0, import_shared7.randomId)());
|
|
1340
|
+
for await (const chunkText of _stream) {
|
|
1341
|
+
eventStream$.sendTextMessageContent(chunkText);
|
|
1342
|
+
}
|
|
1343
|
+
eventStream$.sendTextMessageEnd();
|
|
1344
|
+
eventStream$.complete();
|
|
1345
|
+
});
|
|
1346
|
+
return {
|
|
1347
|
+
threadId: request.threadId || (0, import_shared7.randomId)()
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
__name(ExperimentalOllamaAdapter, "ExperimentalOllamaAdapter");
|
|
1352
|
+
|
|
1353
|
+
// src/service-adapters/experimental/empty/empty-adapter.ts
|
|
1354
|
+
var import_shared8 = require("@copilotkit/shared");
|
|
1355
|
+
var ExperimentalEmptyAdapter = class {
|
|
1356
|
+
async process(request) {
|
|
1357
|
+
return {
|
|
1358
|
+
threadId: request.threadId || (0, import_shared8.randomId)()
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
__name(ExperimentalEmptyAdapter, "ExperimentalEmptyAdapter");
|
|
1363
|
+
|
|
1316
1364
|
// src/service-adapters/events.ts
|
|
1317
|
-
var
|
|
1365
|
+
var import_shared11 = require("@copilotkit/shared");
|
|
1318
1366
|
var import_rxjs2 = require("rxjs");
|
|
1319
1367
|
|
|
1320
1368
|
// src/lib/telemetry-client.ts
|
|
1321
|
-
var
|
|
1369
|
+
var import_shared10 = require("@copilotkit/shared");
|
|
1322
1370
|
|
|
1323
1371
|
// src/lib/runtime/remote-action-constructors.ts
|
|
1324
1372
|
var import_node_crypto2 = require("crypto");
|
|
@@ -1351,7 +1399,7 @@ var CustomEventNames;
|
|
|
1351
1399
|
})(CustomEventNames || (CustomEventNames = {}));
|
|
1352
1400
|
|
|
1353
1401
|
// src/agents/langgraph/event-source.ts
|
|
1354
|
-
var
|
|
1402
|
+
var import_shared9 = require("@copilotkit/shared");
|
|
1355
1403
|
var RemoteLangGraphEventSource = class {
|
|
1356
1404
|
eventStream$ = new import_rxjs.ReplaySubject();
|
|
1357
1405
|
shouldEmitToolCall(shouldEmitToolCalls, toolCallName) {
|
|
@@ -1537,7 +1585,7 @@ var RemoteLangGraphEventSource = class {
|
|
|
1537
1585
|
type: RuntimeEventTypes.ActionExecutionEnd
|
|
1538
1586
|
});
|
|
1539
1587
|
}
|
|
1540
|
-
const messageId = (0,
|
|
1588
|
+
const messageId = (0, import_shared9.randomId)();
|
|
1541
1589
|
events.push({
|
|
1542
1590
|
type: RuntimeEventTypes.TextMessageStart,
|
|
1543
1591
|
messageId
|
|
@@ -2100,6 +2148,7 @@ function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, m
|
|
|
2100
2148
|
}
|
|
2101
2149
|
__name(constructLGCRemoteAction, "constructLGCRemoteAction");
|
|
2102
2150
|
function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, logger: logger2, messages, agentStates }) {
|
|
2151
|
+
const totalAgents = Array.isArray(json["agents"]) ? json["agents"].length : 0;
|
|
2103
2152
|
const actions = json["actions"].map((action) => ({
|
|
2104
2153
|
name: action.name,
|
|
2105
2154
|
description: action.description,
|
|
@@ -2113,7 +2162,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2113
2162
|
telemetry_client_default.capture("oss.runtime.remote_action_executed", {
|
|
2114
2163
|
agentExecution: false,
|
|
2115
2164
|
type: "self-hosted",
|
|
2116
|
-
agentsAmount:
|
|
2165
|
+
agentsAmount: totalAgents
|
|
2117
2166
|
});
|
|
2118
2167
|
try {
|
|
2119
2168
|
const response = await fetch(`${url}/actions/execute`, {
|
|
@@ -2148,7 +2197,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2148
2197
|
}
|
|
2149
2198
|
}
|
|
2150
2199
|
}));
|
|
2151
|
-
const agents = json["agents"].map((agent) => ({
|
|
2200
|
+
const agents = totalAgents ? json["agents"].map((agent) => ({
|
|
2152
2201
|
name: agent.name,
|
|
2153
2202
|
description: agent.description,
|
|
2154
2203
|
parameters: [],
|
|
@@ -2201,7 +2250,7 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
|
|
|
2201
2250
|
streamResponse(response.body, eventSource.eventStream$);
|
|
2202
2251
|
return eventSource.processLangGraphEvents();
|
|
2203
2252
|
}
|
|
2204
|
-
}));
|
|
2253
|
+
})) : [];
|
|
2205
2254
|
return [
|
|
2206
2255
|
...actions,
|
|
2207
2256
|
...agents
|
|
@@ -2378,7 +2427,7 @@ __name(setupRemoteActions, "setupRemoteActions");
|
|
|
2378
2427
|
// src/lib/telemetry-client.ts
|
|
2379
2428
|
var import_node_crypto3 = require("crypto");
|
|
2380
2429
|
var packageJson = require_package();
|
|
2381
|
-
var telemetryClient = new
|
|
2430
|
+
var telemetryClient = new import_shared10.TelemetryClient({
|
|
2382
2431
|
packageName: packageJson.name,
|
|
2383
2432
|
packageVersion: packageJson.version
|
|
2384
2433
|
});
|
|
@@ -2516,10 +2565,10 @@ var RuntimeEventSource = class {
|
|
|
2516
2565
|
const errorMessage = "\u274C An error occurred. Please try again.";
|
|
2517
2566
|
if (!this.callback) {
|
|
2518
2567
|
this.stream(async (eventStream$) => {
|
|
2519
|
-
eventStream$.sendTextMessage((0,
|
|
2568
|
+
eventStream$.sendTextMessage((0, import_shared11.randomId)(), errorMessage);
|
|
2520
2569
|
});
|
|
2521
2570
|
} else {
|
|
2522
|
-
this.eventStream$.sendTextMessage((0,
|
|
2571
|
+
this.eventStream$.sendTextMessage((0, import_shared11.randomId)(), errorMessage);
|
|
2523
2572
|
}
|
|
2524
2573
|
}
|
|
2525
2574
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
|
|
@@ -2786,7 +2835,7 @@ var CopilotRuntime = class {
|
|
|
2786
2835
|
const serverSideActionsInput = serverSideActions.map((action) => ({
|
|
2787
2836
|
name: action.name,
|
|
2788
2837
|
description: action.description,
|
|
2789
|
-
jsonSchema: JSON.stringify((0,
|
|
2838
|
+
jsonSchema: JSON.stringify((0, import_shared12.actionParametersToJsonSchema)(action.parameters))
|
|
2790
2839
|
}));
|
|
2791
2840
|
const actionInputs = flattenToolCallsNoDuplicates([
|
|
2792
2841
|
...serverSideActionsInput,
|
|
@@ -2836,8 +2885,8 @@ var CopilotRuntime = class {
|
|
|
2836
2885
|
console.error("Error getting response:", error);
|
|
2837
2886
|
eventSource.sendErrorMessageToChat();
|
|
2838
2887
|
return {
|
|
2839
|
-
threadId: threadId || (0,
|
|
2840
|
-
runId: runId || (0,
|
|
2888
|
+
threadId: threadId || (0, import_shared12.randomId)(),
|
|
2889
|
+
runId: runId || (0, import_shared12.randomId)(),
|
|
2841
2890
|
eventSource,
|
|
2842
2891
|
serverSideActions: [],
|
|
2843
2892
|
actionInputsWithoutAgents: []
|
|
@@ -2857,7 +2906,7 @@ var CopilotRuntime = class {
|
|
|
2857
2906
|
const serverSideActionsInput = serverSideActions.filter((action) => !isLangGraphAgentAction(action)).map((action) => ({
|
|
2858
2907
|
name: action.name,
|
|
2859
2908
|
description: action.description,
|
|
2860
|
-
jsonSchema: JSON.stringify((0,
|
|
2909
|
+
jsonSchema: JSON.stringify((0, import_shared12.actionParametersToJsonSchema)(action.parameters))
|
|
2861
2910
|
}));
|
|
2862
2911
|
const actionInputsWithoutAgents = flattenToolCallsNoDuplicates([
|
|
2863
2912
|
...serverSideActionsInput,
|
|
@@ -3356,6 +3405,7 @@ var ForwardedParametersInput = class {
|
|
|
3356
3405
|
stop;
|
|
3357
3406
|
toolChoice;
|
|
3358
3407
|
toolChoiceFunctionName;
|
|
3408
|
+
temperature;
|
|
3359
3409
|
};
|
|
3360
3410
|
__name(ForwardedParametersInput, "ForwardedParametersInput");
|
|
3361
3411
|
_ts_decorate7([
|
|
@@ -3390,6 +3440,12 @@ _ts_decorate7([
|
|
|
3390
3440
|
}),
|
|
3391
3441
|
_ts_metadata7("design:type", String)
|
|
3392
3442
|
], ForwardedParametersInput.prototype, "toolChoiceFunctionName", void 0);
|
|
3443
|
+
_ts_decorate7([
|
|
3444
|
+
(0, import_type_graphql8.Field)(() => Number, {
|
|
3445
|
+
nullable: true
|
|
3446
|
+
}),
|
|
3447
|
+
_ts_metadata7("design:type", Number)
|
|
3448
|
+
], ForwardedParametersInput.prototype, "temperature", void 0);
|
|
3393
3449
|
ForwardedParametersInput = _ts_decorate7([
|
|
3394
3450
|
(0, import_type_graphql8.InputType)()
|
|
3395
3451
|
], ForwardedParametersInput);
|
|
@@ -3999,7 +4055,7 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
|
3999
4055
|
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
4000
4056
|
|
|
4001
4057
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
4002
|
-
var
|
|
4058
|
+
var import_shared13 = require("@copilotkit/shared");
|
|
4003
4059
|
function _ts_decorate14(decorators, target, key, desc) {
|
|
4004
4060
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4005
4061
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4116,7 +4172,7 @@ var CopilotResolver = class {
|
|
|
4116
4172
|
rejectOutputMessagesPromise = reject;
|
|
4117
4173
|
});
|
|
4118
4174
|
logger2.debug("Processing");
|
|
4119
|
-
const { eventSource, threadId = (0,
|
|
4175
|
+
const { eventSource, threadId = (0, import_shared13.randomId)(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
|
|
4120
4176
|
serviceAdapter,
|
|
4121
4177
|
messages: data.messages,
|
|
4122
4178
|
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
@@ -4161,7 +4217,7 @@ var CopilotResolver = class {
|
|
|
4161
4217
|
});
|
|
4162
4218
|
outputMessages = [
|
|
4163
4219
|
(0, import_class_transformer2.plainToInstance)(TextMessage, {
|
|
4164
|
-
id: (0,
|
|
4220
|
+
id: (0, import_shared13.randomId)(),
|
|
4165
4221
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4166
4222
|
content: result.reason,
|
|
4167
4223
|
role: MessageRole.assistant
|
|
@@ -4324,7 +4380,7 @@ var CopilotResolver = class {
|
|
|
4324
4380
|
result: event.result
|
|
4325
4381
|
}, "Action execution result event received");
|
|
4326
4382
|
pushMessage({
|
|
4327
|
-
id: (0,
|
|
4383
|
+
id: (0, import_shared13.randomId)(),
|
|
4328
4384
|
status: new SuccessMessageStatus(),
|
|
4329
4385
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4330
4386
|
actionExecutionId: event.actionExecutionId,
|
|
@@ -4332,7 +4388,7 @@ var CopilotResolver = class {
|
|
|
4332
4388
|
result: event.result
|
|
4333
4389
|
});
|
|
4334
4390
|
outputMessages.push((0, import_class_transformer2.plainToInstance)(ResultMessage, {
|
|
4335
|
-
id: (0,
|
|
4391
|
+
id: (0, import_shared13.randomId)(),
|
|
4336
4392
|
createdAt: /* @__PURE__ */ new Date(),
|
|
4337
4393
|
actionExecutionId: event.actionExecutionId,
|
|
4338
4394
|
actionName: event.actionName,
|
|
@@ -4344,7 +4400,7 @@ var CopilotResolver = class {
|
|
|
4344
4400
|
event
|
|
4345
4401
|
}, "Agent message event received");
|
|
4346
4402
|
pushMessage({
|
|
4347
|
-
id: (0,
|
|
4403
|
+
id: (0, import_shared13.randomId)(),
|
|
4348
4404
|
status: new SuccessMessageStatus(),
|
|
4349
4405
|
threadId: event.threadId,
|
|
4350
4406
|
agentName: event.agentName,
|
|
@@ -4357,7 +4413,7 @@ var CopilotResolver = class {
|
|
|
4357
4413
|
createdAt: /* @__PURE__ */ new Date()
|
|
4358
4414
|
});
|
|
4359
4415
|
outputMessages.push((0, import_class_transformer2.plainToInstance)(AgentStateMessage, {
|
|
4360
|
-
id: (0,
|
|
4416
|
+
id: (0, import_shared13.randomId)(),
|
|
4361
4417
|
threadId: event.threadId,
|
|
4362
4418
|
agentName: event.agentName,
|
|
4363
4419
|
nodeName: event.nodeName,
|
|
@@ -4441,8 +4497,8 @@ function createLogger(options) {
|
|
|
4441
4497
|
level: process.env.LOG_LEVEL || level || "error",
|
|
4442
4498
|
redact: {
|
|
4443
4499
|
paths: [
|
|
4444
|
-
"
|
|
4445
|
-
"
|
|
4500
|
+
"pid",
|
|
4501
|
+
"hostname"
|
|
4446
4502
|
],
|
|
4447
4503
|
remove: true
|
|
4448
4504
|
}
|
|
@@ -4648,6 +4704,8 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
|
|
|
4648
4704
|
0 && (module.exports = {
|
|
4649
4705
|
AnthropicAdapter,
|
|
4650
4706
|
CopilotRuntime,
|
|
4707
|
+
ExperimentalEmptyAdapter,
|
|
4708
|
+
ExperimentalOllamaAdapter,
|
|
4651
4709
|
GoogleGenerativeAIAdapter,
|
|
4652
4710
|
GroqAdapter,
|
|
4653
4711
|
GuardrailsValidationFailureResponse,
|