@copilotkit/runtime 1.8.5-next.3 → 1.8.5-next.5

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 (41) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/{chunk-TDPCQIMB.mjs → chunk-AIQJ5N22.mjs} +2 -2
  3. package/dist/{chunk-UOCZJTXN.mjs → chunk-FP7EJSMU.mjs} +2 -2
  4. package/dist/{chunk-2PVUPC44.mjs → chunk-GQEDXH53.mjs} +2 -2
  5. package/dist/{chunk-UTUGZIQI.mjs → chunk-Q4KJZACA.mjs} +146 -9
  6. package/dist/chunk-Q4KJZACA.mjs.map +1 -0
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.js +183 -46
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +4 -4
  11. package/dist/lib/index.d.ts +2 -1
  12. package/dist/lib/index.js +176 -39
  13. package/dist/lib/index.js.map +1 -1
  14. package/dist/lib/index.mjs +4 -4
  15. package/dist/lib/integrations/index.d.ts +3 -2
  16. package/dist/lib/integrations/index.js +15 -10
  17. package/dist/lib/integrations/index.js.map +1 -1
  18. package/dist/lib/integrations/index.mjs +4 -4
  19. package/dist/lib/integrations/nest/index.d.ts +2 -1
  20. package/dist/lib/integrations/nest/index.js +15 -10
  21. package/dist/lib/integrations/nest/index.js.map +1 -1
  22. package/dist/lib/integrations/nest/index.mjs +2 -2
  23. package/dist/lib/integrations/node-express/index.d.ts +2 -1
  24. package/dist/lib/integrations/node-express/index.js +15 -10
  25. package/dist/lib/integrations/node-express/index.js.map +1 -1
  26. package/dist/lib/integrations/node-express/index.mjs +2 -2
  27. package/dist/lib/integrations/node-http/index.d.ts +2 -1
  28. package/dist/lib/integrations/node-http/index.js +15 -10
  29. package/dist/lib/integrations/node-http/index.js.map +1 -1
  30. package/dist/lib/integrations/node-http/index.mjs +1 -1
  31. package/dist/{shared-86ec42e7.d.ts → shared-93687488.d.ts} +3 -0
  32. package/package.json +6 -2
  33. package/src/lib/runtime/agentwire-action.ts +123 -0
  34. package/src/lib/runtime/copilot-runtime.ts +9 -1
  35. package/src/lib/runtime/remote-action-constructors.ts +2 -7
  36. package/src/lib/runtime/remote-actions.ts +25 -1
  37. package/src/lib/runtime/remote-lg-action.ts +24 -2
  38. package/dist/chunk-UTUGZIQI.mjs.map +0 -1
  39. /package/dist/{chunk-TDPCQIMB.mjs.map → chunk-AIQJ5N22.mjs.map} +0 -0
  40. /package/dist/{chunk-UOCZJTXN.mjs.map → chunk-FP7EJSMU.mjs.map} +0 -0
  41. /package/dist/{chunk-2PVUPC44.mjs.map → chunk-GQEDXH53.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.8.5-next.5
4
+
5
+ ### Patch Changes
6
+
7
+ - c0d3261: - full AWP support
8
+
9
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
10
+
11
+ - refactor: address linter issues with the new pages
12
+
13
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
14
+
15
+ - Merge branch 'mme/acp' into mme/mastra
16
+ - add sse example
17
+ - Create small-turkeys-agree.md
18
+ - upgrade AWP
19
+ - Merge branch 'mme/mastra' of github.com:CopilotKit/CopilotKit into mme/mastra
20
+ - make agents a dict
21
+ - update docs
22
+ - send tools
23
+ - update to latest packages
24
+ - fix problem where state sync are preventing tool calls
25
+ - set possibly undefined toolCalls to an empty array
26
+ - fix missing tool call ids
27
+
28
+ - c0d3261: - add AWP support
29
+
30
+ - make it work
31
+ - update docs
32
+ - refactor: move UI files to be normal NextJS pages and update generation
33
+
34
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
35
+
36
+ - refactor: address linter issues with the new pages
37
+
38
+ Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
39
+
40
+ - Merge branch 'mme/acp' into mme/mastra
41
+ - add sse example
42
+ - @copilotkit/shared@1.8.5-next.5
43
+
44
+ ## 1.8.5-next.4
45
+
46
+ ### Patch Changes
47
+
48
+ - 76d9ef9: - fix: handle langgraph client specific errors when running lgc stream
49
+ - @copilotkit/shared@1.8.5-next.4
50
+
3
51
  ## 1.8.5-next.3
4
52
 
5
53
  ### Patch Changes
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-UTUGZIQI.mjs";
5
+ } from "./chunk-Q4KJZACA.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNestEndpoint, "copilotRuntimeNestEndpoint");
22
22
  export {
23
23
  copilotRuntimeNestEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-TDPCQIMB.mjs.map
25
+ //# sourceMappingURL=chunk-AIQJ5N22.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-UTUGZIQI.mjs";
5
+ } from "./chunk-Q4KJZACA.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -77,4 +77,4 @@ export {
77
77
  config,
