@ai-ecoverse/mcpcat 0.23.1 → 0.23.3

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.
@@ -12737,6 +12737,7 @@ function startHolder(platform2, options) {
12737
12737
  var DIALOG_HOLD_MIN_VERSION = "1.39.0";
12738
12738
  var DIALOG_ANSWER_MS = 7e3;
12739
12739
  var DIALOG_CLAIM_MS = 1e3;
12740
+ var DIALOG_FAIL_FAST = 2;
12740
12741
  var DIALOG_MODES = ["report", "dismiss", "accept"];
12741
12742
  var LABEL2 = "mcpcat serve --webmcp";
12742
12743
  var REFUSED = "playwright-cli refuses to answer it (protected, unverified or in a frame)";
@@ -12770,6 +12771,26 @@ function reporter(options) {
12770
12771
  function answerProblem(event, answerMs) {
12771
12772
  return event === "timeout" ? `playwright-cli dialog-hold did not answer within ${Math.round(answerMs / 1e3)}s` : `playwright-cli dialog-hold replied ${event}`;
12772
12773
  }
12774
+ function latch() {
12775
+ let shut = false;
12776
+ let wait = Promise.resolve();
12777
+ let release = () => {
12778
+ };
12779
+ return {
12780
+ close() {
12781
+ if (shut) return;
12782
+ shut = true;
12783
+ wait = new Promise((resolve) => {
12784
+ release = () => {
12785
+ shut = false;
12786
+ resolve();
12787
+ };
12788
+ });
12789
+ },
12790
+ open: () => release(),
12791
+ wait: () => wait
12792
+ };
12793
+ }
12773
12794
  var isId = (value) => Number.isSafeInteger(value) && Number(value) >= 0;
12774
12795
  function startDialogHolder(platform2, options) {
12775
12796
  const verb = options.accept ? "dialog-accept" : "dialog-dismiss";
@@ -12779,6 +12800,8 @@ function startDialogHolder(platform2, options) {
12779
12800
  let stopped = false;
12780
12801
  let isReady = false;
12781
12802
  let waitedOut = false;
12803
+ let failing = false;
12804
+ let failures = 0;
12782
12805
  let armed = 0;
12783
12806
  let current;
12784
12807
  let nextId2 = 1;
@@ -12787,21 +12810,11 @@ function startDialogHolder(platform2, options) {
12787
12810
  let delay = HOLDER_RESTART_MIN_MS;
12788
12811
  let readyAt;
12789
12812
  let restartTimer;
12790
- let settled = true;
12791
- let pending = Promise.resolve();
12792
- let settle = () => {
12793
- };
12813
+ const gate = latch();
12794
12814
  const unready = () => {
12795
12815
  isReady = false;
12796
12816
  waitedOut = false;
12797
- if (!settled) return;
12798
- settled = false;
12799
- pending = new Promise((resolve) => {
12800
- settle = () => {
12801
- settled = true;
12802
- resolve();
12803
- };
12804
- });
12817
+ gate.close();
12805
12818
  };
12806
12819
  let exited = Promise.resolve();
12807
12820
  const report = reporter(options);
@@ -12844,8 +12857,9 @@ function startDialogHolder(platform2, options) {
12844
12857
  }
12845
12858
  if (event.event === "ready") {
12846
12859
  isReady = true;
12860
+ failing = false;
12847
12861
  readyAt = Date.now();
12848
- settle();
12862
+ gate.open();
12849
12863
  } else if (event.event === "dialog-opened" && isId(event.dialogId)) {
12850
12864
  current = { id: event.dialogId, armed: armed > 0 };
12851
12865
  if (current.armed) answer(current);
@@ -12867,7 +12881,7 @@ function startDialogHolder(platform2, options) {
12867
12881
  child = await platform2.spawn({ argv, dieWithParent: true });
12868
12882
  } catch (err2) {
12869
12883
  report(`cannot start playwright-cli dialog-hold: ${err2.message}`);
12870
- scheduleRestart();
12884
+ scheduleRestart(false);
12871
12885
  return;
12872
12886
  }
12873
12887
  if (stopped) {
@@ -12890,22 +12904,24 @@ function startDialogHolder(platform2, options) {
12890
12904
  current = void 0;
12891
12905
  reply?.resolve("holder-gone");
12892
12906
  if (!stopped) unready();
12893
- if (readyAt !== void 0 && Date.now() - readyAt >= HOLDER_STABLE_MS) {
12894
- delay = HOLDER_RESTART_MIN_MS;
12895
- }
12907
+ const reached = readyAt !== void 0;
12908
+ if (reached && Date.now() - readyAt >= HOLDER_STABLE_MS) delay = HOLDER_RESTART_MIN_MS;
12896
12909
  readyAt = void 0;
12897
12910
  if (stopped) return;
12898
12911
  const why = lastError ?? `exited ${result.status}`;
12899
12912
  report(
12900
12913
  `the dialog holder for tab ${options.tab} stopped (playwright-cli dialog-hold: ${why}); restarting in ${Math.ceil(delay / 1e3)}s`
12901
12914
  );
12902
- scheduleRestart();
12915
+ scheduleRestart(reached);
12903
12916
  });
12904
12917
  };
12905
- const scheduleRestart = () => {
12918
+ const scheduleRestart = (reached) => {
12906
12919
  if (stopped) return;
12907
12920
  const wait = delay;
12908
12921
  delay = Math.min(delay * 2, HOLDER_RESTART_MAX_MS);
12922
+ failures = reached ? 0 : failures + 1;
12923
+ failing = failures >= DIALOG_FAIL_FAST || wait >= options.readyTimeoutMs;
12924
+ if (failing) gate.open();
12909
12925
  restartTimer = setTimeout(() => {
12910
12926
  restartTimer = void 0;
12911
12927
  if (!stopped) void spawn3();
@@ -12915,8 +12931,8 @@ function startDialogHolder(platform2, options) {
12915
12931
  void spawn3();
12916
12932
  return {
12917
12933
  async ready() {
12918
- if (waitedOut || isReady) return;
12919
- if (!await within(pending, options.readyTimeoutMs)) waitedOut = true;
12934
+ if (failing || waitedOut || isReady) return;
12935
+ if (!await within(gate.wait(), options.readyTimeoutMs)) waitedOut = true;
12920
12936
  },
12921
12937
  attached: () => isReady,
12922
12938
  open: () => current !== void 0,
@@ -12936,7 +12952,7 @@ function startDialogHolder(platform2, options) {
12936
12952
  },
12937
12953
  async stop() {
12938
12954
  stopped = true;
12939
- settle();
12955
+ gate.open();
12940
12956
  clearTimeout(restartTimer);
12941
12957
  const child = proc;
12942
12958
  const w = writer;
@@ -17749,7 +17765,8 @@ async function dispatchMultiTarget(platform2, parsed, version) {
17749
17765
  }
17750
17766
  async function run(platform2, version, args2) {
17751
17767
  try {
17752
- if (UPGRADE_VERBS.has(args2[0])) return await upgrade(platform2, version, args2);
17768
+ const upgrading = upgradeArgs(args2);
17769
+ if (upgrading) return await upgrade(platform2, version, upgrading);
17753
17770
  return await runInner(platform2, version, args2);
17754
17771
  } catch (err) {
17755
17772
  if (err.code === "EACCES") {
@@ -17765,6 +17782,53 @@ function wantsServeHelp(args2) {
17765
17782
  return parseArgs(args2).verb === "serve";
17766
17783
  }
17767
17784
  var UPGRADE_VERBS = /* @__PURE__ */ new Set(["upgrade", "update"]);
17785
+ var LEADING_STOPS = /* @__PURE__ */ new Set(["--", "--help", "-h", "--version", "-V"]);
17786
+ var GLOBAL_VALUE_FLAGS = /* @__PURE__ */ new Set([
17787
+ "-H",
17788
+ "--header",
17789
+ "-d",
17790
+ "--protocol-version",
17791
+ "--budget",
17792
+ "-e",
17793
+ "-s",
17794
+ "--server",
17795
+ "-m",
17796
+ "--timeout",
17797
+ "--respond",
17798
+ "--root",
17799
+ "-o",
17800
+ "--output",
17801
+ "--memory"
17802
+ ]);
17803
+ var GLOBAL_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
17804
+ "--schema",
17805
+ "--ts",
17806
+ "--json",
17807
+ "--rank",
17808
+ "-E",
17809
+ "--allow-shell",
17810
+ "-v",
17811
+ "--verbose",
17812
+ "--silent",
17813
+ "--no-input",
17814
+ "--no-validate"
17815
+ ]);
17816
+ function upgradeArgs(args2) {
17817
+ const at = args2.findIndex((arg) => UPGRADE_VERBS.has(arg));
17818
+ if (at < 0) return void 0;
17819
+ const own = [];
17820
+ for (let i = 0; i < at; i++) {
17821
+ const arg = args2[i];
17822
+ if (LEADING_STOPS.has(arg) || !arg.startsWith("-")) return void 0;
17823
+ if (GLOBAL_VALUE_FLAGS.has(arg)) {
17824
+ if (i + 1 === at) return void 0;
17825
+ i++;
17826
+ } else if (!GLOBAL_BOOLEAN_FLAGS.has(arg)) {
17827
+ own.push(arg);
17828
+ }
17829
+ }
17830
+ return [args2[at], ...own, ...args2.slice(at + 1)];
17831
+ }
17768
17832
  async function upgrade(platform2, version, args2) {
17769
17833
  const command = args2[0];
17770
17834
  const parsed = parseUpgradeArgs(args2.slice(1));
@@ -18879,5 +18943,5 @@ try {
18879
18943
  });
18880
18944
  } catch {
18881
18945
  }
18882
- var code = await run(platform, "0.23.1", args);
18946
+ var code = await run(platform, "0.23.3", args);
18883
18947
  process.exit(code);
@@ -12358,6 +12358,7 @@ function startHolder(platform2, options) {
12358
12358
  var DIALOG_HOLD_MIN_VERSION = "1.39.0";
12359
12359
  var DIALOG_ANSWER_MS = 7e3;
12360
12360
  var DIALOG_CLAIM_MS = 1e3;
12361
+ var DIALOG_FAIL_FAST = 2;
12361
12362
  var DIALOG_MODES = ["report", "dismiss", "accept"];
12362
12363
  var LABEL2 = "mcpcat serve --webmcp";
12363
12364
  var REFUSED = "playwright-cli refuses to answer it (protected, unverified or in a frame)";
@@ -12391,6 +12392,26 @@ function reporter(options) {
12391
12392
  function answerProblem(event, answerMs) {
12392
12393
  return event === "timeout" ? `playwright-cli dialog-hold did not answer within ${Math.round(answerMs / 1e3)}s` : `playwright-cli dialog-hold replied ${event}`;
12393
12394
  }
12395
+ function latch() {
12396
+ let shut = false;
12397
+ let wait = Promise.resolve();
12398
+ let release = () => {
12399
+ };
12400
+ return {
12401
+ close() {
12402
+ if (shut) return;
12403
+ shut = true;
12404
+ wait = new Promise((resolve2) => {
12405
+ release = () => {
12406
+ shut = false;
12407
+ resolve2();
12408
+ };
12409
+ });
12410
+ },
12411
+ open: () => release(),
12412
+ wait: () => wait
12413
+ };
12414
+ }
12394
12415
  var isId = (value) => Number.isSafeInteger(value) && Number(value) >= 0;
12395
12416
  function startDialogHolder(platform2, options) {
12396
12417
  const verb = options.accept ? "dialog-accept" : "dialog-dismiss";
@@ -12400,6 +12421,8 @@ function startDialogHolder(platform2, options) {
12400
12421
  let stopped = false;
12401
12422
  let isReady = false;
12402
12423
  let waitedOut = false;
12424
+ let failing = false;
12425
+ let failures = 0;
12403
12426
  let armed = 0;
12404
12427
  let current;
12405
12428
  let nextId2 = 1;
@@ -12408,21 +12431,11 @@ function startDialogHolder(platform2, options) {
12408
12431
  let delay = HOLDER_RESTART_MIN_MS;
12409
12432
  let readyAt;
12410
12433
  let restartTimer;
12411
- let settled = true;
12412
- let pending = Promise.resolve();
12413
- let settle = () => {
12414
- };
12434
+ const gate = latch();
12415
12435
  const unready = () => {
12416
12436
  isReady = false;
12417
12437
  waitedOut = false;
12418
- if (!settled) return;
12419
- settled = false;
12420
- pending = new Promise((resolve2) => {
12421
- settle = () => {
12422
- settled = true;
12423
- resolve2();
12424
- };
12425
- });
12438
+ gate.close();
12426
12439
  };
12427
12440
  let exited = Promise.resolve();
12428
12441
  const report = reporter(options);
@@ -12465,8 +12478,9 @@ function startDialogHolder(platform2, options) {
12465
12478
  }
12466
12479
  if (event.event === "ready") {
12467
12480
  isReady = true;
12481
+ failing = false;
12468
12482
  readyAt = Date.now();
12469
- settle();
12483
+ gate.open();
12470
12484
  } else if (event.event === "dialog-opened" && isId(event.dialogId)) {
12471
12485
  current = { id: event.dialogId, armed: armed > 0 };
12472
12486
  if (current.armed) answer(current);
@@ -12488,7 +12502,7 @@ function startDialogHolder(platform2, options) {
12488
12502
  child = await platform2.spawn({ argv, dieWithParent: true });
12489
12503
  } catch (err2) {
12490
12504
  report(`cannot start playwright-cli dialog-hold: ${err2.message}`);
12491
- scheduleRestart();
12505
+ scheduleRestart(false);
12492
12506
  return;
12493
12507
  }
12494
12508
  if (stopped) {
@@ -12511,22 +12525,24 @@ function startDialogHolder(platform2, options) {
12511
12525
  current = void 0;
12512
12526
  reply?.resolve("holder-gone");
12513
12527
  if (!stopped) unready();
12514
- if (readyAt !== void 0 && Date.now() - readyAt >= HOLDER_STABLE_MS) {
12515
- delay = HOLDER_RESTART_MIN_MS;
12516
- }
12528
+ const reached = readyAt !== void 0;
12529
+ if (reached && Date.now() - readyAt >= HOLDER_STABLE_MS) delay = HOLDER_RESTART_MIN_MS;
12517
12530
  readyAt = void 0;
12518
12531
  if (stopped) return;
12519
12532
  const why = lastError ?? `exited ${result.status}`;
12520
12533
  report(
12521
12534
  `the dialog holder for tab ${options.tab} stopped (playwright-cli dialog-hold: ${why}); restarting in ${Math.ceil(delay / 1e3)}s`
12522
12535
  );
12523
- scheduleRestart();
12536
+ scheduleRestart(reached);
12524
12537
  });
12525
12538
  };
12526
- const scheduleRestart = () => {
12539
+ const scheduleRestart = (reached) => {
12527
12540
  if (stopped) return;
12528
12541
  const wait = delay;
12529
12542
  delay = Math.min(delay * 2, HOLDER_RESTART_MAX_MS);
12543
+ failures = reached ? 0 : failures + 1;
12544
+ failing = failures >= DIALOG_FAIL_FAST || wait >= options.readyTimeoutMs;
12545
+ if (failing) gate.open();
12530
12546
  restartTimer = setTimeout(() => {
12531
12547
  restartTimer = void 0;
12532
12548
  if (!stopped) void spawn2();
@@ -12536,8 +12552,8 @@ function startDialogHolder(platform2, options) {
12536
12552
  void spawn2();
12537
12553
  return {
12538
12554
  async ready() {
12539
- if (waitedOut || isReady) return;
12540
- if (!await within(pending, options.readyTimeoutMs)) waitedOut = true;
12555
+ if (failing || waitedOut || isReady) return;
12556
+ if (!await within(gate.wait(), options.readyTimeoutMs)) waitedOut = true;
12541
12557
  },
12542
12558
  attached: () => isReady,
12543
12559
  open: () => current !== void 0,
@@ -12557,7 +12573,7 @@ function startDialogHolder(platform2, options) {
12557
12573
  },
12558
12574
  async stop() {
12559
12575
  stopped = true;
12560
- settle();
12576
+ gate.open();
12561
12577
  clearTimeout(restartTimer);
12562
12578
  const child = proc;
12563
12579
  const w = writer;
@@ -17266,7 +17282,8 @@ async function dispatchMultiTarget(platform2, parsed, version) {
17266
17282
  }
17267
17283
  async function run(platform2, version, args) {
17268
17284
  try {
17269
- if (UPGRADE_VERBS.has(args[0])) return await upgrade(platform2, version, args);
17285
+ const upgrading = upgradeArgs(args);
17286
+ if (upgrading) return await upgrade(platform2, version, upgrading);
17270
17287
  return await runInner(platform2, version, args);
17271
17288
  } catch (err) {
17272
17289
  if (err.code === "EACCES") {
@@ -17282,6 +17299,53 @@ function wantsServeHelp(args) {
17282
17299
  return parseArgs(args).verb === "serve";
17283
17300
  }
17284
17301
  var UPGRADE_VERBS = /* @__PURE__ */ new Set(["upgrade", "update"]);
17302
+ var LEADING_STOPS = /* @__PURE__ */ new Set(["--", "--help", "-h", "--version", "-V"]);
17303
+ var GLOBAL_VALUE_FLAGS = /* @__PURE__ */ new Set([
17304
+ "-H",
17305
+ "--header",
17306
+ "-d",
17307
+ "--protocol-version",
17308
+ "--budget",
17309
+ "-e",
17310
+ "-s",
17311
+ "--server",
17312
+ "-m",
17313
+ "--timeout",
17314
+ "--respond",
17315
+ "--root",
17316
+ "-o",
17317
+ "--output",
17318
+ "--memory"
17319
+ ]);
17320
+ var GLOBAL_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
17321
+ "--schema",
17322
+ "--ts",
17323
+ "--json",
17324
+ "--rank",
17325
+ "-E",
17326
+ "--allow-shell",
17327
+ "-v",
17328
+ "--verbose",
17329
+ "--silent",
17330
+ "--no-input",
17331
+ "--no-validate"
17332
+ ]);
17333
+ function upgradeArgs(args) {
17334
+ const at = args.findIndex((arg) => UPGRADE_VERBS.has(arg));
17335
+ if (at < 0) return void 0;
17336
+ const own = [];
17337
+ for (let i = 0; i < at; i++) {
17338
+ const arg = args[i];
17339
+ if (LEADING_STOPS.has(arg) || !arg.startsWith("-")) return void 0;
17340
+ if (GLOBAL_VALUE_FLAGS.has(arg)) {
17341
+ if (i + 1 === at) return void 0;
17342
+ i++;
17343
+ } else if (!GLOBAL_BOOLEAN_FLAGS.has(arg)) {
17344
+ own.push(arg);
17345
+ }
17346
+ }
17347
+ return [args[at], ...own, ...args.slice(at + 1)];
17348
+ }
17285
17349
  async function upgrade(platform2, version, args) {
17286
17350
  const command = args[0];
17287
17351
  const parsed = parseUpgradeArgs(args.slice(1));
@@ -18106,7 +18170,7 @@ async function main(ctx) {
18106
18170
  packageDir: "/node_modules/@ai-ecoverse/mcpcat"
18107
18171
  });
18108
18172
  const args = ctx.argv.slice(1);
18109
- return run(platform2, "0.23.1", args);
18173
+ return run(platform2, "0.23.3", args);
18110
18174
  }
18111
18175
  export {
18112
18176
  main as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/mcpcat",
3
- "version": "0.23.1",
3
+ "version": "0.23.3",
4
4
  "description": "A curl for the Model Context Protocol",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -58,7 +58,7 @@
58
58
  "trust:dry": "npx fledgling sync --dry-run -y --skip-publish"
59
59
  },
60
60
  "devDependencies": {
61
- "@ai-ecoverse/slicc-kernel": "1.151.1",
61
+ "@ai-ecoverse/slicc-kernel": "1.152.1",
62
62
  "@ai-ecoverse/slicc-shared-web": "2.11.3",
63
63
  "@biomejs/biome": "2.5.15",
64
64
  "@earendil-works/pi-codemode": "1.3.0",