@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.
- package/.prettierrc +11 -0
- package/README.md +104 -10
- package/bun.lock +209 -0
- package/dist/adapter/hono/assistants.js +3 -9
- package/dist/adapter/hono/endpoint.js +1 -2
- package/dist/adapter/hono/runs.js +23 -39
- package/dist/adapter/hono/threads.js +5 -46
- package/dist/adapter/nextjs/endpoint.d.ts +1 -0
- package/dist/adapter/nextjs/endpoint.js +2 -0
- package/dist/adapter/nextjs/index.d.ts +1 -0
- package/dist/adapter/nextjs/index.js +2 -0
- package/dist/adapter/nextjs/router.d.ts +5 -0
- package/dist/adapter/nextjs/router.js +179 -0
- package/dist/adapter/nextjs/zod.d.ts +203 -0
- package/dist/adapter/nextjs/zod.js +60 -0
- package/dist/adapter/zod.d.ts +584 -0
- package/dist/adapter/zod.js +127 -0
- package/dist/createEndpoint.d.ts +1 -2
- package/dist/createEndpoint.js +4 -3
- package/dist/global.d.ts +6 -4
- package/dist/global.js +10 -5
- package/dist/graph/stream.d.ts +1 -1
- package/dist/graph/stream.js +18 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/queue/stream_queue.d.ts +5 -3
- package/dist/queue/stream_queue.js +4 -2
- package/dist/storage/index.d.ts +9 -4
- package/dist/storage/index.js +38 -3
- package/dist/storage/memory/threads.d.ts +3 -2
- package/dist/storage/memory/threads.js +29 -2
- package/dist/storage/redis/queue.d.ts +39 -0
- package/dist/storage/redis/queue.js +130 -0
- package/dist/storage/sqlite/DB.d.ts +3 -0
- package/dist/storage/sqlite/DB.js +14 -0
- package/dist/storage/sqlite/checkpoint.d.ts +18 -0
- package/dist/storage/sqlite/checkpoint.js +374 -0
- package/dist/storage/sqlite/threads.d.ts +44 -0
- package/dist/storage/sqlite/threads.js +300 -0
- package/dist/storage/sqlite/type.d.ts +15 -0
- package/dist/storage/sqlite/type.js +1 -0
- package/dist/threads/index.d.ts +3 -2
- package/dist/threads/index.js +1 -26
- package/dist/types.d.ts +2 -1
- package/dist/utils/createEntrypointGraph.d.ts +14 -0
- package/dist/utils/createEntrypointGraph.js +11 -0
- package/dist/utils/getGraph.js +3 -3
- package/examples/nextjs/README.md +36 -0
- package/examples/nextjs/app/api/langgraph/[...path]/route.ts +10 -0
- package/examples/nextjs/app/favicon.ico +0 -0
- package/examples/nextjs/app/globals.css +26 -0
- package/examples/nextjs/app/layout.tsx +34 -0
- package/examples/nextjs/app/page.tsx +211 -0
- package/examples/nextjs/next.config.ts +26 -0
- package/examples/nextjs/package.json +24 -0
- package/examples/nextjs/postcss.config.mjs +5 -0
- package/examples/nextjs/tsconfig.json +27 -0
- package/package.json +9 -4
- package/packages/agent-graph/demo.json +35 -0
- package/packages/agent-graph/package.json +18 -0
- package/packages/agent-graph/src/index.ts +47 -0
- package/packages/agent-graph/src/tools/tavily.ts +9 -0
- package/packages/agent-graph/src/tools.ts +38 -0
- package/packages/agent-graph/src/types.ts +42 -0
- package/pnpm-workspace.yaml +4 -0
- package/src/adapter/hono/assistants.ts +16 -33
- package/src/adapter/hono/endpoint.ts +1 -2
- package/src/adapter/hono/runs.ts +42 -51
- package/src/adapter/hono/threads.ts +15 -70
- package/src/adapter/nextjs/endpoint.ts +2 -0
- package/src/adapter/nextjs/index.ts +2 -0
- package/src/adapter/nextjs/router.ts +206 -0
- package/src/adapter/{hono → nextjs}/zod.ts +22 -5
- package/src/adapter/zod.ts +144 -0
- package/src/createEndpoint.ts +12 -5
- package/src/e.d.ts +3 -0
- package/src/global.ts +11 -6
- package/src/graph/stream.ts +20 -10
- package/src/index.ts +1 -0
- package/src/queue/stream_queue.ts +6 -5
- package/src/storage/index.ts +42 -4
- package/src/storage/memory/threads.ts +30 -1
- package/src/storage/redis/queue.ts +148 -0
- package/src/storage/sqlite/DB.ts +16 -0
- package/src/storage/sqlite/checkpoint.ts +502 -0
- package/src/storage/sqlite/threads.ts +405 -0
- package/src/storage/sqlite/type.ts +12 -0
- package/src/threads/index.ts +11 -25
- package/src/types.ts +2 -0
- package/src/utils/createEntrypointGraph.ts +20 -0
- package/src/utils/getGraph.ts +3 -3
- package/test/graph/entrypoint.ts +21 -0
- package/test/graph/index.ts +45 -6
- package/test/hono.ts +5 -0
- package/test/test.ts +0 -10
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/** @ts-ignore */
|
|
2
|
+
import { NextResponse } from 'next/server';
|
|
3
|
+
import { client } from './endpoint';
|
|
4
|
+
import { AssistantsSearchSchema, AssistantGraphQuerySchema, RunStreamPayloadSchema, RunListQuerySchema, RunCancelQuerySchema, ThreadCreatePayloadSchema, ThreadSearchPayloadSchema, ThreadStateUpdate, } from '../zod';
|
|
5
|
+
import { serialiseAsDict } from '../../graph/stream';
|
|
6
|
+
// Next.js App Router 的 SSE 响应实现
|
|
7
|
+
async function sseResponse(generator) {
|
|
8
|
+
const encoder = new TextEncoder();
|
|
9
|
+
const stream = new ReadableStream({
|
|
10
|
+
async start(controller) {
|
|
11
|
+
try {
|
|
12
|
+
for await (const { event, data } of generator) {
|
|
13
|
+
const line = `event: ${event}\n` + `data: ${serialiseAsDict(data, 0)}\n\n`;
|
|
14
|
+
controller.enqueue(encoder.encode(line));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
// ignore
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
controller.close();
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return new Response(stream, {
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'text/event-stream; charset=utf-8',
|
|
28
|
+
'Cache-Control': 'no-cache, no-transform',
|
|
29
|
+
Connection: 'keep-alive',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// 统一路由处理器
|
|
34
|
+
export async function GET(req) {
|
|
35
|
+
const url = new URL(req.url);
|
|
36
|
+
const pathname = url.pathname;
|
|
37
|
+
// Assistants routes
|
|
38
|
+
if (pathname.match(/\/assistants\/[^/]+\/graph$/)) {
|
|
39
|
+
const match = pathname.match(/\/assistants\/([^/]+)\/graph$/);
|
|
40
|
+
if (match) {
|
|
41
|
+
const assistant_id = match[1];
|
|
42
|
+
const xrayParam = url.searchParams.get('xray');
|
|
43
|
+
const queryParams = { xray: xrayParam };
|
|
44
|
+
const { xray } = AssistantGraphQuerySchema.parse(queryParams);
|
|
45
|
+
const data = await client.assistants.getGraph(assistant_id, {
|
|
46
|
+
xray: xray !== undefined ? xray === 'true' : undefined,
|
|
47
|
+
});
|
|
48
|
+
return NextResponse.json(data);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Threads routes
|
|
52
|
+
if (pathname.match(/\/threads\/[0-9a-fA-F-]{36}$/)) {
|
|
53
|
+
const match = pathname.match(/\/threads\/([0-9a-fA-F-]{36})$/);
|
|
54
|
+
if (match) {
|
|
55
|
+
const thread_id = match[1];
|
|
56
|
+
const data = await client.threads.get(thread_id);
|
|
57
|
+
return NextResponse.json(data);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Runs routes
|
|
61
|
+
if (pathname.match(/\/threads\/[0-9a-fA-F-]{36}\/runs$/)) {
|
|
62
|
+
const match = pathname.match(/\/threads\/([0-9a-fA-F-]{36})\/runs$/);
|
|
63
|
+
if (match) {
|
|
64
|
+
const thread_id = match[1];
|
|
65
|
+
const limit = url.searchParams.get('limit');
|
|
66
|
+
const offset = url.searchParams.get('offset');
|
|
67
|
+
const status = url.searchParams.get('status');
|
|
68
|
+
const queryParams = { limit, offset, status };
|
|
69
|
+
const { limit: parsedLimit, offset: parsedOffset, status: parsedStatus, } = RunListQuerySchema.parse(queryParams);
|
|
70
|
+
const runs = await client.runs.list(thread_id, {
|
|
71
|
+
limit: parsedLimit,
|
|
72
|
+
offset: parsedOffset,
|
|
73
|
+
status: parsedStatus,
|
|
74
|
+
});
|
|
75
|
+
return Response.json(runs);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return new NextResponse('Not Found', { status: 404 });
|
|
79
|
+
}
|
|
80
|
+
export async function POST(req) {
|
|
81
|
+
const url = new URL(req.url);
|
|
82
|
+
const pathname = url.pathname;
|
|
83
|
+
// Assistants routes
|
|
84
|
+
if (pathname.endsWith('/assistants/search')) {
|
|
85
|
+
const body = await req.json();
|
|
86
|
+
const payload = AssistantsSearchSchema.parse(body);
|
|
87
|
+
const data = await client.assistants.search({
|
|
88
|
+
graphId: payload.graph_id,
|
|
89
|
+
metadata: payload.metadata,
|
|
90
|
+
limit: payload.limit,
|
|
91
|
+
offset: payload.offset,
|
|
92
|
+
});
|
|
93
|
+
return NextResponse.json(data, {
|
|
94
|
+
headers: { 'X-Pagination-Total': String(data.length) },
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Threads routes
|
|
98
|
+
if (pathname.endsWith('/threads')) {
|
|
99
|
+
const body = await req.json();
|
|
100
|
+
const payload = ThreadCreatePayloadSchema.parse(body);
|
|
101
|
+
const thread = await client.threads.create({
|
|
102
|
+
thread_id: payload.thread_id,
|
|
103
|
+
metadata: payload.metadata,
|
|
104
|
+
if_exists: payload.if_exists ?? undefined,
|
|
105
|
+
});
|
|
106
|
+
return NextResponse.json(thread);
|
|
107
|
+
}
|
|
108
|
+
if (pathname.endsWith('/threads/search')) {
|
|
109
|
+
const body = await req.json();
|
|
110
|
+
const payload = ThreadSearchPayloadSchema.parse(body);
|
|
111
|
+
const result = await client.threads.search({
|
|
112
|
+
metadata: payload.metadata,
|
|
113
|
+
status: payload.status,
|
|
114
|
+
limit: payload.limit,
|
|
115
|
+
offset: payload.offset,
|
|
116
|
+
sortBy: payload.sort_by ?? undefined,
|
|
117
|
+
sortOrder: payload.sort_order ?? undefined,
|
|
118
|
+
});
|
|
119
|
+
return NextResponse.json(result, {
|
|
120
|
+
headers: { 'X-Pagination-Total': String(result.length) },
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Threads state update
|
|
124
|
+
if (pathname.match(/\/threads\/[0-9a-fA-F-]{36}\/state$/)) {
|
|
125
|
+
const match = pathname.match(/\/threads\/([0-9a-fA-F-]{36})\/state$/);
|
|
126
|
+
if (match) {
|
|
127
|
+
const thread_id = match[1];
|
|
128
|
+
const body = await req.json();
|
|
129
|
+
const payload = ThreadStateUpdate.parse(body);
|
|
130
|
+
const result = await client.threads.updateState(thread_id, payload);
|
|
131
|
+
return NextResponse.json(result);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Runs routes - stream
|
|
135
|
+
if (pathname.match(/\/threads\/[0-9a-fA-F-]{36}\/runs\/stream$/)) {
|
|
136
|
+
const match = pathname.match(/\/threads\/([0-9a-fA-F-]{36})\/runs\/stream$/);
|
|
137
|
+
if (match) {
|
|
138
|
+
const thread_id = match[1];
|
|
139
|
+
const body = await req.json();
|
|
140
|
+
const payload = RunStreamPayloadSchema.parse(body);
|
|
141
|
+
const generator = client.runs.stream(thread_id, payload.assistant_id, payload);
|
|
142
|
+
return sseResponse(generator);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Runs routes - cancel
|
|
146
|
+
if (pathname.match(/\/threads\/[0-9a-fA-F-]{36}\/runs\/[0-9a-fA-F-]{36}\/cancel$/)) {
|
|
147
|
+
const match = pathname.match(/\/threads\/([0-9a-fA-F-]{36})\/runs\/([0-9a-fA-F-]{36})\/cancel$/);
|
|
148
|
+
if (match) {
|
|
149
|
+
const thread_id = match[1];
|
|
150
|
+
const run_id = match[2];
|
|
151
|
+
const waitParam = url.searchParams.get('wait');
|
|
152
|
+
const actionParam = url.searchParams.get('action');
|
|
153
|
+
const queryParams = {
|
|
154
|
+
wait: waitParam ? waitParam === 'true' : false,
|
|
155
|
+
action: actionParam ?? 'interrupt',
|
|
156
|
+
};
|
|
157
|
+
const { wait, action } = RunCancelQuerySchema.parse(queryParams);
|
|
158
|
+
const promise = client.runs.cancel(thread_id, run_id, wait, action);
|
|
159
|
+
if (wait)
|
|
160
|
+
await promise;
|
|
161
|
+
return new Response(null, { status: wait ? 204 : 202 });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return new NextResponse('Not Found', { status: 404 });
|
|
165
|
+
}
|
|
166
|
+
export async function DELETE(req) {
|
|
167
|
+
const url = new URL(req.url);
|
|
168
|
+
const pathname = url.pathname;
|
|
169
|
+
// Threads routes
|
|
170
|
+
if (pathname.match(/\/threads\/[0-9a-fA-F-]{36}$/)) {
|
|
171
|
+
const match = pathname.match(/\/threads\/([0-9a-fA-F-]{36})$/);
|
|
172
|
+
if (match) {
|
|
173
|
+
const thread_id = match[1];
|
|
174
|
+
await client.threads.delete(thread_id);
|
|
175
|
+
return new NextResponse(null, { status: 204 });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return new NextResponse('Not Found', { status: 404 });
|
|
179
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
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
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
});
|