@aku11i/phantom 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/phantom.js +1341 -162
package/phantom.js CHANGED
@@ -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, {
@@ -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();
@@ -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),
@@ -21152,19 +21162,19 @@ _phantom_completion() {
21152
21162
  return 0
21153
21163
  elif [[ \${words[2]} == "get" ]]; then
21154
21164
  if [[ \${cword} -eq 3 ]]; then
21155
- local keys="editor ai"
21165
+ local keys="editor ai worktreesDirectory"
21156
21166
  COMPREPLY=( $(compgen -W "\${keys}" -- "\${cur}") )
21157
21167
  return 0
21158
21168
  fi
21159
21169
  elif [[ \${words[2]} == "set" ]]; then
21160
21170
  if [[ \${cword} -eq 3 ]]; then
21161
- local keys="editor ai"
21171
+ local keys="editor ai worktreesDirectory"
21162
21172
  COMPREPLY=( $(compgen -W "\${keys}" -- "\${cur}") )
21163
21173
  return 0
21164
21174
  fi
21165
21175
  elif [[ \${words[2]} == "remove" ]]; then
21166
21176
  if [[ \${cword} -eq 3 ]]; then
21167
- local keys="editor ai"
21177
+ local keys="editor ai worktreesDirectory"
21168
21178
  COMPREPLY=( $(compgen -W "\${keys}" -- "\${cur}") )
21169
21179
  return 0
21170
21180
  fi
@@ -21308,12 +21318,12 @@ complete -c phantom -n "__phantom_using_command" -a "create" -d "Create a new Gi
21308
21318
  complete -c phantom -n "__phantom_using_command" -a "attach" -d "Attach to an existing branch by creating a new worktree"
21309
21319
  complete -c phantom -n "__phantom_using_command" -a "list" -d "List all Git worktrees (phantoms)"
21310
21320
  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 a Git worktree (phantom)"
21321
+ complete -c phantom -n "__phantom_using_command" -a "delete" -d "Delete Git worktrees (phantoms)"
21312
21322
  complete -c phantom -n "__phantom_using_command" -a "exec" -d "Execute a command in a worktree directory"
21313
21323
  complete -c phantom -n "__phantom_using_command" -a "edit" -d "Open a worktree in your configured editor"
21314
21324
  complete -c phantom -n "__phantom_using_command" -a "ai" -d "Launch your configured AI coding assistant in a worktree"
21315
21325
  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)"
21326
+ complete -c phantom -n "__phantom_using_command" -a "preferences" -d "Manage editor/ai/worktreesDirectory preferences (stored in git config --global)"
21317
21327
  complete -c phantom -n "__phantom_using_command" -a "github" -d "GitHub integration commands"
21318
21328
  complete -c phantom -n "__phantom_using_command" -a "gh" -d "GitHub integration commands (alias)"
21319
21329
  complete -c phantom -n "__phantom_using_command" -a "version" -d "Display phantom version information"
@@ -21379,9 +21389,9 @@ complete -c phantom -n "__phantom_using_command ai" -a "(__phantom_list_worktree
21379
21389
 
21380
21390
  # preferences command
21381
21391
  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"
21392
+ complete -c phantom -n "__phantom_using_command preferences get" -a "editor ai worktreesDirectory" -d "Preference key"
21393
+ complete -c phantom -n "__phantom_using_command preferences set" -a "editor ai worktreesDirectory" -d "Preference key"
21394
+ complete -c phantom -n "__phantom_using_command preferences remove" -a "editor ai worktreesDirectory" -d "Preference key"
21385
21395
 
21386
21396
  # shell command options
21387
21397
  complete -c phantom -n "__phantom_using_command shell" -l fzf -d "Use fzf for interactive selection"
@@ -21430,12 +21440,12 @@ _phantom() {
21430
21440
  'attach:Attach to an existing branch by creating a new worktree'
21431
21441
  'list:List all Git worktrees (phantoms)'
21432
21442
  'where:Output the filesystem path of a specific worktree'
21433
- 'delete:Delete a Git worktree (phantom)'
21443
+ 'delete:Delete Git worktrees (phantoms)'
21434
21444
  'exec:Execute a command in a worktree directory'
21435
21445
  'edit:Open a worktree in your configured editor'
21436
21446
  'ai:Launch your configured AI coding assistant in a worktree'
21437
21447
  'shell:Open an interactive shell in a worktree directory'
21438
- 'preferences:Manage editor/ai preferences (git config --global)'
21448
+ 'preferences:Manage editor/ai/worktreesDirectory preferences (git config --global)'
21439
21449
  'github:GitHub integration commands'
21440
21450
  'gh:GitHub integration commands (alias)'
21441
21451
  'version:Display phantom version information'
@@ -21468,7 +21478,7 @@ _phantom() {
21468
21478
  elif [[ \${line[1]} == "shell" ]]; then
21469
21479
  _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
21480
  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]' '1:worktree:(\${(q)worktrees[@]})'
21481
+ _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
21482
  fi
21473
21483
  ;;
21474
21484
  exec)
@@ -21487,7 +21497,7 @@ _phantom() {
21487
21497
  _arguments '1:worktree:(\${(q)worktrees[@]})'
21488
21498
  ;;
21489
21499
  preferences)
21490
- _arguments '1:subcommand:(get set remove)' '2:key:(editor ai)'
21500
+ _arguments '1:subcommand:(get set remove)' '2:key:(editor ai worktreesDirectory)'
21491
21501
  ;;
21492
21502
  completion)
21493
21503
  _arguments '1:shell:(fish zsh bash)'
