@copilotkit/runtime 1.4.2 → 1.4.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 (30) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{chunk-NGIMUY3P.mjs → chunk-7SECLS5W.mjs} +2 -2
  3. package/dist/{chunk-5OSRXQBR.mjs → chunk-KO6WITMC.mjs} +18 -10
  4. package/dist/chunk-KO6WITMC.mjs.map +1 -0
  5. package/dist/{chunk-P37XVLVE.mjs → chunk-PF5ZEXF5.mjs} +2 -2
  6. package/dist/{chunk-P2G5TCZA.mjs → chunk-YJZFFI54.mjs} +2 -2
  7. package/dist/index.js +17 -9
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4 -4
  10. package/dist/lib/index.js +17 -9
  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 +4 -4
  26. package/src/lib/runtime/remote-lg-action.ts +25 -14
  27. package/dist/chunk-5OSRXQBR.mjs.map +0 -1
  28. /package/dist/{chunk-NGIMUY3P.mjs.map → chunk-7SECLS5W.mjs.map} +0 -0
  29. /package/dist/{chunk-P37XVLVE.mjs.map → chunk-PF5ZEXF5.mjs.map} +0 -0
  30. /package/dist/{chunk-P2G5TCZA.mjs.map → chunk-YJZFFI54.mjs.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-5OSRXQBR.mjs";
5
+ } from "./chunk-KO6WITMC.mjs";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-44O2JGUY.mjs";
@@ -22,4 +22,4 @@ __name(copilotRuntimeNodeExpressEndpoint, "copilotRuntimeNodeExpressEndpoint");
22
22
  export {
23
23
  copilotRuntimeNodeExpressEndpoint
24
24
  };
25
- //# sourceMappingURL=chunk-P37XVLVE.mjs.map
25
+ //# sourceMappingURL=chunk-PF5ZEXF5.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-5OSRXQBR.mjs";
5
+ } from "./chunk-KO6WITMC.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-P2G5TCZA.mjs.map
80
+ //# sourceMappingURL=chunk-YJZFFI54.mjs.map
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.4.2",
47
+ version: "1.4.3",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -1634,8 +1634,6 @@ async function streamEvents(controller, args) {
1634
1634
  if (initialThreadId && initialThreadId.startsWith("ck-")) {
1635
1635
  initialThreadId = initialThreadId.substring(3);
1636
1636
  }
1637
- const assistants = await client.assistants.search();
1638
- const retrievedAssistant = assistants.find((a) => a.name === name);
1639
1637
  const threadId = initialThreadId ?? (0, import_node_crypto.randomUUID)();
1640
1638
  if (initialThreadId === threadId) {
1641
1639
  await client.threads.get(threadId);
@@ -1666,8 +1664,16 @@ async function streamEvents(controller, args) {
1666
1664
  asNode: nodeName
1667
1665
  });
1668
1666
  }
1669
- const assistantId = initialAssistantId ?? (retrievedAssistant == null ? void 0 : retrievedAssistant.assistant_id);
1670
- if (!assistantId) {
1667
+ let streamInfo = {
1668
+ hashedLgcKey: (0, import_node_crypto.createHash)("sha256").update(langsmithApiKey).digest("hex")
1669
+ };
1670
+ const assistants = await client.assistants.search();
1671
+ const retrievedAssistant = assistants.find((a) => a.name === name || a.assistant_id === initialAssistantId);
1672
+ if (!retrievedAssistant) {
1673
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
1674
+ ...streamInfo,
1675
+ error: `Found no assistants for given information, while ${assistants.length} assistants exists`
1676
+ });
1671
1677
  console.error(`
1672
1678
  No agent found for the agent name specified in CopilotKit provider
1673
1679
  Please check your available agents or provide an agent ID in the LangGraph Platform endpoint definition.
@@ -1677,6 +1683,7 @@ async function streamEvents(controller, args) {
1677
1683
  `);
1678
1684
  throw new Error("No agent id found");
1679
1685
  }
1686
+ const assistantId = retrievedAssistant.assistant_id;
1680
1687
  const graphInfo = await client.assistants.getGraph(assistantId);
1681
1688
  const streamInput = mode === "start" ? state : null;
1682
1689
  let streamingStateExtractor = new StreamingStateExtractor([]);
@@ -1695,9 +1702,6 @@ async function streamEvents(controller, args) {
1695
1702
  let latestStateValues = {};
1696
1703
  let updatedState = state;
1697
1704
  let manuallyEmittedState = null;
1698
- let streamInfo = {
1699
- hashedLgcKey: (0, import_node_crypto.createHash)("sha256").update(langsmithApiKey).digest("hex")
1700
- };
1701
1705
  try {
1702
1706
  telemetry_client_default.capture("oss.runtime.agent_execution_stream_started", {
1703
1707
  hashedLgcKey: streamInfo.hashedLgcKey
@@ -1710,7 +1714,6 @@ async function streamEvents(controller, args) {
1710
1714
  ].includes(chunk.event))
1711
1715
  continue;
1712
1716
  if (chunk.event === "error") {
1713
- logger2.error(chunk, `Error event thrown: ${chunk.data.message}`);
1714
1717
  throw new Error(`Error event thrown: ${chunk.data.message}`);
1715
1718
  }
1716
1719
  if (chunk.event === "values") {
@@ -1807,6 +1810,11 @@ async function streamEvents(controller, args) {
1807
1810
  }));
1808
1811
  return Promise.resolve();
1809
1812
  } catch (e) {
1813
+ logger2.error(e);
1814
+ telemetry_client_default.capture("oss.runtime.agent_execution_stream_errored", {
1815
+ ...streamInfo,
1816
+ error: e.message
1817
+ });
1810
1818
  return Promise.resolve();
1811
1819
  }
1812
1820
  }