@langgraph-js/pure-graph 1.0.2 → 1.3.0

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 (95) hide show
  1. package/.prettierrc +11 -0
  2. package/README.md +104 -10
  3. package/bun.lock +209 -0
  4. package/dist/adapter/hono/assistants.js +3 -9
  5. package/dist/adapter/hono/endpoint.js +1 -2
  6. package/dist/adapter/hono/runs.js +23 -39
  7. package/dist/adapter/hono/threads.js +5 -46
  8. package/dist/adapter/nextjs/endpoint.d.ts +1 -0
  9. package/dist/adapter/nextjs/endpoint.js +2 -0
  10. package/dist/adapter/nextjs/index.d.ts +1 -0
  11. package/dist/adapter/nextjs/index.js +2 -0
  12. package/dist/adapter/nextjs/router.d.ts +5 -0
  13. package/dist/adapter/nextjs/router.js +179 -0
  14. package/dist/adapter/nextjs/zod.d.ts +203 -0
  15. package/dist/adapter/nextjs/zod.js +60 -0
  16. package/dist/adapter/zod.d.ts +584 -0
  17. package/dist/adapter/zod.js +127 -0
  18. package/dist/createEndpoint.d.ts +1 -2
  19. package/dist/createEndpoint.js +4 -3
  20. package/dist/global.d.ts +6 -4
  21. package/dist/global.js +10 -5
  22. package/dist/graph/stream.d.ts +1 -1
  23. package/dist/graph/stream.js +18 -10
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +1 -0
  26. package/dist/queue/stream_queue.d.ts +5 -3
  27. package/dist/queue/stream_queue.js +4 -2
  28. package/dist/storage/index.d.ts +9 -4
  29. package/dist/storage/index.js +38 -3
  30. package/dist/storage/memory/threads.d.ts +3 -2
  31. package/dist/storage/memory/threads.js +29 -2
  32. package/dist/storage/redis/queue.d.ts +39 -0
  33. package/dist/storage/redis/queue.js +130 -0
  34. package/dist/storage/sqlite/DB.d.ts +3 -0
  35. package/dist/storage/sqlite/DB.js +14 -0
  36. package/dist/storage/sqlite/checkpoint.d.ts +18 -0
  37. package/dist/storage/sqlite/checkpoint.js +374 -0
  38. package/dist/storage/sqlite/threads.d.ts +44 -0
  39. package/dist/storage/sqlite/threads.js +300 -0
  40. package/dist/storage/sqlite/type.d.ts +15 -0
  41. package/dist/storage/sqlite/type.js +1 -0
  42. package/dist/threads/index.d.ts +3 -2
  43. package/dist/threads/index.js +1 -26
  44. package/dist/types.d.ts +2 -1
  45. package/dist/utils/createEntrypointGraph.d.ts +14 -0
  46. package/dist/utils/createEntrypointGraph.js +11 -0
  47. package/dist/utils/getGraph.js +3 -3
  48. package/examples/nextjs/README.md +36 -0
  49. package/examples/nextjs/app/api/langgraph/[...path]/route.ts +10 -0
  50. package/examples/nextjs/app/favicon.ico +0 -0
  51. package/examples/nextjs/app/globals.css +26 -0
  52. package/examples/nextjs/app/layout.tsx +34 -0
  53. package/examples/nextjs/app/page.tsx +211 -0
  54. package/examples/nextjs/next.config.ts +26 -0
  55. package/examples/nextjs/package.json +24 -0
  56. package/examples/nextjs/postcss.config.mjs +5 -0
  57. package/examples/nextjs/tsconfig.json +27 -0
  58. package/package.json +9 -4
  59. package/packages/agent-graph/demo.json +35 -0
  60. package/packages/agent-graph/package.json +18 -0
  61. package/packages/agent-graph/src/index.ts +47 -0
  62. package/packages/agent-graph/src/tools/tavily.ts +9 -0
  63. package/packages/agent-graph/src/tools.ts +38 -0
  64. package/packages/agent-graph/src/types.ts +42 -0
  65. package/pnpm-workspace.yaml +4 -0
  66. package/src/adapter/hono/assistants.ts +16 -33
  67. package/src/adapter/hono/endpoint.ts +1 -2
  68. package/src/adapter/hono/runs.ts +42 -51
  69. package/src/adapter/hono/threads.ts +15 -70
  70. package/src/adapter/nextjs/endpoint.ts +2 -0
  71. package/src/adapter/nextjs/index.ts +2 -0
  72. package/src/adapter/nextjs/router.ts +206 -0
  73. package/src/adapter/{hono → nextjs}/zod.ts +22 -5
  74. package/src/adapter/zod.ts +144 -0
  75. package/src/createEndpoint.ts +12 -5
  76. package/src/e.d.ts +3 -0
  77. package/src/global.ts +11 -6
  78. package/src/graph/stream.ts +20 -10
  79. package/src/index.ts +1 -0
  80. package/src/queue/stream_queue.ts +6 -5
  81. package/src/storage/index.ts +42 -4
  82. package/src/storage/memory/threads.ts +30 -1
  83. package/src/storage/redis/queue.ts +148 -0
  84. package/src/storage/sqlite/DB.ts +16 -0
  85. package/src/storage/sqlite/checkpoint.ts +502 -0
  86. package/src/storage/sqlite/threads.ts +405 -0
  87. package/src/storage/sqlite/type.ts +12 -0
  88. package/src/threads/index.ts +11 -25
  89. package/src/types.ts +2 -0
  90. package/src/utils/createEntrypointGraph.ts +20 -0
  91. package/src/utils/getGraph.ts +3 -3
  92. package/test/graph/entrypoint.ts +21 -0
  93. package/test/graph/index.ts +45 -6
  94. package/test/hono.ts +5 -0
  95. package/test/test.ts +0 -10