@@ -21735,7 +21745,7 @@ async function deleteHandler(args2) {
21735
21745
  const useFzf = values.fzf ?? false;
21736
21746
  if (positionals.length === 0 && !deleteCurrent && !useFzf) {
21737
21747
  exitWithError(
21738
- "Please provide a worktree name to delete, use --current to delete the current worktree, or use --fzf for interactive selection",
21748
+ "Please provide at least one worktree name to delete, use --current to delete the current worktree, or use --fzf for interactive selection",
21739
21749
  exitCodes.validationError
21740
21750
  );
21741
21751
  }
@@ -21755,7 +21765,7 @@ async function deleteHandler(args2) {
21755
21765
  try {
21756
21766
  const gitRoot = await getGitRoot();
21757
21767
  const context = await createContext(gitRoot);
21758
- let worktreeName;
21768
+ const worktreeNames = [];
21759
21769
  if (deleteCurrent) {
21760
21770
  const currentWorktree = await getCurrentWorktree(gitRoot);
21761
21771
  if (!currentWorktree) {
@@ -21764,7 +21774,7 @@ async function deleteHandler(args2) {
21764
21774
  exitCodes.validationError
21765
21775
  );
21766
21776
  }
21767
- worktreeName = currentWorktree;
21777
+ worktreeNames.push(currentWorktree);
21768
21778
  } else if (useFzf) {
21769
21779
  const selectResult = await selectWorktreeWithFzf(context.gitRoot);
21770
21780
  if (isErr(selectResult)) {
@@ -21773,24 +21783,26 @@ async function deleteHandler(args2) {
21773
21783
  if (!selectResult.value) {
21774
21784
  exitWithSuccess();
21775
21785
  }
21776
- worktreeName = selectResult.value.name;
21786
+ worktreeNames.push(selectResult.value.name);
21777
21787
  } else {
21778
- worktreeName = positionals[0];
21788
+ worktreeNames.push(...positionals);
21779
21789
  }
21780
- const result = await deleteWorktree(
21781
- context.gitRoot,
21782
- context.worktreesDirectory,
21783
- worktreeName,
21784
- {
21785
- force: forceDelete
21786
- },
21787
- context.config?.preDelete?.commands
21788
- );
21789
- if (isErr(result)) {
21790
- const exitCode = result.error instanceof WorktreeNotFoundError ? exitCodes.validationError : result.error instanceof WorktreeError && result.error.message.includes("uncommitted changes") ? exitCodes.validationError : exitCodes.generalError;
21791
- exitWithError(result.error.message, exitCode);
21790
+ for (const worktreeName of worktreeNames) {
21791
+ const result = await deleteWorktree(
21792
+ context.gitRoot,
21793
+ context.worktreesDirectory,
21794
+ worktreeName,
21795
+ {
21796
+ force: forceDelete
21797
+ },
21798
+ context.config?.preDelete?.commands
21799
+ );
21800
+ if (isErr(result)) {
21801
+ const exitCode = result.error instanceof WorktreeNotFoundError ? exitCodes.validationError : result.error instanceof WorktreeError && result.error.message.includes("uncommitted changes") ? exitCodes.validationError : exitCodes.generalError;
21802
+ exitWithError(result.error.message, exitCode);
21803
+ }
21804
+ output.log(result.value.message);
21792
21805
  }
21793
- output.log(result.value.message);
21794
21806
  exitWithSuccess();
21795
21807
  } catch (error46) {
21796
21808
  exitWithError(
@@ -22341,7 +22353,7 @@ function bindApi(hook2, state, name) {
22341
22353
  });
22342
22354
  }
22343
22355
  function Singular() {
22344
- const singularHookName = Symbol("Singular");
22356
+ const singularHookName = /* @__PURE__ */ Symbol("Singular");
22345
22357
  const singularHookState = {
22346
22358
  registry: {}
22347
22359
  };
@@ -29864,7 +29876,6 @@ ZodNaN2.create = (params) => {
29864
29876
  ...processCreateParams(params)
29865
29877
  });
29866
29878
  };
29867
- var BRAND = Symbol("zod_brand");
29868
29879
  var ZodBranded = class extends ZodType2 {
29869
29880
  _parse(input) {
29870
29881
  const { ctx } = this._processInputParams(input);
@@ -30077,7 +30088,7 @@ function object2(shape, params) {
30077
30088
  return new ZodMiniObject(def);
30078
30089
  }
30079
30090
 
30080
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
30091
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
30081
30092
  function isZ4Schema(s) {
30082
30093
  const schema5 = s;
30083
30094
  return !!schema5._zod;
@@ -30152,7 +30163,7 @@ function normalizeObjectSchema(schema5) {
30152
30163
  if (isZ4Schema(schema5)) {
30153
30164
  const v4Schema = schema5;
30154
30165
  const def = (_a2 = v4Schema._zod) === null || _a2 === void 0 ? void 0 : _a2.def;
30155
- if (def && (def.typeName === "object" || def.shape !== void 0)) {
30166
+ if (def && (def.type === "object" || def.shape !== void 0)) {
30156
30167
  return schema5;
30157
30168
  }
30158
30169
  } else {
@@ -30195,7 +30206,7 @@ function isSchemaOptional(schema5) {
30195
30206
  var _a2, _b, _c;
30196
30207
  if (isZ4Schema(schema5)) {
30197
30208
  const v4Schema = schema5;
30198
- return ((_b = (_a2 = v4Schema._zod) === null || _a2 === void 0 ? void 0 : _a2.def) === null || _b === void 0 ? void 0 : _b.typeName) === "ZodOptional";
30209
+ return ((_b = (_a2 = v4Schema._zod) === null || _a2 === void 0 ? void 0 : _a2.def) === null || _b === void 0 ? void 0 : _b.type) === "optional";
30199
30210
  }
30200
30211
  const v3Schema = schema5;
30201
30212
  if (typeof schema5.isOptional === "function") {
@@ -30231,20 +30242,44 @@ function getLiteralValue(schema5) {
30231
30242
  return void 0;
30232
30243
  }
30233
30244
 
30234
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
30235
- var LATEST_PROTOCOL_VERSION = "2025-06-18";
30236
- var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
30245
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
30246
+ var LATEST_PROTOCOL_VERSION = "2025-11-25";
30247
+ var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
30248
+ var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
30237
30249
  var JSONRPC_VERSION = "2.0";
30238
30250
  var AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
30239
30251
  var ProgressTokenSchema = union([string2(), number2().int()]);
30240
30252
  var CursorSchema = string2();
30253
+ var TaskCreationParamsSchema = looseObject({
30254
+ /**
30255
+ * Time in milliseconds to keep task results available after completion.
30256
+ * If null, the task has unlimited lifetime until manually cleaned up.
30257
+ */
30258
+ ttl: union([number2(), _null3()]).optional(),
30259
+ /**
30260
+ * Time in milliseconds to wait between task status requests.
30261
+ */
30262
+ pollInterval: number2().optional()
30263
+ });
30264
+ var RelatedTaskMetadataSchema = looseObject({
30265
+ taskId: string2()
30266
+ });
30241
30267
  var RequestMetaSchema = looseObject({
30242
30268
  /**
30243
30269
  * 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
30270
  */
30245
- progressToken: ProgressTokenSchema.optional()
30271
+ progressToken: ProgressTokenSchema.optional(),
30272
+ /**
30273
+ * If specified, this request is related to the provided task.
30274
+ */
30275
+ [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
30246
30276
  });
30247
30277
  var BaseRequestParamsSchema = looseObject({
30278
+ /**
30279
+ * If specified, the caller is requesting that the receiver create a task to represent the request.
30280
+ * Task creation parameters are now at the top level instead of in _meta.
30281
+ */
30282
+ task: TaskCreationParamsSchema.optional(),
30248
30283
  /**
30249
30284
  * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
30250
30285
  */
@@ -30259,7 +30294,12 @@ var NotificationsParamsSchema = looseObject({
30259
30294
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30260
30295
  * for notes on _meta usage.
30261
30296
  */
30262
- _meta: record(string2(), unknown()).optional()
30297
+ _meta: object({
30298
+ /**
30299
+ * If specified, this notification is related to the provided task.
30300
+ */
30301
+ [RELATED_TASK_META_KEY]: optional(RelatedTaskMetadataSchema)
30302
+ }).passthrough().optional()
30263
30303
  });
30264
30304
  var NotificationSchema = object({
30265
30305
  method: string2(),
@@ -30270,7 +30310,12 @@ var ResultSchema = looseObject({
30270
30310
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30271
30311
  * for notes on _meta usage.
30272
30312
  */
30273
- _meta: record(string2(), unknown()).optional()
30313
+ _meta: looseObject({
30314
+ /**
30315
+ * If specified, this result is related to the provided task.
30316
+ */
30317
+ [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
30318
+ }).optional()
30274
30319
  });
30275
30320
  var RequestIdSchema = union([string2(), number2().int()]);
30276
30321
  var JSONRPCRequestSchema = object({
@@ -30405,6 +30450,54 @@ var ElicitationCapabilitySchema = preprocess((value) => {
30405
30450
  form: FormElicitationCapabilitySchema.optional(),
30406
30451
  url: AssertObjectSchema.optional()
30407
30452
  }), record(string2(), unknown()).optional()));
30453
+ var ClientTasksCapabilitySchema = object({
30454
+ /**
30455
+ * Present if the client supports listing tasks.
30456
+ */
30457
+ list: optional(object({}).passthrough()),
30458
+ /**
30459
+ * Present if the client supports cancelling tasks.
30460
+ */
30461
+ cancel: optional(object({}).passthrough()),
30462
+ /**
30463
+ * Capabilities for task creation on specific request types.
30464
+ */
30465
+ requests: optional(object({
30466
+ /**
30467
+ * Task support for sampling requests.
30468
+ */
30469
+ sampling: optional(object({
30470
+ createMessage: optional(object({}).passthrough())
30471
+ }).passthrough()),
30472
+ /**
30473
+ * Task support for elicitation requests.
30474
+ */
30475
+ elicitation: optional(object({
30476
+ create: optional(object({}).passthrough())
30477
+ }).passthrough())
30478
+ }).passthrough())
30479
+ }).passthrough();
30480
+ var ServerTasksCapabilitySchema = object({
30481
+ /**
30482
+ * Present if the server supports listing tasks.
30483
+ */
30484
+ list: optional(object({}).passthrough()),
30485
+ /**
30486
+ * Present if the server 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 tool requests.
30495
+ */
30496
+ tools: optional(object({
30497
+ call: optional(object({}).passthrough())
30498
+ }).passthrough())
30499
+ }).passthrough())
30500
+ }).passthrough();
30408
30501
  var ClientCapabilitiesSchema = object({
30409
30502
  /**
30410
30503
  * Experimental, non-standard capabilities that the client supports.
@@ -30436,7 +30529,11 @@ var ClientCapabilitiesSchema = object({
30436
30529
  * Whether the client supports issuing notifications for changes to the roots list.
30437
30530
  */
30438
30531
  listChanged: boolean2().optional()
30439
- }).optional()
30532
+ }).optional(),
30533
+ /**
30534
+ * Present if the client supports task creation.
30535
+ */
30536
+ tasks: optional(ClientTasksCapabilitySchema)
30440
30537
  });
30441
30538
  var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
30442
30539
  /**
@@ -30493,8 +30590,12 @@ var ServerCapabilitiesSchema = object({
30493
30590
  * Whether this server supports issuing notifications for changes to the tool list.
30494
30591
  */
30495
30592
  listChanged: boolean2().optional()
30496
- }).optional()
30497
- });
30593
+ }).optional(),
30594
+ /**
30595
+ * Present if the server supports task creation.
30596
+ */
30597
+ tasks: optional(ServerTasksCapabilitySchema)
30598
+ }).passthrough();
30498
30599
  var InitializeResultSchema = ResultSchema.extend({
30499
30600
  /**
30500
30601
  * 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 +30659,62 @@ var PaginatedResultSchema = ResultSchema.extend({
30558
30659
  */
30559
30660
  nextCursor: optional(CursorSchema)
30560
30661
  });
30662
+ var TaskSchema = object({
30663
+ taskId: string2(),
30664
+ status: _enum2(["working", "input_required", "completed", "failed", "cancelled"]),
30665
+ /**
30666
+ * Time in milliseconds to keep task results available after completion.
30667
+ * If null, the task has unlimited lifetime until manually cleaned up.
30668
+ */
30669
+ ttl: union([number2(), _null3()]),
30670
+ /**
30671
+ * ISO 8601 timestamp when the task was created.
30672
+ */
30673
+ createdAt: string2(),
30674
+ /**
30675
+ * ISO 8601 timestamp when the task was last updated.
30676
+ */
30677
+ lastUpdatedAt: string2(),
30678
+ pollInterval: optional(number2()),
30679
+ /**
30680
+ * Optional diagnostic message for failed tasks or other status information.
30681
+ */
30682
+ statusMessage: optional(string2())
30683
+ });
30684
+ var CreateTaskResultSchema = ResultSchema.extend({
30685
+ task: TaskSchema
30686
+ });
30687
+ var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
30688
+ var TaskStatusNotificationSchema = NotificationSchema.extend({
30689
+ method: literal("notifications/tasks/status"),
30690
+ params: TaskStatusNotificationParamsSchema
30691
+ });
30692
+ var GetTaskRequestSchema = RequestSchema.extend({
30693
+ method: literal("tasks/get"),
30694
+ params: BaseRequestParamsSchema.extend({
30695
+ taskId: string2()
30696
+ })
30697
+ });
30698
+ var GetTaskResultSchema = ResultSchema.merge(TaskSchema);
30699
+ var GetTaskPayloadRequestSchema = RequestSchema.extend({
30700
+ method: literal("tasks/result"),
30701
+ params: BaseRequestParamsSchema.extend({
30702
+ taskId: string2()
30703
+ })
30704
+ });
30705
+ var ListTasksRequestSchema = PaginatedRequestSchema.extend({
30706
+ method: literal("tasks/list")
30707
+ });
30708
+ var ListTasksResultSchema = PaginatedResultSchema.extend({
30709
+ tasks: array(TaskSchema)
30710
+ });
30711
+ var CancelTaskRequestSchema = RequestSchema.extend({
30712
+ method: literal("tasks/cancel"),
30713
+ params: BaseRequestParamsSchema.extend({
30714
+ taskId: string2()
30715
+ })
30716
+ });
30717
+ var CancelTaskResultSchema = ResultSchema.merge(TaskSchema);
30561
30718
  var ResourceContentsSchema = object({
30562
30719
  /**
30563
30720
  * The URI of this resource.
@@ -30593,6 +30750,20 @@ var BlobResourceContentsSchema = ResourceContentsSchema.extend({
30593
30750
  */
30594
30751
  blob: Base64Schema
30595
30752
  });
30753
+ var AnnotationsSchema = object({
30754
+ /**
30755
+ * Intended audience(s) for the resource.
30756
+ */
30757
+ audience: array(_enum2(["user", "assistant"])).optional(),
30758
+ /**
30759
+ * Importance hint for the resource, from 0 (least) to 1 (most).
30760
+ */
30761
+ priority: number2().min(0).max(1).optional(),
30762
+ /**
30763
+ * ISO 8601 timestamp for the most recent modification.
30764
+ */
30765
+ lastModified: iso_exports.datetime({ offset: true }).optional()
30766
+ });
30596
30767
  var ResourceSchema = object({
30597
30768
  ...BaseMetadataSchema.shape,
30598
30769
  ...IconsSchema.shape,
@@ -30610,6 +30781,10 @@ var ResourceSchema = object({
30610
30781
  * The MIME type of this resource, if known.
30611
30782
  */
30612
30783
  mimeType: optional(string2()),
30784
+ /**
30785
+ * Optional annotations for the client.
30786
+ */
30787
+ annotations: AnnotationsSchema.optional(),
30613
30788
  /**
30614
30789
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30615
30790
  * for notes on _meta usage.
@@ -30633,6 +30808,10 @@ var ResourceTemplateSchema = object({
30633
30808
  * 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
30809
  */
30635
30810
  mimeType: optional(string2()),
30811
+ /**
30812
+ * Optional annotations for the client.
30813
+ */
30814
+ annotations: AnnotationsSchema.optional(),
30636
30815
  /**
30637
30816
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30638
30817
  * for notes on _meta usage.
@@ -30747,6 +30926,10 @@ var TextContentSchema = object({
30747
30926
  * The text content of the message.
30748
30927
  */
30749
30928
  text: string2(),
30929
+ /**
30930
+ * Optional annotations for the client.
30931
+ */
30932
+ annotations: AnnotationsSchema.optional(),
30750
30933
  /**
30751
30934
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30752
30935
  * for notes on _meta usage.
@@ -30763,6 +30946,10 @@ var ImageContentSchema = object({
30763
30946
  * The MIME type of the image. Different providers may support different image types.
30764
30947
  */
30765
30948
  mimeType: string2(),
30949
+ /**
30950
+ * Optional annotations for the client.
30951
+ */
30952
+ annotations: AnnotationsSchema.optional(),
30766
30953
  /**
30767
30954
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30768
30955
  * for notes on _meta usage.
@@ -30779,6 +30966,10 @@ var AudioContentSchema = object({
30779
30966
  * The MIME type of the audio. Different providers may support different audio types.
30780
30967
  */
30781
30968
  mimeType: string2(),
30969
+ /**
30970
+ * Optional annotations for the client.
30971
+ */
30972
+ annotations: AnnotationsSchema.optional(),
30782
30973
  /**
30783
30974
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30784
30975
  * for notes on _meta usage.
@@ -30811,6 +31002,10 @@ var ToolUseContentSchema = object({
30811
31002
  var EmbeddedResourceSchema = object({
30812
31003
  type: literal("resource"),
30813
31004
  resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
31005
+ /**
31006
+ * Optional annotations for the client.
31007
+ */
31008
+ annotations: AnnotationsSchema.optional(),
30814
31009
  /**
30815
31010
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30816
31011
  * for notes on _meta usage.
@@ -30880,6 +31075,17 @@ var ToolAnnotationsSchema = object({
30880
31075
  */
30881
31076
  openWorldHint: boolean2().optional()
30882
31077
  });
31078
+ var ToolExecutionSchema = object({
31079
+ /**
31080
+ * Indicates the tool's preference for task-augmented execution.
31081
+ * - "required": Clients MUST invoke the tool as a task
31082
+ * - "optional": Clients MAY invoke the tool as a task or normal request
31083
+ * - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
31084
+ *
31085
+ * If not present, defaults to "forbidden".
31086
+ */
31087
+ taskSupport: _enum2(["required", "optional", "forbidden"]).optional()
31088
+ });
30883
31089
  var ToolSchema = object({
30884
31090
  ...BaseMetadataSchema.shape,
30885
31091
  ...IconsSchema.shape,
@@ -30910,6 +31116,10 @@ var ToolSchema = object({
30910
31116
  * Optional additional tool information.
30911
31117
  */
30912
31118
  annotations: optional(ToolAnnotationsSchema),
31119
+ /**
31120
+ * Execution-related properties for this tool.
31121
+ */
31122
+ execution: optional(ToolExecutionSchema),
30913
31123
  /**
30914
31124
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
30915
31125
  * for notes on _meta usage.
@@ -31046,6 +31256,7 @@ var ToolResultContentSchema = object({
31046
31256
  */
31047
31257
  _meta: optional(object({}).passthrough())
31048
31258
  }).passthrough();
31259
+ var SamplingContentSchema = discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
31049
31260
  var SamplingMessageContentBlockSchema = discriminatedUnion("type", [
31050
31261
  TextContentSchema,
31051
31262
  ImageContentSchema,
@@ -31109,6 +31320,28 @@ var CreateMessageRequestSchema = RequestSchema.extend({
31109
31320
  params: CreateMessageRequestParamsSchema
31110
31321
  });
31111
31322
  var CreateMessageResultSchema = ResultSchema.extend({
31323
+ /**
31324
+ * The name of the model that generated the message.
31325
+ */
31326
+ model: string2(),
31327
+ /**
31328
+ * The reason why sampling stopped, if known.
31329
+ *
31330
+ * Standard values:
31331
+ * - "endTurn": Natural end of the assistant's turn
31332
+ * - "stopSequence": A stop sequence was encountered
31333
+ * - "maxTokens": Maximum token limit was reached
31334
+ *
31335
+ * This field is an open string to allow for provider-specific stop reasons.
31336
+ */
31337
+ stopReason: optional(_enum2(["endTurn", "stopSequence", "maxTokens"]).or(string2())),
31338
+ role: _enum2(["user", "assistant"]),
31339
+ /**
31340
+ * Response content. Single content block (text, image, or audio).
31341
+ */
31342
+ content: SamplingContentSchema
31343
+ });
31344
+ var CreateMessageResultWithToolsSchema = ResultSchema.extend({
31112
31345
  /**
31113
31346
  * The name of the model that generated the message.
31114
31347
  */
@@ -31127,7 +31360,7 @@ var CreateMessageResultSchema = ResultSchema.extend({
31127
31360
  stopReason: optional(_enum2(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(string2())),
31128
31361
  role: _enum2(["user", "assistant"]),
31129
31362
  /**
31130
- * Response content. May be ToolUseContent if stopReason is "toolUse".
31363
+ * Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
31131
31364
  */
31132
31365
  content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
31133
31366
  });
@@ -31275,8 +31508,10 @@ var ElicitResultSchema = ResultSchema.extend({
31275
31508
  /**
31276
31509
  * The submitted form data, only present when action is "accept".
31277
31510
  * Contains values matching the requested schema.
31511
+ * Per MCP spec, content is "typically omitted" for decline/cancel actions.
31512
+ * We normalize null to undefined for leniency while maintaining type compatibility.
31278
31513
  */
31279
- content: record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional()
31514
+ content: preprocess((val) => val === null ? void 0 : val, record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional())
31280
31515
  });
31281
31516
  var ResourceTemplateReferenceSchema = object({
31282
31517
  type: literal("ref/resource"),
@@ -31383,16 +31618,37 @@ var ClientRequestSchema = union([
31383
31618
  SubscribeRequestSchema,
31384
31619
  UnsubscribeRequestSchema,
31385
31620
  CallToolRequestSchema,
31386
- ListToolsRequestSchema
31621
+ ListToolsRequestSchema,
31622
+ GetTaskRequestSchema,
31623
+ GetTaskPayloadRequestSchema,
31624
+ ListTasksRequestSchema
31387
31625
  ]);
31388
31626
  var ClientNotificationSchema = union([
31389
31627
  CancelledNotificationSchema,
31390
31628
  ProgressNotificationSchema,
31391
31629
  InitializedNotificationSchema,
31392
- RootsListChangedNotificationSchema
31630
+ RootsListChangedNotificationSchema,
31631
+ TaskStatusNotificationSchema
31632
+ ]);
31633
+ var ClientResultSchema = union([
31634
+ EmptyResultSchema,
31635
+ CreateMessageResultSchema,
31636
+ CreateMessageResultWithToolsSchema,
31637
+ ElicitResultSchema,
31638
+ ListRootsResultSchema,
31639
+ GetTaskResultSchema,
31640
+ ListTasksResultSchema,
31641
+ CreateTaskResultSchema
31642
+ ]);
31643
+ var ServerRequestSchema = union([
31644
+ PingRequestSchema,
31645
+ CreateMessageRequestSchema,
31646
+ ElicitRequestSchema,
31647
+ ListRootsRequestSchema,
31648
+ GetTaskRequestSchema,
31649
+ GetTaskPayloadRequestSchema,
31650
+ ListTasksRequestSchema
31393
31651
  ]);
31394
- var ClientResultSchema = union([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
31395
- var ServerRequestSchema = union([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
31396
31652
  var ServerNotificationSchema = union([
31397
31653
  CancelledNotificationSchema,
31398
31654
  ProgressNotificationSchema,
@@ -31401,6 +31657,7 @@ var ServerNotificationSchema = union([
31401
31657
  ResourceListChangedNotificationSchema,
31402
31658
  ToolListChangedNotificationSchema,
31403
31659
  PromptListChangedNotificationSchema,
31660
+ TaskStatusNotificationSchema,
31404
31661
  ElicitationCompleteNotificationSchema
31405
31662
  ]);
31406
31663
  var ServerResultSchema = union([
@@ -31413,7 +31670,10 @@ var ServerResultSchema = union([
31413
31670
  ListResourceTemplatesResultSchema,
31414
31671
  ReadResourceResultSchema,
31415
31672
  CallToolResultSchema,
31416
- ListToolsResultSchema
31673
+ ListToolsResultSchema,
31674
+ GetTaskResultSchema,
31675
+ ListTasksResultSchema,
31676
+ CreateTaskResultSchema
31417
31677
  ]);
31418
31678
  var McpError = class _McpError extends Error {
31419
31679
  constructor(code, message, data) {
@@ -31447,8 +31707,13 @@ var UrlElicitationRequiredError = class extends McpError {
31447
31707
  }
31448
31708
  };
31449
31709
 
31710
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
31711
+ function isTerminal(status) {
31712
+ return status === "completed" || status === "failed" || status === "cancelled";
31713
+ }
31714
+
31450
31715
  // ../../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");
31716
+ var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
31452
31717
  var defaultOptions = {
31453
31718
  name: void 0,
31454
31719
  $refStrategy: "root",
@@ -32731,7 +32996,7 @@ var zodToJsonSchema = (schema5, options) => {
32731
32996
  return combined;
32732
32997
  };
32733
32998
 
32734
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
32999
+ // ../../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
33000
  function mapMiniTarget(t) {
32736
33001
  if (!t)
32737
33002
  return "draft-7";
@@ -32774,7 +33039,7 @@ function parseWithCompat(schema5, data) {
32774
33039
  return result.data;
32775
33040
  }
32776
33041
 
32777
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
33042
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
32778
33043
  var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
32779
33044
  var Protocol = class {
32780
33045
  constructor(_options) {
@@ -32787,9 +33052,10 @@ var Protocol = class {
32787
33052
  this._progressHandlers = /* @__PURE__ */ new Map();
32788
33053
  this._timeoutInfo = /* @__PURE__ */ new Map();
32789
33054
  this._pendingDebouncedNotifications = /* @__PURE__ */ new Set();
33055
+ this._taskProgressTokens = /* @__PURE__ */ new Map();
33056
+ this._requestResolvers = /* @__PURE__ */ new Map();
32790
33057
  this.setNotificationHandler(CancelledNotificationSchema, (notification) => {
32791
- const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
32792
- controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
33058
+ this._oncancel(notification);
32793
33059
  });
32794
33060
  this.setNotificationHandler(ProgressNotificationSchema, (notification) => {
32795
33061
  this._onprogress(notification);
@@ -32799,6 +33065,116 @@ var Protocol = class {
32799
33065
  // Automatic pong by default.
32800
33066
  (_request) => ({})
32801
33067
  );
33068
+ this._taskStore = _options === null || _options === void 0 ? void 0 : _options.taskStore;
33069
+ this._taskMessageQueue = _options === null || _options === void 0 ? void 0 : _options.taskMessageQueue;
33070
+ if (this._taskStore) {
33071
+ this.setRequestHandler(GetTaskRequestSchema, async (request2, extra) => {
33072
+ const task = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
33073
+ if (!task) {
33074
+ throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
33075
+ }
33076
+ return {
33077
+ ...task
33078
+ };
33079
+ });
33080
+ this.setRequestHandler(GetTaskPayloadRequestSchema, async (request2, extra) => {
33081
+ const handleTaskResult = async () => {
33082
+ var _a2;
33083
+ const taskId = request2.params.taskId;
33084
+ if (this._taskMessageQueue) {
33085
+ let queuedMessage;
33086
+ while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
33087
+ if (queuedMessage.type === "response" || queuedMessage.type === "error") {
33088
+ const message = queuedMessage.message;
33089
+ const requestId = message.id;
33090
+ const resolver = this._requestResolvers.get(requestId);
33091
+ if (resolver) {
33092
+ this._requestResolvers.delete(requestId);
33093
+ if (queuedMessage.type === "response") {
33094
+ resolver(message);
33095
+ } else {
33096
+ const errorMessage = message;
33097
+ const error46 = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
33098
+ resolver(error46);
33099
+ }
33100
+ } else {
33101
+ const messageType = queuedMessage.type === "response" ? "Response" : "Error";
33102
+ this._onerror(new Error(`${messageType} handler missing for request ${requestId}`));
33103
+ }
33104
+ continue;
33105
+ }
33106
+ await ((_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send(queuedMessage.message, { relatedRequestId: extra.requestId }));
33107
+ }
33108
+ }
33109
+ const task = await this._taskStore.getTask(taskId, extra.sessionId);
33110
+ if (!task) {
33111
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
33112
+ }
33113
+ if (!isTerminal(task.status)) {
33114
+ await this._waitForTaskUpdate(taskId, extra.signal);
33115
+ return await handleTaskResult();
33116
+ }
33117
+ if (isTerminal(task.status)) {
33118
+ const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
33119
+ this._clearTaskQueue(taskId);
33120
+ return {
33121
+ ...result,
33122
+ _meta: {
33123
+ ...result._meta,
33124
+ [RELATED_TASK_META_KEY]: {
33125
+ taskId
33126
+ }
33127
+ }
33128
+ };
33129
+ }
33130
+ return await handleTaskResult();
33131
+ };
33132
+ return await handleTaskResult();
33133
+ });
33134
+ this.setRequestHandler(ListTasksRequestSchema, async (request2, extra) => {
33135
+ var _a2;
33136
+ try {
33137
+ const { tasks, nextCursor } = await this._taskStore.listTasks((_a2 = request2.params) === null || _a2 === void 0 ? void 0 : _a2.cursor, extra.sessionId);
33138
+ return {
33139
+ tasks,
33140
+ nextCursor,
33141
+ _meta: {}
33142
+ };
33143
+ } catch (error46) {
33144
+ throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error46 instanceof Error ? error46.message : String(error46)}`);
33145
+ }
33146
+ });
33147
+ this.setRequestHandler(CancelTaskRequestSchema, async (request2, extra) => {
33148
+ try {
33149
+ const task = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
33150
+ if (!task) {
33151
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request2.params.taskId}`);
33152
+ }
33153
+ if (isTerminal(task.status)) {
33154
+ throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
33155
+ }
33156
+ await this._taskStore.updateTaskStatus(request2.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
33157
+ this._clearTaskQueue(request2.params.taskId);
33158
+ const cancelledTask = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
33159
+ if (!cancelledTask) {
33160
+ throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request2.params.taskId}`);
33161
+ }
33162
+ return {
33163
+ _meta: {},
33164
+ ...cancelledTask
33165
+ };
33166
+ } catch (error46) {
33167
+ if (error46 instanceof McpError) {
33168
+ throw error46;
33169
+ }
33170
+ throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error46 instanceof Error ? error46.message : String(error46)}`);
33171
+ }
33172
+ });
33173
+ }
33174
+ }
33175
+ async _oncancel(notification) {
33176
+ const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
33177
+ controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
32802
33178
  }
32803
33179
  _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
32804
33180
  this._timeoutInfo.set(messageId, {
@@ -32871,10 +33247,11 @@ var Protocol = class {
32871
33247
  const responseHandlers = this._responseHandlers;
32872
33248
  this._responseHandlers = /* @__PURE__ */ new Map();
32873
33249
  this._progressHandlers.clear();
33250
+ this._taskProgressTokens.clear();
32874
33251
  this._pendingDebouncedNotifications.clear();
33252
+ const error46 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
32875
33253
  this._transport = void 0;
32876
33254
  (_a2 = this.onclose) === null || _a2 === void 0 ? void 0 : _a2.call(this);
32877
- const error46 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
32878
33255
  for (const handler2 of responseHandlers.values()) {
32879
33256
  handler2(error46);
32880
33257
  }
@@ -32892,47 +33269,94 @@ var Protocol = class {
32892
33269
  Promise.resolve().then(() => handler2(notification)).catch((error46) => this._onerror(new Error(`Uncaught error in notification handler: ${error46}`)));
32893
33270
  }
32894
33271
  _onrequest(request2, extra) {
32895
- var _a2, _b;
33272
+ var _a2, _b, _c, _d, _e, _f;
32896
33273
  const handler2 = (_a2 = this._requestHandlers.get(request2.method)) !== null && _a2 !== void 0 ? _a2 : this.fallbackRequestHandler;
32897
33274
  const capturedTransport = this._transport;
33275
+ 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
33276
  if (handler2 === void 0) {
32899
- capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
33277
+ const errorResponse = {
32900
33278
  jsonrpc: "2.0",
32901
33279
  id: request2.id,
32902
33280
  error: {
32903
33281
  code: ErrorCode.MethodNotFound,
32904
33282
  message: "Method not found"
32905
33283
  }
32906
- }).catch((error46) => this._onerror(new Error(`Failed to send an error response: ${error46}`)));
33284
+ };
33285
+ if (relatedTaskId && this._taskMessageQueue) {
33286
+ this._enqueueTaskMessage(relatedTaskId, {
33287
+ type: "error",
33288
+ message: errorResponse,
33289
+ timestamp: Date.now()
33290
+ }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId).catch((error46) => this._onerror(new Error(`Failed to enqueue error response: ${error46}`)));
33291
+ } else {
33292
+ capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse).catch((error46) => this._onerror(new Error(`Failed to send an error response: ${error46}`)));
33293
+ }
32907
33294
  return;
32908
33295
  }
32909
33296
  const abortController = new AbortController();
32910
33297
  this._requestHandlerAbortControllers.set(request2.id, abortController);
33298
+ const taskCreationParams = (_e = request2.params) === null || _e === void 0 ? void 0 : _e.task;
33299
+ const taskStore = this._taskStore ? this.requestTaskStore(request2, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId) : void 0;
32911
33300
  const fullExtra = {
32912
33301
  signal: abortController.signal,
32913
33302
  sessionId: capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId,
32914
- _meta: (_b = request2.params) === null || _b === void 0 ? void 0 : _b._meta,
32915
- sendNotification: (notification) => this.notification(notification, { relatedRequestId: request2.id }),
32916
- sendRequest: (r, resultSchema, options) => this.request(r, resultSchema, { ...options, relatedRequestId: request2.id }),
33303
+ _meta: (_f = request2.params) === null || _f === void 0 ? void 0 : _f._meta,
33304
+ sendNotification: async (notification) => {
33305
+ const notificationOptions = { relatedRequestId: request2.id };
33306
+ if (relatedTaskId) {
33307
+ notificationOptions.relatedTask = { taskId: relatedTaskId };
33308
+ }
33309
+ await this.notification(notification, notificationOptions);
33310
+ },
33311
+ sendRequest: async (r, resultSchema, options) => {
33312
+ var _a3, _b2;
33313
+ const requestOptions = { ...options, relatedRequestId: request2.id };
33314
+ if (relatedTaskId && !requestOptions.relatedTask) {
33315
+ requestOptions.relatedTask = { taskId: relatedTaskId };
33316
+ }
33317
+ const effectiveTaskId = (_b2 = (_a3 = requestOptions.relatedTask) === null || _a3 === void 0 ? void 0 : _a3.taskId) !== null && _b2 !== void 0 ? _b2 : relatedTaskId;
33318
+ if (effectiveTaskId && taskStore) {
33319
+ await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
33320
+ }
33321
+ return await this.request(r, resultSchema, requestOptions);
33322
+ },
32917
33323
  authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
32918
33324
  requestId: request2.id,
32919
- requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo
33325
+ requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo,
33326
+ taskId: relatedTaskId,
33327
+ taskStore,
33328
+ taskRequestedTtl: taskCreationParams === null || taskCreationParams === void 0 ? void 0 : taskCreationParams.ttl,
33329
+ closeSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeSSEStream,
33330
+ closeStandaloneSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeStandaloneSSEStream
32920
33331
  };
32921
- Promise.resolve().then(() => handler2(request2, fullExtra)).then((result) => {
33332
+ Promise.resolve().then(() => {
33333
+ if (taskCreationParams) {
33334
+ this.assertTaskHandlerCapability(request2.method);
33335
+ }
33336
+ }).then(() => handler2(request2, fullExtra)).then(async (result) => {
32922
33337
  if (abortController.signal.aborted) {
32923
33338
  return;
32924
33339
  }
32925
- return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
33340
+ const response = {
32926
33341
  result,
32927
33342
  jsonrpc: "2.0",
32928
33343
  id: request2.id
32929
- });
32930
- }, (error46) => {
33344
+ };
33345
+ if (relatedTaskId && this._taskMessageQueue) {
33346
+ await this._enqueueTaskMessage(relatedTaskId, {
33347
+ type: "response",
33348
+ message: response,
33349
+ timestamp: Date.now()
33350
+ }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
33351
+ } else {
33352
+ await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(response));
33353
+ }
33354
+ }, async (error46) => {
32931
33355
  var _a3;
32932
33356
  if (abortController.signal.aborted) {
32933
33357
  return;
32934
33358
  }
32935
- return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
33359
+ const errorResponse = {
32936
33360
  jsonrpc: "2.0",
32937
33361
  id: request2.id,
32938
33362
  error: {
@@ -32940,7 +33364,16 @@ var Protocol = class {
32940
33364
  message: (_a3 = error46.message) !== null && _a3 !== void 0 ? _a3 : "Internal error",
32941
33365
  ...error46["data"] !== void 0 && { data: error46["data"] }
32942
33366
  }
32943
- });
33367
+ };
33368
+ if (relatedTaskId && this._taskMessageQueue) {
33369
+ await this._enqueueTaskMessage(relatedTaskId, {
33370
+ type: "error",
33371
+ message: errorResponse,
33372
+ timestamp: Date.now()
33373
+ }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
33374
+ } else {
33375
+ await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse));
33376
+ }
32944
33377
  }).catch((error46) => this._onerror(new Error(`Failed to send response: ${error46}`))).finally(() => {
32945
33378
  this._requestHandlerAbortControllers.delete(request2.id);
32946
33379
  });
@@ -32959,6 +33392,9 @@ var Protocol = class {
32959
33392
  try {
32960
33393
  this._resetTimeout(messageId);
32961
33394
  } catch (error46) {
33395
+ this._responseHandlers.delete(messageId);
33396
+ this._progressHandlers.delete(messageId);
33397
+ this._cleanupTimeout(messageId);
32962
33398
  responseHandler(error46);
32963
33399
  return;
32964
33400
  }
@@ -32967,14 +33403,38 @@ var Protocol = class {
32967
33403
  }
32968
33404
  _onresponse(response) {
32969
33405
  const messageId = Number(response.id);
33406
+ const resolver = this._requestResolvers.get(messageId);
33407
+ if (resolver) {
33408
+ this._requestResolvers.delete(messageId);
33409
+ if (isJSONRPCResponse(response)) {
33410
+ resolver(response);
33411
+ } else {
33412
+ const error46 = new McpError(response.error.code, response.error.message, response.error.data);
33413
+ resolver(error46);
33414
+ }
33415
+ return;
33416
+ }
32970
33417
  const handler2 = this._responseHandlers.get(messageId);
32971
33418
  if (handler2 === void 0) {
32972
33419
  this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(response)}`));
32973
33420
  return;
32974
33421
  }
32975
33422
  this._responseHandlers.delete(messageId);
32976
- this._progressHandlers.delete(messageId);
32977
33423
  this._cleanupTimeout(messageId);
33424
+ let isTaskResponse = false;
33425
+ if (isJSONRPCResponse(response) && response.result && typeof response.result === "object") {
33426
+ const result = response.result;
33427
+ if (result.task && typeof result.task === "object") {
33428
+ const task = result.task;
33429
+ if (typeof task.taskId === "string") {
33430
+ isTaskResponse = true;
33431
+ this._taskProgressTokens.set(task.taskId, messageId);
33432
+ }
33433
+ }
33434
+ }
33435
+ if (!isTaskResponse) {
33436
+ this._progressHandlers.delete(messageId);
33437
+ }
32978
33438
  if (isJSONRPCResponse(response)) {
32979
33439
  handler2(response);
32980
33440
  } else {
@@ -32993,20 +33453,118 @@ var Protocol = class {
32993
33453
  await ((_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.close());
32994
33454
  }
32995
33455
  /**
32996
- * Sends a request and wait for a response.
33456
+ * Sends a request and returns an AsyncGenerator that yields response messages.
33457
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
33458
+ *
33459
+ * @example
33460
+ * ```typescript
33461
+ * const stream = protocol.requestStream(request, resultSchema, options);
33462
+ * for await (const message of stream) {
33463
+ * switch (message.type) {
33464
+ * case 'taskCreated':
33465
+ * console.log('Task created:', message.task.taskId);
33466
+ * break;
33467
+ * case 'taskStatus':
33468
+ * console.log('Task status:', message.task.status);
33469
+ * break;
33470
+ * case 'result':
33471
+ * console.log('Final result:', message.result);
33472
+ * break;
33473
+ * case 'error':
33474
+ * console.error('Error:', message.error);
33475
+ * break;
33476
+ * }
33477
+ * }
33478
+ * ```
33479
+ *
33480
+ * @experimental Use `client.experimental.tasks.requestStream()` to access this method.
33481
+ */
33482
+ async *requestStream(request2, resultSchema, options) {
33483
+ var _a2, _b, _c, _d;
33484
+ const { task } = options !== null && options !== void 0 ? options : {};
33485
+ if (!task) {
33486
+ try {
33487
+ const result = await this.request(request2, resultSchema, options);
33488
+ yield { type: "result", result };
33489
+ } catch (error46) {
33490
+ yield {
33491
+ type: "error",
33492
+ error: error46 instanceof McpError ? error46 : new McpError(ErrorCode.InternalError, String(error46))
33493
+ };
33494
+ }
33495
+ return;
33496
+ }
33497
+ let taskId;
33498
+ try {
33499
+ const createResult = await this.request(request2, CreateTaskResultSchema, options);
33500
+ if (createResult.task) {
33501
+ taskId = createResult.task.taskId;
33502
+ yield { type: "taskCreated", task: createResult.task };
33503
+ } else {
33504
+ throw new McpError(ErrorCode.InternalError, "Task creation did not return a task");
33505
+ }
33506
+ while (true) {
33507
+ const task2 = await this.getTask({ taskId }, options);
33508
+ yield { type: "taskStatus", task: task2 };
33509
+ if (isTerminal(task2.status)) {
33510
+ if (task2.status === "completed") {
33511
+ const result = await this.getTaskResult({ taskId }, resultSchema, options);
33512
+ yield { type: "result", result };
33513
+ } else if (task2.status === "failed") {
33514
+ yield {
33515
+ type: "error",
33516
+ error: new McpError(ErrorCode.InternalError, `Task ${taskId} failed`)
33517
+ };
33518
+ } else if (task2.status === "cancelled") {
33519
+ yield {
33520
+ type: "error",
33521
+ error: new McpError(ErrorCode.InternalError, `Task ${taskId} was cancelled`)
33522
+ };
33523
+ }
33524
+ return;
33525
+ }
33526
+ if (task2.status === "input_required") {
33527
+ const result = await this.getTaskResult({ taskId }, resultSchema, options);
33528
+ yield { type: "result", result };
33529
+ return;
33530
+ }
33531
+ 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;
33532
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
33533
+ (_d = options === null || options === void 0 ? void 0 : options.signal) === null || _d === void 0 ? void 0 : _d.throwIfAborted();
33534
+ }
33535
+ } catch (error46) {
33536
+ yield {
33537
+ type: "error",
33538
+ error: error46 instanceof McpError ? error46 : new McpError(ErrorCode.InternalError, String(error46))
33539
+ };
33540
+ }
33541
+ }
33542
+ /**
33543
+ * Sends a request and waits for a response.
32997
33544
  *
32998
33545
  * Do not use this method to emit notifications! Use notification() instead.
32999
33546
  */
33000
33547
  request(request2, resultSchema, options) {
33001
- const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== void 0 ? options : {};
33548
+ const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options !== null && options !== void 0 ? options : {};
33002
33549
  return new Promise((resolve2, reject) => {
33003
- var _a2, _b, _c, _d, _e, _f;
33550
+ var _a2, _b, _c, _d, _e, _f, _g;
33551
+ const earlyReject = (error46) => {
33552
+ reject(error46);
33553
+ };
33004
33554
  if (!this._transport) {
33005
- reject(new Error("Not connected"));
33555
+ earlyReject(new Error("Not connected"));
33006
33556
  return;
33007
33557
  }
33008
33558
  if (((_a2 = this._options) === null || _a2 === void 0 ? void 0 : _a2.enforceStrictCapabilities) === true) {
33009
- this.assertCapabilityForMethod(request2.method);
33559
+ try {
33560
+ this.assertCapabilityForMethod(request2.method);
33561
+ if (task) {
33562
+ this.assertTaskCapability(request2.method);
33563
+ }
33564
+ } catch (e) {
33565
+ earlyReject(e);
33566
+ return;
33567
+ }
33010
33568
  }
33011
33569
  (_b = options === null || options === void 0 ? void 0 : options.signal) === null || _b === void 0 ? void 0 : _b.throwIfAborted();
33012
33570
  const messageId = this._requestMessageId++;
@@ -33025,6 +33583,21 @@ var Protocol = class {
33025
33583
  }
33026
33584
  };
33027
33585
  }
33586
+ if (task) {
33587
+ jsonrpcRequest.params = {
33588
+ ...jsonrpcRequest.params,
33589
+ task
33590
+ };
33591
+ }
33592
+ if (relatedTask) {
33593
+ jsonrpcRequest.params = {
33594
+ ...jsonrpcRequest.params,
33595
+ _meta: {
33596
+ ...((_d = jsonrpcRequest.params) === null || _d === void 0 ? void 0 : _d._meta) || {},
33597
+ [RELATED_TASK_META_KEY]: relatedTask
33598
+ }
33599
+ };
33600
+ }
33028
33601
  const cancel = (reason) => {
33029
33602
  var _a3;
33030
33603
  this._responseHandlers.delete(messageId);
@@ -33037,8 +33610,9 @@ var Protocol = class {
33037
33610
  requestId: messageId,
33038
33611
  reason: String(reason)
33039
33612
  }
33040
- }, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error46) => this._onerror(new Error(`Failed to send cancellation: ${error46}`)));
33041
- reject(reason);
33613
+ }, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error47) => this._onerror(new Error(`Failed to send cancellation: ${error47}`)));
33614
+ const error46 = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
33615
+ reject(error46);
33042
33616
  };
33043
33617
  this._responseHandlers.set(messageId, (response) => {
33044
33618
  var _a3;
@@ -33059,53 +33633,150 @@ var Protocol = class {
33059
33633
  reject(error46);
33060
33634
  }
33061
33635
  });
33062
- (_d = options === null || options === void 0 ? void 0 : options.signal) === null || _d === void 0 ? void 0 : _d.addEventListener("abort", () => {
33636
+ (_e = options === null || options === void 0 ? void 0 : options.signal) === null || _e === void 0 ? void 0 : _e.addEventListener("abort", () => {
33063
33637
  var _a3;
33064
33638
  cancel((_a3 = options === null || options === void 0 ? void 0 : options.signal) === null || _a3 === void 0 ? void 0 : _a3.reason);
33065
33639
  });
33066
- const timeout = (_e = options === null || options === void 0 ? void 0 : options.timeout) !== null && _e !== void 0 ? _e : DEFAULT_REQUEST_TIMEOUT_MSEC;
33640
+ const timeout = (_f = options === null || options === void 0 ? void 0 : options.timeout) !== null && _f !== void 0 ? _f : DEFAULT_REQUEST_TIMEOUT_MSEC;
33067
33641
  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, (_f = options === null || options === void 0 ? void 0 : options.resetTimeoutOnProgress) !== null && _f !== void 0 ? _f : false);
33069
- this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error46) => {
33070
- this._cleanupTimeout(messageId);
33071
- reject(error46);
33072
- });
33642
+ 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);
33643
+ const relatedTaskId = relatedTask === null || relatedTask === void 0 ? void 0 : relatedTask.taskId;
33644
+ if (relatedTaskId) {
33645
+ const responseResolver = (response) => {
33646
+ const handler2 = this._responseHandlers.get(messageId);
33647
+ if (handler2) {
33648
+ handler2(response);
33649
+ } else {
33650
+ this._onerror(new Error(`Response handler missing for side-channeled request ${messageId}`));
33651
+ }
33652
+ };
33653
+ this._requestResolvers.set(messageId, responseResolver);
33654
+ this._enqueueTaskMessage(relatedTaskId, {
33655
+ type: "request",
33656
+ message: jsonrpcRequest,
33657
+ timestamp: Date.now()
33658
+ }).catch((error46) => {
33659
+ this._cleanupTimeout(messageId);
33660
+ reject(error46);
33661
+ });
33662
+ } else {
33663
+ this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error46) => {
33664
+ this._cleanupTimeout(messageId);
33665
+ reject(error46);
33666
+ });
33667
+ }
33073
33668
  });
33074
33669
  }
33670
+ /**
33671
+ * Gets the current status of a task.
33672
+ *
33673
+ * @experimental Use `client.experimental.tasks.getTask()` to access this method.
33674
+ */
33675
+ async getTask(params, options) {
33676
+ return this.request({ method: "tasks/get", params }, GetTaskResultSchema, options);
33677
+ }
33678
+ /**
33679
+ * Retrieves the result of a completed task.
33680
+ *
33681
+ * @experimental Use `client.experimental.tasks.getTaskResult()` to access this method.
33682
+ */
33683
+ async getTaskResult(params, resultSchema, options) {
33684
+ return this.request({ method: "tasks/result", params }, resultSchema, options);
33685
+ }
33686
+ /**
33687
+ * Lists tasks, optionally starting from a pagination cursor.
33688
+ *
33689
+ * @experimental Use `client.experimental.tasks.listTasks()` to access this method.
33690
+ */
33691
+ async listTasks(params, options) {
33692
+ return this.request({ method: "tasks/list", params }, ListTasksResultSchema, options);
33693
+ }
33694
+ /**
33695
+ * Cancels a specific task.
33696
+ *
33697
+ * @experimental Use `client.experimental.tasks.cancelTask()` to access this method.
33698
+ */
33699
+ async cancelTask(params, options) {
33700
+ return this.request({ method: "tasks/cancel", params }, CancelTaskResultSchema, options);
33701
+ }
33075
33702
  /**
33076
33703
  * Emits a notification, which is a one-way message that does not expect a response.
33077
33704
  */
33078
33705
  async notification(notification, options) {
33079
- var _a2, _b;
33706
+ var _a2, _b, _c, _d, _e;
33080
33707
  if (!this._transport) {
33081
33708
  throw new Error("Not connected");
33082
33709
  }
33083
33710
  this.assertNotificationCapability(notification.method);
33084
- const debouncedMethods = (_b = (_a2 = this._options) === null || _a2 === void 0 ? void 0 : _a2.debouncedNotificationMethods) !== null && _b !== void 0 ? _b : [];
33085
- const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !(options === null || options === void 0 ? void 0 : options.relatedRequestId);
33711
+ const relatedTaskId = (_a2 = options === null || options === void 0 ? void 0 : options.relatedTask) === null || _a2 === void 0 ? void 0 : _a2.taskId;
33712
+ if (relatedTaskId) {
33713
+ const jsonrpcNotification2 = {
33714
+ ...notification,
33715
+ jsonrpc: "2.0",
33716
+ params: {
33717
+ ...notification.params,
33718
+ _meta: {
33719
+ ...((_b = notification.params) === null || _b === void 0 ? void 0 : _b._meta) || {},
33720
+ [RELATED_TASK_META_KEY]: options.relatedTask
33721
+ }
33722
+ }
33723
+ };
33724
+ await this._enqueueTaskMessage(relatedTaskId, {
33725
+ type: "notification",
33726
+ message: jsonrpcNotification2,
33727
+ timestamp: Date.now()
33728
+ });
33729
+ return;
33730
+ }
33731
+ const debouncedMethods = (_d = (_c = this._options) === null || _c === void 0 ? void 0 : _c.debouncedNotificationMethods) !== null && _d !== void 0 ? _d : [];
33732
+ 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
33733
  if (canDebounce) {
33087
33734
  if (this._pendingDebouncedNotifications.has(notification.method)) {
33088
33735
  return;
33089
33736
  }
33090
33737
  this._pendingDebouncedNotifications.add(notification.method);
33091
33738
  Promise.resolve().then(() => {
33092
- var _a3;
33739
+ var _a3, _b2;
33093
33740
  this._pendingDebouncedNotifications.delete(notification.method);
33094
33741
  if (!this._transport) {
33095
33742
  return;
33096
33743
  }
33097
- const jsonrpcNotification2 = {
33744
+ let jsonrpcNotification2 = {
33098
33745
  ...notification,
33099
33746
  jsonrpc: "2.0"
33100
33747
  };
33101
- (_a3 = this._transport) === null || _a3 === void 0 ? void 0 : _a3.send(jsonrpcNotification2, options).catch((error46) => this._onerror(error46));
33748
+ if (options === null || options === void 0 ? void 0 : options.relatedTask) {
33749
+ jsonrpcNotification2 = {
33750
+ ...jsonrpcNotification2,
33751
+ params: {
33752
+ ...jsonrpcNotification2.params,
33753
+ _meta: {
33754
+ ...((_a3 = jsonrpcNotification2.params) === null || _a3 === void 0 ? void 0 : _a3._meta) || {},
33755
+ [RELATED_TASK_META_KEY]: options.relatedTask
33756
+ }
33757
+ }
33758
+ };
33759
+ }
33760
+ (_b2 = this._transport) === null || _b2 === void 0 ? void 0 : _b2.send(jsonrpcNotification2, options).catch((error46) => this._onerror(error46));
33102
33761
  });
33103
33762
  return;
33104
33763
  }
33105
- const jsonrpcNotification = {
33764
+ let jsonrpcNotification = {
33106
33765
  ...notification,
33107
33766
  jsonrpc: "2.0"
33108
33767
  };
33768
+ if (options === null || options === void 0 ? void 0 : options.relatedTask) {
33769
+ jsonrpcNotification = {
33770
+ ...jsonrpcNotification,
33771
+ params: {
33772
+ ...jsonrpcNotification.params,
33773
+ _meta: {
33774
+ ...((_e = jsonrpcNotification.params) === null || _e === void 0 ? void 0 : _e._meta) || {},
33775
+ [RELATED_TASK_META_KEY]: options.relatedTask
33776
+ }
33777
+ }
33778
+ };
33779
+ }
33109
33780
  await this._transport.send(jsonrpcNotification, options);
33110
33781
  }
33111
33782
  /**
@@ -33153,6 +33824,152 @@ var Protocol = class {
33153
33824
  removeNotificationHandler(method) {
33154
33825
  this._notificationHandlers.delete(method);
33155
33826
  }
33827
+ /**
33828
+ * Cleans up the progress handler associated with a task.
33829
+ * This should be called when a task reaches a terminal status.
33830
+ */
33831
+ _cleanupTaskProgressHandler(taskId) {
33832
+ const progressToken = this._taskProgressTokens.get(taskId);
33833
+ if (progressToken !== void 0) {
33834
+ this._progressHandlers.delete(progressToken);
33835
+ this._taskProgressTokens.delete(taskId);
33836
+ }
33837
+ }
33838
+ /**
33839
+ * Enqueues a task-related message for side-channel delivery via tasks/result.
33840
+ * @param taskId The task ID to associate the message with
33841
+ * @param message The message to enqueue
33842
+ * @param sessionId Optional session ID for binding the operation to a specific session
33843
+ * @throws Error if taskStore is not configured or if enqueue fails (e.g., queue overflow)
33844
+ *
33845
+ * Note: If enqueue fails, it's the TaskMessageQueue implementation's responsibility to handle
33846
+ * the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
33847
+ * simply propagates the error.
33848
+ */
33849
+ async _enqueueTaskMessage(taskId, message, sessionId) {
33850
+ var _a2;
33851
+ if (!this._taskStore || !this._taskMessageQueue) {
33852
+ throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
33853
+ }
33854
+ const maxQueueSize = (_a2 = this._options) === null || _a2 === void 0 ? void 0 : _a2.maxTaskQueueSize;
33855
+ await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
33856
+ }
33857
+ /**
33858
+ * Clears the message queue for a task and rejects any pending request resolvers.
33859
+ * @param taskId The task ID whose queue should be cleared
33860
+ * @param sessionId Optional session ID for binding the operation to a specific session
33861
+ */
33862
+ async _clearTaskQueue(taskId, sessionId) {
33863
+ if (this._taskMessageQueue) {
33864
+ const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId);
33865
+ for (const message of messages) {
33866
+ if (message.type === "request" && isJSONRPCRequest(message.message)) {
33867
+ const requestId = message.message.id;
33868
+ const resolver = this._requestResolvers.get(requestId);
33869
+ if (resolver) {
33870
+ resolver(new McpError(ErrorCode.InternalError, "Task cancelled or completed"));
33871
+ this._requestResolvers.delete(requestId);
33872
+ } else {
33873
+ this._onerror(new Error(`Resolver missing for request ${requestId} during task ${taskId} cleanup`));
33874
+ }
33875
+ }
33876
+ }
33877
+ }
33878
+ }
33879
+ /**
33880
+ * Waits for a task update (new messages or status change) with abort signal support.
33881
+ * Uses polling to check for updates at the task's configured poll interval.
33882
+ * @param taskId The task ID to wait for
33883
+ * @param signal Abort signal to cancel the wait
33884
+ * @returns Promise that resolves when an update occurs or rejects if aborted
33885
+ */
33886
+ async _waitForTaskUpdate(taskId, signal) {
33887
+ var _a2, _b, _c;
33888
+ let interval = (_b = (_a2 = this._options) === null || _a2 === void 0 ? void 0 : _a2.defaultTaskPollInterval) !== null && _b !== void 0 ? _b : 1e3;
33889
+ try {
33890
+ const task = await ((_c = this._taskStore) === null || _c === void 0 ? void 0 : _c.getTask(taskId));
33891
+ if (task === null || task === void 0 ? void 0 : task.pollInterval) {
33892
+ interval = task.pollInterval;
33893
+ }
33894
+ } catch (_d) {
33895
+ }
33896
+ return new Promise((resolve2, reject) => {
33897
+ if (signal.aborted) {
33898
+ reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
33899
+ return;
33900
+ }
33901
+ const timeoutId = setTimeout(resolve2, interval);
33902
+ signal.addEventListener("abort", () => {
33903
+ clearTimeout(timeoutId);
33904
+ reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
33905
+ }, { once: true });
33906
+ });
33907
+ }
33908
+ requestTaskStore(request2, sessionId) {
33909
+ const taskStore = this._taskStore;
33910
+ if (!taskStore) {
33911
+ throw new Error("No task store configured");
33912
+ }
33913
+ return {
33914
+ createTask: async (taskParams) => {
33915
+ if (!request2) {
33916
+ throw new Error("No request provided");
33917
+ }
33918
+ return await taskStore.createTask(taskParams, request2.id, {
33919
+ method: request2.method,
33920
+ params: request2.params
33921
+ }, sessionId);
33922
+ },
33923
+ getTask: async (taskId) => {
33924
+ const task = await taskStore.getTask(taskId, sessionId);
33925
+ if (!task) {
33926
+ throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
33927
+ }
33928
+ return task;
33929
+ },
33930
+ storeTaskResult: async (taskId, status, result) => {
33931
+ await taskStore.storeTaskResult(taskId, status, result, sessionId);
33932
+ const task = await taskStore.getTask(taskId, sessionId);
33933
+ if (task) {
33934
+ const notification = TaskStatusNotificationSchema.parse({
33935
+ method: "notifications/tasks/status",
33936
+ params: task
33937
+ });
33938
+ await this.notification(notification);
33939
+ if (isTerminal(task.status)) {
33940
+ this._cleanupTaskProgressHandler(taskId);
33941
+ }
33942
+ }
33943
+ },
33944
+ getTaskResult: (taskId) => {
33945
+ return taskStore.getTaskResult(taskId, sessionId);
33946
+ },
33947
+ updateTaskStatus: async (taskId, status, statusMessage) => {
33948
+ const task = await taskStore.getTask(taskId, sessionId);
33949
+ if (!task) {
33950
+ throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
33951
+ }
33952
+ if (isTerminal(task.status)) {
33953
+ 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.`);
33954
+ }
33955
+ await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId);
33956
+ const updatedTask = await taskStore.getTask(taskId, sessionId);
33957
+ if (updatedTask) {
33958
+ const notification = TaskStatusNotificationSchema.parse({
33959
+ method: "notifications/tasks/status",
33960
+ params: updatedTask
33961
+ });
33962
+ await this.notification(notification);
33963
+ if (isTerminal(updatedTask.status)) {
33964
+ this._cleanupTaskProgressHandler(taskId);
33965
+ }
33966
+ }
33967
+ },
33968
+ listTasks: (cursor) => {
33969
+ return taskStore.listTasks(cursor, sessionId);
33970
+ }
33971
+ };
33972
+ }
33156
33973
  };
33157
33974
  function isPlainObject4(value) {
33158
33975
  return value !== null && typeof value === "object" && !Array.isArray(value);
@@ -33174,7 +33991,7 @@ function mergeCapabilities(base, additional) {
33174
33991
  return result;
33175
33992
  }
33176
33993
 
33177
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
33994
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
33178
33995
  var import_ajv = __toESM(require_ajv(), 1);
33179
33996
  var import_ajv_formats = __toESM(require_dist(), 1);
33180
33997
  function createDefaultAjvInstance() {
@@ -33243,7 +34060,116 @@ var AjvJsonSchemaValidator = class {
33243
34060
  }
33244
34061
  };
33245
34062
 
33246
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
34063
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
34064
+ var ExperimentalServerTasks = class {
34065
+ constructor(_server) {
34066
+ this._server = _server;
34067
+ }
34068
+ /**
34069
+ * Sends a request and returns an AsyncGenerator that yields response messages.
34070
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
34071
+ *
34072
+ * This method provides streaming access to request processing, allowing you to
34073
+ * observe intermediate task status updates for task-augmented requests.
34074
+ *
34075
+ * @param request - The request to send
34076
+ * @param resultSchema - Zod schema for validating the result
34077
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
34078
+ * @returns AsyncGenerator that yields ResponseMessage objects
34079
+ *
34080
+ * @experimental
34081
+ */
34082
+ requestStream(request2, resultSchema, options) {
34083
+ return this._server.requestStream(request2, resultSchema, options);
34084
+ }
34085
+ /**
34086
+ * Gets the current status of a task.
34087
+ *
34088
+ * @param taskId - The task identifier
34089
+ * @param options - Optional request options
34090
+ * @returns The task status
34091
+ *
34092
+ * @experimental
34093
+ */
34094
+ async getTask(taskId, options) {
34095
+ return this._server.getTask({ taskId }, options);
34096
+ }
34097
+ /**
34098
+ * Retrieves the result of a completed task.
34099
+ *
34100
+ * @param taskId - The task identifier
34101
+ * @param resultSchema - Zod schema for validating the result
34102
+ * @param options - Optional request options
34103
+ * @returns The task result
34104
+ *
34105
+ * @experimental
34106
+ */
34107
+ async getTaskResult(taskId, resultSchema, options) {
34108
+ return this._server.getTaskResult({ taskId }, resultSchema, options);
34109
+ }
34110
+ /**
34111
+ * Lists tasks with optional pagination.
34112
+ *
34113
+ * @param cursor - Optional pagination cursor
34114
+ * @param options - Optional request options
34115
+ * @returns List of tasks with optional next cursor
34116
+ *
34117
+ * @experimental
34118
+ */
34119
+ async listTasks(cursor, options) {
34120
+ return this._server.listTasks(cursor ? { cursor } : void 0, options);
34121
+ }
34122
+ /**
34123
+ * Cancels a running task.
34124
+ *
34125
+ * @param taskId - The task identifier
34126
+ * @param options - Optional request options
34127
+ *
34128
+ * @experimental
34129
+ */
34130
+ async cancelTask(taskId, options) {
34131
+ return this._server.cancelTask({ taskId }, options);
34132
+ }
34133
+ };
34134
+
34135
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
34136
+ function assertToolsCallTaskCapability(requests, method, entityName) {
34137
+ var _a2;
34138
+ if (!requests) {
34139
+ throw new Error(`${entityName} does not support task creation (required for ${method})`);
34140
+ }
34141
+ switch (method) {
34142
+ case "tools/call":
34143
+ if (!((_a2 = requests.tools) === null || _a2 === void 0 ? void 0 : _a2.call)) {
34144
+ throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
34145
+ }
34146
+ break;
34147
+ default:
34148
+ break;
34149
+ }
34150
+ }
34151
+ function assertClientRequestTaskCapability(requests, method, entityName) {
34152
+ var _a2, _b;
34153
+ if (!requests) {
34154
+ throw new Error(`${entityName} does not support task creation (required for ${method})`);
34155
+ }
34156
+ switch (method) {
34157
+ case "sampling/createMessage":
34158
+ if (!((_a2 = requests.sampling) === null || _a2 === void 0 ? void 0 : _a2.createMessage)) {
34159
+ throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
34160
+ }
34161
+ break;
34162
+ case "elicitation/create":
34163
+ if (!((_b = requests.elicitation) === null || _b === void 0 ? void 0 : _b.create)) {
34164
+ throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
34165
+ }
34166
+ break;
34167
+ default:
34168
+ break;
34169
+ }
34170
+ }
34171
+
34172
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
33247
34173
  var Server = class extends Protocol {
33248
34174
  /**
33249
34175
  * Initializes this server with the given name and version information.
@@ -33279,6 +34205,21 @@ var Server = class extends Protocol {
33279
34205
  });
33280
34206
  }
33281
34207
  }
34208
+ /**
34209
+ * Access experimental features.
34210
+ *
34211
+ * WARNING: These APIs are experimental and may change without notice.
34212
+ *
34213
+ * @experimental
34214
+ */
34215
+ get experimental() {
34216
+ if (!this._experimental) {
34217
+ this._experimental = {
34218
+ tasks: new ExperimentalServerTasks(this)
34219
+ };
34220
+ }
34221
+ return this._experimental;
34222
+ }
33282
34223
  /**
33283
34224
  * Registers new capabilities. This can only be called before connecting to a transport.
33284
34225
  *
@@ -33290,6 +34231,58 @@ var Server = class extends Protocol {
33290
34231
  }
33291
34232
  this._capabilities = mergeCapabilities(this._capabilities, capabilities);
33292
34233
  }
34234
+ /**
34235
+ * Override request handler registration to enforce server-side validation for tools/call.
34236
+ */
34237
+ setRequestHandler(requestSchema, handler2) {
34238
+ var _a2, _b, _c;
34239
+ const shape = getObjectShape(requestSchema);
34240
+ const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
34241
+ if (!methodSchema) {
34242
+ throw new Error("Schema is missing a method literal");
34243
+ }
34244
+ let methodValue;
34245
+ if (isZ4Schema(methodSchema)) {
34246
+ const v4Schema = methodSchema;
34247
+ const v4Def = (_a2 = v4Schema._zod) === null || _a2 === void 0 ? void 0 : _a2.def;
34248
+ methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
34249
+ } else {
34250
+ const v3Schema = methodSchema;
34251
+ const legacyDef = v3Schema._def;
34252
+ methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
34253
+ }
34254
+ if (typeof methodValue !== "string") {
34255
+ throw new Error("Schema method literal must be a string");
34256
+ }
34257
+ const method = methodValue;
34258
+ if (method === "tools/call") {
34259
+ const wrappedHandler = async (request2, extra) => {
34260
+ const validatedRequest = safeParse4(CallToolRequestSchema, request2);
34261
+ if (!validatedRequest.success) {
34262
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
34263
+ throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
34264
+ }
34265
+ const { params } = validatedRequest.data;
34266
+ const result = await Promise.resolve(handler2(request2, extra));
34267
+ if (params.task) {
34268
+ const taskValidationResult = safeParse4(CreateTaskResultSchema, result);
34269
+ if (!taskValidationResult.success) {
34270
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
34271
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
34272
+ }
34273
+ return taskValidationResult.data;
34274
+ }
34275
+ const validationResult = safeParse4(CallToolResultSchema, result);
34276
+ if (!validationResult.success) {
34277
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
34278
+ throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
34279
+ }
34280
+ return validationResult.data;
34281
+ };
34282
+ return super.setRequestHandler(requestSchema, wrappedHandler);
34283
+ }
34284
+ return super.setRequestHandler(requestSchema, handler2);
34285
+ }
33293
34286
  assertCapabilityForMethod(method) {
33294
34287
  var _a2, _b, _c;
33295
34288
  switch (method) {
@@ -33348,6 +34341,9 @@ var Server = class extends Protocol {
33348
34341
  }
33349
34342
  }
33350
34343
  assertRequestHandlerCapability(method) {
34344
+ if (!this._capabilities) {
34345
+ return;
34346
+ }
33351
34347
  switch (method) {
33352
34348
  case "completion/complete":
33353
34349
  if (!this._capabilities.completions) {
@@ -33378,11 +34374,30 @@ var Server = class extends Protocol {
33378
34374
  throw new Error(`Server does not support tools (required for ${method})`);
33379
34375
  }
33380
34376
  break;
34377
+ case "tasks/get":
34378
+ case "tasks/list":
34379
+ case "tasks/result":
34380
+ case "tasks/cancel":
34381
+ if (!this._capabilities.tasks) {
34382
+ throw new Error(`Server does not support tasks capability (required for ${method})`);
34383
+ }
34384
+ break;
33381
34385
  case "ping":
33382
34386
  case "initialize":
33383
34387
  break;
33384
34388
  }
33385
34389
  }
34390
+ assertTaskCapability(method) {
34391
+ var _a2, _b;
34392
+ assertClientRequestTaskCapability((_b = (_a2 = this._clientCapabilities) === null || _a2 === void 0 ? void 0 : _a2.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Client");
34393
+ }
34394
+ assertTaskHandlerCapability(method) {
34395
+ var _a2;
34396
+ if (!this._capabilities) {
34397
+ return;
34398
+ }
34399
+ assertToolsCallTaskCapability((_a2 = this._capabilities.tasks) === null || _a2 === void 0 ? void 0 : _a2.requests, method, "Server");
34400
+ }
33386
34401
  async _oninitialize(request2) {
33387
34402
  const requestedVersion = request2.params.protocolVersion;
33388
34403
  this._clientCapabilities = request2.params.capabilities;
@@ -33413,6 +34428,7 @@ var Server = class extends Protocol {
33413
34428
  async ping() {
33414
34429
  return this.request({ method: "ping" }, EmptyResultSchema);
33415
34430
  }
34431
+ // Implementation
33416
34432
  async createMessage(params, options) {
33417
34433
  var _a2, _b;
33418
34434
  if (params.tools || params.toolChoice) {
@@ -33443,6 +34459,9 @@ var Server = class extends Protocol {
33443
34459
  }
33444
34460
  }
33445
34461
  }
34462
+ if (params.tools) {
34463
+ return this.request({ method: "sampling/createMessage", params }, CreateMessageResultWithToolsSchema, options);
34464
+ }
33446
34465
  return this.request({ method: "sampling/createMessage", params }, CreateMessageResultSchema, options);
33447
34466
  }
33448
34467
  /**
@@ -33543,8 +34562,8 @@ var Server = class extends Protocol {
33543
34562
  }
33544
34563
  };
33545
34564
 
33546
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
33547
- var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
34565
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
34566
+ var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
33548
34567
  function isCompletable(schema5) {
33549
34568
  return !!schema5 && typeof schema5 === "object" && COMPLETABLE_SYMBOL in schema5;
33550
34569
  }
@@ -33557,7 +34576,7 @@ var McpZodTypeKind;
33557
34576
  McpZodTypeKind2["Completable"] = "McpCompletable";
33558
34577
  })(McpZodTypeKind || (McpZodTypeKind = {}));
33559
34578
 
33560
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
34579
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
33561
34580
  var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
33562
34581
  function validateToolName(name) {
33563
34582
  const warnings = [];
@@ -33615,7 +34634,22 @@ function validateAndWarnToolName(name) {
33615
34634
  return result.isValid;
33616
34635
  }
33617
34636
 
33618
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
34637
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
34638
+ var ExperimentalMcpServerTasks = class {
34639
+ constructor(_mcpServer) {
34640
+ this._mcpServer = _mcpServer;
34641
+ }
34642
+ registerToolTask(name, config2, handler2) {
34643
+ const execution = { taskSupport: "required", ...config2.execution };
34644
+ if (execution.taskSupport === "forbidden") {
34645
+ throw new Error(`Cannot register task-based tool '${name}' with taskSupport 'forbidden'. Use registerTool() instead.`);
34646
+ }
34647
+ const mcpServerInternal = this._mcpServer;
34648
+ return mcpServerInternal._createRegisteredTool(name, config2.title, config2.description, config2.inputSchema, config2.outputSchema, config2.annotations, execution, config2._meta, handler2);
34649
+ }
34650
+ };
34651
+
34652
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
33619
34653
  var McpServer = class {
33620
34654
  constructor(serverInfo, options) {
33621
34655
  this._registeredResources = {};
@@ -33628,6 +34662,21 @@ var McpServer = class {
33628
34662
  this._promptHandlersInitialized = false;
33629
34663
  this.server = new Server(serverInfo, options);
33630
34664
  }
34665
+ /**
34666
+ * Access experimental features.
34667
+ *
34668
+ * WARNING: These APIs are experimental and may change without notice.
34669
+ *
34670
+ * @experimental
34671
+ */
34672
+ get experimental() {
34673
+ if (!this._experimental) {
34674
+ this._experimental = {
34675
+ tasks: new ExperimentalMcpServerTasks(this)
34676
+ };
34677
+ }
34678
+ return this._experimental;
34679
+ }
33631
34680
  /**
33632
34681
  * Attaches to the given transport, starts it, and starts listening for messages.
33633
34682
  *
@@ -33667,6 +34716,7 @@ var McpServer = class {
33667
34716
  }) : EMPTY_OBJECT_JSON_SCHEMA;
33668
34717
  })(),
33669
34718
  annotations: tool.annotations,
34719
+ execution: tool.execution,
33670
34720
  _meta: tool._meta
33671
34721
  };
33672
34722
  if (tool.outputSchema) {
@@ -33682,39 +34732,34 @@ var McpServer = class {
33682
34732
  })
33683
34733
  }));
33684
34734
  this.server.setRequestHandler(CallToolRequestSchema, async (request2, extra) => {
33685
- const tool = this._registeredTools[request2.params.name];
33686
- let result;
34735
+ var _a2;
33687
34736
  try {
34737
+ const tool = this._registeredTools[request2.params.name];
33688
34738
  if (!tool) {
33689
34739
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request2.params.name} not found`);
33690
34740
  }
33691
34741
  if (!tool.enabled) {
33692
34742
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request2.params.name} disabled`);
33693
34743
  }
33694
- if (tool.inputSchema) {
33695
- const cb = tool.callback;
33696
- const inputObj = normalizeObjectSchema(tool.inputSchema);
33697
- const schemaToParse = inputObj !== null && inputObj !== void 0 ? inputObj : tool.inputSchema;
33698
- const parseResult = await safeParseAsync3(schemaToParse, request2.params.arguments);
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));
34744
+ const isTaskRequest = !!request2.params.task;
34745
+ const taskSupport = (_a2 = tool.execution) === null || _a2 === void 0 ? void 0 : _a2.taskSupport;
34746
+ const isTaskHandler = "createTask" in tool.handler;
34747
+ if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
34748
+ throw new McpError(ErrorCode.InternalError, `Tool ${request2.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
33707
34749
  }
33708
- if (tool.outputSchema && !result.isError) {
33709
- if (!result.structuredContent) {
33710
- throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${request2.params.name} has an output schema but no structured content was provided`);
33711
- }
33712
- const outputObj = normalizeObjectSchema(tool.outputSchema);
33713
- const parseResult = await safeParseAsync3(outputObj, result.structuredContent);
33714
- if (!parseResult.success) {
33715
- throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${request2.params.name}: ${getParseErrorMessage(parseResult.error)}`);
33716
- }
34750
+ if (taskSupport === "required" && !isTaskRequest) {
34751
+ throw new McpError(ErrorCode.MethodNotFound, `Tool ${request2.params.name} requires task augmentation (taskSupport: 'required')`);
34752
+ }
34753
+ if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) {
34754
+ return await this.handleAutomaticTaskPolling(tool, request2, extra);
33717
34755
  }
34756
+ const args2 = await this.validateToolInput(tool, request2.params.arguments, request2.params.name);
34757
+ const result = await this.executeToolHandler(tool, args2, extra);
34758
+ if (isTaskRequest) {
34759
+ return result;
34760
+ }
34761
+ await this.validateToolOutput(tool, result, request2.params.name);
34762
+ return result;
33718
34763
  } catch (error46) {
33719
34764
  if (error46 instanceof McpError) {
33720
34765
  if (error46.code === ErrorCode.UrlElicitationRequired) {
@@ -33723,7 +34768,6 @@ var McpServer = class {
33723
34768
  }
33724
34769
  return this.createToolError(error46 instanceof Error ? error46.message : String(error46));
33725
34770
  }
33726
- return result;
33727
34771
  });
33728
34772
  this._toolHandlersInitialized = true;
33729
34773
  }
@@ -33744,6 +34788,102 @@ var McpServer = class {
33744
34788
  isError: true
33745
34789
  };
33746
34790
  }
34791
+ /**
34792
+ * Validates tool input arguments against the tool's input schema.
34793
+ */
34794
+ async validateToolInput(tool, args2, toolName) {
34795
+ if (!tool.inputSchema) {
34796
+ return void 0;
34797
+ }
34798
+ const inputObj = normalizeObjectSchema(tool.inputSchema);
34799
+ const schemaToParse = inputObj !== null && inputObj !== void 0 ? inputObj : tool.inputSchema;
34800
+ const parseResult = await safeParseAsync3(schemaToParse, args2);
34801
+ if (!parseResult.success) {
34802
+ const error46 = "error" in parseResult ? parseResult.error : "Unknown error";
34803
+ const errorMessage = getParseErrorMessage(error46);
34804
+ throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${errorMessage}`);
34805
+ }
34806
+ return parseResult.data;
34807
+ }
34808
+ /**
34809
+ * Validates tool output against the tool's output schema.
34810
+ */
34811
+ async validateToolOutput(tool, result, toolName) {
34812
+ if (!tool.outputSchema) {
34813
+ return;
34814
+ }
34815
+ if (!("content" in result)) {
34816
+ return;
34817
+ }
34818
+ if (result.isError) {
34819
+ return;
34820
+ }
34821
+ if (!result.structuredContent) {
34822
+ throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
34823
+ }
34824
+ const outputObj = normalizeObjectSchema(tool.outputSchema);
34825
+ const parseResult = await safeParseAsync3(outputObj, result.structuredContent);
34826
+ if (!parseResult.success) {
34827
+ const error46 = "error" in parseResult ? parseResult.error : "Unknown error";
34828
+ const errorMessage = getParseErrorMessage(error46);
34829
+ throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`);
34830
+ }
34831
+ }
34832
+ /**
34833
+ * Executes a tool handler (either regular or task-based).
34834
+ */
34835
+ async executeToolHandler(tool, args2, extra) {
34836
+ const handler2 = tool.handler;
34837
+ const isTaskHandler = "createTask" in handler2;
34838
+ if (isTaskHandler) {
34839
+ if (!extra.taskStore) {
34840
+ throw new Error("No task store provided.");
34841
+ }
34842
+ const taskExtra = { ...extra, taskStore: extra.taskStore };
34843
+ if (tool.inputSchema) {
34844
+ const typedHandler = handler2;
34845
+ return await Promise.resolve(typedHandler.createTask(args2, taskExtra));
34846
+ } else {
34847
+ const typedHandler = handler2;
34848
+ return await Promise.resolve(typedHandler.createTask(taskExtra));
34849
+ }
34850
+ }
34851
+ if (tool.inputSchema) {
34852
+ const typedHandler = handler2;
34853
+ return await Promise.resolve(typedHandler(args2, extra));
34854
+ } else {
34855
+ const typedHandler = handler2;
34856
+ return await Promise.resolve(typedHandler(extra));
34857
+ }
34858
+ }
34859
+ /**
34860
+ * Handles automatic task polling for tools with taskSupport 'optional'.
34861
+ */
34862
+ async handleAutomaticTaskPolling(tool, request2, extra) {
34863
+ var _a2;
34864
+ if (!extra.taskStore) {
34865
+ throw new Error("No task store provided for task-capable tool.");
34866
+ }
34867
+ const args2 = await this.validateToolInput(tool, request2.params.arguments, request2.params.name);
34868
+ const handler2 = tool.handler;
34869
+ const taskExtra = { ...extra, taskStore: extra.taskStore };
34870
+ const createTaskResult = args2 ? await Promise.resolve(handler2.createTask(args2, taskExtra)) : (
34871
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34872
+ await Promise.resolve(handler2.createTask(taskExtra))
34873
+ );
34874
+ const taskId = createTaskResult.task.taskId;
34875
+ let task = createTaskResult.task;
34876
+ const pollInterval = (_a2 = task.pollInterval) !== null && _a2 !== void 0 ? _a2 : 5e3;
34877
+ while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
34878
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
34879
+ const updatedTask = await extra.taskStore.getTask(taskId);
34880
+ if (!updatedTask) {
34881
+ throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
34882
+ }
34883
+ task = updatedTask;
34884
+ }
34885
+ return await extra.taskStore.getTaskResult(taskId);
34886
+ }
33747
34887
  setCompletionRequestHandler() {
33748
34888
  if (this._completionHandlerInitialized) {
33749
34889
  return;
@@ -33899,7 +35039,9 @@ var McpServer = class {
33899
35039
  const argsObj = normalizeObjectSchema(prompt.argsSchema);
33900
35040
  const parseResult = await safeParseAsync3(argsObj, request2.params.arguments);
33901
35041
  if (!parseResult.success) {
33902
- throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request2.params.name}: ${getParseErrorMessage(parseResult.error)}`);
35042
+ const error46 = "error" in parseResult ? parseResult.error : "Unknown error";
35043
+ const errorMessage = getParseErrorMessage(error46);
35044
+ throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request2.params.name}: ${errorMessage}`);
33903
35045
  }
33904
35046
  const args2 = parseResult.data;
33905
35047
  const cb = prompt.callback;
@@ -34051,7 +35193,7 @@ var McpServer = class {
34051
35193
  this._registeredPrompts[name] = registeredPrompt;
34052
35194
  return registeredPrompt;
34053
35195
  }
34054
- _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, callback) {
35196
+ _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, execution, _meta, handler2) {
34055
35197
  validateAndWarnToolName(name);
34056
35198
  const registeredTool = {
34057
35199
  title,
@@ -34059,8 +35201,9 @@ var McpServer = class {
34059
35201
  inputSchema: getZodSchemaObject(inputSchema),
34060
35202
  outputSchema: getZodSchemaObject(outputSchema),
34061
35203
  annotations,
35204
+ execution,
34062
35205
  _meta,
34063
- callback,
35206
+ handler: handler2,
34064
35207
  enabled: true,
34065
35208
  disable: () => registeredTool.update({ enabled: false }),
34066
35209
  enable: () => registeredTool.update({ enabled: true }),
@@ -34081,7 +35224,7 @@ var McpServer = class {
34081
35224
  if (typeof updates.paramsSchema !== "undefined")
34082
35225
  registeredTool.inputSchema = objectFromShape(updates.paramsSchema);
34083
35226
  if (typeof updates.callback !== "undefined")
34084
- registeredTool.callback = updates.callback;
35227
+ registeredTool.handler = updates.callback;
34085
35228
  if (typeof updates.annotations !== "undefined")
34086
35229
  registeredTool.annotations = updates.annotations;
34087
35230
  if (typeof updates._meta !== "undefined")
@@ -34112,9 +35255,9 @@ var McpServer = class {
34112
35255
  }
34113
35256
  if (rest.length > 1) {
34114
35257
  const firstArg = rest[0];
34115
- if (isZodRawShape(firstArg)) {
35258
+ if (isZodRawShapeCompat(firstArg)) {
34116
35259
  inputSchema = rest.shift();
34117
- if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShape(rest[0])) {
35260
+ if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) {
34118
35261
  annotations = rest.shift();
34119
35262
  }
34120
35263
  } else if (typeof firstArg === "object" && firstArg !== null) {
@@ -34122,7 +35265,7 @@ var McpServer = class {
34122
35265
  }
34123
35266
  }
34124
35267
  const callback = rest[0];
34125
- return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, void 0, callback);
35268
+ return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
34126
35269
  }
34127
35270
  /**
34128
35271
  * Registers a tool with a config object and callback.
@@ -34132,7 +35275,7 @@ var McpServer = class {
34132
35275
  throw new Error(`Tool ${name} is already registered`);
34133
35276
  }
34134
35277
  const { title, description, inputSchema, outputSchema, annotations, _meta } = config2;
34135
- return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, cb);
35278
+ return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
34136
35279
  }
34137
35280
  prompt(name, ...rest) {
34138
35281
  if (this._registeredPrompts[name]) {
@@ -34211,20 +35354,29 @@ var EMPTY_OBJECT_JSON_SCHEMA = {
34211
35354
  type: "object",
34212
35355
  properties: {}
34213
35356
  };
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
35357
  function isZodTypeLike(value) {
34221
35358
  return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
34222
35359
  }
35360
+ function isZodSchemaInstance(obj) {
35361
+ return "_def" in obj || "_zod" in obj || isZodTypeLike(obj);
35362
+ }
35363
+ function isZodRawShapeCompat(obj) {
35364
+ if (typeof obj !== "object" || obj === null) {
35365
+ return false;
35366
+ }
35367
+ if (isZodSchemaInstance(obj)) {
35368
+ return false;
35369
+ }
35370
+ if (Object.keys(obj).length === 0) {
35371
+ return true;
35372
+ }
35373
+ return Object.values(obj).some(isZodTypeLike);
35374
+ }
34223
35375
  function getZodSchemaObject(schema5) {
34224
35376
  if (!schema5) {
34225
35377
  return void 0;
34226
35378
  }
34227
- if (isZodRawShape(schema5)) {
35379
+ if (isZodRawShapeCompat(schema5)) {
34228
35380
  return objectFromShape(schema5);
34229
35381
  }
34230
35382
  return schema5;
@@ -34271,10 +35423,10 @@ var EMPTY_COMPLETION_RESULT = {
34271
35423
  }
34272
35424
  };
34273
35425
 
34274
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
35426
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
34275
35427
  import process2 from "node:process";
34276
35428
 
34277
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
35429
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
34278
35430
  var ReadBuffer = class {
34279
35431
  append(chunk) {
34280
35432
  this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
@@ -34302,7 +35454,7 @@ function serializeMessage(message) {
34302
35454
  return JSON.stringify(message) + "\n";
34303
35455
  }
34304
35456
 
34305
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.23.0_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
35457
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.24.3_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
34306
35458
  var StdioServerTransport = class {
34307
35459
  constructor(_stdin = process2.stdin, _stdout = process2.stdout) {
34308
35460
  this._stdin = _stdin;
@@ -34369,7 +35521,7 @@ var StdioServerTransport = class {
34369
35521
  // ../mcp/package.json
34370
35522
  var package_default = {
34371
35523
  name: "@aku11i/phantom-mcp",
34372
- version: "3.2.0",
35524
+ version: "3.3.0",
34373
35525
  private: true,
34374
35526
  type: "module",
34375
35527
  main: "./src/index.ts",
@@ -34385,11 +35537,11 @@ var package_default = {
34385
35537
  "@aku11i/phantom-github": "workspace:*",
34386
35538
  "@aku11i/phantom-process": "workspace:*",
34387
35539
  "@aku11i/phantom-shared": "workspace:*",
34388
- "@modelcontextprotocol/sdk": "^1.23.0",
35540
+ "@modelcontextprotocol/sdk": "^1.24.3",
34389
35541
  zod: "^4.1.13"
34390
35542
  },
34391
35543
  devDependencies: {
34392
- "@modelcontextprotocol/inspector": "^0.17.2"
35544
+ "@modelcontextprotocol/inspector": "^0.17.5"
34393
35545
  }
34394
35546
  };
34395
35547
 
@@ -34662,6 +35814,10 @@ var preferencesHelp = {
34662
35814
  command: 'phantom preferences set ai "codex --full-auto"',
34663
35815
  description: "Set the AI assistant preference (stored as phantom.ai in git config --global)"
34664
35816
  },
35817
+ {
35818
+ command: "phantom preferences set worktreesDirectory ../phantom-worktrees",
35819
+ description: "Store a custom worktreesDirectory (relative to the Git repository root) for all commands"
35820
+ },
34665
35821
  {
34666
35822
  command: "phantom preferences remove editor",
34667
35823
  description: "Remove the editor preference (fallback to env/default)"
@@ -34674,7 +35830,10 @@ var preferencesHelp = {
34674
35830
  " remove <key> Remove a preference value",
34675
35831
  "",
34676
35832
  "Preferences are saved in git config with the 'phantom.' prefix (global scope).",
34677
- "Supported keys: editor (used by 'phantom edit', preferred over $EDITOR) and ai (used by 'phantom ai')."
35833
+ "Supported keys:",
35834
+ " editor - used by 'phantom edit', preferred over $EDITOR",
35835
+ " ai - used by 'phantom ai'",
35836
+ " worktreesDirectory - path relative to the Git repo root for storing worktrees (defaults to .git/phantom/worktrees)"
34678
35837
  ]
34679
35838
  };
34680
35839
  var preferencesGetHelp = {
@@ -34689,9 +35848,13 @@ var preferencesGetHelp = {
34689
35848
  {
34690
35849
  command: "phantom preferences get ai",
34691
35850
  description: "Show the AI assistant preference"
35851
+ },
35852
+ {
35853
+ command: "phantom preferences get worktreesDirectory",
35854
+ description: "Show the preferred worktrees directory (relative to repo root)"
34692
35855
  }
34693
35856
  ],
34694
- notes: ["Supported keys: editor, ai"]
35857
+ notes: ["Supported keys: editor, ai, worktreesDirectory"]
34695
35858
  };
34696
35859
  var preferencesSetHelp = {
34697
35860
  name: "preferences set",
@@ -34705,9 +35868,16 @@ var preferencesSetHelp = {
34705
35868
  {
34706
35869
  command: "phantom preferences set ai claude",
34707
35870
  description: "Configure the AI assistant command"
35871
+ },
35872
+ {
35873
+ command: "phantom preferences set worktreesDirectory ../phantom-worktrees",
35874
+ description: "Store worktrees in ../phantom-worktrees relative to the Git repository root"
34708
35875
  }
34709
35876
  ],
34710
- notes: ["Supported keys: editor, ai"]
35877
+ notes: [
35878
+ "Supported keys: editor, ai, worktreesDirectory",
35879
+ "For worktreesDirectory, provide a path relative to the Git repository root; defaults to .git/phantom/worktrees when unset"
35880
+ ]
34711
35881
  };
34712
35882
  var preferencesRemoveHelp = {
34713
35883
  name: "preferences remove",
@@ -34721,9 +35891,13 @@ var preferencesRemoveHelp = {
34721
35891
  {
34722
35892
  command: "phantom preferences remove ai",
34723
35893
  description: "Unset the AI assistant preference"
35894
+ },
35895
+ {
35896
+ command: "phantom preferences remove worktreesDirectory",
35897
+ description: "Unset the custom worktrees directory preference"
34724
35898
  }
34725
35899
  ],
34726
- notes: ["Supported keys: editor, ai"]
35900
+ notes: ["Supported keys: editor, ai, worktreesDirectory"]
34727
35901
  };
34728
35902
 
34729
35903
  // src/handlers/preferences.ts
@@ -34737,7 +35911,7 @@ async function preferencesHandler(args2) {
34737
35911
 
34738
35912
  // src/handlers/preferences-get.ts
34739
35913
  import { parseArgs as parseArgs10 } from "node:util";
34740
- var supportedKeys = ["editor", "ai"];
35914
+ var supportedKeys = ["editor", "ai", "worktreesDirectory"];
34741
35915
  async function preferencesGetHandler(args2) {
34742
35916
  const { positionals } = parseArgs10({
34743
35917
  args: args2,
@@ -34760,7 +35934,7 @@ async function preferencesGetHandler(args2) {
34760
35934
  }
34761
35935
  try {
34762
35936
  const preferences = await loadPreferences();
34763
- const value = inputKey === "editor" ? preferences.editor : inputKey === "ai" ? preferences.ai : void 0;
35937
+ const value = inputKey === "editor" ? preferences.editor : inputKey === "ai" ? preferences.ai : inputKey === "worktreesDirectory" ? preferences.worktreesDirectory : void 0;
34764
35938
  if (value === void 0) {
34765
35939
  output.log(
34766
35940
  `Preference '${inputKey}' is not set (git config --global phantom.${inputKey})`
@@ -34779,7 +35953,7 @@ async function preferencesGetHandler(args2) {
34779
35953
 
34780
35954
  // src/handlers/preferences-remove.ts
34781
35955
  import { parseArgs as parseArgs11 } from "node:util";
34782
- var supportedKeys2 = ["editor", "ai"];
35956
+ var supportedKeys2 = ["editor", "ai", "worktreesDirectory"];
34783
35957
  async function preferencesRemoveHandler(args2) {
34784
35958
  const { positionals } = parseArgs11({
34785
35959
  args: args2,
@@ -34818,7 +35992,7 @@ async function preferencesRemoveHandler(args2) {
34818
35992
  }
34819
35993
 
34820
35994
  // src/handlers/preferences-set.ts
34821
- var supportedKeys3 = ["editor", "ai"];
35995
+ var supportedKeys3 = ["editor", "ai", "worktreesDirectory"];
34822
35996
  async function preferencesSetHandler(args2) {
34823
35997
  if (args2.length < 2) {
34824
35998
  exitWithError(
@@ -34986,7 +36160,7 @@ import { parseArgs as parseArgs13 } from "node:util";
34986
36160
  // package.json
34987
36161
  var package_default2 = {
34988
36162
  name: "@aku11i/phantom-cli",
34989
- version: "3.2.0",
36163
+ version: "3.3.0",
34990
36164
  private: true,
34991
36165
  type: "module",
34992
36166
  scripts: {
@@ -35309,8 +36483,8 @@ var createHelp = {
35309
36483
  // src/help/delete.ts
35310
36484
  var deleteHelp = {
35311
36485
  name: "delete",
35312
- description: "Delete a Git worktree",
35313
- usage: "phantom delete <name> [options]",
36486
+ description: "Delete one or more Git worktrees",
36487
+ usage: "phantom delete <name...> [options]",
35314
36488
  options: [
35315
36489
  {
35316
36490
  name: "force",
@@ -35334,6 +36508,10 @@ var deleteHelp = {
35334
36508
  description: "Delete a worktree",
35335
36509
  command: "phantom delete feature-auth"
35336
36510
  },
36511
+ {
36512
+ description: "Delete multiple worktrees in one command",
36513
+ command: "phantom delete feature-auth docs-cleanup spike-login"
36514
+ },
35337
36515
  {
35338
36516
  description: "Force delete a worktree with uncommitted changes",
35339
36517
  command: "phantom delete experimental --force"
@@ -35349,6 +36527,7 @@ var deleteHelp = {
35349
36527
  ],
35350
36528
  notes: [
35351
36529
  "By default, deletion will fail if the worktree has uncommitted changes",
36530
+ "You can pass multiple worktree names to delete them at once",
35352
36531
  "The associated branch will also be deleted if it's not checked out elsewhere",
35353
36532
  "With --fzf, you can interactively select the worktree to delete"
35354
36533
  ]