78
78
  copilotRuntimeNextJSPagesRouterEndpoint
79
79
  };
80
- //# sourceMappingURL=chunk-UOCZJTXN.mjs.map
80
+ //# sourceMappingURL=chunk-FP7EJSMU.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-UTUGZIQI.mjs";
5
+ } from "./chunk-Q4KJZACA.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-FHD4JECV.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
22
22
  export {
23
23
  copilotRuntimeNodeExpressEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-2PVUPC44.mjs.map
25
+ //# sourceMappingURL=chunk-GQEDXH53.mjs.map
@@ -39,7 +39,7 @@ var require_package = __commonJS({
39
39
  publishConfig: {
40
40
  access: "public"
41
41
  },
42
- version: "1.8.5-next.3",
42
+ version: "1.8.5-next.5",
43
43
  sideEffects: false,
44
44
  main: "./dist/index.js",
45
45
  module: "./dist/index.mjs",
@@ -76,6 +76,10 @@ var require_package = __commonJS({
76
76
  "zod-to-json-schema": "^3.23.5"
77
77
  },
78
78
  dependencies: {
79
+ "@agentwire/client": "0.0.26",
80
+ "@agentwire/proto": "0.0.26",
81
+ "@agentwire/core": "0.0.26",
82
+ "@agentwire/encoder": "0.0.26",
79
83
  "@anthropic-ai/sdk": "^0.27.3",
80
84
  "@copilotkit/shared": "workspace:*",
81
85
  "@graphql-yoga/plugin-defer-stream": "^3.3.1",
@@ -1410,6 +1414,9 @@ import { of, concat, scan as scan2, concatMap, ReplaySubject as ReplaySubject2,
1410
1414
  // src/lib/telemetry-client.ts
1411
1415
  import { TelemetryClient } from "@copilotkit/shared";
1412
1416
 
1417
+ // src/lib/runtime/remote-actions.ts
1418
+ import { CopilotKitErrorCode } from "@copilotkit/shared";
1419
+
1413
1420
  // src/lib/runtime/remote-action-constructors.ts
1414
1421
  import { createHash as createHash2 } from "crypto";
1415
1422
 
@@ -1687,7 +1694,7 @@ import { Client as LangGraphClient } from "@langchain/langgraph-sdk";
1687
1694
  import { createHash } from "crypto";
1688
1695
  import { isValidUUID, randomUUID } from "@copilotkit/shared";
1689
1696
  import { parse as parsePartialJson } from "partial-json";
1690
- import { parseJson } from "@copilotkit/shared";
1697
+ import { parseJson, CopilotKitMisuseError } from "@copilotkit/shared";
1691
1698
  import { RemoveMessage } from "@langchain/core/messages";
1692
1699
  var activeInterruptEvent = false;
1693
1700
  async function execute(args) {
@@ -1697,6 +1704,23 @@ async function execute(args) {
1697
1704
  await streamEvents(controller, args);
1698
1705
  controller.close();
1699
1706
  } catch (err) {
1707
+ const cause = err == null ? void 0 : err.cause;
1708
+ const errorCode = (cause == null ? void 0 : cause.code) || (err == null ? void 0 : err.code);
1709
+ if (errorCode === "ECONNREFUSED") {
1710
+ throw new CopilotKitMisuseError({
1711
+ message: `
1712
+ The LangGraph client could not connect to the graph. Please further check previous logs, which includes further details.
1713
+
1714
+ See more: https://docs.copilotkit.ai/troubleshooting/common-issues`
1715
+ });
1716
+ } else {
1717
+ throw new CopilotKitMisuseError({
1718
+ message: `
1719
+ The LangGraph client threw unhandled error ${err}.
1720
+
1721
+ See more: https://docs.copilotkit.ai/troubleshooting/common-issues`
1722
+ });
1723
+ }
1700
1724
  }
1701
1725
  }
1702
1726
  });
@@ -2562,6 +2586,100 @@ __name(createHeaders, "createHeaders");
2562
2586
 
2563
2587
  // src/lib/runtime/remote-actions.ts
2564
2588
  import { CopilotKitLowLevelError as CopilotKitLowLevelError2, ResolvedCopilotKitError as ResolvedCopilotKitError2, CopilotKitError as CopilotKitError2 } from "@copilotkit/shared";
2589
+
2590
+ // src/lib/runtime/agentwire-action.ts
2591
+ import { parseJson as parseJson3 } from "@copilotkit/shared";
2592
+ function constructAgentWireRemoteAction({ logger: logger2, messages, agentStates, agent }) {
2593
+ const action = {
2594
+ name: agent.agentId,
2595
+ description: agent.description,
2596
+ parameters: [],
2597
+ handler: async (_args) => {
2598
+ },
2599
+ remoteAgentHandler: async ({ actionInputsWithoutAgents, threadId }) => {
2600
+ logger2.debug({
2601
+ actionName: agent.agentId
2602
+ }, "Executing remote agent");
2603
+ const agentWireMessages = convertMessagesToAgentWire(messages);
2604
+ agent.messages = agentWireMessages;
2605
+ agent.threadId = threadId;
2606
+ telemetry_client_default.capture("oss.runtime.remote_action_executed", {
2607
+ agentExecution: true,
2608
+ type: "self-hosted",
2609
+ agentsAmount: 1
2610
+ });
2611
+ let state = {};
2612
+ if (agentStates) {
2613
+ const jsonState = agentStates.find((state2) => state2.agentName === agent.agentId);
2614
+ if (jsonState) {
2615
+ state = parseJson3(jsonState.state, {});
2616
+ }
2617
+ }
2618
+ agent.state = state;
2619
+ const tools = actionInputsWithoutAgents.map((input) => {
2620
+ return {
2621
+ name: input.name,
2622
+ description: input.description,
2623
+ parameters: JSON.parse(input.jsonSchema)
2624
+ };
2625
+ });
2626
+ return agent.legacy_to_be_removed_runAgentBridged({
2627
+ tools
2628
+ });
2629
+ }
2630
+ };
2631
+ return [
2632
+ action
2633
+ ];
2634
+ }
2635
+ __name(constructAgentWireRemoteAction, "constructAgentWireRemoteAction");
2636
+ function convertMessagesToAgentWire(messages) {
2637
+ const result = [];
2638
+ for (const message of messages) {
2639
+ if (message.isTextMessage()) {
2640
+ result.push({
2641
+ id: message.id,
2642
+ role: message.role,
2643
+ content: message.content
2644
+ });
2645
+ } else if (message.isActionExecutionMessage()) {
2646
+ const toolCall = {
2647
+ id: message.id,
2648
+ type: "function",
2649
+ function: {
2650
+ name: message.name,
2651
+ arguments: JSON.stringify(message.arguments)
2652
+ }
2653
+ };
2654
+ if (message.parentMessageId && result.some((m) => m.id === message.parentMessageId)) {
2655
+ const parentMessage = result.find((m) => m.id === message.parentMessageId);
2656
+ if (parentMessage.toolCalls === void 0) {
2657
+ parentMessage.toolCalls = [];
2658
+ }
2659
+ parentMessage.toolCalls.push(toolCall);
2660
+ } else {
2661
+ result.push({
2662
+ id: message.parentMessageId ?? message.id,
2663
+ role: "assistant",
2664
+ toolCalls: [
2665
+ toolCall
2666
+ ]
2667
+ });
2668
+ }
2669
+ } else if (message.isResultMessage()) {
2670
+ result.push({
2671
+ id: message.id,
2672
+ role: "tool",
2673
+ content: message.result,
2674
+ toolCallId: message.actionExecutionId
2675
+ });
2676
+ }
2677
+ }
2678
+ return result;
2679
+ }
2680
+ __name(convertMessagesToAgentWire, "convertMessagesToAgentWire");
2681
+
2682
+ // src/lib/runtime/remote-actions.ts
2565
2683
  var EndpointType;
2566
2684
  (function(EndpointType2) {
2567
2685
  EndpointType2["CopilotKit"] = "copilotKit";
@@ -2617,7 +2735,7 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
2617
2735
  }
2618
2736
  }
2619
2737
  __name(fetchRemoteInfo, "fetchRemoteInfo");
2620
- async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl }) {
2738
+ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, messages, agentStates, frontendUrl, agents }) {
2621
2739
  const logger2 = graphqlContext.logger.child({
2622
2740
  component: "remote-actions.fetchRemoteActions"
2623
2741
  });
@@ -2666,6 +2784,22 @@ async function setupRemoteActions({ remoteEndpointDefinitions, graphqlContext, m
2666
2784
  agentStates
2667
2785
  });
2668
2786
  }));
