@langgraph-js/pure-graph 1.3.0 → 1.4.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 (71) hide show
  1. package/README.md +22 -14
  2. package/dist/adapter/nextjs/router.js +6 -6
  3. package/dist/global.d.ts +3 -2
  4. package/dist/storage/index.d.ts +4 -3
  5. package/dist/storage/index.js +13 -1
  6. package/dist/storage/pg/checkpoint.d.ts +2 -0
  7. package/dist/storage/pg/checkpoint.js +9 -0
  8. package/dist/storage/pg/threads.d.ts +43 -0
  9. package/dist/storage/pg/threads.js +304 -0
  10. package/dist/tsconfig.tsbuildinfo +1 -0
  11. package/package.json +38 -5
  12. package/.prettierrc +0 -11
  13. package/bun.lock +0 -209
  14. package/dist/adapter/hono/zod.d.ts +0 -203
  15. package/dist/adapter/hono/zod.js +0 -43
  16. package/dist/adapter/nextjs/zod.d.ts +0 -203
  17. package/dist/adapter/nextjs/zod.js +0 -60
  18. package/examples/nextjs/README.md +0 -36
  19. package/examples/nextjs/app/api/langgraph/[...path]/route.ts +0 -10
  20. package/examples/nextjs/app/favicon.ico +0 -0
  21. package/examples/nextjs/app/globals.css +0 -26
  22. package/examples/nextjs/app/layout.tsx +0 -34
  23. package/examples/nextjs/app/page.tsx +0 -211
  24. package/examples/nextjs/next.config.ts +0 -26
  25. package/examples/nextjs/package.json +0 -24
  26. package/examples/nextjs/postcss.config.mjs +0 -5
  27. package/examples/nextjs/tsconfig.json +0 -27
  28. package/packages/agent-graph/demo.json +0 -35
  29. package/packages/agent-graph/package.json +0 -18
  30. package/packages/agent-graph/src/index.ts +0 -47
  31. package/packages/agent-graph/src/tools/tavily.ts +0 -9
  32. package/packages/agent-graph/src/tools.ts +0 -38
  33. package/packages/agent-graph/src/types.ts +0 -42
  34. package/pnpm-workspace.yaml +0 -4
  35. package/src/adapter/hono/assistants.ts +0 -24
  36. package/src/adapter/hono/endpoint.ts +0 -3
  37. package/src/adapter/hono/index.ts +0 -14
  38. package/src/adapter/hono/runs.ts +0 -92
  39. package/src/adapter/hono/threads.ts +0 -37
  40. package/src/adapter/nextjs/endpoint.ts +0 -2
  41. package/src/adapter/nextjs/index.ts +0 -2
  42. package/src/adapter/nextjs/router.ts +0 -206
  43. package/src/adapter/nextjs/zod.ts +0 -66
  44. package/src/adapter/zod.ts +0 -144
  45. package/src/createEndpoint.ts +0 -116
  46. package/src/e.d.ts +0 -3
  47. package/src/global.ts +0 -11
  48. package/src/graph/stream.ts +0 -263
  49. package/src/graph/stringify.ts +0 -219
  50. package/src/index.ts +0 -6
  51. package/src/queue/JsonPlusSerializer.ts +0 -143
  52. package/src/queue/event_message.ts +0 -30
  53. package/src/queue/stream_queue.ts +0 -237
  54. package/src/storage/index.ts +0 -52
  55. package/src/storage/memory/checkpoint.ts +0 -2
  56. package/src/storage/memory/queue.ts +0 -91
  57. package/src/storage/memory/threads.ts +0 -183
  58. package/src/storage/redis/queue.ts +0 -148
  59. package/src/storage/sqlite/DB.ts +0 -16
  60. package/src/storage/sqlite/checkpoint.ts +0 -502
  61. package/src/storage/sqlite/threads.ts +0 -405
  62. package/src/storage/sqlite/type.ts +0 -12
  63. package/src/threads/index.ts +0 -37
  64. package/src/types.ts +0 -118
  65. package/src/utils/createEntrypointGraph.ts +0 -20
  66. package/src/utils/getGraph.ts +0 -44
  67. package/src/utils/getLangGraphCommand.ts +0 -21
  68. package/test/graph/entrypoint.ts +0 -21
  69. package/test/graph/index.ts +0 -60
  70. package/test/hono.ts +0 -15
  71. package/tsconfig.json +0 -20
