@langchain/langgraph-api 0.0.30 → 0.0.32

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 (50) hide show
  1. package/dist/api/assistants.d.mts +3 -0
  2. package/dist/api/assistants.mjs +37 -21
  3. package/dist/api/meta.d.mts +3 -0
  4. package/dist/api/runs.d.mts +3 -0
  5. package/dist/api/store.d.mts +3 -0
  6. package/dist/api/threads.d.mts +3 -0
  7. package/dist/auth/custom.d.mts +12 -0
  8. package/dist/auth/index.d.mts +1 -1
  9. package/dist/cli/entrypoint.d.mts +1 -0
  10. package/dist/cli/utils/ipc/client.d.mts +5 -0
  11. package/dist/cli/utils/ipc/utils/get-pipe-path.d.mts +1 -0
  12. package/dist/cli/utils/ipc/utils/temporary-directory.d.mts +5 -0
  13. package/dist/command.d.mts +11 -0
  14. package/dist/graph/load.d.mts +16 -0
  15. package/dist/graph/load.hooks.d.mts +2 -0
  16. package/dist/graph/load.mjs +17 -4
  17. package/dist/graph/load.utils.d.mts +22 -0
  18. package/dist/graph/load.utils.mjs +4 -36
  19. package/dist/graph/parser/index.d.mts +17 -0
  20. package/dist/graph/parser/index.mjs +41 -0
  21. package/dist/graph/parser/parser.d.mts +63 -0
  22. package/dist/graph/parser/parser.mjs +3 -3
  23. package/dist/graph/parser/parser.worker.d.mts +1 -0
  24. package/dist/graph/parser/schema/types.d.mts +154 -0
  25. package/dist/graph/parser/schema/types.mjs +0 -111
  26. package/dist/graph/parser/schema/types.template.d.mts +1 -0
  27. package/dist/graph/parser/schema/types.template.mts +9 -4
  28. package/dist/http/custom.d.mts +6 -0
  29. package/dist/http/middleware.d.mts +11 -0
  30. package/dist/logging.d.mts +7 -0
  31. package/dist/loopback.d.mts +3 -0
  32. package/dist/preload.d.mts +1 -0
  33. package/dist/queue.d.mts +1 -0
  34. package/dist/schemas.d.mts +1369 -0
  35. package/dist/server.d.mts +157 -0
  36. package/dist/state.d.mts +3 -0
  37. package/dist/storage/checkpoint.d.mts +19 -0
  38. package/dist/storage/importMap.d.mts +55 -0
  39. package/dist/storage/ops.d.mts +284 -0
  40. package/dist/storage/persist.d.mts +18 -0
  41. package/dist/storage/store.d.mts +17 -0
  42. package/dist/stream.d.mts +38 -0
  43. package/dist/ui/load.d.mts +8 -0
  44. package/dist/utils/abort.d.mts +1 -0
  45. package/dist/utils/hono.d.mts +5 -0
  46. package/dist/utils/importMap.d.mts +55 -0
  47. package/dist/utils/runnableConfig.d.mts +3 -0
  48. package/dist/utils/serde.d.mts +5 -0
  49. package/dist/webhook.d.mts +11 -0
  50. package/package.json +10 -6
@@ -14,10 +14,8 @@
14
14
  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
15
  import * as ts from "typescript";
16
16
  import * as vm from "node:vm";
17
- import * as fs from "node:fs/promises";
18
17
  import * as path from "node:path";
19
18
  import { createHash } from "node:crypto";
20
- import dedent from "dedent";
21
19
  const REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"\)|".*?")\.| /g;
