@langchain/langgraph-sdk 0.0.60 → 0.0.62

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.
@@ -320,6 +320,26 @@ function useStream(options) {
320
320
  setStreamError(undefined);
321
321
  submittingRef.current = true;
322
322
  abortRef.current = new AbortController();
323
+ // Unbranch things
324
+ const newPath = submitOptions?.checkpoint?.checkpoint_id
325
+ ? branchByCheckpoint[submitOptions?.checkpoint?.checkpoint_id]?.branch
326
+ : undefined;
327
+ if (newPath != null)
328
+ setBranch(newPath ?? "");
329
+ // Assumption: we're setting the initial value
330
+ // Used for instant feedback
331
+ setStreamValues(() => {
332
+ const values = { ...historyValues };
333
+ if (submitOptions?.optimisticValues != null) {
334
+ return {
335
+ ...values,
336
+ ...(typeof submitOptions.optimisticValues === "function"
337
+ ? submitOptions.optimisticValues(values)
338
+ : submitOptions.optimisticValues),
339
+ };
340
+ }
341
+ return values;
342
+ });
323
343
  let usableThreadId = threadId;
324
344
  if (!usableThreadId) {
325
345
  const thread = await client.threads.create();
@@ -335,7 +355,7 @@ function useStream(options) {
335
355
  // @ts-expect-error
336
356
  if (checkpoint != null)
337
357
  delete checkpoint.thread_id;
338
- const run = (await client.runs.stream(usableThreadId, assistantId, {
358
+ const run = client.runs.stream(usableThreadId, assistantId, {
339
359
  input: values,
340
360
  config: submitOptions?.config,
341
361
  command: submitOptions?.command,
@@ -348,26 +368,6 @@ function useStream(options) {
348
368
  signal: abortRef.current.signal,
349
369
  checkpoint,
350
370
  streamMode,
351
- }));
352
- // Unbranch things
353
- const newPath = submitOptions?.checkpoint?.checkpoint_id
354
- ? branchByCheckpoint[submitOptions?.checkpoint?.checkpoint_id]?.branch
355
- : undefined;
356
- if (newPath != null)
357
- setBranch(newPath ?? "");
358
- // Assumption: we're setting the initial value
359
- // Used for instant feedback
360
- setStreamValues(() => {
361
- const values = { ...historyValues };
362
- if (submitOptions?.optimisticValues != null) {
363
- return {
364
- ...values,
365
- ...(typeof submitOptions.optimisticValues === "function"
366
- ? submitOptions.optimisticValues(values)
367
- : submitOptions.optimisticValues),
368
- };
369
- }
370
- return values;
371
371
  });
372
372
  let streamError;
373
373
  for await (const { event, data } of run) {
@@ -317,6 +317,26 @@ export function useStream(options) {
317
317
  setStreamError(undefined);
318
318
  submittingRef.current = true;
319
319
  abortRef.current = new AbortController();
320
+ // Unbranch things
321
+ const newPath = submitOptions?.checkpoint?.checkpoint_id
322
+ ? branchByCheckpoint[submitOptions?.checkpoint?.checkpoint_id]?.branch
323
+ : undefined;
324
+ if (newPath != null)
325
+ setBranch(newPath ?? "");
326
+ // Assumption: we're setting the initial value
327
+ // Used for instant feedback
328
+ setStreamValues(() => {
329
+ const values = { ...historyValues };
330
+ if (submitOptions?.optimisticValues != null) {
331
+ return {
332
+ ...values,
333
+ ...(typeof submitOptions.optimisticValues === "function"
334
+ ? submitOptions.optimisticValues(values)
335
+ : submitOptions.optimisticValues),
336
+ };
337
+ }
338
+ return values;
339
+ });
320
340
  let usableThreadId = threadId;
321
341
  if (!usableThreadId) {
322
342
  const thread = await client.threads.create();
@@ -332,7 +352,7 @@ export function useStream(options) {
332
352
  // @ts-expect-error
333
353
  if (checkpoint != null)
334
354
  delete checkpoint.thread_id;
335
- const run = (await client.runs.stream(usableThreadId, assistantId, {
355
+ const run = client.runs.stream(usableThreadId, assistantId, {
336
356
  input: values,
337
357
  config: submitOptions?.config,
338
358
  command: submitOptions?.command,
@@ -345,26 +365,6 @@ export function useStream(options) {
345
365
  signal: abortRef.current.signal,
346
366
  checkpoint,
347
367
  streamMode,
348
- }));
349
- // Unbranch things
350
- const newPath = submitOptions?.checkpoint?.checkpoint_id
351
- ? branchByCheckpoint[submitOptions?.checkpoint?.checkpoint_id]?.branch
352
- : undefined;
353
- if (newPath != null)
354
- setBranch(newPath ?? "");
355
- // Assumption: we're setting the initial value
356
- // Used for instant feedback
357
- setStreamValues(() => {
358
- const values = { ...historyValues };
359
- if (submitOptions?.optimisticValues != null) {
360
- return {
361
- ...values,
362
- ...(typeof submitOptions.optimisticValues === "function"
363
- ? submitOptions.optimisticValues(values)
364
- : submitOptions.optimisticValues),
365
- };
366
- }
367
- return values;
368
368
  });
369
369
  let streamError;
370
370
  for await (const { event, data } of run) {
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  return result;
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.bootstrapUiContext = exports.LoadExternalComponent = exports.useStreamContext = void 0;
27
+ exports.bootstrapUiContext = exports.experimental_loadShare = exports.LoadExternalComponent = exports.useStreamContext = void 0;
28
28
  const jsx_runtime_1 = require("react/jsx-runtime");
29
29
  const index_js_1 = require("../react/index.cjs");
30
30
  const React = __importStar(require("react"));
@@ -87,6 +87,7 @@ class ComponentStore {
87
87
  const COMPONENT_STORE = new ComponentStore();
88
88
  const EXT_STORE_SYMBOL = Symbol.for("LGUI_EXT_STORE");
89
89
  const REQUIRE_SYMBOL = Symbol.for("LGUI_REQUIRE");
90
+ const REQUIRE_EXTRA_SYMBOL = Symbol.for("LGUI_REQUIRE_EXTRA");
90
91
  function LoadExternalComponent({ stream, namespace, message, meta, fallback, components, ...props }) {
91
92
  const ref = React.useRef(null);
92
93
  const id = React.useId();
@@ -119,6 +120,13 @@ function LoadExternalComponent({ stream, namespace, message, meta, fallback, com
119
120
  : fallback })] }));
120
121
  }
121
122
  exports.LoadExternalComponent = LoadExternalComponent;
123
+ function experimental_loadShare(name, module) {
124
+ if (typeof window === "undefined")
125
+ return;
126
+ window[REQUIRE_EXTRA_SYMBOL] ??= {};
127
+ window[REQUIRE_EXTRA_SYMBOL][name] = module;
128
+ }
129
+ exports.experimental_loadShare = experimental_loadShare;
122
130
  function bootstrapUiContext() {
123
131
  if (typeof window === "undefined") {
124
132
  console.warn("Attempting to bootstrap UI context outside of browser environment. " +
@@ -143,6 +151,11 @@ function bootstrapUiContext() {
143
151
  },
144
152
  };
145
153
  }
154
+ if (window[REQUIRE_EXTRA_SYMBOL] != null &&
155
+ typeof window[REQUIRE_EXTRA_SYMBOL] === "object" &&
156
+ name in window[REQUIRE_EXTRA_SYMBOL]) {
157
+ return window[REQUIRE_EXTRA_SYMBOL][name];
158
+ }
146
159
  throw new Error(`Unknown module...: ${name}`);
147
160
  };
148
161
  }
@@ -48,6 +48,7 @@ declare class ComponentStore {
48
48
  }
49
49
  declare const EXT_STORE_SYMBOL: unique symbol;
50
50
  declare const REQUIRE_SYMBOL: unique symbol;
51
+ declare const REQUIRE_EXTRA_SYMBOL: unique symbol;
51
52
  interface LoadExternalComponentProps extends Pick<React.HTMLAttributes<HTMLDivElement>, "style" | "className"> {
52
53
  /** Stream of the assistant */
53
54
  stream: ReturnType<typeof useStream>;
@@ -70,7 +71,9 @@ declare global {
70
71
  interface Window {
71
72
  [EXT_STORE_SYMBOL]: ComponentStore;
72
73
  [REQUIRE_SYMBOL]: (name: string) => unknown;
74
+ [REQUIRE_EXTRA_SYMBOL]: Record<string, unknown>;
73
75
  }
74
76
  }
77
+ export declare function experimental_loadShare(name: string, module: unknown): void;
75
78
  export declare function bootstrapUiContext(): void;
76
79
  export {};
@@ -60,6 +60,7 @@ class ComponentStore {
60
60
  const COMPONENT_STORE = new ComponentStore();
61
61
  const EXT_STORE_SYMBOL = Symbol.for("LGUI_EXT_STORE");
62
62
  const REQUIRE_SYMBOL = Symbol.for("LGUI_REQUIRE");
63
+ const REQUIRE_EXTRA_SYMBOL = Symbol.for("LGUI_REQUIRE_EXTRA");
63
64
  export function LoadExternalComponent({ stream, namespace, message, meta, fallback, components, ...props }) {
64
65
  const ref = React.useRef(null);
65
66
  const id = React.useId();
@@ -91,6 +92,12 @@ export function LoadExternalComponent({ stream, namespace, message, meta, fallba
91
92
  ? ReactDOM.createPortal(React.createElement(state.comp, message.props), state.target)
92
93
  : fallback })] }));
93
94
  }
95
+ export function experimental_loadShare(name, module) {
96
+ if (typeof window === "undefined")
97
+ return;
98
+ window[REQUIRE_EXTRA_SYMBOL] ??= {};
99
+ window[REQUIRE_EXTRA_SYMBOL][name] = module;
100
+ }
94
101
  export function bootstrapUiContext() {
95
102
  if (typeof window === "undefined") {
96
103
  console.warn("Attempting to bootstrap UI context outside of browser environment. " +
@@ -115,6 +122,11 @@ export function bootstrapUiContext() {
115
122
  },
116
123
  };
117
124
  }
125
+ if (window[REQUIRE_EXTRA_SYMBOL] != null &&
126
+ typeof window[REQUIRE_EXTRA_SYMBOL] === "object" &&
127
+ name in window[REQUIRE_EXTRA_SYMBOL]) {
128
+ return window[REQUIRE_EXTRA_SYMBOL][name];
129
+ }
118
130
  throw new Error(`Unknown module...: ${name}`);
119
131
  };
120
132
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uiMessageReducer = exports.LoadExternalComponent = exports.useStreamContext = void 0;
3
+ exports.uiMessageReducer = exports.experimental_loadShare = exports.LoadExternalComponent = exports.useStreamContext = void 0;
4
4
  const client_js_1 = require("./client.cjs");
5
5
  (0, client_js_1.bootstrapUiContext)();
6
6
  var client_js_2 = require("./client.cjs");
7
7
  Object.defineProperty(exports, "useStreamContext", { enumerable: true, get: function () { return client_js_2.useStreamContext; } });
8
8
  Object.defineProperty(exports, "LoadExternalComponent", { enumerable: true, get: function () { return client_js_2.LoadExternalComponent; } });
9
+ Object.defineProperty(exports, "experimental_loadShare", { enumerable: true, get: function () { return client_js_2.experimental_loadShare; } });
9
10
  var types_js_1 = require("./types.cjs");
10
11
  Object.defineProperty(exports, "uiMessageReducer", { enumerable: true, get: function () { return types_js_1.uiMessageReducer; } });
@@ -1,2 +1,2 @@
1
- export { useStreamContext, LoadExternalComponent } from "./client.js";
1
+ export { useStreamContext, LoadExternalComponent, experimental_loadShare, } from "./client.js";
2
2
  export { uiMessageReducer, type UIMessage, type RemoveUIMessage, } from "./types.js";
@@ -1,4 +1,4 @@
1
1
  import { bootstrapUiContext } from "./client.js";
2
2
  bootstrapUiContext();
3
- export { useStreamContext, LoadExternalComponent } from "./client.js";
3
+ export { useStreamContext, LoadExternalComponent, experimental_loadShare, } from "./client.js";
4
4
  export { uiMessageReducer, } from "./types.js";
package/dist/schema.d.ts CHANGED
@@ -39,22 +39,22 @@ export interface GraphSchema {
39
39
  * The schema for the input state.
40
40
  * Missing if unable to generate JSON schema from graph.
41
41
  */
42
- input_schema?: JSONSchema7;
42
+ input_schema?: JSONSchema7 | null | undefined;
43
43
  /**
44
44
  * The schema for the output state.
45
45
  * Missing if unable to generate JSON schema from graph.
46
46
  */
47
- output_schema?: JSONSchema7;
47
+ output_schema?: JSONSchema7 | null | undefined;
48
48
  /**
49
49
  * The schema for the graph state.
50
50
  * Missing if unable to generate JSON schema from graph.
51
51
  */
52
- state_schema?: JSONSchema7;
52
+ state_schema?: JSONSchema7 | null | undefined;
53
53
  /**
54
54
  * The schema for the graph config.
55
55
  * Missing if unable to generate JSON schema from graph.
56
56
  */
57
- config_schema?: JSONSchema7;
57
+ config_schema?: JSONSchema7 | null | undefined;
58
58
  }
59
59
  export type Subgraphs = Record<string, GraphSchema>;
60
60
  export type Metadata = Optional<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",