2787
+ for (const [key, agent] of Object.entries(agents)) {
2788
+ if (agent.agentId !== void 0 && agent.agentId !== key) {
2789
+ throw new CopilotKitError2({
2790
+ message: `Agent ${key} has agentId ${agent.agentId} which does not match the key ${key}`,
2791
+ code: CopilotKitErrorCode.UNKNOWN
2792
+ });
2793
+ } else if (agent.agentId === void 0) {
2794
+ agent.agentId = key;
2795
+ }
2796
+ result.push(constructAgentWireRemoteAction({
2797
+ logger: logger2,
2798
+ messages,
2799
+ agentStates,
2800
+ agent
2801
+ }));
2802
+ }
2669
2803
  return result.flat();
2670
2804
  }
2671
2805
  __name(setupRemoteActions, "setupRemoteActions");
@@ -2674,7 +2808,7 @@ __name(setupRemoteActions, "setupRemoteActions");
2674
2808
  import { createHash as createHash3 } from "crypto";
2675
2809
 
2676
2810
  // src/lib/runtime/copilot-runtime.ts
2677
- import { actionParametersToJsonSchema, ResolvedCopilotKitError as ResolvedCopilotKitError3, CopilotKitApiDiscoveryError as CopilotKitApiDiscoveryError2, randomId as randomId2, CopilotKitError as CopilotKitError3, CopilotKitLowLevelError as CopilotKitLowLevelError3, CopilotKitAgentDiscoveryError, CopilotKitMisuseError } from "@copilotkit/shared";
2811
+ import { actionParametersToJsonSchema, ResolvedCopilotKitError as ResolvedCopilotKitError3, CopilotKitApiDiscoveryError as CopilotKitApiDiscoveryError2, randomId as randomId2, CopilotKitError as CopilotKitError3, CopilotKitLowLevelError as CopilotKitLowLevelError3, CopilotKitAgentDiscoveryError, CopilotKitMisuseError as CopilotKitMisuseError2 } from "@copilotkit/shared";
2678
2812
 
