@copilotkit/runtime 1.5.1-next.0 → 1.5.1-next.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/CHANGELOG.md +17 -0
- package/__snapshots__/schema/schema.graphql +11 -0
- package/dist/{chunk-E7C6IPQ3.mjs → chunk-2FY7EQEE.mjs} +2 -2
- package/dist/{chunk-ESA3KK24.mjs → chunk-2V7BHSFE.mjs} +134 -20
- package/dist/chunk-2V7BHSFE.mjs.map +1 -0
- package/dist/{chunk-BZWZBSGW.mjs → chunk-2ZPE55QG.mjs} +2 -2
- package/dist/{chunk-BDHGW64L.mjs → chunk-W6E7AVR7.mjs} +2 -2
- package/dist/{copilot-runtime-6285d897.d.ts → copilot-runtime-36700e00.d.ts} +9 -2
- package/dist/graphql/types/converted/index.d.ts +1 -1
- package/dist/{groq-adapter-15d41154.d.ts → groq-adapter-696b5d29.d.ts} +1 -1
- package/dist/{index-ff3fbc33.d.ts → index-cc2b17be.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +133 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/{langserve-48e976ac.d.ts → langserve-9125a12e.d.ts} +1 -1
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +133 -19
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +4 -4
- package/dist/lib/integrations/index.d.ts +4 -4
- package/dist/lib/integrations/index.js +94 -19
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +4 -4
- package/dist/lib/integrations/nest/index.d.ts +3 -3
- package/dist/lib/integrations/nest/index.js +94 -19
- 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.d.ts +3 -3
- package/dist/lib/integrations/node-express/index.js +94 -19
- 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.d.ts +3 -3
- package/dist/lib/integrations/node-http/index.js +94 -19
- 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.d.ts +4 -4
- package/package.json +2 -2
- package/src/graphql/resolvers/copilot.resolver.ts +16 -0
- package/src/graphql/types/agents-response.type.ts +22 -0
- package/src/lib/runtime/copilot-runtime.ts +50 -0
- package/dist/chunk-ESA3KK24.mjs.map +0 -1
- /package/dist/{chunk-E7C6IPQ3.mjs.map → chunk-2FY7EQEE.mjs.map} +0 -0
- /package/dist/{chunk-BZWZBSGW.mjs.map → chunk-2ZPE55QG.mjs.map} +0 -0
- /package/dist/{chunk-BDHGW64L.mjs.map → chunk-W6E7AVR7.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @copilotkit/runtime
|
|
2
2
|
|
|
3
|
+
## 1.5.1-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- da280ed: Test prerelease script
|
|
8
|
+
- 649ebcc: - fix: add warning when using agents that are not available on agent related hooks
|
|
9
|
+
- Updated dependencies [da280ed]
|
|
10
|
+
- @copilotkit/shared@1.5.1-next.2
|
|
11
|
+
|
|
12
|
+
## 1.5.1-next.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 03f3d6f: Test next prerelease
|
|
17
|
+
- Updated dependencies [03f3d6f]
|
|
18
|
+
- @copilotkit/shared@1.5.1-next.1
|
|
19
|
+
|
|
3
20
|
## 1.5.1-next.0
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -34,6 +34,12 @@ enum ActionInputAvailability {
|
|
|
34
34
|
remote
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
type Agent {
|
|
38
|
+
description: String!
|
|
39
|
+
id: String!
|
|
40
|
+
name: String!
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
input AgentSessionInput {
|
|
38
44
|
agentName: String!
|
|
39
45
|
nodeName: String
|
|
@@ -70,6 +76,10 @@ type AgentStateMessageOutput implements BaseMessageOutput {
|
|
|
70
76
|
threadId: String!
|
|
71
77
|
}
|
|
72
78
|
|
|
79
|
+
type AgentsResponse {
|
|
80
|
+
agents: [Agent!]!
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
interface BaseMessageOutput {
|
|
74
84
|
createdAt: DateTimeISO!
|
|
75
85
|
id: String!
|
|
@@ -211,6 +221,7 @@ type PendingResponseStatus implements BaseResponseStatus {
|
|
|
211
221
|
}
|
|
212
222
|
|
|
213
223
|
type Query {
|
|
224
|
+
availableAgents: AgentsResponse!
|
|
214
225
|
hello: String!
|
|
215
226
|
}
|
|
216
227
|
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getCommonConfig,
|
|
3
3
|
getRuntimeInstanceTelemetryInfo,
|
|
4
4
|
telemetry_client_default
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2V7BHSFE.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-44O2JGUY.mjs";
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
config,
|
|
78
78
|
copilotRuntimeNextJSPagesRouterEndpoint
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-2FY7EQEE.mjs.map
|
|
@@ -37,7 +37,7 @@ var require_package = __commonJS({
|
|
|
37
37
|
publishConfig: {
|
|
38
38
|
access: "public"
|
|
39
39
|
},
|
|
40
|
-
version: "1.5.1-next.
|
|
40
|
+
version: "1.5.1-next.2",
|
|
41
41
|
sideEffects: false,
|
|
42
42
|
main: "./dist/index.js",
|
|
43
43
|
module: "./dist/index.mjs",
|
|
@@ -1079,7 +1079,7 @@ CopilotResponse = _ts_decorate11([
|
|
|
1079
1079
|
import { Repeater } from "graphql-yoga";
|
|
1080
1080
|
|
|
1081
1081
|
// src/service-adapters/events.ts
|
|
1082
|
-
import { randomId as
|
|
1082
|
+
import { randomId as randomId3 } from "@copilotkit/shared";
|
|
1083
1083
|
import { of, concat, scan as scan2, concatMap, ReplaySubject as ReplaySubject2, firstValueFrom, from as from2 } from "rxjs";
|
|
1084
1084
|
|
|
1085
1085
|
// src/lib/telemetry-client.ts
|
|
@@ -2142,7 +2142,7 @@ __name(setupRemoteActions, "setupRemoteActions");
|
|
|
2142
2142
|
import { createHash as createHash3 } from "crypto";
|
|
2143
2143
|
|
|
2144
2144
|
// src/lib/runtime/copilot-runtime.ts
|
|
2145
|
-
import { actionParametersToJsonSchema } from "@copilotkit/shared";
|
|
2145
|
+
import { actionParametersToJsonSchema, randomId as randomId2 } from "@copilotkit/shared";
|
|
2146
2146
|
|
|
2147
2147
|
// src/service-adapters/conversion.ts
|
|
2148
2148
|
import { plainToInstance } from "class-transformer";
|
|
@@ -2277,6 +2277,45 @@ var CopilotRuntime = class {
|
|
|
2277
2277
|
throw error;
|
|
2278
2278
|
}
|
|
2279
2279
|
}
|
|
2280
|
+
async discoverAgentsFromEndpoints(graphqlContext) {
|
|
2281
|
+
const headers = createHeaders(null, graphqlContext);
|
|
2282
|
+
const agents = this.remoteEndpointDefinitions.reduce(async (acc, endpoint) => {
|
|
2283
|
+
const agents2 = await acc;
|
|
2284
|
+
if (endpoint.type === EndpointType.LangGraphPlatform) {
|
|
2285
|
+
const response2 = await fetch(`${endpoint.deploymentUrl}/assistants/search`, {
|
|
2286
|
+
method: "POST",
|
|
2287
|
+
headers
|
|
2288
|
+
});
|
|
2289
|
+
const data2 = await response2.json();
|
|
2290
|
+
const endpointAgents2 = (data2 ?? []).map((entry) => ({
|
|
2291
|
+
name: entry.graph_id,
|
|
2292
|
+
id: entry.assistant_id
|
|
2293
|
+
}));
|
|
2294
|
+
return [
|
|
2295
|
+
...agents2,
|
|
2296
|
+
...endpointAgents2
|
|
2297
|
+
];
|
|
2298
|
+
}
|
|
2299
|
+
const response = await fetch(`${endpoint.url}/info`, {
|
|
2300
|
+
method: "POST",
|
|
2301
|
+
headers,
|
|
2302
|
+
body: JSON.stringify({
|
|
2303
|
+
properties: graphqlContext.properties
|
|
2304
|
+
})
|
|
2305
|
+
});
|
|
2306
|
+
const data = await response.json();
|
|
2307
|
+
const endpointAgents = ((data == null ? void 0 : data.agents) ?? []).map((agent) => ({
|
|
2308
|
+
name: agent.name,
|
|
2309
|
+
description: agent.description,
|
|
2310
|
+
id: randomId2()
|
|
2311
|
+
}));
|
|
2312
|
+
return [
|
|
2313
|
+
...agents2,
|
|
2314
|
+
...endpointAgents
|
|
2315
|
+
];
|
|
2316
|
+
}, Promise.resolve([]));
|
|
2317
|
+
return agents;
|
|
2318
|
+
}
|
|
2280
2319
|
async processAgentRequest(request) {
|
|
2281
2320
|
var _a;
|
|
2282
2321
|
const { messages: rawMessages, outputMessagesPromise, graphqlContext, agentSession } = request;
|
|
@@ -2576,10 +2615,10 @@ var RuntimeEventSource = class {
|
|
|
2576
2615
|
const errorMessage = `\u274C ${message}`;
|
|
2577
2616
|
if (!this.callback) {
|
|
2578
2617
|
this.stream(async (eventStream$) => {
|
|
2579
|
-
eventStream$.sendTextMessage(
|
|
2618
|
+
eventStream$.sendTextMessage(randomId3(), errorMessage);
|
|
2580
2619
|
});
|
|
2581
2620
|
} else {
|
|
2582
|
-
this.eventStream$.sendTextMessage(
|
|
2621
|
+
this.eventStream$.sendTextMessage(randomId3(), errorMessage);
|
|
2583
2622
|
}
|
|
2584
2623
|
}
|
|
2585
2624
|
processRuntimeEvents({ serverSideActions, guardrailsResult$, actionInputsWithoutAgents }) {
|
|
@@ -2701,7 +2740,10 @@ __name(executeAction, "executeAction");
|
|
|
2701
2740
|
import { GraphQLJSONObject } from "graphql-scalars";
|
|
2702
2741
|
import { plainToInstance as plainToInstance3 } from "class-transformer";
|
|
2703
2742
|
import { GraphQLError } from "graphql";
|
|
2704
|
-
import { randomId as
|
|
2743
|
+
import { randomId as randomId4 } from "@copilotkit/shared";
|
|
2744
|
+
|
|
2745
|
+
// src/graphql/types/agents-response.type.ts
|
|
2746
|
+
import { Field as Field12, ObjectType as ObjectType3 } from "type-graphql";
|
|
2705
2747
|
function _ts_decorate12(decorators, target, key, desc) {
|
|
2706
2748
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2707
2749
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2718,6 +2760,58 @@ function _ts_metadata12(k, v) {
|
|
|
2718
2760
|
return Reflect.metadata(k, v);
|
|
2719
2761
|
}
|
|
2720
2762
|
__name(_ts_metadata12, "_ts_metadata");
|
|
2763
|
+
var Agent = class {
|
|
2764
|
+
id;
|
|
2765
|
+
name;
|
|
2766
|
+
description;
|
|
2767
|
+
};
|
|
2768
|
+
__name(Agent, "Agent");
|
|
2769
|
+
_ts_decorate12([
|
|
2770
|
+
Field12(() => String),
|
|
2771
|
+
_ts_metadata12("design:type", String)
|
|
2772
|
+
], Agent.prototype, "id", void 0);
|
|
2773
|
+
_ts_decorate12([
|
|
2774
|
+
Field12(() => String),
|
|
2775
|
+
_ts_metadata12("design:type", String)
|
|
2776
|
+
], Agent.prototype, "name", void 0);
|
|
2777
|
+
_ts_decorate12([
|
|
2778
|
+
Field12(() => String),
|
|
2779
|
+
_ts_metadata12("design:type", String)
|
|
2780
|
+
], Agent.prototype, "description", void 0);
|
|
2781
|
+
Agent = _ts_decorate12([
|
|
2782
|
+
ObjectType3()
|
|
2783
|
+
], Agent);
|
|
2784
|
+
var AgentsResponse = class {
|
|
2785
|
+
agents;
|
|
2786
|
+
};
|
|
2787
|
+
__name(AgentsResponse, "AgentsResponse");
|
|
2788
|
+
_ts_decorate12([
|
|
2789
|
+
Field12(() => [
|
|
2790
|
+
Agent
|
|
2791
|
+
]),
|
|
2792
|
+
_ts_metadata12("design:type", Array)
|
|
2793
|
+
], AgentsResponse.prototype, "agents", void 0);
|
|
2794
|
+
AgentsResponse = _ts_decorate12([
|
|
2795
|
+
ObjectType3()
|
|
2796
|
+
], AgentsResponse);
|
|
2797
|
+
|
|
2798
|
+
// src/graphql/resolvers/copilot.resolver.ts
|
|
2799
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2800
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2801
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2802
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2803
|
+
else
|
|
2804
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
2805
|
+
if (d = decorators[i])
|
|
2806
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2807
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2808
|
+
}
|
|
2809
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2810
|
+
function _ts_metadata13(k, v) {
|
|
2811
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2812
|
+
return Reflect.metadata(k, v);
|
|
2813
|
+
}
|
|
2814
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2721
2815
|
function _ts_param(paramIndex, decorator) {
|
|
2722
2816
|
return function(target, key) {
|
|
2723
2817
|
decorator(target, key, paramIndex);
|
|
@@ -2759,6 +2853,17 @@ var CopilotResolver = class {
|
|
|
2759
2853
|
async hello() {
|
|
2760
2854
|
return "Hello World";
|
|
2761
2855
|
}
|
|
2856
|
+
async availableAgents(ctx) {
|
|
2857
|
+
let logger2 = ctx.logger.child({
|
|
2858
|
+
component: "CopilotResolver.availableAgents"
|
|
2859
|
+
});
|
|
2860
|
+
logger2.debug("Processing");
|
|
2861
|
+
const agents = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
|
|
2862
|
+
logger2.debug("Event source created, creating response");
|
|
2863
|
+
return {
|
|
2864
|
+
agents
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2762
2867
|
async generateCopilotResponse(ctx, data, properties) {
|
|
2763
2868
|
var _a, _b, _c;
|
|
2764
2869
|
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
@@ -2818,7 +2923,7 @@ var CopilotResolver = class {
|
|
|
2818
2923
|
rejectOutputMessagesPromise = reject;
|
|
2819
2924
|
});
|
|
2820
2925
|
logger2.debug("Processing");
|
|
2821
|
-
const { eventSource, threadId =
|
|
2926
|
+
const { eventSource, threadId = randomId4(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
|
|
2822
2927
|
serviceAdapter,
|
|
2823
2928
|
messages: data.messages,
|
|
2824
2929
|
actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
|
|
@@ -2863,7 +2968,7 @@ var CopilotResolver = class {
|
|
|
2863
2968
|
});
|
|
2864
2969
|
outputMessages = [
|
|
2865
2970
|
plainToInstance3(TextMessage, {
|
|
2866
|
-
id:
|
|
2971
|
+
id: randomId4(),
|
|
2867
2972
|
createdAt: /* @__PURE__ */ new Date(),
|
|
2868
2973
|
content: result.reason,
|
|
2869
2974
|
role: MessageRole.assistant
|
|
@@ -3054,7 +3159,7 @@ var CopilotResolver = class {
|
|
|
3054
3159
|
event
|
|
3055
3160
|
}, "Agent message event received");
|
|
3056
3161
|
pushMessage({
|
|
3057
|
-
id:
|
|
3162
|
+
id: randomId4(),
|
|
3058
3163
|
status: new SuccessMessageStatus(),
|
|
3059
3164
|
threadId: event.threadId,
|
|
3060
3165
|
agentName: event.agentName,
|
|
@@ -3067,7 +3172,7 @@ var CopilotResolver = class {
|
|
|
3067
3172
|
createdAt: /* @__PURE__ */ new Date()
|
|
3068
3173
|
});
|
|
3069
3174
|
outputMessages.push(plainToInstance3(AgentStateMessage, {
|
|
3070
|
-
id:
|
|
3175
|
+
id: randomId4(),
|
|
3071
3176
|
threadId: event.threadId,
|
|
3072
3177
|
agentName: event.agentName,
|
|
3073
3178
|
nodeName: event.nodeName,
|
|
@@ -3111,28 +3216,37 @@ var CopilotResolver = class {
|
|
|
3111
3216
|
}
|
|
3112
3217
|
};
|
|
3113
3218
|
__name(CopilotResolver, "CopilotResolver");
|
|
3114
|
-
|
|
3219
|
+
_ts_decorate13([
|
|
3115
3220
|
Query(() => String),
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3221
|
+
_ts_metadata13("design:type", Function),
|
|
3222
|
+
_ts_metadata13("design:paramtypes", []),
|
|
3223
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3119
3224
|
], CopilotResolver.prototype, "hello", null);
|
|
3120
|
-
|
|
3225
|
+
_ts_decorate13([
|
|
3226
|
+
Query(() => AgentsResponse),
|
|
3227
|
+
_ts_param(0, Ctx()),
|
|
3228
|
+
_ts_metadata13("design:type", Function),
|
|
3229
|
+
_ts_metadata13("design:paramtypes", [
|
|
3230
|
+
typeof GraphQLContext === "undefined" ? Object : GraphQLContext
|
|
3231
|
+
]),
|
|
3232
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3233
|
+
], CopilotResolver.prototype, "availableAgents", null);
|
|
3234
|
+
_ts_decorate13([
|
|
3121
3235
|
Mutation(() => CopilotResponse),
|
|
3122
3236
|
_ts_param(0, Ctx()),
|
|
3123
3237
|
_ts_param(1, Arg("data")),
|
|
3124
3238
|
_ts_param(2, Arg("properties", () => GraphQLJSONObject, {
|
|
3125
3239
|
nullable: true
|
|
3126
3240
|
})),
|
|
3127
|
-
|
|
3128
|
-
|
|
3241
|
+
_ts_metadata13("design:type", Function),
|
|
3242
|
+
_ts_metadata13("design:paramtypes", [
|
|
3129
3243
|
typeof GraphQLContext === "undefined" ? Object : GraphQLContext,
|
|
3130
3244
|
typeof GenerateCopilotResponseInput === "undefined" ? Object : GenerateCopilotResponseInput,
|
|
3131
3245
|
typeof CopilotRequestContextProperties === "undefined" ? Object : CopilotRequestContextProperties
|
|
3132
3246
|
]),
|
|
3133
|
-
|
|
3247
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3134
3248
|
], CopilotResolver.prototype, "generateCopilotResponse", null);
|
|
3135
|
-
CopilotResolver =
|
|
3249
|
+
CopilotResolver = _ts_decorate13([
|
|
3136
3250
|
Resolver(() => CopilotResponse)
|
|
3137
3251
|
], CopilotResolver);
|
|
3138
3252
|
|
|
@@ -3278,4 +3392,4 @@ export {
|
|
|
3278
3392
|
getCommonConfig,
|
|
3279
3393
|
copilotRuntimeNodeHttpEndpoint
|
|
3280
3394
|
};
|
|
3281
|
-
//# sourceMappingURL=chunk-
|
|
3395
|
+
//# sourceMappingURL=chunk-2V7BHSFE.mjs.map
|