taskin 1.0.11 → 1.0.13
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/dashboard-dist/assets/index-Bz7sRK8R.css +1 -0
- package/dashboard-dist/assets/index-CbgQ3MFu.js +21 -0
- package/dashboard-dist/index.html +2 -2
- package/dist/index.js +2636 -924
- package/package.json +24 -23
- package/dashboard-dist/assets/index-BUUmUx2c.js +0 -21
- package/dashboard-dist/assets/index-C7xLvQXX.css +0 -1
package/dist/index.js
CHANGED
|
@@ -38,12 +38,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
mod
|
|
39
39
|
));
|
|
40
40
|
|
|
41
|
-
// ../../node_modules/.pnpm/tsup@8.5.
|
|
41
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
|
|
42
42
|
import path from "path";
|
|
43
43
|
import { fileURLToPath } from "url";
|
|
44
44
|
var getFilename, getDirname, __dirname;
|
|
45
45
|
var init_esm_shims = __esm({
|
|
46
|
-
"../../node_modules/.pnpm/tsup@8.5.
|
|
46
|
+
"../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
47
47
|
"use strict";
|
|
48
48
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
49
49
|
getDirname = () => path.dirname(getFilename());
|
|
@@ -51,6 +51,48 @@ var init_esm_shims = __esm({
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
+
// ../fs-task-provider/dist/i18n.js
|
|
55
|
+
function getI18n(locale = "en-US") {
|
|
56
|
+
return i18nConfig[locale];
|
|
57
|
+
}
|
|
58
|
+
function detectLocale(content) {
|
|
59
|
+
if (content.includes("## Descri\xE7\xE3o") || content.includes("## Tipo") || content.includes("## Respons\xE1vel") || content.includes("## Tarefas")) {
|
|
60
|
+
return "pt-BR";
|
|
61
|
+
}
|
|
62
|
+
return "en-US";
|
|
63
|
+
}
|
|
64
|
+
var i18nConfig;
|
|
65
|
+
var init_i18n = __esm({
|
|
66
|
+
"../fs-task-provider/dist/i18n.js"() {
|
|
67
|
+
"use strict";
|
|
68
|
+
init_esm_shims();
|
|
69
|
+
i18nConfig = {
|
|
70
|
+
"en-US": {
|
|
71
|
+
status: "Status",
|
|
72
|
+
type: "Type",
|
|
73
|
+
assignee: "Assignee",
|
|
74
|
+
description: "Description",
|
|
75
|
+
tasks: "Tasks",
|
|
76
|
+
notes: "Notes",
|
|
77
|
+
defaultAssignee: "To be defined",
|
|
78
|
+
descriptionPlaceholder: "Add task description here...",
|
|
79
|
+
notesPlaceholder: "Add any relevant notes or links here."
|
|
80
|
+
},
|
|
81
|
+
"pt-BR": {
|
|
82
|
+
status: "Status",
|
|
83
|
+
type: "Tipo",
|
|
84
|
+
assignee: "Respons\xE1vel",
|
|
85
|
+
description: "Descri\xE7\xE3o",
|
|
86
|
+
tasks: "Tarefas",
|
|
87
|
+
notes: "Notas",
|
|
88
|
+
defaultAssignee: "A definir",
|
|
89
|
+
descriptionPlaceholder: "Adicione a descri\xE7\xE3o da tarefa aqui...",
|
|
90
|
+
notesPlaceholder: "Adicione notas ou links relevantes aqui."
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
54
96
|
// ../fs-task-provider/dist/task-validator.js
|
|
55
97
|
var task_validator_exports = {};
|
|
56
98
|
__export(task_validator_exports, {
|
|
@@ -62,47 +104,97 @@ import { readFile, writeFile } from "fs/promises";
|
|
|
62
104
|
async function fixTaskFile(filePath) {
|
|
63
105
|
try {
|
|
64
106
|
const content = await readFile(filePath, "utf-8");
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
107
|
+
const locale = detectLocale(content);
|
|
108
|
+
const i18n = getI18n(locale);
|
|
109
|
+
const statusPattern = new RegExp(
|
|
110
|
+
`##\\s*(?:Status|${i18n.status})\\s*\\n\\s*([^\\n\\r]+)`,
|
|
111
|
+
"i"
|
|
112
|
+
);
|
|
113
|
+
const typePattern = new RegExp(
|
|
114
|
+
`##\\s*(?:Type|${i18n.type})\\s*\\n\\s*([^\\n\\r]+)`,
|
|
115
|
+
"i"
|
|
116
|
+
);
|
|
117
|
+
const assigneePattern = new RegExp(
|
|
118
|
+
`##\\s*(?:Assignee|${i18n.assignee})\\s*\\n\\s*([^\\n\\r]+)`,
|
|
119
|
+
"i"
|
|
120
|
+
);
|
|
121
|
+
const hasSectionStatus = statusPattern.test(content);
|
|
122
|
+
const hasSectionType = typePattern.test(content);
|
|
123
|
+
const hasSectionAssignee = assigneePattern.test(content);
|
|
124
|
+
const inlineStatusPattern = /^(Status|Tipo):\s*(.+?)(\s*)$/im;
|
|
125
|
+
const inlineTypePattern = /^(Type|Tipo):\s*(.+?)(\s*)$/im;
|
|
126
|
+
const inlineAssigneePattern = /^(Assignee|Responsável):\s*(.+?)(\s*)$/im;
|
|
127
|
+
const hasInlineStatus = inlineStatusPattern.test(content);
|
|
128
|
+
const hasInlineType = inlineTypePattern.test(content);
|
|
129
|
+
const hasInlineAssignee = inlineAssigneePattern.test(content);
|
|
130
|
+
const needsSpaceFix = hasInlineStatus && !/^(?:Status|Tipo):.+ $/im.test(content) || hasInlineType && !/^(?:Type|Tipo):.+ $/im.test(content) || hasInlineAssignee && !/^(?:Assignee|Responsável):.+ $/im.test(content);
|
|
131
|
+
if (!hasSectionStatus && !hasSectionType && !hasSectionAssignee && !needsSpaceFix) {
|
|
69
132
|
return false;
|
|
70
133
|
}
|
|
71
|
-
const statusMatch = content.match(/^Status:\s*(.+)$/im);
|
|
72
|
-
const typeMatch = content.match(/^Type:\s*(.+)$/im);
|
|
73
|
-
const assigneeMatch = content.match(/^Assignee:\s*(.+)$/im);
|
|
74
134
|
let newContent = content;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
135
|
+
let wasModified = false;
|
|
136
|
+
if (hasSectionStatus || hasSectionType || hasSectionAssignee) {
|
|
137
|
+
const statusMatch = content.match(statusPattern);
|
|
138
|
+
const typeMatch = content.match(typePattern);
|
|
139
|
+
const assigneeMatch = content.match(assigneePattern);
|
|
140
|
+
if (statusMatch) {
|
|
141
|
+
newContent = newContent.replace(statusPattern, "");
|
|
142
|
+
}
|
|
143
|
+
if (typeMatch) {
|
|
144
|
+
newContent = newContent.replace(typePattern, "");
|
|
145
|
+
}
|
|
146
|
+
if (assigneeMatch) {
|
|
147
|
+
newContent = newContent.replace(assigneePattern, "");
|
|
148
|
+
}
|
|
149
|
+
newContent = newContent.replace(/\n{3,}/g, "\n\n");
|
|
150
|
+
const titleLineIdx = newContent.split("\n").findIndex((line) => line.trim().startsWith("# "));
|
|
151
|
+
if (titleLineIdx === -1) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
const contentLines = newContent.split("\n");
|
|
155
|
+
const beforeTitle = contentLines.slice(0, titleLineIdx + 1);
|
|
156
|
+
const afterTitle = contentLines.slice(titleLineIdx + 1);
|
|
157
|
+
const inlineMetadata = [];
|
|
158
|
+
if (statusMatch) {
|
|
159
|
+
inlineMetadata.push(`Status: ${statusMatch[1].trim()} `);
|
|
160
|
+
}
|
|
161
|
+
if (typeMatch) {
|
|
162
|
+
inlineMetadata.push(`Type: ${typeMatch[1].trim()} `);
|
|
163
|
+
}
|
|
164
|
+
if (assigneeMatch) {
|
|
165
|
+
inlineMetadata.push(`Assignee: ${assigneeMatch[1].trim()} `);
|
|
166
|
+
}
|
|
167
|
+
newContent = [
|
|
168
|
+
...beforeTitle,
|
|
169
|
+
"",
|
|
170
|
+
...inlineMetadata,
|
|
171
|
+
"",
|
|
172
|
+
...afterTitle
|
|
173
|
+
].join("\n");
|
|
174
|
+
wasModified = true;
|
|
175
|
+
}
|
|
176
|
+
if (needsSpaceFix) {
|
|
177
|
+
newContent = newContent.replace(/^(# .+)\n([^#\n])/m, "$1\n\n$2");
|
|
178
|
+
newContent = newContent.replace(
|
|
179
|
+
/^(Status|Tipo):\s*(.+?)(\s*)$/im,
|
|
180
|
+
(_, key, value) => `${key}: ${value.trim()} `
|
|
181
|
+
);
|
|
182
|
+
newContent = newContent.replace(
|
|
183
|
+
/^(Type|Tipo):\s*(.+?)(\s*)$/im,
|
|
184
|
+
(_, key, value) => `${key}: ${value.trim()} `
|
|
185
|
+
);
|
|
186
|
+
newContent = newContent.replace(
|
|
187
|
+
/^(Assignee|Responsável):\s*(.+?)(\s*)$/im,
|
|
188
|
+
(_, key, value) => `${key}: ${value.trim()} `
|
|
189
|
+
);
|
|
190
|
+
wasModified = true;
|
|
98
191
|
}
|
|
99
|
-
if (
|
|
100
|
-
|
|
192
|
+
if (wasModified) {
|
|
193
|
+
const finalContent = newContent.replace(/\n{3,}/g, "\n\n").trim() + "\n";
|
|
194
|
+
await writeFile(filePath, finalContent, "utf-8");
|
|
195
|
+
return true;
|
|
101
196
|
}
|
|
102
|
-
|
|
103
|
-
const finalContent = fixed.replace(/\n{3,}/g, "\n\n").trim() + "\n";
|
|
104
|
-
await writeFile(filePath, finalContent, "utf-8");
|
|
105
|
-
return true;
|
|
197
|
+
return false;
|
|
106
198
|
} catch (error2) {
|
|
107
199
|
console.error(`Failed to fix ${filePath}:`, error2);
|
|
108
200
|
return false;
|
|
@@ -113,9 +205,19 @@ async function validateTaskFile(filePath) {
|
|
|
113
205
|
try {
|
|
114
206
|
const content = await readFile(filePath, "utf-8");
|
|
115
207
|
const lines = content.split("\n");
|
|
208
|
+
const locale = detectLocale(content);
|
|
209
|
+
const i18n = getI18n(locale);
|
|
116
210
|
const hasTitleSection = lines.some((line) => line.trim().startsWith("# "));
|
|
117
|
-
const
|
|
118
|
-
|
|
211
|
+
const inlineStatusPattern = new RegExp(
|
|
212
|
+
`^(?:Status|${i18n.status}):\\s*.+$`,
|
|
213
|
+
"im"
|
|
214
|
+
);
|
|
215
|
+
const sectionStatusPattern = new RegExp(
|
|
216
|
+
`##\\s*(?:Status|${i18n.status})`,
|
|
217
|
+
"i"
|
|
218
|
+
);
|
|
219
|
+
const hasInlineStatus = inlineStatusPattern.test(content);
|
|
220
|
+
const hasSectionStatus = sectionStatusPattern.test(content);
|
|
119
221
|
const hasDescriptionSection = content.includes("## Description") || content.includes("## Descri\xE7\xE3o");
|
|
120
222
|
if (!hasTitleSection) {
|
|
121
223
|
issues.push({
|
|
@@ -126,38 +228,47 @@ async function validateTaskFile(filePath) {
|
|
|
126
228
|
suggestion: "Add a level-1 heading at the start: # Your Task Title"
|
|
127
229
|
});
|
|
128
230
|
}
|
|
129
|
-
if (
|
|
231
|
+
if (hasSectionStatus) {
|
|
130
232
|
const statusLineIdx = lines.findIndex(
|
|
131
|
-
(line) =>
|
|
233
|
+
(line) => sectionStatusPattern.test(line.trim())
|
|
132
234
|
);
|
|
133
235
|
issues.push({
|
|
134
236
|
file: filePath,
|
|
135
237
|
line: statusLineIdx >= 0 ? statusLineIdx + 1 : void 0,
|
|
136
|
-
message: '
|
|
238
|
+
message: 'Section-based metadata ("## Status") is not allowed. Use inline format instead.',
|
|
137
239
|
severity: "error",
|
|
138
|
-
suggestion:
|
|
240
|
+
suggestion: `Replace section with inline metadata:
|
|
241
|
+
${i18n.status}: <todo|in-progress|done>`
|
|
139
242
|
});
|
|
140
243
|
}
|
|
141
|
-
if (!
|
|
244
|
+
if (!hasInlineStatus) {
|
|
142
245
|
issues.push({
|
|
143
246
|
file: filePath,
|
|
144
|
-
message: "Task file must have a
|
|
247
|
+
message: "Task file must have a Status field",
|
|
145
248
|
severity: "error",
|
|
146
|
-
suggestion:
|
|
249
|
+
suggestion: `Add inline metadata after title:
|
|
250
|
+
${i18n.status}: <todo|in-progress|done>`
|
|
147
251
|
});
|
|
148
252
|
} else {
|
|
149
|
-
const statusMatch = content.match(
|
|
150
|
-
const statusValue = statusMatch ? statusMatch[1]
|
|
151
|
-
if (![
|
|
253
|
+
const statusMatch = content.match(inlineStatusPattern);
|
|
254
|
+
const statusValue = statusMatch ? statusMatch[0].split(":")[1]?.trim().toLowerCase() || "" : "";
|
|
255
|
+
if (![
|
|
256
|
+
"todo",
|
|
257
|
+
"in-progress",
|
|
258
|
+
"done",
|
|
259
|
+
"pending",
|
|
260
|
+
"blocked",
|
|
261
|
+
"canceled"
|
|
262
|
+
].includes(statusValue)) {
|
|
152
263
|
const statusLineIdx = lines.findIndex(
|
|
153
|
-
(line) => line.trim()
|
|
264
|
+
(line) => inlineStatusPattern.test(line.trim())
|
|
154
265
|
);
|
|
155
266
|
issues.push({
|
|
156
267
|
file: filePath,
|
|
157
|
-
line: statusLineIdx >= 0 ? statusLineIdx +
|
|
158
|
-
message: "Status must be one of: todo, in-progress, done, pending",
|
|
268
|
+
line: statusLineIdx >= 0 ? statusLineIdx + 1 : void 0,
|
|
269
|
+
message: "Status must be one of: todo, in-progress, done, pending, blocked, canceled",
|
|
159
270
|
severity: "error",
|
|
160
|
-
suggestion: "Set status to: todo, in-progress, done, or
|
|
271
|
+
suggestion: "Set status to: todo, in-progress, done, pending, blocked, or canceled"
|
|
161
272
|
});
|
|
162
273
|
}
|
|
163
274
|
}
|
|
@@ -219,6 +330,7 @@ var init_task_validator = __esm({
|
|
|
219
330
|
"../fs-task-provider/dist/task-validator.js"() {
|
|
220
331
|
"use strict";
|
|
221
332
|
init_esm_shims();
|
|
333
|
+
init_i18n();
|
|
222
334
|
}
|
|
223
335
|
});
|
|
224
336
|
|
|
@@ -7063,47 +7175,10 @@ init_esm_shims();
|
|
|
7063
7175
|
|
|
7064
7176
|
// ../fs-task-provider/dist/fs-task-provider.js
|
|
7065
7177
|
init_esm_shims();
|
|
7178
|
+
init_i18n();
|
|
7179
|
+
init_task_validator();
|
|
7066
7180
|
import { promises as fs } from "fs";
|
|
7067
7181
|
import path2 from "path";
|
|
7068
|
-
|
|
7069
|
-
// ../fs-task-provider/dist/i18n.js
|
|
7070
|
-
init_esm_shims();
|
|
7071
|
-
var i18nConfig = {
|
|
7072
|
-
"en-US": {
|
|
7073
|
-
status: "Status",
|
|
7074
|
-
type: "Type",
|
|
7075
|
-
assignee: "Assignee",
|
|
7076
|
-
description: "Description",
|
|
7077
|
-
tasks: "Tasks",
|
|
7078
|
-
notes: "Notes",
|
|
7079
|
-
defaultAssignee: "To be defined",
|
|
7080
|
-
descriptionPlaceholder: "Add task description here...",
|
|
7081
|
-
notesPlaceholder: "Add any relevant notes or links here."
|
|
7082
|
-
},
|
|
7083
|
-
"pt-BR": {
|
|
7084
|
-
status: "Status",
|
|
7085
|
-
type: "Tipo",
|
|
7086
|
-
assignee: "Respons\xE1vel",
|
|
7087
|
-
description: "Descri\xE7\xE3o",
|
|
7088
|
-
tasks: "Tarefas",
|
|
7089
|
-
notes: "Notas",
|
|
7090
|
-
defaultAssignee: "A definir",
|
|
7091
|
-
descriptionPlaceholder: "Adicione a descri\xE7\xE3o da tarefa aqui...",
|
|
7092
|
-
notesPlaceholder: "Adicione notas ou links relevantes aqui."
|
|
7093
|
-
}
|
|
7094
|
-
};
|
|
7095
|
-
function getI18n(locale = "en-US") {
|
|
7096
|
-
return i18nConfig[locale];
|
|
7097
|
-
}
|
|
7098
|
-
function detectLocale(content) {
|
|
7099
|
-
if (content.includes("## Descri\xE7\xE3o") || content.includes("## Tipo") || content.includes("## Respons\xE1vel") || content.includes("## Tarefas")) {
|
|
7100
|
-
return "pt-BR";
|
|
7101
|
-
}
|
|
7102
|
-
return "en-US";
|
|
7103
|
-
}
|
|
7104
|
-
|
|
7105
|
-
// ../fs-task-provider/dist/fs-task-provider.js
|
|
7106
|
-
init_task_validator();
|
|
7107
7182
|
var FileSystemTaskProvider = class {
|
|
7108
7183
|
tasksDirectory;
|
|
7109
7184
|
userRegistry;
|
|
@@ -7127,18 +7202,19 @@ var FileSystemTaskProvider = class {
|
|
|
7127
7202
|
const title = titleMatch ? titleMatch[1].trim() : "Untitled";
|
|
7128
7203
|
const contentLocale = detectLocale(content);
|
|
7129
7204
|
const i18n = getI18n(contentLocale);
|
|
7130
|
-
const
|
|
7205
|
+
const extractInline = (name, localizedName) => {
|
|
7131
7206
|
const names = localizedName && localizedName !== name ? [localizedName, name] : [name];
|
|
7132
7207
|
for (const n of names) {
|
|
7133
|
-
const
|
|
7208
|
+
const escapedName = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7209
|
+
const rx = new RegExp(`^${escapedName}:\\s*(.+)$`, "im");
|
|
7134
7210
|
const m = content.match(rx);
|
|
7135
7211
|
if (m) return m[1].trim();
|
|
7136
7212
|
}
|
|
7137
7213
|
return null;
|
|
7138
7214
|
};
|
|
7139
|
-
const statusMatch =
|
|
7140
|
-
const typeMatch =
|
|
7141
|
-
const assigneeMatch =
|
|
7215
|
+
const statusMatch = extractInline("Status", i18n.status);
|
|
7216
|
+
const typeMatch = extractInline("Type", i18n.type);
|
|
7217
|
+
const assigneeMatch = extractInline("Assignee", i18n.assignee);
|
|
7142
7218
|
let assignee;
|
|
7143
7219
|
if (assigneeMatch) {
|
|
7144
7220
|
const assigneeValue = assigneeMatch.trim();
|
|
@@ -7164,26 +7240,24 @@ var FileSystemTaskProvider = class {
|
|
|
7164
7240
|
}
|
|
7165
7241
|
async updateTask(task) {
|
|
7166
7242
|
const currentContent = await fs.readFile(task.filePath, "utf-8");
|
|
7167
|
-
const
|
|
7243
|
+
const hasSectionMetadata = /##\s*(Status|Type|Assignee)/i.test(
|
|
7168
7244
|
currentContent
|
|
7169
7245
|
);
|
|
7170
|
-
if (
|
|
7246
|
+
if (hasSectionMetadata) {
|
|
7171
7247
|
const { fixTaskFile: fixTaskFile2 } = await Promise.resolve().then(() => (init_task_validator(), task_validator_exports));
|
|
7172
7248
|
await fixTaskFile2(task.filePath);
|
|
7173
7249
|
}
|
|
7174
7250
|
const content = await fs.readFile(task.filePath, "utf-8");
|
|
7175
7251
|
let updatedContent;
|
|
7176
|
-
if (
|
|
7252
|
+
if (/^Status:\s*.+$/im.test(content)) {
|
|
7177
7253
|
updatedContent = content.replace(
|
|
7178
|
-
|
|
7179
|
-
|
|
7254
|
+
/^Status:\s*.+$/im,
|
|
7255
|
+
`Status: ${task.status} `
|
|
7180
7256
|
);
|
|
7181
7257
|
} else {
|
|
7182
7258
|
updatedContent = content.replace(
|
|
7183
7259
|
/(^#.*\n)/,
|
|
7184
|
-
`$
|
|
7185
|
-
## Status
|
|
7186
|
-
${task.status}
|
|
7260
|
+
`$1Status: ${task.status}
|
|
7187
7261
|
`
|
|
7188
7262
|
);
|
|
7189
7263
|
}
|
|
@@ -7204,18 +7278,19 @@ ${task.status}
|
|
|
7204
7278
|
const title = titleMatch ? titleMatch[1].trim() : "Untitled";
|
|
7205
7279
|
const contentLocale = detectLocale(content);
|
|
7206
7280
|
const i18n = getI18n(contentLocale);
|
|
7207
|
-
const
|
|
7281
|
+
const extractInline = (name, localizedName) => {
|
|
7208
7282
|
const names = localizedName && localizedName !== name ? [localizedName, name] : [name];
|
|
7209
7283
|
for (const n of names) {
|
|
7210
|
-
const
|
|
7284
|
+
const escapedName = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7285
|
+
const rx = new RegExp(`^${escapedName}:\\s*(.+)$`, "im");
|
|
7211
7286
|
const m = content.match(rx);
|
|
7212
7287
|
if (m) return m[1].trim();
|
|
7213
7288
|
}
|
|
7214
7289
|
return null;
|
|
7215
7290
|
};
|
|
7216
|
-
const statusMatch =
|
|
7217
|
-
const typeMatch =
|
|
7218
|
-
const assigneeMatch =
|
|
7291
|
+
const statusMatch = extractInline("Status", i18n.status);
|
|
7292
|
+
const typeMatch = extractInline("Type", i18n.type);
|
|
7293
|
+
const assigneeMatch = extractInline("Assignee", i18n.assignee);
|
|
7219
7294
|
let assignee;
|
|
7220
7295
|
if (assigneeMatch) {
|
|
7221
7296
|
const assigneeValue = assigneeMatch.trim();
|
|
@@ -7239,8 +7314,13 @@ ${task.status}
|
|
|
7239
7314
|
return tasks;
|
|
7240
7315
|
}
|
|
7241
7316
|
async createTask(options) {
|
|
7242
|
-
const i18n = getI18n(this.locale);
|
|
7243
7317
|
const allTasks = await this.getAllTasks();
|
|
7318
|
+
let detectedLocale = this.locale;
|
|
7319
|
+
if (allTasks.length > 0) {
|
|
7320
|
+
const lastTask = allTasks[allTasks.length - 1];
|
|
7321
|
+
detectedLocale = detectLocale(lastTask.content);
|
|
7322
|
+
}
|
|
7323
|
+
const i18n = getI18n(detectedLocale);
|
|
7244
7324
|
const taskNumbers = allTasks.map((task2) => {
|
|
7245
7325
|
const match = task2.id.match(/^(\d+)$/);
|
|
7246
7326
|
return match ? parseInt(match[1], 10) : 0;
|
|
@@ -7284,30 +7364,19 @@ ${task.status}
|
|
|
7284
7364
|
const { id, title, type, description, assignee, i18n } = data;
|
|
7285
7365
|
return `# \u{1F9E9} Task ${id} \u2014 ${title}
|
|
7286
7366
|
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
## ${i18n.type}
|
|
7292
|
-
|
|
7293
|
-
${type}
|
|
7294
|
-
|
|
7295
|
-
## ${i18n.assignee}
|
|
7296
|
-
|
|
7297
|
-
${assignee}
|
|
7367
|
+
${i18n.status}: pending
|
|
7368
|
+
${i18n.type}: ${type}
|
|
7369
|
+
${i18n.assignee}: ${assignee}
|
|
7298
7370
|
|
|
7299
7371
|
## ${i18n.description}
|
|
7300
|
-
|
|
7301
7372
|
${description || i18n.descriptionPlaceholder}
|
|
7302
7373
|
|
|
7303
7374
|
## ${i18n.tasks}
|
|
7304
|
-
|
|
7305
7375
|
- [ ] Task 1
|
|
7306
7376
|
- [ ] Task 2
|
|
7307
7377
|
- [ ] Task 3
|
|
7308
7378
|
|
|
7309
7379
|
## ${i18n.notes}
|
|
7310
|
-
|
|
7311
7380
|
${i18n.notesPlaceholder}
|
|
7312
7381
|
`;
|
|
7313
7382
|
}
|
|
@@ -7335,6 +7404,9 @@ ${i18n.notesPlaceholder}
|
|
|
7335
7404
|
}
|
|
7336
7405
|
};
|
|
7337
7406
|
|
|
7407
|
+
// ../fs-task-provider/dist/index.js
|
|
7408
|
+
init_i18n();
|
|
7409
|
+
|
|
7338
7410
|
// ../fs-task-provider/dist/user-registry.js
|
|
7339
7411
|
init_esm_shims();
|
|
7340
7412
|
import { promises as fs2 } from "fs";
|
|
@@ -7834,38 +7906,41 @@ init_esm_shims();
|
|
|
7834
7906
|
// ../utils/dist/security.js
|
|
7835
7907
|
init_esm_shims();
|
|
7836
7908
|
import { z } from "zod";
|
|
7837
|
-
var HostSchema = z.string().refine(
|
|
7838
|
-
|
|
7839
|
-
return false;
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
})
|
|
7909
|
+
var HostSchema = z.string().refine(
|
|
7910
|
+
(host) => {
|
|
7911
|
+
if (!host || host.length === 0) return false;
|
|
7912
|
+
if (host === "localhost") return true;
|
|
7913
|
+
const parts = host.split(".");
|
|
7914
|
+
const allNumeric = parts.every((p) => /^\d+$/.test(p));
|
|
7915
|
+
if (allNumeric) {
|
|
7916
|
+
if (parts.length !== 4) return false;
|
|
7917
|
+
return parts.every((part) => {
|
|
7918
|
+
const num = parseInt(part, 10);
|
|
7919
|
+
return !isNaN(num) && num >= 0 && num <= 255 && part === num.toString();
|
|
7920
|
+
});
|
|
7921
|
+
}
|
|
7922
|
+
const hostnameRegex = /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
7923
|
+
return hostnameRegex.test(host);
|
|
7924
|
+
},
|
|
7925
|
+
{
|
|
7926
|
+
message: "Invalid host. Must be localhost, a valid IPv4 address, or hostname."
|
|
7851
7927
|
}
|
|
7852
|
-
|
|
7853
|
-
return hostnameRegex.test(host);
|
|
7854
|
-
}, {
|
|
7855
|
-
message: "Invalid host. Must be localhost, a valid IPv4 address, or hostname."
|
|
7856
|
-
});
|
|
7928
|
+
);
|
|
7857
7929
|
var PortSchema = z.union([
|
|
7858
7930
|
z.number().int().min(1).max(65535),
|
|
7859
7931
|
z.string().regex(/^\d+$/).transform((val) => parseInt(val, 10)).pipe(z.number().int().min(1).max(65535))
|
|
7860
7932
|
]);
|
|
7861
|
-
var WebSocketUrlSchema = z.string().refine(
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
}
|
|
7933
|
+
var WebSocketUrlSchema = z.string().refine(
|
|
7934
|
+
(url) => {
|
|
7935
|
+
try {
|
|
7936
|
+
const parsed = new URL(url);
|
|
7937
|
+
return parsed.protocol === "ws:" || parsed.protocol === "wss:";
|
|
7938
|
+
} catch {
|
|
7939
|
+
return false;
|
|
7940
|
+
}
|
|
7941
|
+
},
|
|
7942
|
+
{ message: "Invalid WebSocket URL. Must use ws:// or wss:// protocol." }
|
|
7943
|
+
);
|
|
7869
7944
|
var TaskIdSchema = z.string().min(1).max(100).regex(/^[a-zA-Z0-9_-]+$/, {
|
|
7870
7945
|
message: "Task ID must contain only alphanumeric characters, hyphens, and underscores."
|
|
7871
7946
|
});
|
|
@@ -7873,23 +7948,25 @@ var UserIdSchema = z.string().min(1).max(100).regex(/^[a-zA-Z0-9._-]+$/, {
|
|
|
7873
7948
|
message: "User ID must contain only alphanumeric characters, dots, hyphens, and underscores."
|
|
7874
7949
|
});
|
|
7875
7950
|
var EmailSchema = z.string().email().max(254);
|
|
7876
|
-
var SafePathSchema = z.string().refine(
|
|
7877
|
-
|
|
7878
|
-
return false;
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
},
|
|
7891
|
-
|
|
7892
|
-
|
|
7951
|
+
var SafePathSchema = z.string().refine(
|
|
7952
|
+
(filePath) => {
|
|
7953
|
+
if (!filePath || filePath.length === 0) return false;
|
|
7954
|
+
const dangerousPatterns = [
|
|
7955
|
+
/\.\./,
|
|
7956
|
+
// Parent directory (..)
|
|
7957
|
+
/~\//,
|
|
7958
|
+
// Home directory
|
|
7959
|
+
/^\//,
|
|
7960
|
+
// Absolute path
|
|
7961
|
+
/^[A-Za-z]:\\/
|
|
7962
|
+
// Windows absolute path
|
|
7963
|
+
];
|
|
7964
|
+
return !dangerousPatterns.some((pattern) => pattern.test(filePath));
|
|
7965
|
+
},
|
|
7966
|
+
{
|
|
7967
|
+
message: "Invalid path. Must be a relative path without traversal patterns."
|
|
7968
|
+
}
|
|
7969
|
+
);
|
|
7893
7970
|
var DashboardOptionsSchema = z.object({
|
|
7894
7971
|
host: HostSchema.optional(),
|
|
7895
7972
|
port: PortSchema.optional(),
|
|
@@ -8319,7 +8396,13 @@ async function finishTask(taskId, options) {
|
|
|
8319
8396
|
|
|
8320
8397
|
// src/commands/init.ts
|
|
8321
8398
|
init_esm_shims();
|
|
8322
|
-
import {
|
|
8399
|
+
import {
|
|
8400
|
+
existsSync as existsSync4,
|
|
8401
|
+
mkdirSync,
|
|
8402
|
+
readFileSync,
|
|
8403
|
+
readdirSync,
|
|
8404
|
+
writeFileSync
|
|
8405
|
+
} from "fs";
|
|
8323
8406
|
import inquirer from "inquirer";
|
|
8324
8407
|
import { join } from "path";
|
|
8325
8408
|
|
|
@@ -8603,7 +8686,7 @@ async function initializeTaskin(options) {
|
|
|
8603
8686
|
success(`\u2713 Created ${colors2.highlight(".taskin.json")}`);
|
|
8604
8687
|
const gitignorePath = join(cwd, ".gitignore");
|
|
8605
8688
|
if (existsSync4(gitignorePath)) {
|
|
8606
|
-
const gitignoreContent =
|
|
8689
|
+
const gitignoreContent = readFileSync(gitignorePath, "utf-8");
|
|
8607
8690
|
if (!gitignoreContent.includes(".taskin.json")) {
|
|
8608
8691
|
info("Adding .taskin.json to .gitignore...");
|
|
8609
8692
|
writeFileSync(
|
|
@@ -8666,8 +8749,14 @@ async function setupFileSystemProvider(cwd) {
|
|
|
8666
8749
|
info(`${colors2.highlight("TASKS/")} directory already exists`);
|
|
8667
8750
|
success("\u2713 Directory is ready to use");
|
|
8668
8751
|
}
|
|
8669
|
-
const
|
|
8670
|
-
|
|
8752
|
+
const existingTask001 = readdirSync(tasksDir).find(
|
|
8753
|
+
(file) => file.startsWith("task-001-") && file.endsWith(".md")
|
|
8754
|
+
);
|
|
8755
|
+
if (existingTask001) {
|
|
8756
|
+
info(`Sample task already exists: ${colors2.highlight(existingTask001)}`);
|
|
8757
|
+
info("Skipping sample task creation (users already know the pattern)");
|
|
8758
|
+
} else {
|
|
8759
|
+
const sampleTaskFile = join(tasksDir, "task-001-setup-project.md");
|
|
8671
8760
|
info("Creating sample task...");
|
|
8672
8761
|
const sampleTask = `# Task 001 \u2014 Setup Project
|
|
8673
8762
|
|
|
@@ -8701,303 +8790,59 @@ You can edit or delete this file. Use \`taskin list\` to see all tasks.
|
|
|
8701
8790
|
|
|
8702
8791
|
// src/commands/lint.ts
|
|
8703
8792
|
init_esm_shims();
|
|
8704
|
-
import { join as join3 } from "path";
|
|
8705
|
-
|
|
8706
|
-
// src/lib/file-system-task-linter/index.ts
|
|
8707
|
-
init_esm_shims();
|
|
8708
|
-
|
|
8709
|
-
// src/lib/file-system-task-linter/file-system-task-linter.ts
|
|
8710
|
-
init_esm_shims();
|
|
8711
8793
|
import chalk4 from "chalk";
|
|
8712
|
-
import { readdir, readFile as readFile2 } from "fs/promises";
|
|
8713
8794
|
import { join as join2 } from "path";
|
|
8714
|
-
var
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
if (!pattern.test(fileName)) {
|
|
8727
|
-
return {
|
|
8728
|
-
file: fileName,
|
|
8729
|
-
message: "Invalid filename. Expected: task-NNN-kebab-case-title.md",
|
|
8730
|
-
severity: "error"
|
|
8731
|
-
};
|
|
8795
|
+
var lintCommand = defineCommand({
|
|
8796
|
+
name: "lint",
|
|
8797
|
+
description: "\u{1F50D} Validate task markdown files",
|
|
8798
|
+
options: [
|
|
8799
|
+
{
|
|
8800
|
+
flags: "-p, --path <directory>",
|
|
8801
|
+
description: "Path to TASKS directory",
|
|
8802
|
+
defaultValue: "TASKS"
|
|
8803
|
+
},
|
|
8804
|
+
{
|
|
8805
|
+
flags: "-f, --fix",
|
|
8806
|
+
description: "Automatically fix task file format issues"
|
|
8732
8807
|
}
|
|
8733
|
-
|
|
8808
|
+
],
|
|
8809
|
+
handler: async (options) => {
|
|
8810
|
+
await executeLint(options);
|
|
8734
8811
|
}
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
};
|
|
8812
|
+
});
|
|
8813
|
+
async function executeLint(options) {
|
|
8814
|
+
const tasksDir = options.path || join2(process.cwd(), "TASKS");
|
|
8815
|
+
if (options.fix) {
|
|
8816
|
+
console.log(`\u{1F527} Fixing task files in: ${tasksDir}
|
|
8817
|
+
`);
|
|
8818
|
+
} else {
|
|
8819
|
+
console.log(`\u{1F4CB} Linting task files in: ${tasksDir}
|
|
8820
|
+
`);
|
|
8745
8821
|
}
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
severity: "error"
|
|
8762
|
-
});
|
|
8763
|
-
}
|
|
8764
|
-
if (!metadata.type) {
|
|
8765
|
-
errors.push({
|
|
8766
|
-
file: filePath,
|
|
8767
|
-
message: "Missing required metadata: Type",
|
|
8768
|
-
severity: "error"
|
|
8769
|
-
});
|
|
8770
|
-
} else if (!VALID_TYPES.includes(metadata.type)) {
|
|
8771
|
-
errors.push({
|
|
8772
|
-
file: filePath,
|
|
8773
|
-
message: `Invalid type "${metadata.type}". Valid: ${VALID_TYPES.join(", ")}`,
|
|
8774
|
-
severity: "error"
|
|
8775
|
-
});
|
|
8776
|
-
}
|
|
8777
|
-
if (!metadata.assignee) {
|
|
8778
|
-
errors.push({
|
|
8779
|
-
file: filePath,
|
|
8780
|
-
message: "Missing recommended metadata: Assignee",
|
|
8781
|
-
severity: "warning"
|
|
8782
|
-
});
|
|
8822
|
+
const userRegistry = new UserRegistry({
|
|
8823
|
+
taskinDir: join2(process.cwd(), ".taskin")
|
|
8824
|
+
});
|
|
8825
|
+
await userRegistry.load();
|
|
8826
|
+
const provider = new FileSystemTaskProvider(tasksDir, userRegistry);
|
|
8827
|
+
const result = await provider.lint(options.fix);
|
|
8828
|
+
if (result.valid) {
|
|
8829
|
+
console.log(chalk4.green(`\u2705 All task files are valid!
|
|
8830
|
+
`));
|
|
8831
|
+
} else {
|
|
8832
|
+
console.log(chalk4.red(`
|
|
8833
|
+
\u274C Found ${result.issues.length} issue(s):
|
|
8834
|
+
`));
|
|
8835
|
+
for (const issue of result.issues) {
|
|
8836
|
+
console.log(chalk4.yellow(` ${issue.file}: ${issue.message}`));
|
|
8783
8837
|
}
|
|
8784
|
-
|
|
8838
|
+
console.log();
|
|
8785
8839
|
}
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
"error",
|
|
8793
|
-
1
|
|
8794
|
-
);
|
|
8795
|
-
}
|
|
8796
|
-
const h1Pattern = /^#\s+(?:🧩\s+)?Task\s+\d{2,3}\s+[—-]\s+.+$/i;
|
|
8797
|
-
if (lines[0] && !h1Pattern.test(lines[0])) {
|
|
8798
|
-
this.addError(
|
|
8799
|
-
filename,
|
|
8800
|
-
'H1 heading must follow format: "# Task NNN \u2014 Title"',
|
|
8801
|
-
"error",
|
|
8802
|
-
1
|
|
8803
|
-
);
|
|
8804
|
-
}
|
|
8805
|
-
const metadata = this.extractMetadata(content);
|
|
8806
|
-
const metadataErrors = this.validateMetadata(metadata, filename);
|
|
8807
|
-
metadataErrors.forEach((error2) => {
|
|
8808
|
-
this.addError(error2.file, error2.message, error2.severity, error2.line);
|
|
8809
|
-
});
|
|
8810
|
-
const h2Sections = content.match(/^##\s+.+$/gm);
|
|
8811
|
-
if (!h2Sections || h2Sections.length === 0) {
|
|
8812
|
-
this.addError(
|
|
8813
|
-
filename,
|
|
8814
|
-
"Task should have at least one section (## heading)",
|
|
8815
|
-
"warning"
|
|
8816
|
-
);
|
|
8817
|
-
}
|
|
8818
|
-
const firstH2Index = content.indexOf("\n##");
|
|
8819
|
-
if (firstH2Index > -1) {
|
|
8820
|
-
const afterH2 = content.substring(firstH2Index);
|
|
8821
|
-
if (afterH2.match(/^Status:/im) || afterH2.match(/^Type:/im) || afterH2.match(/^Assignee:/im)) {
|
|
8822
|
-
this.addError(
|
|
8823
|
-
filename,
|
|
8824
|
-
"Metadata must be placed BEFORE the first ## section",
|
|
8825
|
-
"error"
|
|
8826
|
-
);
|
|
8827
|
-
}
|
|
8828
|
-
}
|
|
8829
|
-
}
|
|
8830
|
-
/**
|
|
8831
|
-
* Lint a single task file (FileSystem-specific)
|
|
8832
|
-
*/
|
|
8833
|
-
async lintFile(filePath) {
|
|
8834
|
-
const errors = [];
|
|
8835
|
-
const fileName = filePath.split("/").pop() || filePath;
|
|
8836
|
-
const fileNameError = this.validateFileName(fileName);
|
|
8837
|
-
if (fileNameError) {
|
|
8838
|
-
errors.push(fileNameError);
|
|
8839
|
-
}
|
|
8840
|
-
try {
|
|
8841
|
-
const content = await readFile2(filePath, "utf-8");
|
|
8842
|
-
this.errors = [];
|
|
8843
|
-
this.validateContent(fileName, content);
|
|
8844
|
-
errors.push(...this.errors);
|
|
8845
|
-
} catch (error2) {
|
|
8846
|
-
errors.push({
|
|
8847
|
-
file: fileName,
|
|
8848
|
-
message: `Failed to read file: ${error2}`,
|
|
8849
|
-
severity: "error"
|
|
8850
|
-
});
|
|
8851
|
-
}
|
|
8852
|
-
return errors;
|
|
8853
|
-
}
|
|
8854
|
-
/**
|
|
8855
|
-
* Lint all task files in the specified directory (FileSystem-specific)
|
|
8856
|
-
*/
|
|
8857
|
-
async lintDirectory(tasksDir) {
|
|
8858
|
-
this.errors = [];
|
|
8859
|
-
try {
|
|
8860
|
-
const files = await readdir(tasksDir);
|
|
8861
|
-
const taskFiles = files.filter((f) => f.endsWith(".md"));
|
|
8862
|
-
for (const file of taskFiles) {
|
|
8863
|
-
const fileNameError = this.validateFileName(file);
|
|
8864
|
-
if (fileNameError) {
|
|
8865
|
-
this.addError(file, fileNameError.message, fileNameError.severity);
|
|
8866
|
-
}
|
|
8867
|
-
const content = await readFile2(join2(tasksDir, file), "utf-8");
|
|
8868
|
-
this.validateContent(file, content);
|
|
8869
|
-
}
|
|
8870
|
-
const errors = this.errors.filter((e) => e.severity === "error");
|
|
8871
|
-
const warnings = this.errors.filter((e) => e.severity === "warning");
|
|
8872
|
-
return {
|
|
8873
|
-
errors,
|
|
8874
|
-
warnings,
|
|
8875
|
-
filesChecked: taskFiles.length,
|
|
8876
|
-
valid: errors.length === 0
|
|
8877
|
-
};
|
|
8878
|
-
} catch (error2) {
|
|
8879
|
-
throw new Error(`Failed to lint tasks: ${error2}`);
|
|
8880
|
-
}
|
|
8881
|
-
}
|
|
8882
|
-
static printResults(result) {
|
|
8883
|
-
if (result.errors.length === 0 && result.warnings.length === 0) {
|
|
8884
|
-
console.log(
|
|
8885
|
-
chalk4.green(`\u2705 All ${result.filesChecked} task files are valid!
|
|
8886
|
-
`)
|
|
8887
|
-
);
|
|
8888
|
-
return;
|
|
8889
|
-
}
|
|
8890
|
-
console.log(
|
|
8891
|
-
chalk4.bold(
|
|
8892
|
-
`
|
|
8893
|
-
\u{1F4CA} Validation Results (${result.filesChecked} files checked):
|
|
8894
|
-
`
|
|
8895
|
-
)
|
|
8896
|
-
);
|
|
8897
|
-
const errorsByFile = /* @__PURE__ */ new Map();
|
|
8898
|
-
[...result.errors, ...result.warnings].forEach((error2) => {
|
|
8899
|
-
if (!errorsByFile.has(error2.file)) {
|
|
8900
|
-
errorsByFile.set(error2.file, []);
|
|
8901
|
-
}
|
|
8902
|
-
errorsByFile.get(error2.file).push(error2);
|
|
8903
|
-
});
|
|
8904
|
-
for (const [file, fileErrors] of errorsByFile) {
|
|
8905
|
-
console.log(chalk4.cyan(`
|
|
8906
|
-
\u{1F4C4} ${file}`));
|
|
8907
|
-
for (const error2 of fileErrors) {
|
|
8908
|
-
const icon = error2.severity === "error" ? chalk4.red("\u274C") : chalk4.yellow("\u26A0\uFE0F");
|
|
8909
|
-
const location = error2.line ? `:${error2.line}` : "";
|
|
8910
|
-
console.log(` ${icon} ${error2.message}${location}`);
|
|
8911
|
-
}
|
|
8912
|
-
}
|
|
8913
|
-
console.log("\n" + "\u2500".repeat(60));
|
|
8914
|
-
console.log(
|
|
8915
|
-
chalk4.bold(
|
|
8916
|
-
`
|
|
8917
|
-
\u{1F4CA} Summary: ${chalk4.red(result.errors.length + " error(s)")}, ${chalk4.yellow(result.warnings.length + " warning(s)")}
|
|
8918
|
-
`
|
|
8919
|
-
)
|
|
8920
|
-
);
|
|
8921
|
-
}
|
|
8922
|
-
};
|
|
8923
|
-
|
|
8924
|
-
// src/lib/file-system-task-linter/file-system-task-linter.mock.ts
|
|
8925
|
-
init_esm_shims();
|
|
8926
|
-
function createMockFileValidationError(overrides) {
|
|
8927
|
-
return {
|
|
8928
|
-
file: "task-001.md",
|
|
8929
|
-
message: "Mock validation error",
|
|
8930
|
-
severity: "error",
|
|
8931
|
-
...overrides
|
|
8932
|
-
};
|
|
8933
|
-
}
|
|
8934
|
-
var MOCK_INVALID_LINT_RESULT = {
|
|
8935
|
-
errors: [
|
|
8936
|
-
createMockFileValidationError({
|
|
8937
|
-
file: "task-001.md",
|
|
8938
|
-
message: 'Invalid status: "invalid"'
|
|
8939
|
-
}),
|
|
8940
|
-
createMockFileValidationError({
|
|
8941
|
-
file: "task-002.md",
|
|
8942
|
-
message: 'Invalid type: "unknown"'
|
|
8943
|
-
})
|
|
8944
|
-
],
|
|
8945
|
-
filesChecked: 2,
|
|
8946
|
-
valid: false,
|
|
8947
|
-
warnings: []
|
|
8948
|
-
};
|
|
8949
|
-
var MOCK_WARNINGS_LINT_RESULT = {
|
|
8950
|
-
errors: [],
|
|
8951
|
-
filesChecked: 3,
|
|
8952
|
-
valid: true,
|
|
8953
|
-
warnings: [
|
|
8954
|
-
createMockFileValidationError({
|
|
8955
|
-
file: "task-003.md",
|
|
8956
|
-
message: "Consider adding assignee",
|
|
8957
|
-
severity: "warning"
|
|
8958
|
-
})
|
|
8959
|
-
]
|
|
8960
|
-
};
|
|
8961
|
-
var MOCK_VALIDATION_ERRORS = [
|
|
8962
|
-
createMockFileValidationError({
|
|
8963
|
-
file: "task-001.md",
|
|
8964
|
-
message: "Invalid status: must be one of [pending, in-progress, done, blocked]",
|
|
8965
|
-
line: 5
|
|
8966
|
-
}),
|
|
8967
|
-
createMockFileValidationError({
|
|
8968
|
-
file: "task-001.md",
|
|
8969
|
-
message: "Invalid type: must be one of [feat, fix, chore, docs, refactor, test]",
|
|
8970
|
-
line: 6
|
|
8971
|
-
})
|
|
8972
|
-
];
|
|
8973
|
-
|
|
8974
|
-
// src/lib/file-system-task-linter/file-system-task-linter.types.ts
|
|
8975
|
-
init_esm_shims();
|
|
8976
|
-
|
|
8977
|
-
// src/commands/lint.ts
|
|
8978
|
-
var lintCommand = defineCommand({
|
|
8979
|
-
name: "lint",
|
|
8980
|
-
description: "\u{1F50D} Validate task markdown files",
|
|
8981
|
-
options: [
|
|
8982
|
-
{
|
|
8983
|
-
flags: "-p, --path <directory>",
|
|
8984
|
-
description: "Path to TASKS directory",
|
|
8985
|
-
defaultValue: "TASKS"
|
|
8986
|
-
}
|
|
8987
|
-
],
|
|
8988
|
-
handler: async (options) => {
|
|
8989
|
-
await executeLint(options);
|
|
8990
|
-
}
|
|
8991
|
-
});
|
|
8992
|
-
async function executeLint(options) {
|
|
8993
|
-
const tasksDir = options.path || join3(process.cwd(), "TASKS");
|
|
8994
|
-
console.log(`\u{1F4CB} Linting task files in: ${tasksDir}
|
|
8995
|
-
`);
|
|
8996
|
-
const linter = new FileSystemTaskLinter();
|
|
8997
|
-
const result = await linter.lintDirectory(tasksDir);
|
|
8998
|
-
FileSystemTaskLinter.printResults(result);
|
|
8999
|
-
if (!result.valid) {
|
|
9000
|
-
process.exit(1);
|
|
8840
|
+
if (!result.valid && !options.fix) {
|
|
8841
|
+
console.log(
|
|
8842
|
+
chalk4.blue(`\u{1F4A1} Run with --fix to automatically fix format issues
|
|
8843
|
+
`)
|
|
8844
|
+
);
|
|
8845
|
+
process.exit(1);
|
|
9001
8846
|
}
|
|
9002
8847
|
}
|
|
9003
8848
|
|
|
@@ -9132,67 +8977,173 @@ init_esm_shims();
|
|
|
9132
8977
|
// ../task-server-mcp/dist/task-server-mcp.js
|
|
9133
8978
|
init_esm_shims();
|
|
9134
8979
|
|
|
9135
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
8980
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
8981
|
+
init_esm_shims();
|
|
8982
|
+
|
|
8983
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
9136
8984
|
init_esm_shims();
|
|
9137
8985
|
|
|
9138
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
8986
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
9139
8987
|
init_esm_shims();
|
|
8988
|
+
import * as z3rt from "zod/v3";
|
|
8989
|
+
import * as z4mini from "zod/v4-mini";
|
|
8990
|
+
function isZ4Schema(s) {
|
|
8991
|
+
const schema = s;
|
|
8992
|
+
return !!schema._zod;
|
|
8993
|
+
}
|
|
8994
|
+
function safeParse2(schema, data) {
|
|
8995
|
+
if (isZ4Schema(schema)) {
|
|
8996
|
+
const result2 = z4mini.safeParse(schema, data);
|
|
8997
|
+
return result2;
|
|
8998
|
+
}
|
|
8999
|
+
const v3Schema = schema;
|
|
9000
|
+
const result = v3Schema.safeParse(data);
|
|
9001
|
+
return result;
|
|
9002
|
+
}
|
|
9003
|
+
function getObjectShape(schema) {
|
|
9004
|
+
if (!schema)
|
|
9005
|
+
return void 0;
|
|
9006
|
+
let rawShape;
|
|
9007
|
+
if (isZ4Schema(schema)) {
|
|
9008
|
+
const v4Schema = schema;
|
|
9009
|
+
rawShape = v4Schema._zod?.def?.shape;
|
|
9010
|
+
} else {
|
|
9011
|
+
const v3Schema = schema;
|
|
9012
|
+
rawShape = v3Schema.shape;
|
|
9013
|
+
}
|
|
9014
|
+
if (!rawShape)
|
|
9015
|
+
return void 0;
|
|
9016
|
+
if (typeof rawShape === "function") {
|
|
9017
|
+
try {
|
|
9018
|
+
return rawShape();
|
|
9019
|
+
} catch {
|
|
9020
|
+
return void 0;
|
|
9021
|
+
}
|
|
9022
|
+
}
|
|
9023
|
+
return rawShape;
|
|
9024
|
+
}
|
|
9025
|
+
function getLiteralValue(schema) {
|
|
9026
|
+
if (isZ4Schema(schema)) {
|
|
9027
|
+
const v4Schema = schema;
|
|
9028
|
+
const def2 = v4Schema._zod?.def;
|
|
9029
|
+
if (def2) {
|
|
9030
|
+
if (def2.value !== void 0)
|
|
9031
|
+
return def2.value;
|
|
9032
|
+
if (Array.isArray(def2.values) && def2.values.length > 0) {
|
|
9033
|
+
return def2.values[0];
|
|
9034
|
+
}
|
|
9035
|
+
}
|
|
9036
|
+
}
|
|
9037
|
+
const v3Schema = schema;
|
|
9038
|
+
const def = v3Schema._def;
|
|
9039
|
+
if (def) {
|
|
9040
|
+
if (def.value !== void 0)
|
|
9041
|
+
return def.value;
|
|
9042
|
+
if (Array.isArray(def.values) && def.values.length > 0) {
|
|
9043
|
+
return def.values[0];
|
|
9044
|
+
}
|
|
9045
|
+
}
|
|
9046
|
+
const directValue = schema.value;
|
|
9047
|
+
if (directValue !== void 0)
|
|
9048
|
+
return directValue;
|
|
9049
|
+
return void 0;
|
|
9050
|
+
}
|
|
9140
9051
|
|
|
9141
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
9052
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
9142
9053
|
init_esm_shims();
|
|
9143
|
-
import
|
|
9144
|
-
var LATEST_PROTOCOL_VERSION = "2025-
|
|
9145
|
-
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
9054
|
+
import * as z2 from "zod/v4";
|
|
9055
|
+
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
9056
|
+
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
9057
|
+
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
9146
9058
|
var JSONRPC_VERSION = "2.0";
|
|
9059
|
+
var AssertObjectSchema = z2.custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
9147
9060
|
var ProgressTokenSchema = z2.union([z2.string(), z2.number().int()]);
|
|
9148
9061
|
var CursorSchema = z2.string();
|
|
9149
|
-
var
|
|
9062
|
+
var TaskCreationParamsSchema = z2.looseObject({
|
|
9063
|
+
/**
|
|
9064
|
+
* Time in milliseconds to keep task results available after completion.
|
|
9065
|
+
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
9066
|
+
*/
|
|
9067
|
+
ttl: z2.union([z2.number(), z2.null()]).optional(),
|
|
9068
|
+
/**
|
|
9069
|
+
* Time in milliseconds to wait between task status requests.
|
|
9070
|
+
*/
|
|
9071
|
+
pollInterval: z2.number().optional()
|
|
9072
|
+
});
|
|
9073
|
+
var TaskMetadataSchema = z2.object({
|
|
9074
|
+
ttl: z2.number().optional()
|
|
9075
|
+
});
|
|
9076
|
+
var RelatedTaskMetadataSchema = z2.object({
|
|
9077
|
+
taskId: z2.string()
|
|
9078
|
+
});
|
|
9079
|
+
var RequestMetaSchema = z2.looseObject({
|
|
9150
9080
|
/**
|
|
9151
9081
|
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
|
|
9152
9082
|
*/
|
|
9153
|
-
progressToken:
|
|
9154
|
-
|
|
9083
|
+
progressToken: ProgressTokenSchema.optional(),
|
|
9084
|
+
/**
|
|
9085
|
+
* If specified, this request is related to the provided task.
|
|
9086
|
+
*/
|
|
9087
|
+
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
9088
|
+
});
|
|
9155
9089
|
var BaseRequestParamsSchema = z2.object({
|
|
9156
|
-
|
|
9157
|
-
|
|
9090
|
+
/**
|
|
9091
|
+
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
9092
|
+
*/
|
|
9093
|
+
_meta: RequestMetaSchema.optional()
|
|
9094
|
+
});
|
|
9095
|
+
var TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
9096
|
+
/**
|
|
9097
|
+
* If specified, the caller is requesting task-augmented execution for this request.
|
|
9098
|
+
* The request will return a CreateTaskResult immediately, and the actual result can be
|
|
9099
|
+
* retrieved later via tasks/result.
|
|
9100
|
+
*
|
|
9101
|
+
* Task augmentation is subject to capability negotiation - receivers MUST declare support
|
|
9102
|
+
* for task augmentation of specific request types in their capabilities.
|
|
9103
|
+
*/
|
|
9104
|
+
task: TaskMetadataSchema.optional()
|
|
9105
|
+
});
|
|
9106
|
+
var isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
|
|
9158
9107
|
var RequestSchema = z2.object({
|
|
9159
9108
|
method: z2.string(),
|
|
9160
|
-
params:
|
|
9109
|
+
params: BaseRequestParamsSchema.loose().optional()
|
|
9161
9110
|
});
|
|
9162
|
-
var
|
|
9111
|
+
var NotificationsParamsSchema = z2.object({
|
|
9163
9112
|
/**
|
|
9164
9113
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9165
9114
|
* for notes on _meta usage.
|
|
9166
9115
|
*/
|
|
9167
|
-
_meta:
|
|
9168
|
-
})
|
|
9116
|
+
_meta: RequestMetaSchema.optional()
|
|
9117
|
+
});
|
|
9169
9118
|
var NotificationSchema = z2.object({
|
|
9170
9119
|
method: z2.string(),
|
|
9171
|
-
params:
|
|
9120
|
+
params: NotificationsParamsSchema.loose().optional()
|
|
9172
9121
|
});
|
|
9173
|
-
var ResultSchema = z2.
|
|
9122
|
+
var ResultSchema = z2.looseObject({
|
|
9174
9123
|
/**
|
|
9175
9124
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9176
9125
|
* for notes on _meta usage.
|
|
9177
9126
|
*/
|
|
9178
|
-
_meta:
|
|
9179
|
-
})
|
|
9127
|
+
_meta: RequestMetaSchema.optional()
|
|
9128
|
+
});
|
|
9180
9129
|
var RequestIdSchema = z2.union([z2.string(), z2.number().int()]);
|
|
9181
9130
|
var JSONRPCRequestSchema = z2.object({
|
|
9182
9131
|
jsonrpc: z2.literal(JSONRPC_VERSION),
|
|
9183
|
-
id: RequestIdSchema
|
|
9184
|
-
|
|
9132
|
+
id: RequestIdSchema,
|
|
9133
|
+
...RequestSchema.shape
|
|
9134
|
+
}).strict();
|
|
9185
9135
|
var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
|
|
9186
9136
|
var JSONRPCNotificationSchema = z2.object({
|
|
9187
|
-
jsonrpc: z2.literal(JSONRPC_VERSION)
|
|
9188
|
-
|
|
9137
|
+
jsonrpc: z2.literal(JSONRPC_VERSION),
|
|
9138
|
+
...NotificationSchema.shape
|
|
9139
|
+
}).strict();
|
|
9189
9140
|
var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
|
|
9190
|
-
var
|
|
9141
|
+
var JSONRPCResultResponseSchema = z2.object({
|
|
9191
9142
|
jsonrpc: z2.literal(JSONRPC_VERSION),
|
|
9192
9143
|
id: RequestIdSchema,
|
|
9193
9144
|
result: ResultSchema
|
|
9194
9145
|
}).strict();
|
|
9195
|
-
var
|
|
9146
|
+
var isJSONRPCResultResponse = (value) => JSONRPCResultResponseSchema.safeParse(value).success;
|
|
9196
9147
|
var ErrorCode;
|
|
9197
9148
|
(function(ErrorCode2) {
|
|
9198
9149
|
ErrorCode2[ErrorCode2["ConnectionClosed"] = -32e3] = "ConnectionClosed";
|
|
@@ -9202,10 +9153,11 @@ var ErrorCode;
|
|
|
9202
9153
|
ErrorCode2[ErrorCode2["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
9203
9154
|
ErrorCode2[ErrorCode2["InvalidParams"] = -32602] = "InvalidParams";
|
|
9204
9155
|
ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
|
|
9156
|
+
ErrorCode2[ErrorCode2["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
9205
9157
|
})(ErrorCode || (ErrorCode = {}));
|
|
9206
|
-
var
|
|
9158
|
+
var JSONRPCErrorResponseSchema = z2.object({
|
|
9207
9159
|
jsonrpc: z2.literal(JSONRPC_VERSION),
|
|
9208
|
-
id: RequestIdSchema,
|
|
9160
|
+
id: RequestIdSchema.optional(),
|
|
9209
9161
|
error: z2.object({
|
|
9210
9162
|
/**
|
|
9211
9163
|
* The error type that occurred.
|
|
@@ -9218,26 +9170,33 @@ var JSONRPCErrorSchema = z2.object({
|
|
|
9218
9170
|
/**
|
|
9219
9171
|
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
|
|
9220
9172
|
*/
|
|
9221
|
-
data: z2.
|
|
9173
|
+
data: z2.unknown().optional()
|
|
9222
9174
|
})
|
|
9223
9175
|
}).strict();
|
|
9224
|
-
var
|
|
9225
|
-
var JSONRPCMessageSchema = z2.union([
|
|
9176
|
+
var isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success;
|
|
9177
|
+
var JSONRPCMessageSchema = z2.union([
|
|
9178
|
+
JSONRPCRequestSchema,
|
|
9179
|
+
JSONRPCNotificationSchema,
|
|
9180
|
+
JSONRPCResultResponseSchema,
|
|
9181
|
+
JSONRPCErrorResponseSchema
|
|
9182
|
+
]);
|
|
9183
|
+
var JSONRPCResponseSchema = z2.union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
9226
9184
|
var EmptyResultSchema = ResultSchema.strict();
|
|
9185
|
+
var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
9186
|
+
/**
|
|
9187
|
+
* The ID of the request to cancel.
|
|
9188
|
+
*
|
|
9189
|
+
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
9190
|
+
*/
|
|
9191
|
+
requestId: RequestIdSchema.optional(),
|
|
9192
|
+
/**
|
|
9193
|
+
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
9194
|
+
*/
|
|
9195
|
+
reason: z2.string().optional()
|
|
9196
|
+
});
|
|
9227
9197
|
var CancelledNotificationSchema = NotificationSchema.extend({
|
|
9228
9198
|
method: z2.literal("notifications/cancelled"),
|
|
9229
|
-
params:
|
|
9230
|
-
/**
|
|
9231
|
-
* The ID of the request to cancel.
|
|
9232
|
-
*
|
|
9233
|
-
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
9234
|
-
*/
|
|
9235
|
-
requestId: RequestIdSchema,
|
|
9236
|
-
/**
|
|
9237
|
-
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
9238
|
-
*/
|
|
9239
|
-
reason: z2.string().optional()
|
|
9240
|
-
})
|
|
9199
|
+
params: CancelledNotificationParamsSchema
|
|
9241
9200
|
});
|
|
9242
9201
|
var IconSchema = z2.object({
|
|
9243
9202
|
/**
|
|
@@ -9247,15 +9206,23 @@ var IconSchema = z2.object({
|
|
|
9247
9206
|
/**
|
|
9248
9207
|
* Optional MIME type for the icon.
|
|
9249
9208
|
*/
|
|
9250
|
-
mimeType: z2.
|
|
9209
|
+
mimeType: z2.string().optional(),
|
|
9251
9210
|
/**
|
|
9252
9211
|
* Optional array of strings that specify sizes at which the icon can be used.
|
|
9253
9212
|
* Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
|
|
9254
9213
|
*
|
|
9255
9214
|
* If not provided, the client should assume that the icon can be used at any size.
|
|
9256
9215
|
*/
|
|
9257
|
-
sizes: z2.
|
|
9258
|
-
|
|
9216
|
+
sizes: z2.array(z2.string()).optional(),
|
|
9217
|
+
/**
|
|
9218
|
+
* Optional specifier for the theme this icon is designed for. `light` indicates
|
|
9219
|
+
* the icon is designed to be used with a light background, and `dark` indicates
|
|
9220
|
+
* the icon is designed to be used with a dark background.
|
|
9221
|
+
*
|
|
9222
|
+
* If not provided, the client should assume the icon can be used with any theme.
|
|
9223
|
+
*/
|
|
9224
|
+
theme: z2.enum(["light", "dark"]).optional()
|
|
9225
|
+
});
|
|
9259
9226
|
var IconsSchema = z2.object({
|
|
9260
9227
|
/**
|
|
9261
9228
|
* Optional set of sized icons that the client can display in a user interface.
|
|
@@ -9269,7 +9236,7 @@ var IconsSchema = z2.object({
|
|
|
9269
9236
|
* - `image/webp` - WebP images (modern, efficient format)
|
|
9270
9237
|
*/
|
|
9271
9238
|
icons: z2.array(IconSchema).optional()
|
|
9272
|
-
})
|
|
9239
|
+
});
|
|
9273
9240
|
var BaseMetadataSchema = z2.object({
|
|
9274
9241
|
/** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
|
|
9275
9242
|
name: z2.string(),
|
|
@@ -9281,94 +9248,185 @@ var BaseMetadataSchema = z2.object({
|
|
|
9281
9248
|
* where `annotations.title` should be given precedence over using `name`,
|
|
9282
9249
|
* if present).
|
|
9283
9250
|
*/
|
|
9284
|
-
title: z2.
|
|
9285
|
-
})
|
|
9251
|
+
title: z2.string().optional()
|
|
9252
|
+
});
|
|
9286
9253
|
var ImplementationSchema = BaseMetadataSchema.extend({
|
|
9254
|
+
...BaseMetadataSchema.shape,
|
|
9255
|
+
...IconsSchema.shape,
|
|
9287
9256
|
version: z2.string(),
|
|
9288
9257
|
/**
|
|
9289
9258
|
* An optional URL of the website for this implementation.
|
|
9290
9259
|
*/
|
|
9291
|
-
websiteUrl: z2.
|
|
9292
|
-
|
|
9260
|
+
websiteUrl: z2.string().optional(),
|
|
9261
|
+
/**
|
|
9262
|
+
* An optional human-readable description of what this implementation does.
|
|
9263
|
+
*
|
|
9264
|
+
* This can be used by clients or servers to provide context about their purpose
|
|
9265
|
+
* and capabilities. For example, a server might describe the types of resources
|
|
9266
|
+
* or tools it provides, while a client might describe its intended use case.
|
|
9267
|
+
*/
|
|
9268
|
+
description: z2.string().optional()
|
|
9269
|
+
});
|
|
9270
|
+
var FormElicitationCapabilitySchema = z2.intersection(z2.object({
|
|
9271
|
+
applyDefaults: z2.boolean().optional()
|
|
9272
|
+
}), z2.record(z2.string(), z2.unknown()));
|
|
9273
|
+
var ElicitationCapabilitySchema = z2.preprocess((value) => {
|
|
9274
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
9275
|
+
if (Object.keys(value).length === 0) {
|
|
9276
|
+
return { form: {} };
|
|
9277
|
+
}
|
|
9278
|
+
}
|
|
9279
|
+
return value;
|
|
9280
|
+
}, z2.intersection(z2.object({
|
|
9281
|
+
form: FormElicitationCapabilitySchema.optional(),
|
|
9282
|
+
url: AssertObjectSchema.optional()
|
|
9283
|
+
}), z2.record(z2.string(), z2.unknown()).optional()));
|
|
9284
|
+
var ClientTasksCapabilitySchema = z2.looseObject({
|
|
9285
|
+
/**
|
|
9286
|
+
* Present if the client supports listing tasks.
|
|
9287
|
+
*/
|
|
9288
|
+
list: AssertObjectSchema.optional(),
|
|
9289
|
+
/**
|
|
9290
|
+
* Present if the client supports cancelling tasks.
|
|
9291
|
+
*/
|
|
9292
|
+
cancel: AssertObjectSchema.optional(),
|
|
9293
|
+
/**
|
|
9294
|
+
* Capabilities for task creation on specific request types.
|
|
9295
|
+
*/
|
|
9296
|
+
requests: z2.looseObject({
|
|
9297
|
+
/**
|
|
9298
|
+
* Task support for sampling requests.
|
|
9299
|
+
*/
|
|
9300
|
+
sampling: z2.looseObject({
|
|
9301
|
+
createMessage: AssertObjectSchema.optional()
|
|
9302
|
+
}).optional(),
|
|
9303
|
+
/**
|
|
9304
|
+
* Task support for elicitation requests.
|
|
9305
|
+
*/
|
|
9306
|
+
elicitation: z2.looseObject({
|
|
9307
|
+
create: AssertObjectSchema.optional()
|
|
9308
|
+
}).optional()
|
|
9309
|
+
}).optional()
|
|
9310
|
+
});
|
|
9311
|
+
var ServerTasksCapabilitySchema = z2.looseObject({
|
|
9312
|
+
/**
|
|
9313
|
+
* Present if the server supports listing tasks.
|
|
9314
|
+
*/
|
|
9315
|
+
list: AssertObjectSchema.optional(),
|
|
9316
|
+
/**
|
|
9317
|
+
* Present if the server supports cancelling tasks.
|
|
9318
|
+
*/
|
|
9319
|
+
cancel: AssertObjectSchema.optional(),
|
|
9320
|
+
/**
|
|
9321
|
+
* Capabilities for task creation on specific request types.
|
|
9322
|
+
*/
|
|
9323
|
+
requests: z2.looseObject({
|
|
9324
|
+
/**
|
|
9325
|
+
* Task support for tool requests.
|
|
9326
|
+
*/
|
|
9327
|
+
tools: z2.looseObject({
|
|
9328
|
+
call: AssertObjectSchema.optional()
|
|
9329
|
+
}).optional()
|
|
9330
|
+
}).optional()
|
|
9331
|
+
});
|
|
9293
9332
|
var ClientCapabilitiesSchema = z2.object({
|
|
9294
9333
|
/**
|
|
9295
9334
|
* Experimental, non-standard capabilities that the client supports.
|
|
9296
9335
|
*/
|
|
9297
|
-
experimental: z2.
|
|
9336
|
+
experimental: z2.record(z2.string(), AssertObjectSchema).optional(),
|
|
9298
9337
|
/**
|
|
9299
9338
|
* Present if the client supports sampling from an LLM.
|
|
9300
9339
|
*/
|
|
9301
|
-
sampling: z2.
|
|
9340
|
+
sampling: z2.object({
|
|
9341
|
+
/**
|
|
9342
|
+
* Present if the client supports context inclusion via includeContext parameter.
|
|
9343
|
+
* If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
|
|
9344
|
+
*/
|
|
9345
|
+
context: AssertObjectSchema.optional(),
|
|
9346
|
+
/**
|
|
9347
|
+
* Present if the client supports tool use via tools and toolChoice parameters.
|
|
9348
|
+
*/
|
|
9349
|
+
tools: AssertObjectSchema.optional()
|
|
9350
|
+
}).optional(),
|
|
9302
9351
|
/**
|
|
9303
9352
|
* Present if the client supports eliciting user input.
|
|
9304
9353
|
*/
|
|
9305
|
-
elicitation:
|
|
9354
|
+
elicitation: ElicitationCapabilitySchema.optional(),
|
|
9306
9355
|
/**
|
|
9307
9356
|
* Present if the client supports listing roots.
|
|
9308
9357
|
*/
|
|
9309
|
-
roots: z2.
|
|
9358
|
+
roots: z2.object({
|
|
9310
9359
|
/**
|
|
9311
9360
|
* Whether the client supports issuing notifications for changes to the roots list.
|
|
9312
9361
|
*/
|
|
9313
|
-
listChanged: z2.
|
|
9314
|
-
}).
|
|
9315
|
-
|
|
9362
|
+
listChanged: z2.boolean().optional()
|
|
9363
|
+
}).optional(),
|
|
9364
|
+
/**
|
|
9365
|
+
* Present if the client supports task creation.
|
|
9366
|
+
*/
|
|
9367
|
+
tasks: ClientTasksCapabilitySchema.optional()
|
|
9368
|
+
});
|
|
9369
|
+
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
9370
|
+
/**
|
|
9371
|
+
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
|
|
9372
|
+
*/
|
|
9373
|
+
protocolVersion: z2.string(),
|
|
9374
|
+
capabilities: ClientCapabilitiesSchema,
|
|
9375
|
+
clientInfo: ImplementationSchema
|
|
9376
|
+
});
|
|
9316
9377
|
var InitializeRequestSchema = RequestSchema.extend({
|
|
9317
9378
|
method: z2.literal("initialize"),
|
|
9318
|
-
params:
|
|
9319
|
-
/**
|
|
9320
|
-
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
|
|
9321
|
-
*/
|
|
9322
|
-
protocolVersion: z2.string(),
|
|
9323
|
-
capabilities: ClientCapabilitiesSchema,
|
|
9324
|
-
clientInfo: ImplementationSchema
|
|
9325
|
-
})
|
|
9379
|
+
params: InitializeRequestParamsSchema
|
|
9326
9380
|
});
|
|
9327
9381
|
var ServerCapabilitiesSchema = z2.object({
|
|
9328
9382
|
/**
|
|
9329
9383
|
* Experimental, non-standard capabilities that the server supports.
|
|
9330
9384
|
*/
|
|
9331
|
-
experimental: z2.
|
|
9385
|
+
experimental: z2.record(z2.string(), AssertObjectSchema).optional(),
|
|
9332
9386
|
/**
|
|
9333
9387
|
* Present if the server supports sending log messages to the client.
|
|
9334
9388
|
*/
|
|
9335
|
-
logging:
|
|
9389
|
+
logging: AssertObjectSchema.optional(),
|
|
9336
9390
|
/**
|
|
9337
9391
|
* Present if the server supports sending completions to the client.
|
|
9338
9392
|
*/
|
|
9339
|
-
completions:
|
|
9393
|
+
completions: AssertObjectSchema.optional(),
|
|
9340
9394
|
/**
|
|
9341
9395
|
* Present if the server offers any prompt templates.
|
|
9342
9396
|
*/
|
|
9343
|
-
prompts: z2.
|
|
9397
|
+
prompts: z2.object({
|
|
9344
9398
|
/**
|
|
9345
9399
|
* Whether this server supports issuing notifications for changes to the prompt list.
|
|
9346
9400
|
*/
|
|
9347
|
-
listChanged: z2.
|
|
9348
|
-
}).
|
|
9401
|
+
listChanged: z2.boolean().optional()
|
|
9402
|
+
}).optional(),
|
|
9349
9403
|
/**
|
|
9350
9404
|
* Present if the server offers any resources to read.
|
|
9351
9405
|
*/
|
|
9352
|
-
resources: z2.
|
|
9406
|
+
resources: z2.object({
|
|
9353
9407
|
/**
|
|
9354
9408
|
* Whether this server supports clients subscribing to resource updates.
|
|
9355
9409
|
*/
|
|
9356
|
-
subscribe: z2.
|
|
9410
|
+
subscribe: z2.boolean().optional(),
|
|
9357
9411
|
/**
|
|
9358
9412
|
* Whether this server supports issuing notifications for changes to the resource list.
|
|
9359
9413
|
*/
|
|
9360
|
-
listChanged: z2.
|
|
9361
|
-
}).
|
|
9414
|
+
listChanged: z2.boolean().optional()
|
|
9415
|
+
}).optional(),
|
|
9362
9416
|
/**
|
|
9363
9417
|
* Present if the server offers any tools to call.
|
|
9364
9418
|
*/
|
|
9365
|
-
tools: z2.
|
|
9419
|
+
tools: z2.object({
|
|
9366
9420
|
/**
|
|
9367
9421
|
* Whether this server supports issuing notifications for changes to the tool list.
|
|
9368
9422
|
*/
|
|
9369
|
-
listChanged: z2.
|
|
9370
|
-
}).
|
|
9371
|
-
|
|
9423
|
+
listChanged: z2.boolean().optional()
|
|
9424
|
+
}).optional(),
|
|
9425
|
+
/**
|
|
9426
|
+
* Present if the server supports task creation.
|
|
9427
|
+
*/
|
|
9428
|
+
tasks: ServerTasksCapabilitySchema.optional()
|
|
9429
|
+
});
|
|
9372
9430
|
var InitializeResultSchema = ResultSchema.extend({
|
|
9373
9431
|
/**
|
|
9374
9432
|
* The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.
|
|
@@ -9381,13 +9439,15 @@ var InitializeResultSchema = ResultSchema.extend({
|
|
|
9381
9439
|
*
|
|
9382
9440
|
* This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
|
|
9383
9441
|
*/
|
|
9384
|
-
instructions: z2.
|
|
9442
|
+
instructions: z2.string().optional()
|
|
9385
9443
|
});
|
|
9386
9444
|
var InitializedNotificationSchema = NotificationSchema.extend({
|
|
9387
|
-
method: z2.literal("notifications/initialized")
|
|
9445
|
+
method: z2.literal("notifications/initialized"),
|
|
9446
|
+
params: NotificationsParamsSchema.optional()
|
|
9388
9447
|
});
|
|
9389
9448
|
var PingRequestSchema = RequestSchema.extend({
|
|
9390
|
-
method: z2.literal("ping")
|
|
9449
|
+
method: z2.literal("ping"),
|
|
9450
|
+
params: BaseRequestParamsSchema.optional()
|
|
9391
9451
|
});
|
|
9392
9452
|
var ProgressSchema = z2.object({
|
|
9393
9453
|
/**
|
|
@@ -9402,32 +9462,94 @@ var ProgressSchema = z2.object({
|
|
|
9402
9462
|
* An optional message describing the current progress.
|
|
9403
9463
|
*/
|
|
9404
9464
|
message: z2.optional(z2.string())
|
|
9405
|
-
})
|
|
9406
|
-
var
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9465
|
+
});
|
|
9466
|
+
var ProgressNotificationParamsSchema = z2.object({
|
|
9467
|
+
...NotificationsParamsSchema.shape,
|
|
9468
|
+
...ProgressSchema.shape,
|
|
9469
|
+
/**
|
|
9470
|
+
* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
|
|
9471
|
+
*/
|
|
9472
|
+
progressToken: ProgressTokenSchema
|
|
9473
|
+
});
|
|
9474
|
+
var ProgressNotificationSchema = NotificationSchema.extend({
|
|
9475
|
+
method: z2.literal("notifications/progress"),
|
|
9476
|
+
params: ProgressNotificationParamsSchema
|
|
9477
|
+
});
|
|
9478
|
+
var PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
9479
|
+
/**
|
|
9480
|
+
* An opaque token representing the current pagination position.
|
|
9481
|
+
* If provided, the server should return results starting after this cursor.
|
|
9482
|
+
*/
|
|
9483
|
+
cursor: CursorSchema.optional()
|
|
9414
9484
|
});
|
|
9415
9485
|
var PaginatedRequestSchema = RequestSchema.extend({
|
|
9416
|
-
params:
|
|
9417
|
-
/**
|
|
9418
|
-
* An opaque token representing the current pagination position.
|
|
9419
|
-
* If provided, the server should return results starting after this cursor.
|
|
9420
|
-
*/
|
|
9421
|
-
cursor: z2.optional(CursorSchema)
|
|
9422
|
-
}).optional()
|
|
9486
|
+
params: PaginatedRequestParamsSchema.optional()
|
|
9423
9487
|
});
|
|
9424
9488
|
var PaginatedResultSchema = ResultSchema.extend({
|
|
9425
9489
|
/**
|
|
9426
9490
|
* An opaque token representing the pagination position after the last returned result.
|
|
9427
9491
|
* If present, there may be more results available.
|
|
9428
9492
|
*/
|
|
9429
|
-
nextCursor:
|
|
9493
|
+
nextCursor: CursorSchema.optional()
|
|
9494
|
+
});
|
|
9495
|
+
var TaskStatusSchema = z2.enum(["working", "input_required", "completed", "failed", "cancelled"]);
|
|
9496
|
+
var TaskSchema = z2.object({
|
|
9497
|
+
taskId: z2.string(),
|
|
9498
|
+
status: TaskStatusSchema,
|
|
9499
|
+
/**
|
|
9500
|
+
* Time in milliseconds to keep task results available after completion.
|
|
9501
|
+
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
9502
|
+
*/
|
|
9503
|
+
ttl: z2.union([z2.number(), z2.null()]),
|
|
9504
|
+
/**
|
|
9505
|
+
* ISO 8601 timestamp when the task was created.
|
|
9506
|
+
*/
|
|
9507
|
+
createdAt: z2.string(),
|
|
9508
|
+
/**
|
|
9509
|
+
* ISO 8601 timestamp when the task was last updated.
|
|
9510
|
+
*/
|
|
9511
|
+
lastUpdatedAt: z2.string(),
|
|
9512
|
+
pollInterval: z2.optional(z2.number()),
|
|
9513
|
+
/**
|
|
9514
|
+
* Optional diagnostic message for failed tasks or other status information.
|
|
9515
|
+
*/
|
|
9516
|
+
statusMessage: z2.optional(z2.string())
|
|
9517
|
+
});
|
|
9518
|
+
var CreateTaskResultSchema = ResultSchema.extend({
|
|
9519
|
+
task: TaskSchema
|
|
9520
|
+
});
|
|
9521
|
+
var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
|
|
9522
|
+
var TaskStatusNotificationSchema = NotificationSchema.extend({
|
|
9523
|
+
method: z2.literal("notifications/tasks/status"),
|
|
9524
|
+
params: TaskStatusNotificationParamsSchema
|
|
9525
|
+
});
|
|
9526
|
+
var GetTaskRequestSchema = RequestSchema.extend({
|
|
9527
|
+
method: z2.literal("tasks/get"),
|
|
9528
|
+
params: BaseRequestParamsSchema.extend({
|
|
9529
|
+
taskId: z2.string()
|
|
9530
|
+
})
|
|
9531
|
+
});
|
|
9532
|
+
var GetTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
9533
|
+
var GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
9534
|
+
method: z2.literal("tasks/result"),
|
|
9535
|
+
params: BaseRequestParamsSchema.extend({
|
|
9536
|
+
taskId: z2.string()
|
|
9537
|
+
})
|
|
9538
|
+
});
|
|
9539
|
+
var GetTaskPayloadResultSchema = ResultSchema.loose();
|
|
9540
|
+
var ListTasksRequestSchema = PaginatedRequestSchema.extend({
|
|
9541
|
+
method: z2.literal("tasks/list")
|
|
9542
|
+
});
|
|
9543
|
+
var ListTasksResultSchema = PaginatedResultSchema.extend({
|
|
9544
|
+
tasks: z2.array(TaskSchema)
|
|
9545
|
+
});
|
|
9546
|
+
var CancelTaskRequestSchema = RequestSchema.extend({
|
|
9547
|
+
method: z2.literal("tasks/cancel"),
|
|
9548
|
+
params: BaseRequestParamsSchema.extend({
|
|
9549
|
+
taskId: z2.string()
|
|
9550
|
+
})
|
|
9430
9551
|
});
|
|
9552
|
+
var CancelTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
9431
9553
|
var ResourceContentsSchema = z2.object({
|
|
9432
9554
|
/**
|
|
9433
9555
|
* The URI of this resource.
|
|
@@ -9441,8 +9563,8 @@ var ResourceContentsSchema = z2.object({
|
|
|
9441
9563
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9442
9564
|
* for notes on _meta usage.
|
|
9443
9565
|
*/
|
|
9444
|
-
_meta: z2.
|
|
9445
|
-
})
|
|
9566
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
9567
|
+
});
|
|
9446
9568
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
9447
9569
|
/**
|
|
9448
9570
|
* The text of the item. This must only be set if the item can actually be represented as text (not binary data).
|
|
@@ -9453,7 +9575,7 @@ var Base64Schema = z2.string().refine((val) => {
|
|
|
9453
9575
|
try {
|
|
9454
9576
|
atob(val);
|
|
9455
9577
|
return true;
|
|
9456
|
-
} catch
|
|
9578
|
+
} catch {
|
|
9457
9579
|
return false;
|
|
9458
9580
|
}
|
|
9459
9581
|
}, { message: "Invalid Base64 string" });
|
|
@@ -9463,7 +9585,24 @@ var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
|
9463
9585
|
*/
|
|
9464
9586
|
blob: Base64Schema
|
|
9465
9587
|
});
|
|
9466
|
-
var
|
|
9588
|
+
var RoleSchema = z2.enum(["user", "assistant"]);
|
|
9589
|
+
var AnnotationsSchema = z2.object({
|
|
9590
|
+
/**
|
|
9591
|
+
* Intended audience(s) for the resource.
|
|
9592
|
+
*/
|
|
9593
|
+
audience: z2.array(RoleSchema).optional(),
|
|
9594
|
+
/**
|
|
9595
|
+
* Importance hint for the resource, from 0 (least) to 1 (most).
|
|
9596
|
+
*/
|
|
9597
|
+
priority: z2.number().min(0).max(1).optional(),
|
|
9598
|
+
/**
|
|
9599
|
+
* ISO 8601 timestamp for the most recent modification.
|
|
9600
|
+
*/
|
|
9601
|
+
lastModified: z2.iso.datetime({ offset: true }).optional()
|
|
9602
|
+
});
|
|
9603
|
+
var ResourceSchema = z2.object({
|
|
9604
|
+
...BaseMetadataSchema.shape,
|
|
9605
|
+
...IconsSchema.shape,
|
|
9467
9606
|
/**
|
|
9468
9607
|
* The URI of this resource.
|
|
9469
9608
|
*/
|
|
@@ -9478,13 +9617,19 @@ var ResourceSchema = BaseMetadataSchema.extend({
|
|
|
9478
9617
|
* The MIME type of this resource, if known.
|
|
9479
9618
|
*/
|
|
9480
9619
|
mimeType: z2.optional(z2.string()),
|
|
9620
|
+
/**
|
|
9621
|
+
* Optional annotations for the client.
|
|
9622
|
+
*/
|
|
9623
|
+
annotations: AnnotationsSchema.optional(),
|
|
9481
9624
|
/**
|
|
9482
9625
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9483
9626
|
* for notes on _meta usage.
|
|
9484
9627
|
*/
|
|
9485
|
-
_meta: z2.optional(z2.
|
|
9486
|
-
})
|
|
9487
|
-
var ResourceTemplateSchema =
|
|
9628
|
+
_meta: z2.optional(z2.looseObject({}))
|
|
9629
|
+
});
|
|
9630
|
+
var ResourceTemplateSchema = z2.object({
|
|
9631
|
+
...BaseMetadataSchema.shape,
|
|
9632
|
+
...IconsSchema.shape,
|
|
9488
9633
|
/**
|
|
9489
9634
|
* A URI template (according to RFC 6570) that can be used to construct resource URIs.
|
|
9490
9635
|
*/
|
|
@@ -9499,12 +9644,16 @@ var ResourceTemplateSchema = BaseMetadataSchema.extend({
|
|
|
9499
9644
|
* The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
|
|
9500
9645
|
*/
|
|
9501
9646
|
mimeType: z2.optional(z2.string()),
|
|
9647
|
+
/**
|
|
9648
|
+
* Optional annotations for the client.
|
|
9649
|
+
*/
|
|
9650
|
+
annotations: AnnotationsSchema.optional(),
|
|
9502
9651
|
/**
|
|
9503
9652
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9504
9653
|
* for notes on _meta usage.
|
|
9505
9654
|
*/
|
|
9506
|
-
_meta: z2.optional(z2.
|
|
9507
|
-
})
|
|
9655
|
+
_meta: z2.optional(z2.looseObject({}))
|
|
9656
|
+
});
|
|
9508
9657
|
var ListResourcesRequestSchema = PaginatedRequestSchema.extend({
|
|
9509
9658
|
method: z2.literal("resources/list")
|
|
9510
9659
|
});
|
|
@@ -9517,47 +9666,45 @@ var ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({
|
|
|
9517
9666
|
var ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({
|
|
9518
9667
|
resourceTemplates: z2.array(ResourceTemplateSchema)
|
|
9519
9668
|
});
|
|
9669
|
+
var ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
9670
|
+
/**
|
|
9671
|
+
* The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
|
|
9672
|
+
*
|
|
9673
|
+
* @format uri
|
|
9674
|
+
*/
|
|
9675
|
+
uri: z2.string()
|
|
9676
|
+
});
|
|
9677
|
+
var ReadResourceRequestParamsSchema = ResourceRequestParamsSchema;
|
|
9520
9678
|
var ReadResourceRequestSchema = RequestSchema.extend({
|
|
9521
9679
|
method: z2.literal("resources/read"),
|
|
9522
|
-
params:
|
|
9523
|
-
/**
|
|
9524
|
-
* The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
|
|
9525
|
-
*/
|
|
9526
|
-
uri: z2.string()
|
|
9527
|
-
})
|
|
9680
|
+
params: ReadResourceRequestParamsSchema
|
|
9528
9681
|
});
|
|
9529
9682
|
var ReadResourceResultSchema = ResultSchema.extend({
|
|
9530
9683
|
contents: z2.array(z2.union([TextResourceContentsSchema, BlobResourceContentsSchema]))
|
|
9531
9684
|
});
|
|
9532
9685
|
var ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
9533
|
-
method: z2.literal("notifications/resources/list_changed")
|
|
9686
|
+
method: z2.literal("notifications/resources/list_changed"),
|
|
9687
|
+
params: NotificationsParamsSchema.optional()
|
|
9534
9688
|
});
|
|
9689
|
+
var SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
9535
9690
|
var SubscribeRequestSchema = RequestSchema.extend({
|
|
9536
9691
|
method: z2.literal("resources/subscribe"),
|
|
9537
|
-
params:
|
|
9538
|
-
/**
|
|
9539
|
-
* The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.
|
|
9540
|
-
*/
|
|
9541
|
-
uri: z2.string()
|
|
9542
|
-
})
|
|
9692
|
+
params: SubscribeRequestParamsSchema
|
|
9543
9693
|
});
|
|
9694
|
+
var UnsubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
9544
9695
|
var UnsubscribeRequestSchema = RequestSchema.extend({
|
|
9545
9696
|
method: z2.literal("resources/unsubscribe"),
|
|
9546
|
-
params:
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9697
|
+
params: UnsubscribeRequestParamsSchema
|
|
9698
|
+
});
|
|
9699
|
+
var ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
9700
|
+
/**
|
|
9701
|
+
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
|
|
9702
|
+
*/
|
|
9703
|
+
uri: z2.string()
|
|
9552
9704
|
});
|
|
9553
9705
|
var ResourceUpdatedNotificationSchema = NotificationSchema.extend({
|
|
9554
9706
|
method: z2.literal("notifications/resources/updated"),
|
|
9555
|
-
params:
|
|
9556
|
-
/**
|
|
9557
|
-
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
|
|
9558
|
-
*/
|
|
9559
|
-
uri: z2.string()
|
|
9560
|
-
})
|
|
9707
|
+
params: ResourceUpdatedNotificationParamsSchema
|
|
9561
9708
|
});
|
|
9562
9709
|
var PromptArgumentSchema = z2.object({
|
|
9563
9710
|
/**
|
|
@@ -9572,8 +9719,10 @@ var PromptArgumentSchema = z2.object({
|
|
|
9572
9719
|
* Whether this argument must be provided.
|
|
9573
9720
|
*/
|
|
9574
9721
|
required: z2.optional(z2.boolean())
|
|
9575
|
-
})
|
|
9576
|
-
var PromptSchema =
|
|
9722
|
+
});
|
|
9723
|
+
var PromptSchema = z2.object({
|
|
9724
|
+
...BaseMetadataSchema.shape,
|
|
9725
|
+
...IconsSchema.shape,
|
|
9577
9726
|
/**
|
|
9578
9727
|
* An optional description of what this prompt provides
|
|
9579
9728
|
*/
|
|
@@ -9586,26 +9735,27 @@ var PromptSchema = BaseMetadataSchema.extend({
|
|
|
9586
9735
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9587
9736
|
* for notes on _meta usage.
|
|
9588
9737
|
*/
|
|
9589
|
-
_meta: z2.optional(z2.
|
|
9590
|
-
})
|
|
9738
|
+
_meta: z2.optional(z2.looseObject({}))
|
|
9739
|
+
});
|
|
9591
9740
|
var ListPromptsRequestSchema = PaginatedRequestSchema.extend({
|
|
9592
9741
|
method: z2.literal("prompts/list")
|
|
9593
9742
|
});
|
|
9594
9743
|
var ListPromptsResultSchema = PaginatedResultSchema.extend({
|
|
9595
9744
|
prompts: z2.array(PromptSchema)
|
|
9596
9745
|
});
|
|
9746
|
+
var GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
9747
|
+
/**
|
|
9748
|
+
* The name of the prompt or prompt template.
|
|
9749
|
+
*/
|
|
9750
|
+
name: z2.string(),
|
|
9751
|
+
/**
|
|
9752
|
+
* Arguments to use for templating the prompt.
|
|
9753
|
+
*/
|
|
9754
|
+
arguments: z2.record(z2.string(), z2.string()).optional()
|
|
9755
|
+
});
|
|
9597
9756
|
var GetPromptRequestSchema = RequestSchema.extend({
|
|
9598
9757
|
method: z2.literal("prompts/get"),
|
|
9599
|
-
params:
|
|
9600
|
-
/**
|
|
9601
|
-
* The name of the prompt or prompt template.
|
|
9602
|
-
*/
|
|
9603
|
-
name: z2.string(),
|
|
9604
|
-
/**
|
|
9605
|
-
* Arguments to use for templating the prompt.
|
|
9606
|
-
*/
|
|
9607
|
-
arguments: z2.optional(z2.record(z2.string()))
|
|
9608
|
-
})
|
|
9758
|
+
params: GetPromptRequestParamsSchema
|
|
9609
9759
|
});
|
|
9610
9760
|
var TextContentSchema = z2.object({
|
|
9611
9761
|
type: z2.literal("text"),
|
|
@@ -9613,12 +9763,16 @@ var TextContentSchema = z2.object({
|
|
|
9613
9763
|
* The text content of the message.
|
|
9614
9764
|
*/
|
|
9615
9765
|
text: z2.string(),
|
|
9766
|
+
/**
|
|
9767
|
+
* Optional annotations for the client.
|
|
9768
|
+
*/
|
|
9769
|
+
annotations: AnnotationsSchema.optional(),
|
|
9616
9770
|
/**
|
|
9617
9771
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9618
9772
|
* for notes on _meta usage.
|
|
9619
9773
|
*/
|
|
9620
|
-
_meta: z2.
|
|
9621
|
-
})
|
|
9774
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
9775
|
+
});
|
|
9622
9776
|
var ImageContentSchema = z2.object({
|
|
9623
9777
|
type: z2.literal("image"),
|
|
9624
9778
|
/**
|
|
@@ -9629,12 +9783,16 @@ var ImageContentSchema = z2.object({
|
|
|
9629
9783
|
* The MIME type of the image. Different providers may support different image types.
|
|
9630
9784
|
*/
|
|
9631
9785
|
mimeType: z2.string(),
|
|
9786
|
+
/**
|
|
9787
|
+
* Optional annotations for the client.
|
|
9788
|
+
*/
|
|
9789
|
+
annotations: AnnotationsSchema.optional(),
|
|
9632
9790
|
/**
|
|
9633
9791
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9634
9792
|
* for notes on _meta usage.
|
|
9635
9793
|
*/
|
|
9636
|
-
_meta: z2.
|
|
9637
|
-
})
|
|
9794
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
9795
|
+
});
|
|
9638
9796
|
var AudioContentSchema = z2.object({
|
|
9639
9797
|
type: z2.literal("audio"),
|
|
9640
9798
|
/**
|
|
@@ -9645,21 +9803,52 @@ var AudioContentSchema = z2.object({
|
|
|
9645
9803
|
* The MIME type of the audio. Different providers may support different audio types.
|
|
9646
9804
|
*/
|
|
9647
9805
|
mimeType: z2.string(),
|
|
9806
|
+
/**
|
|
9807
|
+
* Optional annotations for the client.
|
|
9808
|
+
*/
|
|
9809
|
+
annotations: AnnotationsSchema.optional(),
|
|
9810
|
+
/**
|
|
9811
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9812
|
+
* for notes on _meta usage.
|
|
9813
|
+
*/
|
|
9814
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
9815
|
+
});
|
|
9816
|
+
var ToolUseContentSchema = z2.object({
|
|
9817
|
+
type: z2.literal("tool_use"),
|
|
9818
|
+
/**
|
|
9819
|
+
* The name of the tool to invoke.
|
|
9820
|
+
* Must match a tool name from the request's tools array.
|
|
9821
|
+
*/
|
|
9822
|
+
name: z2.string(),
|
|
9823
|
+
/**
|
|
9824
|
+
* Unique identifier for this tool call.
|
|
9825
|
+
* Used to correlate with ToolResultContent in subsequent messages.
|
|
9826
|
+
*/
|
|
9827
|
+
id: z2.string(),
|
|
9828
|
+
/**
|
|
9829
|
+
* Arguments to pass to the tool.
|
|
9830
|
+
* Must conform to the tool's inputSchema.
|
|
9831
|
+
*/
|
|
9832
|
+
input: z2.record(z2.string(), z2.unknown()),
|
|
9648
9833
|
/**
|
|
9649
9834
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9650
9835
|
* for notes on _meta usage.
|
|
9651
9836
|
*/
|
|
9652
|
-
_meta: z2.
|
|
9653
|
-
})
|
|
9837
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
9838
|
+
});
|
|
9654
9839
|
var EmbeddedResourceSchema = z2.object({
|
|
9655
9840
|
type: z2.literal("resource"),
|
|
9656
9841
|
resource: z2.union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
9842
|
+
/**
|
|
9843
|
+
* Optional annotations for the client.
|
|
9844
|
+
*/
|
|
9845
|
+
annotations: AnnotationsSchema.optional(),
|
|
9657
9846
|
/**
|
|
9658
9847
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9659
9848
|
* for notes on _meta usage.
|
|
9660
9849
|
*/
|
|
9661
|
-
_meta: z2.
|
|
9662
|
-
})
|
|
9850
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
9851
|
+
});
|
|
9663
9852
|
var ResourceLinkSchema = ResourceSchema.extend({
|
|
9664
9853
|
type: z2.literal("resource_link")
|
|
9665
9854
|
});
|
|
@@ -9671,30 +9860,31 @@ var ContentBlockSchema = z2.union([
|
|
|
9671
9860
|
EmbeddedResourceSchema
|
|
9672
9861
|
]);
|
|
9673
9862
|
var PromptMessageSchema = z2.object({
|
|
9674
|
-
role:
|
|
9863
|
+
role: RoleSchema,
|
|
9675
9864
|
content: ContentBlockSchema
|
|
9676
|
-
})
|
|
9865
|
+
});
|
|
9677
9866
|
var GetPromptResultSchema = ResultSchema.extend({
|
|
9678
9867
|
/**
|
|
9679
9868
|
* An optional description for the prompt.
|
|
9680
9869
|
*/
|
|
9681
|
-
description: z2.
|
|
9870
|
+
description: z2.string().optional(),
|
|
9682
9871
|
messages: z2.array(PromptMessageSchema)
|
|
9683
9872
|
});
|
|
9684
9873
|
var PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
9685
|
-
method: z2.literal("notifications/prompts/list_changed")
|
|
9874
|
+
method: z2.literal("notifications/prompts/list_changed"),
|
|
9875
|
+
params: NotificationsParamsSchema.optional()
|
|
9686
9876
|
});
|
|
9687
9877
|
var ToolAnnotationsSchema = z2.object({
|
|
9688
9878
|
/**
|
|
9689
9879
|
* A human-readable title for the tool.
|
|
9690
9880
|
*/
|
|
9691
|
-
title: z2.
|
|
9881
|
+
title: z2.string().optional(),
|
|
9692
9882
|
/**
|
|
9693
9883
|
* If true, the tool does not modify its environment.
|
|
9694
9884
|
*
|
|
9695
9885
|
* Default: false
|
|
9696
9886
|
*/
|
|
9697
|
-
readOnlyHint: z2.
|
|
9887
|
+
readOnlyHint: z2.boolean().optional(),
|
|
9698
9888
|
/**
|
|
9699
9889
|
* If true, the tool may perform destructive updates to its environment.
|
|
9700
9890
|
* If false, the tool performs only additive updates.
|
|
@@ -9703,7 +9893,7 @@ var ToolAnnotationsSchema = z2.object({
|
|
|
9703
9893
|
*
|
|
9704
9894
|
* Default: true
|
|
9705
9895
|
*/
|
|
9706
|
-
destructiveHint: z2.
|
|
9896
|
+
destructiveHint: z2.boolean().optional(),
|
|
9707
9897
|
/**
|
|
9708
9898
|
* If true, calling the tool repeatedly with the same arguments
|
|
9709
9899
|
* will have no additional effect on the its environment.
|
|
@@ -9712,7 +9902,7 @@ var ToolAnnotationsSchema = z2.object({
|
|
|
9712
9902
|
*
|
|
9713
9903
|
* Default: false
|
|
9714
9904
|
*/
|
|
9715
|
-
idempotentHint: z2.
|
|
9905
|
+
idempotentHint: z2.boolean().optional(),
|
|
9716
9906
|
/**
|
|
9717
9907
|
* If true, this tool may interact with an "open world" of external
|
|
9718
9908
|
* entities. If false, the tool's domain of interaction is closed.
|
|
@@ -9721,40 +9911,59 @@ var ToolAnnotationsSchema = z2.object({
|
|
|
9721
9911
|
*
|
|
9722
9912
|
* Default: true
|
|
9723
9913
|
*/
|
|
9724
|
-
openWorldHint: z2.
|
|
9725
|
-
})
|
|
9726
|
-
var
|
|
9914
|
+
openWorldHint: z2.boolean().optional()
|
|
9915
|
+
});
|
|
9916
|
+
var ToolExecutionSchema = z2.object({
|
|
9917
|
+
/**
|
|
9918
|
+
* Indicates the tool's preference for task-augmented execution.
|
|
9919
|
+
* - "required": Clients MUST invoke the tool as a task
|
|
9920
|
+
* - "optional": Clients MAY invoke the tool as a task or normal request
|
|
9921
|
+
* - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
|
|
9922
|
+
*
|
|
9923
|
+
* If not present, defaults to "forbidden".
|
|
9924
|
+
*/
|
|
9925
|
+
taskSupport: z2.enum(["required", "optional", "forbidden"]).optional()
|
|
9926
|
+
});
|
|
9927
|
+
var ToolSchema = z2.object({
|
|
9928
|
+
...BaseMetadataSchema.shape,
|
|
9929
|
+
...IconsSchema.shape,
|
|
9727
9930
|
/**
|
|
9728
9931
|
* A human-readable description of the tool.
|
|
9729
9932
|
*/
|
|
9730
|
-
description: z2.
|
|
9933
|
+
description: z2.string().optional(),
|
|
9731
9934
|
/**
|
|
9732
|
-
* A JSON Schema object defining the expected parameters for the tool.
|
|
9935
|
+
* A JSON Schema 2020-12 object defining the expected parameters for the tool.
|
|
9936
|
+
* Must have type: 'object' at the root level per MCP spec.
|
|
9733
9937
|
*/
|
|
9734
9938
|
inputSchema: z2.object({
|
|
9735
9939
|
type: z2.literal("object"),
|
|
9736
|
-
properties: z2.
|
|
9737
|
-
required: z2.
|
|
9738
|
-
}).
|
|
9940
|
+
properties: z2.record(z2.string(), AssertObjectSchema).optional(),
|
|
9941
|
+
required: z2.array(z2.string()).optional()
|
|
9942
|
+
}).catchall(z2.unknown()),
|
|
9739
9943
|
/**
|
|
9740
|
-
* An optional JSON Schema object defining the structure of the tool's output
|
|
9741
|
-
* the structuredContent field of a CallToolResult.
|
|
9944
|
+
* An optional JSON Schema 2020-12 object defining the structure of the tool's output
|
|
9945
|
+
* returned in the structuredContent field of a CallToolResult.
|
|
9946
|
+
* Must have type: 'object' at the root level per MCP spec.
|
|
9742
9947
|
*/
|
|
9743
|
-
outputSchema: z2.
|
|
9948
|
+
outputSchema: z2.object({
|
|
9744
9949
|
type: z2.literal("object"),
|
|
9745
|
-
properties: z2.
|
|
9746
|
-
required: z2.
|
|
9747
|
-
}).
|
|
9950
|
+
properties: z2.record(z2.string(), AssertObjectSchema).optional(),
|
|
9951
|
+
required: z2.array(z2.string()).optional()
|
|
9952
|
+
}).catchall(z2.unknown()).optional(),
|
|
9748
9953
|
/**
|
|
9749
9954
|
* Optional additional tool information.
|
|
9750
9955
|
*/
|
|
9751
|
-
annotations:
|
|
9956
|
+
annotations: ToolAnnotationsSchema.optional(),
|
|
9957
|
+
/**
|
|
9958
|
+
* Execution-related properties for this tool.
|
|
9959
|
+
*/
|
|
9960
|
+
execution: ToolExecutionSchema.optional(),
|
|
9752
9961
|
/**
|
|
9753
9962
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
9754
9963
|
* for notes on _meta usage.
|
|
9755
9964
|
*/
|
|
9756
|
-
_meta: z2.
|
|
9757
|
-
})
|
|
9965
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
9966
|
+
});
|
|
9758
9967
|
var ListToolsRequestSchema = PaginatedRequestSchema.extend({
|
|
9759
9968
|
method: z2.literal("tools/list")
|
|
9760
9969
|
});
|
|
@@ -9774,7 +9983,7 @@ var CallToolResultSchema = ResultSchema.extend({
|
|
|
9774
9983
|
*
|
|
9775
9984
|
* If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
|
|
9776
9985
|
*/
|
|
9777
|
-
structuredContent: z2.
|
|
9986
|
+
structuredContent: z2.record(z2.string(), z2.unknown()).optional(),
|
|
9778
9987
|
/**
|
|
9779
9988
|
* Whether the tool call ended in an error.
|
|
9780
9989
|
*
|
|
@@ -9789,103 +9998,185 @@ var CallToolResultSchema = ResultSchema.extend({
|
|
|
9789
9998
|
* server does not support tool calls, or any other exceptional conditions,
|
|
9790
9999
|
* should be reported as an MCP error response.
|
|
9791
10000
|
*/
|
|
9792
|
-
isError: z2.
|
|
10001
|
+
isError: z2.boolean().optional()
|
|
9793
10002
|
});
|
|
9794
10003
|
var CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({
|
|
9795
10004
|
toolResult: z2.unknown()
|
|
9796
10005
|
}));
|
|
10006
|
+
var CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
10007
|
+
/**
|
|
10008
|
+
* The name of the tool to call.
|
|
10009
|
+
*/
|
|
10010
|
+
name: z2.string(),
|
|
10011
|
+
/**
|
|
10012
|
+
* Arguments to pass to the tool.
|
|
10013
|
+
*/
|
|
10014
|
+
arguments: z2.record(z2.string(), z2.unknown()).optional()
|
|
10015
|
+
});
|
|
9797
10016
|
var CallToolRequestSchema = RequestSchema.extend({
|
|
9798
10017
|
method: z2.literal("tools/call"),
|
|
9799
|
-
params:
|
|
9800
|
-
name: z2.string(),
|
|
9801
|
-
arguments: z2.optional(z2.record(z2.unknown()))
|
|
9802
|
-
})
|
|
10018
|
+
params: CallToolRequestParamsSchema
|
|
9803
10019
|
});
|
|
9804
10020
|
var ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
9805
|
-
method: z2.literal("notifications/tools/list_changed")
|
|
10021
|
+
method: z2.literal("notifications/tools/list_changed"),
|
|
10022
|
+
params: NotificationsParamsSchema.optional()
|
|
10023
|
+
});
|
|
10024
|
+
var ListChangedOptionsBaseSchema = z2.object({
|
|
10025
|
+
/**
|
|
10026
|
+
* If true, the list will be refreshed automatically when a list changed notification is received.
|
|
10027
|
+
* The callback will be called with the updated list.
|
|
10028
|
+
*
|
|
10029
|
+
* If false, the callback will be called with null items, allowing manual refresh.
|
|
10030
|
+
*
|
|
10031
|
+
* @default true
|
|
10032
|
+
*/
|
|
10033
|
+
autoRefresh: z2.boolean().default(true),
|
|
10034
|
+
/**
|
|
10035
|
+
* Debounce time in milliseconds for list changed notification processing.
|
|
10036
|
+
*
|
|
10037
|
+
* Multiple notifications received within this timeframe will only trigger one refresh.
|
|
10038
|
+
* Set to 0 to disable debouncing.
|
|
10039
|
+
*
|
|
10040
|
+
* @default 300
|
|
10041
|
+
*/
|
|
10042
|
+
debounceMs: z2.number().int().nonnegative().default(300)
|
|
9806
10043
|
});
|
|
9807
10044
|
var LoggingLevelSchema = z2.enum(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
|
|
10045
|
+
var SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
10046
|
+
/**
|
|
10047
|
+
* The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.
|
|
10048
|
+
*/
|
|
10049
|
+
level: LoggingLevelSchema
|
|
10050
|
+
});
|
|
9808
10051
|
var SetLevelRequestSchema = RequestSchema.extend({
|
|
9809
10052
|
method: z2.literal("logging/setLevel"),
|
|
9810
|
-
params:
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
10053
|
+
params: SetLevelRequestParamsSchema
|
|
10054
|
+
});
|
|
10055
|
+
var LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
10056
|
+
/**
|
|
10057
|
+
* The severity of this log message.
|
|
10058
|
+
*/
|
|
10059
|
+
level: LoggingLevelSchema,
|
|
10060
|
+
/**
|
|
10061
|
+
* An optional name of the logger issuing this message.
|
|
10062
|
+
*/
|
|
10063
|
+
logger: z2.string().optional(),
|
|
10064
|
+
/**
|
|
10065
|
+
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
|
|
10066
|
+
*/
|
|
10067
|
+
data: z2.unknown()
|
|
9816
10068
|
});
|
|
9817
10069
|
var LoggingMessageNotificationSchema = NotificationSchema.extend({
|
|
9818
10070
|
method: z2.literal("notifications/message"),
|
|
9819
|
-
params:
|
|
9820
|
-
/**
|
|
9821
|
-
* The severity of this log message.
|
|
9822
|
-
*/
|
|
9823
|
-
level: LoggingLevelSchema,
|
|
9824
|
-
/**
|
|
9825
|
-
* An optional name of the logger issuing this message.
|
|
9826
|
-
*/
|
|
9827
|
-
logger: z2.optional(z2.string()),
|
|
9828
|
-
/**
|
|
9829
|
-
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
|
|
9830
|
-
*/
|
|
9831
|
-
data: z2.unknown()
|
|
9832
|
-
})
|
|
10071
|
+
params: LoggingMessageNotificationParamsSchema
|
|
9833
10072
|
});
|
|
9834
10073
|
var ModelHintSchema = z2.object({
|
|
9835
10074
|
/**
|
|
9836
10075
|
* A hint for a model name.
|
|
9837
10076
|
*/
|
|
9838
10077
|
name: z2.string().optional()
|
|
9839
|
-
})
|
|
10078
|
+
});
|
|
9840
10079
|
var ModelPreferencesSchema = z2.object({
|
|
9841
10080
|
/**
|
|
9842
10081
|
* Optional hints to use for model selection.
|
|
9843
10082
|
*/
|
|
9844
|
-
hints: z2.
|
|
10083
|
+
hints: z2.array(ModelHintSchema).optional(),
|
|
9845
10084
|
/**
|
|
9846
10085
|
* How much to prioritize cost when selecting a model.
|
|
9847
10086
|
*/
|
|
9848
|
-
costPriority: z2.
|
|
10087
|
+
costPriority: z2.number().min(0).max(1).optional(),
|
|
9849
10088
|
/**
|
|
9850
10089
|
* How much to prioritize sampling speed (latency) when selecting a model.
|
|
9851
10090
|
*/
|
|
9852
|
-
speedPriority: z2.
|
|
10091
|
+
speedPriority: z2.number().min(0).max(1).optional(),
|
|
9853
10092
|
/**
|
|
9854
10093
|
* How much to prioritize intelligence and capabilities when selecting a model.
|
|
9855
10094
|
*/
|
|
9856
|
-
intelligencePriority: z2.
|
|
9857
|
-
})
|
|
10095
|
+
intelligencePriority: z2.number().min(0).max(1).optional()
|
|
10096
|
+
});
|
|
10097
|
+
var ToolChoiceSchema = z2.object({
|
|
10098
|
+
/**
|
|
10099
|
+
* Controls when tools are used:
|
|
10100
|
+
* - "auto": Model decides whether to use tools (default)
|
|
10101
|
+
* - "required": Model MUST use at least one tool before completing
|
|
10102
|
+
* - "none": Model MUST NOT use any tools
|
|
10103
|
+
*/
|
|
10104
|
+
mode: z2.enum(["auto", "required", "none"]).optional()
|
|
10105
|
+
});
|
|
10106
|
+
var ToolResultContentSchema = z2.object({
|
|
10107
|
+
type: z2.literal("tool_result"),
|
|
10108
|
+
toolUseId: z2.string().describe("The unique identifier for the corresponding tool call."),
|
|
10109
|
+
content: z2.array(ContentBlockSchema).default([]),
|
|
10110
|
+
structuredContent: z2.object({}).loose().optional(),
|
|
10111
|
+
isError: z2.boolean().optional(),
|
|
10112
|
+
/**
|
|
10113
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10114
|
+
* for notes on _meta usage.
|
|
10115
|
+
*/
|
|
10116
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
10117
|
+
});
|
|
10118
|
+
var SamplingContentSchema = z2.discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
|
|
10119
|
+
var SamplingMessageContentBlockSchema = z2.discriminatedUnion("type", [
|
|
10120
|
+
TextContentSchema,
|
|
10121
|
+
ImageContentSchema,
|
|
10122
|
+
AudioContentSchema,
|
|
10123
|
+
ToolUseContentSchema,
|
|
10124
|
+
ToolResultContentSchema
|
|
10125
|
+
]);
|
|
9858
10126
|
var SamplingMessageSchema = z2.object({
|
|
9859
|
-
role:
|
|
9860
|
-
content: z2.union([
|
|
9861
|
-
|
|
10127
|
+
role: RoleSchema,
|
|
10128
|
+
content: z2.union([SamplingMessageContentBlockSchema, z2.array(SamplingMessageContentBlockSchema)]),
|
|
10129
|
+
/**
|
|
10130
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10131
|
+
* for notes on _meta usage.
|
|
10132
|
+
*/
|
|
10133
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
10134
|
+
});
|
|
10135
|
+
var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
10136
|
+
messages: z2.array(SamplingMessageSchema),
|
|
10137
|
+
/**
|
|
10138
|
+
* The server's preferences for which model to select. The client MAY modify or omit this request.
|
|
10139
|
+
*/
|
|
10140
|
+
modelPreferences: ModelPreferencesSchema.optional(),
|
|
10141
|
+
/**
|
|
10142
|
+
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
|
|
10143
|
+
*/
|
|
10144
|
+
systemPrompt: z2.string().optional(),
|
|
10145
|
+
/**
|
|
10146
|
+
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
|
|
10147
|
+
* The client MAY ignore this request.
|
|
10148
|
+
*
|
|
10149
|
+
* Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
|
|
10150
|
+
* declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
|
|
10151
|
+
*/
|
|
10152
|
+
includeContext: z2.enum(["none", "thisServer", "allServers"]).optional(),
|
|
10153
|
+
temperature: z2.number().optional(),
|
|
10154
|
+
/**
|
|
10155
|
+
* The requested maximum number of tokens to sample (to prevent runaway completions).
|
|
10156
|
+
*
|
|
10157
|
+
* The client MAY choose to sample fewer tokens than the requested maximum.
|
|
10158
|
+
*/
|
|
10159
|
+
maxTokens: z2.number().int(),
|
|
10160
|
+
stopSequences: z2.array(z2.string()).optional(),
|
|
10161
|
+
/**
|
|
10162
|
+
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
|
|
10163
|
+
*/
|
|
10164
|
+
metadata: AssertObjectSchema.optional(),
|
|
10165
|
+
/**
|
|
10166
|
+
* Tools that the model may use during generation.
|
|
10167
|
+
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
10168
|
+
*/
|
|
10169
|
+
tools: z2.array(ToolSchema).optional(),
|
|
10170
|
+
/**
|
|
10171
|
+
* Controls how the model uses tools.
|
|
10172
|
+
* The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
|
|
10173
|
+
* Default is `{ mode: "auto" }`.
|
|
10174
|
+
*/
|
|
10175
|
+
toolChoice: ToolChoiceSchema.optional()
|
|
10176
|
+
});
|
|
9862
10177
|
var CreateMessageRequestSchema = RequestSchema.extend({
|
|
9863
10178
|
method: z2.literal("sampling/createMessage"),
|
|
9864
|
-
params:
|
|
9865
|
-
messages: z2.array(SamplingMessageSchema),
|
|
9866
|
-
/**
|
|
9867
|
-
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
|
|
9868
|
-
*/
|
|
9869
|
-
systemPrompt: z2.optional(z2.string()),
|
|
9870
|
-
/**
|
|
9871
|
-
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.
|
|
9872
|
-
*/
|
|
9873
|
-
includeContext: z2.optional(z2.enum(["none", "thisServer", "allServers"])),
|
|
9874
|
-
temperature: z2.optional(z2.number()),
|
|
9875
|
-
/**
|
|
9876
|
-
* The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.
|
|
9877
|
-
*/
|
|
9878
|
-
maxTokens: z2.number().int(),
|
|
9879
|
-
stopSequences: z2.optional(z2.array(z2.string())),
|
|
9880
|
-
/**
|
|
9881
|
-
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
|
|
9882
|
-
*/
|
|
9883
|
-
metadata: z2.optional(z2.object({}).passthrough()),
|
|
9884
|
-
/**
|
|
9885
|
-
* The server's preferences for which model to select.
|
|
9886
|
-
*/
|
|
9887
|
-
modelPreferences: z2.optional(ModelPreferencesSchema)
|
|
9888
|
-
})
|
|
10179
|
+
params: CreateMessageRequestParamsSchema
|
|
9889
10180
|
});
|
|
9890
10181
|
var CreateMessageResultSchema = ResultSchema.extend({
|
|
9891
10182
|
/**
|
|
@@ -9893,67 +10184,193 @@ var CreateMessageResultSchema = ResultSchema.extend({
|
|
|
9893
10184
|
*/
|
|
9894
10185
|
model: z2.string(),
|
|
9895
10186
|
/**
|
|
9896
|
-
* The reason why sampling stopped.
|
|
10187
|
+
* The reason why sampling stopped, if known.
|
|
10188
|
+
*
|
|
10189
|
+
* Standard values:
|
|
10190
|
+
* - "endTurn": Natural end of the assistant's turn
|
|
10191
|
+
* - "stopSequence": A stop sequence was encountered
|
|
10192
|
+
* - "maxTokens": Maximum token limit was reached
|
|
10193
|
+
*
|
|
10194
|
+
* This field is an open string to allow for provider-specific stop reasons.
|
|
9897
10195
|
*/
|
|
9898
10196
|
stopReason: z2.optional(z2.enum(["endTurn", "stopSequence", "maxTokens"]).or(z2.string())),
|
|
9899
|
-
role:
|
|
9900
|
-
|
|
10197
|
+
role: RoleSchema,
|
|
10198
|
+
/**
|
|
10199
|
+
* Response content. Single content block (text, image, or audio).
|
|
10200
|
+
*/
|
|
10201
|
+
content: SamplingContentSchema
|
|
10202
|
+
});
|
|
10203
|
+
var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
10204
|
+
/**
|
|
10205
|
+
* The name of the model that generated the message.
|
|
10206
|
+
*/
|
|
10207
|
+
model: z2.string(),
|
|
10208
|
+
/**
|
|
10209
|
+
* The reason why sampling stopped, if known.
|
|
10210
|
+
*
|
|
10211
|
+
* Standard values:
|
|
10212
|
+
* - "endTurn": Natural end of the assistant's turn
|
|
10213
|
+
* - "stopSequence": A stop sequence was encountered
|
|
10214
|
+
* - "maxTokens": Maximum token limit was reached
|
|
10215
|
+
* - "toolUse": The model wants to use one or more tools
|
|
10216
|
+
*
|
|
10217
|
+
* This field is an open string to allow for provider-specific stop reasons.
|
|
10218
|
+
*/
|
|
10219
|
+
stopReason: z2.optional(z2.enum(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(z2.string())),
|
|
10220
|
+
role: RoleSchema,
|
|
10221
|
+
/**
|
|
10222
|
+
* Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
|
|
10223
|
+
*/
|
|
10224
|
+
content: z2.union([SamplingMessageContentBlockSchema, z2.array(SamplingMessageContentBlockSchema)])
|
|
9901
10225
|
});
|
|
9902
10226
|
var BooleanSchemaSchema = z2.object({
|
|
9903
10227
|
type: z2.literal("boolean"),
|
|
9904
|
-
title: z2.
|
|
9905
|
-
description: z2.
|
|
9906
|
-
default: z2.
|
|
9907
|
-
})
|
|
10228
|
+
title: z2.string().optional(),
|
|
10229
|
+
description: z2.string().optional(),
|
|
10230
|
+
default: z2.boolean().optional()
|
|
10231
|
+
});
|
|
9908
10232
|
var StringSchemaSchema = z2.object({
|
|
9909
10233
|
type: z2.literal("string"),
|
|
9910
|
-
title: z2.
|
|
9911
|
-
description: z2.
|
|
9912
|
-
minLength: z2.
|
|
9913
|
-
maxLength: z2.
|
|
9914
|
-
format: z2.
|
|
9915
|
-
|
|
10234
|
+
title: z2.string().optional(),
|
|
10235
|
+
description: z2.string().optional(),
|
|
10236
|
+
minLength: z2.number().optional(),
|
|
10237
|
+
maxLength: z2.number().optional(),
|
|
10238
|
+
format: z2.enum(["email", "uri", "date", "date-time"]).optional(),
|
|
10239
|
+
default: z2.string().optional()
|
|
10240
|
+
});
|
|
9916
10241
|
var NumberSchemaSchema = z2.object({
|
|
9917
10242
|
type: z2.enum(["number", "integer"]),
|
|
9918
|
-
title: z2.
|
|
9919
|
-
description: z2.
|
|
9920
|
-
minimum: z2.
|
|
9921
|
-
maximum: z2.
|
|
9922
|
-
|
|
9923
|
-
|
|
10243
|
+
title: z2.string().optional(),
|
|
10244
|
+
description: z2.string().optional(),
|
|
10245
|
+
minimum: z2.number().optional(),
|
|
10246
|
+
maximum: z2.number().optional(),
|
|
10247
|
+
default: z2.number().optional()
|
|
10248
|
+
});
|
|
10249
|
+
var UntitledSingleSelectEnumSchemaSchema = z2.object({
|
|
9924
10250
|
type: z2.literal("string"),
|
|
9925
|
-
title: z2.
|
|
9926
|
-
description: z2.
|
|
10251
|
+
title: z2.string().optional(),
|
|
10252
|
+
description: z2.string().optional(),
|
|
9927
10253
|
enum: z2.array(z2.string()),
|
|
9928
|
-
|
|
9929
|
-
}).passthrough();
|
|
9930
|
-
var PrimitiveSchemaDefinitionSchema = z2.union([BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, EnumSchemaSchema]);
|
|
9931
|
-
var ElicitRequestSchema = RequestSchema.extend({
|
|
9932
|
-
method: z2.literal("elicitation/create"),
|
|
9933
|
-
params: BaseRequestParamsSchema.extend({
|
|
9934
|
-
/**
|
|
9935
|
-
* The message to present to the user.
|
|
9936
|
-
*/
|
|
9937
|
-
message: z2.string(),
|
|
9938
|
-
/**
|
|
9939
|
-
* The schema for the requested user input.
|
|
9940
|
-
*/
|
|
9941
|
-
requestedSchema: z2.object({
|
|
9942
|
-
type: z2.literal("object"),
|
|
9943
|
-
properties: z2.record(z2.string(), PrimitiveSchemaDefinitionSchema),
|
|
9944
|
-
required: z2.optional(z2.array(z2.string()))
|
|
9945
|
-
}).passthrough()
|
|
9946
|
-
})
|
|
10254
|
+
default: z2.string().optional()
|
|
9947
10255
|
});
|
|
9948
|
-
var
|
|
10256
|
+
var TitledSingleSelectEnumSchemaSchema = z2.object({
|
|
10257
|
+
type: z2.literal("string"),
|
|
10258
|
+
title: z2.string().optional(),
|
|
10259
|
+
description: z2.string().optional(),
|
|
10260
|
+
oneOf: z2.array(z2.object({
|
|
10261
|
+
const: z2.string(),
|
|
10262
|
+
title: z2.string()
|
|
10263
|
+
})),
|
|
10264
|
+
default: z2.string().optional()
|
|
10265
|
+
});
|
|
10266
|
+
var LegacyTitledEnumSchemaSchema = z2.object({
|
|
10267
|
+
type: z2.literal("string"),
|
|
10268
|
+
title: z2.string().optional(),
|
|
10269
|
+
description: z2.string().optional(),
|
|
10270
|
+
enum: z2.array(z2.string()),
|
|
10271
|
+
enumNames: z2.array(z2.string()).optional(),
|
|
10272
|
+
default: z2.string().optional()
|
|
10273
|
+
});
|
|
10274
|
+
var SingleSelectEnumSchemaSchema = z2.union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]);
|
|
10275
|
+
var UntitledMultiSelectEnumSchemaSchema = z2.object({
|
|
10276
|
+
type: z2.literal("array"),
|
|
10277
|
+
title: z2.string().optional(),
|
|
10278
|
+
description: z2.string().optional(),
|
|
10279
|
+
minItems: z2.number().optional(),
|
|
10280
|
+
maxItems: z2.number().optional(),
|
|
10281
|
+
items: z2.object({
|
|
10282
|
+
type: z2.literal("string"),
|
|
10283
|
+
enum: z2.array(z2.string())
|
|
10284
|
+
}),
|
|
10285
|
+
default: z2.array(z2.string()).optional()
|
|
10286
|
+
});
|
|
10287
|
+
var TitledMultiSelectEnumSchemaSchema = z2.object({
|
|
10288
|
+
type: z2.literal("array"),
|
|
10289
|
+
title: z2.string().optional(),
|
|
10290
|
+
description: z2.string().optional(),
|
|
10291
|
+
minItems: z2.number().optional(),
|
|
10292
|
+
maxItems: z2.number().optional(),
|
|
10293
|
+
items: z2.object({
|
|
10294
|
+
anyOf: z2.array(z2.object({
|
|
10295
|
+
const: z2.string(),
|
|
10296
|
+
title: z2.string()
|
|
10297
|
+
}))
|
|
10298
|
+
}),
|
|
10299
|
+
default: z2.array(z2.string()).optional()
|
|
10300
|
+
});
|
|
10301
|
+
var MultiSelectEnumSchemaSchema = z2.union([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema]);
|
|
10302
|
+
var EnumSchemaSchema = z2.union([LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema]);
|
|
10303
|
+
var PrimitiveSchemaDefinitionSchema = z2.union([EnumSchemaSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema]);
|
|
10304
|
+
var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
9949
10305
|
/**
|
|
9950
|
-
* The
|
|
10306
|
+
* The elicitation mode.
|
|
10307
|
+
*
|
|
10308
|
+
* Optional for backward compatibility. Clients MUST treat missing mode as "form".
|
|
9951
10309
|
*/
|
|
9952
|
-
|
|
10310
|
+
mode: z2.literal("form").optional(),
|
|
9953
10311
|
/**
|
|
9954
|
-
* The
|
|
10312
|
+
* The message to present to the user describing what information is being requested.
|
|
9955
10313
|
*/
|
|
9956
|
-
|
|
10314
|
+
message: z2.string(),
|
|
10315
|
+
/**
|
|
10316
|
+
* A restricted subset of JSON Schema.
|
|
10317
|
+
* Only top-level properties are allowed, without nesting.
|
|
10318
|
+
*/
|
|
10319
|
+
requestedSchema: z2.object({
|
|
10320
|
+
type: z2.literal("object"),
|
|
10321
|
+
properties: z2.record(z2.string(), PrimitiveSchemaDefinitionSchema),
|
|
10322
|
+
required: z2.array(z2.string()).optional()
|
|
10323
|
+
})
|
|
10324
|
+
});
|
|
10325
|
+
var ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
10326
|
+
/**
|
|
10327
|
+
* The elicitation mode.
|
|
10328
|
+
*/
|
|
10329
|
+
mode: z2.literal("url"),
|
|
10330
|
+
/**
|
|
10331
|
+
* The message to present to the user explaining why the interaction is needed.
|
|
10332
|
+
*/
|
|
10333
|
+
message: z2.string(),
|
|
10334
|
+
/**
|
|
10335
|
+
* The ID of the elicitation, which must be unique within the context of the server.
|
|
10336
|
+
* The client MUST treat this ID as an opaque value.
|
|
10337
|
+
*/
|
|
10338
|
+
elicitationId: z2.string(),
|
|
10339
|
+
/**
|
|
10340
|
+
* The URL that the user should navigate to.
|
|
10341
|
+
*/
|
|
10342
|
+
url: z2.string().url()
|
|
10343
|
+
});
|
|
10344
|
+
var ElicitRequestParamsSchema = z2.union([ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema]);
|
|
10345
|
+
var ElicitRequestSchema = RequestSchema.extend({
|
|
10346
|
+
method: z2.literal("elicitation/create"),
|
|
10347
|
+
params: ElicitRequestParamsSchema
|
|
10348
|
+
});
|
|
10349
|
+
var ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
10350
|
+
/**
|
|
10351
|
+
* The ID of the elicitation that completed.
|
|
10352
|
+
*/
|
|
10353
|
+
elicitationId: z2.string()
|
|
10354
|
+
});
|
|
10355
|
+
var ElicitationCompleteNotificationSchema = NotificationSchema.extend({
|
|
10356
|
+
method: z2.literal("notifications/elicitation/complete"),
|
|
10357
|
+
params: ElicitationCompleteNotificationParamsSchema
|
|
10358
|
+
});
|
|
10359
|
+
var ElicitResultSchema = ResultSchema.extend({
|
|
10360
|
+
/**
|
|
10361
|
+
* The user action in response to the elicitation.
|
|
10362
|
+
* - "accept": User submitted the form/confirmed the action
|
|
10363
|
+
* - "decline": User explicitly decline the action
|
|
10364
|
+
* - "cancel": User dismissed without making an explicit choice
|
|
10365
|
+
*/
|
|
10366
|
+
action: z2.enum(["accept", "decline", "cancel"]),
|
|
10367
|
+
/**
|
|
10368
|
+
* The submitted form data, only present when action is "accept".
|
|
10369
|
+
* Contains values matching the requested schema.
|
|
10370
|
+
* Per MCP spec, content is "typically omitted" for decline/cancel actions.
|
|
10371
|
+
* We normalize null to undefined for leniency while maintaining type compatibility.
|
|
10372
|
+
*/
|
|
10373
|
+
content: z2.preprocess((val) => val === null ? void 0 : val, z2.record(z2.string(), z2.union([z2.string(), z2.number(), z2.boolean(), z2.array(z2.string())])).optional())
|
|
9957
10374
|
});
|
|
9958
10375
|
var ResourceTemplateReferenceSchema = z2.object({
|
|
9959
10376
|
type: z2.literal("ref/resource"),
|
|
@@ -9961,41 +10378,42 @@ var ResourceTemplateReferenceSchema = z2.object({
|
|
|
9961
10378
|
* The URI or URI template of the resource.
|
|
9962
10379
|
*/
|
|
9963
10380
|
uri: z2.string()
|
|
9964
|
-
})
|
|
10381
|
+
});
|
|
9965
10382
|
var PromptReferenceSchema = z2.object({
|
|
9966
10383
|
type: z2.literal("ref/prompt"),
|
|
9967
10384
|
/**
|
|
9968
10385
|
* The name of the prompt or prompt template
|
|
9969
10386
|
*/
|
|
9970
10387
|
name: z2.string()
|
|
9971
|
-
})
|
|
9972
|
-
var
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
10388
|
+
});
|
|
10389
|
+
var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
10390
|
+
ref: z2.union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
|
|
10391
|
+
/**
|
|
10392
|
+
* The argument's information
|
|
10393
|
+
*/
|
|
10394
|
+
argument: z2.object({
|
|
9976
10395
|
/**
|
|
9977
|
-
* The argument
|
|
10396
|
+
* The name of the argument
|
|
9978
10397
|
*/
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
})
|
|
10398
|
+
name: z2.string(),
|
|
10399
|
+
/**
|
|
10400
|
+
* The value of the argument to use for completion matching.
|
|
10401
|
+
*/
|
|
10402
|
+
value: z2.string()
|
|
10403
|
+
}),
|
|
10404
|
+
context: z2.object({
|
|
10405
|
+
/**
|
|
10406
|
+
* Previously-resolved variables in a URI template or prompt.
|
|
10407
|
+
*/
|
|
10408
|
+
arguments: z2.record(z2.string(), z2.string()).optional()
|
|
10409
|
+
}).optional()
|
|
10410
|
+
});
|
|
10411
|
+
var CompleteRequestSchema = RequestSchema.extend({
|
|
10412
|
+
method: z2.literal("completion/complete"),
|
|
10413
|
+
params: CompleteRequestParamsSchema
|
|
9996
10414
|
});
|
|
9997
10415
|
var CompleteResultSchema = ResultSchema.extend({
|
|
9998
|
-
completion: z2.
|
|
10416
|
+
completion: z2.looseObject({
|
|
9999
10417
|
/**
|
|
10000
10418
|
* An array of completion values. Must not exceed 100 items.
|
|
10001
10419
|
*/
|
|
@@ -10008,7 +10426,7 @@ var CompleteResultSchema = ResultSchema.extend({
|
|
|
10008
10426
|
* Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
|
|
10009
10427
|
*/
|
|
10010
10428
|
hasMore: z2.optional(z2.boolean())
|
|
10011
|
-
})
|
|
10429
|
+
})
|
|
10012
10430
|
});
|
|
10013
10431
|
var RootSchema = z2.object({
|
|
10014
10432
|
/**
|
|
@@ -10018,21 +10436,23 @@ var RootSchema = z2.object({
|
|
|
10018
10436
|
/**
|
|
10019
10437
|
* An optional name for the root.
|
|
10020
10438
|
*/
|
|
10021
|
-
name: z2.
|
|
10439
|
+
name: z2.string().optional(),
|
|
10022
10440
|
/**
|
|
10023
10441
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
10024
10442
|
* for notes on _meta usage.
|
|
10025
10443
|
*/
|
|
10026
|
-
_meta: z2.
|
|
10027
|
-
})
|
|
10444
|
+
_meta: z2.record(z2.string(), z2.unknown()).optional()
|
|
10445
|
+
});
|
|
10028
10446
|
var ListRootsRequestSchema = RequestSchema.extend({
|
|
10029
|
-
method: z2.literal("roots/list")
|
|
10447
|
+
method: z2.literal("roots/list"),
|
|
10448
|
+
params: BaseRequestParamsSchema.optional()
|
|
10030
10449
|
});
|
|
10031
10450
|
var ListRootsResultSchema = ResultSchema.extend({
|
|
10032
10451
|
roots: z2.array(RootSchema)
|
|
10033
10452
|
});
|
|
10034
10453
|
var RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
10035
|
-
method: z2.literal("notifications/roots/list_changed")
|
|
10454
|
+
method: z2.literal("notifications/roots/list_changed"),
|
|
10455
|
+
params: NotificationsParamsSchema.optional()
|
|
10036
10456
|
});
|
|
10037
10457
|
var ClientRequestSchema = z2.union([
|
|
10038
10458
|
PingRequestSchema,
|
|
@@ -10047,16 +10467,39 @@ var ClientRequestSchema = z2.union([
|
|
|
10047
10467
|
SubscribeRequestSchema,
|
|
10048
10468
|
UnsubscribeRequestSchema,
|
|
10049
10469
|
CallToolRequestSchema,
|
|
10050
|
-
ListToolsRequestSchema
|
|
10470
|
+
ListToolsRequestSchema,
|
|
10471
|
+
GetTaskRequestSchema,
|
|
10472
|
+
GetTaskPayloadRequestSchema,
|
|
10473
|
+
ListTasksRequestSchema,
|
|
10474
|
+
CancelTaskRequestSchema
|
|
10051
10475
|
]);
|
|
10052
10476
|
var ClientNotificationSchema = z2.union([
|
|
10053
10477
|
CancelledNotificationSchema,
|
|
10054
10478
|
ProgressNotificationSchema,
|
|
10055
10479
|
InitializedNotificationSchema,
|
|
10056
|
-
RootsListChangedNotificationSchema
|
|
10480
|
+
RootsListChangedNotificationSchema,
|
|
10481
|
+
TaskStatusNotificationSchema
|
|
10482
|
+
]);
|
|
10483
|
+
var ClientResultSchema = z2.union([
|
|
10484
|
+
EmptyResultSchema,
|
|
10485
|
+
CreateMessageResultSchema,
|
|
10486
|
+
CreateMessageResultWithToolsSchema,
|
|
10487
|
+
ElicitResultSchema,
|
|
10488
|
+
ListRootsResultSchema,
|
|
10489
|
+
GetTaskResultSchema,
|
|
10490
|
+
ListTasksResultSchema,
|
|
10491
|
+
CreateTaskResultSchema
|
|
10492
|
+
]);
|
|
10493
|
+
var ServerRequestSchema = z2.union([
|
|
10494
|
+
PingRequestSchema,
|
|
10495
|
+
CreateMessageRequestSchema,
|
|
10496
|
+
ElicitRequestSchema,
|
|
10497
|
+
ListRootsRequestSchema,
|
|
10498
|
+
GetTaskRequestSchema,
|
|
10499
|
+
GetTaskPayloadRequestSchema,
|
|
10500
|
+
ListTasksRequestSchema,
|
|
10501
|
+
CancelTaskRequestSchema
|
|
10057
10502
|
]);
|
|
10058
|
-
var ClientResultSchema = z2.union([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
|
|
10059
|
-
var ServerRequestSchema = z2.union([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
|
|
10060
10503
|
var ServerNotificationSchema = z2.union([
|
|
10061
10504
|
CancelledNotificationSchema,
|
|
10062
10505
|
ProgressNotificationSchema,
|
|
@@ -10064,7 +10507,9 @@ var ServerNotificationSchema = z2.union([
|
|
|
10064
10507
|
ResourceUpdatedNotificationSchema,
|
|
10065
10508
|
ResourceListChangedNotificationSchema,
|
|
10066
10509
|
ToolListChangedNotificationSchema,
|
|
10067
|
-
PromptListChangedNotificationSchema
|
|
10510
|
+
PromptListChangedNotificationSchema,
|
|
10511
|
+
TaskStatusNotificationSchema,
|
|
10512
|
+
ElicitationCompleteNotificationSchema
|
|
10068
10513
|
]);
|
|
10069
10514
|
var ServerResultSchema = z2.union([
|
|
10070
10515
|
EmptyResultSchema,
|
|
@@ -10076,18 +10521,195 @@ var ServerResultSchema = z2.union([
|
|
|
10076
10521
|
ListResourceTemplatesResultSchema,
|
|
10077
10522
|
ReadResourceResultSchema,
|
|
10078
10523
|
CallToolResultSchema,
|
|
10079
|
-
ListToolsResultSchema
|
|
10524
|
+
ListToolsResultSchema,
|
|
10525
|
+
GetTaskResultSchema,
|
|
10526
|
+
ListTasksResultSchema,
|
|
10527
|
+
CreateTaskResultSchema
|
|
10080
10528
|
]);
|
|
10081
|
-
var McpError = class extends Error {
|
|
10529
|
+
var McpError = class _McpError extends Error {
|
|
10082
10530
|
constructor(code, message, data) {
|
|
10083
10531
|
super(`MCP error ${code}: ${message}`);
|
|
10084
10532
|
this.code = code;
|
|
10085
10533
|
this.data = data;
|
|
10086
10534
|
this.name = "McpError";
|
|
10087
10535
|
}
|
|
10536
|
+
/**
|
|
10537
|
+
* Factory method to create the appropriate error type based on the error code and data
|
|
10538
|
+
*/
|
|
10539
|
+
static fromError(code, message, data) {
|
|
10540
|
+
if (code === ErrorCode.UrlElicitationRequired && data) {
|
|
10541
|
+
const errorData = data;
|
|
10542
|
+
if (errorData.elicitations) {
|
|
10543
|
+
return new UrlElicitationRequiredError(errorData.elicitations, message);
|
|
10544
|
+
}
|
|
10545
|
+
}
|
|
10546
|
+
return new _McpError(code, message, data);
|
|
10547
|
+
}
|
|
10548
|
+
};
|
|
10549
|
+
var UrlElicitationRequiredError = class extends McpError {
|
|
10550
|
+
constructor(elicitations, message = `URL elicitation${elicitations.length > 1 ? "s" : ""} required`) {
|
|
10551
|
+
super(ErrorCode.UrlElicitationRequired, message, {
|
|
10552
|
+
elicitations
|
|
10553
|
+
});
|
|
10554
|
+
}
|
|
10555
|
+
get elicitations() {
|
|
10556
|
+
return this.data?.elicitations ?? [];
|
|
10557
|
+
}
|
|
10088
10558
|
};
|
|
10089
10559
|
|
|
10090
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
10560
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
10561
|
+
init_esm_shims();
|
|
10562
|
+
function isTerminal(status) {
|
|
10563
|
+
return status === "completed" || status === "failed" || status === "cancelled";
|
|
10564
|
+
}
|
|
10565
|
+
|
|
10566
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
10567
|
+
init_esm_shims();
|
|
10568
|
+
import * as z4mini2 from "zod/v4-mini";
|
|
10569
|
+
|
|
10570
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/index.js
|
|
10571
|
+
init_esm_shims();
|
|
10572
|
+
|
|
10573
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
10574
|
+
init_esm_shims();
|
|
10575
|
+
|
|
10576
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
10577
|
+
init_esm_shims();
|
|
10578
|
+
|
|
10579
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
10580
|
+
init_esm_shims();
|
|
10581
|
+
|
|
10582
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
10583
|
+
init_esm_shims();
|
|
10584
|
+
|
|
10585
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
10586
|
+
init_esm_shims();
|
|
10587
|
+
|
|
10588
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
10589
|
+
init_esm_shims();
|
|
10590
|
+
import { ZodFirstPartyTypeKind as ZodFirstPartyTypeKind3 } from "zod/v3";
|
|
10591
|
+
|
|
10592
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
10593
|
+
init_esm_shims();
|
|
10594
|
+
|
|
10595
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
10596
|
+
init_esm_shims();
|
|
10597
|
+
import { ZodFirstPartyTypeKind } from "zod/v3";
|
|
10598
|
+
|
|
10599
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
10600
|
+
init_esm_shims();
|
|
10601
|
+
|
|
10602
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
10603
|
+
init_esm_shims();
|
|
10604
|
+
|
|
10605
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
10606
|
+
init_esm_shims();
|
|
10607
|
+
|
|
10608
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
10609
|
+
init_esm_shims();
|
|
10610
|
+
|
|
10611
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
10612
|
+
init_esm_shims();
|
|
10613
|
+
|
|
10614
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
10615
|
+
init_esm_shims();
|
|
10616
|
+
|
|
10617
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
10618
|
+
init_esm_shims();
|
|
10619
|
+
|
|
10620
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
10621
|
+
init_esm_shims();
|
|
10622
|
+
|
|
10623
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
10624
|
+
init_esm_shims();
|
|
10625
|
+
|
|
10626
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
10627
|
+
init_esm_shims();
|
|
10628
|
+
|
|
10629
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
10630
|
+
init_esm_shims();
|
|
10631
|
+
|
|
10632
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
10633
|
+
init_esm_shims();
|
|
10634
|
+
import { ZodFirstPartyTypeKind as ZodFirstPartyTypeKind2 } from "zod/v3";
|
|
10635
|
+
|
|
10636
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
10637
|
+
init_esm_shims();
|
|
10638
|
+
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
10639
|
+
|
|
10640
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
10641
|
+
init_esm_shims();
|
|
10642
|
+
|
|
10643
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
10644
|
+
init_esm_shims();
|
|
10645
|
+
|
|
10646
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
10647
|
+
init_esm_shims();
|
|
10648
|
+
|
|
10649
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
10650
|
+
init_esm_shims();
|
|
10651
|
+
|
|
10652
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
10653
|
+
init_esm_shims();
|
|
10654
|
+
|
|
10655
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
10656
|
+
init_esm_shims();
|
|
10657
|
+
|
|
10658
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
10659
|
+
init_esm_shims();
|
|
10660
|
+
|
|
10661
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
10662
|
+
init_esm_shims();
|
|
10663
|
+
|
|
10664
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
10665
|
+
init_esm_shims();
|
|
10666
|
+
|
|
10667
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
10668
|
+
init_esm_shims();
|
|
10669
|
+
|
|
10670
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
10671
|
+
init_esm_shims();
|
|
10672
|
+
|
|
10673
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
10674
|
+
init_esm_shims();
|
|
10675
|
+
|
|
10676
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
10677
|
+
init_esm_shims();
|
|
10678
|
+
|
|
10679
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
10680
|
+
init_esm_shims();
|
|
10681
|
+
|
|
10682
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
10683
|
+
init_esm_shims();
|
|
10684
|
+
|
|
10685
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseTypes.js
|
|
10686
|
+
init_esm_shims();
|
|
10687
|
+
|
|
10688
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
10689
|
+
init_esm_shims();
|
|
10690
|
+
|
|
10691
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
10692
|
+
function getMethodLiteral(schema) {
|
|
10693
|
+
const shape = getObjectShape(schema);
|
|
10694
|
+
const methodSchema = shape?.method;
|
|
10695
|
+
if (!methodSchema) {
|
|
10696
|
+
throw new Error("Schema is missing a method literal");
|
|
10697
|
+
}
|
|
10698
|
+
const value = getLiteralValue(methodSchema);
|
|
10699
|
+
if (typeof value !== "string") {
|
|
10700
|
+
throw new Error("Schema method literal must be a string");
|
|
10701
|
+
}
|
|
10702
|
+
return value;
|
|
10703
|
+
}
|
|
10704
|
+
function parseWithCompat(schema, data) {
|
|
10705
|
+
const result = safeParse2(schema, data);
|
|
10706
|
+
if (!result.success) {
|
|
10707
|
+
throw result.error;
|
|
10708
|
+
}
|
|
10709
|
+
return result.data;
|
|
10710
|
+
}
|
|
10711
|
+
|
|
10712
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
10091
10713
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
|
|
10092
10714
|
var Protocol = class {
|
|
10093
10715
|
constructor(_options) {
|
|
@@ -10100,9 +10722,10 @@ var Protocol = class {
|
|
|
10100
10722
|
this._progressHandlers = /* @__PURE__ */ new Map();
|
|
10101
10723
|
this._timeoutInfo = /* @__PURE__ */ new Map();
|
|
10102
10724
|
this._pendingDebouncedNotifications = /* @__PURE__ */ new Set();
|
|
10725
|
+
this._taskProgressTokens = /* @__PURE__ */ new Map();
|
|
10726
|
+
this._requestResolvers = /* @__PURE__ */ new Map();
|
|
10103
10727
|
this.setNotificationHandler(CancelledNotificationSchema, (notification) => {
|
|
10104
|
-
|
|
10105
|
-
controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
|
|
10728
|
+
this._oncancel(notification);
|
|
10106
10729
|
});
|
|
10107
10730
|
this.setNotificationHandler(ProgressNotificationSchema, (notification) => {
|
|
10108
10731
|
this._onprogress(notification);
|
|
@@ -10112,6 +10735,117 @@ var Protocol = class {
|
|
|
10112
10735
|
// Automatic pong by default.
|
|
10113
10736
|
(_request) => ({})
|
|
10114
10737
|
);
|
|
10738
|
+
this._taskStore = _options?.taskStore;
|
|
10739
|
+
this._taskMessageQueue = _options?.taskMessageQueue;
|
|
10740
|
+
if (this._taskStore) {
|
|
10741
|
+
this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
|
|
10742
|
+
const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
10743
|
+
if (!task) {
|
|
10744
|
+
throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
|
|
10745
|
+
}
|
|
10746
|
+
return {
|
|
10747
|
+
...task
|
|
10748
|
+
};
|
|
10749
|
+
});
|
|
10750
|
+
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
10751
|
+
const handleTaskResult = async () => {
|
|
10752
|
+
const taskId = request.params.taskId;
|
|
10753
|
+
if (this._taskMessageQueue) {
|
|
10754
|
+
let queuedMessage;
|
|
10755
|
+
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
10756
|
+
if (queuedMessage.type === "response" || queuedMessage.type === "error") {
|
|
10757
|
+
const message = queuedMessage.message;
|
|
10758
|
+
const requestId = message.id;
|
|
10759
|
+
const resolver = this._requestResolvers.get(requestId);
|
|
10760
|
+
if (resolver) {
|
|
10761
|
+
this._requestResolvers.delete(requestId);
|
|
10762
|
+
if (queuedMessage.type === "response") {
|
|
10763
|
+
resolver(message);
|
|
10764
|
+
} else {
|
|
10765
|
+
const errorMessage = message;
|
|
10766
|
+
const error2 = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
|
|
10767
|
+
resolver(error2);
|
|
10768
|
+
}
|
|
10769
|
+
} else {
|
|
10770
|
+
const messageType = queuedMessage.type === "response" ? "Response" : "Error";
|
|
10771
|
+
this._onerror(new Error(`${messageType} handler missing for request ${requestId}`));
|
|
10772
|
+
}
|
|
10773
|
+
continue;
|
|
10774
|
+
}
|
|
10775
|
+
await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
|
|
10776
|
+
}
|
|
10777
|
+
}
|
|
10778
|
+
const task = await this._taskStore.getTask(taskId, extra.sessionId);
|
|
10779
|
+
if (!task) {
|
|
10780
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
10781
|
+
}
|
|
10782
|
+
if (!isTerminal(task.status)) {
|
|
10783
|
+
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
10784
|
+
return await handleTaskResult();
|
|
10785
|
+
}
|
|
10786
|
+
if (isTerminal(task.status)) {
|
|
10787
|
+
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
10788
|
+
this._clearTaskQueue(taskId);
|
|
10789
|
+
return {
|
|
10790
|
+
...result,
|
|
10791
|
+
_meta: {
|
|
10792
|
+
...result._meta,
|
|
10793
|
+
[RELATED_TASK_META_KEY]: {
|
|
10794
|
+
taskId
|
|
10795
|
+
}
|
|
10796
|
+
}
|
|
10797
|
+
};
|
|
10798
|
+
}
|
|
10799
|
+
return await handleTaskResult();
|
|
10800
|
+
};
|
|
10801
|
+
return await handleTaskResult();
|
|
10802
|
+
});
|
|
10803
|
+
this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
|
|
10804
|
+
try {
|
|
10805
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
|
|
10806
|
+
return {
|
|
10807
|
+
tasks,
|
|
10808
|
+
nextCursor,
|
|
10809
|
+
_meta: {}
|
|
10810
|
+
};
|
|
10811
|
+
} catch (error2) {
|
|
10812
|
+
throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
10813
|
+
}
|
|
10814
|
+
});
|
|
10815
|
+
this.setRequestHandler(CancelTaskRequestSchema, async (request, extra) => {
|
|
10816
|
+
try {
|
|
10817
|
+
const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
10818
|
+
if (!task) {
|
|
10819
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request.params.taskId}`);
|
|
10820
|
+
}
|
|
10821
|
+
if (isTerminal(task.status)) {
|
|
10822
|
+
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
10823
|
+
}
|
|
10824
|
+
await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
10825
|
+
this._clearTaskQueue(request.params.taskId);
|
|
10826
|
+
const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
10827
|
+
if (!cancelledTask) {
|
|
10828
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
|
|
10829
|
+
}
|
|
10830
|
+
return {
|
|
10831
|
+
_meta: {},
|
|
10832
|
+
...cancelledTask
|
|
10833
|
+
};
|
|
10834
|
+
} catch (error2) {
|
|
10835
|
+
if (error2 instanceof McpError) {
|
|
10836
|
+
throw error2;
|
|
10837
|
+
}
|
|
10838
|
+
throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
10839
|
+
}
|
|
10840
|
+
});
|
|
10841
|
+
}
|
|
10842
|
+
}
|
|
10843
|
+
async _oncancel(notification) {
|
|
10844
|
+
if (!notification.params.requestId) {
|
|
10845
|
+
return;
|
|
10846
|
+
}
|
|
10847
|
+
const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
|
|
10848
|
+
controller?.abort(notification.params.reason);
|
|
10115
10849
|
}
|
|
10116
10850
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
10117
10851
|
this._timeoutInfo.set(messageId, {
|
|
@@ -10130,7 +10864,7 @@ var Protocol = class {
|
|
|
10130
10864
|
const totalElapsed = Date.now() - info2.startTime;
|
|
10131
10865
|
if (info2.maxTotalTimeout && totalElapsed >= info2.maxTotalTimeout) {
|
|
10132
10866
|
this._timeoutInfo.delete(messageId);
|
|
10133
|
-
throw
|
|
10867
|
+
throw McpError.fromError(ErrorCode.RequestTimeout, "Maximum total timeout exceeded", {
|
|
10134
10868
|
maxTotalTimeout: info2.maxTotalTimeout,
|
|
10135
10869
|
totalElapsed
|
|
10136
10870
|
});
|
|
@@ -10152,22 +10886,21 @@ var Protocol = class {
|
|
|
10152
10886
|
* The Protocol object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
|
|
10153
10887
|
*/
|
|
10154
10888
|
async connect(transport) {
|
|
10155
|
-
var _a, _b, _c;
|
|
10156
10889
|
this._transport = transport;
|
|
10157
|
-
const _onclose =
|
|
10890
|
+
const _onclose = this.transport?.onclose;
|
|
10158
10891
|
this._transport.onclose = () => {
|
|
10159
|
-
_onclose
|
|
10892
|
+
_onclose?.();
|
|
10160
10893
|
this._onclose();
|
|
10161
10894
|
};
|
|
10162
|
-
const _onerror =
|
|
10895
|
+
const _onerror = this.transport?.onerror;
|
|
10163
10896
|
this._transport.onerror = (error2) => {
|
|
10164
|
-
_onerror
|
|
10897
|
+
_onerror?.(error2);
|
|
10165
10898
|
this._onerror(error2);
|
|
10166
10899
|
};
|
|
10167
|
-
const _onmessage =
|
|
10900
|
+
const _onmessage = this._transport?.onmessage;
|
|
10168
10901
|
this._transport.onmessage = (message, extra) => {
|
|
10169
|
-
_onmessage
|
|
10170
|
-
if (
|
|
10902
|
+
_onmessage?.(message, extra);
|
|
10903
|
+
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
|
|
10171
10904
|
this._onresponse(message);
|
|
10172
10905
|
} else if (isJSONRPCRequest(message)) {
|
|
10173
10906
|
this._onrequest(message, extra);
|
|
@@ -10180,79 +10913,131 @@ var Protocol = class {
|
|
|
10180
10913
|
await this._transport.start();
|
|
10181
10914
|
}
|
|
10182
10915
|
_onclose() {
|
|
10183
|
-
var _a;
|
|
10184
10916
|
const responseHandlers = this._responseHandlers;
|
|
10185
10917
|
this._responseHandlers = /* @__PURE__ */ new Map();
|
|
10186
10918
|
this._progressHandlers.clear();
|
|
10919
|
+
this._taskProgressTokens.clear();
|
|
10187
10920
|
this._pendingDebouncedNotifications.clear();
|
|
10921
|
+
const error2 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
10188
10922
|
this._transport = void 0;
|
|
10189
|
-
|
|
10190
|
-
const error2 = new McpError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
10923
|
+
this.onclose?.();
|
|
10191
10924
|
for (const handler of responseHandlers.values()) {
|
|
10192
10925
|
handler(error2);
|
|
10193
10926
|
}
|
|
10194
10927
|
}
|
|
10195
10928
|
_onerror(error2) {
|
|
10196
|
-
|
|
10197
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
|
|
10929
|
+
this.onerror?.(error2);
|
|
10198
10930
|
}
|
|
10199
10931
|
_onnotification(notification) {
|
|
10200
|
-
|
|
10201
|
-
const handler = (_a = this._notificationHandlers.get(notification.method)) !== null && _a !== void 0 ? _a : this.fallbackNotificationHandler;
|
|
10932
|
+
const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
|
|
10202
10933
|
if (handler === void 0) {
|
|
10203
10934
|
return;
|
|
10204
10935
|
}
|
|
10205
10936
|
Promise.resolve().then(() => handler(notification)).catch((error2) => this._onerror(new Error(`Uncaught error in notification handler: ${error2}`)));
|
|
10206
10937
|
}
|
|
10207
10938
|
_onrequest(request, extra) {
|
|
10208
|
-
|
|
10209
|
-
const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
|
|
10939
|
+
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
10210
10940
|
const capturedTransport = this._transport;
|
|
10941
|
+
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
10211
10942
|
if (handler === void 0) {
|
|
10212
|
-
|
|
10943
|
+
const errorResponse = {
|
|
10213
10944
|
jsonrpc: "2.0",
|
|
10214
10945
|
id: request.id,
|
|
10215
10946
|
error: {
|
|
10216
10947
|
code: ErrorCode.MethodNotFound,
|
|
10217
10948
|
message: "Method not found"
|
|
10218
10949
|
}
|
|
10219
|
-
}
|
|
10950
|
+
};
|
|
10951
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
10952
|
+
this._enqueueTaskMessage(relatedTaskId, {
|
|
10953
|
+
type: "error",
|
|
10954
|
+
message: errorResponse,
|
|
10955
|
+
timestamp: Date.now()
|
|
10956
|
+
}, capturedTransport?.sessionId).catch((error2) => this._onerror(new Error(`Failed to enqueue error response: ${error2}`)));
|
|
10957
|
+
} else {
|
|
10958
|
+
capturedTransport?.send(errorResponse).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
10959
|
+
}
|
|
10220
10960
|
return;
|
|
10221
10961
|
}
|
|
10222
10962
|
const abortController = new AbortController();
|
|
10223
10963
|
this._requestHandlerAbortControllers.set(request.id, abortController);
|
|
10964
|
+
const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
|
|
10965
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
|
|
10224
10966
|
const fullExtra = {
|
|
10225
10967
|
signal: abortController.signal,
|
|
10226
|
-
sessionId: capturedTransport
|
|
10227
|
-
_meta:
|
|
10228
|
-
sendNotification: (notification) =>
|
|
10229
|
-
|
|
10230
|
-
|
|
10968
|
+
sessionId: capturedTransport?.sessionId,
|
|
10969
|
+
_meta: request.params?._meta,
|
|
10970
|
+
sendNotification: async (notification) => {
|
|
10971
|
+
const notificationOptions = { relatedRequestId: request.id };
|
|
10972
|
+
if (relatedTaskId) {
|
|
10973
|
+
notificationOptions.relatedTask = { taskId: relatedTaskId };
|
|
10974
|
+
}
|
|
10975
|
+
await this.notification(notification, notificationOptions);
|
|
10976
|
+
},
|
|
10977
|
+
sendRequest: async (r, resultSchema, options) => {
|
|
10978
|
+
const requestOptions = { ...options, relatedRequestId: request.id };
|
|
10979
|
+
if (relatedTaskId && !requestOptions.relatedTask) {
|
|
10980
|
+
requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
10981
|
+
}
|
|
10982
|
+
const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
|
|
10983
|
+
if (effectiveTaskId && taskStore) {
|
|
10984
|
+
await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
|
|
10985
|
+
}
|
|
10986
|
+
return await this.request(r, resultSchema, requestOptions);
|
|
10987
|
+
},
|
|
10988
|
+
authInfo: extra?.authInfo,
|
|
10231
10989
|
requestId: request.id,
|
|
10232
|
-
requestInfo: extra
|
|
10233
|
-
|
|
10234
|
-
|
|
10990
|
+
requestInfo: extra?.requestInfo,
|
|
10991
|
+
taskId: relatedTaskId,
|
|
10992
|
+
taskStore,
|
|
10993
|
+
taskRequestedTtl: taskCreationParams?.ttl,
|
|
10994
|
+
closeSSEStream: extra?.closeSSEStream,
|
|
10995
|
+
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
10996
|
+
};
|
|
10997
|
+
Promise.resolve().then(() => {
|
|
10998
|
+
if (taskCreationParams) {
|
|
10999
|
+
this.assertTaskHandlerCapability(request.method);
|
|
11000
|
+
}
|
|
11001
|
+
}).then(() => handler(request, fullExtra)).then(async (result) => {
|
|
10235
11002
|
if (abortController.signal.aborted) {
|
|
10236
11003
|
return;
|
|
10237
11004
|
}
|
|
10238
|
-
|
|
11005
|
+
const response = {
|
|
10239
11006
|
result,
|
|
10240
11007
|
jsonrpc: "2.0",
|
|
10241
11008
|
id: request.id
|
|
10242
|
-
}
|
|
10243
|
-
|
|
10244
|
-
|
|
11009
|
+
};
|
|
11010
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
11011
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
11012
|
+
type: "response",
|
|
11013
|
+
message: response,
|
|
11014
|
+
timestamp: Date.now()
|
|
11015
|
+
}, capturedTransport?.sessionId);
|
|
11016
|
+
} else {
|
|
11017
|
+
await capturedTransport?.send(response);
|
|
11018
|
+
}
|
|
11019
|
+
}, async (error2) => {
|
|
10245
11020
|
if (abortController.signal.aborted) {
|
|
10246
11021
|
return;
|
|
10247
11022
|
}
|
|
10248
|
-
|
|
11023
|
+
const errorResponse = {
|
|
10249
11024
|
jsonrpc: "2.0",
|
|
10250
11025
|
id: request.id,
|
|
10251
11026
|
error: {
|
|
10252
11027
|
code: Number.isSafeInteger(error2["code"]) ? error2["code"] : ErrorCode.InternalError,
|
|
10253
|
-
message:
|
|
11028
|
+
message: error2.message ?? "Internal error",
|
|
11029
|
+
...error2["data"] !== void 0 && { data: error2["data"] }
|
|
10254
11030
|
}
|
|
10255
|
-
}
|
|
11031
|
+
};
|
|
11032
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
11033
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
11034
|
+
type: "error",
|
|
11035
|
+
message: errorResponse,
|
|
11036
|
+
timestamp: Date.now()
|
|
11037
|
+
}, capturedTransport?.sessionId);
|
|
11038
|
+
} else {
|
|
11039
|
+
await capturedTransport?.send(errorResponse);
|
|
11040
|
+
}
|
|
10256
11041
|
}).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
|
|
10257
11042
|
this._requestHandlerAbortControllers.delete(request.id);
|
|
10258
11043
|
});
|
|
@@ -10271,6 +11056,9 @@ var Protocol = class {
|
|
|
10271
11056
|
try {
|
|
10272
11057
|
this._resetTimeout(messageId);
|
|
10273
11058
|
} catch (error2) {
|
|
11059
|
+
this._responseHandlers.delete(messageId);
|
|
11060
|
+
this._progressHandlers.delete(messageId);
|
|
11061
|
+
this._cleanupTimeout(messageId);
|
|
10274
11062
|
responseHandler(error2);
|
|
10275
11063
|
return;
|
|
10276
11064
|
}
|
|
@@ -10279,18 +11067,42 @@ var Protocol = class {
|
|
|
10279
11067
|
}
|
|
10280
11068
|
_onresponse(response) {
|
|
10281
11069
|
const messageId = Number(response.id);
|
|
11070
|
+
const resolver = this._requestResolvers.get(messageId);
|
|
11071
|
+
if (resolver) {
|
|
11072
|
+
this._requestResolvers.delete(messageId);
|
|
11073
|
+
if (isJSONRPCResultResponse(response)) {
|
|
11074
|
+
resolver(response);
|
|
11075
|
+
} else {
|
|
11076
|
+
const error2 = new McpError(response.error.code, response.error.message, response.error.data);
|
|
11077
|
+
resolver(error2);
|
|
11078
|
+
}
|
|
11079
|
+
return;
|
|
11080
|
+
}
|
|
10282
11081
|
const handler = this._responseHandlers.get(messageId);
|
|
10283
11082
|
if (handler === void 0) {
|
|
10284
11083
|
this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(response)}`));
|
|
10285
11084
|
return;
|
|
10286
11085
|
}
|
|
10287
11086
|
this._responseHandlers.delete(messageId);
|
|
10288
|
-
this._progressHandlers.delete(messageId);
|
|
10289
11087
|
this._cleanupTimeout(messageId);
|
|
10290
|
-
|
|
11088
|
+
let isTaskResponse = false;
|
|
11089
|
+
if (isJSONRPCResultResponse(response) && response.result && typeof response.result === "object") {
|
|
11090
|
+
const result = response.result;
|
|
11091
|
+
if (result.task && typeof result.task === "object") {
|
|
11092
|
+
const task = result.task;
|
|
11093
|
+
if (typeof task.taskId === "string") {
|
|
11094
|
+
isTaskResponse = true;
|
|
11095
|
+
this._taskProgressTokens.set(task.taskId, messageId);
|
|
11096
|
+
}
|
|
11097
|
+
}
|
|
11098
|
+
}
|
|
11099
|
+
if (!isTaskResponse) {
|
|
11100
|
+
this._progressHandlers.delete(messageId);
|
|
11101
|
+
}
|
|
11102
|
+
if (isJSONRPCResultResponse(response)) {
|
|
10291
11103
|
handler(response);
|
|
10292
11104
|
} else {
|
|
10293
|
-
const error2 =
|
|
11105
|
+
const error2 = McpError.fromError(response.error.code, response.error.message, response.error.data);
|
|
10294
11106
|
handler(error2);
|
|
10295
11107
|
}
|
|
10296
11108
|
}
|
|
@@ -10301,119 +11113,326 @@ var Protocol = class {
|
|
|
10301
11113
|
* Closes the connection.
|
|
10302
11114
|
*/
|
|
10303
11115
|
async close() {
|
|
10304
|
-
|
|
10305
|
-
|
|
11116
|
+
await this._transport?.close();
|
|
11117
|
+
}
|
|
11118
|
+
/**
|
|
11119
|
+
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
11120
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
11121
|
+
*
|
|
11122
|
+
* @example
|
|
11123
|
+
* ```typescript
|
|
11124
|
+
* const stream = protocol.requestStream(request, resultSchema, options);
|
|
11125
|
+
* for await (const message of stream) {
|
|
11126
|
+
* switch (message.type) {
|
|
11127
|
+
* case 'taskCreated':
|
|
11128
|
+
* console.log('Task created:', message.task.taskId);
|
|
11129
|
+
* break;
|
|
11130
|
+
* case 'taskStatus':
|
|
11131
|
+
* console.log('Task status:', message.task.status);
|
|
11132
|
+
* break;
|
|
11133
|
+
* case 'result':
|
|
11134
|
+
* console.log('Final result:', message.result);
|
|
11135
|
+
* break;
|
|
11136
|
+
* case 'error':
|
|
11137
|
+
* console.error('Error:', message.error);
|
|
11138
|
+
* break;
|
|
11139
|
+
* }
|
|
11140
|
+
* }
|
|
11141
|
+
* ```
|
|
11142
|
+
*
|
|
11143
|
+
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
|
|
11144
|
+
*/
|
|
11145
|
+
async *requestStream(request, resultSchema, options) {
|
|
11146
|
+
const { task } = options ?? {};
|
|
11147
|
+
if (!task) {
|
|
11148
|
+
try {
|
|
11149
|
+
const result = await this.request(request, resultSchema, options);
|
|
11150
|
+
yield { type: "result", result };
|
|
11151
|
+
} catch (error2) {
|
|
11152
|
+
yield {
|
|
11153
|
+
type: "error",
|
|
11154
|
+
error: error2 instanceof McpError ? error2 : new McpError(ErrorCode.InternalError, String(error2))
|
|
11155
|
+
};
|
|
11156
|
+
}
|
|
11157
|
+
return;
|
|
11158
|
+
}
|
|
11159
|
+
let taskId;
|
|
11160
|
+
try {
|
|
11161
|
+
const createResult = await this.request(request, CreateTaskResultSchema, options);
|
|
11162
|
+
if (createResult.task) {
|
|
11163
|
+
taskId = createResult.task.taskId;
|
|
11164
|
+
yield { type: "taskCreated", task: createResult.task };
|
|
11165
|
+
} else {
|
|
11166
|
+
throw new McpError(ErrorCode.InternalError, "Task creation did not return a task");
|
|
11167
|
+
}
|
|
11168
|
+
while (true) {
|
|
11169
|
+
const task2 = await this.getTask({ taskId }, options);
|
|
11170
|
+
yield { type: "taskStatus", task: task2 };
|
|
11171
|
+
if (isTerminal(task2.status)) {
|
|
11172
|
+
if (task2.status === "completed") {
|
|
11173
|
+
const result = await this.getTaskResult({ taskId }, resultSchema, options);
|
|
11174
|
+
yield { type: "result", result };
|
|
11175
|
+
} else if (task2.status === "failed") {
|
|
11176
|
+
yield {
|
|
11177
|
+
type: "error",
|
|
11178
|
+
error: new McpError(ErrorCode.InternalError, `Task ${taskId} failed`)
|
|
11179
|
+
};
|
|
11180
|
+
} else if (task2.status === "cancelled") {
|
|
11181
|
+
yield {
|
|
11182
|
+
type: "error",
|
|
11183
|
+
error: new McpError(ErrorCode.InternalError, `Task ${taskId} was cancelled`)
|
|
11184
|
+
};
|
|
11185
|
+
}
|
|
11186
|
+
return;
|
|
11187
|
+
}
|
|
11188
|
+
if (task2.status === "input_required") {
|
|
11189
|
+
const result = await this.getTaskResult({ taskId }, resultSchema, options);
|
|
11190
|
+
yield { type: "result", result };
|
|
11191
|
+
return;
|
|
11192
|
+
}
|
|
11193
|
+
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
11194
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
11195
|
+
options?.signal?.throwIfAborted();
|
|
11196
|
+
}
|
|
11197
|
+
} catch (error2) {
|
|
11198
|
+
yield {
|
|
11199
|
+
type: "error",
|
|
11200
|
+
error: error2 instanceof McpError ? error2 : new McpError(ErrorCode.InternalError, String(error2))
|
|
11201
|
+
};
|
|
11202
|
+
}
|
|
10306
11203
|
}
|
|
10307
11204
|
/**
|
|
10308
|
-
* Sends a request and
|
|
11205
|
+
* Sends a request and waits for a response.
|
|
10309
11206
|
*
|
|
10310
11207
|
* Do not use this method to emit notifications! Use notification() instead.
|
|
10311
11208
|
*/
|
|
10312
11209
|
request(request, resultSchema, options) {
|
|
10313
|
-
const { relatedRequestId, resumptionToken, onresumptiontoken } = options
|
|
11210
|
+
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
10314
11211
|
return new Promise((resolve, reject) => {
|
|
10315
|
-
|
|
11212
|
+
const earlyReject = (error2) => {
|
|
11213
|
+
reject(error2);
|
|
11214
|
+
};
|
|
10316
11215
|
if (!this._transport) {
|
|
10317
|
-
|
|
11216
|
+
earlyReject(new Error("Not connected"));
|
|
10318
11217
|
return;
|
|
10319
11218
|
}
|
|
10320
|
-
if (
|
|
10321
|
-
|
|
11219
|
+
if (this._options?.enforceStrictCapabilities === true) {
|
|
11220
|
+
try {
|
|
11221
|
+
this.assertCapabilityForMethod(request.method);
|
|
11222
|
+
if (task) {
|
|
11223
|
+
this.assertTaskCapability(request.method);
|
|
11224
|
+
}
|
|
11225
|
+
} catch (e) {
|
|
11226
|
+
earlyReject(e);
|
|
11227
|
+
return;
|
|
11228
|
+
}
|
|
10322
11229
|
}
|
|
10323
|
-
|
|
11230
|
+
options?.signal?.throwIfAborted();
|
|
10324
11231
|
const messageId = this._requestMessageId++;
|
|
10325
11232
|
const jsonrpcRequest = {
|
|
10326
11233
|
...request,
|
|
10327
11234
|
jsonrpc: "2.0",
|
|
10328
11235
|
id: messageId
|
|
10329
11236
|
};
|
|
10330
|
-
if (options
|
|
11237
|
+
if (options?.onprogress) {
|
|
10331
11238
|
this._progressHandlers.set(messageId, options.onprogress);
|
|
10332
11239
|
jsonrpcRequest.params = {
|
|
10333
11240
|
...request.params,
|
|
10334
11241
|
_meta: {
|
|
10335
|
-
...
|
|
11242
|
+
...request.params?._meta || {},
|
|
10336
11243
|
progressToken: messageId
|
|
10337
11244
|
}
|
|
10338
11245
|
};
|
|
10339
11246
|
}
|
|
11247
|
+
if (task) {
|
|
11248
|
+
jsonrpcRequest.params = {
|
|
11249
|
+
...jsonrpcRequest.params,
|
|
11250
|
+
task
|
|
11251
|
+
};
|
|
11252
|
+
}
|
|
11253
|
+
if (relatedTask) {
|
|
11254
|
+
jsonrpcRequest.params = {
|
|
11255
|
+
...jsonrpcRequest.params,
|
|
11256
|
+
_meta: {
|
|
11257
|
+
...jsonrpcRequest.params?._meta || {},
|
|
11258
|
+
[RELATED_TASK_META_KEY]: relatedTask
|
|
11259
|
+
}
|
|
11260
|
+
};
|
|
11261
|
+
}
|
|
10340
11262
|
const cancel = (reason) => {
|
|
10341
|
-
var _a2;
|
|
10342
11263
|
this._responseHandlers.delete(messageId);
|
|
10343
11264
|
this._progressHandlers.delete(messageId);
|
|
10344
11265
|
this._cleanupTimeout(messageId);
|
|
10345
|
-
|
|
11266
|
+
this._transport?.send({
|
|
10346
11267
|
jsonrpc: "2.0",
|
|
10347
11268
|
method: "notifications/cancelled",
|
|
10348
11269
|
params: {
|
|
10349
11270
|
requestId: messageId,
|
|
10350
11271
|
reason: String(reason)
|
|
10351
11272
|
}
|
|
10352
|
-
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((
|
|
10353
|
-
|
|
11273
|
+
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error3) => this._onerror(new Error(`Failed to send cancellation: ${error3}`)));
|
|
11274
|
+
const error2 = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
|
|
11275
|
+
reject(error2);
|
|
10354
11276
|
};
|
|
10355
11277
|
this._responseHandlers.set(messageId, (response) => {
|
|
10356
|
-
|
|
10357
|
-
if ((_a2 = options === null || options === void 0 ? void 0 : options.signal) === null || _a2 === void 0 ? void 0 : _a2.aborted) {
|
|
11278
|
+
if (options?.signal?.aborted) {
|
|
10358
11279
|
return;
|
|
10359
11280
|
}
|
|
10360
11281
|
if (response instanceof Error) {
|
|
10361
11282
|
return reject(response);
|
|
10362
11283
|
}
|
|
10363
11284
|
try {
|
|
10364
|
-
const
|
|
10365
|
-
|
|
11285
|
+
const parseResult = safeParse2(resultSchema, response.result);
|
|
11286
|
+
if (!parseResult.success) {
|
|
11287
|
+
reject(parseResult.error);
|
|
11288
|
+
} else {
|
|
11289
|
+
resolve(parseResult.data);
|
|
11290
|
+
}
|
|
10366
11291
|
} catch (error2) {
|
|
10367
11292
|
reject(error2);
|
|
10368
11293
|
}
|
|
10369
11294
|
});
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
cancel((_a2 = options === null || options === void 0 ? void 0 : options.signal) === null || _a2 === void 0 ? void 0 : _a2.reason);
|
|
10373
|
-
});
|
|
10374
|
-
const timeout = (_e = options === null || options === void 0 ? void 0 : options.timeout) !== null && _e !== void 0 ? _e : DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
10375
|
-
const timeoutHandler = () => cancel(new McpError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
10376
|
-
this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (_f = options === null || options === void 0 ? void 0 : options.resetTimeoutOnProgress) !== null && _f !== void 0 ? _f : false);
|
|
10377
|
-
this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error2) => {
|
|
10378
|
-
this._cleanupTimeout(messageId);
|
|
10379
|
-
reject(error2);
|
|
11295
|
+
options?.signal?.addEventListener("abort", () => {
|
|
11296
|
+
cancel(options?.signal?.reason);
|
|
10380
11297
|
});
|
|
11298
|
+
const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
11299
|
+
const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
11300
|
+
this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
|
|
11301
|
+
const relatedTaskId = relatedTask?.taskId;
|
|
11302
|
+
if (relatedTaskId) {
|
|
11303
|
+
const responseResolver = (response) => {
|
|
11304
|
+
const handler = this._responseHandlers.get(messageId);
|
|
11305
|
+
if (handler) {
|
|
11306
|
+
handler(response);
|
|
11307
|
+
} else {
|
|
11308
|
+
this._onerror(new Error(`Response handler missing for side-channeled request ${messageId}`));
|
|
11309
|
+
}
|
|
11310
|
+
};
|
|
11311
|
+
this._requestResolvers.set(messageId, responseResolver);
|
|
11312
|
+
this._enqueueTaskMessage(relatedTaskId, {
|
|
11313
|
+
type: "request",
|
|
11314
|
+
message: jsonrpcRequest,
|
|
11315
|
+
timestamp: Date.now()
|
|
11316
|
+
}).catch((error2) => {
|
|
11317
|
+
this._cleanupTimeout(messageId);
|
|
11318
|
+
reject(error2);
|
|
11319
|
+
});
|
|
11320
|
+
} else {
|
|
11321
|
+
this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error2) => {
|
|
11322
|
+
this._cleanupTimeout(messageId);
|
|
11323
|
+
reject(error2);
|
|
11324
|
+
});
|
|
11325
|
+
}
|
|
10381
11326
|
});
|
|
10382
11327
|
}
|
|
11328
|
+
/**
|
|
11329
|
+
* Gets the current status of a task.
|
|
11330
|
+
*
|
|
11331
|
+
* @experimental Use `client.experimental.tasks.getTask()` to access this method.
|
|
11332
|
+
*/
|
|
11333
|
+
async getTask(params, options) {
|
|
11334
|
+
return this.request({ method: "tasks/get", params }, GetTaskResultSchema, options);
|
|
11335
|
+
}
|
|
11336
|
+
/**
|
|
11337
|
+
* Retrieves the result of a completed task.
|
|
11338
|
+
*
|
|
11339
|
+
* @experimental Use `client.experimental.tasks.getTaskResult()` to access this method.
|
|
11340
|
+
*/
|
|
11341
|
+
async getTaskResult(params, resultSchema, options) {
|
|
11342
|
+
return this.request({ method: "tasks/result", params }, resultSchema, options);
|
|
11343
|
+
}
|
|
11344
|
+
/**
|
|
11345
|
+
* Lists tasks, optionally starting from a pagination cursor.
|
|
11346
|
+
*
|
|
11347
|
+
* @experimental Use `client.experimental.tasks.listTasks()` to access this method.
|
|
11348
|
+
*/
|
|
11349
|
+
async listTasks(params, options) {
|
|
11350
|
+
return this.request({ method: "tasks/list", params }, ListTasksResultSchema, options);
|
|
11351
|
+
}
|
|
11352
|
+
/**
|
|
11353
|
+
* Cancels a specific task.
|
|
11354
|
+
*
|
|
11355
|
+
* @experimental Use `client.experimental.tasks.cancelTask()` to access this method.
|
|
11356
|
+
*/
|
|
11357
|
+
async cancelTask(params, options) {
|
|
11358
|
+
return this.request({ method: "tasks/cancel", params }, CancelTaskResultSchema, options);
|
|
11359
|
+
}
|
|
10383
11360
|
/**
|
|
10384
11361
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
10385
11362
|
*/
|
|
10386
11363
|
async notification(notification, options) {
|
|
10387
|
-
var _a, _b;
|
|
10388
11364
|
if (!this._transport) {
|
|
10389
11365
|
throw new Error("Not connected");
|
|
10390
11366
|
}
|
|
10391
11367
|
this.assertNotificationCapability(notification.method);
|
|
10392
|
-
const
|
|
10393
|
-
|
|
11368
|
+
const relatedTaskId = options?.relatedTask?.taskId;
|
|
11369
|
+
if (relatedTaskId) {
|
|
11370
|
+
const jsonrpcNotification2 = {
|
|
11371
|
+
...notification,
|
|
11372
|
+
jsonrpc: "2.0",
|
|
11373
|
+
params: {
|
|
11374
|
+
...notification.params,
|
|
11375
|
+
_meta: {
|
|
11376
|
+
...notification.params?._meta || {},
|
|
11377
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
11378
|
+
}
|
|
11379
|
+
}
|
|
11380
|
+
};
|
|
11381
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
11382
|
+
type: "notification",
|
|
11383
|
+
message: jsonrpcNotification2,
|
|
11384
|
+
timestamp: Date.now()
|
|
11385
|
+
});
|
|
11386
|
+
return;
|
|
11387
|
+
}
|
|
11388
|
+
const debouncedMethods = this._options?.debouncedNotificationMethods ?? [];
|
|
11389
|
+
const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask;
|
|
10394
11390
|
if (canDebounce) {
|
|
10395
11391
|
if (this._pendingDebouncedNotifications.has(notification.method)) {
|
|
10396
11392
|
return;
|
|
10397
11393
|
}
|
|
10398
11394
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
10399
11395
|
Promise.resolve().then(() => {
|
|
10400
|
-
var _a2;
|
|
10401
11396
|
this._pendingDebouncedNotifications.delete(notification.method);
|
|
10402
11397
|
if (!this._transport) {
|
|
10403
11398
|
return;
|
|
10404
11399
|
}
|
|
10405
|
-
|
|
11400
|
+
let jsonrpcNotification2 = {
|
|
10406
11401
|
...notification,
|
|
10407
11402
|
jsonrpc: "2.0"
|
|
10408
11403
|
};
|
|
10409
|
-
|
|
11404
|
+
if (options?.relatedTask) {
|
|
11405
|
+
jsonrpcNotification2 = {
|
|
11406
|
+
...jsonrpcNotification2,
|
|
11407
|
+
params: {
|
|
11408
|
+
...jsonrpcNotification2.params,
|
|
11409
|
+
_meta: {
|
|
11410
|
+
...jsonrpcNotification2.params?._meta || {},
|
|
11411
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
11412
|
+
}
|
|
11413
|
+
}
|
|
11414
|
+
};
|
|
11415
|
+
}
|
|
11416
|
+
this._transport?.send(jsonrpcNotification2, options).catch((error2) => this._onerror(error2));
|
|
10410
11417
|
});
|
|
10411
11418
|
return;
|
|
10412
11419
|
}
|
|
10413
|
-
|
|
11420
|
+
let jsonrpcNotification = {
|
|
10414
11421
|
...notification,
|
|
10415
11422
|
jsonrpc: "2.0"
|
|
10416
11423
|
};
|
|
11424
|
+
if (options?.relatedTask) {
|
|
11425
|
+
jsonrpcNotification = {
|
|
11426
|
+
...jsonrpcNotification,
|
|
11427
|
+
params: {
|
|
11428
|
+
...jsonrpcNotification.params,
|
|
11429
|
+
_meta: {
|
|
11430
|
+
...jsonrpcNotification.params?._meta || {},
|
|
11431
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
11432
|
+
}
|
|
11433
|
+
}
|
|
11434
|
+
};
|
|
11435
|
+
}
|
|
10417
11436
|
await this._transport.send(jsonrpcNotification, options);
|
|
10418
11437
|
}
|
|
10419
11438
|
/**
|
|
@@ -10422,10 +11441,11 @@ var Protocol = class {
|
|
|
10422
11441
|
* Note that this will replace any previous request handler for the same method.
|
|
10423
11442
|
*/
|
|
10424
11443
|
setRequestHandler(requestSchema, handler) {
|
|
10425
|
-
const method = requestSchema
|
|
11444
|
+
const method = getMethodLiteral(requestSchema);
|
|
10426
11445
|
this.assertRequestHandlerCapability(method);
|
|
10427
11446
|
this._requestHandlers.set(method, (request, extra) => {
|
|
10428
|
-
|
|
11447
|
+
const parsed = parseWithCompat(requestSchema, request);
|
|
11448
|
+
return Promise.resolve(handler(parsed, extra));
|
|
10429
11449
|
});
|
|
10430
11450
|
}
|
|
10431
11451
|
/**
|
|
@@ -10448,7 +11468,11 @@ var Protocol = class {
|
|
|
10448
11468
|
* Note that this will replace any previous notification handler for the same method.
|
|
10449
11469
|
*/
|
|
10450
11470
|
setNotificationHandler(notificationSchema, handler) {
|
|
10451
|
-
|
|
11471
|
+
const method = getMethodLiteral(notificationSchema);
|
|
11472
|
+
this._notificationHandlers.set(method, (notification) => {
|
|
11473
|
+
const parsed = parseWithCompat(notificationSchema, notification);
|
|
11474
|
+
return Promise.resolve(handler(parsed));
|
|
11475
|
+
});
|
|
10452
11476
|
}
|
|
10453
11477
|
/**
|
|
10454
11478
|
* Removes the notification handler for the given method.
|
|
@@ -10456,24 +11480,177 @@ var Protocol = class {
|
|
|
10456
11480
|
removeNotificationHandler(method) {
|
|
10457
11481
|
this._notificationHandlers.delete(method);
|
|
10458
11482
|
}
|
|
11483
|
+
/**
|
|
11484
|
+
* Cleans up the progress handler associated with a task.
|
|
11485
|
+
* This should be called when a task reaches a terminal status.
|
|
11486
|
+
*/
|
|
11487
|
+
_cleanupTaskProgressHandler(taskId) {
|
|
11488
|
+
const progressToken = this._taskProgressTokens.get(taskId);
|
|
11489
|
+
if (progressToken !== void 0) {
|
|
11490
|
+
this._progressHandlers.delete(progressToken);
|
|
11491
|
+
this._taskProgressTokens.delete(taskId);
|
|
11492
|
+
}
|
|
11493
|
+
}
|
|
11494
|
+
/**
|
|
11495
|
+
* Enqueues a task-related message for side-channel delivery via tasks/result.
|
|
11496
|
+
* @param taskId The task ID to associate the message with
|
|
11497
|
+
* @param message The message to enqueue
|
|
11498
|
+
* @param sessionId Optional session ID for binding the operation to a specific session
|
|
11499
|
+
* @throws Error if taskStore is not configured or if enqueue fails (e.g., queue overflow)
|
|
11500
|
+
*
|
|
11501
|
+
* Note: If enqueue fails, it's the TaskMessageQueue implementation's responsibility to handle
|
|
11502
|
+
* the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
|
|
11503
|
+
* simply propagates the error.
|
|
11504
|
+
*/
|
|
11505
|
+
async _enqueueTaskMessage(taskId, message, sessionId) {
|
|
11506
|
+
if (!this._taskStore || !this._taskMessageQueue) {
|
|
11507
|
+
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
11508
|
+
}
|
|
11509
|
+
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
11510
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
11511
|
+
}
|
|
11512
|
+
/**
|
|
11513
|
+
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
11514
|
+
* @param taskId The task ID whose queue should be cleared
|
|
11515
|
+
* @param sessionId Optional session ID for binding the operation to a specific session
|
|
11516
|
+
*/
|
|
11517
|
+
async _clearTaskQueue(taskId, sessionId) {
|
|
11518
|
+
if (this._taskMessageQueue) {
|
|
11519
|
+
const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId);
|
|
11520
|
+
for (const message of messages) {
|
|
11521
|
+
if (message.type === "request" && isJSONRPCRequest(message.message)) {
|
|
11522
|
+
const requestId = message.message.id;
|
|
11523
|
+
const resolver = this._requestResolvers.get(requestId);
|
|
11524
|
+
if (resolver) {
|
|
11525
|
+
resolver(new McpError(ErrorCode.InternalError, "Task cancelled or completed"));
|
|
11526
|
+
this._requestResolvers.delete(requestId);
|
|
11527
|
+
} else {
|
|
11528
|
+
this._onerror(new Error(`Resolver missing for request ${requestId} during task ${taskId} cleanup`));
|
|
11529
|
+
}
|
|
11530
|
+
}
|
|
11531
|
+
}
|
|
11532
|
+
}
|
|
11533
|
+
}
|
|
11534
|
+
/**
|
|
11535
|
+
* Waits for a task update (new messages or status change) with abort signal support.
|
|
11536
|
+
* Uses polling to check for updates at the task's configured poll interval.
|
|
11537
|
+
* @param taskId The task ID to wait for
|
|
11538
|
+
* @param signal Abort signal to cancel the wait
|
|
11539
|
+
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
11540
|
+
*/
|
|
11541
|
+
async _waitForTaskUpdate(taskId, signal) {
|
|
11542
|
+
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
11543
|
+
try {
|
|
11544
|
+
const task = await this._taskStore?.getTask(taskId);
|
|
11545
|
+
if (task?.pollInterval) {
|
|
11546
|
+
interval = task.pollInterval;
|
|
11547
|
+
}
|
|
11548
|
+
} catch {
|
|
11549
|
+
}
|
|
11550
|
+
return new Promise((resolve, reject) => {
|
|
11551
|
+
if (signal.aborted) {
|
|
11552
|
+
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
11553
|
+
return;
|
|
11554
|
+
}
|
|
11555
|
+
const timeoutId = setTimeout(resolve, interval);
|
|
11556
|
+
signal.addEventListener("abort", () => {
|
|
11557
|
+
clearTimeout(timeoutId);
|
|
11558
|
+
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
11559
|
+
}, { once: true });
|
|
11560
|
+
});
|
|
11561
|
+
}
|
|
11562
|
+
requestTaskStore(request, sessionId) {
|
|
11563
|
+
const taskStore = this._taskStore;
|
|
11564
|
+
if (!taskStore) {
|
|
11565
|
+
throw new Error("No task store configured");
|
|
11566
|
+
}
|
|
11567
|
+
return {
|
|
11568
|
+
createTask: async (taskParams) => {
|
|
11569
|
+
if (!request) {
|
|
11570
|
+
throw new Error("No request provided");
|
|
11571
|
+
}
|
|
11572
|
+
return await taskStore.createTask(taskParams, request.id, {
|
|
11573
|
+
method: request.method,
|
|
11574
|
+
params: request.params
|
|
11575
|
+
}, sessionId);
|
|
11576
|
+
},
|
|
11577
|
+
getTask: async (taskId) => {
|
|
11578
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
11579
|
+
if (!task) {
|
|
11580
|
+
throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
|
|
11581
|
+
}
|
|
11582
|
+
return task;
|
|
11583
|
+
},
|
|
11584
|
+
storeTaskResult: async (taskId, status, result) => {
|
|
11585
|
+
await taskStore.storeTaskResult(taskId, status, result, sessionId);
|
|
11586
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
11587
|
+
if (task) {
|
|
11588
|
+
const notification = TaskStatusNotificationSchema.parse({
|
|
11589
|
+
method: "notifications/tasks/status",
|
|
11590
|
+
params: task
|
|
11591
|
+
});
|
|
11592
|
+
await this.notification(notification);
|
|
11593
|
+
if (isTerminal(task.status)) {
|
|
11594
|
+
this._cleanupTaskProgressHandler(taskId);
|
|
11595
|
+
}
|
|
11596
|
+
}
|
|
11597
|
+
},
|
|
11598
|
+
getTaskResult: (taskId) => {
|
|
11599
|
+
return taskStore.getTaskResult(taskId, sessionId);
|
|
11600
|
+
},
|
|
11601
|
+
updateTaskStatus: async (taskId, status, statusMessage) => {
|
|
11602
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
11603
|
+
if (!task) {
|
|
11604
|
+
throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
|
|
11605
|
+
}
|
|
11606
|
+
if (isTerminal(task.status)) {
|
|
11607
|
+
throw new McpError(ErrorCode.InvalidParams, `Cannot update task "${taskId}" from terminal status "${task.status}" to "${status}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);
|
|
11608
|
+
}
|
|
11609
|
+
await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId);
|
|
11610
|
+
const updatedTask = await taskStore.getTask(taskId, sessionId);
|
|
11611
|
+
if (updatedTask) {
|
|
11612
|
+
const notification = TaskStatusNotificationSchema.parse({
|
|
11613
|
+
method: "notifications/tasks/status",
|
|
11614
|
+
params: updatedTask
|
|
11615
|
+
});
|
|
11616
|
+
await this.notification(notification);
|
|
11617
|
+
if (isTerminal(updatedTask.status)) {
|
|
11618
|
+
this._cleanupTaskProgressHandler(taskId);
|
|
11619
|
+
}
|
|
11620
|
+
}
|
|
11621
|
+
},
|
|
11622
|
+
listTasks: (cursor) => {
|
|
11623
|
+
return taskStore.listTasks(cursor, sessionId);
|
|
11624
|
+
}
|
|
11625
|
+
};
|
|
11626
|
+
}
|
|
10459
11627
|
};
|
|
11628
|
+
function isPlainObject(value) {
|
|
11629
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11630
|
+
}
|
|
10460
11631
|
function mergeCapabilities(base, additional) {
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
11632
|
+
const result = { ...base };
|
|
11633
|
+
for (const key in additional) {
|
|
11634
|
+
const k = key;
|
|
11635
|
+
const addValue = additional[k];
|
|
11636
|
+
if (addValue === void 0)
|
|
11637
|
+
continue;
|
|
11638
|
+
const baseValue = result[k];
|
|
11639
|
+
if (isPlainObject(baseValue) && isPlainObject(addValue)) {
|
|
11640
|
+
result[k] = { ...baseValue, ...addValue };
|
|
10464
11641
|
} else {
|
|
10465
|
-
|
|
11642
|
+
result[k] = addValue;
|
|
10466
11643
|
}
|
|
10467
|
-
|
|
10468
|
-
|
|
11644
|
+
}
|
|
11645
|
+
return result;
|
|
10469
11646
|
}
|
|
10470
11647
|
|
|
10471
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
11648
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
|
|
10472
11649
|
init_esm_shims();
|
|
10473
11650
|
var import_ajv = __toESM(require_ajv(), 1);
|
|
10474
11651
|
var import_ajv_formats = __toESM(require_dist(), 1);
|
|
10475
11652
|
function createDefaultAjvInstance() {
|
|
10476
|
-
const ajv = new import_ajv.
|
|
11653
|
+
const ajv = new import_ajv.default({
|
|
10477
11654
|
strict: false,
|
|
10478
11655
|
validateFormats: true,
|
|
10479
11656
|
validateSchema: false,
|
|
@@ -10505,7 +11682,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
10505
11682
|
* ```
|
|
10506
11683
|
*/
|
|
10507
11684
|
constructor(ajv) {
|
|
10508
|
-
this._ajv = ajv
|
|
11685
|
+
this._ajv = ajv ?? createDefaultAjvInstance();
|
|
10509
11686
|
}
|
|
10510
11687
|
/**
|
|
10511
11688
|
* Create a validator for the given JSON Schema
|
|
@@ -10517,8 +11694,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
10517
11694
|
* @returns A validator function that validates input data
|
|
10518
11695
|
*/
|
|
10519
11696
|
getValidator(schema) {
|
|
10520
|
-
|
|
10521
|
-
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? (_a = this._ajv.getSchema(schema.$id)) !== null && _a !== void 0 ? _a : this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
11697
|
+
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
10522
11698
|
return (input) => {
|
|
10523
11699
|
const valid = ajvValidator(input);
|
|
10524
11700
|
if (valid) {
|
|
@@ -10538,13 +11714,121 @@ var AjvJsonSchemaValidator = class {
|
|
|
10538
11714
|
}
|
|
10539
11715
|
};
|
|
10540
11716
|
|
|
10541
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
11717
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
11718
|
+
init_esm_shims();
|
|
11719
|
+
var ExperimentalServerTasks = class {
|
|
11720
|
+
constructor(_server) {
|
|
11721
|
+
this._server = _server;
|
|
11722
|
+
}
|
|
11723
|
+
/**
|
|
11724
|
+
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
11725
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
11726
|
+
*
|
|
11727
|
+
* This method provides streaming access to request processing, allowing you to
|
|
11728
|
+
* observe intermediate task status updates for task-augmented requests.
|
|
11729
|
+
*
|
|
11730
|
+
* @param request - The request to send
|
|
11731
|
+
* @param resultSchema - Zod schema for validating the result
|
|
11732
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
11733
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
11734
|
+
*
|
|
11735
|
+
* @experimental
|
|
11736
|
+
*/
|
|
11737
|
+
requestStream(request, resultSchema, options) {
|
|
11738
|
+
return this._server.requestStream(request, resultSchema, options);
|
|
11739
|
+
}
|
|
11740
|
+
/**
|
|
11741
|
+
* Gets the current status of a task.
|
|
11742
|
+
*
|
|
11743
|
+
* @param taskId - The task identifier
|
|
11744
|
+
* @param options - Optional request options
|
|
11745
|
+
* @returns The task status
|
|
11746
|
+
*
|
|
11747
|
+
* @experimental
|
|
11748
|
+
*/
|
|
11749
|
+
async getTask(taskId, options) {
|
|
11750
|
+
return this._server.getTask({ taskId }, options);
|
|
11751
|
+
}
|
|
11752
|
+
/**
|
|
11753
|
+
* Retrieves the result of a completed task.
|
|
11754
|
+
*
|
|
11755
|
+
* @param taskId - The task identifier
|
|
11756
|
+
* @param resultSchema - Zod schema for validating the result
|
|
11757
|
+
* @param options - Optional request options
|
|
11758
|
+
* @returns The task result
|
|
11759
|
+
*
|
|
11760
|
+
* @experimental
|
|
11761
|
+
*/
|
|
11762
|
+
async getTaskResult(taskId, resultSchema, options) {
|
|
11763
|
+
return this._server.getTaskResult({ taskId }, resultSchema, options);
|
|
11764
|
+
}
|
|
11765
|
+
/**
|
|
11766
|
+
* Lists tasks with optional pagination.
|
|
11767
|
+
*
|
|
11768
|
+
* @param cursor - Optional pagination cursor
|
|
11769
|
+
* @param options - Optional request options
|
|
11770
|
+
* @returns List of tasks with optional next cursor
|
|
11771
|
+
*
|
|
11772
|
+
* @experimental
|
|
11773
|
+
*/
|
|
11774
|
+
async listTasks(cursor, options) {
|
|
11775
|
+
return this._server.listTasks(cursor ? { cursor } : void 0, options);
|
|
11776
|
+
}
|
|
11777
|
+
/**
|
|
11778
|
+
* Cancels a running task.
|
|
11779
|
+
*
|
|
11780
|
+
* @param taskId - The task identifier
|
|
11781
|
+
* @param options - Optional request options
|
|
11782
|
+
*
|
|
11783
|
+
* @experimental
|
|
11784
|
+
*/
|
|
11785
|
+
async cancelTask(taskId, options) {
|
|
11786
|
+
return this._server.cancelTask({ taskId }, options);
|
|
11787
|
+
}
|
|
11788
|
+
};
|
|
11789
|
+
|
|
11790
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
11791
|
+
init_esm_shims();
|
|
11792
|
+
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
11793
|
+
if (!requests) {
|
|
11794
|
+
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
11795
|
+
}
|
|
11796
|
+
switch (method) {
|
|
11797
|
+
case "tools/call":
|
|
11798
|
+
if (!requests.tools?.call) {
|
|
11799
|
+
throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
|
|
11800
|
+
}
|
|
11801
|
+
break;
|
|
11802
|
+
default:
|
|
11803
|
+
break;
|
|
11804
|
+
}
|
|
11805
|
+
}
|
|
11806
|
+
function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
11807
|
+
if (!requests) {
|
|
11808
|
+
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
11809
|
+
}
|
|
11810
|
+
switch (method) {
|
|
11811
|
+
case "sampling/createMessage":
|
|
11812
|
+
if (!requests.sampling?.createMessage) {
|
|
11813
|
+
throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
|
|
11814
|
+
}
|
|
11815
|
+
break;
|
|
11816
|
+
case "elicitation/create":
|
|
11817
|
+
if (!requests.elicitation?.create) {
|
|
11818
|
+
throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
|
|
11819
|
+
}
|
|
11820
|
+
break;
|
|
11821
|
+
default:
|
|
11822
|
+
break;
|
|
11823
|
+
}
|
|
11824
|
+
}
|
|
11825
|
+
|
|
11826
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
10542
11827
|
var Server = class extends Protocol {
|
|
10543
11828
|
/**
|
|
10544
11829
|
* Initializes this server with the given name and version information.
|
|
10545
11830
|
*/
|
|
10546
11831
|
constructor(_serverInfo, options) {
|
|
10547
|
-
var _a, _b;
|
|
10548
11832
|
super(options);
|
|
10549
11833
|
this._serverInfo = _serverInfo;
|
|
10550
11834
|
this._loggingLevels = /* @__PURE__ */ new Map();
|
|
@@ -10553,18 +11837,14 @@ var Server = class extends Protocol {
|
|
|
10553
11837
|
const currentLevel = this._loggingLevels.get(sessionId);
|
|
10554
11838
|
return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
|
|
10555
11839
|
};
|
|
10556
|
-
this._capabilities =
|
|
10557
|
-
this._instructions = options
|
|
10558
|
-
this._jsonSchemaValidator =
|
|
11840
|
+
this._capabilities = options?.capabilities ?? {};
|
|
11841
|
+
this._instructions = options?.instructions;
|
|
11842
|
+
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
|
|
10559
11843
|
this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
|
|
10560
|
-
this.setNotificationHandler(InitializedNotificationSchema, () =>
|
|
10561
|
-
var _a2;
|
|
10562
|
-
return (_a2 = this.oninitialized) === null || _a2 === void 0 ? void 0 : _a2.call(this);
|
|
10563
|
-
});
|
|
11844
|
+
this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
|
|
10564
11845
|
if (this._capabilities.logging) {
|
|
10565
11846
|
this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
|
|
10566
|
-
|
|
10567
|
-
const transportSessionId = extra.sessionId || ((_a2 = extra.requestInfo) === null || _a2 === void 0 ? void 0 : _a2.headers["mcp-session-id"]) || void 0;
|
|
11847
|
+
const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
|
|
10568
11848
|
const { level } = request.params;
|
|
10569
11849
|
const parseResult = LoggingLevelSchema.safeParse(level);
|
|
10570
11850
|
if (parseResult.success) {
|
|
@@ -10574,6 +11854,21 @@ var Server = class extends Protocol {
|
|
|
10574
11854
|
});
|
|
10575
11855
|
}
|
|
10576
11856
|
}
|
|
11857
|
+
/**
|
|
11858
|
+
* Access experimental features.
|
|
11859
|
+
*
|
|
11860
|
+
* WARNING: These APIs are experimental and may change without notice.
|
|
11861
|
+
*
|
|
11862
|
+
* @experimental
|
|
11863
|
+
*/
|
|
11864
|
+
get experimental() {
|
|
11865
|
+
if (!this._experimental) {
|
|
11866
|
+
this._experimental = {
|
|
11867
|
+
tasks: new ExperimentalServerTasks(this)
|
|
11868
|
+
};
|
|
11869
|
+
}
|
|
11870
|
+
return this._experimental;
|
|
11871
|
+
}
|
|
10577
11872
|
/**
|
|
10578
11873
|
* Registers new capabilities. This can only be called before connecting to a transport.
|
|
10579
11874
|
*
|
|
@@ -10585,21 +11880,71 @@ var Server = class extends Protocol {
|
|
|
10585
11880
|
}
|
|
10586
11881
|
this._capabilities = mergeCapabilities(this._capabilities, capabilities);
|
|
10587
11882
|
}
|
|
11883
|
+
/**
|
|
11884
|
+
* Override request handler registration to enforce server-side validation for tools/call.
|
|
11885
|
+
*/
|
|
11886
|
+
setRequestHandler(requestSchema, handler) {
|
|
11887
|
+
const shape = getObjectShape(requestSchema);
|
|
11888
|
+
const methodSchema = shape?.method;
|
|
11889
|
+
if (!methodSchema) {
|
|
11890
|
+
throw new Error("Schema is missing a method literal");
|
|
11891
|
+
}
|
|
11892
|
+
let methodValue;
|
|
11893
|
+
if (isZ4Schema(methodSchema)) {
|
|
11894
|
+
const v4Schema = methodSchema;
|
|
11895
|
+
const v4Def = v4Schema._zod?.def;
|
|
11896
|
+
methodValue = v4Def?.value ?? v4Schema.value;
|
|
11897
|
+
} else {
|
|
11898
|
+
const v3Schema = methodSchema;
|
|
11899
|
+
const legacyDef = v3Schema._def;
|
|
11900
|
+
methodValue = legacyDef?.value ?? v3Schema.value;
|
|
11901
|
+
}
|
|
11902
|
+
if (typeof methodValue !== "string") {
|
|
11903
|
+
throw new Error("Schema method literal must be a string");
|
|
11904
|
+
}
|
|
11905
|
+
const method = methodValue;
|
|
11906
|
+
if (method === "tools/call") {
|
|
11907
|
+
const wrappedHandler = async (request, extra) => {
|
|
11908
|
+
const validatedRequest = safeParse2(CallToolRequestSchema, request);
|
|
11909
|
+
if (!validatedRequest.success) {
|
|
11910
|
+
const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
11911
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
|
|
11912
|
+
}
|
|
11913
|
+
const { params } = validatedRequest.data;
|
|
11914
|
+
const result = await Promise.resolve(handler(request, extra));
|
|
11915
|
+
if (params.task) {
|
|
11916
|
+
const taskValidationResult = safeParse2(CreateTaskResultSchema, result);
|
|
11917
|
+
if (!taskValidationResult.success) {
|
|
11918
|
+
const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
|
|
11919
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
|
|
11920
|
+
}
|
|
11921
|
+
return taskValidationResult.data;
|
|
11922
|
+
}
|
|
11923
|
+
const validationResult = safeParse2(CallToolResultSchema, result);
|
|
11924
|
+
if (!validationResult.success) {
|
|
11925
|
+
const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
|
|
11926
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
|
|
11927
|
+
}
|
|
11928
|
+
return validationResult.data;
|
|
11929
|
+
};
|
|
11930
|
+
return super.setRequestHandler(requestSchema, wrappedHandler);
|
|
11931
|
+
}
|
|
11932
|
+
return super.setRequestHandler(requestSchema, handler);
|
|
11933
|
+
}
|
|
10588
11934
|
assertCapabilityForMethod(method) {
|
|
10589
|
-
var _a, _b, _c;
|
|
10590
11935
|
switch (method) {
|
|
10591
11936
|
case "sampling/createMessage":
|
|
10592
|
-
if (!
|
|
11937
|
+
if (!this._clientCapabilities?.sampling) {
|
|
10593
11938
|
throw new Error(`Client does not support sampling (required for ${method})`);
|
|
10594
11939
|
}
|
|
10595
11940
|
break;
|
|
10596
11941
|
case "elicitation/create":
|
|
10597
|
-
if (!
|
|
11942
|
+
if (!this._clientCapabilities?.elicitation) {
|
|
10598
11943
|
throw new Error(`Client does not support elicitation (required for ${method})`);
|
|
10599
11944
|
}
|
|
10600
11945
|
break;
|
|
10601
11946
|
case "roots/list":
|
|
10602
|
-
if (!
|
|
11947
|
+
if (!this._clientCapabilities?.roots) {
|
|
10603
11948
|
throw new Error(`Client does not support listing roots (required for ${method})`);
|
|
10604
11949
|
}
|
|
10605
11950
|
break;
|
|
@@ -10630,6 +11975,11 @@ var Server = class extends Protocol {
|
|
|
10630
11975
|
throw new Error(`Server does not support notifying of prompt list changes (required for ${method})`);
|
|
10631
11976
|
}
|
|
10632
11977
|
break;
|
|
11978
|
+
case "notifications/elicitation/complete":
|
|
11979
|
+
if (!this._clientCapabilities?.elicitation?.url) {
|
|
11980
|
+
throw new Error(`Client does not support URL elicitation (required for ${method})`);
|
|
11981
|
+
}
|
|
11982
|
+
break;
|
|
10633
11983
|
case "notifications/cancelled":
|
|
10634
11984
|
break;
|
|
10635
11985
|
case "notifications/progress":
|
|
@@ -10637,10 +11987,13 @@ var Server = class extends Protocol {
|
|
|
10637
11987
|
}
|
|
10638
11988
|
}
|
|
10639
11989
|
assertRequestHandlerCapability(method) {
|
|
11990
|
+
if (!this._capabilities) {
|
|
11991
|
+
return;
|
|
11992
|
+
}
|
|
10640
11993
|
switch (method) {
|
|
10641
|
-
case "
|
|
10642
|
-
if (!this._capabilities.
|
|
10643
|
-
throw new Error(`Server does not support
|
|
11994
|
+
case "completion/complete":
|
|
11995
|
+
if (!this._capabilities.completions) {
|
|
11996
|
+
throw new Error(`Server does not support completions (required for ${method})`);
|
|
10644
11997
|
}
|
|
10645
11998
|
break;
|
|
10646
11999
|
case "logging/setLevel":
|
|
@@ -10667,11 +12020,28 @@ var Server = class extends Protocol {
|
|
|
10667
12020
|
throw new Error(`Server does not support tools (required for ${method})`);
|
|
10668
12021
|
}
|
|
10669
12022
|
break;
|
|
12023
|
+
case "tasks/get":
|
|
12024
|
+
case "tasks/list":
|
|
12025
|
+
case "tasks/result":
|
|
12026
|
+
case "tasks/cancel":
|
|
12027
|
+
if (!this._capabilities.tasks) {
|
|
12028
|
+
throw new Error(`Server does not support tasks capability (required for ${method})`);
|
|
12029
|
+
}
|
|
12030
|
+
break;
|
|
10670
12031
|
case "ping":
|
|
10671
12032
|
case "initialize":
|
|
10672
12033
|
break;
|
|
10673
12034
|
}
|
|
10674
12035
|
}
|
|
12036
|
+
assertTaskCapability(method) {
|
|
12037
|
+
assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
|
|
12038
|
+
}
|
|
12039
|
+
assertTaskHandlerCapability(method) {
|
|
12040
|
+
if (!this._capabilities) {
|
|
12041
|
+
return;
|
|
12042
|
+
}
|
|
12043
|
+
assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
|
|
12044
|
+
}
|
|
10675
12045
|
async _oninitialize(request) {
|
|
10676
12046
|
const requestedVersion = request.params.protocolVersion;
|
|
10677
12047
|
this._clientCapabilities = request.params.capabilities;
|
|
@@ -10702,26 +12072,100 @@ var Server = class extends Protocol {
|
|
|
10702
12072
|
async ping() {
|
|
10703
12073
|
return this.request({ method: "ping" }, EmptyResultSchema);
|
|
10704
12074
|
}
|
|
12075
|
+
// Implementation
|
|
10705
12076
|
async createMessage(params, options) {
|
|
12077
|
+
if (params.tools || params.toolChoice) {
|
|
12078
|
+
if (!this._clientCapabilities?.sampling?.tools) {
|
|
12079
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
12080
|
+
}
|
|
12081
|
+
}
|
|
12082
|
+
if (params.messages.length > 0) {
|
|
12083
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
12084
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
12085
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
12086
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
12087
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
12088
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
12089
|
+
if (hasToolResults) {
|
|
12090
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
12091
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
12092
|
+
}
|
|
12093
|
+
if (!hasPreviousToolUse) {
|
|
12094
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
12095
|
+
}
|
|
12096
|
+
}
|
|
12097
|
+
if (hasPreviousToolUse) {
|
|
12098
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
12099
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
12100
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
12101
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
12102
|
+
}
|
|
12103
|
+
}
|
|
12104
|
+
}
|
|
12105
|
+
if (params.tools) {
|
|
12106
|
+
return this.request({ method: "sampling/createMessage", params }, CreateMessageResultWithToolsSchema, options);
|
|
12107
|
+
}
|
|
10706
12108
|
return this.request({ method: "sampling/createMessage", params }, CreateMessageResultSchema, options);
|
|
10707
12109
|
}
|
|
12110
|
+
/**
|
|
12111
|
+
* Creates an elicitation request for the given parameters.
|
|
12112
|
+
* For backwards compatibility, `mode` may be omitted for form requests and will default to `'form'`.
|
|
12113
|
+
* @param params The parameters for the elicitation request.
|
|
12114
|
+
* @param options Optional request options.
|
|
12115
|
+
* @returns The result of the elicitation request.
|
|
12116
|
+
*/
|
|
10708
12117
|
async elicitInput(params, options) {
|
|
10709
|
-
const
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
}
|
|
10717
|
-
}
|
|
10718
|
-
|
|
10719
|
-
|
|
12118
|
+
const mode = params.mode ?? "form";
|
|
12119
|
+
switch (mode) {
|
|
12120
|
+
case "url": {
|
|
12121
|
+
if (!this._clientCapabilities?.elicitation?.url) {
|
|
12122
|
+
throw new Error("Client does not support url elicitation.");
|
|
12123
|
+
}
|
|
12124
|
+
const urlParams = params;
|
|
12125
|
+
return this.request({ method: "elicitation/create", params: urlParams }, ElicitResultSchema, options);
|
|
12126
|
+
}
|
|
12127
|
+
case "form": {
|
|
12128
|
+
if (!this._clientCapabilities?.elicitation?.form) {
|
|
12129
|
+
throw new Error("Client does not support form elicitation.");
|
|
12130
|
+
}
|
|
12131
|
+
const formParams = params.mode === "form" ? params : { ...params, mode: "form" };
|
|
12132
|
+
const result = await this.request({ method: "elicitation/create", params: formParams }, ElicitResultSchema, options);
|
|
12133
|
+
if (result.action === "accept" && result.content && formParams.requestedSchema) {
|
|
12134
|
+
try {
|
|
12135
|
+
const validator = this._jsonSchemaValidator.getValidator(formParams.requestedSchema);
|
|
12136
|
+
const validationResult = validator(result.content);
|
|
12137
|
+
if (!validationResult.valid) {
|
|
12138
|
+
throw new McpError(ErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${validationResult.errorMessage}`);
|
|
12139
|
+
}
|
|
12140
|
+
} catch (error2) {
|
|
12141
|
+
if (error2 instanceof McpError) {
|
|
12142
|
+
throw error2;
|
|
12143
|
+
}
|
|
12144
|
+
throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
12145
|
+
}
|
|
10720
12146
|
}
|
|
10721
|
-
|
|
12147
|
+
return result;
|
|
10722
12148
|
}
|
|
10723
12149
|
}
|
|
10724
|
-
|
|
12150
|
+
}
|
|
12151
|
+
/**
|
|
12152
|
+
* Creates a reusable callback that, when invoked, will send a `notifications/elicitation/complete`
|
|
12153
|
+
* notification for the specified elicitation ID.
|
|
12154
|
+
*
|
|
12155
|
+
* @param elicitationId The ID of the elicitation to mark as complete.
|
|
12156
|
+
* @param options Optional notification options. Useful when the completion notification should be related to a prior request.
|
|
12157
|
+
* @returns A function that emits the completion notification when awaited.
|
|
12158
|
+
*/
|
|
12159
|
+
createElicitationCompletionNotifier(elicitationId, options) {
|
|
12160
|
+
if (!this._clientCapabilities?.elicitation?.url) {
|
|
12161
|
+
throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
|
|
12162
|
+
}
|
|
12163
|
+
return () => this.notification({
|
|
12164
|
+
method: "notifications/elicitation/complete",
|
|
12165
|
+
params: {
|
|
12166
|
+
elicitationId
|
|
12167
|
+
}
|
|
12168
|
+
}, options);
|
|
10725
12169
|
}
|
|
10726
12170
|
async listRoots(params, options) {
|
|
10727
12171
|
return this.request({ method: "roots/list", params }, ListRootsResultSchema, options);
|
|
@@ -10759,11 +12203,11 @@ var Server = class extends Protocol {
|
|
|
10759
12203
|
}
|
|
10760
12204
|
};
|
|
10761
12205
|
|
|
10762
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
12206
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
10763
12207
|
init_esm_shims();
|
|
10764
12208
|
import process2 from "process";
|
|
10765
12209
|
|
|
10766
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
12210
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
10767
12211
|
init_esm_shims();
|
|
10768
12212
|
var ReadBuffer = class {
|
|
10769
12213
|
append(chunk) {
|
|
@@ -10792,7 +12236,7 @@ function serializeMessage(message) {
|
|
|
10792
12236
|
return JSON.stringify(message) + "\n";
|
|
10793
12237
|
}
|
|
10794
12238
|
|
|
10795
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
12239
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.25.1_hono@4.11.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
10796
12240
|
var StdioServerTransport = class {
|
|
10797
12241
|
constructor(_stdin = process2.stdin, _stdout = process2.stdout) {
|
|
10798
12242
|
this._stdin = _stdin;
|
|
@@ -10804,8 +12248,7 @@ var StdioServerTransport = class {
|
|
|
10804
12248
|
this.processReadBuffer();
|
|
10805
12249
|
};
|
|
10806
12250
|
this._onerror = (error2) => {
|
|
10807
|
-
|
|
10808
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
|
|
12251
|
+
this.onerror?.(error2);
|
|
10809
12252
|
};
|
|
10810
12253
|
}
|
|
10811
12254
|
/**
|
|
@@ -10820,21 +12263,19 @@ var StdioServerTransport = class {
|
|
|
10820
12263
|
this._stdin.on("error", this._onerror);
|
|
10821
12264
|
}
|
|
10822
12265
|
processReadBuffer() {
|
|
10823
|
-
var _a, _b;
|
|
10824
12266
|
while (true) {
|
|
10825
12267
|
try {
|
|
10826
12268
|
const message = this._readBuffer.readMessage();
|
|
10827
12269
|
if (message === null) {
|
|
10828
12270
|
break;
|
|
10829
12271
|
}
|
|
10830
|
-
|
|
12272
|
+
this.onmessage?.(message);
|
|
10831
12273
|
} catch (error2) {
|
|
10832
|
-
|
|
12274
|
+
this.onerror?.(error2);
|
|
10833
12275
|
}
|
|
10834
12276
|
}
|
|
10835
12277
|
}
|
|
10836
12278
|
async close() {
|
|
10837
|
-
var _a;
|
|
10838
12279
|
this._stdin.off("data", this._ondata);
|
|
10839
12280
|
this._stdin.off("error", this._onerror);
|
|
10840
12281
|
const remainingDataListeners = this._stdin.listenerCount("data");
|
|
@@ -10842,7 +12283,7 @@ var StdioServerTransport = class {
|
|
|
10842
12283
|
this._stdin.pause();
|
|
10843
12284
|
}
|
|
10844
12285
|
this._readBuffer.clear();
|
|
10845
|
-
|
|
12286
|
+
this.onclose?.();
|
|
10846
12287
|
}
|
|
10847
12288
|
send(message) {
|
|
10848
12289
|
return new Promise((resolve) => {
|
|
@@ -11799,15 +13240,15 @@ function showCustomHelp() {
|
|
|
11799
13240
|
|
|
11800
13241
|
// src/version.ts
|
|
11801
13242
|
init_esm_shims();
|
|
11802
|
-
import { readFileSync } from "fs";
|
|
11803
|
-
import { dirname, join as
|
|
13243
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
13244
|
+
import { dirname, join as join3 } from "path";
|
|
11804
13245
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
11805
13246
|
var __filename3 = fileURLToPath3(import.meta.url);
|
|
11806
13247
|
var __dirname3 = dirname(__filename3);
|
|
11807
13248
|
function getVersion() {
|
|
11808
13249
|
try {
|
|
11809
|
-
const packageJsonPath =
|
|
11810
|
-
const packageJson = JSON.parse(
|
|
13250
|
+
const packageJsonPath = join3(__dirname3, "../package.json");
|
|
13251
|
+
const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
11811
13252
|
return packageJson.version;
|
|
11812
13253
|
} catch {
|
|
11813
13254
|
return "0.0.0";
|
|
@@ -11818,6 +13259,277 @@ function getVersion() {
|
|
|
11818
13259
|
init_esm_shims();
|
|
11819
13260
|
import { dirname as dirname2, join as join5 } from "path";
|
|
11820
13261
|
|
|
13262
|
+
// src/lib/file-system-task-linter/index.ts
|
|
13263
|
+
init_esm_shims();
|
|
13264
|
+
|
|
13265
|
+
// src/lib/file-system-task-linter/file-system-task-linter.ts
|
|
13266
|
+
init_esm_shims();
|
|
13267
|
+
import chalk6 from "chalk";
|
|
13268
|
+
import { readdir, readFile as readFile2 } from "fs/promises";
|
|
13269
|
+
import { join as join4 } from "path";
|
|
13270
|
+
var VALID_STATUSES = ["pending", "in-progress", "done", "blocked"];
|
|
13271
|
+
var VALID_TYPES = ["feat", "fix", "chore", "docs", "refactor", "test"];
|
|
13272
|
+
var FileSystemTaskLinter = class {
|
|
13273
|
+
errors = [];
|
|
13274
|
+
addError(file, message, severity = "error", line) {
|
|
13275
|
+
this.errors.push({ file, message, severity, line });
|
|
13276
|
+
}
|
|
13277
|
+
/**
|
|
13278
|
+
* Validate task file name format (FileSystem-specific)
|
|
13279
|
+
*/
|
|
13280
|
+
validateFileName(fileName) {
|
|
13281
|
+
const pattern = /^task-\d{2,3}-[a-z0-9-]+\.md$/;
|
|
13282
|
+
if (!pattern.test(fileName)) {
|
|
13283
|
+
return {
|
|
13284
|
+
file: fileName,
|
|
13285
|
+
message: "Invalid filename. Expected: task-NNN-kebab-case-title.md",
|
|
13286
|
+
severity: "error"
|
|
13287
|
+
};
|
|
13288
|
+
}
|
|
13289
|
+
return null;
|
|
13290
|
+
}
|
|
13291
|
+
extractMetadata(content) {
|
|
13292
|
+
const headerSection = content.split(/^##/m)[0];
|
|
13293
|
+
const statusMatch = headerSection.match(/^Status:\s*(.+)$/im);
|
|
13294
|
+
const typeMatch = headerSection.match(/^Type:\s*(.+)$/im);
|
|
13295
|
+
const assigneeMatch = headerSection.match(/^Assignee:\s*(.+)$/im);
|
|
13296
|
+
return {
|
|
13297
|
+
status: statusMatch?.[1]?.trim().toLowerCase(),
|
|
13298
|
+
type: typeMatch?.[1]?.trim().toLowerCase(),
|
|
13299
|
+
assignee: assigneeMatch?.[1]?.trim()
|
|
13300
|
+
};
|
|
13301
|
+
}
|
|
13302
|
+
/**
|
|
13303
|
+
* Validate task metadata (FileSystem-specific)
|
|
13304
|
+
*/
|
|
13305
|
+
validateMetadata(metadata, filePath) {
|
|
13306
|
+
const errors = [];
|
|
13307
|
+
if (!metadata.status) {
|
|
13308
|
+
errors.push({
|
|
13309
|
+
file: filePath,
|
|
13310
|
+
message: "Missing required metadata: Status",
|
|
13311
|
+
severity: "error"
|
|
13312
|
+
});
|
|
13313
|
+
} else if (!VALID_STATUSES.includes(metadata.status)) {
|
|
13314
|
+
errors.push({
|
|
13315
|
+
file: filePath,
|
|
13316
|
+
message: `Invalid status "${metadata.status}". Valid: ${VALID_STATUSES.join(", ")}`,
|
|
13317
|
+
severity: "error"
|
|
13318
|
+
});
|
|
13319
|
+
}
|
|
13320
|
+
if (!metadata.type) {
|
|
13321
|
+
errors.push({
|
|
13322
|
+
file: filePath,
|
|
13323
|
+
message: "Missing required metadata: Type",
|
|
13324
|
+
severity: "error"
|
|
13325
|
+
});
|
|
13326
|
+
} else if (!VALID_TYPES.includes(metadata.type)) {
|
|
13327
|
+
errors.push({
|
|
13328
|
+
file: filePath,
|
|
13329
|
+
message: `Invalid type "${metadata.type}". Valid: ${VALID_TYPES.join(", ")}`,
|
|
13330
|
+
severity: "error"
|
|
13331
|
+
});
|
|
13332
|
+
}
|
|
13333
|
+
if (!metadata.assignee) {
|
|
13334
|
+
errors.push({
|
|
13335
|
+
file: filePath,
|
|
13336
|
+
message: "Missing recommended metadata: Assignee",
|
|
13337
|
+
severity: "warning"
|
|
13338
|
+
});
|
|
13339
|
+
}
|
|
13340
|
+
return errors;
|
|
13341
|
+
}
|
|
13342
|
+
validateContent(filename, content) {
|
|
13343
|
+
const lines = content.split("\n");
|
|
13344
|
+
if (!lines[0]?.trim().startsWith("# ")) {
|
|
13345
|
+
this.addError(
|
|
13346
|
+
filename,
|
|
13347
|
+
"Task file must start with a level 1 heading (# Task NNN \u2014 Title)",
|
|
13348
|
+
"error",
|
|
13349
|
+
1
|
|
13350
|
+
);
|
|
13351
|
+
}
|
|
13352
|
+
const h1Pattern = /^#\s+(?:🧩\s+)?Task\s+\d{2,3}\s+[—-]\s+.+$/i;
|
|
13353
|
+
if (lines[0] && !h1Pattern.test(lines[0])) {
|
|
13354
|
+
this.addError(
|
|
13355
|
+
filename,
|
|
13356
|
+
'H1 heading must follow format: "# Task NNN \u2014 Title"',
|
|
13357
|
+
"error",
|
|
13358
|
+
1
|
|
13359
|
+
);
|
|
13360
|
+
}
|
|
13361
|
+
const metadata = this.extractMetadata(content);
|
|
13362
|
+
const metadataErrors = this.validateMetadata(metadata, filename);
|
|
13363
|
+
metadataErrors.forEach((error2) => {
|
|
13364
|
+
this.addError(error2.file, error2.message, error2.severity, error2.line);
|
|
13365
|
+
});
|
|
13366
|
+
const h2Sections = content.match(/^##\s+.+$/gm);
|
|
13367
|
+
if (!h2Sections || h2Sections.length === 0) {
|
|
13368
|
+
this.addError(
|
|
13369
|
+
filename,
|
|
13370
|
+
"Task should have at least one section (## heading)",
|
|
13371
|
+
"warning"
|
|
13372
|
+
);
|
|
13373
|
+
}
|
|
13374
|
+
const firstH2Index = content.indexOf("\n##");
|
|
13375
|
+
if (firstH2Index > -1) {
|
|
13376
|
+
const afterH2 = content.substring(firstH2Index);
|
|
13377
|
+
if (afterH2.match(/^Status:/im) || afterH2.match(/^Type:/im) || afterH2.match(/^Assignee:/im)) {
|
|
13378
|
+
this.addError(
|
|
13379
|
+
filename,
|
|
13380
|
+
"Metadata must be placed BEFORE the first ## section",
|
|
13381
|
+
"error"
|
|
13382
|
+
);
|
|
13383
|
+
}
|
|
13384
|
+
}
|
|
13385
|
+
}
|
|
13386
|
+
/**
|
|
13387
|
+
* Lint a single task file (FileSystem-specific)
|
|
13388
|
+
*/
|
|
13389
|
+
async lintFile(filePath) {
|
|
13390
|
+
const errors = [];
|
|
13391
|
+
const fileName = filePath.split("/").pop() || filePath;
|
|
13392
|
+
const fileNameError = this.validateFileName(fileName);
|
|
13393
|
+
if (fileNameError) {
|
|
13394
|
+
errors.push(fileNameError);
|
|
13395
|
+
}
|
|
13396
|
+
try {
|
|
13397
|
+
const content = await readFile2(filePath, "utf-8");
|
|
13398
|
+
this.errors = [];
|
|
13399
|
+
this.validateContent(fileName, content);
|
|
13400
|
+
errors.push(...this.errors);
|
|
13401
|
+
} catch (error2) {
|
|
13402
|
+
errors.push({
|
|
13403
|
+
file: fileName,
|
|
13404
|
+
message: `Failed to read file: ${error2}`,
|
|
13405
|
+
severity: "error"
|
|
13406
|
+
});
|
|
13407
|
+
}
|
|
13408
|
+
return errors;
|
|
13409
|
+
}
|
|
13410
|
+
/**
|
|
13411
|
+
* Lint all task files in the specified directory (FileSystem-specific)
|
|
13412
|
+
*/
|
|
13413
|
+
async lintDirectory(tasksDir) {
|
|
13414
|
+
this.errors = [];
|
|
13415
|
+
try {
|
|
13416
|
+
const files = await readdir(tasksDir);
|
|
13417
|
+
const taskFiles = files.filter((f) => f.endsWith(".md"));
|
|
13418
|
+
for (const file of taskFiles) {
|
|
13419
|
+
const fileNameError = this.validateFileName(file);
|
|
13420
|
+
if (fileNameError) {
|
|
13421
|
+
this.addError(file, fileNameError.message, fileNameError.severity);
|
|
13422
|
+
}
|
|
13423
|
+
const content = await readFile2(join4(tasksDir, file), "utf-8");
|
|
13424
|
+
this.validateContent(file, content);
|
|
13425
|
+
}
|
|
13426
|
+
const errors = this.errors.filter((e) => e.severity === "error");
|
|
13427
|
+
const warnings = this.errors.filter((e) => e.severity === "warning");
|
|
13428
|
+
return {
|
|
13429
|
+
errors,
|
|
13430
|
+
warnings,
|
|
13431
|
+
filesChecked: taskFiles.length,
|
|
13432
|
+
valid: errors.length === 0
|
|
13433
|
+
};
|
|
13434
|
+
} catch (error2) {
|
|
13435
|
+
throw new Error(`Failed to lint tasks: ${error2}`);
|
|
13436
|
+
}
|
|
13437
|
+
}
|
|
13438
|
+
static printResults(result) {
|
|
13439
|
+
if (result.errors.length === 0 && result.warnings.length === 0) {
|
|
13440
|
+
console.log(
|
|
13441
|
+
chalk6.green(`\u2705 All ${result.filesChecked} task files are valid!
|
|
13442
|
+
`)
|
|
13443
|
+
);
|
|
13444
|
+
return;
|
|
13445
|
+
}
|
|
13446
|
+
console.log(
|
|
13447
|
+
chalk6.bold(
|
|
13448
|
+
`
|
|
13449
|
+
\u{1F4CA} Validation Results (${result.filesChecked} files checked):
|
|
13450
|
+
`
|
|
13451
|
+
)
|
|
13452
|
+
);
|
|
13453
|
+
const errorsByFile = /* @__PURE__ */ new Map();
|
|
13454
|
+
[...result.errors, ...result.warnings].forEach((error2) => {
|
|
13455
|
+
if (!errorsByFile.has(error2.file)) {
|
|
13456
|
+
errorsByFile.set(error2.file, []);
|
|
13457
|
+
}
|
|
13458
|
+
errorsByFile.get(error2.file).push(error2);
|
|
13459
|
+
});
|
|
13460
|
+
for (const [file, fileErrors] of errorsByFile) {
|
|
13461
|
+
console.log(chalk6.cyan(`
|
|
13462
|
+
\u{1F4C4} ${file}`));
|
|
13463
|
+
for (const error2 of fileErrors) {
|
|
13464
|
+
const icon = error2.severity === "error" ? chalk6.red("\u274C") : chalk6.yellow("\u26A0\uFE0F");
|
|
13465
|
+
const location = error2.line ? `:${error2.line}` : "";
|
|
13466
|
+
console.log(` ${icon} ${error2.message}${location}`);
|
|
13467
|
+
}
|
|
13468
|
+
}
|
|
13469
|
+
console.log("\n" + "\u2500".repeat(60));
|
|
13470
|
+
console.log(
|
|
13471
|
+
chalk6.bold(
|
|
13472
|
+
`
|
|
13473
|
+
\u{1F4CA} Summary: ${chalk6.red(result.errors.length + " error(s)")}, ${chalk6.yellow(result.warnings.length + " warning(s)")}
|
|
13474
|
+
`
|
|
13475
|
+
)
|
|
13476
|
+
);
|
|
13477
|
+
}
|
|
13478
|
+
};
|
|
13479
|
+
|
|
13480
|
+
// src/lib/file-system-task-linter/file-system-task-linter.mock.ts
|
|
13481
|
+
init_esm_shims();
|
|
13482
|
+
function createMockFileValidationError(overrides) {
|
|
13483
|
+
return {
|
|
13484
|
+
file: "task-001.md",
|
|
13485
|
+
message: "Mock validation error",
|
|
13486
|
+
severity: "error",
|
|
13487
|
+
...overrides
|
|
13488
|
+
};
|
|
13489
|
+
}
|
|
13490
|
+
var MOCK_INVALID_LINT_RESULT = {
|
|
13491
|
+
errors: [
|
|
13492
|
+
createMockFileValidationError({
|
|
13493
|
+
file: "task-001.md",
|
|
13494
|
+
message: 'Invalid status: "invalid"'
|
|
13495
|
+
}),
|
|
13496
|
+
createMockFileValidationError({
|
|
13497
|
+
file: "task-002.md",
|
|
13498
|
+
message: 'Invalid type: "unknown"'
|
|
13499
|
+
})
|
|
13500
|
+
],
|
|
13501
|
+
filesChecked: 2,
|
|
13502
|
+
valid: false,
|
|
13503
|
+
warnings: []
|
|
13504
|
+
};
|
|
13505
|
+
var MOCK_WARNINGS_LINT_RESULT = {
|
|
13506
|
+
errors: [],
|
|
13507
|
+
filesChecked: 3,
|
|
13508
|
+
valid: true,
|
|
13509
|
+
warnings: [
|
|
13510
|
+
createMockFileValidationError({
|
|
13511
|
+
file: "task-003.md",
|
|
13512
|
+
message: "Consider adding assignee",
|
|
13513
|
+
severity: "warning"
|
|
13514
|
+
})
|
|
13515
|
+
]
|
|
13516
|
+
};
|
|
13517
|
+
var MOCK_VALIDATION_ERRORS = [
|
|
13518
|
+
createMockFileValidationError({
|
|
13519
|
+
file: "task-001.md",
|
|
13520
|
+
message: "Invalid status: must be one of [pending, in-progress, done, blocked]",
|
|
13521
|
+
line: 5
|
|
13522
|
+
}),
|
|
13523
|
+
createMockFileValidationError({
|
|
13524
|
+
file: "task-001.md",
|
|
13525
|
+
message: "Invalid type: must be one of [feat, fix, chore, docs, refactor, test]",
|
|
13526
|
+
line: 6
|
|
13527
|
+
})
|
|
13528
|
+
];
|
|
13529
|
+
|
|
13530
|
+
// src/lib/file-system-task-linter/file-system-task-linter.types.ts
|
|
13531
|
+
init_esm_shims();
|
|
13532
|
+
|
|
11821
13533
|
// src/taskin.ts
|
|
11822
13534
|
init_esm_shims();
|
|
11823
13535
|
var Taskin = class {
|