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

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 +11 -0
  2. package/dist/{chunk-SAHKR6PK.mjs → chunk-C7VKUXWC.mjs} +36 -6
  3. package/dist/chunk-C7VKUXWC.mjs.map +1 -0
  4. package/dist/{chunk-LVJSZOFH.mjs → chunk-CC5KHDCV.mjs} +2 -2
  5. package/dist/{chunk-DV4VS5ER.mjs → chunk-DI2VJM3I.mjs} +2 -2
  6. package/dist/{chunk-LTUE24TH.mjs → chunk-LR7HA4X5.mjs} +2 -2
  7. package/dist/index.js +35 -5
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4 -4
  10. package/dist/lib/index.js +35 -5
  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/remote-lg-action.ts +33 -1
  27. package/dist/chunk-SAHKR6PK.mjs.map +0 -1
  28. /package/dist/{chunk-LVJSZOFH.mjs.map → chunk-CC5KHDCV.mjs.map} +0 -0
  29. /package/dist/{chunk-DV4VS5ER.mjs.map → chunk-DI2VJM3I.mjs.map} +0 -0
  30. /package/dist/{chunk-LTUE24TH.mjs.map → chunk-LR7HA4X5.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @copilotkit/runtime
2
2
 
3
+ ## 1.6.0-next.8
4
+
5
+ ### Minor Changes
6
+
7
+ - fea916f: - feat: support input and output schema of langgraph
8
+ - docs: add input output schema docs
9
+
10
+ ### Patch Changes
11
+
12
+ - @copilotkit/shared@1.6.0-next.8
13
+
3
14
  ## 1.6.0-next.7
4
15
 
5
16
  ### Patch Changes
@@ -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.8",
43
43
  sideEffects: false,
44
44
  main: "./dist/index.js",
45
45
  module: "./dist/index.mjs",
@@ -1797,6 +1797,11 @@ async function streamEvents(controller, args) {
1797
1797
  });
1798
1798
  }
1799
1799
  const graphInfo = await client.assistants.getGraph(assistantId);
1800
+ const graphSchema = await client.assistants.getSchemas(assistantId);
1801
+ const schemaKeys = getSchemaKeys(graphSchema);
1802
+ if (payload.input && schemaKeys.input) {
1803
+ payload.input = Object.fromEntries(Object.entries(payload.input).filter(([key]) => schemaKeys.input.includes(key)));
1804
+ }
1800
1805
  let streamingStateExtractor = new StreamingStateExtractor([]);
1801
1806
  let prevNodeName = null;
1802
1807
  let emitIntermediateStateUntilEnd = null;
@@ -1888,7 +1893,8 @@ async function streamEvents(controller, args) {
1888
1893
  nodeName,
1889
1894
  state: manuallyEmittedState,
1890
1895
  running: true,
1891
- active: true
1896
+ active: true,
1897
+ schemaKeys
1892
1898
  }));
1893
1899
  continue;
1894
1900
  }
@@ -1920,7 +1926,8 @@ async function streamEvents(controller, args) {
1920
1926
  nodeName,
1921
1927
  state,
1922
1928
  running: true,
1923
- active: !exitingNode
1929
+ active: !exitingNode,
1930
+ schemaKeys
1924
1931
  }));
1925
1932
  }
1926
1933
  emit(JSON.stringify(event) + "\n");
@@ -1938,7 +1945,8 @@ async function streamEvents(controller, args) {
1938
1945
  state: state.values,
1939
1946
  running: !shouldExit,
1940
1947
  active: false,
1941
- includeMessages: true
1948
+ includeMessages: true,
1949
+ schemaKeys
1942
1950
  }));
1943
1951
  return Promise.resolve();
1944
1952
  } catch (e) {
@@ -1951,7 +1959,7 @@ async function streamEvents(controller, args) {
1951
1959
  }
1952
1960
  }
1953
1961
  __name(streamEvents, "streamEvents");
1954
- function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false }) {
1962
+ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, running, active, includeMessages = false, schemaKeys }) {
1955
1963
  if (!includeMessages) {
1956
1964
  state = Object.keys(state).reduce((acc, key) => {
1957
1965
  if (key !== "messages") {
@@ -1965,6 +1973,9 @@ function getStateSyncEvent({ threadId, runId, agentName, nodeName, state, runnin
1965
1973
  messages: langchainMessagesToCopilotKit(state.messages || [])
1966
1974
  };
1967
1975
  }
1976
+ if (schemaKeys.output) {
1977
+ state = Object.fromEntries(Object.entries(state).filter(([key]) => schemaKeys.output.includes(key)));
1978
+ }
1968
1979
  return JSON.stringify({
1969
1980
  event: LangGraphEventTypes.OnCopilotKitStateSync,
1970
1981
  thread_id: threadId,
@@ -2199,6 +2210,25 @@ function copilotkitMessagesToLangChain(messages) {
2199
2210
  return result;
2200
2211
  }
2201
2212
  __name(copilotkitMessagesToLangChain, "copilotkitMessagesToLangChain");
2213
+ function getSchemaKeys(graphSchema) {
2214
+ const CONSTANT_KEYS = [
2215
+ "messages",
2216
+ "copilotkit"
2217
+ ];
2218
+ const inputSchema = Object.keys(graphSchema.input_schema.properties);
2219
+ const outputSchema = Object.keys(graphSchema.output_schema.properties);
2220
+ return {
2221
+ input: inputSchema && inputSchema.length ? [
2222
+ ...inputSchema,
2223
+ ...CONSTANT_KEYS
2224
+ ] : null,
2225
+ output: outputSchema && outputSchema.length ? [
2226
+ ...outputSchema,
2227
+ ...CONSTANT_KEYS
2228
+ ] : null
2229
+ };
2230
+ }
2231
+ __name(getSchemaKeys, "getSchemaKeys");
2202
2232
 
2203
2233
  // src/lib/runtime/remote-action-constructors.ts
2204
2234
  import { CopilotKitError, CopilotKitLowLevelError } from "@copilotkit/shared";
@@ -4262,4 +4292,4 @@ export {
4262
4292
  getCommonConfig,
4263
4293
  copilotRuntimeNodeHttpEndpoint
4264
4294
  };
4265
- //# sourceMappingURL=chunk-SAHKR6PK.mjs.map
4295
+ //# sourceMappingURL=chunk-C7VKUXWC.mjs.map