@@ -1,203 +0,0 @@
1
- import z from "zod";
2
- export declare const AssistantConfigurable: z.ZodObject<{
3
- thread_id: z.ZodOptional<z.ZodString>;
4
- thread_ts: z.ZodOptional<z.ZodString>;
5
- }, "strip", z.ZodUnknown, z.objectOutputType<{
6
- thread_id: z.ZodOptional<z.ZodString>;
7
- thread_ts: z.ZodOptional<z.ZodString>;
8
- }, z.ZodUnknown, "strip">, z.objectInputType<{
9
- thread_id: z.ZodOptional<z.ZodString>;
10
- thread_ts: z.ZodOptional<z.ZodString>;
11
- }, z.ZodUnknown, "strip">>;
12
- export declare const AssistantConfig: z.ZodObject<{
13
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
14
- recursion_limit: z.ZodOptional<z.ZodNumber>;
15
- configurable: z.ZodOptional<z.ZodObject<{
16
- thread_id: z.ZodOptional<z.ZodString>;
17
- thread_ts: z.ZodOptional<z.ZodString>;
18
- }, "strip", z.ZodUnknown, z.objectOutputType<{
19
- thread_id: z.ZodOptional<z.ZodString>;
20
- thread_ts: z.ZodOptional<z.ZodString>;
21
- }, z.ZodUnknown, "strip">, z.objectInputType<{
22
- thread_id: z.ZodOptional<z.ZodString>;
23
- thread_ts: z.ZodOptional<z.ZodString>;
24
- }, z.ZodUnknown, "strip">>>;
25
- }, "strip", z.ZodUnknown, z.objectOutputType<{
26
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
27
- recursion_limit: z.ZodOptional<z.ZodNumber>;
28
- configurable: z.ZodOptional<z.ZodObject<{
29
- thread_id: z.ZodOptional<z.ZodString>;
30
- thread_ts: z.ZodOptional<z.ZodString>;
31
- }, "strip", z.ZodUnknown, z.objectOutputType<{
32
- thread_id: z.ZodOptional<z.ZodString>;
33
- thread_ts: z.ZodOptional<z.ZodString>;
34
- }, z.ZodUnknown, "strip">, z.objectInputType<{
35
- thread_id: z.ZodOptional<z.ZodString>;
36
- thread_ts: z.ZodOptional<z.ZodString>;
37
- }, z.ZodUnknown, "strip">>>;
38
- }, z.ZodUnknown, "strip">, z.objectInputType<{
39
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
40
- recursion_limit: z.ZodOptional<z.ZodNumber>;
41
- configurable: z.ZodOptional<z.ZodObject<{
42
- thread_id: z.ZodOptional<z.ZodString>;
43
- thread_ts: z.ZodOptional<z.ZodString>;
44
- }, "strip", z.ZodUnknown, z.objectOutputType<{
45
- thread_id: z.ZodOptional<z.ZodString>;
46
- thread_ts: z.ZodOptional<z.ZodString>;
47
- }, z.ZodUnknown, "strip">, z.objectInputType<{
48
- thread_id: z.ZodOptional<z.ZodString>;
49
- thread_ts: z.ZodOptional<z.ZodString>;
50
- }, z.ZodUnknown, "strip">>>;
51
- }, z.ZodUnknown, "strip">>;
52
- export declare const Assistant: z.ZodObject<{
53
- assistant_id: z.ZodString;
54
- graph_id: z.ZodString;
55
- config: z.ZodObject<{
56
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
57
- recursion_limit: z.ZodOptional<z.ZodNumber>;
58
- configurable: z.ZodOptional<z.ZodObject<{
59
- thread_id: z.ZodOptional<z.ZodString>;
60
- thread_ts: z.ZodOptional<z.ZodString>;
61
- }, "strip", z.ZodUnknown, z.objectOutputType<{
62
- thread_id: z.ZodOptional<z.ZodString>;
63
- thread_ts: z.ZodOptional<z.ZodString>;
64
- }, z.ZodUnknown, "strip">, z.objectInputType<{
65
- thread_id: z.ZodOptional<z.ZodString>;
66
- thread_ts: z.ZodOptional<z.ZodString>;
67
- }, z.ZodUnknown, "strip">>>;
68
- }, "strip", z.ZodUnknown, z.objectOutputType<{
69
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
70
- recursion_limit: z.ZodOptional<z.ZodNumber>;
71
- configurable: z.ZodOptional<z.ZodObject<{
72
- thread_id: z.ZodOptional<z.ZodString>;
73
- thread_ts: z.ZodOptional<z.ZodString>;
74
- }, "strip", z.ZodUnknown, z.objectOutputType<{
75
- thread_id: z.ZodOptional<z.ZodString>;
76
- thread_ts: z.ZodOptional<z.ZodString>;
77
- }, z.ZodUnknown, "strip">, z.objectInputType<{
78
- thread_id: z.ZodOptional<z.ZodString>;
79
- thread_ts: z.ZodOptional<z.ZodString>;
80
- }, z.ZodUnknown, "strip">>>;
81
- }, z.ZodUnknown, "strip">, z.objectInputType<{
82
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
83
- recursion_limit: z.ZodOptional<z.ZodNumber>;
84
- configurable: z.ZodOptional<z.ZodObject<{
85
- thread_id: z.ZodOptional<z.ZodString>;
86
- thread_ts: z.ZodOptional<z.ZodString>;
87
- }, "strip", z.ZodUnknown, z.objectOutputType<{
88
- thread_id: z.ZodOptional<z.ZodString>;
89
- thread_ts: z.ZodOptional<z.ZodString>;
90
- }, z.ZodUnknown, "strip">, z.objectInputType<{
91
- thread_id: z.ZodOptional<z.ZodString>;
92
- thread_ts: z.ZodOptional<z.ZodString>;
93
- }, z.ZodUnknown, "strip">>>;
94
- }, z.ZodUnknown, "strip">>;
95
- created_at: z.ZodString;
96
- updated_at: z.ZodString;
97
- metadata: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
98
- }, "strip", z.ZodTypeAny, {
99
- created_at: string;
100
- updated_at: string;
101
- metadata: {} & {
102
- [k: string]: any;
103
- };
104
- graph_id: string;
105
- assistant_id: string;
106
- config: {
107
- configurable?: z.objectOutputType<{
108
- thread_id: z.ZodOptional<z.ZodString>;
109
- thread_ts: z.ZodOptional<z.ZodString>;
110
- }, z.ZodUnknown, "strip"> | undefined;
111
- tags?: string[] | undefined;
112
- recursion_limit?: number | undefined;
113
- } & {
114
- [k: string]: unknown;
115
- };
116
- }, {
117
- created_at: string;
118
- updated_at: string;
119
- metadata: {} & {
120
- [k: string]: any;
121
- };
122
- graph_id: string;
123
- assistant_id: string;
124
- config: {
125
- configurable?: z.objectInputType<{
126
- thread_id: z.ZodOptional<z.ZodString>;
127
- thread_ts: z.ZodOptional<z.ZodString>;
128
- }, z.ZodUnknown, "strip"> | undefined;
129
- tags?: string[] | undefined;
130
- recursion_limit?: number | undefined;
131
- } & {
132
- [k: string]: unknown;
133
- };
134
- }>;
135
- export declare const MetadataSchema: z.ZodObject<{
136
- source: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"input">, z.ZodLiteral<"loop">, z.ZodLiteral<"update">, z.ZodString]>>;
137
- step: z.ZodOptional<z.ZodNumber>;
138
- writes: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
139
- parents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
140
- }, "strip", z.ZodUnknown, z.objectOutputType<{
141
- source: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"input">, z.ZodLiteral<"loop">, z.ZodLiteral<"update">, z.ZodString]>>;
142
- step: z.ZodOptional<z.ZodNumber>;
143
- writes: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
144
- parents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
145
- }, z.ZodUnknown, "strip">, z.objectInputType<{
146
- source: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"input">, z.ZodLiteral<"loop">, z.ZodLiteral<"update">, z.ZodString]>>;
147
- step: z.ZodOptional<z.ZodNumber>;
148
- writes: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
149
- parents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
150
- }, z.ZodUnknown, "strip">>;
151
- export declare const SendSchema: z.ZodObject<{
152
- node: z.ZodString;
153
- input: z.ZodNullable<z.ZodUnknown>;
154
- }, "strip", z.ZodTypeAny, {
155
- node: string;
156
- input?: unknown;
157
- }, {
158
- node: string;
159
- input?: unknown;
160
- }>;
161
- export declare const CommandSchema: z.ZodObject<{
162
- update: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodUnknown], null>, "many">]>>>;
163
- resume: z.ZodOptional<z.ZodUnknown>;
164
- goto: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
165
- node: z.ZodString;
166
- input: z.ZodNullable<z.ZodUnknown>;
167
- }, "strip", z.ZodTypeAny, {
168
- node: string;
169
- input?: unknown;
170
- }, {
171
- node: string;
172
- input?: unknown;
173
- }>, z.ZodArray<z.ZodObject<{
174
- node: z.ZodString;
175
- input: z.ZodNullable<z.ZodUnknown>;
176
- }, "strip", z.ZodTypeAny, {
177
- node: string;
178
- input?: unknown;
179
- }, {
180
- node: string;
181
- input?: unknown;
182
- }>, "many">, z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
183
- }, "strip", z.ZodTypeAny, {
184
- update?: Record<string, unknown> | [string, unknown][] | null | undefined;
185
- resume?: unknown;
186
- goto?: string | string[] | {
187
- node: string;
188
- input?: unknown;
189
- } | {
190
- node: string;
191
- input?: unknown;
192
- }[] | undefined;
193
- }, {
194
- update?: Record<string, unknown> | [string, unknown][] | null | undefined;
195
- resume?: unknown;
196
- goto?: string | string[] | {
197
- node: string;
198
- input?: unknown;
199
- } | {
200
- node: string;
201
- input?: unknown;
202
- }[] | undefined;
203
- }>;
@@ -1,60 +0,0 @@
1
- import z from "zod";
2
- export const AssistantConfigurable = z
3
- .object({
4
- thread_id: z.string().optional(),
5
- thread_ts: z.string().optional(),
6
- })
7
- .catchall(z.unknown());
8
- export const AssistantConfig = z
9
- .object({
10
- tags: z.array(z.string()).optional(),
11
- recursion_limit: z.number().int().optional(),
12
- configurable: AssistantConfigurable.optional(),
13
- })
14
- .catchall(z.unknown())
15
- .describe("The configuration of an assistant.");
16
- export const Assistant = z.object({
17
- assistant_id: z.string().uuid(),
18
- graph_id: z.string(),
19
- config: AssistantConfig,
20
- created_at: z.string(),
21
- updated_at: z.string(),
22
- metadata: z.object({}).catchall(z.any()),
23
- });
24
- export const MetadataSchema = z
25
- .object({
26
- source: z
27
- .union([
28
- z.literal("input"),
29
- z.literal("loop"),
30
- z.literal("update"),
31
- z.string(),
32
- ])
33
- .optional(),
34
- step: z.number().optional(),
35
- writes: z.record(z.unknown()).nullable().optional(),
36
- parents: z.record(z.string()).optional(),
37
- })
38
- .catchall(z.unknown());
39
- export const SendSchema = z.object({
40
- node: z.string(),
41
- input: z.unknown().nullable(),
42
- });
43
- export const CommandSchema = z.object({
44
- update: z
45
- .union([
46
- z.record(z.unknown()),
47
- z.array(z.tuple([z.string(), z.unknown()])),
48
- ])
49
- .nullable()
50
- .optional(),
51
- resume: z.unknown().optional(),
52
- goto: z
53
- .union([
54
- SendSchema,
55
- z.array(SendSchema),
56
- z.string(),
57
- z.array(z.string()),
58
- ])
59
- .optional(),
60
- });
@@ -1,36 +0,0 @@
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.
@@ -1,10 +0,0 @@
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
@@ -1,26 +0,0 @@
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
- }
@@ -1,34 +0,0 @@
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
- }
@@ -1,211 +0,0 @@
1
- "use client";
2
-
3
- import { useState } from "react";
4
-
5
- export default function Home() {
6
- const [result, setResult] = useState<string>("");
7
- const [loading, setLoading] = useState(false);
8
-
9
- const testAPI = async (
10
- endpoint: string,
11
- method: string = "GET",
12
- body?: any
13
- ) => {
14
- setLoading(true);
15
- setResult("");
16
-
17
- try {
18
- const options: RequestInit = {
19
- method,
20
- headers: {
21
- "Content-Type": "application/json",
22
- },
23
- };
24
-
25
- if (body && method !== "GET") {
26
- options.body = JSON.stringify(body);
27
- }
28
-
29
- const response = await fetch(`/api${endpoint}`, options);
30
- const data = await response.text();
31
-
32
- setResult(`状态: ${response.status}\n响应: ${data}`);
33
- } catch (error) {
34
- setResult(`错误: ${error}`);
35
- } finally {
36
- setLoading(false);
37
- }
38
- };
39
-
40
- const testStream = async () => {
41
- setLoading(true);
42
- setResult("");
43
-
44
- try {
45
- // 先创建一个线程
46
- const threadResponse = await fetch("/api/threads", {
47
- method: "POST",
48
- headers: { "Content-Type": "application/json" },
49
- body: JSON.stringify({}),
50
- });
51
- const thread = await threadResponse.json();
52
-
53
- // 测试流式接口
54
- const response = await fetch(
55
- `/api/threads/${thread.thread_id}/runs/stream`,
56
- {
57
- method: "POST",
58
- headers: { "Content-Type": "application/json" },
59
- body: JSON.stringify({
60
- assistant_id: "test-assistant",
61
- input: { message: "Hello" },
62
- }),
63
- }
64
- );
65
-
66
- if (response.body) {
67
- const reader = response.body.getReader();
68
- const decoder = new TextDecoder();
69
- let result = "流式响应:\n";
70
-
71
- while (true) {
72
- const { done, value } = await reader.read();
73
- if (done) break;
74
-
75
- const chunk = decoder.decode(value);
76
- result += chunk;
77
- setResult(result);
78
- }
79
- }
80
- } catch (error) {
81
- setResult(`错误: ${error}`);
82
- } finally {
83
- setLoading(false);
84
- }
85
- };
86
-
87
- return (
88
- <div className="font-sans min-h-screen p-8">
89
- <main className="max-w-4xl mx-auto">
90
- <h1 className="text-3xl font-bold mb-8">
91
- Pure Graph Next.js 统一路由适配器演示
92
- </h1>
93
-
94
- <div className="grid gap-6">
95
- <div className="border rounded-lg p-6">
96
- <h2 className="text-xl font-semibold mb-4">API 测试</h2>
97
- <div className="grid gap-4">
98
- <div className="flex gap-2">
99
- <button
100
- onClick={() =>
101
- testAPI("/assistants/search", "POST", {
102
- limit: 10,
103
- })
104
- }
105
- disabled={loading}
106
- className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50">
107
- 搜索助手
108
- </button>
109
- <button
110
- onClick={() =>
111
- testAPI("/threads", "POST", {})
112
- }
113
- disabled={loading}
114
- className="px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600 disabled:opacity-50">
115
- 创建线程
116
- </button>
117
- <button
118
- onClick={() =>
119
- testAPI("/threads/search", "POST", {
120
- limit: 5,
121
- })
122
- }
123
- disabled={loading}
124
- className="px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600 disabled:opacity-50">
125
- 搜索线程
126
- </button>
127
- </div>
128
- <button
129
- onClick={testStream}
130
- disabled={loading}
131
- className="px-4 py-2 bg-orange-500 text-white rounded hover:bg-orange-600 disabled:opacity-50">
132
- 测试流式接口 (SSE)
133
- </button>
134
- </div>
135
- </div>
136
-
137
- <div className="border rounded-lg p-6">
138
- <h2 className="text-xl font-semibold mb-4">API 响应</h2>
139
- <pre className="bg-gray-100 dark:bg-gray-800 p-4 rounded text-sm overflow-auto max-h-96 whitespace-pre-wrap">
140
- {loading
141
- ? "加载中..."
142
- : result || "点击上方按钮测试 API"}
143
- </pre>
144
- </div>
145
-
146
- <div className="border rounded-lg p-6">
147
- <h2 className="text-xl font-semibold mb-4">
148
- 统一路由 API 端点 (所有请求都通过 /api/[...path])
149
- </h2>
150
- <div className="grid gap-2 text-sm">
151
- <div>
152
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
153
- POST /api/assistants/search
154
- </code>{" "}
155
- - 搜索助手
156
- </div>
157
- <div>
158
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
159
- GET /api/assistants/[id]/graph
160
- </code>{" "}
161
- - 获取助手图谱
162
- </div>
163
- <div>
164
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
165
- POST /api/threads
166
- </code>{" "}
167
- - 创建线程
168
- </div>
169
- <div>
170
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
171
- POST /api/threads/search
172
- </code>{" "}
173
- - 搜索线程
174
- </div>
175
- <div>
176
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
177
- GET /api/threads/[id]
178
- </code>{" "}
179
- - 获取线程
180
- </div>
181
- <div>
182
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
183
- DELETE /api/threads/[id]
184
- </code>{" "}
185
- - 删除线程
186
- </div>
187
- <div>
188
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
189
- GET /api/threads/[id]/runs
190
- </code>{" "}
191
- - 获取运行列表
192
- </div>
193
- <div>
194
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
195
- POST /api/threads/[id]/runs/stream
196
- </code>{" "}
197
- - 流式运行 (SSE)
198
- </div>
199
- <div>
200
- <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">
201
- POST /api/threads/[id]/runs/[run_id]/cancel
202
- </code>{" "}
203
- - 取消运行
204
- </div>
205
- </div>
206
- </div>
207
- </div>
208
- </main>
209
- </div>
210
- );
211
- }
@@ -1,26 +0,0 @@
1
- import type { NextConfig } from "next";
2
-
3
- const nextConfig: NextConfig = {
4
- async headers() {
5
- return [
6
- {
7
- // matching all API routes
8
- source: "/api/:path*",
9
- headers: [
10
- { key: "Access-Control-Allow-Credentials", value: "true" },
11
- { key: "Access-Control-Allow-Origin", value: "*" }, // replace this your actual origin
12
- {
13
- key: "Access-Control-Allow-Methods",
14
- value: "GET,DELETE,PATCH,POST,PUT",
15
- },
16
- {
17
- key: "Access-Control-Allow-Headers",
18
- value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Authorization",
19
- },
20
- ],
21
- },
22
- ];
23
- },
24
- };
25
-
26
- export default nextConfig;
@@ -1,24 +0,0 @@
1
- {
2
- "name": "nextjs",
3
- "version": "0.1.0",
4
- "private": true,
5
- "scripts": {
6
- "dev": "next dev --turbopack",
7
- "build": "next build --turbopack",
8
- "start": "next start"
9
- },
10
- "dependencies": {
11
- "@langgraph-js/pure-graph": "workspace:^*",
12
- "next": "15.5.4",
13
- "react": "19.1.0",
14
- "react-dom": "19.1.0"
15
- },
16
- "devDependencies": {
17
- "@tailwindcss/postcss": "^4",
18
- "@types/node": "^20",
19
- "@types/react": "^19",
20
- "@types/react-dom": "^19",
21
- "tailwindcss": "^4",
22
- "typescript": "^5"
23
- }
24
- }
@@ -1,5 +0,0 @@
1
- const config = {
2
- plugins: ["@tailwindcss/postcss"],
3
- };
4
-
5
- export default config;
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2017",
4
- "lib": ["dom", "dom.iterable", "esnext"],
5
- "allowJs": true,
6
- "skipLibCheck": true,
7
- "strict": true,
8
- "noEmit": true,
9
- "esModuleInterop": true,
10
- "module": "esnext",
11
- "moduleResolution": "bundler",
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "jsx": "preserve",
15
- "incremental": true,
16
- "plugins": [
17
- {
18
- "name": "next"
19
- }
20
- ],
21
- "paths": {
22
- "@/*": ["./*"]
23
- }
24
- },
25
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26
- "exclude": ["node_modules"]
27
- }