@@ -0,0 +1,300 @@
1
+ import { getGraph } from '../../utils/getGraph.js';
2
+ import { serialiseAsDict } from '../../graph/stream.js';
3
+ export class SQLiteThreadsManager {
4
+ db;
5
+ isSetup = false;
6
+ constructor(checkpointer) {
7
+ this.db = checkpointer.db;
8
+ this.setup();
9
+ }
10
+ setup() {
11
+ if (this.isSetup) {
12
+ return;
13
+ }
14
+ // 创建 threads 表
15
+ this.db.exec(`
16
+ CREATE TABLE IF NOT EXISTS threads (
17
+ thread_id TEXT PRIMARY KEY,
18
+ created_at TEXT NOT NULL,
19
+ updated_at TEXT NOT NULL,
20
+ metadata TEXT NOT NULL DEFAULT '{}',
21
+ status TEXT NOT NULL DEFAULT 'idle',
22
+ [values] TEXT,
23
+ interrupts TEXT NOT NULL DEFAULT '{}'
24
+ )
25
+ `);
26
+ // 创建 runs 表
27
+ this.db.exec(`
28
+ CREATE TABLE IF NOT EXISTS runs (
29
+ run_id TEXT PRIMARY KEY,
30
+ thread_id TEXT NOT NULL,
31
+ assistant_id TEXT NOT NULL,
32
+ created_at TEXT NOT NULL,
33
+ updated_at TEXT NOT NULL,
34
+ status TEXT NOT NULL DEFAULT 'pending',
35
+ metadata TEXT NOT NULL DEFAULT '{}',
36
+ multitask_strategy TEXT NOT NULL DEFAULT 'reject',
37
+ FOREIGN KEY (thread_id) REFERENCES threads(thread_id) ON DELETE CASCADE
38
+ )
39
+ `);
40
+ // 创建索引以提高查询性能
41
+ this.db.exec(`CREATE INDEX IF NOT EXISTS idx_threads_status ON threads(status)`);
42
+ this.db.exec(`CREATE INDEX IF NOT EXISTS idx_threads_created_at ON threads(created_at)`);
43
+ this.db.exec(`CREATE INDEX IF NOT EXISTS idx_threads_updated_at ON threads(updated_at)`);
44
+ this.db.exec(`CREATE INDEX IF NOT EXISTS idx_runs_thread_id ON runs(thread_id)`);
45
+ this.db.exec(`CREATE INDEX IF NOT EXISTS idx_runs_status ON runs(status)`);
46
+ this.isSetup = true;
47
+ }
48
+ async create(payload) {
49
+ const threadId = payload?.threadId || crypto.randomUUID();
50
+ // 检查线程是否已存在
51
+ if (payload?.ifExists === 'raise') {
52
+ const existingThread = this.db.prepare('SELECT thread_id FROM threads WHERE thread_id = ?').get(threadId);
53
+ if (existingThread) {
54
+ throw new Error(`Thread with ID ${threadId} already exists.`);
55
+ }
56
+ }
57
+ const now = new Date().toISOString();
58
+ const metadata = JSON.stringify(payload?.metadata || {});
59
+ const interrupts = JSON.stringify({});
60
+ const thread = {
61
+ thread_id: threadId,
62
+ created_at: now,
63
+ updated_at: now,
64
+ metadata: payload?.metadata || {},
65
+ status: 'idle',
66
+ values: null,
67
+ interrupts: {},
68
+ };
69
+ // 插入到数据库
70
+ this.db
71
+ .prepare(`
72
+ INSERT INTO threads (thread_id, created_at, updated_at, metadata, status, [values], interrupts)
73
+ VALUES (?, ?, ?, ?, ?, ?, ?)
74
+ `)
75
+ .run(threadId, now, now, metadata, 'idle', null, interrupts);
76
+ return thread;
77
+ }
78
+ async search(query) {
79
+ let sql = 'SELECT * FROM threads';
80
+ const whereConditions = [];
81
+ const params = [];
82
+ // 构建 WHERE 条件
83
+ if (query?.status) {
84
+ whereConditions.push('status = ?');
85
+ params.push(query.status);
86
+ }
87
+ if (query?.metadata) {
88
+ for (const [key, value] of Object.entries(query.metadata)) {
89
+ whereConditions.push(`json_extract(metadata, '$.${key}') = ?`);
90
+ params.push(JSON.stringify(value));
91
+ }
92
+ }
93
+ if (whereConditions.length > 0) {
94
+ sql += ' WHERE ' + whereConditions.join(' AND ');
95
+ }
96
+ // 添加排序
97
+ if (query?.sortBy) {
98
+ sql += ` ORDER BY ${query.sortBy}`;
99
+ if (query.sortOrder === 'desc') {
100
+ sql += ' DESC';
101
+ }
102
+ else {
103
+ sql += ' ASC';
104
+ }
105
+ }
106
+ // 添加分页
107
+ if (query?.limit) {
108
+ sql += ` LIMIT ${query.limit}`;
109
+ if (query?.offset) {
110
+ sql += ` OFFSET ${query.offset}`;
111
+ }
112
+ }
113
+ const rows = this.db.prepare(sql).all(...params);
114
+ return rows.map((row) => ({
115
+ thread_id: row.thread_id,
116
+ created_at: row.created_at,
117
+ updated_at: row.updated_at,
118
+ metadata: JSON.parse(row.metadata),
119
+ status: row.status,
120
+ values: row.values ? JSON.parse(row.values) : null,
121
+ interrupts: JSON.parse(row.interrupts),
122
+ }));
123
+ }
124
+ async get(threadId) {
125
+ const row = this.db.prepare('SELECT * FROM threads WHERE thread_id = ?').get(threadId);
126
+ if (!row) {
127
+ throw new Error(`Thread with ID ${threadId} not found.`);
128
+ }
129
+ return {
130
+ thread_id: row.thread_id,
131
+ created_at: row.created_at,
132
+ updated_at: row.updated_at,
133
+ metadata: JSON.parse(row.metadata),
134
+ status: row.status,
135
+ values: row.values ? JSON.parse(row.values) : null,
136
+ interrupts: JSON.parse(row.interrupts),
137
+ };
138
+ }
139
+ async set(threadId, thread) {
140
+ // 检查线程是否存在
141
+ const existingThread = this.db.prepare('SELECT thread_id FROM threads WHERE thread_id = ?').get(threadId);
142
+ if (!existingThread) {
143
+ throw new Error(`Thread with ID ${threadId} not found.`);
144
+ }
145
+ const updateFields = [];
146
+ const values = [];
147
+ if (thread.metadata !== undefined) {
148
+ updateFields.push('metadata = ?');
149
+ values.push(JSON.stringify(thread.metadata));
150
+ }
151
+ if (thread.status !== undefined) {
152
+ updateFields.push('status = ?');
153
+ values.push(thread.status);
154
+ }
155
+ if (thread.values !== undefined) {
156
+ updateFields.push('[values] = ?');
157
+ values.push(thread.values ? JSON.stringify(thread.values) : null);
158
+ }
159
+ if (thread.interrupts !== undefined) {
160
+ updateFields.push('interrupts = ?');
161
+ values.push(JSON.stringify(thread.interrupts));
162
+ }
163
+ // 总是更新 updated_at
164
+ updateFields.push('updated_at = ?');
165
+ values.push(new Date().toISOString());
166
+ if (updateFields.length > 0) {
167
+ values.push(threadId);
168
+ this.db
169
+ .prepare(`
170
+ UPDATE threads
171
+ SET ${updateFields.join(', ')}
172
+ WHERE thread_id = ?
173
+ `)
174
+ .run(...values);
175
+ }
176
+ }
177
+ async updateState(threadId, thread) {
178
+ // 从数据库查询线程信息
179
+ const row = this.db.prepare('SELECT * FROM threads WHERE thread_id = ?').get(threadId);
180
+ if (!row) {
181
+ throw new Error(`Thread with ID ${threadId} not found.`);
182
+ }
183
+ const targetThread = {
184
+ thread_id: row.thread_id,
185
+ created_at: row.created_at,
186
+ updated_at: row.updated_at,
187
+ metadata: JSON.parse(row.metadata),
188
+ status: row.status,
189
+ values: row.values ? JSON.parse(row.values) : null,
190
+ interrupts: JSON.parse(row.interrupts),
191
+ };
192
+ if (targetThread.status === 'busy') {
193
+ throw new Error(`Thread with ID ${threadId} is busy, can't update state.`);
194
+ }
195
+ if (!targetThread.metadata?.graph_id) {
196
+ throw new Error(`Thread with ID ${threadId} has no graph_id.`);
197
+ }
198
+ const graphId = targetThread.metadata?.graph_id;
199
+ const config = {
200
+ configurable: {
201
+ thread_id: threadId,
202
+ graph_id: graphId,
203
+ },
204
+ };
205
+ const graph = await getGraph(graphId, config);
206
+ const nextConfig = await graph.updateState(config, thread.values);
207
+ const graphState = await graph.getState(config);
208
+ await this.set(threadId, { values: JSON.parse(serialiseAsDict(graphState.values)) });
209
+ return nextConfig;
210
+ }
211
+ async delete(threadId) {
212
+ const result = this.db.prepare('DELETE FROM threads WHERE thread_id = ?').run(threadId);
213
+ if (result.changes === 0) {
214
+ throw new Error(`Thread with ID ${threadId} not found.`);
215
+ }
216
+ }
217
+ async createRun(threadId, assistantId, payload) {
218
+ const runId = crypto.randomUUID();
219
+ const now = new Date().toISOString();
220
+ const metadata = JSON.stringify(payload?.metadata ?? {});
221
+ const run = {
222
+ run_id: runId,
223
+ thread_id: threadId,
224
+ assistant_id: assistantId,
225
+ created_at: now,
226
+ updated_at: now,
227
+ status: 'pending',
228
+ metadata: payload?.metadata ?? {},
229
+ multitask_strategy: 'reject',
230
+ };
231
+ // 插入到数据库
232
+ this.db
233
+ .prepare(`
234
+ INSERT INTO runs (run_id, thread_id, assistant_id, created_at, updated_at, status, metadata, multitask_strategy)
235
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
236
+ `)
237
+ .run(runId, threadId, assistantId, now, now, 'pending', metadata, 'reject');
238
+ return run;
239
+ }
240
+ async listRuns(threadId, options) {
241
+ let sql = 'SELECT * FROM runs WHERE thread_id = ?';
242
+ const params = [threadId];
243
+ if (options?.status) {
244
+ sql += ' AND status = ?';
245
+ params.push(options.status);
246
+ }
247
+ sql += ' ORDER BY created_at DESC';
248
+ if (options?.limit) {
249
+ sql += ` LIMIT ${options.limit}`;
250
+ if (options?.offset) {
251
+ sql += ` OFFSET ${options.offset}`;
252
+ }
253
+ }
254
+ const rows = this.db.prepare(sql).all(...params);
255
+ return rows.map((row) => ({
256
+ run_id: row.run_id,
257
+ thread_id: row.thread_id,
258
+ assistant_id: row.assistant_id,
259
+ created_at: row.created_at,
260
+ updated_at: row.updated_at,
261
+ status: row.status,
262
+ metadata: JSON.parse(row.metadata),
263
+ multitask_strategy: row.multitask_strategy,
264
+ }));
265
+ }
266
+ async updateRun(runId, run) {
267
+ // 检查运行是否存在
268
+ const existingRun = this.db.prepare('SELECT run_id FROM runs WHERE run_id = ?').get(runId);
269
+ if (!existingRun) {
270
+ throw new Error(`Run with ID ${runId} not found.`);
271
+ }
272
+ const updateFields = [];
273
+ const values = [];
274
+ if (run.status !== undefined) {
275
+ updateFields.push('status = ?');
276
+ values.push(run.status);
277
+ }
278
+ if (run.metadata !== undefined) {
279
+ updateFields.push('metadata = ?');
280
+ values.push(JSON.stringify(run.metadata));
281
+ }
282
+ if (run.multitask_strategy !== undefined) {
283
+ updateFields.push('multitask_strategy = ?');
284
+ values.push(run.multitask_strategy);
285
+ }
286
+ // 总是更新 updated_at
287
+ updateFields.push('updated_at = ?');
288
+ values.push(new Date().toISOString());
289
+ if (updateFields.length > 0) {
290
+ values.push(runId);
291
+ this.db
292
+ .prepare(`
293
+ UPDATE runs
294
+ SET ${updateFields.join(', ')}
295
+ WHERE run_id = ?
296
+ `)
297
+ .run(...values);
298
+ }
299
+ }
300
+ }
@@ -0,0 +1,15 @@
1
+ export interface DatabaseType {
2
+ prepare(sql: string): Statement;
3
+ exec(sql: string): void;
4
+ close(): void;
5
+ transaction<T extends any[]>(fn: (...args: T) => void): (...args: T) => void;
6
+ }
7
+ interface Statement {
8
+ run(...params: any[]): {
9
+ changes: number;
10
+ lastInsertRowid: number;
11
+ };
12
+ get(...params: any[]): any;
13
+ all(...params: any[]): any[];
14
+ }
15
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
- import { Command, Metadata, OnConflictBehavior, Run, RunStatus, SortOrder, Thread, ThreadSortBy, ThreadStatus } from '@langgraph-js/sdk';
2
- export declare class BaseThreadsManager<ValuesType = unknown> {
1
+ import { Command, Config, Metadata, OnConflictBehavior, Run, RunStatus, SortOrder, Thread, ThreadSortBy, ThreadStatus } from '@langgraph-js/sdk';
2
+ export interface BaseThreadsManager<ValuesType = unknown> {
3
3
  create(payload?: {
4
4
  metadata?: Metadata;
5
5
  threadId?: string;
@@ -24,6 +24,7 @@ export declare class BaseThreadsManager<ValuesType = unknown> {
24
24
  }): Promise<Thread<ValuesType>[]>;
25
25
  get(threadId: string): Promise<Thread<ValuesType>>;
26
26
  delete(threadId: string): Promise<void>;
27
+ updateState(threadId: string, thread: Partial<Thread<ValuesType>>): Promise<Pick<Config, 'configurable'>>;
27
28
  createRun(threadId: string, assistantId: string, payload?: {
28
29
  metadata?: Metadata;
29
30
  }): Promise<Run>;
@@ -1,26 +1 @@
1
- export class BaseThreadsManager {
2
- create(payload) {
3
- throw new Error('Function not implemented.');
4
- }
5
- set(threadId, thread) {
6
- throw new Error('Function not implemented.');
7
- }
8
- search(query) {
9
- throw new Error('Function not implemented.');
10
- }
11
- get(threadId) {
12
- throw new Error('Function not implemented.');
13
- }
14
- delete(threadId) {
15
- throw new Error('Function not implemented.');
16
- }
17
- createRun(threadId, assistantId, payload) {
18
- throw new Error('Function not implemented.');
19
- }
20
- listRuns(threadId, options) {
21
- throw new Error('Function not implemented.');
22
- }
23
- updateRun(runId, run) {
24
- throw new Error('Function not implemented.');
25
- }
26
- }
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Thread, Assistant, Run, StreamMode, Command, Metadata, AssistantGraph, OnConflictBehavior, ThreadStatus, Checkpoint } from '@langchain/langgraph-sdk';
1
+ import { Thread, Assistant, Run, StreamMode, Command, Metadata, AssistantGraph, OnConflictBehavior, ThreadStatus, Checkpoint, Config } from '@langchain/langgraph-sdk';
2
2
  import { StreamEvent } from '@langchain/core/tracers/log_stream';
3
3
  import { EventMessage } from './queue/event_message';
4
4
  import { RunnableConfig } from '@langchain/core/runnables';
@@ -71,6 +71,7 @@ export interface ILangGraphClient<TStateType = unknown> {
71
71
  }): Promise<Thread<TStateType>[]>;
72
72
  get(threadId: string): Promise<Thread<TStateType>>;
73
73
  delete(threadId: string): Promise<void>;
74
+ updateState(threadId: string, thread: Partial<Thread<TStateType>>): Promise<Pick<Config, 'configurable'>>;
74
75
  };
