@copilotkit/runtime 1.5.1-next.1 → 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.
Files changed (45) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/__snapshots__/schema/schema.graphql +11 -0
  3. package/dist/{chunk-L4VT7Z25.mjs → chunk-2FY7EQEE.mjs} +2 -2
  4. package/dist/{chunk-6N4ZHRRC.mjs → chunk-2V7BHSFE.mjs} +134 -20
  5. package/dist/chunk-2V7BHSFE.mjs.map +1 -0
  6. package/dist/{chunk-G2PTXSIW.mjs → chunk-2ZPE55QG.mjs} +2 -2
  7. package/dist/{chunk-Z3MD5FQ4.mjs → chunk-W6E7AVR7.mjs} +2 -2
  8. package/dist/{copilot-runtime-6285d897.d.ts → copilot-runtime-36700e00.d.ts} +9 -2
  9. package/dist/graphql/types/converted/index.d.ts +1 -1
  10. package/dist/{groq-adapter-15d41154.d.ts → groq-adapter-696b5d29.d.ts} +1 -1
  11. package/dist/{index-ff3fbc33.d.ts → index-cc2b17be.d.ts} +1 -1
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +133 -19
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +4 -4
  16. package/dist/{langserve-48e976ac.d.ts → langserve-9125a12e.d.ts} +1 -1
  17. package/dist/lib/index.d.ts +4 -4
  18. package/dist/lib/index.js +133 -19
  19. package/dist/lib/index.js.map +1 -1
  20. package/dist/lib/index.mjs +4 -4
  21. package/dist/lib/integrations/index.d.ts +4 -4
  22. package/dist/lib/integrations/index.js +94 -19
  23. package/dist/lib/integrations/index.js.map +1 -1
  24. package/dist/lib/integrations/index.mjs +4 -4
  25. package/dist/lib/integrations/nest/index.d.ts +3 -3
  26. package/dist/lib/integrations/nest/index.js +94 -19
  27. package/dist/lib/integrations/nest/index.js.map +1 -1
  28. package/dist/lib/integrations/nest/index.mjs +2 -2
  29. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  30. package/dist/lib/integrations/node-express/index.js +94 -19
  31. package/dist/lib/integrations/node-express/index.js.map +1 -1
  32. package/dist/lib/integrations/node-express/index.mjs +2 -2
  33. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  34. package/dist/lib/integrations/node-http/index.js +94 -19
  35. package/dist/lib/integrations/node-http/index.js.map +1 -1
  36. package/dist/lib/integrations/node-http/index.mjs +1 -1
  37. package/dist/service-adapters/index.d.ts +4 -4
  38. package/package.json +4 -4
  39. package/src/graphql/resolvers/copilot.resolver.ts +16 -0
  40. package/src/graphql/types/agents-response.type.ts +22 -0
  41. package/src/lib/runtime/copilot-runtime.ts +50 -0
  42. package/dist/chunk-6N4ZHRRC.mjs.map +0 -1
  43. /package/dist/{chunk-L4VT7Z25.mjs.map → chunk-2FY7EQEE.mjs.map} +0 -0
  44. /package/dist/{chunk-G2PTXSIW.mjs.map → chunk-2ZPE55QG.mjs.map} +0 -0
  45. /package/dist/{chunk-Z3MD5FQ4.mjs.map → chunk-W6E7AVR7.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  copilotRuntimeNodeHttpEndpoint
3
- } from "../../../chunk-6N4ZHRRC.mjs";
3
+ } from "../../../chunk-2V7BHSFE.mjs";
4
4
  import "../../../chunk-CLGKEUOA.mjs";
5
5
  import "../../../chunk-U3V2BCGI.mjs";
6
6
  import "../../../chunk-RFF5IIZJ.mjs";
@@ -1,8 +1,8 @@
1
- import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-48e976ac.js';
2
- export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-48e976ac.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-15d41154.js';
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-ff3fbc33.js';
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.1",
12
+ "version": "1.5.1-next.2",
13
13
  "sideEffects": false,
14
14
  "main": "./dist/index.js",
15
15
  "module": "./dist/index.mjs",
@@ -32,8 +32,8 @@
32
32
  "tsup": "^6.7.0",
33
33
  "typescript": "^5.2.3",
34
34
  "zod-to-json-schema": "^3.23.5",
35
- "tsconfig": "1.4.6",
36
- "eslint-config-custom": "1.4.6"
35
+ "eslint-config-custom": "1.4.6",
36
+ "tsconfig": "1.4.6"
37
37
  },
38
38
  "dependencies": {
39
39
  "@anthropic-ai/sdk": "^0.27.3",
@@ -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.1"
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> {