@copilotkit/runtime 1.6.0-next.7 → 1.6.0-next.9

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 +18 -0
  2. package/dist/{chunk-LVJSZOFH.mjs → chunk-4HQ5OZXN.mjs} +2 -2
  3. package/dist/{chunk-LTUE24TH.mjs → chunk-5ZBUMQE2.mjs} +2 -2
  4. package/dist/{chunk-DV4VS5ER.mjs → chunk-7BCFHZLY.mjs} +2 -2
  5. package/dist/{chunk-SAHKR6PK.mjs → chunk-L7OTGCAG.mjs} +46 -12
  6. package/dist/chunk-L7OTGCAG.mjs.map +1 -0
  7. package/dist/index.js +45 -11
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4 -4
  10. package/dist/lib/index.js +45 -11
  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/agents/langgraph/event-source.ts +13 -4
  27. package/src/lib/runtime/copilot-runtime.ts +1 -1
  28. package/src/lib/runtime/remote-lg-action.ts +33 -1
  29. package/dist/chunk-SAHKR6PK.mjs.map +0 -1
  30. /package/dist/{chunk-LVJSZOFH.mjs.map → chunk-4HQ5OZXN.mjs.map} +0 -0
  31. /package/dist/{chunk-LTUE24TH.mjs.map → chunk-5ZBUMQE2.mjs.map} +0 -0
  32. /package/dist/{chunk-DV4VS5ER.mjs.map → chunk-7BCFHZLY.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.6.0-next.9
4
+
5
+ ### Patch Changes
6
+
7
+ - d07f49c: - fix(runtime): fix execution of runtime set backend action handlers
8
+ - @copilotkit/shared@1.6.0-next.9
9
+
10
+ ## 1.6.0-next.8
11
+
12
+ ### Minor Changes
13
+
14
+ - fea916f: - feat: support input and output schema of langgraph
15
+ - docs: add input output schema docs
16
+
17
+ ### Patch Changes
18
+
19
+ - @copilotkit/shared@1.6.0-next.8
20
+
3
21
  ## 1.6.0-next.7
4
22
 
5
23
  ### Patch Changes
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-SAHKR6PK.mjs";
5
+ } from "./chunk-L7OTGCAG.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-LVJSZOFH.mjs.map
25
+ //# sourceMappingURL=chunk-4HQ5OZXN.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  copilotRuntimeNodeHttpEndpoint,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-SAHKR6PK.mjs";
5
+ } from "./chunk-L7OTGCAG.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-LTUE24TH.mjs.map
25
+ //# sourceMappingURL=chunk-5ZBUMQE2.mjs.map
@@ -2,7 +2,7 @@ import {
2
2
  getCommonConfig,
3
3
  getRuntimeInstanceTelemetryInfo,
4
4
  telemetry_client_default
5
- } from "./chunk-SAHKR6PK.mjs";
5
+ } from "./chunk-L7OTGCAG.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-DV4VS5ER.mjs.map
80
+ //# sourceMappingURL=chunk-7BCFHZLY.mjs.map
@@ -39,7 +39,7 @@ var require_package = __commonJS({
39
39
  publishConfig: {
40
40
  access: "public"
41
41
  },
42
- version: "1.6.0-next.7",
42
+ version: "1.6.0-next.9",
43
43
  sideEffects: false,
44
44
  main: "./dist/index.js",
45
45
  module: "./dist/index.mjs",
@@ -1499,10 +1499,15 @@ var RemoteLangGraphEventSource = class {
1499
1499
  acc.lastMessageId = this.getCurrentMessageId(event) ?? acc.lastMessageId;
1500
1500
  const toolCallChunks = this.getCurrentToolCallChunks(event) ?? [];
1501
1501
  const responseMetadata = this.getResponseMetadata(event);
1502
+ const toolCallCheck = toolCallChunks && toolCallChunks.length > 0;
1503
+ let isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
1502
1504
  acc.isToolCallStart = toolCallChunks.some((chunk) => chunk.name && chunk.id);
1503
1505
  acc.isMessageStart = prevMessageId !== acc.lastMessageId && !acc.isToolCallStart;
1504
- acc.isToolCall = toolCallChunks && toolCallChunks.length > 0;
1505
- acc.isToolCallEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls";
1506
+ if (acc.isToolCall && !toolCallCheck) {
1507
+ isToolCallEnd = true;
1508
+ }
1509
+ acc.isToolCall = toolCallCheck;
1510
+ acc.isToolCallEnd = isToolCallEnd;
1506
1511
  acc.isMessageEnd = (responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop";
1507
1512
  ({ name: acc.lastToolCallName, id: acc.lastToolCallId } = toolCallChunks.find((chunk) => chunk.name && chunk.id) ?? {
1508
1513
  name: acc.lastToolCallName,
@@ -1550,13 +1555,12 @@ var RemoteLangGraphEventSource = class {
1550
1555
  });
1551
1556
  }
1552
1557
  const responseMetadata = this.getResponseMetadata(acc.event);
1553
- if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "tool_calls" && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
1558
+ if (acc.isToolCallEnd && this.shouldEmitToolCall(shouldEmitToolCalls, acc.lastToolCallName)) {
1554
1559
  events.push({
1555
1560
  type: RuntimeEventTypes.ActionExecutionEnd,
1556
1561
  actionExecutionId: acc.lastToolCallId
1557
1562
  });
1558
- }
1559
- if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
1563
+ } else if ((responseMetadata == null ? void 0 : responseMetadata.finish_reason) === "stop" && shouldEmitMessages) {
1560
1564
  events.push({
1561
1565
  type: RuntimeEventTypes.TextMessageEnd,
1562
1566
  messageId: acc.lastMessageId
@@ -1797,6 +1801,11 @@ async function streamEvents(controller, args) {
1797
1801
  });
1798
1802
  }
1799
1803
  const graphInfo = await client.assistants.getGraph(assistantId);
1804
+ const graphSchema = await client.assistants.getSchemas(assistantId);
1805
+ const schemaKeys = getSchemaKeys(graphSchema);
1806
+ if (payload.input && schemaKeys.input) {
1807
+ payload.input = Object.fromEntries(Object.entries(payload.input).filter(([key]) => schemaKeys.input.includes(key)));
1808
+ }
1800
1809
  let streamingStateExtractor = new StreamingStateExtractor([]);
1801
1810
  let prevNodeName = null;
1802
1811
  let emitIntermediateStateUntilEnd = null;
@@ -1888,7 +1897,8 @@ async function streamEvents(controller, args) {
1888
1897
  nodeName,
1889
1898
  state: manuallyEmittedState,
1890
1899
  running: true,
1891
- active: true
1900
+ active: true,
1901
+ schemaKeys
1892
1902
  }));
1893
1903
  continue;
1894
1904
  }
@@ -1920,7 +1930,8 @@ async function streamEvents(controller, args) {
1920
1930
  nodeName,
1921
1931
  state,
1922
1932
  running: true,
1923
- active: !exitingNode
1933
+ active: !exitingNode,
1934
+ schemaKeys
1924
1935
  }));
