veryfront 0.1.156 → 0.1.159
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/esm/cli/mcp/remote-file-tools.d.ts.map +1 -1
- package/esm/cli/mcp/remote-file-tools.js +16 -9
- package/esm/deno.js +1 -1
- package/esm/src/agent/human-input.d.ts +298 -0
- package/esm/src/agent/human-input.d.ts.map +1 -0
- package/esm/src/agent/human-input.js +112 -0
- package/esm/src/agent/index.d.ts +1 -0
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +1 -0
- package/esm/src/mcp/server.d.ts +2 -1
- package/esm/src/mcp/server.d.ts.map +1 -1
- package/esm/src/mcp/server.js +12 -5
- package/esm/src/proxy/handler.d.ts.map +1 -1
- package/esm/src/proxy/handler.js +6 -9
- package/esm/src/routing/api/module-loader/loader.d.ts +7 -0
- package/esm/src/routing/api/module-loader/loader.d.ts.map +1 -1
- package/esm/src/routing/api/module-loader/loader.js +104 -94
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/cli/mcp/remote-file-tools.ts +24 -13
- package/src/deno.js +1 -1
- package/src/src/agent/human-input.ts +152 -0
- package/src/src/agent/index.ts +18 -0
- package/src/src/mcp/server.ts +14 -5
- package/src/src/proxy/handler.ts +6 -23
- package/src/src/routing/api/module-loader/loader.ts +127 -100
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-file-tools.d.ts","sourceRoot":"","sources":["../../../src/cli/mcp/remote-file-tools.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"remote-file-tools.d.ts","sourceRoot":"","sources":["../../../src/cli/mcp/remote-file-tools.ts"],"names":[],"mappings":"A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AO,CAAC,wBAAwB,EAAE,yBAAyB,CAe9F,CAAC;AAMF,QAAA,MAAM,uBAAuB;;;;iBAQ3B,CAAC;AAEH,KAAK,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEvE,UAAU,wBAAwB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,uBAAuB,EAAE,wBAAwB,CA0E3F,CAAC;AAMF,eAAO,MAAM,eAAe,EAAE,OAAO,EAapC,CAAC"}
|
|
@@ -68,6 +68,13 @@ function getBranchPath(branch) {
|
|
|
68
68
|
function getBranchParam(branch) {
|
|
69
69
|
return branch ? `?branch_id=${branch}` : "";
|
|
70
70
|
}
|
|
71
|
+
function buildProjectApiPath(project, resource, branch) {
|
|
72
|
+
const normalizedResource = resource.startsWith("/") ? resource.slice(1) : resource;
|
|
73
|
+
return `/${project}${getBranchPath(branch)}/${normalizedResource}`;
|
|
74
|
+
}
|
|
75
|
+
function buildProjectFilePath(project, filePath, branch) {
|
|
76
|
+
return buildProjectApiPath(project, `files/${encodeFilePath(filePath)}`, branch);
|
|
77
|
+
}
|
|
71
78
|
const MAX_SLUG_ATTEMPTS = 10;
|
|
72
79
|
function slugToName(slug) {
|
|
73
80
|
return slug
|
|
@@ -118,7 +125,7 @@ export const vfRemoteListFiles = {
|
|
|
118
125
|
params.set("pattern", input.pattern);
|
|
119
126
|
params.set("limit", String(input.limit));
|
|
120
127
|
params.set("fields", "(path,type,size)");
|
|
121
|
-
const apiPath =
|
|
128
|
+
const apiPath = `${buildProjectApiPath(input.project, "files", input.branch)}?${params.toString()}`;
|
|
122
129
|
const result = await apiRequest("GET", apiPath);
|
|
123
130
|
if (!result.ok)
|
|
124
131
|
return { success: false, error: result.error };
|
|
@@ -145,7 +152,7 @@ export const vfRemoteGetFile = {
|
|
|
145
152
|
description: "Read the content of a file from a remote Veryfront project. Always use this before modifying a file.",
|
|
146
153
|
inputSchema: remoteGetFileInput,
|
|
147
154
|
execute: (input) => withSpan("cli.mcp.tool.vf_remote_get_file", async () => {
|
|
148
|
-
const apiPath =
|
|
155
|
+
const apiPath = buildProjectFilePath(input.project, input.path, input.branch);
|
|
149
156
|
const result = await apiRequest("GET", apiPath);
|
|
150
157
|
if (!result.ok)
|
|
151
158
|
return { success: false, error: result.error };
|
|
@@ -179,7 +186,7 @@ export const vfRemoteUpdateFile = {
|
|
|
179
186
|
description: "Create or update a file in a remote Veryfront project. Always read the file first before updating to understand its current state.",
|
|
180
187
|
inputSchema: remoteUpdateFileInput,
|
|
181
188
|
execute: (input) => withSpan("cli.mcp.tool.vf_remote_update_file", async () => {
|
|
182
|
-
const apiPath =
|
|
189
|
+
const apiPath = `${buildProjectFilePath(input.project, input.path)}${getBranchParam(input.branch)}`;
|
|
183
190
|
const result = await apiRequest("PUT", apiPath, {
|
|
184
191
|
body: { content: input.content },
|
|
185
192
|
});
|
|
@@ -212,7 +219,7 @@ export const vfRemoteDeleteFile = {
|
|
|
212
219
|
description: "Delete a file from a remote Veryfront project.",
|
|
213
220
|
inputSchema: remoteDeleteFileInput,
|
|
214
221
|
execute: async (input) => {
|
|
215
|
-
const apiPath =
|
|
222
|
+
const apiPath = `${buildProjectFilePath(input.project, input.path)}${getBranchParam(input.branch)}`;
|
|
216
223
|
const result = await apiRequest("DELETE", apiPath);
|
|
217
224
|
if (!result.ok)
|
|
218
225
|
return { success: false, error: result.error };
|
|
@@ -238,7 +245,7 @@ export const vfRemoteSearchFiles = {
|
|
|
238
245
|
description: "Search for text patterns within file contents in a remote Veryfront project. Supports regex and glob patterns.",
|
|
239
246
|
inputSchema: remoteSearchFilesInput,
|
|
240
247
|
execute: (input) => withSpan("cli.mcp.tool.vf_remote_search_files", async () => {
|
|
241
|
-
const apiPath =
|
|
248
|
+
const apiPath = buildProjectApiPath(input.project, "files/search", input.branch);
|
|
242
249
|
const result = await apiRequest("POST", apiPath, {
|
|
243
250
|
body: {
|
|
244
251
|
query: input.query,
|
|
@@ -273,7 +280,7 @@ export const vfRemoteMoveFile = {
|
|
|
273
280
|
description: "Move or rename a file in a remote Veryfront project.",
|
|
274
281
|
inputSchema: remoteMoveFileInput,
|
|
275
282
|
execute: async (input) => {
|
|
276
|
-
const apiPath =
|
|
283
|
+
const apiPath = `${buildProjectApiPath(input.project, "files/move")}${getBranchParam(input.branch)}`;
|
|
277
284
|
const result = await apiRequest("POST", apiPath, {
|
|
278
285
|
body: {
|
|
279
286
|
source_path: input.source_path,
|
|
@@ -444,7 +451,7 @@ export const vfRemoteCloneProject = {
|
|
|
444
451
|
params.set("limit", "1000");
|
|
445
452
|
if (input.file_pattern)
|
|
446
453
|
params.set("pattern", input.file_pattern);
|
|
447
|
-
const listResult = await apiRequest("GET",
|
|
454
|
+
const listResult = await apiRequest("GET", `${buildProjectApiPath(input.source_project, "files")}?${params.toString()}`);
|
|
448
455
|
if (!listResult.ok) {
|
|
449
456
|
return {
|
|
450
457
|
success: false,
|
|
@@ -456,12 +463,12 @@ export const vfRemoteCloneProject = {
|
|
|
456
463
|
let filesCopied = 0;
|
|
457
464
|
const errors = [];
|
|
458
465
|
for (const file of sourceFiles) {
|
|
459
|
-
const getResult = await apiRequest("GET",
|
|
466
|
+
const getResult = await apiRequest("GET", buildProjectFilePath(input.source_project, file.path));
|
|
460
467
|
if (!getResult.ok || !getResult.data) {
|
|
461
468
|
errors.push(`Failed to read ${file.path}`);
|
|
462
469
|
continue;
|
|
463
470
|
}
|
|
464
|
-
const createFileResult = await apiRequest("PUT",
|
|
471
|
+
const createFileResult = await apiRequest("PUT", buildProjectFilePath(createResult.slug, file.path), { body: { content: getResult.data.content } });
|
|
465
472
|
if (createFileResult.ok) {
|
|
466
473
|
filesCopied++;
|
|
467
474
|
}
|
package/esm/deno.js
CHANGED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { RunResumeSessionManager } from "./runtime/index.js";
|
|
3
|
+
export declare const HumanInputOptionSchema: z.ZodObject<{
|
|
4
|
+
value: z.ZodString;
|
|
5
|
+
label: z.ZodString;
|
|
6
|
+
description: z.ZodOptional<z.ZodString>;
|
|
7
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const HumanInputFieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
label: z.ZodString;
|
|
12
|
+
description: z.ZodOptional<z.ZodString>;
|
|
13
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
14
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
15
|
+
type: z.ZodEnum<{
|
|
16
|
+
number: "number";
|
|
17
|
+
password: "password";
|
|
18
|
+
url: "url";
|
|
19
|
+
text: "text";
|
|
20
|
+
email: "email";
|
|
21
|
+
}>;
|
|
22
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
23
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
24
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
25
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
label: z.ZodString;
|
|
32
|
+
description: z.ZodOptional<z.ZodString>;
|
|
33
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
34
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
35
|
+
type: z.ZodLiteral<"textarea">;
|
|
36
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
37
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
38
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
rows: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
41
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
label: z.ZodString;
|
|
44
|
+
description: z.ZodOptional<z.ZodString>;
|
|
45
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
46
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
47
|
+
type: z.ZodLiteral<"select">;
|
|
48
|
+
options: z.ZodArray<z.ZodObject<{
|
|
49
|
+
value: z.ZodString;
|
|
50
|
+
label: z.ZodString;
|
|
51
|
+
description: z.ZodOptional<z.ZodString>;
|
|
52
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
}, z.core.$strip>>;
|
|
54
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
55
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
label: z.ZodString;
|
|
59
|
+
description: z.ZodOptional<z.ZodString>;
|
|
60
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
61
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
62
|
+
type: z.ZodLiteral<"checkbox">;
|
|
63
|
+
defaultValue: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
64
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
label: z.ZodString;
|
|
67
|
+
description: z.ZodOptional<z.ZodString>;
|
|
68
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
69
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
70
|
+
type: z.ZodLiteral<"radio">;
|
|
71
|
+
options: z.ZodArray<z.ZodObject<{
|
|
72
|
+
value: z.ZodString;
|
|
73
|
+
label: z.ZodString;
|
|
74
|
+
description: z.ZodOptional<z.ZodString>;
|
|
75
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
}, z.core.$strip>>;
|
|
77
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
79
|
+
name: z.ZodString;
|
|
80
|
+
label: z.ZodString;
|
|
81
|
+
description: z.ZodOptional<z.ZodString>;
|
|
82
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
83
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
84
|
+
type: z.ZodLiteral<"confirm">;
|
|
85
|
+
confirmLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
86
|
+
denyLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
87
|
+
}, z.core.$strip>], "type">;
|
|
88
|
+
export declare const HumanInputRequestSchema: z.ZodObject<{
|
|
89
|
+
title: z.ZodString;
|
|
90
|
+
description: z.ZodOptional<z.ZodString>;
|
|
91
|
+
fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
label: z.ZodString;
|
|
94
|
+
description: z.ZodOptional<z.ZodString>;
|
|
95
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
96
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
97
|
+
type: z.ZodEnum<{
|
|
98
|
+
number: "number";
|
|
99
|
+
password: "password";
|
|
100
|
+
url: "url";
|
|
101
|
+
text: "text";
|
|
102
|
+
email: "email";
|
|
103
|
+
}>;
|
|
104
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
105
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
106
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
107
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
108
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
111
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
112
|
+
name: z.ZodString;
|
|
113
|
+
label: z.ZodString;
|
|
114
|
+
description: z.ZodOptional<z.ZodString>;
|
|
115
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
116
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
117
|
+
type: z.ZodLiteral<"textarea">;
|
|
118
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
119
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
120
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
rows: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
123
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
label: z.ZodString;
|
|
126
|
+
description: z.ZodOptional<z.ZodString>;
|
|
127
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
128
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
129
|
+
type: z.ZodLiteral<"select">;
|
|
130
|
+
options: z.ZodArray<z.ZodObject<{
|
|
131
|
+
value: z.ZodString;
|
|
132
|
+
label: z.ZodString;
|
|
133
|
+
description: z.ZodOptional<z.ZodString>;
|
|
134
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
137
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
138
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
label: z.ZodString;
|
|
141
|
+
description: z.ZodOptional<z.ZodString>;
|
|
142
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
143
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
144
|
+
type: z.ZodLiteral<"checkbox">;
|
|
145
|
+
defaultValue: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
146
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
147
|
+
name: z.ZodString;
|
|
148
|
+
label: z.ZodString;
|
|
149
|
+
description: z.ZodOptional<z.ZodString>;
|
|
150
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
151
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
152
|
+
type: z.ZodLiteral<"radio">;
|
|
153
|
+
options: z.ZodArray<z.ZodObject<{
|
|
154
|
+
value: z.ZodString;
|
|
155
|
+
label: z.ZodString;
|
|
156
|
+
description: z.ZodOptional<z.ZodString>;
|
|
157
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
+
}, z.core.$strip>>;
|
|
159
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
160
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
161
|
+
name: z.ZodString;
|
|
162
|
+
label: z.ZodString;
|
|
163
|
+
description: z.ZodOptional<z.ZodString>;
|
|
164
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
165
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
166
|
+
type: z.ZodLiteral<"confirm">;
|
|
167
|
+
confirmLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
168
|
+
denyLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
169
|
+
}, z.core.$strip>], "type">>;
|
|
170
|
+
submitLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
171
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
export declare const HumanInputResponseValuesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodNull]>>;
|
|
174
|
+
export declare const HumanInputResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
175
|
+
submitted: z.ZodLiteral<true>;
|
|
176
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodNull]>>;
|
|
177
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
178
|
+
submitted: z.ZodLiteral<false>;
|
|
179
|
+
values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodNull]>>>;
|
|
180
|
+
}, z.core.$strip>], "submitted">;
|
|
181
|
+
export declare const HumanInputPendingRequestSchema: z.ZodObject<{
|
|
182
|
+
runId: z.ZodString;
|
|
183
|
+
toolCallId: z.ZodString;
|
|
184
|
+
request: z.ZodObject<{
|
|
185
|
+
title: z.ZodString;
|
|
186
|
+
description: z.ZodOptional<z.ZodString>;
|
|
187
|
+
fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
188
|
+
name: z.ZodString;
|
|
189
|
+
label: z.ZodString;
|
|
190
|
+
description: z.ZodOptional<z.ZodString>;
|
|
191
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
192
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
193
|
+
type: z.ZodEnum<{
|
|
194
|
+
number: "number";
|
|
195
|
+
password: "password";
|
|
196
|
+
url: "url";
|
|
197
|
+
text: "text";
|
|
198
|
+
email: "email";
|
|
199
|
+
}>;
|
|
200
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
201
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
202
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
203
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
205
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
206
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
207
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
208
|
+
name: z.ZodString;
|
|
209
|
+
label: z.ZodString;
|
|
210
|
+
description: z.ZodOptional<z.ZodString>;
|
|
211
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
212
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
213
|
+
type: z.ZodLiteral<"textarea">;
|
|
214
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
215
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
216
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
217
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
218
|
+
rows: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
219
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
220
|
+
name: z.ZodString;
|
|
221
|
+
label: z.ZodString;
|
|
222
|
+
description: z.ZodOptional<z.ZodString>;
|
|
223
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
224
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
225
|
+
type: z.ZodLiteral<"select">;
|
|
226
|
+
options: z.ZodArray<z.ZodObject<{
|
|
227
|
+
value: z.ZodString;
|
|
228
|
+
label: z.ZodString;
|
|
229
|
+
description: z.ZodOptional<z.ZodString>;
|
|
230
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
231
|
+
}, z.core.$strip>>;
|
|
232
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
233
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
234
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
235
|
+
name: z.ZodString;
|
|
236
|
+
label: z.ZodString;
|
|
237
|
+
description: z.ZodOptional<z.ZodString>;
|
|
238
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
239
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
240
|
+
type: z.ZodLiteral<"checkbox">;
|
|
241
|
+
defaultValue: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
242
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
243
|
+
name: z.ZodString;
|
|
244
|
+
label: z.ZodString;
|
|
245
|
+
description: z.ZodOptional<z.ZodString>;
|
|
246
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
247
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
248
|
+
type: z.ZodLiteral<"radio">;
|
|
249
|
+
options: z.ZodArray<z.ZodObject<{
|
|
250
|
+
value: z.ZodString;
|
|
251
|
+
label: z.ZodString;
|
|
252
|
+
description: z.ZodOptional<z.ZodString>;
|
|
253
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
254
|
+
}, z.core.$strip>>;
|
|
255
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
256
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
257
|
+
name: z.ZodString;
|
|
258
|
+
label: z.ZodString;
|
|
259
|
+
description: z.ZodOptional<z.ZodString>;
|
|
260
|
+
required: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
261
|
+
secret: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
262
|
+
type: z.ZodLiteral<"confirm">;
|
|
263
|
+
confirmLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
264
|
+
denyLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
265
|
+
}, z.core.$strip>], "type">>;
|
|
266
|
+
submitLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
267
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
268
|
+
}, z.core.$strip>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
export type HumanInputOption = z.infer<typeof HumanInputOptionSchema>;
|
|
271
|
+
export type HumanInputField = z.infer<typeof HumanInputFieldSchema>;
|
|
272
|
+
export type HumanInputFieldInput = z.input<typeof HumanInputFieldSchema>;
|
|
273
|
+
export type HumanInputRequest = z.infer<typeof HumanInputRequestSchema>;
|
|
274
|
+
export type HumanInputRequestInput = z.input<typeof HumanInputRequestSchema>;
|
|
275
|
+
export type HumanInputResult = z.infer<typeof HumanInputResultSchema>;
|
|
276
|
+
export type HumanInputPendingRequest = z.infer<typeof HumanInputPendingRequestSchema>;
|
|
277
|
+
type HumanInputResumeValue = {
|
|
278
|
+
result: unknown;
|
|
279
|
+
isError: boolean;
|
|
280
|
+
};
|
|
281
|
+
export interface WaitForHumanInputOptions {
|
|
282
|
+
sessionManager: RunResumeSessionManager<HumanInputResumeValue>;
|
|
283
|
+
runId: string;
|
|
284
|
+
toolCallId: string;
|
|
285
|
+
request: HumanInputRequestInput;
|
|
286
|
+
onRequest?: ((request: HumanInputPendingRequest) => void | Promise<void>) | undefined;
|
|
287
|
+
}
|
|
288
|
+
export declare class HumanInputResumeError extends Error {
|
|
289
|
+
readonly detail: unknown;
|
|
290
|
+
constructor(detail: unknown);
|
|
291
|
+
}
|
|
292
|
+
export declare class InvalidHumanInputResultError extends Error {
|
|
293
|
+
readonly detail: z.ZodIssue[];
|
|
294
|
+
constructor(detail: z.ZodIssue[]);
|
|
295
|
+
}
|
|
296
|
+
export declare function waitForHumanInput(options: WaitForHumanInputOptions): Promise<HumanInputResult>;
|
|
297
|
+
export {};
|
|
298
|
+
//# sourceMappingURL=human-input.d.ts.map
|
|
@@ -0,0 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B,CAAC,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAEtF,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,uBAAuB,CAAC,qBAAqB,CAAC,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,sBAAsB,CAAC;IAChC,SAAS,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CACvF;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO;gBAAf,MAAM,EAAE,OAAO;CAMrC;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;gBAApB,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAI1C;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,gBAAgB,CAAC,CAoB3B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AgUiRuntimeRunIdSchema } from "./runtime-ag-ui-contract.js";
|
|
3
|
+
const TOOL_CALL_ID_SCHEMA = z.string().min(1).max(128);
|
|
4
|
+
export const HumanInputOptionSchema = z.object({
|
|
5
|
+
value: z.string(),
|
|
6
|
+
label: z.string(),
|
|
7
|
+
description: z.string().optional(),
|
|
8
|
+
recommended: z.boolean().optional(),
|
|
9
|
+
});
|
|
10
|
+
const BaseHumanInputFieldSchema = z.object({
|
|
11
|
+
name: z.string().min(1).max(128),
|
|
12
|
+
label: z.string().min(1).max(256),
|
|
13
|
+
description: z.string().max(1024).optional(),
|
|
14
|
+
required: z.boolean().optional().default(false),
|
|
15
|
+
secret: z.boolean().optional().default(false),
|
|
16
|
+
});
|
|
17
|
+
export const HumanInputFieldSchema = z.discriminatedUnion("type", [
|
|
18
|
+
BaseHumanInputFieldSchema.extend({
|
|
19
|
+
type: z.enum(["text", "email", "url", "password", "number"]),
|
|
20
|
+
placeholder: z.string().max(512).optional(),
|
|
21
|
+
defaultValue: z.string().optional(),
|
|
22
|
+
pattern: z.string().max(512).optional(),
|
|
23
|
+
minLength: z.number().int().nonnegative().optional(),
|
|
24
|
+
maxLength: z.number().int().positive().optional(),
|
|
25
|
+
min: z.number().optional(),
|
|
26
|
+
max: z.number().optional(),
|
|
27
|
+
}),
|
|
28
|
+
BaseHumanInputFieldSchema.extend({
|
|
29
|
+
type: z.literal("textarea"),
|
|
30
|
+
placeholder: z.string().max(512).optional(),
|
|
31
|
+
defaultValue: z.string().optional(),
|
|
32
|
+
minLength: z.number().int().nonnegative().optional(),
|
|
33
|
+
maxLength: z.number().int().positive().optional(),
|
|
34
|
+
rows: z.number().int().positive().optional().default(3),
|
|
35
|
+
}),
|
|
36
|
+
BaseHumanInputFieldSchema.extend({
|
|
37
|
+
type: z.literal("select"),
|
|
38
|
+
options: z.array(HumanInputOptionSchema).min(1),
|
|
39
|
+
defaultValue: z.string().optional(),
|
|
40
|
+
placeholder: z.string().max(512).optional(),
|
|
41
|
+
}),
|
|
42
|
+
BaseHumanInputFieldSchema.extend({
|
|
43
|
+
type: z.literal("checkbox"),
|
|
44
|
+
defaultValue: z.boolean().optional().default(false),
|
|
45
|
+
}),
|
|
46
|
+
BaseHumanInputFieldSchema.extend({
|
|
47
|
+
type: z.literal("radio"),
|
|
48
|
+
options: z.array(HumanInputOptionSchema).min(1),
|
|
49
|
+
defaultValue: z.string().optional(),
|
|
50
|
+
}),
|
|
51
|
+
BaseHumanInputFieldSchema.extend({
|
|
52
|
+
type: z.literal("confirm"),
|
|
53
|
+
confirmLabel: z.string().max(64).optional().default("Yes"),
|
|
54
|
+
denyLabel: z.string().max(64).optional().default("No"),
|
|
55
|
+
}),
|
|
56
|
+
]);
|
|
57
|
+
export const HumanInputRequestSchema = z.object({
|
|
58
|
+
title: z.string().min(1).max(256),
|
|
59
|
+
description: z.string().max(2048).optional(),
|
|
60
|
+
fields: z.array(HumanInputFieldSchema).min(1),
|
|
61
|
+
submitLabel: z.string().max(64).optional().default("Submit"),
|
|
62
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
63
|
+
});
|
|
64
|
+
export const HumanInputResponseValuesSchema = z.record(z.string(), z.union([z.string(), z.boolean(), z.number(), z.null()]));
|
|
65
|
+
export const HumanInputResultSchema = z.discriminatedUnion("submitted", [
|
|
66
|
+
z.object({
|
|
67
|
+
submitted: z.literal(true),
|
|
68
|
+
values: HumanInputResponseValuesSchema,
|
|
69
|
+
}),
|
|
70
|
+
z.object({
|
|
71
|
+
submitted: z.literal(false),
|
|
72
|
+
values: HumanInputResponseValuesSchema.default({}),
|
|
73
|
+
}),
|
|
74
|
+
]);
|
|
75
|
+
export const HumanInputPendingRequestSchema = z.object({
|
|
76
|
+
runId: AgUiRuntimeRunIdSchema,
|
|
77
|
+
toolCallId: TOOL_CALL_ID_SCHEMA,
|
|
78
|
+
request: HumanInputRequestSchema,
|
|
79
|
+
});
|
|
80
|
+
export class HumanInputResumeError extends Error {
|
|
81
|
+
detail;
|
|
82
|
+
constructor(detail) {
|
|
83
|
+
super(typeof detail === "string" ? detail : "Human input resume failed");
|
|
84
|
+
this.detail = detail;
|
|
85
|
+
this.name = "HumanInputResumeError";
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export class InvalidHumanInputResultError extends Error {
|
|
89
|
+
detail;
|
|
90
|
+
constructor(detail) {
|
|
91
|
+
super("Invalid human input resume payload");
|
|
92
|
+
this.detail = detail;
|
|
93
|
+
this.name = "InvalidHumanInputResultError";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export async function waitForHumanInput(options) {
|
|
97
|
+
const pendingRequest = HumanInputPendingRequestSchema.parse({
|
|
98
|
+
runId: options.runId,
|
|
99
|
+
toolCallId: options.toolCallId,
|
|
100
|
+
request: options.request,
|
|
101
|
+
});
|
|
102
|
+
await options.onRequest?.(pendingRequest);
|
|
103
|
+
const resumed = await options.sessionManager.waitForSignal(options.runId, options.toolCallId);
|
|
104
|
+
if (resumed.isError) {
|
|
105
|
+
throw new HumanInputResumeError(resumed.result);
|
|
106
|
+
}
|
|
107
|
+
const parsed = HumanInputResultSchema.safeParse(resumed.result);
|
|
108
|
+
if (!parsed.success) {
|
|
109
|
+
throw new InvalidHumanInputResultError(parsed.error.issues);
|
|
110
|
+
}
|
|
111
|
+
return parsed.data;
|
|
112
|
+
}
|
package/esm/src/agent/index.d.ts
CHANGED
|
@@ -87,6 +87,7 @@ export { agent } from "./factory.js";
|
|
|
87
87
|
export { type AgUiRuntimeContextItem, AgUiRuntimeContextItemSchema, type AgUiRuntimeInjectedTool, AgUiRuntimeInjectedToolSchema, type AgUiRuntimeMessage, AgUiRuntimeMessageSchema, type AgUiRuntimeRequest, AgUiRuntimeRequestSchema, } from "./runtime-ag-ui-contract.js";
|
|
88
88
|
export { type AgUiCancelHandlerOptions, type AgUiResumeHandlerOptions, type AgUiResumeSignal, AgUiResumeSignalSchema, createAgUiCancelHandler, createAgUiResumeHandler, } from "./ag-ui-run-control.js";
|
|
89
89
|
export { type AgUiContextItem, type AgUiHandlerConfigWithAgent, type AgUiHandlerOptions, type AgUiInjectedTool, type AgUiRequest, AgUiRequestSchema, createAgUiHandler, } from "./ag-ui-handler.js";
|
|
90
|
+
export { type HumanInputField, type HumanInputFieldInput, HumanInputFieldSchema, type HumanInputOption, HumanInputOptionSchema, type HumanInputPendingRequest, HumanInputPendingRequestSchema, type HumanInputRequest, type HumanInputRequestInput, HumanInputRequestSchema, type HumanInputResult, HumanInputResultSchema, HumanInputResumeError, InvalidHumanInputResultError, waitForHumanInput, type WaitForHumanInputOptions, } from "./human-input.js";
|
|
90
91
|
export { type ChatHandlerBeforeStream, type ChatHandlerBeforeStreamContext, type ChatHandlerBeforeStreamResult, type ChatHandlerConfigWithAgent, type ChatHandlerMessageInput, type ChatHandlerOptions, createChatHandler, } from "./chat-handler.js";
|
|
91
92
|
export { AgentRuntime, RunAlreadyExistsError, RunCancelledError, RunNotActiveError, RunResumeSessionManager, type RunResumeSessionManagerOptions, type RunSessionStatus, type SubmitResumeValueOutcome, WaitConflictError, WaitNotPendingError, } from "./runtime/index.js";
|
|
92
93
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,OAAO,IAAI,YAAY,EACvB,WAAW,EACX,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,iBAAiB,EACtB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EACL,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,KAAK,uBAAuB,EAC5B,6BAA6B,EAC7B,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
|
package/esm/src/agent/index.js
CHANGED
|
@@ -86,5 +86,6 @@ export { agent } from "./factory.js";
|
|
|
86
86
|
export { AgUiRuntimeContextItemSchema, AgUiRuntimeInjectedToolSchema, AgUiRuntimeMessageSchema, AgUiRuntimeRequestSchema, } from "./runtime-ag-ui-contract.js";
|
|
87
87
|
export { AgUiResumeSignalSchema, createAgUiCancelHandler, createAgUiResumeHandler, } from "./ag-ui-run-control.js";
|
|
88
88
|
export { AgUiRequestSchema, createAgUiHandler, } from "./ag-ui-handler.js";
|
|
89
|
+
export { HumanInputFieldSchema, HumanInputOptionSchema, HumanInputPendingRequestSchema, HumanInputRequestSchema, HumanInputResultSchema, HumanInputResumeError, InvalidHumanInputResultError, waitForHumanInput, } from "./human-input.js";
|
|
89
90
|
export { createChatHandler, } from "./chat-handler.js";
|
|
90
91
|
export { AgentRuntime, RunAlreadyExistsError, RunCancelledError, RunNotActiveError, RunResumeSessionManager, WaitConflictError, WaitNotPendingError, } from "./runtime/index.js";
|
package/esm/src/mcp/server.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare class MCPServer {
|
|
|
34
34
|
private taskStore;
|
|
35
35
|
private pendingTasks;
|
|
36
36
|
private clientCapabilities;
|
|
37
|
+
private sessionCapabilities;
|
|
37
38
|
/** Callback for server-initiated notifications. Set by transport layer. */
|
|
38
39
|
onNotification?: (notification: {
|
|
39
40
|
jsonrpc: "2.0";
|
|
@@ -52,7 +53,7 @@ export declare class MCPServer {
|
|
|
52
53
|
* Otherwise falls back to the legacy local loading path.
|
|
53
54
|
*/
|
|
54
55
|
setIntegrationLoader(config: IntegrationLoaderConfig): void;
|
|
55
|
-
clientSupportsElicitation(mode: "form" | "url"): boolean;
|
|
56
|
+
clientSupportsElicitation(mode: "form" | "url", sessionId?: string): boolean;
|
|
56
57
|
handleRequest(request: JSONRPCRequest, context?: ToolExecutionContext): Promise<JSONRPCResponse>;
|
|
57
58
|
private dispatch;
|
|
58
59
|
private initialize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAG/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,YAAY,CAAC;AAMjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAazE,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,C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BAAkB,IAAI,IAAI;IAI1B,sBAAsB,IAAI,IAAI;IAI9B,oBAAoB,IAAI,IAAI;IAI5B;;;;;;OAMG;IACH,oBAAoB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;IAK3D,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAY5E,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IAmBhG,OAAO,CAAC,QAAQ;IAiDhB,OAAO,CAAC,UAAU;YAgCJ,SAAS;IA6BvB,OAAO,CAAC,QAAQ;IAkGhB,OAAO,CAAC,qBAAqB;IAuB7B,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,YAAY;IA6CpB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,SAAS;IAuCjB,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,SAAS;IAIjB,0EAA0E;IAC1E,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC,iBAAiB,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;IAwG5E,OAAO,CAAC,qBAAqB;YAgBf,YAAY;IAsB1B,OAAO,CAAC,cAAc;YAsBR,0BAA0B;CA0BzC;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAElE"}
|
package/esm/src/mcp/server.js
CHANGED
|
@@ -84,9 +84,8 @@ export class MCPServer {
|
|
|
84
84
|
sessionManager = new SessionManager();
|
|
85
85
|
taskStore = new TaskStore();
|
|
86
86
|
pendingTasks = new Map();
|
|
87
|
-
// TODO(#842): capabilities should be stored per-session (keyed by MCP-Session-Id)
|
|
88
|
-
// so concurrent clients don't overwrite each other's capability flags.
|
|
89
87
|
clientCapabilities = {};
|
|
88
|
+
sessionCapabilities = new Map();
|
|
90
89
|
/** Callback for server-initiated notifications. Set by transport layer. */
|
|
91
90
|
onNotification;
|
|
92
91
|
constructor(config) {
|
|
@@ -115,8 +114,11 @@ export class MCPServer {
|
|
|
115
114
|
this.integrationLoader = config;
|
|
116
115
|
this.integrationsLoaded = false;
|
|
117
116
|
}
|
|
118
|
-
clientSupportsElicitation(mode) {
|
|
119
|
-
const
|
|
117
|
+
clientSupportsElicitation(mode, sessionId) {
|
|
118
|
+
const capabilities = sessionId
|
|
119
|
+
? this.sessionCapabilities.get(sessionId) ?? {}
|
|
120
|
+
: this.clientCapabilities;
|
|
121
|
+
const raw = capabilities.elicitation;
|
|
120
122
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
121
123
|
return false;
|
|
122
124
|
const elicitation = raw;
|
|
@@ -504,8 +506,10 @@ export class MCPServer {
|
|
|
504
506
|
// DELETE = terminate session
|
|
505
507
|
if (request.method === "DELETE") {
|
|
506
508
|
const sessionId = request.headers.get("MCP-Session-Id");
|
|
507
|
-
if (sessionId)
|
|
509
|
+
if (sessionId) {
|
|
508
510
|
this.sessionManager.terminate(sessionId);
|
|
511
|
+
this.sessionCapabilities.delete(sessionId);
|
|
512
|
+
}
|
|
509
513
|
return new dntShim.Response(null, { status: 200, headers: this.getCORSHeaders(requestOrigin) });
|
|
510
514
|
}
|
|
511
515
|
// Only POST allowed for JSON-RPC messages
|
|
@@ -543,7 +547,10 @@ export class MCPServer {
|
|
|
543
547
|
if (rpcRequest.method === "initialize") {
|
|
544
548
|
const context = this.extractRequestContext(request);
|
|
545
549
|
const rpcResponse = await this.handleRequest(rpcRequest, context);
|
|
550
|
+
const clientCaps = toParamsRecord(rpcRequest.params).capabilities ??
|
|
551
|
+
{};
|
|
546
552
|
const sessionId = this.sessionManager.create();
|
|
553
|
+
this.sessionCapabilities.set(sessionId, clientCaps);
|
|
547
554
|
responseHeaders["MCP-Session-Id"] = sessionId;
|
|
548
555
|
return createJSONResponse(rpcResponse, { headers: responseHeaders });
|
|
549
556
|
}
|