2679
2813
  // src/service-adapters/conversion.ts
2680
2814
  import { plainToInstance } from "class-transformer";
@@ -2787,6 +2921,7 @@ __name(convertMCPToolsToActions, "convertMCPToolsToActions");
2787
2921
  // src/lib/runtime/copilot-runtime.ts
2788
2922
  var CopilotRuntime = class {
2789
2923
  actions;
2924
+ agents;
2790
2925
  remoteEndpointDefinitions;
2791
2926
  langserve = [];
2792
2927
  onBeforeRequest;
@@ -2817,10 +2952,11 @@ var CopilotRuntime = class {
2817
2952
  this.onAfterRequest = (_b = params == null ? void 0 : params.middleware) == null ? void 0 : _b.onAfterRequest;
2818
2953
  this.delegateAgentProcessingToServiceAdapter = (params == null ? void 0 : params.delegateAgentProcessingToServiceAdapter) || false;
2819
2954
  this.observability = params == null ? void 0 : params.observability_c;
2955
+ this.agents = (params == null ? void 0 : params.agents) ?? {};
2820
2956
  this.mcpEndpointsConfig = params == null ? void 0 : params.mcpEndpoints;
2821
2957
  this.createMCPClientImpl = params == null ? void 0 : params.createMCPClient;
2822
2958
  if (this.mcpEndpointsConfig && this.mcpEndpointsConfig.length > 0 && !this.createMCPClientImpl) {
2823
- throw new CopilotKitMisuseError({
2959
+ throw new CopilotKitMisuseError2({
2824
2960
  message: "MCP Integration Error: `mcpEndpoints` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`."
2825
2961
  });
2826
2962
  }
@@ -2881,7 +3017,7 @@ var CopilotRuntime = class {
2881
3017
  return await this.processAgentRequest(request);
2882
3018
  }
2883
3019
  if (serviceAdapter instanceof EmptyAdapter) {
2884
- throw new CopilotKitMisuseError({
3020
+ throw new CopilotKitMisuseError2({
2885
3021
  message: `Invalid adapter configuration: EmptyAdapter is only meant to be used with agent lock mode.
2886
3022
  For non-agent components like useCopilotChatSuggestions, CopilotTextarea, or CopilotTask,
2887
3023
  please use an LLM adapter instead.`
@@ -3071,7 +3207,7 @@ please use an LLM adapter instead.`
3071
3207
  });
3072
3208
  }
3073
3209
  } catch (e) {
3074
- throw new CopilotKitMisuseError({
3210
+ throw new CopilotKitMisuseError2({
3075
3211
  message: `
3076
3212
  Failed to find or contact remote endpoint at url ${endpoint.deploymentUrl}.
3077
3213
  Make sure the API is running and that it's indeed a LangGraph platform url.
@@ -3438,7 +3574,8 @@ please use an LLM adapter instead.`
3438
3574
  graphqlContext,
3439
3575
  messages: inputMessages,
3440
3576
  agentStates,
3441
- frontendUrl: url
3577
+ frontendUrl: url,
3578
+ agents: this.agents
3442
3579
  });
3443
3580
  const configuredActions = typeof this.actions === "function" ? this.actions({
3444
3581
  properties: graphqlContext.properties,
@@ -4757,4 +4894,4 @@ export {
4757
4894
  getCommonConfig,
4758
4895
  copilotRuntimeNodeHttpEndpoint
4759
4896
  };
4760
- //# sourceMappingURL=chunk-UTUGZIQI.mjs.map
4897
+ //# sourceMappingURL=chunk-Q4KJZACA.mjs.map