1925
1936
  }
1926
1937
  emit(JSON.stringify(event) + "\n");
@@ -1938,7 +1949,8 @@ async function streamEvents(controller, args) {
1938
1949
  state: state.values,
1939
1950
  running: !shouldExit,
1940
1951
  active: false,
1941
- includeMessages: true
1952
+ includeMessages: true,
1953
+ schemaKeys
1942
1954
  }));
1943
1955
  return Promise.resolve();
1944
1956
  } catch (e) {
@@ -1951,7 +1963,7 @@ async function streamEvents(controller, args) {
1951
1963
  }
1952
1964
  }
1953
1965
  __name(streamEvents, "streamEvents");
1954
- function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false }) {
1966
+ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false, schemaKeys }) {
1955
1967
  if (!includeMessages) {
1956
1968
  state = Object.keys(state).reduce((acc, key) => {
1957
1969
  if (key !== "messages") {
@@ -1965,6 +1977,9 @@ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, runnin
1965
1977
  messages: langchainMessagesToCopilotKit(state.messages || [])
1966
1978
  };
1967
1979
  }
1980
+ if (schemaKeys.output) {
1981
+ state = Object.fromEntries(Object.entries(state).filter(([key]) => schemaKeys.output.includes(key)));
1982
+ }
1968
1983
  return JSON.stringify({
1969
1984
  event: LangGraphEventTypes.OnCopilotKitStateSync,
1970
1985
  thread_id: threadId,
@@ -2199,6 +2214,25 @@ function copilotkitMessagesToLangChain(messages) {
2199
2214
  return result;
2200
2215
  }
2201
2216
  __name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
2217
+ function getSchemaKeys(graphSchema) {
2218
+ const CONSTANT_KEYS = [
2219
+ "messages",
2220
+ "copilotkit"
2221
+ ];
2222
+ const inputSchema = Object.keys(graphSchema.input_schema.properties);
2223
+ const outputSchema = Object.keys(graphSchema.output_schema.properties);
2224
+ return {
2225
+ input: inputSchema && inputSchema.length ? [
2226
+ ...inputSchema,
2227
+ ...CONSTANT_KEYS
2228
+ ] : null,
2229
+ output: outputSchema && outputSchema.length ? [
2230
+ ...outputSchema,
2231
+ ...CONSTANT_KEYS
2232
+ ] : null
2233
+ };
2234
+ }
2235
+ __name(getSchemaKeys, "getSchemaKeys");
2202
2236
 
2203
2237
  // src/lib/runtime/remote-action-constructors.ts
2204
2238
  import { CopilotKitError, CopilotKitLowLevelError } from "@copilotkit/shared";
@@ -2971,7 +3005,7 @@ please use an LLM adapter instead.`
2971
3005
  threadId,
2972
3006
  runId: void 0,
2973
3007
  eventSource,
2974
- serverSideActions: [],
3008
+ serverSideActions,
2975
3009
  actionInputsWithoutAgents: allAvailableActions
2976
3010
  };
2977
3011
  } catch (error) {
@@ -4262,4 +4296,4 @@ export {
4262
4296
  getCommonConfig,
4263
4297
  copilotRuntimeNodeHttpEndpoint
4264
4298
  };
4265
- //# sourceMappingURL=chunk-SAHKR6PK.mjs.map
4299
+ //# sourceMappingURL=chunk-L7OTGCAG.mjs.map