@copilotkit/runtime 1.5.18-next.1 → 1.5.18-next.3

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 (32) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{chunk-2NWLEHMA.mjs → chunk-JTTO2AKP.mjs} +70 -24
  3. package/dist/chunk-JTTO2AKP.mjs.map +1 -0
  4. package/dist/{chunk-CJZ7QUXU.mjs → chunk-SHQLPOL4.mjs} +2 -2
  5. package/dist/{chunk-OS4N57XE.mjs → chunk-THWPPRSF.mjs} +2 -2
  6. package/dist/{chunk-326WWZNE.mjs → chunk-V2PWHEPG.mjs} +2 -2
  7. package/dist/index.js +89 -43
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4 -4
  10. package/dist/lib/index.js +89 -43
  11. package/dist/lib/index.js.map +1 -1
  12. package/dist/lib/index.mjs +4 -4
  13. package/dist/lib/integrations/index.js +1 -1
  14. package/dist/lib/integrations/index.js.map +1 -1
  15. package/dist/lib/integrations/index.mjs +4 -4
  16. package/dist/lib/integrations/nest/index.js +1 -1
  17. package/dist/lib/integrations/nest/index.js.map +1 -1
  18. package/dist/lib/integrations/nest/index.mjs +2 -2
  19. package/dist/lib/integrations/node-express/index.js +1 -1
  20. package/dist/lib/integrations/node-express/index.js.map +1 -1
  21. package/dist/lib/integrations/node-express/index.mjs +2 -2
  22. package/dist/lib/integrations/node-http/index.js +1 -1
  23. package/dist/lib/integrations/node-http/index.js.map +1 -1
  24. package/dist/lib/integrations/node-http/index.mjs +1 -1
  25. package/package.json +2 -2
  26. package/src/lib/runtime/copilot-runtime.ts +33 -13
  27. package/src/lib/runtime/remote-action-constructors.ts +17 -2
  28. package/src/lib/runtime/remote-actions.ts +5 -1
  29. package/dist/chunk-2NWLEHMA.mjs.map +0 -1
  30. /package/dist/{chunk-CJZ7QUXU.mjs.map → chunk-SHQLPOL4.mjs.map} +0 -0
  31. /package/dist/{chunk-OS4N57XE.mjs.map → chunk-THWPPRSF.mjs.map} +0 -0
  32. /package/dist/{chunk-326WWZNE.mjs.map → chunk-V2PWHEPG.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.5.18-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f77a7b9]
8
+ - @copilotkit/shared@1.5.18-next.3
9
+
10
+ ## 1.5.18-next.2
11
+
12
+ ### Patch Changes
13
+
14
+ - 38d3ac2: - fix: add additional info the our error messages
15
+ - Updated dependencies [38d3ac2]
16
+ - @copilotkit/shared@1.5.18-next.2
17
+
3
18
  ## 1.5.18-next.1
4
19
 
5
20
  ### Patch Changes
