@langchain/langgraph-sdk 0.0.26 → 0.0.28

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.
package/dist/client.cjs CHANGED
@@ -5,6 +5,7 @@ const async_caller_js_1 = require("./utils/async_caller.cjs");
5
5
  const index_js_1 = require("./utils/eventsource-parser/index.cjs");
6
6
  const stream_js_1 = require("./utils/stream.cjs");
7
7
  const signals_js_1 = require("./utils/signals.cjs");
8
+ const env_js_1 = require("./utils/env.cjs");
8
9
  /**
9
10
  * Get the API key from the environment.
10
11
  * Precedence:
@@ -22,7 +23,7 @@ function getApiKey(apiKey) {
22
23
  }
23
24
  const prefixes = ["LANGGRAPH", "LANGSMITH", "LANGCHAIN"];
24
25
  for (const prefix of prefixes) {
25
- const envKey = process.env[`${prefix}_API_KEY`];
26
+ const envKey = (0, env_js_1.getEnvironmentVariable)(`${prefix}_API_KEY`);
26
27
  if (envKey) {
27
28
  // Remove surrounding quotes
28
29
  return envKey.trim().replace(/^["']|["']$/g, "");
package/dist/client.js CHANGED
@@ -2,6 +2,7 @@ import { AsyncCaller } from "./utils/async_caller.js";
2
2
  import { createParser, } from "./utils/eventsource-parser/index.js";
3
3
  import { IterableReadableStream } from "./utils/stream.js";
4
4
  import { mergeSignals } from "./utils/signals.js";
5
+ import { getEnvironmentVariable } from "./utils/env.js";
5
6
  /**
6
7
  * Get the API key from the environment.
7
8
  * Precedence:
@@ -19,7 +20,7 @@ export function getApiKey(apiKey) {
19
20
  }
20
21
  const prefixes = ["LANGGRAPH", "LANGSMITH", "LANGCHAIN"];
21
22
  for (const prefix of prefixes) {
22
- const envKey = process.env[`${prefix}_API_KEY`];
23
+ const envKey = getEnvironmentVariable(`${prefix}_API_KEY`);
23
24
  if (envKey) {
24
25
  // Remove surrounding quotes
25
26
  return envKey.trim().replace(/^["']|["']$/g, "");
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Client } from "./client.js";
2
- export type { Assistant, AssistantVersion, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadTask, ThreadState, ThreadStatus, Cron, Checkpoint, } from "./schema.js";
2
+ export type { Assistant, AssistantVersion, AssistantGraph, Config, DefaultValues, GraphSchema, Metadata, Run, Thread, ThreadTask, ThreadState, ThreadStatus, Cron, Checkpoint, Interrupt, } from "./schema.js";
3
3
  export type { OnConflictBehavior, Command } from "./types.js";
package/dist/schema.d.ts CHANGED
@@ -100,6 +100,15 @@ export interface AssistantGraph {
100
100
  conditional?: boolean;
101
101
  }>;
102
102
  }
103
+ /**
104
+ * An interrupt thrown inside a thread.
105
+ */
106
+ export interface Interrupt {
107
+ value: unknown;
108
+ when: "during";
109
+ resumable: boolean;
110
+ ns?: string[];
111
+ }
103
112
  export interface Thread<ValuesType = DefaultValues> {
104
113
  /** The ID of the thread. */
105
114
  thread_id: string;
@@ -113,6 +122,8 @@ export interface Thread<ValuesType = DefaultValues> {
113
122
  status: ThreadStatus;
114
123
  /** The current state of the thread. */
115
124
  values: ValuesType;
125
+ /** Interrupts which were thrown in this thread */
126
+ interrupts: Record<string, Array<Interrupt>>;
116
127
  }
117
128
  export interface Cron {
118
129
  /** The ID of the cron */
@@ -152,12 +163,7 @@ export interface ThreadTask {
152
163
  name: string;
153
164
  result?: unknown;
154
165
  error: Optional<string>;
155
- interrupts: Array<{
156
- value: unknown;
157
- when: "during";
158
- resumable: boolean;
159
- ns?: string[];
160
- }>;
166
+ interrupts: Array<Interrupt>;
161
167
  checkpoint: Optional<Checkpoint>;
162
168
  state: Optional<ThreadState>;
163
169
  }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnvironmentVariable = void 0;
4
+ function getEnvironmentVariable(name) {
5
+ // Certain setups (Deno, frontend) will throw an error if you try to access environment variables
6
+ try {
7
+ return typeof process !== "undefined"
8
+ ? // eslint-disable-next-line no-process-env
9
+ process.env?.[name]
10
+ : undefined;
11
+ }
12
+ catch (e) {
13
+ return undefined;
14
+ }
15
+ }
16
+ exports.getEnvironmentVariable = getEnvironmentVariable;
@@ -0,0 +1 @@
1
+ export declare function getEnvironmentVariable(name: string): string | undefined;
@@ -0,0 +1,12 @@
1
+ export function getEnvironmentVariable(name) {
2
+ // Certain setups (Deno, frontend) will throw an error if you try to access environment variables
3
+ try {
4
+ return typeof process !== "undefined"
5
+ ? // eslint-disable-next-line no-process-env
6
+ process.env?.[name]
7
+ : undefined;
8
+ }
9
+ catch (e) {
10
+ return undefined;
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-sdk",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",