22
20
  const REGEX_TJS_JSDOC = /^-([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
23
21
  const REGEX_GROUP_JSDOC = /^[.]?([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
@@ -1496,112 +1494,3 @@ export function buildGenerator(program, args = {}) {
1496
1494
  });
1497
1495
  return new JsonSchemaGenerator(symbols, allSymbols, userSymbols, inheritingTypes, typeChecker, settings);
1498
1496
  }
1499
- export async function extractGraphSchema(id, userPath, exportName) {
1500
- const filePath = path.resolve(process.cwd(), userPath);
1501
- const parentPath = path.dirname(filePath);
1502
- const typePath = path.resolve(parentPath, `__$0${id}.mts`);
1503
- const importPath = path.relative(parentPath, filePath);
1504
- try {
1505
- await fs.writeFile(typePath, dedent `
1506
- import { ${exportName} as __graph } from "./${importPath}";
1507
- import type { BaseMessage } from "@langchain/core/messages";
1508
- import type {
1509
- StateType,
1510
- UpdateType,
1511
- StateDefinition,
1512
- } from "@langchain/langgraph";
1513
-
1514
- type Wrap<T> = (a: T) => void;
1515
- type MatchBaseMessage<T> = T extends BaseMessage ? BaseMessage : never;
1516
- type MatchBaseMessageArray<T> =
1517
- T extends Array<infer C>
1518
- ? Wrap<MatchBaseMessage<C>> extends Wrap<BaseMessage>
1519
- ? BaseMessage[]
1520
- : never
1521
- : never;
1522
-
1523
- type Defactorify<T> = T extends (...args: any[]) => infer R
1524
- ? Awaited<R>
1525
- : Awaited<T>;
1526
-
1527
- type Inspect<T> = T extends unknown
1528
- ? {
1529
- [K in keyof T]: 0 extends 1 & T[K]
1530
- ? T[K]
1531
- : Wrap<MatchBaseMessageArray<T[K]>> extends Wrap<BaseMessage[]>
1532
- ? BaseMessage[]
1533
- : Wrap<MatchBaseMessage<T[K]>> extends Wrap<BaseMessage>
1534
- ? BaseMessage
1535
- : Inspect<T[K]>;
1536
- }
1537
- : never;
1538
-
1539
- type ReflectCompiled<T> = T extends { RunInput: infer S; RunOutput: infer U }
1540
- ? { state: S; update: U }
1541
- : never;
1542
-
1543
- type Reflect<T> =
1544
- Defactorify<T> extends infer DT
1545
- ? DT extends {
1546
- compile(...args: any[]): infer Compiled;
1547
- }
1548
- ? ReflectCompiled<Compiled>
1549
- : ReflectCompiled<DT>
1550
- : never;
1551
-
1552
- type __reflect = Reflect<typeof __graph>;
1553
- export type __state = Inspect<__reflect["state"]>;
1554
- export type __update = Inspect<__reflect["update"]>;
1555
-
1556
- type BuilderReflectCompiled<T> = T extends {
1557
- builder: {
1558
- _inputDefinition: infer I extends StateDefinition;
1559
- _outputDefinition: infer O extends StateDefinition;
1560
- _configSchema?: infer C extends StateDefinition | undefined;
1561
- };
1562
- }
1563
- ? { input: UpdateType<I>; output: StateType<O>; config: UpdateType<C> }
1564
- : never;
1565
-
1566
- type BuilderReflect<T> =
1567
- Defactorify<T> extends infer DT
1568
- ? DT extends {
1569
- compile(...args: any[]): infer Compiled;
1570
- }
1571
- ? BuilderReflectCompiled<Compiled>
1572
- : BuilderReflectCompiled<DT>
1573
- : never;
1574
-
1575
- type __builder = BuilderReflect<typeof __graph>;
1576
- type FilterAny<T> = 0 extends 1 & T ? never : T;
1577
- export type __input = Inspect<FilterAny<__builder["input"]>>;
1578
- export type __output = Inspect<FilterAny<__builder["output"]>>;
1579
- export type __config = Inspect<FilterAny<__builder["config"]>>;
1580
- `);
1581
- const program = ts.createProgram([typePath], {
1582
- noEmit: true,
1583
- strict: true,
1584
- allowUnusedLabels: true,
1585
- });
1586
- const schema = buildGenerator(program);
1587
- const trySymbol = (schema, symbol) => {
1588
- try {
1589
- return schema?.getSchemaForSymbol(symbol) ?? undefined;
1590
- }
1591
- catch (e) {
1592
- console.error(`Failed to obtain symbol "${symbol}":`, e?.message);
1593
- }
1594
- return undefined;
1595
- };
1596
- return {
1597
- state: trySymbol(schema, "__state"),
1598
- update: trySymbol(schema, "__update"),
1599
- input: trySymbol(schema, "__input"),
1600
- output: trySymbol(schema, "__output"),
1601
- config: trySymbol(schema, "__config"),
1602
- };
1603
- }
1604
- finally {
1605
- await fs.unlink(typePath);
1606
- }
1607
- }
@@ -0,0 +1 @@
1
+ export {};
@@ -4,14 +4,19 @@ import type {
4
4
  UpdateType,
5
5
  StateDefinition,
6
6
  } from "@langchain/langgraph";
7
- import type { Graph } from "@langchain/langgraph";
8
- import type { Pregel } from "@langchain/langgraph/pregel";
9
7
 
10
8
  // @ts-expect-error
11
- type AnyPregel = Pregel<any, any>;
9
+ type AnyPregel = {
10
+ lg_is_pregel: boolean;
11
+ stream: (...args: any[]) => any;
12
+ invoke: (...args: any[]) => any;
13
+ };
12
14
 
13
15
  // @ts-expect-error
14
- type AnyGraph = Graph<any, any, any, any, any>;
16
+ type AnyGraph = {
17
+ compiled: boolean;
18
+ compile: (...args: any[]) => any;
19
+ };
15
20
 
16
21
  type Wrap<T> = (a: T) => void;
17
22
  type MatchBaseMessage<T> = T extends BaseMessage ? BaseMessage : never;
@@ -0,0 +1,6 @@
1
+ import { Hono } from "hono";
2
+ export declare function registerHttp(appPath: string, options: {
3
+ cwd: string;
4
+ }): Promise<{
5
+ api: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
6
+ }>;
@@ -0,0 +1,11 @@
1
+ import { MiddlewareHandler } from "hono";
2
+ export declare const cors: (cors: {
3
+ allow_origins?: string[];
4
+ allow_origin_regex?: string;
5
+ allow_methods?: string[];
6
+ allow_headers?: string[];
7
+ allow_credentials?: boolean;
8
+ expose_headers?: string[];
9
+ max_age?: number;
10
+ } | undefined) => MiddlewareHandler;
11
+ export declare const ensureContentType: () => MiddlewareHandler;
@@ -0,0 +1,7 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ export declare const logger: import("winston").Logger;
3
+ export declare const logError: (error: unknown, options?: {
4
+ context?: Record<string, unknown>;
5
+ prefix?: string;
6
+ }) => void;
7
+ export declare const requestLogger: () => MiddlewareHandler;
@@ -0,0 +1,3 @@
1
+ import { Hono } from "hono";
2
+ export declare function getLoopbackFetch(): (url: string, init?: RequestInit) => Promise<Response>;
3
+ export declare const bindLoopbackFetch: (app: Hono) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const queue: () => Promise<never>;