@langchain/langgraph-sdk 0.0.27 → 0.0.29

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, "");
@@ -9,6 +9,7 @@ const p_queue_1 = __importDefault(require("p-queue"));
9
9
  const STATUS_NO_RETRY = [
10
10
  400, // Bad Request
11
11
  401, // Unauthorized
12
+ 402, // Payment required
12
13
  403, // Forbidden
13
14
  404, // Not Found
14
15
  405, // Method Not Allowed
@@ -3,6 +3,7 @@ import PQueueMod from "p-queue";
3
3
  const STATUS_NO_RETRY = [
4
4
  400, // Bad Request
5
5
  401, // Unauthorized
6
+ 402, // Payment required
6
7
  403, // Forbidden
7
8
  404, // Not Found
8
9
  405, // Method Not Allowed
@@ -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.27",
3
+ "version": "0.0.29",
4
4
  "description": "Client library for interacting with the LangGraph API",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.19",