mirror of
https://github.com/langchain-ai/langgraphjs.git
synced 2026-07-22 17:15:25 -04:00
feat: langgraph canonical package (#1742)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"langgraph": major
|
||||
---
|
||||
|
||||
release package
|
||||
@@ -118,3 +118,8 @@ jobs:
|
||||
diff -C 3 README.md libs/langgraph/README.md
|
||||
exit 1
|
||||
fi
|
||||
if ! diff -q README.md libs/langgraph-core/README.md >/dev/null; then
|
||||
echo "README.md is out of sync with langgraph-core/README.md"
|
||||
diff -C 3 README.md libs/langgraph-core/README.md
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -10,6 +10,7 @@ services:
|
||||
- ../../internal/environment_tests/test-exports-esbuild:/package
|
||||
- ../../internal/environment_tests/scripts:/scripts
|
||||
- ../../libs/langgraph:/langgraph
|
||||
- ../../libs/langgraph-core:/langgraph-core
|
||||
- ../../libs/checkpoint:/checkpoint
|
||||
command: bash /scripts/docker-ci-entrypoint.sh
|
||||
test-exports-esm:
|
||||
@@ -25,6 +26,7 @@ services:
|
||||
- ../../internal/environment_tests/test-exports-esm:/package
|
||||
- ../../internal/environment_tests/scripts:/scripts
|
||||
- ../../libs/langgraph:/langgraph
|
||||
- ../../libs/langgraph-core:/langgraph-core
|
||||
- ../../libs/checkpoint:/checkpoint
|
||||
command: bash /scripts/docker-ci-entrypoint.sh
|
||||
test-exports-tsc:
|
||||
@@ -37,6 +39,7 @@ services:
|
||||
- ../../internal/environment_tests/test-exports-tsc:/package
|
||||
- ../../internal/environment_tests/scripts:/scripts
|
||||
- ../../libs/langgraph:/langgraph
|
||||
- ../../libs/langgraph-core:/langgraph-core
|
||||
- ../../libs/checkpoint:/checkpoint
|
||||
command: bash /scripts/docker-ci-entrypoint.sh
|
||||
test-exports-cjs:
|
||||
@@ -49,6 +52,7 @@ services:
|
||||
- ../../internal/environment_tests/test-exports-cjs:/package
|
||||
- ../../internal/environment_tests/scripts:/scripts
|
||||
- ../../libs/langgraph:/langgraph
|
||||
- ../../libs/langgraph-core:/langgraph-core
|
||||
- ../../libs/checkpoint:/checkpoint
|
||||
command: bash /scripts/docker-ci-entrypoint.sh
|
||||
test-exports-cf:
|
||||
@@ -61,6 +65,7 @@ services:
|
||||
- ../../internal/environment_tests/test-exports-cf:/package
|
||||
- ../../internal/environment_tests/scripts:/scripts
|
||||
- ../../libs/langgraph:/langgraph
|
||||
- ../../libs/langgraph-core:/langgraph-core
|
||||
- ../../libs/checkpoint:/checkpoint
|
||||
command: bash /scripts/docker-ci-entrypoint.sh
|
||||
test-exports-vercel:
|
||||
@@ -76,6 +81,7 @@ services:
|
||||
- ../../internal/environment_tests/test-exports-vercel:/package
|
||||
- ../../internal/environment_tests/scripts:/scripts
|
||||
- ../../libs/langgraph:/langgraph
|
||||
- ../../libs/langgraph-core:/langgraph-core
|
||||
- ../../libs/checkpoint:/checkpoint
|
||||
command: bash /scripts/docker-ci-entrypoint.sh
|
||||
test-exports-vite:
|
||||
@@ -88,6 +94,7 @@ services:
|
||||
- ../../internal/environment_tests/test-exports-vite:/package
|
||||
- ../../internal/environment_tests/scripts:/scripts
|
||||
- ../../libs/langgraph:/langgraph
|
||||
- ../../libs/langgraph-core:/langgraph-core
|
||||
- ../../libs/checkpoint:/checkpoint
|
||||
command: bash /scripts/docker-ci-entrypoint.sh
|
||||
success:
|
||||
|
||||
@@ -14,9 +14,11 @@ cp -r ../package/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) .
|
||||
cp ../package/.[!.]* . 2>/dev/null || true
|
||||
|
||||
mkdir -p ./libs/langgraph/
|
||||
mkdir -p ./libs/langgraph-core/
|
||||
mkdir -p ./libs/checkpoint/
|
||||
|
||||
cp -r ../langgraph ./libs/
|
||||
cp -r ../langgraph-core ./libs/
|
||||
cp -r ../checkpoint ./libs/
|
||||
|
||||
# copy cache
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
module.exports = {
|
||||
extends: [
|
||||
"airbnb-base",
|
||||
"eslint:recommended",
|
||||
"prettier",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 12,
|
||||
parser: "@typescript-eslint/parser",
|
||||
project: "./tsconfig.json",
|
||||
sourceType: "module",
|
||||
},
|
||||
plugins: ["@typescript-eslint", "no-instanceof"],
|
||||
ignorePatterns: [
|
||||
".eslintrc.cjs",
|
||||
"scripts",
|
||||
"node_modules",
|
||||
"dist",
|
||||
"dist-cjs",
|
||||
"*.js",
|
||||
"*.cjs",
|
||||
"*.d.ts",
|
||||
],
|
||||
rules: {
|
||||
"no-process-env": 2,
|
||||
"no-instanceof/no-instanceof": 2,
|
||||
"@typescript-eslint/explicit-module-boundary-types": 0,
|
||||
"@typescript-eslint/no-empty-function": 0,
|
||||
"@typescript-eslint/no-shadow": 0,
|
||||
"@typescript-eslint/no-empty-interface": 0,
|
||||
"@typescript-eslint/no-use-before-define": ["error", "nofunc"],
|
||||
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }],
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/no-misused-promises": "error",
|
||||
"arrow-body-style": 0,
|
||||
camelcase: 0,
|
||||
"class-methods-use-this": 0,
|
||||
"import/extensions": [2, "ignorePackages"],
|
||||
"import/no-extraneous-dependencies": [
|
||||
"error",
|
||||
{ devDependencies: ["**/*.test.ts", "**/*.test-d.ts"] },
|
||||
],
|
||||
"import/no-unresolved": 0,
|
||||
"import/prefer-default-export": 0,
|
||||
"keyword-spacing": "error",
|
||||
"max-classes-per-file": 0,
|
||||
"max-len": 0,
|
||||
"no-await-in-loop": 0,
|
||||
"no-bitwise": 0,
|
||||
"no-console": 0,
|
||||
"no-empty-function": 0,
|
||||
"no-restricted-syntax": 0,
|
||||
"no-shadow": 0,
|
||||
"no-continue": 0,
|
||||
"no-void": 0,
|
||||
"no-underscore-dangle": 0,
|
||||
"no-use-before-define": 0,
|
||||
"no-useless-constructor": 0,
|
||||
"no-return-await": 0,
|
||||
"consistent-return": 0,
|
||||
"no-else-return": 0,
|
||||
"func-names": 0,
|
||||
"no-lonely-if": 0,
|
||||
"prefer-rest-params": 0,
|
||||
"new-cap": ["error", { properties: false, capIsNew: false }],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ["src/tests/**/*.ts"],
|
||||
rules: { "no-instanceof/no-instanceof": 0 },
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
index.cjs
|
||||
index.js
|
||||
index.d.ts
|
||||
index.d.cts
|
||||
web.cjs
|
||||
web.js
|
||||
web.d.ts
|
||||
web.d.cts
|
||||
pregel.cjs
|
||||
pregel.js
|
||||
pregel.d.ts
|
||||
pregel.d.cts
|
||||
prebuilt.cjs
|
||||
prebuilt.js
|
||||
prebuilt.d.ts
|
||||
prebuilt.d.cts
|
||||
remote.cjs
|
||||
remote.js
|
||||
remote.d.ts
|
||||
remote.d.cts
|
||||
zod.cjs
|
||||
zod.js
|
||||
zod.d.ts
|
||||
zod.d.cts
|
||||
zod/schema.cjs
|
||||
zod/schema.js
|
||||
zod/schema.d.ts
|
||||
zod/schema.d.cts
|
||||
node_modules
|
||||
dist
|
||||
.yarn
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/prettierrc",
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"quoteProps": "as-needed",
|
||||
"jsxSingleQuote": false,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always",
|
||||
"requirePragma": false,
|
||||
"insertPragma": false,
|
||||
"proseWrap": "preserve",
|
||||
"htmlWhitespaceSensitivity": "css",
|
||||
"vueIndentScriptAndStyle": false,
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2024 LangChain
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,123 @@
|
||||
# 🦜🕸️LangGraph.js
|
||||
|
||||
[](https://langchain-ai.github.io/langgraphjs/)
|
||||

|
||||
[](https://www.npmjs.com/package/@langchain/langgraph)
|
||||
[](https://github.com/langchain-ai/langgraphjs/issues)
|
||||
|
||||
> [!NOTE]
|
||||
> Looking for the Python version? See the [Python repo](https://github.com/langchain-ai/langgraph) and the [Python docs](https://langchain-ai.github.io/langgraph/).
|
||||
|
||||
LangGraph — used by Replit, Uber, LinkedIn, GitLab and more — is a low-level orchestration framework for building controllable agents. While langchain provides integrations and composable components to streamline LLM application development, the LangGraph library enables agent orchestration — offering customizable architectures, long-term memory, and human-in-the-loop to reliably handle complex tasks.
|
||||
|
||||
```bash
|
||||
npm install @langchain/langgraph @langchain/core
|
||||
```
|
||||
|
||||
To learn more about how to use LangGraph, check out [the docs](https://langchain-ai.github.io/langgraphjs/). We show a simple example below of how to create a ReAct agent.
|
||||
|
||||
```ts
|
||||
// npm install @langchain-anthropic
|
||||
import { createReactAgent, tool } from "langchain";
|
||||
import { ChatAnthropic } from "@langchain/anthropic";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
const search = tool(
|
||||
async ({ query }) => {
|
||||
if (
|
||||
query.toLowerCase().includes("sf") ||
|
||||
query.toLowerCase().includes("san francisco")
|
||||
) {
|
||||
return "It's 60 degrees and foggy.";
|
||||
}
|
||||
return "It's 90 degrees and sunny.";
|
||||
},
|
||||
{
|
||||
name: "search",
|
||||
description: "Call to surf the web.",
|
||||
schema: z.object({
|
||||
query: z.string().describe("The query to use in your search."),
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
const model = new ChatAnthropic({
|
||||
model: "claude-3-7-sonnet-latest",
|
||||
});
|
||||
|
||||
const agent = createReactAgent({
|
||||
llm: model,
|
||||
tools: [search],
|
||||
});
|
||||
|
||||
const result = await agent.invoke({
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: "what is the weather in sf",
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
## Full-stack Quickstart
|
||||
|
||||
Get started quickly by building a full-stack LangGraph application using the [`create-agent-chat-app`](https://www.npmjs.com/package/create-agent-chat-app) CLI:
|
||||
|
||||
```bash
|
||||
npx create-agent-chat-app@latest
|
||||
```
|
||||
|
||||
The CLI sets up a chat interface and helps you configure your application, including:
|
||||
|
||||
- 🧠 Choice of 4 prebuilt agents (ReAct, Memory, Research, Retrieval)
|
||||
- 🌐 Frontend framework (Next.js or Vite)
|
||||
- 📦 Package manager (`npm`, `yarn`, or `pnpm`)
|
||||
|
||||
## Why use LangGraph?
|
||||
|
||||
LangGraph is built for developers who want to build powerful, adaptable AI agents. Developers choose LangGraph for:
|
||||
|
||||
- **Reliability and controllability.** Steer agent actions with moderation checks and human-in-the-loop approvals. LangGraph persists context for long-running workflows, keeping your agents on course.
|
||||
- **Low-level and extensible.** Build custom agents with fully descriptive, low-level primitives – free from rigid abstractions that limit customization. Design scalable multi-agent systems, with each agent serving a specific role tailored to your use case.
|
||||
- **First-class streaming support.** With token-by-token streaming and streaming of intermediate steps, LangGraph gives users clear visibility into agent reasoning and actions as they unfold in real time.
|
||||
|
||||
LangGraph is trusted in production and powering agents for companies like:
|
||||
|
||||
- [Klarna](https://blog.langchain.dev/customers-klarna/): Customer support bot for 85 million active users
|
||||
- [Elastic](https://www.elastic.co/blog/elastic-security-generative-ai-features): Security AI assistant for threat detection
|
||||
- [Uber](https://dpe.org/sessions/ty-smith-adam-huda/this-year-in-ubers-ai-driven-developer-productivity-revolution/): Automated unit test generation
|
||||
- [Replit](https://www.langchain.com/breakoutagents/replit): Code generation
|
||||
- And many more ([see list here](https://www.langchain.com/built-with-langgraph))
|
||||
|
||||
## LangGraph’s ecosystem
|
||||
|
||||
While LangGraph can be used standalone, it also integrates seamlessly with any LangChain product, giving developers a full suite of tools for building agents. To improve your LLM application development, pair LangGraph with:
|
||||
|
||||
- [LangSmith](http://www.langchain.com/langsmith) — Helpful for agent evals and observability. Debug poor-performing LLM app runs, evaluate agent trajectories, gain visibility in production, and improve performance over time.
|
||||
- [LangGraph Platform](https://langchain-ai.github.io/langgraphjs/concepts/#langgraph-platform) — Deploy and scale agents effortlessly with a purpose-built deployment platform for long running, stateful workflows. Discover, reuse, configure, and share agents across teams — and iterate quickly with visual prototyping in [LangGraph Studio](https://langchain-ai.github.io/langgraphjs/concepts/langgraph_studio/).
|
||||
|
||||
## Pairing with LangGraph Platform
|
||||
|
||||
While LangGraph is our open-source agent orchestration framework, enterprises that need scalable agent deployment can benefit from [LangGraph Platform](https://langchain-ai.github.io/langgraphjs/concepts/langgraph_platform/).
|
||||
|
||||
LangGraph Platform can help engineering teams:
|
||||
|
||||
- **Accelerate agent development**: Quickly create agent UXs with configurable templates and [LangGraph Studio](https://langchain-ai.github.io/langgraphjs/concepts/langgraph_studio/) for visualizing and debugging agent interactions.
|
||||
- **Deploy seamlessly**: We handle the complexity of deploying your agent. LangGraph Platform includes robust APIs for memory, threads, and cron jobs plus auto-scaling task queues & servers.
|
||||
- **Centralize agent management & reusability**: Discover, reuse, and manage agents across the organization. Business users can also modify agents without coding.
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [LangChain Forum](https://forum.langchain.com/): Connect with the community and share all of your technical questions, ideas, and feedback.
|
||||
- [LangChain Academy](https://academy.langchain.com/courses/intro-to-langgraph): Learn the basics of LangGraph in our free, structured course.
|
||||
- [Tutorials](https://langchain-ai.github.io/langgraphjs/tutorials/): Simple walkthroughs with guided examples on getting started with LangGraph.
|
||||
- [Templates](https://langchain-ai.github.io/langgraphjs/concepts/template_applications/): Pre-built reference apps for common agentic workflows (e.g. ReAct agent, memory, retrieval etc.) that can be cloned and adapted.
|
||||
- [How-to Guides](https://langchain-ai.github.io/langgraphjs/how-tos/): Quick, actionable code snippets for topics such as streaming, adding memory & persistence, and design patterns (e.g. branching, subgraphs, etc.).
|
||||
- [API Reference](https://langchain-ai.github.io/langgraphjs/reference/): Detailed reference on core classes, methods, how to use the graph and checkpointing APIs, and higher-level prebuilt components.
|
||||
- [Built with LangGraph](https://www.langchain.com/built-with-langgraph): Hear how industry leaders use LangGraph to ship powerful, production-ready AI applications.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
LangGraph is inspired by [Pregel](https://research.google/pubs/pub37252/) and [Apache Beam](https://beam.apache.org/). The public interface draws inspiration from [NetworkX](https://networkx.org/documentation/latest/). LangGraph is built by LangChain Inc, the creators of LangChain, but can be used without LangChain.
|
||||
@@ -0,0 +1,194 @@
|
||||
{
|
||||
"name": "@langchain/langgraph",
|
||||
"version": "1.0.0",
|
||||
"description": "LangGraph",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:langchain-ai/langgraphjs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn turbo:command build:internal --filter=@langchain/langgraph",
|
||||
"build:internal": "yarn workspace @langchain/build compile @langchain/langgraph",
|
||||
"clean": "rm -rf dist/ dist-cjs/ .turbo/",
|
||||
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
|
||||
"lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
||||
"lint": "yarn lint:eslint && yarn lint:dpdm",
|
||||
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
|
||||
"prepublish": "yarn build",
|
||||
"test": "vitest run",
|
||||
"test:browser": "vitest run --mode browser",
|
||||
"test:watch": "vitest watch",
|
||||
"test:int": "vitest run --mode int",
|
||||
"bench": "vitest bench --mode bench",
|
||||
"format": "prettier --config .prettierrc --write \"src\"",
|
||||
"format:check": "prettier --config .prettierrc --check \"src\""
|
||||
},
|
||||
"author": "LangChain",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@langchain/langgraph-checkpoint": "^1.0.0",
|
||||
"@langchain/langgraph-sdk": "~1.0.0",
|
||||
"uuid": "^10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@langchain/core": "^1.0.1",
|
||||
"zod": "^3.25.32 || ^4.1.0",
|
||||
"zod-to-json-schema": "^3.x"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"zod-to-json-schema": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@langchain/anthropic": "^1.0.0",
|
||||
"@langchain/core": "^1.0.1",
|
||||
"@langchain/langgraph-checkpoint": "workspace:*",
|
||||
"@langchain/langgraph-checkpoint-postgres": "workspace:*",
|
||||
"@langchain/langgraph-checkpoint-sqlite": "workspace:*",
|
||||
"@langchain/langgraph-sdk": "workspace:*",
|
||||
"@langchain/openai": "^1.0.0",
|
||||
"@langchain/scripts": ">=0.1.3 <0.2.0",
|
||||
"@langchain/tavily": "^1.0.0",
|
||||
"@swc/core": "^1.3.90",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@tsconfig/recommended": "^1.0.3",
|
||||
"@types/pg": "^8",
|
||||
"@types/uuid": "^10",
|
||||
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
||||
"@typescript-eslint/parser": "^6.12.0",
|
||||
"@vitest/browser": "^3.0.8",
|
||||
"@xenova/transformers": "^2.17.2",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"dotenv": "^16.3.1",
|
||||
"dpdm": "^3.12.0",
|
||||
"eslint": "^8.33.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-no-instanceof": "^1.0.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"langchain": "^1.0.0-alpha",
|
||||
"pg": "^8.13.0",
|
||||
"playwright": "^1.51.0",
|
||||
"prettier": "^2.8.3",
|
||||
"rollup": "^4.37.0",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "^4.9.5 || ^5.4.5",
|
||||
"vite-plugin-node-polyfills": "^0.23.0",
|
||||
"vitest": "^3.1.2",
|
||||
"zod-to-json-schema": "^3.22.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"input": "./src/index.ts",
|
||||
"typedoc": "./src/index.ts",
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.cts",
|
||||
"default": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"./web": {
|
||||
"input": "./src/web.ts",
|
||||
"typedoc": "./src/web.ts",
|
||||
"import": {
|
||||
"types": "./dist/web.d.ts",
|
||||
"default": "./dist/web.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/web.d.cts",
|
||||
"default": "./dist/web.cjs"
|
||||
}
|
||||
},
|
||||
"./channels": {
|
||||
"input": "./src/channels/index.ts",
|
||||
"typedoc": "./src/channels/index.ts",
|
||||
"import": {
|
||||
"types": "./dist/channels/index.d.ts",
|
||||
"default": "./dist/channels/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/channels/index.d.cts",
|
||||
"default": "./dist/channels/index.cjs"
|
||||
}
|
||||
},
|
||||
"./pregel": {
|
||||
"input": "./src/pregel/index.ts",
|
||||
"typedoc": "./src/pregel/index.ts",
|
||||
"import": {
|
||||
"types": "./dist/pregel/index.d.ts",
|
||||
"default": "./dist/pregel/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/pregel/index.d.cts",
|
||||
"default": "./dist/pregel/index.cjs"
|
||||
}
|
||||
},
|
||||
"./prebuilt": {
|
||||
"input": "./src/prebuilt/index.ts",
|
||||
"typedoc": "./src/prebuilt/index.ts",
|
||||
"import": {
|
||||
"types": "./dist/prebuilt/index.d.ts",
|
||||
"default": "./dist/prebuilt/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/prebuilt/index.d.cts",
|
||||
"default": "./dist/prebuilt/index.cjs"
|
||||
}
|
||||
},
|
||||
"./remote": {
|
||||
"input": "./src/remote.ts",
|
||||
"typedoc": "./src/remote.ts",
|
||||
"import": {
|
||||
"types": "./dist/remote.d.ts",
|
||||
"default": "./dist/remote.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/remote.d.cts",
|
||||
"default": "./dist/remote.cjs"
|
||||
}
|
||||
},
|
||||
"./zod": {
|
||||
"input": "./src/graph/zod/index.ts",
|
||||
"typedoc": "./src/graph/zod/index.ts",
|
||||
"import": {
|
||||
"types": "./dist/graph/zod/index.d.ts",
|
||||
"default": "./dist/graph/zod/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/graph/zod/index.d.cts",
|
||||
"default": "./dist/graph/zod/index.cjs"
|
||||
}
|
||||
},
|
||||
"./zod/schema": {
|
||||
"input": "./src/graph/zod/schema.ts",
|
||||
"typedoc": "./src/graph/zod/schema.ts",
|
||||
"import": {
|
||||
"types": "./dist/graph/zod/schema.d.ts",
|
||||
"default": "./dist/graph/zod/schema.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/graph/zod/schema.d.cts",
|
||||
"default": "./dist/graph/zod/schema.cjs"
|
||||
}
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist/"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
export {
|
||||
BaseChannel,
|
||||
createCheckpoint,
|
||||
emptyChannels as empty,
|
||||
} from "./base.js";
|
||||
export type { BinaryOperator } from "./binop.js";
|
||||
export { AnyValue } from "./any_value.js";
|
||||
export { LastValue, LastValueAfterFinish } from "./last_value.js";
|
||||
export {
|
||||
type WaitForNames,
|
||||
DynamicBarrierValue,
|
||||
} from "./dynamic_barrier_value.js";
|
||||
export { BinaryOperatorAggregate } from "./binop.js";
|
||||
export { EphemeralValue } from "./ephemeral_value.js";
|
||||
export {
|
||||
NamedBarrierValue,
|
||||
NamedBarrierValueAfterFinish,
|
||||
} from "./named_barrier_value.js";
|
||||
export { Topic } from "./topic.js";
|
||||
@@ -0,0 +1,5 @@
|
||||
/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */
|
||||
import "./plugin.js";
|
||||
|
||||
export * from "./meta.js";
|
||||
export * from "./zod-registry.js";
|
||||
@@ -0,0 +1,177 @@
|
||||
import {
|
||||
type JSONSchema,
|
||||
toJsonSchema as interopToJsonSchema,
|
||||
} from "@langchain/core/utils/json_schema";
|
||||
import { InteropZodObject } from "@langchain/core/utils/types";
|
||||
import {
|
||||
META_EXTRAS_DESCRIPTION_PREFIX,
|
||||
SchemaMetaRegistry,
|
||||
schemaMetaRegistry,
|
||||
} from "./meta.js";
|
||||
|
||||
const PartialStateSchema = Symbol.for("langgraph.state.partial");
|
||||
type PartialStateSchema = typeof PartialStateSchema;
|
||||
|
||||
interface GraphWithZodLike {
|
||||
builder: {
|
||||
_schemaRuntimeDefinition: InteropZodObject | undefined;
|
||||
_inputRuntimeDefinition: InteropZodObject | PartialStateSchema | undefined;
|
||||
_outputRuntimeDefinition: InteropZodObject | undefined;
|
||||
_configRuntimeSchema: InteropZodObject | undefined;
|
||||
};
|
||||
}
|
||||
|
||||
function isGraphWithZodLike(graph: unknown): graph is GraphWithZodLike {
|
||||
if (!graph || typeof graph !== "object") return false;
|
||||
if (
|
||||
!("builder" in graph) ||
|
||||
typeof graph.builder !== "object" ||
|
||||
graph.builder == null
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function applyJsonSchemaExtrasFromDescription<T>(schema: T): unknown {
|
||||
if (Array.isArray(schema)) {
|
||||
return schema.map(applyJsonSchemaExtrasFromDescription);
|
||||
}
|
||||
if (typeof schema === "object" && schema != null) {
|
||||
const output = Object.fromEntries(
|
||||
Object.entries(schema).map(([key, value]) => [
|
||||
key,
|
||||
applyJsonSchemaExtrasFromDescription(value),
|
||||
])
|
||||
);
|
||||
|
||||
if (
|
||||
"description" in output &&
|
||||
typeof output.description === "string" &&
|
||||
output.description.startsWith(META_EXTRAS_DESCRIPTION_PREFIX)
|
||||
) {
|
||||
const strMeta = output.description.slice(
|
||||
META_EXTRAS_DESCRIPTION_PREFIX.length
|
||||
);
|
||||
delete output.description;
|
||||
Object.assign(output, JSON.parse(strMeta));
|
||||
}
|
||||
|
||||
return output as T;
|
||||
}
|
||||
return schema;
|
||||
}
|
||||
|
||||
function toJsonSchema(schema: InteropZodObject): JSONSchema {
|
||||
return applyJsonSchemaExtrasFromDescription(
|
||||
interopToJsonSchema(schema)
|
||||
) as JSONSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state schema for a graph.
|
||||
* @param graph - The graph to get the state schema for.
|
||||
* @returns The state schema for the graph.
|
||||
*/
|
||||
export function getStateTypeSchema(
|
||||
graph: unknown,
|
||||
registry: SchemaMetaRegistry = schemaMetaRegistry
|
||||
): JSONSchema | undefined {
|
||||
if (!isGraphWithZodLike(graph)) return undefined;
|
||||
const schemaDef = graph.builder._schemaRuntimeDefinition;
|
||||
if (!schemaDef) return undefined;
|
||||
|
||||
return toJsonSchema(
|
||||
registry.getExtendedChannelSchemas(schemaDef, {
|
||||
withJsonSchemaExtrasAsDescription: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the update schema for a graph.
|
||||
* @param graph - The graph to get the update schema for.
|
||||
* @returns The update schema for the graph.
|
||||
*/
|
||||
export function getUpdateTypeSchema(
|
||||
graph: unknown,
|
||||
registry: SchemaMetaRegistry = schemaMetaRegistry
|
||||
): JSONSchema | undefined {
|
||||
if (!isGraphWithZodLike(graph)) return undefined;
|
||||
const schemaDef = graph.builder._schemaRuntimeDefinition;
|
||||
if (!schemaDef) return undefined;
|
||||
|
||||
return toJsonSchema(
|
||||
registry.getExtendedChannelSchemas(schemaDef, {
|
||||
withReducerSchema: true,
|
||||
withJsonSchemaExtrasAsDescription: true,
|
||||
asPartial: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the input schema for a graph.
|
||||
* @param graph - The graph to get the input schema for.
|
||||
* @returns The input schema for the graph.
|
||||
*/
|
||||
export function getInputTypeSchema(
|
||||
graph: unknown,
|
||||
registry: SchemaMetaRegistry = schemaMetaRegistry
|
||||
): JSONSchema | undefined {
|
||||
if (!isGraphWithZodLike(graph)) return undefined;
|
||||
let schemaDef = graph.builder._inputRuntimeDefinition;
|
||||
if (schemaDef === PartialStateSchema) {
|
||||
// No need to pass `.partial()` here, that's being done by `applyPlugin`
|
||||
schemaDef = graph.builder._schemaRuntimeDefinition;
|
||||
}
|
||||
if (!schemaDef) return undefined;
|
||||
|
||||
return toJsonSchema(
|
||||
registry.getExtendedChannelSchemas(schemaDef, {
|
||||
withReducerSchema: true,
|
||||
withJsonSchemaExtrasAsDescription: true,
|
||||
asPartial: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the output schema for a graph.
|
||||
* @param graph - The graph to get the output schema for.
|
||||
* @returns The output schema for the graph.
|
||||
*/
|
||||
export function getOutputTypeSchema(
|
||||
graph: unknown,
|
||||
registry: SchemaMetaRegistry = schemaMetaRegistry
|
||||
): JSONSchema | undefined {
|
||||
if (!isGraphWithZodLike(graph)) return undefined;
|
||||
const schemaDef = graph.builder._outputRuntimeDefinition;
|
||||
if (!schemaDef) return undefined;
|
||||
|
||||
return toJsonSchema(
|
||||
registry.getExtendedChannelSchemas(schemaDef, {
|
||||
withJsonSchemaExtrasAsDescription: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the config schema for a graph.
|
||||
* @param graph - The graph to get the config schema for.
|
||||
* @returns The config schema for the graph.
|
||||
*/
|
||||
export function getConfigTypeSchema(
|
||||
graph: unknown,
|
||||
registry: SchemaMetaRegistry = schemaMetaRegistry
|
||||
): JSONSchema | undefined {
|
||||
if (!isGraphWithZodLike(graph)) return undefined;
|
||||
const configDef = graph.builder._configRuntimeSchema;
|
||||
if (!configDef) return undefined;
|
||||
|
||||
return toJsonSchema(
|
||||
registry.getExtendedChannelSchemas(configDef, {
|
||||
withJsonSchemaExtrasAsDescription: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */
|
||||
|
||||
import { initializeAsyncLocalStorageSingleton } from "./setup/async_local_storage.js";
|
||||
|
||||
// Initialize global async local storage instance for tracing
|
||||
initializeAsyncLocalStorageSingleton();
|
||||
|
||||
export * from "./web.js";
|
||||
|
||||
export { interrupt } from "./interrupt.js";
|
||||
export { writer } from "./writer.js";
|
||||
export { pushMessage } from "./graph/message.js";
|
||||
export { getStore, getWriter, getConfig } from "./pregel/utils/config.js";
|
||||
export { getPreviousState } from "./func/index.js";
|
||||
export { getCurrentTaskInput } from "./pregel/utils/config.js";
|
||||
@@ -0,0 +1,29 @@
|
||||
export {
|
||||
type AgentExecutorState,
|
||||
createAgentExecutor,
|
||||
} from "./agent_executor.js";
|
||||
export {
|
||||
type FunctionCallingExecutorState,
|
||||
createFunctionCallingExecutor,
|
||||
} from "./chat_agent_executor.js";
|
||||
export {
|
||||
type AgentState,
|
||||
type CreateReactAgentParams,
|
||||
createReactAgent,
|
||||
createReactAgentAnnotation,
|
||||
} from "./react_agent_executor.js";
|
||||
|
||||
export {
|
||||
type ToolExecutorArgs,
|
||||
type ToolInvocationInterface,
|
||||
ToolExecutor,
|
||||
} from "./tool_executor.js";
|
||||
export { ToolNode, toolsCondition, type ToolNodeOptions } from "./tool_node.js";
|
||||
export type {
|
||||
HumanInterruptConfig,
|
||||
ActionRequest,
|
||||
HumanInterrupt,
|
||||
HumanResponse,
|
||||
} from "./interrupt.js";
|
||||
export { withAgentName } from "./agentName.js";
|
||||
export type { AgentNameMode } from "./agentName.js";
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
export { RemoteGraph, type RemoteGraphParams } from "./pregel/remote.js";
|
||||
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user