@aku11i/phantom 3.2.0 → 3.3.1
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/package.json +1 -1
- package/phantom.js +1401 -195
package/phantom.js
CHANGED
|
@@ -3318,8 +3318,8 @@ var require_utils = __commonJS({
|
|
|
3318
3318
|
}
|
|
3319
3319
|
return ind;
|
|
3320
3320
|
}
|
|
3321
|
-
function removeDotSegments(
|
|
3322
|
-
let input =
|
|
3321
|
+
function removeDotSegments(path4) {
|
|
3322
|
+
let input = path4;
|
|
3323
3323
|
const output2 = [];
|
|
3324
3324
|
let nextSlash = -1;
|
|
3325
3325
|
let len = 0;
|
|
@@ -3518,8 +3518,8 @@ var require_schemes = __commonJS({
|
|
|
3518
3518
|
wsComponent.secure = void 0;
|
|
3519
3519
|
}
|
|
3520
3520
|
if (wsComponent.resourceName) {
|
|
3521
|
-
const [
|
|
3522
|
-
wsComponent.path =
|
|
3521
|
+
const [path4, query] = wsComponent.resourceName.split("?");
|
|
3522
|
+
wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
|
|
3523
3523
|
wsComponent.query = query;
|
|
3524
3524
|
wsComponent.resourceName = void 0;
|
|
3525
3525
|
}
|
|
@@ -7476,7 +7476,7 @@ function $constructor(name, initializer3, params) {
|
|
|
7476
7476
|
Object.defineProperty(_, "name", { value: name });
|
|
7477
7477
|
return _;
|
|
7478
7478
|
}
|
|
7479
|
-
var $brand = Symbol("zod_brand");
|
|
7479
|
+
var $brand = /* @__PURE__ */ Symbol("zod_brand");
|
|
7480
7480
|
var $ZodAsyncError = class extends Error {
|
|
7481
7481
|
constructor() {
|
|
7482
7482
|
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
@@ -7622,7 +7622,7 @@ function floatSafeRemainder(val, step) {
|
|
|
7622
7622
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
7623
7623
|
return valInt % stepInt / 10 ** decCount;
|
|
7624
7624
|
}
|
|
7625
|
-
var EVALUATING = Symbol("evaluating");
|
|
7625
|
+
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
7626
7626
|
function defineLazy(object3, key, getter) {
|
|
7627
7627
|
let value = void 0;
|
|
7628
7628
|
Object.defineProperty(object3, key, {
|
|
@@ -7667,10 +7667,10 @@ function mergeDefs(...defs) {
|
|
|
7667
7667
|
function cloneDef(schema5) {
|
|
7668
7668
|
return mergeDefs(schema5._zod.def);
|
|
7669
7669
|
}
|
|
7670
|
-
function getElementAtPath(obj,
|
|
7671
|
-
if (!
|
|
7670
|
+
function getElementAtPath(obj, path4) {
|
|
7671
|
+
if (!path4)
|
|
7672
7672
|
return obj;
|
|
7673
|
-
return
|
|
7673
|
+
return path4.reduce((acc, key) => acc?.[key], obj);
|
|
7674
7674
|
}
|
|
7675
7675
|
function promiseAllObject(promisesObj) {
|
|
7676
7676
|
const keys = Object.keys(promisesObj);
|
|
@@ -8036,11 +8036,11 @@ function aborted(x, startIndex = 0) {
|
|
|
8036
8036
|
}
|
|
8037
8037
|
return false;
|
|
8038
8038
|
}
|
|
8039
|
-
function prefixIssues(
|
|
8039
|
+
function prefixIssues(path4, issues) {
|
|
8040
8040
|
return issues.map((iss) => {
|
|
8041
8041
|
var _a2;
|
|
8042
8042
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
8043
|
-
iss.path.unshift(
|
|
8043
|
+
iss.path.unshift(path4);
|
|
8044
8044
|
return iss;
|
|
8045
8045
|
});
|
|
8046
8046
|
}
|
|
@@ -8202,7 +8202,7 @@ function formatError(error46, mapper = (issue2) => issue2.message) {
|
|
|
8202
8202
|
}
|
|
8203
8203
|
function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
8204
8204
|
const result = { errors: [] };
|
|
8205
|
-
const processError = (error47,
|
|
8205
|
+
const processError = (error47, path4 = []) => {
|
|
8206
8206
|
var _a2, _b;
|
|
8207
8207
|
for (const issue2 of error47.issues) {
|
|
8208
8208
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -8212,7 +8212,7 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
|
8212
8212
|
} else if (issue2.code === "invalid_element") {
|
|
8213
8213
|
processError({ issues: issue2.issues }, issue2.path);
|
|
8214
8214
|
} else {
|
|
8215
|
-
const fullpath = [...
|
|
8215
|
+
const fullpath = [...path4, ...issue2.path];
|
|
8216
8216
|
if (fullpath.length === 0) {
|
|
8217
8217
|
result.errors.push(mapper(issue2));
|
|
8218
8218
|
continue;
|
|
@@ -8244,8 +8244,8 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
|
|
|
8244
8244
|
}
|
|
8245
8245
|
function toDotPath(_path) {
|
|
8246
8246
|
const segs = [];
|
|
8247
|
-
const
|
|
8248
|
-
for (const seg of
|
|
8247
|
+
const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
8248
|
+
for (const seg of path4) {
|
|
8249
8249
|
if (typeof seg === "number")
|
|
8250
8250
|
segs.push(`[${seg}]`);
|
|
8251
8251
|
else if (typeof seg === "symbol")
|
|
@@ -16705,8 +16705,8 @@ function yo_default() {
|
|
|
16705
16705
|
|
|
16706
16706
|
// ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/registries.js
|
|
16707
16707
|
var _a;
|
|
16708
|
-
var $output = Symbol("ZodOutput");
|
|
16709
|
-
var $input = Symbol("ZodInput");
|
|
16708
|
+
var $output = /* @__PURE__ */ Symbol("ZodOutput");
|
|
16709
|
+
var $input = /* @__PURE__ */ Symbol("ZodInput");
|
|
16710
16710
|
var $ZodRegistry = class {
|
|
16711
16711
|
constructor() {
|
|
16712
16712
|
this._map = /* @__PURE__ */ new WeakMap();
|
|
@@ -19601,8 +19601,8 @@ function validateConfig(config2) {
|
|
|
19601
19601
|
const result = phantomConfigSchema.safeParse(config2);
|
|
19602
19602
|
if (!result.success) {
|
|
19603
19603
|
const firstError = result.error.issues[0];
|
|
19604
|
-
const
|
|
19605
|
-
const message =
|
|
19604
|
+
const path4 = firstError.path.join(".");
|
|
19605
|
+
const message = path4 ? `${path4}: ${firstError.message}` : firstError.message;
|
|
19606
19606
|
return err(new ConfigValidationError(message));
|
|
19607
19607
|
}
|
|
19608
19608
|
return ok(result.data);
|
|
@@ -19694,8 +19694,8 @@ async function executeGitCommandInDirectory(directory, args2) {
|
|
|
19694
19694
|
|
|
19695
19695
|
// ../git/src/libs/add-worktree.ts
|
|
19696
19696
|
async function addWorktree(options) {
|
|
19697
|
-
const { path:
|
|
19698
|
-
await executeGitCommand(["worktree", "add",
|
|
19697
|
+
const { path: path4, branch, base = "HEAD" } = options;
|
|
19698
|
+
await executeGitCommand(["worktree", "add", path4, "-b", branch, base]);
|
|
19699
19699
|
}
|
|
19700
19700
|
|
|
19701
19701
|
// ../git/src/libs/attach-worktree.ts
|
|
@@ -19848,7 +19848,8 @@ var PreferencesValidationError = class extends Error {
|
|
|
19848
19848
|
};
|
|
19849
19849
|
var preferencesSchema = external_exports.object({
|
|
19850
19850
|
editor: external_exports.string().optional(),
|
|
19851
|
-
ai: external_exports.string().optional()
|
|
19851
|
+
ai: external_exports.string().optional(),
|
|
19852
|
+
worktreesDirectory: external_exports.string().optional()
|
|
19852
19853
|
}).passthrough();
|
|
19853
19854
|
function parsePreferences(output2) {
|
|
19854
19855
|
if (!output2) {
|
|
@@ -19867,11 +19868,13 @@ function parsePreferences(output2) {
|
|
|
19867
19868
|
if (!key.startsWith("phantom.")) {
|
|
19868
19869
|
continue;
|
|
19869
19870
|
}
|
|
19870
|
-
const strippedKey = key.slice("phantom.".length);
|
|
19871
|
+
const strippedKey = key.slice("phantom.".length).toLowerCase();
|
|
19871
19872
|
if (strippedKey === "editor") {
|
|
19872
19873
|
preferences.editor = value;
|
|
19873
19874
|
} else if (strippedKey === "ai") {
|
|
19874
19875
|
preferences.ai = value;
|
|
19876
|
+
} else if (strippedKey === "worktreesdirectory") {
|
|
19877
|
+
preferences.worktreesDirectory = value;
|
|
19875
19878
|
}
|
|
19876
19879
|
}
|
|
19877
19880
|
const parsed = preferencesSchema.safeParse(preferences);
|
|
@@ -19897,8 +19900,15 @@ async function loadPreferences() {
|
|
|
19897
19900
|
async function createContext(gitRoot) {
|
|
19898
19901
|
const configResult = await loadConfig(gitRoot);
|
|
19899
19902
|
const config2 = isOk(configResult) ? configResult.value : null;
|
|
19900
|
-
const worktreesDirectory = config2?.worktreesDirectory;
|
|
19901
19903
|
const preferences = await loadPreferences();
|
|
19904
|
+
const worktreesDirectoryPreference = preferences.worktreesDirectory;
|
|
19905
|
+
const worktreesDirectoryConfig = config2?.worktreesDirectory;
|
|
19906
|
+
if (worktreesDirectoryConfig !== void 0) {
|
|
19907
|
+
console.warn(
|
|
19908
|
+
"The 'worktreesDirectory' option in phantom.config.json is deprecated and will be removed in the next version. Configure 'phantom preferences set worktreesDirectory <path-from-repo-root>' instead."
|
|
19909
|
+
);
|
|
19910
|
+
}
|
|
19911
|
+
const worktreesDirectory = worktreesDirectoryPreference ?? worktreesDirectoryConfig;
|
|
19902
19912
|
return {
|
|
19903
19913
|
gitRoot,
|
|
19904
19914
|
worktreesDirectory: getWorktreesDirectory(gitRoot, worktreesDirectory),
|
|
@@ -20002,15 +20012,42 @@ async function selectWithFzf(items, options = {}) {
|
|
|
20002
20012
|
import {
|
|
20003
20013
|
spawn as nodeSpawn
|
|
20004
20014
|
} from "node:child_process";
|
|
20015
|
+
|
|
20016
|
+
// ../process/src/resolve-windows-command-path.ts
|
|
20017
|
+
import { execFileSync } from "node:child_process";
|
|
20018
|
+
import path2 from "node:path";
|
|
20019
|
+
function resolveWindowsCommandPath(commandOrPath) {
|
|
20020
|
+
if (process.platform !== "win32") {
|
|
20021
|
+
throw new Error("resolveWindowsCommandPath is only supported on Windows");
|
|
20022
|
+
}
|
|
20023
|
+
if (path2.dirname(commandOrPath) !== ".") {
|
|
20024
|
+
return commandOrPath;
|
|
20025
|
+
}
|
|
20026
|
+
try {
|
|
20027
|
+
const stdout2 = execFileSync("where.exe", [commandOrPath], {
|
|
20028
|
+
windowsHide: true,
|
|
20029
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
20030
|
+
});
|
|
20031
|
+
const executablePath = stdout2.toString().split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
20032
|
+
if (executablePath) {
|
|
20033
|
+
return executablePath;
|
|
20034
|
+
}
|
|
20035
|
+
} catch {
|
|
20036
|
+
}
|
|
20037
|
+
return commandOrPath;
|
|
20038
|
+
}
|
|
20039
|
+
|
|
20040
|
+
// ../process/src/spawn.ts
|
|
20005
20041
|
async function spawnProcess(config2) {
|
|
20006
20042
|
return new Promise((resolve2) => {
|
|
20007
20043
|
const { command: command2, args: args2 = [], options = {} } = config2;
|
|
20008
|
-
const
|
|
20044
|
+
const file2 = process.platform === "win32" ? resolveWindowsCommandPath(command2) : command2;
|
|
20045
|
+
const childProcess = nodeSpawn(file2, args2, {
|
|
20009
20046
|
stdio: "inherit",
|
|
20010
20047
|
...options
|
|
20011
20048
|
});
|
|
20012
20049
|
childProcess.on("error", (error46) => {
|
|
20013
|
-
resolve2(err(new ProcessSpawnError(
|
|
20050
|
+
resolve2(err(new ProcessSpawnError(file2, error46.message)));
|
|
20014
20051
|
});
|
|
20015
20052
|
childProcess.on("exit", (code, signal) => {
|
|
20016
20053
|
if (signal) {
|
|
@@ -20020,7 +20057,7 @@ async function spawnProcess(config2) {
|
|
|
20020
20057
|
if (exitCode === 0) {
|
|
20021
20058
|
resolve2(ok({ exitCode }));
|
|
20022
20059
|
} else {
|
|
20023
|
-
resolve2(err(new ProcessExecutionError(
|
|
20060
|
+
resolve2(err(new ProcessExecutionError(file2, exitCode)));
|
|
20024
20061
|
}
|
|
20025
20062
|
}
|
|
20026
20063
|
});
|
|
@@ -20243,7 +20280,7 @@ import { existsSync } from "node:fs";
|
|
|
20243
20280
|
|
|
20244
20281
|
// ../core/src/worktree/file-copier.ts
|
|
20245
20282
|
import { copyFile, mkdir, stat } from "node:fs/promises";
|
|
20246
|
-
import
|
|
20283
|
+
import path3 from "node:path";
|
|
20247
20284
|
var FileCopyError = class extends Error {
|
|
20248
20285
|
file;
|
|
20249
20286
|
constructor(file2, message) {
|
|
@@ -20256,15 +20293,15 @@ async function copyFiles(sourceDir, targetDir, files) {
|
|
|
20256
20293
|
const copiedFiles = [];
|
|
20257
20294
|
const skippedFiles = [];
|
|
20258
20295
|
for (const file2 of files) {
|
|
20259
|
-
const sourcePath =
|
|
20260
|
-
const targetPath =
|
|
20296
|
+
const sourcePath = path3.join(sourceDir, file2);
|
|
20297
|
+
const targetPath = path3.join(targetDir, file2);
|
|
20261
20298
|
try {
|
|
20262
20299
|
const stats = await stat(sourcePath);
|
|
20263
20300
|
if (!stats.isFile()) {
|
|
20264
20301
|
skippedFiles.push(file2);
|
|
20265
20302
|
continue;
|
|
20266
20303
|
}
|
|
20267
|
-
const targetDirPath =
|
|
20304
|
+
const targetDirPath = path3.dirname(targetPath);
|
|
20268
20305
|
await mkdir(targetDirPath, { recursive: true });
|
|
20269
20306
|
await copyFile(sourcePath, targetPath);
|
|
20270
20307
|
copiedFiles.push(file2);
|
|
@@ -21152,19 +21189,19 @@ _phantom_completion() {
|
|
|
21152
21189
|
return 0
|
|
21153
21190
|
elif [[ \${words[2]} == "get" ]]; then
|
|
21154
21191
|
if [[ \${cword} -eq 3 ]]; then
|
|
21155
|
-
local keys="editor ai"
|
|
21192
|
+
local keys="editor ai worktreesDirectory"
|
|
21156
21193
|
COMPREPLY=( $(compgen -W "\${keys}" -- "\${cur}") )
|
|
21157
21194
|
return 0
|
|
21158
21195
|
fi
|
|
21159
21196
|
elif [[ \${words[2]} == "set" ]]; then
|
|
21160
21197
|
if [[ \${cword} -eq 3 ]]; then
|
|
21161
|
-
local keys="editor ai"
|
|
21198
|
+
local keys="editor ai worktreesDirectory"
|
|
21162
21199
|
COMPREPLY=( $(compgen -W "\${keys}" -- "\${cur}") )
|
|
21163
21200
|
return 0
|
|
21164
21201
|
fi
|
|
21165
21202
|
elif [[ \${words[2]} == "remove" ]]; then
|
|
21166
21203
|
if [[ \${cword} -eq 3 ]]; then
|
|
21167
|
-
local keys="editor ai"
|
|
21204
|
+
local keys="editor ai worktreesDirectory"
|
|
21168
21205
|
COMPREPLY=( $(compgen -W "\${keys}" -- "\${cur}") )
|
|
21169
21206
|
return 0
|
|
21170
21207
|
fi
|
|
@@ -21308,12 +21345,12 @@ complete -c phantom -n "__phantom_using_command" -a "create" -d "Create a new Gi
|
|
|
21308
21345
|
complete -c phantom -n "__phantom_using_command" -a "attach" -d "Attach to an existing branch by creating a new worktree"
|
|
21309
21346
|
complete -c phantom -n "__phantom_using_command" -a "list" -d "List all Git worktrees (phantoms)"
|
|
21310
21347
|
complete -c phantom -n "__phantom_using_command" -a "where" -d "Output the filesystem path of a specific worktree"
|
|
21311
|
-
complete -c phantom -n "__phantom_using_command" -a "delete" -d "Delete
|
|
21348
|
+
complete -c phantom -n "__phantom_using_command" -a "delete" -d "Delete Git worktrees (phantoms)"
|
|
21312
21349
|
complete -c phantom -n "__phantom_using_command" -a "exec" -d "Execute a command in a worktree directory"
|
|
21313
21350
|
complete -c phantom -n "__phantom_using_command" -a "edit" -d "Open a worktree in your configured editor"
|
|
21314
21351
|
complete -c phantom -n "__phantom_using_command" -a "ai" -d "Launch your configured AI coding assistant in a worktree"
|
|
21315
21352
|
complete -c phantom -n "__phantom_using_command" -a "shell" -d "Open an interactive shell in a worktree directory"
|
|
21316
|
-
complete -c phantom -n "__phantom_using_command" -a "preferences" -d "Manage editor/ai preferences (stored in git config --global)"
|
|
21353
|
+
complete -c phantom -n "__phantom_using_command" -a "preferences" -d "Manage editor/ai/worktreesDirectory preferences (stored in git config --global)"
|
|
21317
21354
|
complete -c phantom -n "__phantom_using_command" -a "github" -d "GitHub integration commands"
|
|
21318
21355
|
complete -c phantom -n "__phantom_using_command" -a "gh" -d "GitHub integration commands (alias)"
|
|
21319
21356
|
complete -c phantom -n "__phantom_using_command" -a "version" -d "Display phantom version information"
|
|
@@ -21379,9 +21416,9 @@ complete -c phantom -n "__phantom_using_command ai" -a "(__phantom_list_worktree
|
|
|
21379
21416
|
|
|
21380
21417
|
# preferences command
|
|
21381
21418
|
complete -c phantom -n "__phantom_using_command preferences" -a "get set remove" -d "Manage preferences"
|
|
21382
|
-
complete -c phantom -n "__phantom_using_command preferences get" -a "editor ai" -d "Preference key"
|
|
21383
|
-
complete -c phantom -n "__phantom_using_command preferences set" -a "editor ai" -d "Preference key"
|
|
21384
|
-
complete -c phantom -n "__phantom_using_command preferences remove" -a "editor ai" -d "Preference key"
|
|
21419
|
+
complete -c phantom -n "__phantom_using_command preferences get" -a "editor ai worktreesDirectory" -d "Preference key"
|
|
21420
|
+
complete -c phantom -n "__phantom_using_command preferences set" -a "editor ai worktreesDirectory" -d "Preference key"
|
|
21421
|
+
complete -c phantom -n "__phantom_using_command preferences remove" -a "editor ai worktreesDirectory" -d "Preference key"
|
|
21385
21422
|
|
|
21386
21423
|
# shell command options
|
|
21387
21424
|
complete -c phantom -n "__phantom_using_command shell" -l fzf -d "Use fzf for interactive selection"
|
|
@@ -21430,12 +21467,12 @@ _phantom() {
|
|
|
21430
21467
|
'attach:Attach to an existing branch by creating a new worktree'
|
|
21431
21468
|
'list:List all Git worktrees (phantoms)'
|
|
21432
21469
|
'where:Output the filesystem path of a specific worktree'
|
|
21433
|
-
'delete:Delete
|
|
21470
|
+
'delete:Delete Git worktrees (phantoms)'
|
|
21434
21471
|
'exec:Execute a command in a worktree directory'
|
|
21435
21472
|
'edit:Open a worktree in your configured editor'
|
|
21436
21473
|
'ai:Launch your configured AI coding assistant in a worktree'
|
|
21437
21474
|
'shell:Open an interactive shell in a worktree directory'
|
|
21438
|
-
'preferences:Manage editor/ai preferences (git config --global)'
|
|
21475
|
+
'preferences:Manage editor/ai/worktreesDirectory preferences (git config --global)'
|
|
21439
21476
|
'github:GitHub integration commands'
|
|
21440
21477
|
'gh:GitHub integration commands (alias)'
|
|
21441
21478
|
'version:Display phantom version information'
|
|
@@ -21468,7 +21505,7 @@ _phantom() {
|
|
|
21468
21505
|
elif [[ \${line[1]} == "shell" ]]; then
|
|
21469
21506
|
_arguments '--fzf[Use fzf for interactive selection]' '--tmux[Open shell in new tmux window (-t)]' '--tmux-vertical[Open shell in vertical split pane]' '--tmux-horizontal[Open shell in horizontal split pane]' '1:worktree:(\${(q)worktrees[@]})'
|
|
21470
21507
|
elif [[ \${line[1]} == "delete" ]]; then
|
|
21471
|
-
_arguments '--force[Force deletion even if worktree has uncommitted changes (-f)]' '--current[Delete the current worktree]' '--fzf[Use fzf for interactive selection]' '
|
|
21508
|
+
_arguments '--force[Force deletion even if worktree has uncommitted changes (-f)]' '--current[Delete the current worktree]' '--fzf[Use fzf for interactive selection]' '*:worktree:(\${(q)worktrees[@]})'
|
|
21472
21509
|
fi
|
|
21473
21510
|
;;
|
|
21474
21511
|
exec)
|
|
@@ -21487,7 +21524,7 @@ _phantom() {
|
|
|
21487
21524
|
_arguments '1:worktree:(\${(q)worktrees[@]})'
|
|
21488
21525
|
;;
|
|
21489
21526
|
preferences)
|
|
21490
|
-
_arguments '1:subcommand:(get set remove)' '2:key:(editor ai)'
|
|
21527
|
+
_arguments '1:subcommand:(get set remove)' '2:key:(editor ai worktreesDirectory)'
|
|
21491
21528
|
;;
|
|
21492
21529
|
completion)
|
|
21493
21530
|
_arguments '1:shell:(fish zsh bash)'
|
|
@@ -21735,7 +21772,7 @@ async function deleteHandler(args2) {
|
|
|
21735
21772
|
const useFzf = values.fzf ?? false;
|
|
21736
21773
|
if (positionals.length === 0 && !deleteCurrent && !useFzf) {
|
|
21737
21774
|
exitWithError(
|
|
21738
|
-
"Please provide
|
|
21775
|
+
"Please provide at least one worktree name to delete, use --current to delete the current worktree, or use --fzf for interactive selection",
|
|
21739
21776
|
exitCodes.validationError
|
|
21740
21777
|
);
|
|
21741
21778
|
}
|
|
@@ -21755,7 +21792,7 @@ async function deleteHandler(args2) {
|
|
|
21755
21792
|
try {
|
|
21756
21793
|
const gitRoot = await getGitRoot();
|
|
21757
21794
|
const context = await createContext(gitRoot);
|
|
21758
|
-
|
|
21795
|
+
const worktreeNames = [];
|
|
21759
21796
|
if (deleteCurrent) {
|
|
21760
21797
|
const currentWorktree = await getCurrentWorktree(gitRoot);
|
|
21761
21798
|
if (!currentWorktree) {
|
|
@@ -21764,7 +21801,7 @@ async function deleteHandler(args2) {
|
|
|
21764
21801
|
exitCodes.validationError
|
|
21765
21802
|
);
|
|
21766
21803
|
}
|
|
21767
|
-
|
|
21804
|
+
worktreeNames.push(currentWorktree);
|
|
21768
21805
|
} else if (useFzf) {
|
|
21769
21806
|
const selectResult = await selectWorktreeWithFzf(context.gitRoot);
|
|
21770
21807
|
if (isErr(selectResult)) {
|
|
@@ -21773,24 +21810,26 @@ async function deleteHandler(args2) {
|
|
|
21773
21810
|
if (!selectResult.value) {
|
|
21774
21811
|
exitWithSuccess();
|
|
21775
21812
|
}
|
|
21776
|
-
|
|
21813
|
+
worktreeNames.push(selectResult.value.name);
|
|
21777
21814
|
} else {
|
|
21778
|
-
|
|
21815
|
+
worktreeNames.push(...positionals);
|
|
21779
21816
|
}
|
|
21780
|
-
const
|
|
21781
|
-
|
|
21782
|
-
|
|
21783
|
-
|
|
21784
|
-
|
|
21785
|
-
|
|
21786
|
-
|
|
21787
|
-
|
|
21788
|
-
|
|
21789
|
-
|
|
21790
|
-
|
|
21791
|
-
|
|
21817
|
+
for (const worktreeName of worktreeNames) {
|
|
21818
|
+
const result = await deleteWorktree(
|
|
21819
|
+
context.gitRoot,
|
|
21820
|
+
context.worktreesDirectory,
|
|
21821
|
+
worktreeName,
|
|
21822
|
+
{
|
|
21823
|
+
force: forceDelete
|
|
21824
|
+
},
|
|
21825
|
+
context.config?.preDelete?.commands
|
|
21826
|
+
);
|
|
21827
|
+
if (isErr(result)) {
|
|
21828
|
+
const exitCode = result.error instanceof WorktreeNotFoundError ? exitCodes.validationError : result.error instanceof WorktreeError && result.error.message.includes("uncommitted changes") ? exitCodes.validationError : exitCodes.generalError;
|
|
21829
|
+
exitWithError(result.error.message, exitCode);
|
|
21830
|
+
}
|
|
21831
|
+
output.log(result.value.message);
|
|
21792
21832
|
}
|
|
21793
|
-
output.log(result.value.message);
|
|
21794
21833
|
exitWithSuccess();
|
|
21795
21834
|
} catch (error46) {
|
|
21796
21835
|
exitWithError(
|
|
@@ -22341,7 +22380,7 @@ function bindApi(hook2, state, name) {
|
|
|
22341
22380
|
});
|
|
22342
22381
|
}
|
|
22343
22382
|
function Singular() {
|
|
22344
|
-
const singularHookName = Symbol("Singular");
|
|
22383
|
+
const singularHookName = /* @__PURE__ */ Symbol("Singular");
|
|
22345
22384
|
const singularHookState = {
|
|
22346
22385
|
registry: {}
|
|
22347
22386
|
};
|
|
@@ -23190,17 +23229,17 @@ function requestLog(octokit) {
|
|
|
23190
23229
|
octokit.log.debug("request", options);
|
|
23191
23230
|
const start = Date.now();
|
|
23192
23231
|
const requestOptions = octokit.request.endpoint.parse(options);
|
|
23193
|
-
const
|
|
23232
|
+
const path4 = requestOptions.url.replace(options.baseUrl, "");
|
|
23194
23233
|
return request2(options).then((response) => {
|
|
23195
23234
|
const requestId = response.headers["x-github-request-id"];
|
|
23196
23235
|
octokit.log.info(
|
|
23197
|
-
`${requestOptions.method} ${
|
|
23236
|
+
`${requestOptions.method} ${path4} - ${response.status} with id ${requestId} in ${Date.now() - start}ms`
|
|
23198
23237
|
);
|
|
23199
23238
|
return response;
|
|
23200
23239
|
}).catch((error46) => {
|
|
23201
23240
|
const requestId = error46.response?.headers["x-github-request-id"] || "UNKNOWN";
|
|
23202
23241
|
octokit.log.error(
|
|
23203
|
-
`${requestOptions.method} ${
|
|
23242
|
+
`${requestOptions.method} ${path4} - ${error46.status} with id ${requestId} in ${Date.now() - start}ms`
|
|
23204
23243
|
);
|
|
23205
23244
|
throw error46;
|
|
23206
23245
|
});
|
|
@@ -26515,8 +26554,8 @@ function getErrorMap2() {
|
|
|
26515
26554
|
|
|
26516
26555
|
// ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v3/helpers/parseUtil.js
|
|
26517
26556
|
var makeIssue = (params) => {
|
|
26518
|
-
const { data, path:
|
|
26519
|
-
const fullPath = [...
|
|
26557
|
+
const { data, path: path4, errorMaps, issueData } = params;
|
|
26558
|
+
const fullPath = [...path4, ...issueData.path || []];
|
|
26520
26559
|
const fullIssue = {
|
|
26521
26560
|
...issueData,
|
|
26522
26561
|
path: fullPath
|
|
@@ -26631,11 +26670,11 @@ var errorUtil;
|
|
|
26631
26670
|
|
|
26632
26671
|
// ../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v3/types.js
|
|
26633
26672
|
var ParseInputLazyPath = class {
|
|
26634
|
-
constructor(parent, value,
|
|
26673
|
+
constructor(parent, value, path4, key) {
|
|
26635
26674
|
this._cachedPath = [];
|
|
26636
26675
|
this.parent = parent;
|
|
26637
26676
|
this.data = value;
|
|
26638
|
-
this._path =
|
|
26677
|
+
this._path = path4;
|
|
26639
26678
|
this._key = key;
|
|
26640
26679
|
}
|
|
26641
26680
|
get path() {
|
|
@@ -29864,7 +29903,6 @@ ZodNaN2.create = (params) => {
|
|
|
29864
29903
|
...processCreateParams(params)
|
|
29865
29904
|
});
|
|
29866
29905
|
};
|
|
29867
|
-
var BRAND = Symbol("zod_brand");
|
|
29868
29906
|
var ZodBranded = class extends ZodType2 {
|
|
29869
29907
|
_parse(input) {
|
|
29870
29908
|
const { ctx } = this._processInputParams(input);
|
|
@@ -30077,7 +30115,7 @@ function object2(shape, params) {
|
|
|
30077
30115
|
return new ZodMiniObject(def);
|
|
30078
30116
|
}
|
|
30079
30117
|
|
|
30080
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
30118
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
30081
30119
|
function isZ4Schema(s) {
|
|
30082
30120
|
const schema5 = s;
|
|
30083
30121
|
return !!schema5._zod;
|
|
@@ -30152,7 +30190,7 @@ function normalizeObjectSchema(schema5) {
|
|
|
30152
30190
|
if (isZ4Schema(schema5)) {
|
|
30153
30191
|
const v4Schema = schema5;
|
|
30154
30192
|
const def = (_a2 = v4Schema._zod) === null || _a2 === void 0 ? void 0 : _a2.def;
|
|
30155
|
-
if (def && (def.
|
|
30193
|
+
if (def && (def.type === "object" || def.shape !== void 0)) {
|
|
30156
30194
|
return schema5;
|
|
30157
30195
|
}
|
|
30158
30196
|
} else {
|
|
@@ -30195,7 +30233,7 @@ function isSchemaOptional(schema5) {
|
|
|
30195
30233
|
var _a2, _b, _c;
|
|
30196
30234
|
if (isZ4Schema(schema5)) {
|
|
30197
30235
|
const v4Schema = schema5;
|
|
30198
|
-
return ((_b = (_a2 = v4Schema._zod) === null || _a2 === void 0 ? void 0 : _a2.def) === null || _b === void 0 ? void 0 : _b.
|
|
30236
|
+
return ((_b = (_a2 = v4Schema._zod) === null || _a2 === void 0 ? void 0 : _a2.def) === null || _b === void 0 ? void 0 : _b.type) === "optional";
|
|
30199
30237
|
}
|
|
30200
30238
|
const v3Schema = schema5;
|
|
30201
30239
|
if (typeof schema5.isOptional === "function") {
|
|
@@ -30231,20 +30269,44 @@ function getLiteralValue(schema5) {
|
|
|
30231
30269
|
return void 0;
|
|
30232
30270
|
}
|
|
30233
30271
|
|
|
30234
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
30235
|
-
var LATEST_PROTOCOL_VERSION = "2025-
|
|
30236
|
-
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
30272
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
30273
|
+
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
30274
|
+
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
30275
|
+
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
30237
30276
|
var JSONRPC_VERSION = "2.0";
|
|
30238
30277
|
var AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
|
|
30239
30278
|
var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
30240
30279
|
var CursorSchema = string2();
|
|
30280
|
+
var TaskCreationParamsSchema = looseObject({
|
|
30281
|
+
/**
|
|
30282
|
+
* Time in milliseconds to keep task results available after completion.
|
|
30283
|
+
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
30284
|
+
*/
|
|
30285
|
+
ttl: union([number2(), _null3()]).optional(),
|
|
30286
|
+
/**
|
|
30287
|
+
* Time in milliseconds to wait between task status requests.
|
|
30288
|
+
*/
|
|
30289
|
+
pollInterval: number2().optional()
|
|
30290
|
+
});
|
|
30291
|
+
var RelatedTaskMetadataSchema = looseObject({
|
|
30292
|
+
taskId: string2()
|
|
30293
|
+
});
|
|
30241
30294
|
var RequestMetaSchema = looseObject({
|
|
30242
30295
|
/**
|
|
30243
30296
|
* 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.
|
|
30244
30297
|
*/
|
|
30245
|
-
progressToken: ProgressTokenSchema.optional()
|
|
30298
|
+
progressToken: ProgressTokenSchema.optional(),
|
|
30299
|
+
/**
|
|
30300
|
+
* If specified, this request is related to the provided task.
|
|
30301
|
+
*/
|
|
30302
|
+
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
30246
30303
|
});
|
|
30247
30304
|
var BaseRequestParamsSchema = looseObject({
|
|
30305
|
+
/**
|
|
30306
|
+
* If specified, the caller is requesting that the receiver create a task to represent the request.
|
|
30307
|
+
* Task creation parameters are now at the top level instead of in _meta.
|
|
30308
|
+
*/
|
|
30309
|
+
task: TaskCreationParamsSchema.optional(),
|
|
30248
30310
|
/**
|
|
30249
30311
|
* See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
|
|
30250
30312
|
*/
|
|
@@ -30259,7 +30321,12 @@ var NotificationsParamsSchema = looseObject({
|
|
|
30259
30321
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30260
30322
|
* for notes on _meta usage.
|
|
30261
30323
|
*/
|
|
30262
|
-
_meta:
|
|
30324
|
+
_meta: object({
|
|
30325
|
+
/**
|
|
30326
|
+
* If specified, this notification is related to the provided task.
|
|
30327
|
+
*/
|
|
30328
|
+
[RELATED_TASK_META_KEY]: optional(RelatedTaskMetadataSchema)
|
|
30329
|
+
}).passthrough().optional()
|
|
30263
30330
|
});
|
|
30264
30331
|
var NotificationSchema = object({
|
|
30265
30332
|
method: string2(),
|
|
@@ -30270,7 +30337,12 @@ var ResultSchema = looseObject({
|
|
|
30270
30337
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30271
30338
|
* for notes on _meta usage.
|
|
30272
30339
|
*/
|
|
30273
|
-
_meta:
|
|
30340
|
+
_meta: looseObject({
|
|
30341
|
+
/**
|
|
30342
|
+
* If specified, this result is related to the provided task.
|
|
30343
|
+
*/
|
|
30344
|
+
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
30345
|
+
}).optional()
|
|
30274
30346
|
});
|
|
30275
30347
|
var RequestIdSchema = union([string2(), number2().int()]);
|
|
30276
30348
|
var JSONRPCRequestSchema = object({
|
|
@@ -30405,6 +30477,54 @@ var ElicitationCapabilitySchema = preprocess((value) => {
|
|
|
30405
30477
|
form: FormElicitationCapabilitySchema.optional(),
|
|
30406
30478
|
url: AssertObjectSchema.optional()
|
|
30407
30479
|
}), record(string2(), unknown()).optional()));
|
|
30480
|
+
var ClientTasksCapabilitySchema = object({
|
|
30481
|
+
/**
|
|
30482
|
+
* Present if the client supports listing tasks.
|
|
30483
|
+
*/
|
|
30484
|
+
list: optional(object({}).passthrough()),
|
|
30485
|
+
/**
|
|
30486
|
+
* Present if the client supports cancelling tasks.
|
|
30487
|
+
*/
|
|
30488
|
+
cancel: optional(object({}).passthrough()),
|
|
30489
|
+
/**
|
|
30490
|
+
* Capabilities for task creation on specific request types.
|
|
30491
|
+
*/
|
|
30492
|
+
requests: optional(object({
|
|
30493
|
+
/**
|
|
30494
|
+
* Task support for sampling requests.
|
|
30495
|
+
*/
|
|
30496
|
+
sampling: optional(object({
|
|
30497
|
+
createMessage: optional(object({}).passthrough())
|
|
30498
|
+
}).passthrough()),
|
|
30499
|
+
/**
|
|
30500
|
+
* Task support for elicitation requests.
|
|
30501
|
+
*/
|
|
30502
|
+
elicitation: optional(object({
|
|
30503
|
+
create: optional(object({}).passthrough())
|
|
30504
|
+
}).passthrough())
|
|
30505
|
+
}).passthrough())
|
|
30506
|
+
}).passthrough();
|
|
30507
|
+
var ServerTasksCapabilitySchema = object({
|
|
30508
|
+
/**
|
|
30509
|
+
* Present if the server supports listing tasks.
|
|
30510
|
+
*/
|
|
30511
|
+
list: optional(object({}).passthrough()),
|
|
30512
|
+
/**
|
|
30513
|
+
* Present if the server supports cancelling tasks.
|
|
30514
|
+
*/
|
|
30515
|
+
cancel: optional(object({}).passthrough()),
|
|
30516
|
+
/**
|
|
30517
|
+
* Capabilities for task creation on specific request types.
|
|
30518
|
+
*/
|
|
30519
|
+
requests: optional(object({
|
|
30520
|
+
/**
|
|
30521
|
+
* Task support for tool requests.
|
|
30522
|
+
*/
|
|
30523
|
+
tools: optional(object({
|
|
30524
|
+
call: optional(object({}).passthrough())
|
|
30525
|
+
}).passthrough())
|
|
30526
|
+
}).passthrough())
|
|
30527
|
+
}).passthrough();
|
|
30408
30528
|
var ClientCapabilitiesSchema = object({
|
|
30409
30529
|
/**
|
|
30410
30530
|
* Experimental, non-standard capabilities that the client supports.
|
|
@@ -30436,7 +30556,11 @@ var ClientCapabilitiesSchema = object({
|
|
|
30436
30556
|
* Whether the client supports issuing notifications for changes to the roots list.
|
|
30437
30557
|
*/
|
|
30438
30558
|
listChanged: boolean2().optional()
|
|
30439
|
-
}).optional()
|
|
30559
|
+
}).optional(),
|
|
30560
|
+
/**
|
|
30561
|
+
* Present if the client supports task creation.
|
|
30562
|
+
*/
|
|
30563
|
+
tasks: optional(ClientTasksCapabilitySchema)
|
|
30440
30564
|
});
|
|
30441
30565
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
30442
30566
|
/**
|
|
@@ -30493,8 +30617,12 @@ var ServerCapabilitiesSchema = object({
|
|
|
30493
30617
|
* Whether this server supports issuing notifications for changes to the tool list.
|
|
30494
30618
|
*/
|
|
30495
30619
|
listChanged: boolean2().optional()
|
|
30496
|
-
}).optional()
|
|
30497
|
-
|
|
30620
|
+
}).optional(),
|
|
30621
|
+
/**
|
|
30622
|
+
* Present if the server supports task creation.
|
|
30623
|
+
*/
|
|
30624
|
+
tasks: optional(ServerTasksCapabilitySchema)
|
|
30625
|
+
}).passthrough();
|
|
30498
30626
|
var InitializeResultSchema = ResultSchema.extend({
|
|
30499
30627
|
/**
|
|
30500
30628
|
* 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.
|
|
@@ -30558,6 +30686,62 @@ var PaginatedResultSchema = ResultSchema.extend({
|
|
|
30558
30686
|
*/
|
|
30559
30687
|
nextCursor: optional(CursorSchema)
|
|
30560
30688
|
});
|
|
30689
|
+
var TaskSchema = object({
|
|
30690
|
+
taskId: string2(),
|
|
30691
|
+
status: _enum2(["working", "input_required", "completed", "failed", "cancelled"]),
|
|
30692
|
+
/**
|
|
30693
|
+
* Time in milliseconds to keep task results available after completion.
|
|
30694
|
+
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
30695
|
+
*/
|
|
30696
|
+
ttl: union([number2(), _null3()]),
|
|
30697
|
+
/**
|
|
30698
|
+
* ISO 8601 timestamp when the task was created.
|
|
30699
|
+
*/
|
|
30700
|
+
createdAt: string2(),
|
|
30701
|
+
/**
|
|
30702
|
+
* ISO 8601 timestamp when the task was last updated.
|
|
30703
|
+
*/
|
|
30704
|
+
lastUpdatedAt: string2(),
|
|
30705
|
+
pollInterval: optional(number2()),
|
|
30706
|
+
/**
|
|
30707
|
+
* Optional diagnostic message for failed tasks or other status information.
|
|
30708
|
+
*/
|
|
30709
|
+
statusMessage: optional(string2())
|
|
30710
|
+
});
|
|
30711
|
+
var CreateTaskResultSchema = ResultSchema.extend({
|
|
30712
|
+
task: TaskSchema
|
|
30713
|
+
});
|
|
30714
|
+
var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
|
|
30715
|
+
var TaskStatusNotificationSchema = NotificationSchema.extend({
|
|
30716
|
+
method: literal("notifications/tasks/status"),
|
|
30717
|
+
params: TaskStatusNotificationParamsSchema
|
|
30718
|
+
});
|
|
30719
|
+
var GetTaskRequestSchema = RequestSchema.extend({
|
|
30720
|
+
method: literal("tasks/get"),
|
|
30721
|
+
params: BaseRequestParamsSchema.extend({
|
|
30722
|
+
taskId: string2()
|
|
30723
|
+
})
|
|
30724
|
+
});
|
|
30725
|
+
var GetTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
30726
|
+
var GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
30727
|
+
method: literal("tasks/result"),
|
|
30728
|
+
params: BaseRequestParamsSchema.extend({
|
|
30729
|
+
taskId: string2()
|
|
30730
|
+
})
|
|
30731
|
+
});
|
|
30732
|
+
var ListTasksRequestSchema = PaginatedRequestSchema.extend({
|
|
30733
|
+
method: literal("tasks/list")
|
|
30734
|
+
});
|
|
30735
|
+
var ListTasksResultSchema = PaginatedResultSchema.extend({
|
|
30736
|
+
tasks: array(TaskSchema)
|
|
30737
|
+
});
|
|
30738
|
+
var CancelTaskRequestSchema = RequestSchema.extend({
|
|
30739
|
+
method: literal("tasks/cancel"),
|
|
30740
|
+
params: BaseRequestParamsSchema.extend({
|
|
30741
|
+
taskId: string2()
|
|
30742
|
+
})
|
|
30743
|
+
});
|
|
30744
|
+
var CancelTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
30561
30745
|
var ResourceContentsSchema = object({
|
|
30562
30746
|
/**
|
|
30563
30747
|
* The URI of this resource.
|
|
@@ -30593,6 +30777,20 @@ var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
|
30593
30777
|
*/
|
|
30594
30778
|
blob: Base64Schema
|
|
30595
30779
|
});
|
|
30780
|
+
var AnnotationsSchema = object({
|
|
30781
|
+
/**
|
|
30782
|
+
* Intended audience(s) for the resource.
|
|
30783
|
+
*/
|
|
30784
|
+
audience: array(_enum2(["user", "assistant"])).optional(),
|
|
30785
|
+
/**
|
|
30786
|
+
* Importance hint for the resource, from 0 (least) to 1 (most).
|
|
30787
|
+
*/
|
|
30788
|
+
priority: number2().min(0).max(1).optional(),
|
|
30789
|
+
/**
|
|
30790
|
+
* ISO 8601 timestamp for the most recent modification.
|
|
30791
|
+
*/
|
|
30792
|
+
lastModified: iso_exports.datetime({ offset: true }).optional()
|
|
30793
|
+
});
|
|
30596
30794
|
var ResourceSchema = object({
|
|
30597
30795
|
...BaseMetadataSchema.shape,
|
|
30598
30796
|
...IconsSchema.shape,
|
|
@@ -30610,6 +30808,10 @@ var ResourceSchema = object({
|
|
|
30610
30808
|
* The MIME type of this resource, if known.
|
|
30611
30809
|
*/
|
|
30612
30810
|
mimeType: optional(string2()),
|
|
30811
|
+
/**
|
|
30812
|
+
* Optional annotations for the client.
|
|
30813
|
+
*/
|
|
30814
|
+
annotations: AnnotationsSchema.optional(),
|
|
30613
30815
|
/**
|
|
30614
30816
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30615
30817
|
* for notes on _meta usage.
|
|
@@ -30633,6 +30835,10 @@ var ResourceTemplateSchema = object({
|
|
|
30633
30835
|
* 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.
|
|
30634
30836
|
*/
|
|
30635
30837
|
mimeType: optional(string2()),
|
|
30838
|
+
/**
|
|
30839
|
+
* Optional annotations for the client.
|
|
30840
|
+
*/
|
|
30841
|
+
annotations: AnnotationsSchema.optional(),
|
|
30636
30842
|
/**
|
|
30637
30843
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30638
30844
|
* for notes on _meta usage.
|
|
@@ -30747,6 +30953,10 @@ var TextContentSchema = object({
|
|
|
30747
30953
|
* The text content of the message.
|
|
30748
30954
|
*/
|
|
30749
30955
|
text: string2(),
|
|
30956
|
+
/**
|
|
30957
|
+
* Optional annotations for the client.
|
|
30958
|
+
*/
|
|
30959
|
+
annotations: AnnotationsSchema.optional(),
|
|
30750
30960
|
/**
|
|
30751
30961
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30752
30962
|
* for notes on _meta usage.
|
|
@@ -30763,6 +30973,10 @@ var ImageContentSchema = object({
|
|
|
30763
30973
|
* The MIME type of the image. Different providers may support different image types.
|
|
30764
30974
|
*/
|
|
30765
30975
|
mimeType: string2(),
|
|
30976
|
+
/**
|
|
30977
|
+
* Optional annotations for the client.
|
|
30978
|
+
*/
|
|
30979
|
+
annotations: AnnotationsSchema.optional(),
|
|
30766
30980
|
/**
|
|
30767
30981
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30768
30982
|
* for notes on _meta usage.
|
|
@@ -30779,6 +30993,10 @@ var AudioContentSchema = object({
|
|
|
30779
30993
|
* The MIME type of the audio. Different providers may support different audio types.
|
|
30780
30994
|
*/
|
|
30781
30995
|
mimeType: string2(),
|
|
30996
|
+
/**
|
|
30997
|
+
* Optional annotations for the client.
|
|
30998
|
+
*/
|
|
30999
|
+
annotations: AnnotationsSchema.optional(),
|
|
30782
31000
|
/**
|
|
30783
31001
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30784
31002
|
* for notes on _meta usage.
|
|
@@ -30811,6 +31029,10 @@ var ToolUseContentSchema = object({
|
|
|
30811
31029
|
var EmbeddedResourceSchema = object({
|
|
30812
31030
|
type: literal("resource"),
|
|
30813
31031
|
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
31032
|
+
/**
|
|
31033
|
+
* Optional annotations for the client.
|
|
31034
|
+
*/
|
|
31035
|
+
annotations: AnnotationsSchema.optional(),
|
|
30814
31036
|
/**
|
|
30815
31037
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30816
31038
|
* for notes on _meta usage.
|
|
@@ -30880,6 +31102,17 @@ var ToolAnnotationsSchema = object({
|
|
|
30880
31102
|
*/
|
|
30881
31103
|
openWorldHint: boolean2().optional()
|
|
30882
31104
|
});
|
|
31105
|
+
var ToolExecutionSchema = object({
|
|
31106
|
+
/**
|
|
31107
|
+
* Indicates the tool's preference for task-augmented execution.
|
|
31108
|
+
* - "required": Clients MUST invoke the tool as a task
|
|
31109
|
+
* - "optional": Clients MAY invoke the tool as a task or normal request
|
|
31110
|
+
* - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
|
|
31111
|
+
*
|
|
31112
|
+
* If not present, defaults to "forbidden".
|
|
31113
|
+
*/
|
|
31114
|
+
taskSupport: _enum2(["required", "optional", "forbidden"]).optional()
|
|
31115
|
+
});
|
|
30883
31116
|
var ToolSchema = object({
|
|
30884
31117
|
...BaseMetadataSchema.shape,
|
|
30885
31118
|
...IconsSchema.shape,
|
|
@@ -30910,6 +31143,10 @@ var ToolSchema = object({
|
|
|
30910
31143
|
* Optional additional tool information.
|
|
30911
31144
|
*/
|
|
30912
31145
|
annotations: optional(ToolAnnotationsSchema),
|
|
31146
|
+
/**
|
|
31147
|
+
* Execution-related properties for this tool.
|
|
31148
|
+
*/
|
|
31149
|
+
execution: optional(ToolExecutionSchema),
|
|
30913
31150
|
/**
|
|
30914
31151
|
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
30915
31152
|
* for notes on _meta usage.
|
|
@@ -31046,6 +31283,7 @@ var ToolResultContentSchema = object({
|
|
|
31046
31283
|
*/
|
|
31047
31284
|
_meta: optional(object({}).passthrough())
|
|
31048
31285
|
}).passthrough();
|
|
31286
|
+
var SamplingContentSchema = discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
|
|
31049
31287
|
var SamplingMessageContentBlockSchema = discriminatedUnion("type", [
|
|
31050
31288
|
TextContentSchema,
|
|
31051
31289
|
ImageContentSchema,
|
|
@@ -31109,6 +31347,28 @@ var CreateMessageRequestSchema = RequestSchema.extend({
|
|
|
31109
31347
|
params: CreateMessageRequestParamsSchema
|
|
31110
31348
|
});
|
|
31111
31349
|
var CreateMessageResultSchema = ResultSchema.extend({
|
|
31350
|
+
/**
|
|
31351
|
+
* The name of the model that generated the message.
|
|
31352
|
+
*/
|
|
31353
|
+
model: string2(),
|
|
31354
|
+
/**
|
|
31355
|
+
* The reason why sampling stopped, if known.
|
|
31356
|
+
*
|
|
31357
|
+
* Standard values:
|
|
31358
|
+
* - "endTurn": Natural end of the assistant's turn
|
|
31359
|
+
* - "stopSequence": A stop sequence was encountered
|
|
31360
|
+
* - "maxTokens": Maximum token limit was reached
|
|
31361
|
+
*
|
|
31362
|
+
* This field is an open string to allow for provider-specific stop reasons.
|
|
31363
|
+
*/
|
|
31364
|
+
stopReason: optional(_enum2(["endTurn", "stopSequence", "maxTokens"]).or(string2())),
|
|
31365
|
+
role: _enum2(["user", "assistant"]),
|
|
31366
|
+
/**
|
|
31367
|
+
* Response content. Single content block (text, image, or audio).
|
|
31368
|
+
*/
|
|
31369
|
+
content: SamplingContentSchema
|
|
31370
|
+
});
|
|
31371
|
+
var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
31112
31372
|
/**
|
|
31113
31373
|
* The name of the model that generated the message.
|
|
31114
31374
|
*/
|
|
@@ -31127,7 +31387,7 @@ var CreateMessageResultSchema = ResultSchema.extend({
|
|
|
31127
31387
|
stopReason: optional(_enum2(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(string2())),
|
|
31128
31388
|
role: _enum2(["user", "assistant"]),
|
|
31129
31389
|
/**
|
|
31130
|
-
* Response content. May be ToolUseContent if stopReason is "toolUse".
|
|
31390
|
+
* Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
|
|
31131
31391
|
*/
|
|
31132
31392
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
|
|
31133
31393
|
});
|
|
@@ -31275,8 +31535,10 @@ var ElicitResultSchema = ResultSchema.extend({
|
|
|
31275
31535
|
/**
|
|
31276
31536
|
* The submitted form data, only present when action is "accept".
|
|
31277
31537
|
* Contains values matching the requested schema.
|
|
31538
|
+
* Per MCP spec, content is "typically omitted" for decline/cancel actions.
|
|
31539
|
+
* We normalize null to undefined for leniency while maintaining type compatibility.
|
|
31278
31540
|
*/
|
|
31279
|
-
content: record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional()
|
|
31541
|
+
content: preprocess((val) => val === null ? void 0 : val, record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional())
|
|
31280
31542
|
});
|
|
31281
31543
|
var ResourceTemplateReferenceSchema = object({
|
|
31282
31544
|
type: literal("ref/resource"),
|
|
@@ -31383,16 +31645,37 @@ var ClientRequestSchema = union([
|
|
|
31383
31645
|
SubscribeRequestSchema,
|
|
31384
31646
|
UnsubscribeRequestSchema,
|
|
31385
31647
|
CallToolRequestSchema,
|
|
31386
|
-
ListToolsRequestSchema
|
|
31648
|
+
ListToolsRequestSchema,
|
|
31649
|
+
GetTaskRequestSchema,
|
|
31650
|
+
GetTaskPayloadRequestSchema,
|
|
31651
|
+
ListTasksRequestSchema
|
|
31387
31652
|
]);
|
|
31388
31653
|
var ClientNotificationSchema = union([
|
|
31389
31654
|
CancelledNotificationSchema,
|
|
31390
31655
|
ProgressNotificationSchema,
|
|
31391
31656
|
InitializedNotificationSchema,
|
|
31392
|
-
RootsListChangedNotificationSchema
|
|
31657
|
+
RootsListChangedNotificationSchema,
|
|
31658
|
+
TaskStatusNotificationSchema
|
|
31659
|
+
]);
|
|
31660
|
+
var ClientResultSchema = union([
|
|
31661
|
+
EmptyResultSchema,
|
|
31662
|
+
CreateMessageResultSchema,
|
|
31663
|
+
CreateMessageResultWithToolsSchema,
|
|
31664
|
+
ElicitResultSchema,
|
|
31665
|
+
ListRootsResultSchema,
|
|
31666
|
+
GetTaskResultSchema,
|
|
31667
|
+
ListTasksResultSchema,
|
|
31668
|
+
CreateTaskResultSchema
|
|
31669
|
+
]);
|
|
31670
|
+
var ServerRequestSchema = union([
|
|
31671
|
+
PingRequestSchema,
|
|
31672
|
+
CreateMessageRequestSchema,
|
|
31673
|
+
ElicitRequestSchema,
|
|
31674
|
+
ListRootsRequestSchema,
|
|
31675
|
+
GetTaskRequestSchema,
|
|
31676
|
+
GetTaskPayloadRequestSchema,
|
|
31677
|
+
ListTasksRequestSchema
|
|
31393
31678
|
]);
|
|
31394
|
-
var ClientResultSchema = union([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
|
|
31395
|
-
var ServerRequestSchema = union([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
|
|
31396
31679
|
var ServerNotificationSchema = union([
|
|
31397
31680
|
CancelledNotificationSchema,
|
|
31398
31681
|
ProgressNotificationSchema,
|
|
@@ -31401,6 +31684,7 @@ var ServerNotificationSchema = union([
|
|
|
31401
31684
|
ResourceListChangedNotificationSchema,
|
|
31402
31685
|
ToolListChangedNotificationSchema,
|
|
31403
31686
|
PromptListChangedNotificationSchema,
|
|
31687
|
+
TaskStatusNotificationSchema,
|
|
31404
31688
|
ElicitationCompleteNotificationSchema
|
|
31405
31689
|
]);
|
|
31406
31690
|
var ServerResultSchema = union([
|
|
@@ -31413,7 +31697,10 @@ var ServerResultSchema = union([
|
|
|
31413
31697
|
ListResourceTemplatesResultSchema,
|
|
31414
31698
|
ReadResourceResultSchema,
|
|
31415
31699
|
CallToolResultSchema,
|
|
31416
|
-
ListToolsResultSchema
|
|
31700
|
+
ListToolsResultSchema,
|
|
31701
|
+
GetTaskResultSchema,
|
|
31702
|
+
ListTasksResultSchema,
|
|
31703
|
+
CreateTaskResultSchema
|
|
31417
31704
|
]);
|
|
31418
31705
|
var McpError = class _McpError extends Error {
|
|
31419
31706
|
constructor(code, message, data) {
|
|
@@ -31447,8 +31734,13 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
31447
31734
|
}
|
|
31448
31735
|
};
|
|
31449
31736
|
|
|
31737
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
31738
|
+
function isTerminal(status) {
|
|
31739
|
+
return status === "completed" || status === "failed" || status === "cancelled";
|
|
31740
|
+
}
|
|
31741
|
+
|
|
31450
31742
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.0_zod@4.1.13/node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
31451
|
-
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
31743
|
+
var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
31452
31744
|
var defaultOptions = {
|
|
31453
31745
|
name: void 0,
|
|
31454
31746
|
$refStrategy: "root",
|
|
@@ -32731,7 +33023,7 @@ var zodToJsonSchema = (schema5, options) => {
|
|
|
32731
33023
|
return combined;
|
|
32732
33024
|
};
|
|
32733
33025
|
|
|
32734
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
33026
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
32735
33027
|
function mapMiniTarget(t) {
|
|
32736
33028
|
if (!t)
|
|
32737
33029
|
return "draft-7";
|
|
@@ -32774,7 +33066,7 @@ function parseWithCompat(schema5, data) {
|
|
|
32774
33066
|
return result.data;
|
|
32775
33067
|
}
|
|
32776
33068
|
|
|
32777
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
33069
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
32778
33070
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
|
|
32779
33071
|
var Protocol = class {
|
|
32780
33072
|
constructor(_options) {
|
|
@@ -32787,9 +33079,10 @@ var Protocol = class {
|
|
|
32787
33079
|
this._progressHandlers = /* @__PURE__ */ new Map();
|
|
32788
33080
|
this._timeoutInfo = /* @__PURE__ */ new Map();
|
|
32789
33081
|
this._pendingDebouncedNotifications = /* @__PURE__ */ new Set();
|
|
33082
|
+
this._taskProgressTokens = /* @__PURE__ */ new Map();
|
|
33083
|
+
this._requestResolvers = /* @__PURE__ */ new Map();
|
|
32790
33084
|
this.setNotificationHandler(CancelledNotificationSchema, (notification) => {
|
|
32791
|
-
|
|
32792
|
-
controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
|
|
33085
|
+
this._oncancel(notification);
|
|
32793
33086
|
});
|
|
32794
33087
|
this.setNotificationHandler(ProgressNotificationSchema, (notification) => {
|
|
32795
33088
|
this._onprogress(notification);
|
|
@@ -32799,6 +33092,116 @@ var Protocol = class {
|
|
|
32799
33092
|
// Automatic pong by default.
|
|
32800
33093
|
(_request) => ({})
|
|
32801
33094
|
);
|
|
33095
|
+
this._taskStore = _options === null || _options === void 0 ? void 0 : _options.taskStore;
|
|
33096
|
+
this._taskMessageQueue = _options === null || _options === void 0 ? void 0 : _options.taskMessageQueue;
|
|
33097
|
+
if (this._taskStore) {
|
|
33098
|
+
this.setRequestHandler(GetTaskRequestSchema, async (request2, extra) => {
|
|
33099
|
+
const task = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
33100
|
+
if (!task) {
|
|
33101
|
+
throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
|
|
33102
|
+
}
|
|
33103
|
+
return {
|
|
33104
|
+
...task
|
|
33105
|
+
};
|
|
33106
|
+
});
|
|
33107
|
+
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request2, extra) => {
|
|
33108
|
+
const handleTaskResult = async () => {
|
|
33109
|
+
var _a2;
|
|
33110
|
+
const taskId = request2.params.taskId;
|
|
33111
|
+
if (this._taskMessageQueue) {
|
|
33112
|
+
let queuedMessage;
|
|
33113
|
+
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
33114
|
+
if (queuedMessage.type === "response" || queuedMessage.type === "error") {
|
|
33115
|
+
const message = queuedMessage.message;
|
|
33116
|
+
const requestId = message.id;
|
|
33117
|
+
const resolver = this._requestResolvers.get(requestId);
|
|
33118
|
+
if (resolver) {
|
|
33119
|
+
this._requestResolvers.delete(requestId);
|
|
33120
|
+
if (queuedMessage.type === "response") {
|
|
33121
|
+
resolver(message);
|
|
33122
|
+
} else {
|
|
33123
|
+
const errorMessage = message;
|
|
33124
|
+
const error46 = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
|
|
33125
|
+
resolver(error46);
|
|
33126
|
+
}
|
|
33127
|
+
} else {
|
|
33128
|
+
const messageType = queuedMessage.type === "response" ? "Response" : "Error";
|
|
33129
|
+
this._onerror(new Error(`${messageType} handler missing for request ${requestId}`));
|
|
33130
|
+
}
|
|
33131
|
+
continue;
|
|
33132
|
+
}
|
|
33133
|
+
await ((_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send(queuedMessage.message, { relatedRequestId: extra.requestId }));
|
|
33134
|
+
}
|
|
33135
|
+
}
|
|
33136
|
+
const task = await this._taskStore.getTask(taskId, extra.sessionId);
|
|
33137
|
+
if (!task) {
|
|
33138
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
|
|
33139
|
+
}
|
|
33140
|
+
if (!isTerminal(task.status)) {
|
|
33141
|
+
await this._waitForTaskUpdate(taskId, extra.signal);
|
|
33142
|
+
return await handleTaskResult();
|
|
33143
|
+
}
|
|
33144
|
+
if (isTerminal(task.status)) {
|
|
33145
|
+
const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
|
|
33146
|
+
this._clearTaskQueue(taskId);
|
|
33147
|
+
return {
|
|
33148
|
+
...result,
|
|
33149
|
+
_meta: {
|
|
33150
|
+
...result._meta,
|
|
33151
|
+
[RELATED_TASK_META_KEY]: {
|
|
33152
|
+
taskId
|
|
33153
|
+
}
|
|
33154
|
+
}
|
|
33155
|
+
};
|
|
33156
|
+
}
|
|
33157
|
+
return await handleTaskResult();
|
|
33158
|
+
};
|
|
33159
|
+
return await handleTaskResult();
|
|
33160
|
+
});
|
|
33161
|
+
this.setRequestHandler(ListTasksRequestSchema, async (request2, extra) => {
|
|
33162
|
+
var _a2;
|
|
33163
|
+
try {
|
|
33164
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks((_a2 = request2.params) === null || _a2 === void 0 ? void 0 : _a2.cursor, extra.sessionId);
|
|
33165
|
+
return {
|
|
33166
|
+
tasks,
|
|
33167
|
+
nextCursor,
|
|
33168
|
+
_meta: {}
|
|
33169
|
+
};
|
|
33170
|
+
} catch (error46) {
|
|
33171
|
+
throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error46 instanceof Error ? error46.message : String(error46)}`);
|
|
33172
|
+
}
|
|
33173
|
+
});
|
|
33174
|
+
this.setRequestHandler(CancelTaskRequestSchema, async (request2, extra) => {
|
|
33175
|
+
try {
|
|
33176
|
+
const task = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
33177
|
+
if (!task) {
|
|
33178
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request2.params.taskId}`);
|
|
33179
|
+
}
|
|
33180
|
+
if (isTerminal(task.status)) {
|
|
33181
|
+
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
33182
|
+
}
|
|
33183
|
+
await this._taskStore.updateTaskStatus(request2.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
33184
|
+
this._clearTaskQueue(request2.params.taskId);
|
|
33185
|
+
const cancelledTask = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
33186
|
+
if (!cancelledTask) {
|
|
33187
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request2.params.taskId}`);
|
|
33188
|
+
}
|
|
33189
|
+
return {
|
|
33190
|
+
_meta: {},
|
|
33191
|
+
...cancelledTask
|
|
33192
|
+
};
|
|
33193
|
+
} catch (error46) {
|
|
33194
|
+
if (error46 instanceof McpError) {
|
|
33195
|
+
throw error46;
|
|
33196
|
+
}
|
|
33197
|
+
throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error46 instanceof Error ? error46.message : String(error46)}`);
|
|
33198
|
+
}
|
|
33199
|
+
});
|
|
33200
|
+
}
|
|
33201
|
+
}
|
|
33202
|
+
async _oncancel(notification) {
|
|
33203
|
+
const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
|
|
33204
|
+
controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
|
|
32802
33205
|
}
|
|
32803
33206
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
32804
33207
|
this._timeoutInfo.set(messageId, {
|
|
@@ -32871,10 +33274,11 @@ var Protocol = class {
|
|
|
32871
33274
|
const responseHandlers = this._responseHandlers;
|
|
32872
33275
|
this._responseHandlers = /* @__PURE__ */ new Map();
|
|
32873
33276
|
this._progressHandlers.clear();
|
|
33277
|
+
this._taskProgressTokens.clear();
|
|
32874
33278
|
this._pendingDebouncedNotifications.clear();
|
|
33279
|
+
const error46 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
32875
33280
|
this._transport = void 0;
|
|
32876
33281
|
(_a2 = this.onclose) === null || _a2 === void 0 ? void 0 : _a2.call(this);
|
|
32877
|
-
const error46 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
32878
33282
|
for (const handler2 of responseHandlers.values()) {
|
|
32879
33283
|
handler2(error46);
|
|
32880
33284
|
}
|
|
@@ -32892,47 +33296,94 @@ var Protocol = class {
|
|
|
32892
33296
|
Promise.resolve().then(() => handler2(notification)).catch((error46) => this._onerror(new Error(`Uncaught error in notification handler: ${error46}`)));
|
|
32893
33297
|
}
|
|
32894
33298
|
_onrequest(request2, extra) {
|
|
32895
|
-
var _a2, _b;
|
|
33299
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
32896
33300
|
const handler2 = (_a2 = this._requestHandlers.get(request2.method)) !== null && _a2 !== void 0 ? _a2 : this.fallbackRequestHandler;
|
|
32897
33301
|
const capturedTransport = this._transport;
|
|
33302
|
+
const relatedTaskId = (_d = (_c = (_b = request2.params) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c[RELATED_TASK_META_KEY]) === null || _d === void 0 ? void 0 : _d.taskId;
|
|
32898
33303
|
if (handler2 === void 0) {
|
|
32899
|
-
|
|
33304
|
+
const errorResponse = {
|
|
32900
33305
|
jsonrpc: "2.0",
|
|
32901
33306
|
id: request2.id,
|
|
32902
33307
|
error: {
|
|
32903
33308
|
code: ErrorCode.MethodNotFound,
|
|
32904
33309
|
message: "Method not found"
|
|
32905
33310
|
}
|
|
32906
|
-
}
|
|
33311
|
+
};
|
|
33312
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
33313
|
+
this._enqueueTaskMessage(relatedTaskId, {
|
|
33314
|
+
type: "error",
|
|
33315
|
+
message: errorResponse,
|
|
33316
|
+
timestamp: Date.now()
|
|
33317
|
+
}, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId).catch((error46) => this._onerror(new Error(`Failed to enqueue error response: ${error46}`)));
|
|
33318
|
+
} else {
|
|
33319
|
+
capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse).catch((error46) => this._onerror(new Error(`Failed to send an error response: ${error46}`)));
|
|
33320
|
+
}
|
|
32907
33321
|
return;
|
|
32908
33322
|
}
|
|
32909
33323
|
const abortController = new AbortController();
|
|
32910
33324
|
this._requestHandlerAbortControllers.set(request2.id, abortController);
|
|
33325
|
+
const taskCreationParams = (_e = request2.params) === null || _e === void 0 ? void 0 : _e.task;
|
|
33326
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request2, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId) : void 0;
|
|
32911
33327
|
const fullExtra = {
|
|
32912
33328
|
signal: abortController.signal,
|
|
32913
33329
|
sessionId: capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId,
|
|
32914
|
-
_meta: (
|
|
32915
|
-
sendNotification: (notification) =>
|
|
32916
|
-
|
|
33330
|
+
_meta: (_f = request2.params) === null || _f === void 0 ? void 0 : _f._meta,
|
|
33331
|
+
sendNotification: async (notification) => {
|
|
33332
|
+
const notificationOptions = { relatedRequestId: request2.id };
|
|
33333
|
+
if (relatedTaskId) {
|
|
33334
|
+
notificationOptions.relatedTask = { taskId: relatedTaskId };
|
|
33335
|
+
}
|
|
33336
|
+
await this.notification(notification, notificationOptions);
|
|
33337
|
+
},
|
|
33338
|
+
sendRequest: async (r, resultSchema, options) => {
|
|
33339
|
+
var _a3, _b2;
|
|
33340
|
+
const requestOptions = { ...options, relatedRequestId: request2.id };
|
|
33341
|
+
if (relatedTaskId && !requestOptions.relatedTask) {
|
|
33342
|
+
requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
33343
|
+
}
|
|
33344
|
+
const effectiveTaskId = (_b2 = (_a3 = requestOptions.relatedTask) === null || _a3 === void 0 ? void 0 : _a3.taskId) !== null && _b2 !== void 0 ? _b2 : relatedTaskId;
|
|
33345
|
+
if (effectiveTaskId && taskStore) {
|
|
33346
|
+
await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
|
|
33347
|
+
}
|
|
33348
|
+
return await this.request(r, resultSchema, requestOptions);
|
|
33349
|
+
},
|
|
32917
33350
|
authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
|
|
32918
33351
|
requestId: request2.id,
|
|
32919
|
-
requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo
|
|
33352
|
+
requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo,
|
|
33353
|
+
taskId: relatedTaskId,
|
|
33354
|
+
taskStore,
|
|
33355
|
+
taskRequestedTtl: taskCreationParams === null || taskCreationParams === void 0 ? void 0 : taskCreationParams.ttl,
|
|
33356
|
+
closeSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeSSEStream,
|
|
33357
|
+
closeStandaloneSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeStandaloneSSEStream
|
|
32920
33358
|
};
|
|
32921
|
-
Promise.resolve().then(() =>
|
|
33359
|
+
Promise.resolve().then(() => {
|
|
33360
|
+
if (taskCreationParams) {
|
|
33361
|
+
this.assertTaskHandlerCapability(request2.method);
|
|
33362
|
+
}
|
|
33363
|
+
}).then(() => handler2(request2, fullExtra)).then(async (result) => {
|
|
32922
33364
|
if (abortController.signal.aborted) {
|
|
32923
33365
|
return;
|
|
32924
33366
|
}
|
|
32925
|
-
|
|
33367
|
+
const response = {
|
|
32926
33368
|
result,
|
|
32927
33369
|
jsonrpc: "2.0",
|
|
32928
33370
|
id: request2.id
|
|
32929
|
-
}
|
|
32930
|
-
|
|
33371
|
+
};
|
|
33372
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
33373
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
33374
|
+
type: "response",
|
|
33375
|
+
message: response,
|
|
33376
|
+
timestamp: Date.now()
|
|
33377
|
+
}, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
|
|
33378
|
+
} else {
|
|
33379
|
+
await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(response));
|
|
33380
|
+
}
|
|
33381
|
+
}, async (error46) => {
|
|
32931
33382
|
var _a3;
|
|
32932
33383
|
if (abortController.signal.aborted) {
|
|
32933
33384
|
return;
|
|
32934
33385
|
}
|
|
32935
|
-
|
|
33386
|
+
const errorResponse = {
|
|
32936
33387
|
jsonrpc: "2.0",
|
|
32937
33388
|
id: request2.id,
|
|
32938
33389
|
error: {
|
|
@@ -32940,7 +33391,16 @@ var Protocol = class {
|
|
|
32940
33391
|
message: (_a3 = error46.message) !== null && _a3 !== void 0 ? _a3 : "Internal error",
|
|
32941
33392
|
...error46["data"] !== void 0 && { data: error46["data"] }
|
|
32942
33393
|
}
|
|
32943
|
-
}
|
|
33394
|
+
};
|
|
33395
|
+
if (relatedTaskId && this._taskMessageQueue) {
|
|
33396
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
33397
|
+
type: "error",
|
|
33398
|
+
message: errorResponse,
|
|
33399
|
+
timestamp: Date.now()
|
|
33400
|
+
}, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
|
|
33401
|
+
} else {
|
|
33402
|
+
await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse));
|
|
33403
|
+
}
|
|
32944
33404
|
}).catch((error46) => this._onerror(new Error(`Failed to send response: ${error46}`))).finally(() => {
|
|
32945
33405
|
this._requestHandlerAbortControllers.delete(request2.id);
|
|
32946
33406
|
});
|
|
@@ -32959,6 +33419,9 @@ var Protocol = class {
|
|
|
32959
33419
|
try {
|
|
32960
33420
|
this._resetTimeout(messageId);
|
|
32961
33421
|
} catch (error46) {
|
|
33422
|
+
this._responseHandlers.delete(messageId);
|
|
33423
|
+
this._progressHandlers.delete(messageId);
|
|
33424
|
+
this._cleanupTimeout(messageId);
|
|
32962
33425
|
responseHandler(error46);
|
|
32963
33426
|
return;
|
|
32964
33427
|
}
|
|
@@ -32967,14 +33430,38 @@ var Protocol = class {
|
|
|
32967
33430
|
}
|
|
32968
33431
|
_onresponse(response) {
|
|
32969
33432
|
const messageId = Number(response.id);
|
|
33433
|
+
const resolver = this._requestResolvers.get(messageId);
|
|
33434
|
+
if (resolver) {
|
|
33435
|
+
this._requestResolvers.delete(messageId);
|
|
33436
|
+
if (isJSONRPCResponse(response)) {
|
|
33437
|
+
resolver(response);
|
|
33438
|
+
} else {
|
|
33439
|
+
const error46 = new McpError(response.error.code, response.error.message, response.error.data);
|
|
33440
|
+
resolver(error46);
|
|
33441
|
+
}
|
|
33442
|
+
return;
|
|
33443
|
+
}
|
|
32970
33444
|
const handler2 = this._responseHandlers.get(messageId);
|
|
32971
33445
|
if (handler2 === void 0) {
|
|
32972
33446
|
this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(response)}`));
|
|
32973
33447
|
return;
|
|
32974
33448
|
}
|
|
32975
33449
|
this._responseHandlers.delete(messageId);
|
|
32976
|
-
this._progressHandlers.delete(messageId);
|
|
32977
33450
|
this._cleanupTimeout(messageId);
|
|
33451
|
+
let isTaskResponse = false;
|
|
33452
|
+
if (isJSONRPCResponse(response) && response.result && typeof response.result === "object") {
|
|
33453
|
+
const result = response.result;
|
|
33454
|
+
if (result.task && typeof result.task === "object") {
|
|
33455
|
+
const task = result.task;
|
|
33456
|
+
if (typeof task.taskId === "string") {
|
|
33457
|
+
isTaskResponse = true;
|
|
33458
|
+
this._taskProgressTokens.set(task.taskId, messageId);
|
|
33459
|
+
}
|
|
33460
|
+
}
|
|
33461
|
+
}
|
|
33462
|
+
if (!isTaskResponse) {
|
|
33463
|
+
this._progressHandlers.delete(messageId);
|
|
33464
|
+
}
|
|
32978
33465
|
if (isJSONRPCResponse(response)) {
|
|
32979
33466
|
handler2(response);
|
|
32980
33467
|
} else {
|
|
@@ -32993,22 +33480,120 @@ var Protocol = class {
|
|
|
32993
33480
|
await ((_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.close());
|
|
32994
33481
|
}
|
|
32995
33482
|
/**
|
|
32996
|
-
* Sends a request and
|
|
33483
|
+
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
33484
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
33485
|
+
*
|
|
33486
|
+
* @example
|
|
33487
|
+
* ```typescript
|
|
33488
|
+
* const stream = protocol.requestStream(request, resultSchema, options);
|
|
33489
|
+
* for await (const message of stream) {
|
|
33490
|
+
* switch (message.type) {
|
|
33491
|
+
* case 'taskCreated':
|
|
33492
|
+
* console.log('Task created:', message.task.taskId);
|
|
33493
|
+
* break;
|
|
33494
|
+
* case 'taskStatus':
|
|
33495
|
+
* console.log('Task status:', message.task.status);
|
|
33496
|
+
* break;
|
|
33497
|
+
* case 'result':
|
|
33498
|
+
* console.log('Final result:', message.result);
|
|
33499
|
+
* break;
|
|
33500
|
+
* case 'error':
|
|
33501
|
+
* console.error('Error:', message.error);
|
|
33502
|
+
* break;
|
|
33503
|
+
* }
|
|
33504
|
+
* }
|
|
33505
|
+
* ```
|
|
33506
|
+
*
|
|
33507
|
+
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
|
|
33508
|
+
*/
|
|
33509
|
+
async *requestStream(request2, resultSchema, options) {
|
|
33510
|
+
var _a2, _b, _c, _d;
|
|
33511
|
+
const { task } = options !== null && options !== void 0 ? options : {};
|
|
33512
|
+
if (!task) {
|
|
33513
|
+
try {
|
|
33514
|
+
const result = await this.request(request2, resultSchema, options);
|
|
33515
|
+
yield { type: "result", result };
|
|
33516
|
+
} catch (error46) {
|
|
33517
|
+
yield {
|
|
33518
|
+
type: "error",
|
|
33519
|
+
error: error46 instanceof McpError ? error46 : new McpError(ErrorCode.InternalError, String(error46))
|
|
33520
|
+
};
|
|
33521
|
+
}
|
|
33522
|
+
return;
|
|
33523
|
+
}
|
|
33524
|
+
let taskId;
|
|
33525
|
+
try {
|
|
33526
|
+
const createResult = await this.request(request2, CreateTaskResultSchema, options);
|
|
33527
|
+
if (createResult.task) {
|
|
33528
|
+
taskId = createResult.task.taskId;
|
|
33529
|
+
yield { type: "taskCreated", task: createResult.task };
|
|
33530
|
+
} else {
|
|
33531
|
+
throw new McpError(ErrorCode.InternalError, "Task creation did not return a task");
|
|
33532
|
+
}
|
|
33533
|
+
while (true) {
|
|
33534
|
+
const task2 = await this.getTask({ taskId }, options);
|
|
33535
|
+
yield { type: "taskStatus", task: task2 };
|
|
33536
|
+
if (isTerminal(task2.status)) {
|
|
33537
|
+
if (task2.status === "completed") {
|
|
33538
|
+
const result = await this.getTaskResult({ taskId }, resultSchema, options);
|
|
33539
|
+
yield { type: "result", result };
|
|
33540
|
+
} else if (task2.status === "failed") {
|
|
33541
|
+
yield {
|
|
33542
|
+
type: "error",
|
|
33543
|
+
error: new McpError(ErrorCode.InternalError, `Task ${taskId} failed`)
|
|
33544
|
+
};
|
|
33545
|
+
} else if (task2.status === "cancelled") {
|
|
33546
|
+
yield {
|
|
33547
|
+
type: "error",
|
|
33548
|
+
error: new McpError(ErrorCode.InternalError, `Task ${taskId} was cancelled`)
|
|
33549
|
+
};
|
|
33550
|
+
}
|
|
33551
|
+
return;
|
|
33552
|
+
}
|
|
33553
|
+
if (task2.status === "input_required") {
|
|
33554
|
+
const result = await this.getTaskResult({ taskId }, resultSchema, options);
|
|
33555
|
+
yield { type: "result", result };
|
|
33556
|
+
return;
|
|
33557
|
+
}
|
|
33558
|
+
const pollInterval = (_c = (_a2 = task2.pollInterval) !== null && _a2 !== void 0 ? _a2 : (_b = this._options) === null || _b === void 0 ? void 0 : _b.defaultTaskPollInterval) !== null && _c !== void 0 ? _c : 1e3;
|
|
33559
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
33560
|
+
(_d = options === null || options === void 0 ? void 0 : options.signal) === null || _d === void 0 ? void 0 : _d.throwIfAborted();
|
|
33561
|
+
}
|
|
33562
|
+
} catch (error46) {
|
|
33563
|
+
yield {
|
|
33564
|
+
type: "error",
|
|
33565
|
+
error: error46 instanceof McpError ? error46 : new McpError(ErrorCode.InternalError, String(error46))
|
|
33566
|
+
};
|
|
33567
|
+
}
|
|
33568
|
+
}
|
|
33569
|
+
/**
|
|
33570
|
+
* Sends a request and waits for a response.
|
|
32997
33571
|
*
|
|
32998
33572
|
* Do not use this method to emit notifications! Use notification() instead.
|
|
32999
33573
|
*/
|
|
33000
33574
|
request(request2, resultSchema, options) {
|
|
33001
|
-
const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== void 0 ? options : {};
|
|
33575
|
+
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options !== null && options !== void 0 ? options : {};
|
|
33002
33576
|
return new Promise((resolve2, reject) => {
|
|
33003
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
33577
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
33578
|
+
const earlyReject = (error46) => {
|
|
33579
|
+
reject(error46);
|
|
33580
|
+
};
|
|
33004
33581
|
if (!this._transport) {
|
|
33005
|
-
|
|
33582
|
+
earlyReject(new Error("Not connected"));
|
|
33006
33583
|
return;
|
|
33007
33584
|
}
|
|
33008
33585
|
if (((_a2 = this._options) === null || _a2 === void 0 ? void 0 : _a2.enforceStrictCapabilities) === true) {
|
|
33009
|
-
|
|
33010
|
-
|
|
33011
|
-
|
|
33586
|
+
try {
|
|
33587
|
+
this.assertCapabilityForMethod(request2.method);
|
|
33588
|
+
if (task) {
|
|
33589
|
+
this.assertTaskCapability(request2.method);
|
|
33590
|
+
}
|
|
33591
|
+
} catch (e) {
|
|
33592
|
+
earlyReject(e);
|
|
33593
|
+
return;
|
|
33594
|
+
}
|
|
33595
|
+
}
|
|
33596
|
+
(_b = options === null || options === void 0 ? void 0 : options.signal) === null || _b === void 0 ? void 0 : _b.throwIfAborted();
|
|
33012
33597
|
const messageId = this._requestMessageId++;
|
|
33013
33598
|
const jsonrpcRequest = {
|
|
33014
33599
|
...request2,
|
|
@@ -33025,6 +33610,21 @@ var Protocol = class {
|
|
|
33025
33610
|
}
|
|
33026
33611
|
};
|
|
33027
33612
|
}
|
|
33613
|
+
if (task) {
|
|
33614
|
+
jsonrpcRequest.params = {
|
|
33615
|
+
...jsonrpcRequest.params,
|
|
33616
|
+
task
|
|
33617
|
+
};
|
|
33618
|
+
}
|
|
33619
|
+
if (relatedTask) {
|
|
33620
|
+
jsonrpcRequest.params = {
|
|
33621
|
+
...jsonrpcRequest.params,
|
|
33622
|
+
_meta: {
|
|
33623
|
+
...((_d = jsonrpcRequest.params) === null || _d === void 0 ? void 0 : _d._meta) || {},
|
|
33624
|
+
[RELATED_TASK_META_KEY]: relatedTask
|
|
33625
|
+
}
|
|
33626
|
+
};
|
|
33627
|
+
}
|
|
33028
33628
|
const cancel = (reason) => {
|
|
33029
33629
|
var _a3;
|
|
33030
33630
|
this._responseHandlers.delete(messageId);
|
|
@@ -33037,8 +33637,9 @@ var Protocol = class {
|
|
|
33037
33637
|
requestId: messageId,
|
|
33038
33638
|
reason: String(reason)
|
|
33039
33639
|
}
|
|
33040
|
-
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((
|
|
33041
|
-
|
|
33640
|
+
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error47) => this._onerror(new Error(`Failed to send cancellation: ${error47}`)));
|
|
33641
|
+
const error46 = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
|
|
33642
|
+
reject(error46);
|
|
33042
33643
|
};
|
|
33043
33644
|
this._responseHandlers.set(messageId, (response) => {
|
|
33044
33645
|
var _a3;
|
|
@@ -33059,53 +33660,150 @@ var Protocol = class {
|
|
|
33059
33660
|
reject(error46);
|
|
33060
33661
|
}
|
|
33061
33662
|
});
|
|
33062
|
-
(
|
|
33663
|
+
(_e = options === null || options === void 0 ? void 0 : options.signal) === null || _e === void 0 ? void 0 : _e.addEventListener("abort", () => {
|
|
33063
33664
|
var _a3;
|
|
33064
33665
|
cancel((_a3 = options === null || options === void 0 ? void 0 : options.signal) === null || _a3 === void 0 ? void 0 : _a3.reason);
|
|
33065
33666
|
});
|
|
33066
|
-
const timeout = (
|
|
33667
|
+
const timeout = (_f = options === null || options === void 0 ? void 0 : options.timeout) !== null && _f !== void 0 ? _f : DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
33067
33668
|
const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
33068
|
-
this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (
|
|
33069
|
-
|
|
33070
|
-
|
|
33071
|
-
|
|
33072
|
-
|
|
33669
|
+
this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (_g = options === null || options === void 0 ? void 0 : options.resetTimeoutOnProgress) !== null && _g !== void 0 ? _g : false);
|
|
33670
|
+
const relatedTaskId = relatedTask === null || relatedTask === void 0 ? void 0 : relatedTask.taskId;
|
|
33671
|
+
if (relatedTaskId) {
|
|
33672
|
+
const responseResolver = (response) => {
|
|
33673
|
+
const handler2 = this._responseHandlers.get(messageId);
|
|
33674
|
+
if (handler2) {
|
|
33675
|
+
handler2(response);
|
|
33676
|
+
} else {
|
|
33677
|
+
this._onerror(new Error(`Response handler missing for side-channeled request ${messageId}`));
|
|
33678
|
+
}
|
|
33679
|
+
};
|
|
33680
|
+
this._requestResolvers.set(messageId, responseResolver);
|
|
33681
|
+
this._enqueueTaskMessage(relatedTaskId, {
|
|
33682
|
+
type: "request",
|
|
33683
|
+
message: jsonrpcRequest,
|
|
33684
|
+
timestamp: Date.now()
|
|
33685
|
+
}).catch((error46) => {
|
|
33686
|
+
this._cleanupTimeout(messageId);
|
|
33687
|
+
reject(error46);
|
|
33688
|
+
});
|
|
33689
|
+
} else {
|
|
33690
|
+
this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error46) => {
|
|
33691
|
+
this._cleanupTimeout(messageId);
|
|
33692
|
+
reject(error46);
|
|
33693
|
+
});
|
|
33694
|
+
}
|
|
33073
33695
|
});
|
|
33074
33696
|
}
|
|
33697
|
+
/**
|
|
33698
|
+
* Gets the current status of a task.
|
|
33699
|
+
*
|
|
33700
|
+
* @experimental Use `client.experimental.tasks.getTask()` to access this method.
|
|
33701
|
+
*/
|
|
33702
|
+
async getTask(params, options) {
|
|
33703
|
+
return this.request({ method: "tasks/get", params }, GetTaskResultSchema, options);
|
|
33704
|
+
}
|
|
33705
|
+
/**
|
|
33706
|
+
* Retrieves the result of a completed task.
|
|
33707
|
+
*
|
|
33708
|
+
* @experimental Use `client.experimental.tasks.getTaskResult()` to access this method.
|
|
33709
|
+
*/
|
|
33710
|
+
async getTaskResult(params, resultSchema, options) {
|
|
33711
|
+
return this.request({ method: "tasks/result", params }, resultSchema, options);
|
|
33712
|
+
}
|
|
33713
|
+
/**
|
|
33714
|
+
* Lists tasks, optionally starting from a pagination cursor.
|
|
33715
|
+
*
|
|
33716
|
+
* @experimental Use `client.experimental.tasks.listTasks()` to access this method.
|
|
33717
|
+
*/
|
|
33718
|
+
async listTasks(params, options) {
|
|
33719
|
+
return this.request({ method: "tasks/list", params }, ListTasksResultSchema, options);
|
|
33720
|
+
}
|
|
33721
|
+
/**
|
|
33722
|
+
* Cancels a specific task.
|
|
33723
|
+
*
|
|
33724
|
+
* @experimental Use `client.experimental.tasks.cancelTask()` to access this method.
|
|
33725
|
+
*/
|
|
33726
|
+
async cancelTask(params, options) {
|
|
33727
|
+
return this.request({ method: "tasks/cancel", params }, CancelTaskResultSchema, options);
|
|
33728
|
+
}
|
|
33075
33729
|
/**
|
|
33076
33730
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
33077
33731
|
*/
|
|
33078
33732
|
async notification(notification, options) {
|
|
33079
|
-
var _a2, _b;
|
|
33733
|
+
var _a2, _b, _c, _d, _e;
|
|
33080
33734
|
if (!this._transport) {
|
|
33081
33735
|
throw new Error("Not connected");
|
|
33082
33736
|
}
|
|
33083
33737
|
this.assertNotificationCapability(notification.method);
|
|
33084
|
-
const
|
|
33085
|
-
|
|
33738
|
+
const relatedTaskId = (_a2 = options === null || options === void 0 ? void 0 : options.relatedTask) === null || _a2 === void 0 ? void 0 : _a2.taskId;
|
|
33739
|
+
if (relatedTaskId) {
|
|
33740
|
+
const jsonrpcNotification2 = {
|
|
33741
|
+
...notification,
|
|
33742
|
+
jsonrpc: "2.0",
|
|
33743
|
+
params: {
|
|
33744
|
+
...notification.params,
|
|
33745
|
+
_meta: {
|
|
33746
|
+
...((_b = notification.params) === null || _b === void 0 ? void 0 : _b._meta) || {},
|
|
33747
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
33748
|
+
}
|
|
33749
|
+
}
|
|
33750
|
+
};
|
|
33751
|
+
await this._enqueueTaskMessage(relatedTaskId, {
|
|
33752
|
+
type: "notification",
|
|
33753
|
+
message: jsonrpcNotification2,
|
|
33754
|
+
timestamp: Date.now()
|
|
33755
|
+
});
|
|
33756
|
+
return;
|
|
33757
|
+
}
|
|
33758
|
+
const debouncedMethods = (_d = (_c = this._options) === null || _c === void 0 ? void 0 : _c.debouncedNotificationMethods) !== null && _d !== void 0 ? _d : [];
|
|
33759
|
+
const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !(options === null || options === void 0 ? void 0 : options.relatedRequestId) && !(options === null || options === void 0 ? void 0 : options.relatedTask);
|
|
33086
33760
|
if (canDebounce) {
|
|
33087
33761
|
if (this._pendingDebouncedNotifications.has(notification.method)) {
|
|
33088
33762
|
return;
|
|
33089
33763
|
}
|
|
33090
33764
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
33091
33765
|
Promise.resolve().then(() => {
|
|
33092
|
-
var _a3;
|
|
33766
|
+
var _a3, _b2;
|
|
33093
33767
|
this._pendingDebouncedNotifications.delete(notification.method);
|
|
33094
33768
|
if (!this._transport) {
|
|
33095
33769
|
return;
|
|
33096
33770
|
}
|
|
33097
|
-
|
|
33771
|
+
let jsonrpcNotification2 = {
|
|
33098
33772
|
...notification,
|
|
33099
33773
|
jsonrpc: "2.0"
|
|
33100
33774
|
};
|
|
33101
|
-
(
|
|
33775
|
+
if (options === null || options === void 0 ? void 0 : options.relatedTask) {
|
|
33776
|
+
jsonrpcNotification2 = {
|
|
33777
|
+
...jsonrpcNotification2,
|
|
33778
|
+
params: {
|
|
33779
|
+
...jsonrpcNotification2.params,
|
|
33780
|
+
_meta: {
|
|
33781
|
+
...((_a3 = jsonrpcNotification2.params) === null || _a3 === void 0 ? void 0 : _a3._meta) || {},
|
|
33782
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
33783
|
+
}
|
|
33784
|
+
}
|
|
33785
|
+
};
|
|
33786
|
+
}
|
|
33787
|
+
(_b2 = this._transport) === null || _b2 === void 0 ? void 0 : _b2.send(jsonrpcNotification2, options).catch((error46) => this._onerror(error46));
|
|
33102
33788
|
});
|
|
33103
33789
|
return;
|
|
33104
33790
|
}
|
|
33105
|
-
|
|
33791
|
+
let jsonrpcNotification = {
|
|
33106
33792
|
...notification,
|
|
33107
33793
|
jsonrpc: "2.0"
|
|
33108
33794
|
};
|
|
33795
|
+
if (options === null || options === void 0 ? void 0 : options.relatedTask) {
|
|
33796
|
+
jsonrpcNotification = {
|
|
33797
|
+
...jsonrpcNotification,
|
|
33798
|
+
params: {
|
|
33799
|
+
...jsonrpcNotification.params,
|
|
33800
|
+
_meta: {
|
|
33801
|
+
...((_e = jsonrpcNotification.params) === null || _e === void 0 ? void 0 : _e._meta) || {},
|
|
33802
|
+
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
33803
|
+
}
|
|
33804
|
+
}
|
|
33805
|
+
};
|
|
33806
|
+
}
|
|
33109
33807
|
await this._transport.send(jsonrpcNotification, options);
|
|
33110
33808
|
}
|
|
33111
33809
|
/**
|
|
@@ -33153,6 +33851,152 @@ var Protocol = class {
|
|
|
33153
33851
|
removeNotificationHandler(method) {
|
|
33154
33852
|
this._notificationHandlers.delete(method);
|
|
33155
33853
|
}
|
|
33854
|
+
/**
|
|
33855
|
+
* Cleans up the progress handler associated with a task.
|
|
33856
|
+
* This should be called when a task reaches a terminal status.
|
|
33857
|
+
*/
|
|
33858
|
+
_cleanupTaskProgressHandler(taskId) {
|
|
33859
|
+
const progressToken = this._taskProgressTokens.get(taskId);
|
|
33860
|
+
if (progressToken !== void 0) {
|
|
33861
|
+
this._progressHandlers.delete(progressToken);
|
|
33862
|
+
this._taskProgressTokens.delete(taskId);
|
|
33863
|
+
}
|
|
33864
|
+
}
|
|
33865
|
+
/**
|
|
33866
|
+
* Enqueues a task-related message for side-channel delivery via tasks/result.
|
|
33867
|
+
* @param taskId The task ID to associate the message with
|
|
33868
|
+
* @param message The message to enqueue
|
|
33869
|
+
* @param sessionId Optional session ID for binding the operation to a specific session
|
|
33870
|
+
* @throws Error if taskStore is not configured or if enqueue fails (e.g., queue overflow)
|
|
33871
|
+
*
|
|
33872
|
+
* Note: If enqueue fails, it's the TaskMessageQueue implementation's responsibility to handle
|
|
33873
|
+
* the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
|
|
33874
|
+
* simply propagates the error.
|
|
33875
|
+
*/
|
|
33876
|
+
async _enqueueTaskMessage(taskId, message, sessionId) {
|
|
33877
|
+
var _a2;
|
|
33878
|
+
if (!this._taskStore || !this._taskMessageQueue) {
|
|
33879
|
+
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
33880
|
+
}
|
|
33881
|
+
const maxQueueSize = (_a2 = this._options) === null || _a2 === void 0 ? void 0 : _a2.maxTaskQueueSize;
|
|
33882
|
+
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
33883
|
+
}
|
|
33884
|
+
/**
|
|
33885
|
+
* Clears the message queue for a task and rejects any pending request resolvers.
|
|
33886
|
+
* @param taskId The task ID whose queue should be cleared
|
|
33887
|
+
* @param sessionId Optional session ID for binding the operation to a specific session
|
|
33888
|
+
*/
|
|
33889
|
+
async _clearTaskQueue(taskId, sessionId) {
|
|
33890
|
+
if (this._taskMessageQueue) {
|
|
33891
|
+
const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId);
|
|
33892
|
+
for (const message of messages) {
|
|
33893
|
+
if (message.type === "request" && isJSONRPCRequest(message.message)) {
|
|
33894
|
+
const requestId = message.message.id;
|
|
33895
|
+
const resolver = this._requestResolvers.get(requestId);
|
|
33896
|
+
if (resolver) {
|
|
33897
|
+
resolver(new McpError(ErrorCode.InternalError, "Task cancelled or completed"));
|
|
33898
|
+
this._requestResolvers.delete(requestId);
|
|
33899
|
+
} else {
|
|
33900
|
+
this._onerror(new Error(`Resolver missing for request ${requestId} during task ${taskId} cleanup`));
|
|
33901
|
+
}
|
|
33902
|
+
}
|
|
33903
|
+
}
|
|
33904
|
+
}
|
|
33905
|
+
}
|
|
33906
|
+
/**
|
|
33907
|
+
* Waits for a task update (new messages or status change) with abort signal support.
|
|
33908
|
+
* Uses polling to check for updates at the task's configured poll interval.
|
|
33909
|
+
* @param taskId The task ID to wait for
|
|
33910
|
+
* @param signal Abort signal to cancel the wait
|
|
33911
|
+
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
33912
|
+
*/
|
|
33913
|
+
async _waitForTaskUpdate(taskId, signal) {
|
|
33914
|
+
var _a2, _b, _c;
|
|
33915
|
+
let interval = (_b = (_a2 = this._options) === null || _a2 === void 0 ? void 0 : _a2.defaultTaskPollInterval) !== null && _b !== void 0 ? _b : 1e3;
|
|
33916
|
+
try {
|
|
33917
|
+
const task = await ((_c = this._taskStore) === null || _c === void 0 ? void 0 : _c.getTask(taskId));
|
|
33918
|
+
if (task === null || task === void 0 ? void 0 : task.pollInterval) {
|
|
33919
|
+
interval = task.pollInterval;
|
|
33920
|
+
}
|
|
33921
|
+
} catch (_d) {
|
|
33922
|
+
}
|
|
33923
|
+
return new Promise((resolve2, reject) => {
|
|
33924
|
+
if (signal.aborted) {
|
|
33925
|
+
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
33926
|
+
return;
|
|
33927
|
+
}
|
|
33928
|
+
const timeoutId = setTimeout(resolve2, interval);
|
|
33929
|
+
signal.addEventListener("abort", () => {
|
|
33930
|
+
clearTimeout(timeoutId);
|
|
33931
|
+
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
33932
|
+
}, { once: true });
|
|
33933
|
+
});
|
|
33934
|
+
}
|
|
33935
|
+
requestTaskStore(request2, sessionId) {
|
|
33936
|
+
const taskStore = this._taskStore;
|
|
33937
|
+
if (!taskStore) {
|
|
33938
|
+
throw new Error("No task store configured");
|
|
33939
|
+
}
|
|
33940
|
+
return {
|
|
33941
|
+
createTask: async (taskParams) => {
|
|
33942
|
+
if (!request2) {
|
|
33943
|
+
throw new Error("No request provided");
|
|
33944
|
+
}
|
|
33945
|
+
return await taskStore.createTask(taskParams, request2.id, {
|
|
33946
|
+
method: request2.method,
|
|
33947
|
+
params: request2.params
|
|
33948
|
+
}, sessionId);
|
|
33949
|
+
},
|
|
33950
|
+
getTask: async (taskId) => {
|
|
33951
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
33952
|
+
if (!task) {
|
|
33953
|
+
throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
|
|
33954
|
+
}
|
|
33955
|
+
return task;
|
|
33956
|
+
},
|
|
33957
|
+
storeTaskResult: async (taskId, status, result) => {
|
|
33958
|
+
await taskStore.storeTaskResult(taskId, status, result, sessionId);
|
|
33959
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
33960
|
+
if (task) {
|
|
33961
|
+
const notification = TaskStatusNotificationSchema.parse({
|
|
33962
|
+
method: "notifications/tasks/status",
|
|
33963
|
+
params: task
|
|
33964
|
+
});
|
|
33965
|
+
await this.notification(notification);
|
|
33966
|
+
if (isTerminal(task.status)) {
|
|
33967
|
+
this._cleanupTaskProgressHandler(taskId);
|
|
33968
|
+
}
|
|
33969
|
+
}
|
|
33970
|
+
},
|
|
33971
|
+
getTaskResult: (taskId) => {
|
|
33972
|
+
return taskStore.getTaskResult(taskId, sessionId);
|
|
33973
|
+
},
|
|
33974
|
+
updateTaskStatus: async (taskId, status, statusMessage) => {
|
|
33975
|
+
const task = await taskStore.getTask(taskId, sessionId);
|
|
33976
|
+
if (!task) {
|
|
33977
|
+
throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
|
|
33978
|
+
}
|
|
33979
|
+
if (isTerminal(task.status)) {
|
|
33980
|
+
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.`);
|
|
33981
|
+
}
|
|
33982
|
+
await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId);
|
|
33983
|
+
const updatedTask = await taskStore.getTask(taskId, sessionId);
|
|
33984
|
+
if (updatedTask) {
|
|
33985
|
+
const notification = TaskStatusNotificationSchema.parse({
|
|
33986
|
+
method: "notifications/tasks/status",
|
|
33987
|
+
params: updatedTask
|
|
33988
|
+
});
|
|
33989
|
+
await this.notification(notification);
|
|
33990
|
+
if (isTerminal(updatedTask.status)) {
|
|
33991
|
+
this._cleanupTaskProgressHandler(taskId);
|
|
33992
|
+
}
|
|
33993
|
+
}
|
|
33994
|
+
},
|
|
33995
|
+
listTasks: (cursor) => {
|
|
33996
|
+
return taskStore.listTasks(cursor, sessionId);
|
|
33997
|
+
}
|
|
33998
|
+
};
|
|
33999
|
+
}
|
|
33156
34000
|
};
|
|
33157
34001
|
function isPlainObject4(value) {
|
|
33158
34002
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -33174,7 +34018,7 @@ function mergeCapabilities(base, additional) {
|
|
|
33174
34018
|
return result;
|
|
33175
34019
|
}
|
|
33176
34020
|
|
|
33177
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
34021
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
|
|
33178
34022
|
var import_ajv = __toESM(require_ajv(), 1);
|
|
33179
34023
|
var import_ajv_formats = __toESM(require_dist(), 1);
|
|
33180
34024
|
function createDefaultAjvInstance() {
|
|
@@ -33243,7 +34087,116 @@ var AjvJsonSchemaValidator = class {
|
|
|
33243
34087
|
}
|
|
33244
34088
|
};
|
|
33245
34089
|
|
|
33246
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
34090
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
34091
|
+
var ExperimentalServerTasks = class {
|
|
34092
|
+
constructor(_server) {
|
|
34093
|
+
this._server = _server;
|
|
34094
|
+
}
|
|
34095
|
+
/**
|
|
34096
|
+
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
34097
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
34098
|
+
*
|
|
34099
|
+
* This method provides streaming access to request processing, allowing you to
|
|
34100
|
+
* observe intermediate task status updates for task-augmented requests.
|
|
34101
|
+
*
|
|
34102
|
+
* @param request - The request to send
|
|
34103
|
+
* @param resultSchema - Zod schema for validating the result
|
|
34104
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
34105
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
34106
|
+
*
|
|
34107
|
+
* @experimental
|
|
34108
|
+
*/
|
|
34109
|
+
requestStream(request2, resultSchema, options) {
|
|
34110
|
+
return this._server.requestStream(request2, resultSchema, options);
|
|
34111
|
+
}
|
|
34112
|
+
/**
|
|
34113
|
+
* Gets the current status of a task.
|
|
34114
|
+
*
|
|
34115
|
+
* @param taskId - The task identifier
|
|
34116
|
+
* @param options - Optional request options
|
|
34117
|
+
* @returns The task status
|
|
34118
|
+
*
|
|
34119
|
+
* @experimental
|
|
34120
|
+
*/
|
|
34121
|
+
async getTask(taskId, options) {
|
|
34122
|
+
return this._server.getTask({ taskId }, options);
|
|
34123
|
+
}
|
|
34124
|
+
/**
|
|
34125
|
+
* Retrieves the result of a completed task.
|
|
34126
|
+
*
|
|
34127
|
+
* @param taskId - The task identifier
|
|
34128
|
+
* @param resultSchema - Zod schema for validating the result
|
|
34129
|
+
* @param options - Optional request options
|
|
34130
|
+
* @returns The task result
|
|
34131
|
+
*
|
|
34132
|
+
* @experimental
|
|
34133
|
+
*/
|
|
34134
|
+
async getTaskResult(taskId, resultSchema, options) {
|
|
34135
|
+
return this._server.getTaskResult({ taskId }, resultSchema, options);
|
|
34136
|
+
}
|
|
34137
|
+
/**
|
|
34138
|
+
* Lists tasks with optional pagination.
|
|
34139
|
+
*
|
|
34140
|
+
* @param cursor - Optional pagination cursor
|
|
34141
|
+
* @param options - Optional request options
|
|
34142
|
+
* @returns List of tasks with optional next cursor
|
|
34143
|
+
*
|
|
34144
|
+
* @experimental
|
|
34145
|
+
*/
|
|
34146
|
+
async listTasks(cursor, options) {
|
|
34147
|
+
return this._server.listTasks(cursor ? { cursor } : void 0, options);
|
|
34148
|
+
}
|
|
34149
|
+
/**
|
|
34150
|
+
* Cancels a running task.
|
|
34151
|
+
*
|
|
34152
|
+
* @param taskId - The task identifier
|
|
34153
|
+
* @param options - Optional request options
|
|
34154
|
+
*
|
|
34155
|
+
* @experimental
|
|
34156
|
+
*/
|
|
34157
|
+
async cancelTask(taskId, options) {
|
|
34158
|
+
return this._server.cancelTask({ taskId }, options);
|
|
34159
|
+
}
|
|
34160
|
+
};
|
|
34161
|
+
|
|
34162
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
34163
|
+
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
34164
|
+
var _a2;
|
|
34165
|
+
if (!requests) {
|
|
34166
|
+
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
34167
|
+
}
|
|
34168
|
+
switch (method) {
|
|
34169
|
+
case "tools/call":
|
|
34170
|
+
if (!((_a2 = requests.tools) === null || _a2 === void 0 ? void 0 : _a2.call)) {
|
|
34171
|
+
throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
|
|
34172
|
+
}
|
|
34173
|
+
break;
|
|
34174
|
+
default:
|
|
34175
|
+
break;
|
|
34176
|
+
}
|
|
34177
|
+
}
|
|
34178
|
+
function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
34179
|
+
var _a2, _b;
|
|
34180
|
+
if (!requests) {
|
|
34181
|
+
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
34182
|
+
}
|
|
34183
|
+
switch (method) {
|
|
34184
|
+
case "sampling/createMessage":
|
|
34185
|
+
if (!((_a2 = requests.sampling) === null || _a2 === void 0 ? void 0 : _a2.createMessage)) {
|
|
34186
|
+
throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
|
|
34187
|
+
}
|
|
34188
|
+
break;
|
|
34189
|
+
case "elicitation/create":
|
|
34190
|
+
if (!((_b = requests.elicitation) === null || _b === void 0 ? void 0 : _b.create)) {
|
|
34191
|
+
throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
|
|
34192
|
+
}
|
|
34193
|
+
break;
|
|
34194
|
+
default:
|
|
34195
|
+
break;
|
|
34196
|
+
}
|
|
34197
|
+
}
|
|
34198
|
+
|
|
34199
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
33247
34200
|
var Server = class extends Protocol {
|
|
33248
34201
|
/**
|
|
33249
34202
|
* Initializes this server with the given name and version information.
|
|
@@ -33279,6 +34232,21 @@ var Server = class extends Protocol {
|
|
|
33279
34232
|
});
|
|
33280
34233
|
}
|
|
33281
34234
|
}
|
|
34235
|
+
/**
|
|
34236
|
+
* Access experimental features.
|
|
34237
|
+
*
|
|
34238
|
+
* WARNING: These APIs are experimental and may change without notice.
|
|
34239
|
+
*
|
|
34240
|
+
* @experimental
|
|
34241
|
+
*/
|
|
34242
|
+
get experimental() {
|
|
34243
|
+
if (!this._experimental) {
|
|
34244
|
+
this._experimental = {
|
|
34245
|
+
tasks: new ExperimentalServerTasks(this)
|
|
34246
|
+
};
|
|
34247
|
+
}
|
|
34248
|
+
return this._experimental;
|
|
34249
|
+
}
|
|
33282
34250
|
/**
|
|
33283
34251
|
* Registers new capabilities. This can only be called before connecting to a transport.
|
|
33284
34252
|
*
|
|
@@ -33290,6 +34258,58 @@ var Server = class extends Protocol {
|
|
|
33290
34258
|
}
|
|
33291
34259
|
this._capabilities = mergeCapabilities(this._capabilities, capabilities);
|
|
33292
34260
|
}
|
|
34261
|
+
/**
|
|
34262
|
+
* Override request handler registration to enforce server-side validation for tools/call.
|
|
34263
|
+
*/
|
|
34264
|
+
setRequestHandler(requestSchema, handler2) {
|
|
34265
|
+
var _a2, _b, _c;
|
|
34266
|
+
const shape = getObjectShape(requestSchema);
|
|
34267
|
+
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
34268
|
+
if (!methodSchema) {
|
|
34269
|
+
throw new Error("Schema is missing a method literal");
|
|
34270
|
+
}
|
|
34271
|
+
let methodValue;
|
|
34272
|
+
if (isZ4Schema(methodSchema)) {
|
|
34273
|
+
const v4Schema = methodSchema;
|
|
34274
|
+
const v4Def = (_a2 = v4Schema._zod) === null || _a2 === void 0 ? void 0 : _a2.def;
|
|
34275
|
+
methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
|
|
34276
|
+
} else {
|
|
34277
|
+
const v3Schema = methodSchema;
|
|
34278
|
+
const legacyDef = v3Schema._def;
|
|
34279
|
+
methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
|
|
34280
|
+
}
|
|
34281
|
+
if (typeof methodValue !== "string") {
|
|
34282
|
+
throw new Error("Schema method literal must be a string");
|
|
34283
|
+
}
|
|
34284
|
+
const method = methodValue;
|
|
34285
|
+
if (method === "tools/call") {
|
|
34286
|
+
const wrappedHandler = async (request2, extra) => {
|
|
34287
|
+
const validatedRequest = safeParse4(CallToolRequestSchema, request2);
|
|
34288
|
+
if (!validatedRequest.success) {
|
|
34289
|
+
const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
34290
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
|
|
34291
|
+
}
|
|
34292
|
+
const { params } = validatedRequest.data;
|
|
34293
|
+
const result = await Promise.resolve(handler2(request2, extra));
|
|
34294
|
+
if (params.task) {
|
|
34295
|
+
const taskValidationResult = safeParse4(CreateTaskResultSchema, result);
|
|
34296
|
+
if (!taskValidationResult.success) {
|
|
34297
|
+
const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
|
|
34298
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
|
|
34299
|
+
}
|
|
34300
|
+
return taskValidationResult.data;
|
|
34301
|
+
}
|
|
34302
|
+
const validationResult = safeParse4(CallToolResultSchema, result);
|
|
34303
|
+
if (!validationResult.success) {
|
|
34304
|
+
const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
|
|
34305
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
|
|
34306
|
+
}
|
|
34307
|
+
return validationResult.data;
|
|
34308
|
+
};
|
|
34309
|
+
return super.setRequestHandler(requestSchema, wrappedHandler);
|
|
34310
|
+
}
|
|
34311
|
+
return super.setRequestHandler(requestSchema, handler2);
|
|
34312
|
+
}
|
|
33293
34313
|
assertCapabilityForMethod(method) {
|
|
33294
34314
|
var _a2, _b, _c;
|
|
33295
34315
|
switch (method) {
|
|
@@ -33348,6 +34368,9 @@ var Server = class extends Protocol {
|
|
|
33348
34368
|
}
|
|
33349
34369
|
}
|
|
33350
34370
|
assertRequestHandlerCapability(method) {
|
|
34371
|
+
if (!this._capabilities) {
|
|
34372
|
+
return;
|
|
34373
|
+
}
|
|
33351
34374
|
switch (method) {
|
|
33352
34375
|
case "completion/complete":
|
|
33353
34376
|
if (!this._capabilities.completions) {
|
|
@@ -33378,11 +34401,30 @@ var Server = class extends Protocol {
|
|
|
33378
34401
|
throw new Error(`Server does not support tools (required for ${method})`);
|
|
33379
34402
|
}
|
|
33380
34403
|
break;
|
|
34404
|
+
case "tasks/get":
|
|
34405
|
+
case "tasks/list":
|
|
34406
|
+
case "tasks/result":
|
|
34407
|
+
case "tasks/cancel":
|
|
34408
|
+
if (!this._capabilities.tasks) {
|
|
34409
|
+
throw new Error(`Server does not support tasks capability (required for ${method})`);
|
|
34410
|
+
}
|
|
34411
|
+
break;
|
|
33381
34412
|
case "ping":
|
|
33382
34413
|
case "initialize":
|
|
33383
34414
|
break;
|
|
33384
34415
|
}
|
|
33385
34416
|
}
|
|
34417
|
+
assertTaskCapability(method) {
|
|
34418
|
+
var _a2, _b;
|
|
34419
|
+
assertClientRequestTaskCapability((_b = (_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Client");
|
|
34420
|
+
}
|
|
34421
|
+
assertTaskHandlerCapability(method) {
|
|
34422
|
+
var _a2;
|
|
34423
|
+
if (!this._capabilities) {
|
|
34424
|
+
return;
|
|
34425
|
+
}
|
|
34426
|
+
assertToolsCallTaskCapability((_a2 = this._capabilities.tasks) === null || _a2 === void 0 ? void 0 : _a2.requests, method, "Server");
|
|
34427
|
+
}
|
|
33386
34428
|
async _oninitialize(request2) {
|
|
33387
34429
|
const requestedVersion = request2.params.protocolVersion;
|
|
33388
34430
|
this._clientCapabilities = request2.params.capabilities;
|
|
@@ -33413,6 +34455,7 @@ var Server = class extends Protocol {
|
|
|
33413
34455
|
async ping() {
|
|
33414
34456
|
return this.request({ method: "ping" }, EmptyResultSchema);
|
|
33415
34457
|
}
|
|
34458
|
+
// Implementation
|
|
33416
34459
|
async createMessage(params, options) {
|
|
33417
34460
|
var _a2, _b;
|
|
33418
34461
|
if (params.tools || params.toolChoice) {
|
|
@@ -33443,6 +34486,9 @@ var Server = class extends Protocol {
|
|
|
33443
34486
|
}
|
|
33444
34487
|
}
|
|
33445
34488
|
}
|
|
34489
|
+
if (params.tools) {
|
|
34490
|
+
return this.request({ method: "sampling/createMessage", params }, CreateMessageResultWithToolsSchema, options);
|
|
34491
|
+
}
|
|
33446
34492
|
return this.request({ method: "sampling/createMessage", params }, CreateMessageResultSchema, options);
|
|
33447
34493
|
}
|
|
33448
34494
|
/**
|
|
@@ -33543,8 +34589,8 @@ var Server = class extends Protocol {
|
|
|
33543
34589
|
}
|
|
33544
34590
|
};
|
|
33545
34591
|
|
|
33546
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
33547
|
-
var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
|
|
34592
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
|
|
34593
|
+
var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
|
|
33548
34594
|
function isCompletable(schema5) {
|
|
33549
34595
|
return !!schema5 && typeof schema5 === "object" && COMPLETABLE_SYMBOL in schema5;
|
|
33550
34596
|
}
|
|
@@ -33557,7 +34603,7 @@ var McpZodTypeKind;
|
|
|
33557
34603
|
McpZodTypeKind2["Completable"] = "McpCompletable";
|
|
33558
34604
|
})(McpZodTypeKind || (McpZodTypeKind = {}));
|
|
33559
34605
|
|
|
33560
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
34606
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
|
|
33561
34607
|
var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
|
|
33562
34608
|
function validateToolName(name) {
|
|
33563
34609
|
const warnings = [];
|
|
@@ -33615,7 +34661,22 @@ function validateAndWarnToolName(name) {
|
|
|
33615
34661
|
return result.isValid;
|
|
33616
34662
|
}
|
|
33617
34663
|
|
|
33618
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
34664
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
|
|
34665
|
+
var ExperimentalMcpServerTasks = class {
|
|
34666
|
+
constructor(_mcpServer) {
|
|
34667
|
+
this._mcpServer = _mcpServer;
|
|
34668
|
+
}
|
|
34669
|
+
registerToolTask(name, config2, handler2) {
|
|
34670
|
+
const execution = { taskSupport: "required", ...config2.execution };
|
|
34671
|
+
if (execution.taskSupport === "forbidden") {
|
|
34672
|
+
throw new Error(`Cannot register task-based tool '${name}' with taskSupport 'forbidden'. Use registerTool() instead.`);
|
|
34673
|
+
}
|
|
34674
|
+
const mcpServerInternal = this._mcpServer;
|
|
34675
|
+
return mcpServerInternal._createRegisteredTool(name, config2.title, config2.description, config2.inputSchema, config2.outputSchema, config2.annotations, execution, config2._meta, handler2);
|
|
34676
|
+
}
|
|
34677
|
+
};
|
|
34678
|
+
|
|
34679
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
|
|
33619
34680
|
var McpServer = class {
|
|
33620
34681
|
constructor(serverInfo, options) {
|
|
33621
34682
|
this._registeredResources = {};
|
|
@@ -33628,6 +34689,21 @@ var McpServer = class {
|
|
|
33628
34689
|
this._promptHandlersInitialized = false;
|
|
33629
34690
|
this.server = new Server(serverInfo, options);
|
|
33630
34691
|
}
|
|
34692
|
+
/**
|
|
34693
|
+
* Access experimental features.
|
|
34694
|
+
*
|
|
34695
|
+
* WARNING: These APIs are experimental and may change without notice.
|
|
34696
|
+
*
|
|
34697
|
+
* @experimental
|
|
34698
|
+
*/
|
|
34699
|
+
get experimental() {
|
|
34700
|
+
if (!this._experimental) {
|
|
34701
|
+
this._experimental = {
|
|
34702
|
+
tasks: new ExperimentalMcpServerTasks(this)
|
|
34703
|
+
};
|
|
34704
|
+
}
|
|
34705
|
+
return this._experimental;
|
|
34706
|
+
}
|
|
33631
34707
|
/**
|
|
33632
34708
|
* Attaches to the given transport, starts it, and starts listening for messages.
|
|
33633
34709
|
*
|
|
@@ -33667,6 +34743,7 @@ var McpServer = class {
|
|
|
33667
34743
|
}) : EMPTY_OBJECT_JSON_SCHEMA;
|
|
33668
34744
|
})(),
|
|
33669
34745
|
annotations: tool.annotations,
|
|
34746
|
+
execution: tool.execution,
|
|
33670
34747
|
_meta: tool._meta
|
|
33671
34748
|
};
|
|
33672
34749
|
if (tool.outputSchema) {
|
|
@@ -33682,39 +34759,34 @@ var McpServer = class {
|
|
|
33682
34759
|
})
|
|
33683
34760
|
}));
|
|
33684
34761
|
this.server.setRequestHandler(CallToolRequestSchema, async (request2, extra) => {
|
|
33685
|
-
|
|
33686
|
-
let result;
|
|
34762
|
+
var _a2;
|
|
33687
34763
|
try {
|
|
34764
|
+
const tool = this._registeredTools[request2.params.name];
|
|
33688
34765
|
if (!tool) {
|
|
33689
34766
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request2.params.name} not found`);
|
|
33690
34767
|
}
|
|
33691
34768
|
if (!tool.enabled) {
|
|
33692
34769
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request2.params.name} disabled`);
|
|
33693
34770
|
}
|
|
33694
|
-
|
|
33695
|
-
|
|
33696
|
-
|
|
33697
|
-
|
|
33698
|
-
|
|
33699
|
-
if (!parseResult.success) {
|
|
33700
|
-
throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${request2.params.name}: ${getParseErrorMessage(parseResult.error)}`);
|
|
33701
|
-
}
|
|
33702
|
-
const args2 = parseResult.data;
|
|
33703
|
-
result = await Promise.resolve(cb(args2, extra));
|
|
33704
|
-
} else {
|
|
33705
|
-
const cb = tool.callback;
|
|
33706
|
-
result = await Promise.resolve(cb(extra));
|
|
34771
|
+
const isTaskRequest = !!request2.params.task;
|
|
34772
|
+
const taskSupport = (_a2 = tool.execution) === null || _a2 === void 0 ? void 0 : _a2.taskSupport;
|
|
34773
|
+
const isTaskHandler = "createTask" in tool.handler;
|
|
34774
|
+
if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
|
|
34775
|
+
throw new McpError(ErrorCode.InternalError, `Tool ${request2.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
|
|
33707
34776
|
}
|
|
33708
|
-
if (
|
|
33709
|
-
|
|
33710
|
-
|
|
33711
|
-
|
|
33712
|
-
|
|
33713
|
-
|
|
33714
|
-
|
|
33715
|
-
|
|
33716
|
-
|
|
34777
|
+
if (taskSupport === "required" && !isTaskRequest) {
|
|
34778
|
+
throw new McpError(ErrorCode.MethodNotFound, `Tool ${request2.params.name} requires task augmentation (taskSupport: 'required')`);
|
|
34779
|
+
}
|
|
34780
|
+
if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) {
|
|
34781
|
+
return await this.handleAutomaticTaskPolling(tool, request2, extra);
|
|
34782
|
+
}
|
|
34783
|
+
const args2 = await this.validateToolInput(tool, request2.params.arguments, request2.params.name);
|
|
34784
|
+
const result = await this.executeToolHandler(tool, args2, extra);
|
|
34785
|
+
if (isTaskRequest) {
|
|
34786
|
+
return result;
|
|
33717
34787
|
}
|
|
34788
|
+
await this.validateToolOutput(tool, result, request2.params.name);
|
|
34789
|
+
return result;
|
|
33718
34790
|
} catch (error46) {
|
|
33719
34791
|
if (error46 instanceof McpError) {
|
|
33720
34792
|
if (error46.code === ErrorCode.UrlElicitationRequired) {
|
|
@@ -33723,7 +34795,6 @@ var McpServer = class {
|
|
|
33723
34795
|
}
|
|
33724
34796
|
return this.createToolError(error46 instanceof Error ? error46.message : String(error46));
|
|
33725
34797
|
}
|
|
33726
|
-
return result;
|
|
33727
34798
|
});
|
|
33728
34799
|
this._toolHandlersInitialized = true;
|
|
33729
34800
|
}
|
|
@@ -33744,6 +34815,102 @@ var McpServer = class {
|
|
|
33744
34815
|
isError: true
|
|
33745
34816
|
};
|
|
33746
34817
|
}
|
|
34818
|
+
/**
|
|
34819
|
+
* Validates tool input arguments against the tool's input schema.
|
|
34820
|
+
*/
|
|
34821
|
+
async validateToolInput(tool, args2, toolName) {
|
|
34822
|
+
if (!tool.inputSchema) {
|
|
34823
|
+
return void 0;
|
|
34824
|
+
}
|
|
34825
|
+
const inputObj = normalizeObjectSchema(tool.inputSchema);
|
|
34826
|
+
const schemaToParse = inputObj !== null && inputObj !== void 0 ? inputObj : tool.inputSchema;
|
|
34827
|
+
const parseResult = await safeParseAsync3(schemaToParse, args2);
|
|
34828
|
+
if (!parseResult.success) {
|
|
34829
|
+
const error46 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
34830
|
+
const errorMessage = getParseErrorMessage(error46);
|
|
34831
|
+
throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${errorMessage}`);
|
|
34832
|
+
}
|
|
34833
|
+
return parseResult.data;
|
|
34834
|
+
}
|
|
34835
|
+
/**
|
|
34836
|
+
* Validates tool output against the tool's output schema.
|
|
34837
|
+
*/
|
|
34838
|
+
async validateToolOutput(tool, result, toolName) {
|
|
34839
|
+
if (!tool.outputSchema) {
|
|
34840
|
+
return;
|
|
34841
|
+
}
|
|
34842
|
+
if (!("content" in result)) {
|
|
34843
|
+
return;
|
|
34844
|
+
}
|
|
34845
|
+
if (result.isError) {
|
|
34846
|
+
return;
|
|
34847
|
+
}
|
|
34848
|
+
if (!result.structuredContent) {
|
|
34849
|
+
throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
|
|
34850
|
+
}
|
|
34851
|
+
const outputObj = normalizeObjectSchema(tool.outputSchema);
|
|
34852
|
+
const parseResult = await safeParseAsync3(outputObj, result.structuredContent);
|
|
34853
|
+
if (!parseResult.success) {
|
|
34854
|
+
const error46 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
34855
|
+
const errorMessage = getParseErrorMessage(error46);
|
|
34856
|
+
throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`);
|
|
34857
|
+
}
|
|
34858
|
+
}
|
|
34859
|
+
/**
|
|
34860
|
+
* Executes a tool handler (either regular or task-based).
|
|
34861
|
+
*/
|
|
34862
|
+
async executeToolHandler(tool, args2, extra) {
|
|
34863
|
+
const handler2 = tool.handler;
|
|
34864
|
+
const isTaskHandler = "createTask" in handler2;
|
|
34865
|
+
if (isTaskHandler) {
|
|
34866
|
+
if (!extra.taskStore) {
|
|
34867
|
+
throw new Error("No task store provided.");
|
|
34868
|
+
}
|
|
34869
|
+
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
34870
|
+
if (tool.inputSchema) {
|
|
34871
|
+
const typedHandler = handler2;
|
|
34872
|
+
return await Promise.resolve(typedHandler.createTask(args2, taskExtra));
|
|
34873
|
+
} else {
|
|
34874
|
+
const typedHandler = handler2;
|
|
34875
|
+
return await Promise.resolve(typedHandler.createTask(taskExtra));
|
|
34876
|
+
}
|
|
34877
|
+
}
|
|
34878
|
+
if (tool.inputSchema) {
|
|
34879
|
+
const typedHandler = handler2;
|
|
34880
|
+
return await Promise.resolve(typedHandler(args2, extra));
|
|
34881
|
+
} else {
|
|
34882
|
+
const typedHandler = handler2;
|
|
34883
|
+
return await Promise.resolve(typedHandler(extra));
|
|
34884
|
+
}
|
|
34885
|
+
}
|
|
34886
|
+
/**
|
|
34887
|
+
* Handles automatic task polling for tools with taskSupport 'optional'.
|
|
34888
|
+
*/
|
|
34889
|
+
async handleAutomaticTaskPolling(tool, request2, extra) {
|
|
34890
|
+
var _a2;
|
|
34891
|
+
if (!extra.taskStore) {
|
|
34892
|
+
throw new Error("No task store provided for task-capable tool.");
|
|
34893
|
+
}
|
|
34894
|
+
const args2 = await this.validateToolInput(tool, request2.params.arguments, request2.params.name);
|
|
34895
|
+
const handler2 = tool.handler;
|
|
34896
|
+
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
34897
|
+
const createTaskResult = args2 ? await Promise.resolve(handler2.createTask(args2, taskExtra)) : (
|
|
34898
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34899
|
+
await Promise.resolve(handler2.createTask(taskExtra))
|
|
34900
|
+
);
|
|
34901
|
+
const taskId = createTaskResult.task.taskId;
|
|
34902
|
+
let task = createTaskResult.task;
|
|
34903
|
+
const pollInterval = (_a2 = task.pollInterval) !== null && _a2 !== void 0 ? _a2 : 5e3;
|
|
34904
|
+
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
34905
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
34906
|
+
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
34907
|
+
if (!updatedTask) {
|
|
34908
|
+
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
34909
|
+
}
|
|
34910
|
+
task = updatedTask;
|
|
34911
|
+
}
|
|
34912
|
+
return await extra.taskStore.getTaskResult(taskId);
|
|
34913
|
+
}
|
|
33747
34914
|
setCompletionRequestHandler() {
|
|
33748
34915
|
if (this._completionHandlerInitialized) {
|
|
33749
34916
|
return;
|
|
@@ -33899,7 +35066,9 @@ var McpServer = class {
|
|
|
33899
35066
|
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
33900
35067
|
const parseResult = await safeParseAsync3(argsObj, request2.params.arguments);
|
|
33901
35068
|
if (!parseResult.success) {
|
|
33902
|
-
|
|
35069
|
+
const error46 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
35070
|
+
const errorMessage = getParseErrorMessage(error46);
|
|
35071
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request2.params.name}: ${errorMessage}`);
|
|
33903
35072
|
}
|
|
33904
35073
|
const args2 = parseResult.data;
|
|
33905
35074
|
const cb = prompt.callback;
|
|
@@ -34051,7 +35220,7 @@ var McpServer = class {
|
|
|
34051
35220
|
this._registeredPrompts[name] = registeredPrompt;
|
|
34052
35221
|
return registeredPrompt;
|
|
34053
35222
|
}
|
|
34054
|
-
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta,
|
|
35223
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, execution, _meta, handler2) {
|
|
34055
35224
|
validateAndWarnToolName(name);
|
|
34056
35225
|
const registeredTool = {
|
|
34057
35226
|
title,
|
|
@@ -34059,8 +35228,9 @@ var McpServer = class {
|
|
|
34059
35228
|
inputSchema: getZodSchemaObject(inputSchema),
|
|
34060
35229
|
outputSchema: getZodSchemaObject(outputSchema),
|
|
34061
35230
|
annotations,
|
|
35231
|
+
execution,
|
|
34062
35232
|
_meta,
|
|
34063
|
-
|
|
35233
|
+
handler: handler2,
|
|
34064
35234
|
enabled: true,
|
|
34065
35235
|
disable: () => registeredTool.update({ enabled: false }),
|
|
34066
35236
|
enable: () => registeredTool.update({ enabled: true }),
|
|
@@ -34081,7 +35251,7 @@ var McpServer = class {
|
|
|
34081
35251
|
if (typeof updates.paramsSchema !== "undefined")
|
|
34082
35252
|
registeredTool.inputSchema = objectFromShape(updates.paramsSchema);
|
|
34083
35253
|
if (typeof updates.callback !== "undefined")
|
|
34084
|
-
registeredTool.
|
|
35254
|
+
registeredTool.handler = updates.callback;
|
|
34085
35255
|
if (typeof updates.annotations !== "undefined")
|
|
34086
35256
|
registeredTool.annotations = updates.annotations;
|
|
34087
35257
|
if (typeof updates._meta !== "undefined")
|
|
@@ -34112,9 +35282,9 @@ var McpServer = class {
|
|
|
34112
35282
|
}
|
|
34113
35283
|
if (rest.length > 1) {
|
|
34114
35284
|
const firstArg = rest[0];
|
|
34115
|
-
if (
|
|
35285
|
+
if (isZodRawShapeCompat(firstArg)) {
|
|
34116
35286
|
inputSchema = rest.shift();
|
|
34117
|
-
if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !
|
|
35287
|
+
if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) {
|
|
34118
35288
|
annotations = rest.shift();
|
|
34119
35289
|
}
|
|
34120
35290
|
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
@@ -34122,7 +35292,7 @@ var McpServer = class {
|
|
|
34122
35292
|
}
|
|
34123
35293
|
}
|
|
34124
35294
|
const callback = rest[0];
|
|
34125
|
-
return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, void 0, callback);
|
|
35295
|
+
return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
|
|
34126
35296
|
}
|
|
34127
35297
|
/**
|
|
34128
35298
|
* Registers a tool with a config object and callback.
|
|
@@ -34132,7 +35302,7 @@ var McpServer = class {
|
|
|
34132
35302
|
throw new Error(`Tool ${name} is already registered`);
|
|
34133
35303
|
}
|
|
34134
35304
|
const { title, description, inputSchema, outputSchema, annotations, _meta } = config2;
|
|
34135
|
-
return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, cb);
|
|
35305
|
+
return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
|
|
34136
35306
|
}
|
|
34137
35307
|
prompt(name, ...rest) {
|
|
34138
35308
|
if (this._registeredPrompts[name]) {
|
|
@@ -34211,20 +35381,29 @@ var EMPTY_OBJECT_JSON_SCHEMA = {
|
|
|
34211
35381
|
type: "object",
|
|
34212
35382
|
properties: {}
|
|
34213
35383
|
};
|
|
34214
|
-
function isZodRawShape(obj) {
|
|
34215
|
-
if (typeof obj !== "object" || obj === null)
|
|
34216
|
-
return false;
|
|
34217
|
-
const isEmptyObject = Object.keys(obj).length === 0;
|
|
34218
|
-
return isEmptyObject || Object.values(obj).some(isZodTypeLike);
|
|
34219
|
-
}
|
|
34220
35384
|
function isZodTypeLike(value) {
|
|
34221
35385
|
return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
34222
35386
|
}
|
|
35387
|
+
function isZodSchemaInstance(obj) {
|
|
35388
|
+
return "_def" in obj || "_zod" in obj || isZodTypeLike(obj);
|
|
35389
|
+
}
|
|
35390
|
+
function isZodRawShapeCompat(obj) {
|
|
35391
|
+
if (typeof obj !== "object" || obj === null) {
|
|
35392
|
+
return false;
|
|
35393
|
+
}
|
|
35394
|
+
if (isZodSchemaInstance(obj)) {
|
|
35395
|
+
return false;
|
|
35396
|
+
}
|
|
35397
|
+
if (Object.keys(obj).length === 0) {
|
|
35398
|
+
return true;
|
|
35399
|
+
}
|
|
35400
|
+
return Object.values(obj).some(isZodTypeLike);
|
|
35401
|
+
}
|
|
34223
35402
|
function getZodSchemaObject(schema5) {
|
|
34224
35403
|
if (!schema5) {
|
|
34225
35404
|
return void 0;
|
|
34226
35405
|
}
|
|
34227
|
-
if (
|
|
35406
|
+
if (isZodRawShapeCompat(schema5)) {
|
|
34228
35407
|
return objectFromShape(schema5);
|
|
34229
35408
|
}
|
|
34230
35409
|
return schema5;
|
|
@@ -34271,10 +35450,10 @@ var EMPTY_COMPLETION_RESULT = {
|
|
|
34271
35450
|
}
|
|
34272
35451
|
};
|
|
34273
35452
|
|
|
34274
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
35453
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
34275
35454
|
import process2 from "node:process";
|
|
34276
35455
|
|
|
34277
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
35456
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
34278
35457
|
var ReadBuffer = class {
|
|
34279
35458
|
append(chunk) {
|
|
34280
35459
|
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
@@ -34302,7 +35481,7 @@ function serializeMessage(message) {
|
|
|
34302
35481
|
return JSON.stringify(message) + "\n";
|
|
34303
35482
|
}
|
|
34304
35483
|
|
|
34305
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
35484
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
34306
35485
|
var StdioServerTransport = class {
|
|
34307
35486
|
constructor(_stdin = process2.stdin, _stdout = process2.stdout) {
|
|
34308
35487
|
this._stdin = _stdin;
|
|
@@ -34369,7 +35548,7 @@ var StdioServerTransport = class {
|
|
|
34369
35548
|
// ../mcp/package.json
|
|
34370
35549
|
var package_default = {
|
|
34371
35550
|
name: "@aku11i/phantom-mcp",
|
|
34372
|
-
version: "3.
|
|
35551
|
+
version: "3.3.1",
|
|
34373
35552
|
private: true,
|
|
34374
35553
|
type: "module",
|
|
34375
35554
|
main: "./src/index.ts",
|
|
@@ -34385,11 +35564,11 @@ var package_default = {
|
|
|
34385
35564
|
"@aku11i/phantom-github": "workspace:*",
|
|
34386
35565
|
"@aku11i/phantom-process": "workspace:*",
|
|
34387
35566
|
"@aku11i/phantom-shared": "workspace:*",
|
|
34388
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
35567
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
34389
35568
|
zod: "^4.1.13"
|
|
34390
35569
|
},
|
|
34391
35570
|
devDependencies: {
|
|
34392
|
-
"@modelcontextprotocol/inspector": "^0.17.
|
|
35571
|
+
"@modelcontextprotocol/inspector": "^0.17.5"
|
|
34393
35572
|
}
|
|
34394
35573
|
};
|
|
34395
35574
|
|
|
@@ -34662,6 +35841,10 @@ var preferencesHelp = {
|
|
|
34662
35841
|
command: 'phantom preferences set ai "codex --full-auto"',
|
|
34663
35842
|
description: "Set the AI assistant preference (stored as phantom.ai in git config --global)"
|
|
34664
35843
|
},
|
|
35844
|
+
{
|
|
35845
|
+
command: "phantom preferences set worktreesDirectory ../phantom-worktrees",
|
|
35846
|
+
description: "Store a custom worktreesDirectory (relative to the Git repository root) for all commands"
|
|
35847
|
+
},
|
|
34665
35848
|
{
|
|
34666
35849
|
command: "phantom preferences remove editor",
|
|
34667
35850
|
description: "Remove the editor preference (fallback to env/default)"
|
|
@@ -34674,7 +35857,10 @@ var preferencesHelp = {
|
|
|
34674
35857
|
" remove <key> Remove a preference value",
|
|
34675
35858
|
"",
|
|
34676
35859
|
"Preferences are saved in git config with the 'phantom.' prefix (global scope).",
|
|
34677
|
-
"Supported keys:
|
|
35860
|
+
"Supported keys:",
|
|
35861
|
+
" editor - used by 'phantom edit', preferred over $EDITOR",
|
|
35862
|
+
" ai - used by 'phantom ai'",
|
|
35863
|
+
" worktreesDirectory - path relative to the Git repo root for storing worktrees (defaults to .git/phantom/worktrees)"
|
|
34678
35864
|
]
|
|
34679
35865
|
};
|
|
34680
35866
|
var preferencesGetHelp = {
|
|
@@ -34689,9 +35875,13 @@ var preferencesGetHelp = {
|
|
|
34689
35875
|
{
|
|
34690
35876
|
command: "phantom preferences get ai",
|
|
34691
35877
|
description: "Show the AI assistant preference"
|
|
35878
|
+
},
|
|
35879
|
+
{
|
|
35880
|
+
command: "phantom preferences get worktreesDirectory",
|
|
35881
|
+
description: "Show the preferred worktrees directory (relative to repo root)"
|
|
34692
35882
|
}
|
|
34693
35883
|
],
|
|
34694
|
-
notes: ["Supported keys: editor, ai"]
|
|
35884
|
+
notes: ["Supported keys: editor, ai, worktreesDirectory"]
|
|
34695
35885
|
};
|
|
34696
35886
|
var preferencesSetHelp = {
|
|
34697
35887
|
name: "preferences set",
|
|
@@ -34705,9 +35895,16 @@ var preferencesSetHelp = {
|
|
|
34705
35895
|
{
|
|
34706
35896
|
command: "phantom preferences set ai claude",
|
|
34707
35897
|
description: "Configure the AI assistant command"
|
|
35898
|
+
},
|
|
35899
|
+
{
|
|
35900
|
+
command: "phantom preferences set worktreesDirectory ../phantom-worktrees",
|
|
35901
|
+
description: "Store worktrees in ../phantom-worktrees relative to the Git repository root"
|
|
34708
35902
|
}
|
|
34709
35903
|
],
|
|
34710
|
-
notes: [
|
|
35904
|
+
notes: [
|
|
35905
|
+
"Supported keys: editor, ai, worktreesDirectory",
|
|
35906
|
+
"For worktreesDirectory, provide a path relative to the Git repository root; defaults to .git/phantom/worktrees when unset"
|
|
35907
|
+
]
|
|
34711
35908
|
};
|
|
34712
35909
|
var preferencesRemoveHelp = {
|
|
34713
35910
|
name: "preferences remove",
|
|
@@ -34721,9 +35918,13 @@ var preferencesRemoveHelp = {
|
|
|
34721
35918
|
{
|
|
34722
35919
|
command: "phantom preferences remove ai",
|
|
34723
35920
|
description: "Unset the AI assistant preference"
|
|
35921
|
+
},
|
|
35922
|
+
{
|
|
35923
|
+
command: "phantom preferences remove worktreesDirectory",
|
|
35924
|
+
description: "Unset the custom worktrees directory preference"
|
|
34724
35925
|
}
|
|
34725
35926
|
],
|
|
34726
|
-
notes: ["Supported keys: editor, ai"]
|
|
35927
|
+
notes: ["Supported keys: editor, ai, worktreesDirectory"]
|
|
34727
35928
|
};
|
|
34728
35929
|
|
|
34729
35930
|
// src/handlers/preferences.ts
|
|
@@ -34737,7 +35938,7 @@ async function preferencesHandler(args2) {
|
|
|
34737
35938
|
|
|
34738
35939
|
// src/handlers/preferences-get.ts
|
|
34739
35940
|
import { parseArgs as parseArgs10 } from "node:util";
|
|
34740
|
-
var supportedKeys = ["editor", "ai"];
|
|
35941
|
+
var supportedKeys = ["editor", "ai", "worktreesDirectory"];
|
|
34741
35942
|
async function preferencesGetHandler(args2) {
|
|
34742
35943
|
const { positionals } = parseArgs10({
|
|
34743
35944
|
args: args2,
|
|
@@ -34760,7 +35961,7 @@ async function preferencesGetHandler(args2) {
|
|
|
34760
35961
|
}
|
|
34761
35962
|
try {
|
|
34762
35963
|
const preferences = await loadPreferences();
|
|
34763
|
-
const value = inputKey === "editor" ? preferences.editor : inputKey === "ai" ? preferences.ai : void 0;
|
|
35964
|
+
const value = inputKey === "editor" ? preferences.editor : inputKey === "ai" ? preferences.ai : inputKey === "worktreesDirectory" ? preferences.worktreesDirectory : void 0;
|
|
34764
35965
|
if (value === void 0) {
|
|
34765
35966
|
output.log(
|
|
34766
35967
|
`Preference '${inputKey}' is not set (git config --global phantom.${inputKey})`
|
|
@@ -34779,7 +35980,7 @@ async function preferencesGetHandler(args2) {
|
|
|
34779
35980
|
|
|
34780
35981
|
// src/handlers/preferences-remove.ts
|
|
34781
35982
|
import { parseArgs as parseArgs11 } from "node:util";
|
|
34782
|
-
var supportedKeys2 = ["editor", "ai"];
|
|
35983
|
+
var supportedKeys2 = ["editor", "ai", "worktreesDirectory"];
|
|
34783
35984
|
async function preferencesRemoveHandler(args2) {
|
|
34784
35985
|
const { positionals } = parseArgs11({
|
|
34785
35986
|
args: args2,
|
|
@@ -34818,7 +36019,7 @@ async function preferencesRemoveHandler(args2) {
|
|
|
34818
36019
|
}
|
|
34819
36020
|
|
|
34820
36021
|
// src/handlers/preferences-set.ts
|
|
34821
|
-
var supportedKeys3 = ["editor", "ai"];
|
|
36022
|
+
var supportedKeys3 = ["editor", "ai", "worktreesDirectory"];
|
|
34822
36023
|
async function preferencesSetHandler(args2) {
|
|
34823
36024
|
if (args2.length < 2) {
|
|
34824
36025
|
exitWithError(
|
|
@@ -34986,7 +36187,7 @@ import { parseArgs as parseArgs13 } from "node:util";
|
|
|
34986
36187
|
// package.json
|
|
34987
36188
|
var package_default2 = {
|
|
34988
36189
|
name: "@aku11i/phantom-cli",
|
|
34989
|
-
version: "3.
|
|
36190
|
+
version: "3.3.1",
|
|
34990
36191
|
private: true,
|
|
34991
36192
|
type: "module",
|
|
34992
36193
|
scripts: {
|
|
@@ -35309,8 +36510,8 @@ var createHelp = {
|
|
|
35309
36510
|
// src/help/delete.ts
|
|
35310
36511
|
var deleteHelp = {
|
|
35311
36512
|
name: "delete",
|
|
35312
|
-
description: "Delete
|
|
35313
|
-
usage: "phantom delete <name
|
|
36513
|
+
description: "Delete one or more Git worktrees",
|
|
36514
|
+
usage: "phantom delete <name...> [options]",
|
|
35314
36515
|
options: [
|
|
35315
36516
|
{
|
|
35316
36517
|
name: "force",
|
|
@@ -35334,6 +36535,10 @@ var deleteHelp = {
|
|
|
35334
36535
|
description: "Delete a worktree",
|
|
35335
36536
|
command: "phantom delete feature-auth"
|
|
35336
36537
|
},
|
|
36538
|
+
{
|
|
36539
|
+
description: "Delete multiple worktrees in one command",
|
|
36540
|
+
command: "phantom delete feature-auth docs-cleanup spike-login"
|
|
36541
|
+
},
|
|
35337
36542
|
{
|
|
35338
36543
|
description: "Force delete a worktree with uncommitted changes",
|
|
35339
36544
|
command: "phantom delete experimental --force"
|
|
@@ -35349,6 +36554,7 @@ var deleteHelp = {
|
|
|
35349
36554
|
],
|
|
35350
36555
|
notes: [
|
|
35351
36556
|
"By default, deletion will fail if the worktree has uncommitted changes",
|
|
36557
|
+
"You can pass multiple worktree names to delete them at once",
|
|
35352
36558
|
"The associated branch will also be deleted if it's not checked out elsewhere",
|
|
35353
36559
|
"With --fzf, you can interactively select the worktree to delete"
|
|
35354
36560
|
]
|