@@ -39,7 +39,7 @@ var require_package = __commonJS({
39
39
  publishConfig: {
40
40
  access: "public"
41
41
  },
42
- version: "1.5.18-next.1",
42
+ version: "1.5.18-next.3",
43
43
  sideEffects: false,
44
44
  main: "./dist/index.js",
45
45
  module: "./dist/index.mjs",
@@ -2191,6 +2191,7 @@ __name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
2191
2191
 
2192
2192
  // src/lib/runtime/remote-action-constructors.ts
2193
2193
  import { CopilotKitError, CopilotKitLowLevelError } from "@copilotkit/shared";
2194
+ import { CopilotKitApiDiscoveryError, ResolvedCopilotKitError } from "@copilotkit/shared";
2194
2195
  function constructLGCRemoteAction({ endpoint, graphqlContext, logger: logger2, messages, agentStates }) {
2195
2196
  const agents = endpoint.agents.map((agent) => ({
2196
2197
  name: agent.name,
@@ -2291,7 +2292,16 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2291
2292
  status: response.status,
2292
2293
  body: await response.text()
2293
2294
  }, "Failed to execute remote action");
2294
- return "Failed to execute remote action";
2295
+ if (response.status === 404) {
2296
+ throw new CopilotKitApiDiscoveryError({
2297
+ url: fetchUrl
2298
+ });
2299
+ }
2300
+ throw new ResolvedCopilotKitError({
2301
+ status: response.status,
2302
+ url: fetchUrl,
2303
+ isRemoteEndpoint: true
2304
+ });
2295
2305
  }
2296
2306
  const requestResult = await response.json();
2297
2307
  const result = requestResult["result"];
@@ -2364,7 +2374,16 @@ function constructRemoteActions({ json, url, onBeforeRequest, graphqlContext, lo
2364
2374
  status: response.status,
2365
2375
  body: await response.text()
2366
2376
  }, "Failed to execute remote agent");
2367
- throw new Error("Failed to execute remote agent");
2377
+ if (response.status === 404) {
2378
+ throw new CopilotKitApiDiscoveryError({
2379
+ url: fetchUrl
2380
+ });
2381
+ }
2382
+ throw new ResolvedCopilotKitError({
2383
+ status: response.status,
2384
+ url: fetchUrl,
2385
+ isRemoteEndpoint: true
2386
+ });
2368
2387
  }
2369
2388
  const eventSource = new RemoteLangGraphEventSource();
2370
2389
  streamResponse(response.body, eventSource.eventStream$);
@@ -2447,7 +2466,7 @@ function createHeaders(onBeforeRequest, graphqlContext) {
2447
2466
  __name(createHeaders, "createHeaders");
2448
2467
 
2449
2468
  // src/lib/runtime/remote-actions.ts
2450
- import { CopilotKitLowLevelError as CopilotKitLowLevelError2, ResolvedCopilotKitError, CopilotKitError as CopilotKitError2 } from "@copilotkit/shared";
2469
+ import { CopilotKitLowLevelError as CopilotKitLowLevelError2, ResolvedCopilotKitError as ResolvedCopilotKitError2, CopilotKitError as CopilotKitError2 } from "@copilotkit/shared";
2451
2470
  var EndpointType;
2452
2471
  (function(EndpointType2) {
2453
2472
  EndpointType2["CopilotKit"] = "copilotKit";
@@ -2481,8 +2500,9 @@ async function fetchRemoteInfo({ url, onBeforeRequest, graphqlContext, logger: l
2481
2500
  status: response.status,
2482
2501
  body: await response.text()
2483
2502
  }, "Failed to fetch actions from url");
2484
- throw new ResolvedCopilotKitError({
2503
+ throw new ResolvedCopilotKitError2({
2485
2504
  status: response.status,
2505
+ url: fetchUrl,
2486
2506
  isRemoteEndpoint: true
2487
2507
  });
2488
2508
  }
@@ -2559,7 +2579,7 @@ __name(setupRemoteActions, "setupRemoteActions");
2559
2579
  import { createHash as createHash3 } from "crypto";
2560
2580
 
2561
2581
  // src/lib/runtime/copilot-runtime.ts
2562
- import { actionParametersToJsonSchema, ResolvedCopilotKitError as ResolvedCopilotKitError2, CopilotKitApiDiscoveryError, randomId as randomId2, CopilotKitError as CopilotKitError3, CopilotKitLowLevelError as CopilotKitLowLevelError3, CopilotKitAgentDiscoveryError, CopilotKitMisuseError } from "@copilotkit/shared";
2582
+ import { actionParametersToJsonSchema, ResolvedCopilotKitError as ResolvedCopilotKitError3, CopilotKitApiDiscoveryError as CopilotKitApiDiscoveryError2, randomId as randomId2, CopilotKitError as CopilotKitError3, CopilotKitLowLevelError as CopilotKitLowLevelError3, CopilotKitAgentDiscoveryError, CopilotKitMisuseError } from "@copilotkit/shared";
2563
2583
 
2564
2584
  // src/service-adapters/conversion.ts
2565
2585
  import { plainToInstance } from "class-transformer";
@@ -2750,10 +2770,13 @@ please use an LLM adapter instead.`
2750
2770
  });
2751
2771
  if (!response.ok) {
2752
2772
  if (response.status === 404) {
2753
- throw new CopilotKitApiDiscoveryError();
2773
+ throw new CopilotKitApiDiscoveryError2({
2774
+ url: fetchUrl
2775
+ });
2754
2776
  }
2755
- throw new ResolvedCopilotKitError2({
2777
+ throw new ResolvedCopilotKitError3({
2756
2778
  status: response.status,
2779
+ url: fetchUrl,
2757
2780
  isRemoteEndpoint: true
2758
2781
  });
2759
2782
  }
@@ -2821,21 +2844,44 @@ please use an LLM adapter instead.`
2821
2844
  };
2822
2845
  }
2823
2846
  } else if (agentWithEndpoint.endpoint.type === EndpointType.CopilotKit || !("type" in agentWithEndpoint.endpoint)) {
2824
- const response = await fetch(`${agentWithEndpoint.endpoint.url}/agents/state`, {
2825
- method: "POST",
2826
- headers,
2827
- body: JSON.stringify({
2828
- properties: graphqlContext.properties,
2829
- threadId,
2830
- name: agentName
2831
- })
2832
- });
2833
- const data = await response.json();
2834
- return {
2835
- ...data,
2836
- state: JSON.stringify(data.state),
2837
- messages: JSON.stringify(data.messages)
2838
- };
2847
+ const fetchUrl = `${agentWithEndpoint.endpoint.url}/agents/state`;
2848
+ try {
2849
+ const response = await fetch(fetchUrl, {
2850
+ method: "POST",
2851
+ headers,
2852
+ body: JSON.stringify({
2853
+ properties: graphqlContext.properties,
2854
+ threadId,
2855
+ name: agentName
2856
+ })
2857
+ });
2858
+ if (!response.ok) {
2859
+ if (response.status === 404) {
2860
+ throw new CopilotKitApiDiscoveryError2({
2861
+ url: fetchUrl
2862
+ });
2863
+ }
2864
+ throw new ResolvedCopilotKitError3({
2865
+ status: response.status,
2866
+ url: fetchUrl,
2867
+ isRemoteEndpoint: true
2868
+ });
2869
+ }
2870
+ const data = await response.json();
2871
+ return {
2872
+ ...data,
2873
+ state: JSON.stringify(data.state),
2874
+ messages: JSON.stringify(data.messages)
2875
+ };
2876
+ } catch (error) {
2877
+ if (error instanceof CopilotKitError3) {
2878
+ throw error;
2879
+ }
2880
+ throw new CopilotKitLowLevelError3({
2881
+ error,
2882
+ url: fetchUrl
2883
+ });
2884
+ }
2839
2885
  } else {
2840
2886
  throw new Error(`Unknown endpoint type: ${agentWithEndpoint.endpoint.type}`);
2841
2887
  }
@@ -4198,4 +4244,4 @@ export {
4198
4244
  getCommonConfig,
4199
4245
  copilotRuntimeNodeHttpEndpoint
4200
4246
  };
4201
- //# sourceMappingURL=chunk-2NWLEHMA.mjs.map
4247
+ //# sourceMappingURL=chunk-JTTO2AKP.mjs.map