@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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-
|
|
2
|
-
export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-
|
|
3
|
-
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-
|
|
1
|
+
import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-9125a12e.js';
|
|
2
|
+
export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-9125a12e.js';
|
|
3
|
+
export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-696b5d29.js';
|
|
4
4
|
import Anthropic from '@anthropic-ai/sdk';
|
|
5
|
-
import '../index-
|
|
5
|
+
import '../index-cc2b17be.js';
|
|
6
6
|
import '../graphql/types/base/index.js';
|
|
7
7
|
import 'rxjs';
|
|
8
8
|
import '@copilotkit/shared';
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.5.1-next.
|
|
12
|
+
"version": "1.5.1-next.2",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"rxjs": "^7.8.1",
|
|
59
59
|
"type-graphql": "2.0.0-rc.1",
|
|
60
60
|
"zod": "^3.23.3",
|
|
61
|
-
"@copilotkit/shared": "1.5.1-next.
|
|
61
|
+
"@copilotkit/shared": "1.5.1-next.2"
|
|
62
62
|
},
|
|
63
63
|
"keywords": [
|
|
64
64
|
"copilotkit",
|
|
@@ -42,6 +42,8 @@ import {
|
|
|
42
42
|
} from "../types/converted";
|
|
43
43
|
import telemetry from "../../lib/telemetry-client";
|
|
44
44
|
import { randomId } from "@copilotkit/shared";
|
|
45
|
+
import { EndpointType, LangGraphPlatformAgent } from "../../lib/runtime/remote-actions";
|
|
46
|
+
import { AgentsResponse } from "../types/agents-response.type";
|
|
45
47
|
|
|
46
48
|
const invokeGuardrails = async ({
|
|
47
49
|
baseUrl,
|
|
@@ -106,6 +108,20 @@ export class CopilotResolver {
|
|
|
106
108
|
return "Hello World";
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
@Query(() => AgentsResponse)
|
|
112
|
+
async availableAgents(@Ctx() ctx: GraphQLContext) {
|
|
113
|
+
let logger = ctx.logger.child({ component: "CopilotResolver.availableAgents" });
|
|
114
|
+
|
|
115
|
+
logger.debug("Processing");
|
|
116
|
+
const agents = await ctx._copilotkit.runtime.discoverAgentsFromEndpoints(ctx);
|
|
117
|
+
|
|
118
|
+
logger.debug("Event source created, creating response");
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
agents,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
109
125
|
@Mutation(() => CopilotResponse)
|
|
110
126
|
async generateCopilotResponse(
|
|
111
127
|
@Ctx() ctx: GraphQLContext,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Field, InterfaceType, ObjectType } from "type-graphql";
|
|
2
|
+
import { MessageRole } from "./enums";
|
|
3
|
+
import { MessageStatusUnion } from "./message-status.type";
|
|
4
|
+
import { ResponseStatusUnion } from "./response-status.type";
|
|
5
|
+
|
|
6
|
+
@ObjectType()
|
|
7
|
+
export class Agent {
|
|
8
|
+
@Field(() => String)
|
|
9
|
+
id: string;
|
|
10
|
+
|
|
11
|
+
@Field(() => String)
|
|
12
|
+
name: string;
|
|
13
|
+
|
|
14
|
+
@Field(() => String)
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@ObjectType()
|
|
19
|
+
export class AgentsResponse {
|
|
20
|
+
@Field(() => [Agent])
|
|
21
|
+
agents: Agent[];
|
|
22
|
+
}
|
|
@@ -34,6 +34,8 @@ import { AgentSessionInput } from "../../graphql/inputs/agent-session.input";
|
|
|
34
34
|
import { from } from "rxjs";
|
|
35
35
|
import { AgentStateInput } from "../../graphql/inputs/agent-state.input";
|
|
36
36
|
import { ActionInputAvailability } from "../../graphql/types/enums";
|
|
37
|
+
import { createHeaders } from "./remote-action-constructors";
|
|
38
|
+
import { Agent } from "../../graphql/types/agents-response.type";
|
|
37
39
|
|
|
38
40
|
interface CopilotRuntimeRequest {
|
|
39
41
|
serviceAdapter: CopilotServiceAdapter;
|
|
@@ -253,6 +255,54 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
|
253
255
|
}
|
|
254
256
|
}
|
|
255
257
|
|
|
258
|
+
async discoverAgentsFromEndpoints(graphqlContext: GraphQLContext): Promise<Agent[]> {
|
|
259
|
+
const headers = createHeaders(null, graphqlContext);
|
|
260
|
+
const agents = this.remoteEndpointDefinitions.reduce(
|
|
261
|
+
async (acc: Promise<Agent[]>, endpoint) => {
|
|
262
|
+
const agents = await acc;
|
|
263
|
+
if (endpoint.type === EndpointType.LangGraphPlatform) {
|
|
264
|
+
const response = await fetch(
|
|
265
|
+
`${(endpoint as LangGraphPlatformEndpoint).deploymentUrl}/assistants/search`,
|
|
266
|
+
{
|
|
267
|
+
method: "POST",
|
|
268
|
+
headers,
|
|
269
|
+
},
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const data: Array<{ assistant_id: string; graph_id: string }> = await response.json();
|
|
273
|
+
const endpointAgents = (data ?? []).map((entry) => ({
|
|
274
|
+
name: entry.graph_id,
|
|
275
|
+
id: entry.assistant_id,
|
|
276
|
+
}));
|
|
277
|
+
return [...agents, ...endpointAgents];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
interface InfoResponse {
|
|
281
|
+
agents?: Array<{
|
|
282
|
+
name: string;
|
|
283
|
+
description: string;
|
|
284
|
+
}>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const response = await fetch(`${(endpoint as CopilotKitEndpoint).url}/info`, {
|
|
288
|
+
method: "POST",
|
|
289
|
+
headers,
|
|
290
|
+
body: JSON.stringify({ properties: graphqlContext.properties }),
|
|
291
|
+
});
|
|
292
|
+
const data: InfoResponse = await response.json();
|
|
293
|
+
const endpointAgents = (data?.agents ?? []).map((agent) => ({
|
|
294
|
+
name: agent.name,
|
|
295
|
+
description: agent.description,
|
|
296
|
+
id: randomId(), // Required by Agent type
|
|
297
|
+
}));
|
|
298
|
+
return [...agents, ...endpointAgents];
|
|
299
|
+
},
|
|
300
|
+
Promise.resolve([]),
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
return agents;
|
|
304
|
+
}
|
|
305
|
+
|
|
256
306
|
private async processAgentRequest(
|
|
257
307
|
request: CopilotRuntimeRequest,
|
|
258
308
|
): Promise<CopilotRuntimeResponse> {
|