75
76
  runs: {
76
77
  list(threadId: string, options?: {
@@ -0,0 +1,14 @@
1
+ import { AnnotationRoot, Pregel } from '@langchain/langgraph';
2
+ export declare const createEntrypointGraph: <StateType extends AnnotationRoot<any>, ConfigType extends AnnotationRoot<any>>({ stateSchema, config, graph, }: {
3
+ stateSchema: StateType;
4
+ config?: ConfigType;
5
+ graph: Pregel<any, any>;
6
+ }) => import("@langchain/langgraph").CompiledStateGraph<{
7
+ [x: string]: any;
8
+ }, {
9
+ [x: string]: any;
10
+ } | {
11
+ [x: string]: any;
12
+ }, string, any, any, any, {
13
+ [x: string]: any;
14
+ }>;
@@ -0,0 +1,11 @@
1
+ import { StateGraph } from '@langchain/langgraph';
2
+ export const createEntrypointGraph = ({ stateSchema, config, graph, }) => {
3
+ const name = graph.getName();
4
+ return new StateGraph(stateSchema, config)
5
+ .addNode(name, (state, config) => graph.invoke(state, config))
6
+ .addEdge('__start__', name)
7
+ .addEdge(name, '__end__')
8
+ .compile({
9
+ name,
10
+ });
11
+ };
@@ -1,4 +1,4 @@
1
- import { globalCheckPointer } from '../global';
1
+ import { LangGraphGlobal } from '../global';
2
2
  export const GRAPHS = {};
3
3
  export async function registerGraph(graphId, graph) {
4
4
  GRAPHS[graphId] = graph;
@@ -8,10 +8,10 @@ export async function getGraph(graphId, config, options) {
8
8
  throw new Error(`Graph "${graphId}" not found`);
9
9
  const compiled = typeof GRAPHS[graphId] === 'function' ? await GRAPHS[graphId](config ?? { configurable: {} }) : GRAPHS[graphId];
10
10
  if (typeof options?.checkpointer !== 'undefined') {
11
- compiled.checkpointer = options?.checkpointer ?? globalCheckPointer;
11
+ compiled.checkpointer = options?.checkpointer ?? LangGraphGlobal.globalCheckPointer;
12
12
  }
13
13
  else {
14
- compiled.checkpointer = globalCheckPointer;
14
+ compiled.checkpointer = LangGraphGlobal.globalCheckPointer;
15
15
  }
16
16
  compiled.store = options?.store ?? undefined;
17
17
  return compiled;
@@ -0,0 +1,36 @@
1
+ This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2
+
3
+ ## Getting Started
4
+
5
+ First, run the development server:
6
+
7
+ ```bash
8
+ npm run dev
9
+ # or
10
+ yarn dev
11
+ # or
12
+ pnpm dev
13
+ # or
14
+ bun dev
15
+ ```
16
+
17
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
+
19
+ You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20
+
21
+ This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22
+
23
+ ## Learn More
24
+
25
+ To learn more about Next.js, take a look at the following resources:
26
+
27
+ - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28
+ - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29
+
30
+ You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31
+
32
+ ## Deploy on Vercel
33
+
34
+ The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35
+
36
+ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
@@ -0,0 +1,10 @@
1
+ import {
2
+ GET,
3
+ POST,
4
+ DELETE,
5
+ } from "@langgraph-js/pure-graph/dist/adapter/nextjs/router.js";
6
+ import { registerGraph } from "@langgraph-js/pure-graph";
7
+ import { graph } from "../../../../../../test/graph/index";
8
+ registerGraph("test", graph);
9
+
10
+ export { GET, POST, DELETE };
Binary file
@@ -0,0 +1,26 @@
1
+ @import "tailwindcss";
2
+
3
+ :root {
4
+ --background: #ffffff;
5
+ --foreground: #171717;
6
+ }
7
+
8
+ @theme inline {
9
+ --color-background: var(--background);
10
+ --color-foreground: var(--foreground);
11
+ --font-sans: var(--font-geist-sans);
12
+ --font-mono: var(--font-geist-mono);
13
+ }
14
+
15
+ @media (prefers-color-scheme: dark) {
16
+ :root {
17
+ --background: #0a0a0a;
18
+ --foreground: #ededed;
19
+ }
20
+ }
21
+
22
+ body {
23
+ background: var(--background);
24
+ color: var(--foreground);
25
+ font-family: Arial, Helvetica, sans-serif;
26
+ }
@@ -0,0 +1,34 @@
1
+ import type { Metadata } from "next";
2
+ import { Geist, Geist_Mono } from "next/font/google";
3
+ import "./globals.css";
4
+
5
+ const geistSans = Geist({
6
+ variable: "--font-geist-sans",
7
+ subsets: ["latin"],
8
+ });
9
+
10
+ const geistMono = Geist_Mono({
11
+ variable: "--font-geist-mono",
12
+ subsets: ["latin"],
13
+ });
14
+
15
+ export const metadata: Metadata = {
16
+ title: "Create Next App",
17
+ description: "Generated by create next app",
18
+ };
19
+
20
+ export default function RootLayout({
21
+ children,
22
+ }: Readonly<{
23
+ children: React.ReactNode;
24
+ }>) {
25
+ return (
26
+ <html lang="en">
27
+ <body
28
+ className={`${geistSans.variable} ${geistMono.variable} antialiased`}
29
+ >
30
+ {children}
31
+ </body>
32
+ </html>
33
+ );
34
+ }