@zapier/zapier-sdk-cli 0.65.5 → 0.65.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @zapier/zapier-sdk-cli
2
2
 
3
+ ## 0.65.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [197a125]
8
+ - @zapier/zapier-sdk@0.84.1
9
+ - @zapier/zapier-sdk-mcp@0.18.7
10
+
11
+ ## 0.65.6
12
+
13
+ ### Patch Changes
14
+
15
+ - 4328489: Removed the `react` and `ink` runtime dependencies from the CLI, along with the `@types/react` dev dependency. The approval progress panel is now rendered directly using the terminal libraries already bundled with the CLI, so its appearance and behavior are unchanged while the installed dependency tree is significantly smaller.
16
+
3
17
  ## 0.65.5
4
18
 
5
19
  ### Patch Changes
package/dist/cli.cjs CHANGED
@@ -9,7 +9,7 @@ var search = require('@inquirer/search');
9
9
  var chalk = require('chalk');
10
10
  var ora = require('ora');
11
11
  var util = require('util');
12
- var wrapAnsi = require('wrap-ansi');
12
+ var wrapAnsi3 = require('wrap-ansi');
13
13
  var jwt = require('jsonwebtoken');
14
14
  var crossKeychain = require('cross-keychain');
15
15
  var Conf = require('conf');
@@ -33,8 +33,7 @@ var url = require('url');
33
33
  var experimental = require('@zapier/zapier-sdk/experimental');
34
34
  var packageJsonLib = require('package-json');
35
35
  var semver = require('semver');
36
- var React = require('react');
37
- var jsxRuntime = require('react/jsx-runtime');
36
+ var readline = require('readline');
38
37
 
39
38
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
40
39
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -62,7 +61,7 @@ var search__default = /*#__PURE__*/_interopDefault(search);
62
61
  var chalk__default = /*#__PURE__*/_interopDefault(chalk);
63
62
  var ora__default = /*#__PURE__*/_interopDefault(ora);
64
63
  var util__default = /*#__PURE__*/_interopDefault(util);
65
- var wrapAnsi__default = /*#__PURE__*/_interopDefault(wrapAnsi);
64
+ var wrapAnsi3__default = /*#__PURE__*/_interopDefault(wrapAnsi3);
66
65
  var jwt__namespace = /*#__PURE__*/_interopNamespace(jwt);
67
66
  var Conf__default = /*#__PURE__*/_interopDefault(Conf);
68
67
  var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
@@ -77,7 +76,7 @@ var isInstalledGlobally__default = /*#__PURE__*/_interopDefault(isInstalledGloba
77
76
  var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
78
77
  var packageJsonLib__default = /*#__PURE__*/_interopDefault(packageJsonLib);
79
78
  var semver__default = /*#__PURE__*/_interopDefault(semver);
80
- var React__default = /*#__PURE__*/_interopDefault(React);
79
+ var readline__namespace = /*#__PURE__*/_interopNamespace(readline);
81
80
 
82
81
  var __defProp = Object.defineProperty;
83
82
  var __export = (target, all) => {
@@ -638,25 +637,25 @@ var SchemaParameterResolver = class {
638
637
  name: chalk__default.default.dim("(Try a different search)"),
639
638
  value: TRY_AGAIN_SENTINEL
640
639
  };
641
- const out = [];
640
+ const out2 = [];
642
641
  if (orderedMatches.length === 0) {
643
- out.push(useAsIsChoice);
644
- out.push(tryAgainChoice);
645
- out.push(...skipChoice);
642
+ out2.push(useAsIsChoice);
643
+ out2.push(tryAgainChoice);
644
+ out2.push(...skipChoice);
646
645
  } else {
647
- out.push(...orderedMatches);
648
- out.push(...skipChoice);
649
- out.push(useAsIsChoice);
650
- out.push(tryAgainChoice);
646
+ out2.push(...orderedMatches);
647
+ out2.push(...skipChoice);
648
+ out2.push(useAsIsChoice);
649
+ out2.push(tryAgainChoice);
651
650
  }
652
651
  for (const message2 of capabilityHintMessages) {
653
- out.push({
652
+ out2.push({
654
653
  name: chalk__default.default.dim(message2),
655
654
  value: SKIP_SENTINEL,
656
655
  disabled: true
657
656
  });
658
657
  }
659
- return out;
658
+ return out2;
660
659
  }
661
660
  });
662
661
  if (selected === SKIP_SENTINEL) return void 0;
@@ -838,7 +837,7 @@ var SchemaParameterResolver = class {
838
837
  const matches = trimmed ? dataChoices.filter(
839
838
  (c) => c.name.toLowerCase().includes(lower)
840
839
  ) : dataChoices;
841
- const out = [];
840
+ const out2 = [];
842
841
  const skipChoice = isOptional ? [
843
842
  {
844
843
  name: chalk__default.default.dim("(Skip)"),
@@ -856,24 +855,24 @@ var SchemaParameterResolver = class {
856
855
  value: LOAD_MORE_SENTINEL
857
856
  } : null;
858
857
  if (matchesFirst && orderedMatches.length > 0) {
859
- out.push(...orderedMatches);
860
- out.push(...skipChoice);
861
- out.push(customValueChoice);
862
- if (loadMoreChoice) out.push(loadMoreChoice);
858
+ out2.push(...orderedMatches);
859
+ out2.push(...skipChoice);
860
+ out2.push(customValueChoice);
861
+ if (loadMoreChoice) out2.push(loadMoreChoice);
863
862
  } else if (matchesFirst) {
864
- out.push(customValueChoice);
865
- if (loadMoreChoice) out.push(loadMoreChoice);
866
- out.push(...skipChoice);
863
+ out2.push(customValueChoice);
864
+ if (loadMoreChoice) out2.push(loadMoreChoice);
865
+ out2.push(...skipChoice);
867
866
  } else {
868
- out.push(...skipChoice);
869
- out.push(customValueChoice);
870
- out.push(...orderedMatches);
871
- if (loadMoreChoice) out.push(loadMoreChoice);
867
+ out2.push(...skipChoice);
868
+ out2.push(customValueChoice);
869
+ out2.push(...orderedMatches);
870
+ if (loadMoreChoice) out2.push(loadMoreChoice);
872
871
  }
873
872
  if (capabilityHints.length > 0 && (!trimmed || matches.length > 0)) {
874
- out.push(...capabilityHints);
873
+ out2.push(...capabilityHints);
875
874
  }
876
- return out;
875
+ return out2;
877
876
  }
878
877
  });
879
878
  } else {
@@ -1315,7 +1314,7 @@ Optional fields${pathContext}:`));
1315
1314
  const trimmed = (term ?? "").trim();
1316
1315
  const lower = trimmed.toLowerCase();
1317
1316
  const matches = trimmed ? dataChoices.filter((c) => c.name.toLowerCase().includes(lower)) : dataChoices;
1318
- const out = [];
1317
+ const out2 = [];
1319
1318
  const skipChoice = !fieldMeta.isRequired ? [{ name: chalk__default.default.dim("(Skip)"), value: SKIP_SENTINEL }] : [];
1320
1319
  const customValueChoice = {
1321
1320
  name: chalk__default.default.dim("(Enter custom value)"),
@@ -1326,21 +1325,21 @@ Optional fields${pathContext}:`));
1326
1325
  value: LOAD_MORE_SENTINEL
1327
1326
  } : null;
1328
1327
  if (trimmed && matches.length > 0) {
1329
- out.push(...matches);
1330
- out.push(...skipChoice);
1331
- out.push(customValueChoice);
1332
- if (loadMoreChoice) out.push(loadMoreChoice);
1328
+ out2.push(...matches);
1329
+ out2.push(...skipChoice);
1330
+ out2.push(customValueChoice);
1331
+ if (loadMoreChoice) out2.push(loadMoreChoice);
1333
1332
  } else if (trimmed) {
1334
- out.push(customValueChoice);
1335
- if (loadMoreChoice) out.push(loadMoreChoice);
1336
- out.push(...skipChoice);
1333
+ out2.push(customValueChoice);
1334
+ if (loadMoreChoice) out2.push(loadMoreChoice);
1335
+ out2.push(...skipChoice);
1337
1336
  } else {
1338
- out.push(...skipChoice);
1339
- out.push(customValueChoice);
1340
- out.push(...matches);
1341
- if (loadMoreChoice) out.push(loadMoreChoice);
1337
+ out2.push(...skipChoice);
1338
+ out2.push(customValueChoice);
1339
+ out2.push(...matches);
1340
+ if (loadMoreChoice) out2.push(loadMoreChoice);
1342
1341
  }
1343
- return out;
1342
+ return out2;
1344
1343
  }
1345
1344
  });
1346
1345
  if (selectedValue === SKIP_SENTINEL) {
@@ -1760,7 +1759,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1760
1759
 
1761
1760
  // package.json
1762
1761
  var package_default = {
1763
- version: "0.65.5"};
1762
+ version: "0.65.7"};
1764
1763
 
1765
1764
  // src/telemetry/builders.ts
1766
1765
  function createCliBaseEvent(context = {}) {
@@ -1903,7 +1902,7 @@ var DETAIL_INDENT = " ";
1903
1902
  var DETAIL_MAX_LINES = 5;
1904
1903
  function formatDetailText(text, indent = DETAIL_INDENT) {
1905
1904
  const columns = Math.max((process.stdout.columns || 80) - indent.length, 40);
1906
- const wrapped = wrapAnsi__default.default(text, columns, { hard: true, trim: false });
1905
+ const wrapped = wrapAnsi3__default.default(text, columns, { hard: true, trim: false });
1907
1906
  const lines = wrapped.split("\n");
1908
1907
  if (lines.length <= DETAIL_MAX_LINES) {
1909
1908
  return lines.join("\n" + indent);
@@ -6658,27 +6657,27 @@ function formatWriteOut(params) {
6658
6657
  "%{url_effective}": params.urlEffective,
6659
6658
  "%{content_type}": params.contentType ?? ""
6660
6659
  };
6661
- let out = template;
6660
+ let out2 = template;
6662
6661
  for (const [token, value] of Object.entries(replacements)) {
6663
- out = out.split(token).join(value);
6662
+ out2 = out2.split(token).join(value);
6664
6663
  }
6665
- return decodeWriteOutEscapes(out);
6664
+ return decodeWriteOutEscapes(out2);
6666
6665
  }
6667
6666
  function appendQueryParams(url, dataParts) {
6668
- const out = new URL(url.toString());
6667
+ const out2 = new URL(url.toString());
6669
6668
  for (const part of dataParts) {
6670
6669
  const segments = part.split("&");
6671
6670
  for (const seg of segments) {
6672
6671
  if (!seg) continue;
6673
6672
  const idx = seg.indexOf("=");
6674
6673
  if (idx === -1) {
6675
- out.searchParams.append(seg, "");
6674
+ out2.searchParams.append(seg, "");
6676
6675
  } else {
6677
- out.searchParams.append(seg.slice(0, idx), seg.slice(idx + 1));
6676
+ out2.searchParams.append(seg.slice(0, idx), seg.slice(idx + 1));
6678
6677
  }
6679
6678
  }
6680
6679
  }
6681
- return out;
6680
+ return out2;
6682
6681
  }
6683
6682
  async function readAllStdin() {
6684
6683
  const chunks = [];
@@ -8008,7 +8007,7 @@ function renderDeprecationNotices() {
8008
8007
  function buildBoxLines(message) {
8009
8008
  const innerWidth = BOX_WIDTH - 4;
8010
8009
  const pad = (line) => `\u2502 ${line.padEnd(innerWidth)} \u2502`;
8011
- const wrapped = wrapAnsi__default.default(message, innerWidth, { hard: true }).split("\n");
8010
+ const wrapped = wrapAnsi3__default.default(message, innerWidth, { hard: true }).split("\n");
8012
8011
  return [
8013
8012
  `\u256D${"\u2500".repeat(BOX_WIDTH - 2)}\u256E`,
8014
8013
  pad(BOX_TITLE),
@@ -8021,7 +8020,7 @@ function buildBoxLines(message) {
8021
8020
  // package.json with { type: 'json' }
8022
8021
  var package_default2 = {
8023
8022
  name: "@zapier/zapier-sdk-cli",
8024
- version: "0.65.5"};
8023
+ version: "0.65.7"};
8025
8024
 
8026
8025
  // src/sdk.ts
8027
8026
  var warnedDeprecatedMethods = /* @__PURE__ */ new Set();
@@ -8359,16 +8358,63 @@ async function checkAndNotifyUpdates({
8359
8358
  const versionInfo = await checkForUpdates({ packageName, currentVersion });
8360
8359
  displayUpdateNotification(versionInfo, packageName);
8361
8360
  }
8361
+ var EMOJI_PRESENTATION_PATTERN = /\p{Emoji_Presentation}/u;
8362
+ var WIDE_CODE_POINT_RANGES = [
8363
+ [4352, 4447],
8364
+ // Hangul Jamo
8365
+ [11904, 12350],
8366
+ // CJK Radicals ... CJK Symbols and Punctuation
8367
+ [12353, 13311],
8368
+ // Hiragana ... CJK Compatibility
8369
+ [13312, 19903],
8370
+ // CJK Unified Ideographs Extension A
8371
+ [19968, 40959],
8372
+ // CJK Unified Ideographs
8373
+ [40960, 42191],
8374
+ // Yi Syllables, Yi Radicals
8375
+ [44032, 55203],
8376
+ // Hangul Syllables
8377
+ [63744, 64255],
8378
+ // CJK Compatibility Ideographs
8379
+ [65040, 65049],
8380
+ // Vertical Forms
8381
+ [65072, 65131],
8382
+ // CJK Compatibility Forms, Small Form Variants
8383
+ [65281, 65376],
8384
+ // Fullwidth Forms
8385
+ [65504, 65510],
8386
+ // Fullwidth Signs
8387
+ [110592, 110593],
8388
+ // Kana Supplement
8389
+ [131072, 262141]
8390
+ // CJK Unified Ideographs Extension B and beyond
8391
+ ];
8392
+ function isWideCodePoint(codePoint) {
8393
+ return WIDE_CODE_POINT_RANGES.some(
8394
+ ([start, end]) => codePoint >= start && codePoint <= end
8395
+ );
8396
+ }
8397
+ function displayWidth(text) {
8398
+ let width = 0;
8399
+ for (const character of util.stripVTControlCharacters(text)) {
8400
+ const codePoint = character.codePointAt(0);
8401
+ if (codePoint === void 0) continue;
8402
+ width += isWideCodePoint(codePoint) || EMOJI_PRESENTATION_PATTERN.test(character) ? 2 : 1;
8403
+ }
8404
+ return width;
8405
+ }
8406
+
8407
+ // src/utils/approval-progress.ts
8362
8408
  var FALLBACK_PANEL_WIDTH = 72;
8363
8409
  var MIN_PANEL_WIDTH = 36;
8364
8410
  var MAX_PANEL_WIDTH = 88;
8365
8411
  var SPINNER_INTERVAL_MS = 80;
8366
8412
  var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
8367
- var inkImportPromise;
8368
- function loadInk() {
8369
- inkImportPromise ?? (inkImportPromise = import('ink'));
8370
- return inkImportPromise;
8371
- }
8413
+ var ESC = String.fromCharCode(27);
8414
+ var HIDE_CURSOR = `${ESC}[?25l`;
8415
+ var SHOW_CURSOR = `${ESC}[?25h`;
8416
+ var CURSOR_RESTORE_SIGNALS = ["SIGINT", "SIGTERM"];
8417
+ var out = process.stderr;
8372
8418
  function createInitialState() {
8373
8419
  return {
8374
8420
  messages: [],
@@ -8376,7 +8422,7 @@ function createInitialState() {
8376
8422
  };
8377
8423
  }
8378
8424
  function getPanelWidth() {
8379
- const terminalColumns = process.stderr.columns;
8425
+ const terminalColumns = out.columns;
8380
8426
  if (!terminalColumns) return FALLBACK_PANEL_WIDTH;
8381
8427
  return Math.min(
8382
8428
  Math.max(terminalColumns - 4, MIN_PANEL_WIDTH),
@@ -8398,128 +8444,186 @@ function getApprovedVerdict(decision, reason) {
8398
8444
  reason
8399
8445
  };
8400
8446
  }
8401
- function Spinner({ text }) {
8402
- const [frameIndex, setFrameIndex] = React__default.default.useState(0);
8403
- const InkText = text;
8404
- React__default.default.useEffect(() => {
8405
- const timer = setInterval(() => {
8406
- setFrameIndex((index) => (index + 1) % SPINNER_FRAMES.length);
8407
- }, SPINNER_INTERVAL_MS);
8408
- return () => clearInterval(timer);
8409
- }, []);
8410
- return /* @__PURE__ */ jsxRuntime.jsx(InkText, { color: "yellow", children: `${SPINNER_FRAMES[frameIndex]} Checking approval...` });
8411
- }
8412
- function ApprovalProgressView({
8413
- state,
8414
- box,
8415
- text
8416
- }) {
8417
- if (!state.active) return null;
8418
- const InkBox = box;
8419
- const InkText = text;
8447
+ function buildFrameLines(state, frameIndex) {
8448
+ const width = getPanelWidth();
8449
+ const innerWidth = width - 4;
8450
+ const bodyWidth = width - 2;
8451
+ const bodyTextWidth = innerWidth - 2;
8452
+ const content = [];
8453
+ content.push(chalk__default.default.bold.cyan("Approval review"));
8454
+ content.push("");
8455
+ if (!state.verdict) {
8456
+ content.push(
8457
+ chalk__default.default.yellow(`${SPINNER_FRAMES[frameIndex]} Checking approval...`)
8458
+ );
8459
+ }
8420
8460
  const recentMessages = state.messages.slice(-5);
8421
8461
  const hasMessages = recentMessages.length > 0;
8422
- return /* @__PURE__ */ jsxRuntime.jsxs(
8423
- InkBox,
8424
- {
8425
- borderColor: "cyan",
8426
- borderStyle: "round",
8427
- flexDirection: "column",
8428
- paddingX: 1,
8429
- width: getPanelWidth(),
8430
- children: [
8431
- /* @__PURE__ */ jsxRuntime.jsx(InkText, { bold: true, color: "cyan", children: "Approval review" }),
8432
- /* @__PURE__ */ jsxRuntime.jsxs(InkBox, { flexDirection: "column", marginTop: 1, children: [
8433
- !state.verdict && /* @__PURE__ */ jsxRuntime.jsx(Spinner, { text }),
8434
- recentMessages.map((message, index) => /* @__PURE__ */ jsxRuntime.jsxs(InkBox, { flexDirection: "row", children: [
8435
- /* @__PURE__ */ jsxRuntime.jsx(InkText, { color: "cyan", children: "> " }),
8436
- /* @__PURE__ */ jsxRuntime.jsx(
8437
- InkText,
8438
- {
8439
- dimColor: Boolean(state.verdict) || index < recentMessages.length - 1,
8440
- wrap: "wrap",
8441
- children: message
8442
- }
8443
- )
8444
- ] }, `${index}-${message}`)),
8445
- state.streamError && /* @__PURE__ */ jsxRuntime.jsxs(
8446
- InkBox,
8447
- {
8448
- flexDirection: "column",
8449
- marginTop: hasMessages || !state.verdict ? 1 : 0,
8450
- children: [
8451
- /* @__PURE__ */ jsxRuntime.jsx(InkText, { bold: true, color: "red", children: "Approval stream error" }),
8452
- /* @__PURE__ */ jsxRuntime.jsx(InkText, { wrap: "wrap", children: ` ${state.streamError}` })
8453
- ]
8454
- }
8455
- ),
8456
- state.verdict && /* @__PURE__ */ jsxRuntime.jsxs(
8457
- InkBox,
8458
- {
8459
- flexDirection: "column",
8460
- marginTop: hasMessages || state.streamError ? 1 : 0,
8461
- children: [
8462
- /* @__PURE__ */ jsxRuntime.jsx(InkText, { bold: true, color: state.verdict.color, children: `${state.verdict.icon} ${state.verdict.label}` }),
8463
- state.verdict.reason && /* @__PURE__ */ jsxRuntime.jsx(InkText, { wrap: "wrap", children: ` ${state.verdict.reason}` })
8464
- ]
8465
- }
8466
- )
8467
- ] })
8468
- ]
8462
+ recentMessages.forEach((message, index) => {
8463
+ const dimmed = Boolean(state.verdict) || index < recentMessages.length - 1;
8464
+ const segments = wrapAnsi3__default.default(message, bodyTextWidth, { hard: true }).split(
8465
+ "\n"
8466
+ );
8467
+ segments.forEach((segment, segmentIndex) => {
8468
+ const prefix = segmentIndex === 0 ? chalk__default.default.cyan("> ") : " ";
8469
+ content.push(`${prefix}${dimmed ? chalk__default.default.dim(segment) : segment}`);
8470
+ });
8471
+ });
8472
+ if (state.streamError) {
8473
+ if (hasMessages || !state.verdict) content.push("");
8474
+ content.push(chalk__default.default.bold.red("Approval stream error"));
8475
+ for (const segment of wrapAnsi3__default.default(state.streamError, bodyTextWidth, {
8476
+ hard: true
8477
+ }).split("\n")) {
8478
+ content.push(` ${segment}`);
8479
+ }
8480
+ }
8481
+ if (state.verdict) {
8482
+ if (hasMessages || state.streamError) content.push("");
8483
+ content.push(
8484
+ chalk__default.default.bold.green(`${state.verdict.icon} ${state.verdict.label}`)
8485
+ );
8486
+ if (state.verdict.reason) {
8487
+ for (const segment of wrapAnsi3__default.default(state.verdict.reason, bodyTextWidth, {
8488
+ hard: true
8489
+ }).split("\n")) {
8490
+ content.push(` ${segment}`);
8491
+ }
8469
8492
  }
8470
- );
8493
+ }
8494
+ const pad = (line) => {
8495
+ const padding = " ".repeat(Math.max(0, innerWidth - displayWidth(line)));
8496
+ return `${chalk__default.default.cyan("\u2502")} ${line}${padding} ${chalk__default.default.cyan("\u2502")}`;
8497
+ };
8498
+ return [
8499
+ chalk__default.default.cyan(`\u256D${"\u2500".repeat(bodyWidth)}\u256E`),
8500
+ ...content.map(pad),
8501
+ chalk__default.default.cyan(`\u2570${"\u2500".repeat(bodyWidth)}\u256F`)
8502
+ ];
8471
8503
  }
8472
8504
  function createApprovalProgressRenderer({
8473
8505
  enabled,
8474
8506
  onEvent
8475
8507
  }) {
8476
- let instance;
8477
8508
  let currentState = createInitialState();
8478
- let renderQueue = Promise.resolve();
8479
- let renderGeneration = 0;
8480
8509
  let renderEnabled = enabled;
8510
+ let disposed = false;
8481
8511
  let renderErrorReported = false;
8512
+ let lastFrameLineCount = 0;
8513
+ let spinnerFrameIndex = 0;
8514
+ let spinnerTimer;
8515
+ let cursorHidden = false;
8516
+ let signalHandlers = [];
8517
+ function restoreCursor() {
8518
+ if (cursorHidden) {
8519
+ try {
8520
+ out.write(SHOW_CURSOR);
8521
+ } catch {
8522
+ }
8523
+ cursorHidden = false;
8524
+ }
8525
+ for (const { signal, handler } of signalHandlers) {
8526
+ process.removeListener(signal, handler);
8527
+ }
8528
+ signalHandlers = [];
8529
+ }
8530
+ function ensureCursorHidden() {
8531
+ if (cursorHidden) return;
8532
+ out.write(HIDE_CURSOR);
8533
+ cursorHidden = true;
8534
+ for (const signal of CURSOR_RESTORE_SIGNALS) {
8535
+ const handler = () => {
8536
+ restoreCursor();
8537
+ if (process.listenerCount(signal) === 0) {
8538
+ process.kill(process.pid, signal);
8539
+ }
8540
+ };
8541
+ signalHandlers.push({ signal, handler });
8542
+ process.once(signal, handler);
8543
+ }
8544
+ }
8545
+ function eraseFrame() {
8546
+ if (lastFrameLineCount === 0) return;
8547
+ readline__namespace.moveCursor(out, 0, -lastFrameLineCount);
8548
+ readline__namespace.cursorTo(out, 0);
8549
+ readline__namespace.clearScreenDown(out);
8550
+ lastFrameLineCount = 0;
8551
+ }
8552
+ function paint(lines) {
8553
+ eraseFrame();
8554
+ out.write(`${lines.join("\n")}
8555
+ `);
8556
+ lastFrameLineCount = lines.length;
8557
+ }
8558
+ function renderFrame(state) {
8559
+ paint(buildFrameLines(state, spinnerFrameIndex));
8560
+ }
8561
+ function stopSpinnerTimer() {
8562
+ if (spinnerTimer) {
8563
+ clearInterval(spinnerTimer);
8564
+ spinnerTimer = void 0;
8565
+ }
8566
+ }
8567
+ function disableAfterError(error) {
8568
+ renderEnabled = false;
8569
+ stopSpinnerTimer();
8570
+ restoreCursor();
8571
+ lastFrameLineCount = 0;
8572
+ currentState = createInitialState();
8573
+ if (renderErrorReported) return;
8574
+ renderErrorReported = true;
8575
+ const message = error instanceof Error ? error.message : String(error);
8576
+ try {
8577
+ out.write(`Approval progress unavailable: ${message}
8578
+ `);
8579
+ } catch {
8580
+ }
8581
+ }
8582
+ function ensureSpinnerTimer() {
8583
+ if (spinnerTimer) return;
8584
+ spinnerTimer = setInterval(() => {
8585
+ if (!renderEnabled || !currentState.active || currentState.verdict) {
8586
+ return;
8587
+ }
8588
+ spinnerFrameIndex = (spinnerFrameIndex + 1) % SPINNER_FRAMES.length;
8589
+ try {
8590
+ renderFrame(currentState);
8591
+ } catch (error) {
8592
+ disableAfterError(error);
8593
+ }
8594
+ }, SPINNER_INTERVAL_MS);
8595
+ spinnerTimer.unref?.();
8596
+ }
8482
8597
  function update(nextState, { complete = false } = {}) {
8483
- const generation = renderGeneration;
8484
- currentState = complete ? createInitialState() : nextState;
8485
- renderQueue = renderQueue.then(async () => {
8486
- if (generation !== renderGeneration) return;
8487
- const { Box, Text, render } = await loadInk();
8488
- if (generation !== renderGeneration) return;
8489
- const element = /* @__PURE__ */ jsxRuntime.jsx(ApprovalProgressView, { state: nextState, box: Box, text: Text });
8490
- if (!instance) {
8491
- instance = render(element, {
8492
- stdout: process.stderr,
8493
- stderr: process.stderr
8494
- });
8598
+ try {
8599
+ ensureCursorHidden();
8600
+ renderFrame(nextState);
8601
+ if (complete) {
8602
+ stopSpinnerTimer();
8603
+ restoreCursor();
8604
+ lastFrameLineCount = 0;
8605
+ currentState = createInitialState();
8495
8606
  } else {
8496
- instance.rerender(element);
8607
+ currentState = nextState;
8608
+ ensureSpinnerTimer();
8497
8609
  }
8498
- if (complete) {
8499
- instance.unmount();
8500
- instance = void 0;
8501
- }
8502
- }).catch((error) => {
8503
- if (generation !== renderGeneration) return;
8504
- renderEnabled = false;
8505
- currentState = createInitialState();
8506
- if (renderErrorReported) return;
8507
- renderErrorReported = true;
8508
- const message = error instanceof Error ? error.message : String(error);
8509
- process.stderr.write(`Approval progress unavailable: ${message}
8510
- `);
8511
- });
8610
+ } catch (error) {
8611
+ disableAfterError(error);
8612
+ }
8512
8613
  }
8513
8614
  function dismiss() {
8514
- renderGeneration++;
8615
+ stopSpinnerTimer();
8616
+ try {
8617
+ eraseFrame();
8618
+ } catch {
8619
+ }
8620
+ restoreCursor();
8515
8621
  currentState = createInitialState();
8516
- instance?.unmount();
8517
- instance = void 0;
8518
8622
  }
8519
8623
  return {
8520
8624
  onEvent(event) {
8521
8625
  onEvent?.(event);
8522
- if (!renderEnabled) return;
8626
+ if (disposed || !renderEnabled) return;
8523
8627
  if (event.type === "approval:required") {
8524
8628
  if (event.payload?.mode !== "auto") return;
8525
8629
  update({
@@ -8580,6 +8684,11 @@ function createApprovalProgressRenderer({
8580
8684
  if (event.type === "approval:denied" || event.type === "approval:failed" || event.type === "approval:timeout" || event.type === "approval:error") {
8581
8685
  dismiss();
8582
8686
  }
8687
+ },
8688
+ dispose() {
8689
+ disposed = true;
8690
+ stopSpinnerTimer();
8691
+ restoreCursor();
8583
8692
  }
8584
8693
  };
8585
8694
  }
@@ -8725,6 +8834,8 @@ program.exitOverride();
8725
8834
  console.error("Unexpected error:", error);
8726
8835
  exitCode = 1;
8727
8836
  }
8837
+ } finally {
8838
+ approvalProgress.dispose();
8728
8839
  }
8729
8840
  await versionCheckPromise;
8730
8841
  await zapierSdk.disposeSdk(sdk, { exitCode }).catch(() => {
package/dist/cli.mjs CHANGED
@@ -6,8 +6,8 @@ import inquirer from 'inquirer';
6
6
  import search from '@inquirer/search';
7
7
  import chalk from 'chalk';
8
8
  import ora from 'ora';
9
- import util from 'util';
10
- import wrapAnsi from 'wrap-ansi';
9
+ import util, { stripVTControlCharacters } from 'util';
10
+ import wrapAnsi3 from 'wrap-ansi';
11
11
  import * as jwt from 'jsonwebtoken';
12
12
  import { deletePassword, getKeyring, setPassword, getPassword } from 'cross-keychain';
13
13
  import Conf from 'conf';
@@ -33,8 +33,7 @@ import { fileURLToPath } from 'url';
33
33
  import { triggerInboxResolver, DrainTriggerInboxSchema, WatchTriggerInboxSchema, injectCliLogin as injectCliLogin$1, definePlugin as definePlugin$1, omitExports as omitExports$1, zapierExperimentalSdkPlugin, createSdk, CORE_OPTIONS_ID, SDK_OPTIONS_ID, addPlugin } from '@zapier/zapier-sdk/experimental';
34
34
  import packageJsonLib, { VersionNotFoundError } from 'package-json';
35
35
  import semver from 'semver';
36
- import React from 'react';
37
- import { jsx, jsxs } from 'react/jsx-runtime';
36
+ import * as readline from 'readline';
38
37
 
39
38
  var __defProp = Object.defineProperty;
40
39
  var __export = (target, all) => {
@@ -595,25 +594,25 @@ var SchemaParameterResolver = class {
595
594
  name: chalk.dim("(Try a different search)"),
596
595
  value: TRY_AGAIN_SENTINEL
597
596
  };
598
- const out = [];
597
+ const out2 = [];
599
598
  if (orderedMatches.length === 0) {
600
- out.push(useAsIsChoice);
601
- out.push(tryAgainChoice);
602
- out.push(...skipChoice);
599
+ out2.push(useAsIsChoice);
600
+ out2.push(tryAgainChoice);
601
+ out2.push(...skipChoice);
603
602
  } else {
604
- out.push(...orderedMatches);
605
- out.push(...skipChoice);
606
- out.push(useAsIsChoice);
607
- out.push(tryAgainChoice);
603
+ out2.push(...orderedMatches);
604
+ out2.push(...skipChoice);
605
+ out2.push(useAsIsChoice);
606
+ out2.push(tryAgainChoice);
608
607
  }
609
608
  for (const message2 of capabilityHintMessages) {
610
- out.push({
609
+ out2.push({
611
610
  name: chalk.dim(message2),
612
611
  value: SKIP_SENTINEL,
613
612
  disabled: true
614
613
  });
615
614
  }
616
- return out;
615
+ return out2;
617
616
  }
618
617
  });
619
618
  if (selected === SKIP_SENTINEL) return void 0;
@@ -795,7 +794,7 @@ var SchemaParameterResolver = class {
795
794
  const matches = trimmed ? dataChoices.filter(
796
795
  (c) => c.name.toLowerCase().includes(lower)
797
796
  ) : dataChoices;
798
- const out = [];
797
+ const out2 = [];
799
798
  const skipChoice = isOptional ? [
800
799
  {
801
800
  name: chalk.dim("(Skip)"),
@@ -813,24 +812,24 @@ var SchemaParameterResolver = class {
813
812
  value: LOAD_MORE_SENTINEL
814
813
  } : null;
815
814
  if (matchesFirst && orderedMatches.length > 0) {
816
- out.push(...orderedMatches);
817
- out.push(...skipChoice);
818
- out.push(customValueChoice);
819
- if (loadMoreChoice) out.push(loadMoreChoice);
815
+ out2.push(...orderedMatches);
816
+ out2.push(...skipChoice);
817
+ out2.push(customValueChoice);
818
+ if (loadMoreChoice) out2.push(loadMoreChoice);
820
819
  } else if (matchesFirst) {
821
- out.push(customValueChoice);
822
- if (loadMoreChoice) out.push(loadMoreChoice);
823
- out.push(...skipChoice);
820
+ out2.push(customValueChoice);
821
+ if (loadMoreChoice) out2.push(loadMoreChoice);
822
+ out2.push(...skipChoice);
824
823
  } else {
825
- out.push(...skipChoice);
826
- out.push(customValueChoice);
827
- out.push(...orderedMatches);
828
- if (loadMoreChoice) out.push(loadMoreChoice);
824
+ out2.push(...skipChoice);
825
+ out2.push(customValueChoice);
826
+ out2.push(...orderedMatches);
827
+ if (loadMoreChoice) out2.push(loadMoreChoice);
829
828
  }
830
829
  if (capabilityHints.length > 0 && (!trimmed || matches.length > 0)) {
831
- out.push(...capabilityHints);
830
+ out2.push(...capabilityHints);
832
831
  }
833
- return out;
832
+ return out2;
834
833
  }
835
834
  });
836
835
  } else {
@@ -1272,7 +1271,7 @@ Optional fields${pathContext}:`));
1272
1271
  const trimmed = (term ?? "").trim();
1273
1272
  const lower = trimmed.toLowerCase();
1274
1273
  const matches = trimmed ? dataChoices.filter((c) => c.name.toLowerCase().includes(lower)) : dataChoices;
1275
- const out = [];
1274
+ const out2 = [];
1276
1275
  const skipChoice = !fieldMeta.isRequired ? [{ name: chalk.dim("(Skip)"), value: SKIP_SENTINEL }] : [];
1277
1276
  const customValueChoice = {
1278
1277
  name: chalk.dim("(Enter custom value)"),
@@ -1283,21 +1282,21 @@ Optional fields${pathContext}:`));
1283
1282
  value: LOAD_MORE_SENTINEL
1284
1283
  } : null;
1285
1284
  if (trimmed && matches.length > 0) {
1286
- out.push(...matches);
1287
- out.push(...skipChoice);
1288
- out.push(customValueChoice);
1289
- if (loadMoreChoice) out.push(loadMoreChoice);
1285
+ out2.push(...matches);
1286
+ out2.push(...skipChoice);
1287
+ out2.push(customValueChoice);
1288
+ if (loadMoreChoice) out2.push(loadMoreChoice);
1290
1289
  } else if (trimmed) {
1291
- out.push(customValueChoice);
1292
- if (loadMoreChoice) out.push(loadMoreChoice);
1293
- out.push(...skipChoice);
1290
+ out2.push(customValueChoice);
1291
+ if (loadMoreChoice) out2.push(loadMoreChoice);
1292
+ out2.push(...skipChoice);
1294
1293
  } else {
1295
- out.push(...skipChoice);
1296
- out.push(customValueChoice);
1297
- out.push(...matches);
1298
- if (loadMoreChoice) out.push(loadMoreChoice);
1294
+ out2.push(...skipChoice);
1295
+ out2.push(customValueChoice);
1296
+ out2.push(...matches);
1297
+ if (loadMoreChoice) out2.push(loadMoreChoice);
1299
1298
  }
1300
- return out;
1299
+ return out2;
1301
1300
  }
1302
1301
  });
1303
1302
  if (selectedValue === SKIP_SENTINEL) {
@@ -1717,7 +1716,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1717
1716
 
1718
1717
  // package.json
1719
1718
  var package_default = {
1720
- version: "0.65.5"};
1719
+ version: "0.65.7"};
1721
1720
 
1722
1721
  // src/telemetry/builders.ts
1723
1722
  function createCliBaseEvent(context = {}) {
@@ -1860,7 +1859,7 @@ var DETAIL_INDENT = " ";
1860
1859
  var DETAIL_MAX_LINES = 5;
1861
1860
  function formatDetailText(text, indent = DETAIL_INDENT) {
1862
1861
  const columns = Math.max((process.stdout.columns || 80) - indent.length, 40);
1863
- const wrapped = wrapAnsi(text, columns, { hard: true, trim: false });
1862
+ const wrapped = wrapAnsi3(text, columns, { hard: true, trim: false });
1864
1863
  const lines = wrapped.split("\n");
1865
1864
  if (lines.length <= DETAIL_MAX_LINES) {
1866
1865
  return lines.join("\n" + indent);
@@ -6615,27 +6614,27 @@ function formatWriteOut(params) {
6615
6614
  "%{url_effective}": params.urlEffective,
6616
6615
  "%{content_type}": params.contentType ?? ""
6617
6616
  };
6618
- let out = template;
6617
+ let out2 = template;
6619
6618
  for (const [token, value] of Object.entries(replacements)) {
6620
- out = out.split(token).join(value);
6619
+ out2 = out2.split(token).join(value);
6621
6620
  }
6622
- return decodeWriteOutEscapes(out);
6621
+ return decodeWriteOutEscapes(out2);
6623
6622
  }
6624
6623
  function appendQueryParams(url, dataParts) {
6625
- const out = new URL(url.toString());
6624
+ const out2 = new URL(url.toString());
6626
6625
  for (const part of dataParts) {
6627
6626
  const segments = part.split("&");
6628
6627
  for (const seg of segments) {
6629
6628
  if (!seg) continue;
6630
6629
  const idx = seg.indexOf("=");
6631
6630
  if (idx === -1) {
6632
- out.searchParams.append(seg, "");
6631
+ out2.searchParams.append(seg, "");
6633
6632
  } else {
6634
- out.searchParams.append(seg.slice(0, idx), seg.slice(idx + 1));
6633
+ out2.searchParams.append(seg.slice(0, idx), seg.slice(idx + 1));
6635
6634
  }
6636
6635
  }
6637
6636
  }
6638
- return out;
6637
+ return out2;
6639
6638
  }
6640
6639
  async function readAllStdin() {
6641
6640
  const chunks = [];
@@ -7965,7 +7964,7 @@ function renderDeprecationNotices() {
7965
7964
  function buildBoxLines(message) {
7966
7965
  const innerWidth = BOX_WIDTH - 4;
7967
7966
  const pad = (line) => `\u2502 ${line.padEnd(innerWidth)} \u2502`;
7968
- const wrapped = wrapAnsi(message, innerWidth, { hard: true }).split("\n");
7967
+ const wrapped = wrapAnsi3(message, innerWidth, { hard: true }).split("\n");
7969
7968
  return [
7970
7969
  `\u256D${"\u2500".repeat(BOX_WIDTH - 2)}\u256E`,
7971
7970
  pad(BOX_TITLE),
@@ -7978,7 +7977,7 @@ function buildBoxLines(message) {
7978
7977
  // package.json with { type: 'json' }
7979
7978
  var package_default2 = {
7980
7979
  name: "@zapier/zapier-sdk-cli",
7981
- version: "0.65.5"};
7980
+ version: "0.65.7"};
7982
7981
 
7983
7982
  // src/sdk.ts
7984
7983
  var warnedDeprecatedMethods = /* @__PURE__ */ new Set();
@@ -8316,16 +8315,63 @@ async function checkAndNotifyUpdates({
8316
8315
  const versionInfo = await checkForUpdates({ packageName, currentVersion });
8317
8316
  displayUpdateNotification(versionInfo, packageName);
8318
8317
  }
8318
+ var EMOJI_PRESENTATION_PATTERN = /\p{Emoji_Presentation}/u;
8319
+ var WIDE_CODE_POINT_RANGES = [
8320
+ [4352, 4447],
8321
+ // Hangul Jamo
8322
+ [11904, 12350],
8323
+ // CJK Radicals ... CJK Symbols and Punctuation
8324
+ [12353, 13311],
8325
+ // Hiragana ... CJK Compatibility
8326
+ [13312, 19903],
8327
+ // CJK Unified Ideographs Extension A
8328
+ [19968, 40959],
8329
+ // CJK Unified Ideographs
8330
+ [40960, 42191],
8331
+ // Yi Syllables, Yi Radicals
8332
+ [44032, 55203],
8333
+ // Hangul Syllables
8334
+ [63744, 64255],
8335
+ // CJK Compatibility Ideographs
8336
+ [65040, 65049],
8337
+ // Vertical Forms
8338
+ [65072, 65131],
8339
+ // CJK Compatibility Forms, Small Form Variants
8340
+ [65281, 65376],
8341
+ // Fullwidth Forms
8342
+ [65504, 65510],
8343
+ // Fullwidth Signs
8344
+ [110592, 110593],
8345
+ // Kana Supplement
8346
+ [131072, 262141]
8347
+ // CJK Unified Ideographs Extension B and beyond
8348
+ ];
8349
+ function isWideCodePoint(codePoint) {
8350
+ return WIDE_CODE_POINT_RANGES.some(
8351
+ ([start, end]) => codePoint >= start && codePoint <= end
8352
+ );
8353
+ }
8354
+ function displayWidth(text) {
8355
+ let width = 0;
8356
+ for (const character of stripVTControlCharacters(text)) {
8357
+ const codePoint = character.codePointAt(0);
8358
+ if (codePoint === void 0) continue;
8359
+ width += isWideCodePoint(codePoint) || EMOJI_PRESENTATION_PATTERN.test(character) ? 2 : 1;
8360
+ }
8361
+ return width;
8362
+ }
8363
+
8364
+ // src/utils/approval-progress.ts
8319
8365
  var FALLBACK_PANEL_WIDTH = 72;
8320
8366
  var MIN_PANEL_WIDTH = 36;
8321
8367
  var MAX_PANEL_WIDTH = 88;
8322
8368
  var SPINNER_INTERVAL_MS = 80;
8323
8369
  var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
8324
- var inkImportPromise;
8325
- function loadInk() {
8326
- inkImportPromise ?? (inkImportPromise = import('ink'));
8327
- return inkImportPromise;
8328
- }
8370
+ var ESC = String.fromCharCode(27);
8371
+ var HIDE_CURSOR = `${ESC}[?25l`;
8372
+ var SHOW_CURSOR = `${ESC}[?25h`;
8373
+ var CURSOR_RESTORE_SIGNALS = ["SIGINT", "SIGTERM"];
8374
+ var out = process.stderr;
8329
8375
  function createInitialState() {
8330
8376
  return {
8331
8377
  messages: [],
@@ -8333,7 +8379,7 @@ function createInitialState() {
8333
8379
  };
8334
8380
  }
8335
8381
  function getPanelWidth() {
8336
- const terminalColumns = process.stderr.columns;
8382
+ const terminalColumns = out.columns;
8337
8383
  if (!terminalColumns) return FALLBACK_PANEL_WIDTH;
8338
8384
  return Math.min(
8339
8385
  Math.max(terminalColumns - 4, MIN_PANEL_WIDTH),
@@ -8355,128 +8401,186 @@ function getApprovedVerdict(decision, reason) {
8355
8401
  reason
8356
8402
  };
8357
8403
  }
8358
- function Spinner({ text }) {
8359
- const [frameIndex, setFrameIndex] = React.useState(0);
8360
- const InkText = text;
8361
- React.useEffect(() => {
8362
- const timer = setInterval(() => {
8363
- setFrameIndex((index) => (index + 1) % SPINNER_FRAMES.length);
8364
- }, SPINNER_INTERVAL_MS);
8365
- return () => clearInterval(timer);
8366
- }, []);
8367
- return /* @__PURE__ */ jsx(InkText, { color: "yellow", children: `${SPINNER_FRAMES[frameIndex]} Checking approval...` });
8368
- }
8369
- function ApprovalProgressView({
8370
- state,
8371
- box,
8372
- text
8373
- }) {
8374
- if (!state.active) return null;
8375
- const InkBox = box;
8376
- const InkText = text;
8404
+ function buildFrameLines(state, frameIndex) {
8405
+ const width = getPanelWidth();
8406
+ const innerWidth = width - 4;
8407
+ const bodyWidth = width - 2;
8408
+ const bodyTextWidth = innerWidth - 2;
8409
+ const content = [];
8410
+ content.push(chalk.bold.cyan("Approval review"));
8411
+ content.push("");
8412
+ if (!state.verdict) {
8413
+ content.push(
8414
+ chalk.yellow(`${SPINNER_FRAMES[frameIndex]} Checking approval...`)
8415
+ );
8416
+ }
8377
8417
  const recentMessages = state.messages.slice(-5);
8378
8418
  const hasMessages = recentMessages.length > 0;
8379
- return /* @__PURE__ */ jsxs(
8380
- InkBox,
8381
- {
8382
- borderColor: "cyan",
8383
- borderStyle: "round",
8384
- flexDirection: "column",
8385
- paddingX: 1,
8386
- width: getPanelWidth(),
8387
- children: [
8388
- /* @__PURE__ */ jsx(InkText, { bold: true, color: "cyan", children: "Approval review" }),
8389
- /* @__PURE__ */ jsxs(InkBox, { flexDirection: "column", marginTop: 1, children: [
8390
- !state.verdict && /* @__PURE__ */ jsx(Spinner, { text }),
8391
- recentMessages.map((message, index) => /* @__PURE__ */ jsxs(InkBox, { flexDirection: "row", children: [
8392
- /* @__PURE__ */ jsx(InkText, { color: "cyan", children: "> " }),
8393
- /* @__PURE__ */ jsx(
8394
- InkText,
8395
- {
8396
- dimColor: Boolean(state.verdict) || index < recentMessages.length - 1,
8397
- wrap: "wrap",
8398
- children: message
8399
- }
8400
- )
8401
- ] }, `${index}-${message}`)),
8402
- state.streamError && /* @__PURE__ */ jsxs(
8403
- InkBox,
8404
- {
8405
- flexDirection: "column",
8406
- marginTop: hasMessages || !state.verdict ? 1 : 0,
8407
- children: [
8408
- /* @__PURE__ */ jsx(InkText, { bold: true, color: "red", children: "Approval stream error" }),
8409
- /* @__PURE__ */ jsx(InkText, { wrap: "wrap", children: ` ${state.streamError}` })
8410
- ]
8411
- }
8412
- ),
8413
- state.verdict && /* @__PURE__ */ jsxs(
8414
- InkBox,
8415
- {
8416
- flexDirection: "column",
8417
- marginTop: hasMessages || state.streamError ? 1 : 0,
8418
- children: [
8419
- /* @__PURE__ */ jsx(InkText, { bold: true, color: state.verdict.color, children: `${state.verdict.icon} ${state.verdict.label}` }),
8420
- state.verdict.reason && /* @__PURE__ */ jsx(InkText, { wrap: "wrap", children: ` ${state.verdict.reason}` })
8421
- ]
8422
- }
8423
- )
8424
- ] })
8425
- ]
8419
+ recentMessages.forEach((message, index) => {
8420
+ const dimmed = Boolean(state.verdict) || index < recentMessages.length - 1;
8421
+ const segments = wrapAnsi3(message, bodyTextWidth, { hard: true }).split(
8422
+ "\n"
8423
+ );
8424
+ segments.forEach((segment, segmentIndex) => {
8425
+ const prefix = segmentIndex === 0 ? chalk.cyan("> ") : " ";
8426
+ content.push(`${prefix}${dimmed ? chalk.dim(segment) : segment}`);
8427
+ });
8428
+ });
8429
+ if (state.streamError) {
8430
+ if (hasMessages || !state.verdict) content.push("");
8431
+ content.push(chalk.bold.red("Approval stream error"));
8432
+ for (const segment of wrapAnsi3(state.streamError, bodyTextWidth, {
8433
+ hard: true
8434
+ }).split("\n")) {
8435
+ content.push(` ${segment}`);
8436
+ }
8437
+ }
8438
+ if (state.verdict) {
8439
+ if (hasMessages || state.streamError) content.push("");
8440
+ content.push(
8441
+ chalk.bold.green(`${state.verdict.icon} ${state.verdict.label}`)
8442
+ );
8443
+ if (state.verdict.reason) {
8444
+ for (const segment of wrapAnsi3(state.verdict.reason, bodyTextWidth, {
8445
+ hard: true
8446
+ }).split("\n")) {
8447
+ content.push(` ${segment}`);
8448
+ }
8426
8449
  }
8427
- );
8450
+ }
8451
+ const pad = (line) => {
8452
+ const padding = " ".repeat(Math.max(0, innerWidth - displayWidth(line)));
8453
+ return `${chalk.cyan("\u2502")} ${line}${padding} ${chalk.cyan("\u2502")}`;
8454
+ };
8455
+ return [
8456
+ chalk.cyan(`\u256D${"\u2500".repeat(bodyWidth)}\u256E`),
8457
+ ...content.map(pad),
8458
+ chalk.cyan(`\u2570${"\u2500".repeat(bodyWidth)}\u256F`)
8459
+ ];
8428
8460
  }
8429
8461
  function createApprovalProgressRenderer({
8430
8462
  enabled,
8431
8463
  onEvent
8432
8464
  }) {
8433
- let instance;
8434
8465
  let currentState = createInitialState();
8435
- let renderQueue = Promise.resolve();
8436
- let renderGeneration = 0;
8437
8466
  let renderEnabled = enabled;
8467
+ let disposed = false;
8438
8468
  let renderErrorReported = false;
8469
+ let lastFrameLineCount = 0;
8470
+ let spinnerFrameIndex = 0;
8471
+ let spinnerTimer;
8472
+ let cursorHidden = false;
8473
+ let signalHandlers = [];
8474
+ function restoreCursor() {
8475
+ if (cursorHidden) {
8476
+ try {
8477
+ out.write(SHOW_CURSOR);
8478
+ } catch {
8479
+ }
8480
+ cursorHidden = false;
8481
+ }
8482
+ for (const { signal, handler } of signalHandlers) {
8483
+ process.removeListener(signal, handler);
8484
+ }
8485
+ signalHandlers = [];
8486
+ }
8487
+ function ensureCursorHidden() {
8488
+ if (cursorHidden) return;
8489
+ out.write(HIDE_CURSOR);
8490
+ cursorHidden = true;
8491
+ for (const signal of CURSOR_RESTORE_SIGNALS) {
8492
+ const handler = () => {
8493
+ restoreCursor();
8494
+ if (process.listenerCount(signal) === 0) {
8495
+ process.kill(process.pid, signal);
8496
+ }
8497
+ };
8498
+ signalHandlers.push({ signal, handler });
8499
+ process.once(signal, handler);
8500
+ }
8501
+ }
8502
+ function eraseFrame() {
8503
+ if (lastFrameLineCount === 0) return;
8504
+ readline.moveCursor(out, 0, -lastFrameLineCount);
8505
+ readline.cursorTo(out, 0);
8506
+ readline.clearScreenDown(out);
8507
+ lastFrameLineCount = 0;
8508
+ }
8509
+ function paint(lines) {
8510
+ eraseFrame();
8511
+ out.write(`${lines.join("\n")}
8512
+ `);
8513
+ lastFrameLineCount = lines.length;
8514
+ }
8515
+ function renderFrame(state) {
8516
+ paint(buildFrameLines(state, spinnerFrameIndex));
8517
+ }
8518
+ function stopSpinnerTimer() {
8519
+ if (spinnerTimer) {
8520
+ clearInterval(spinnerTimer);
8521
+ spinnerTimer = void 0;
8522
+ }
8523
+ }
8524
+ function disableAfterError(error) {
8525
+ renderEnabled = false;
8526
+ stopSpinnerTimer();
8527
+ restoreCursor();
8528
+ lastFrameLineCount = 0;
8529
+ currentState = createInitialState();
8530
+ if (renderErrorReported) return;
8531
+ renderErrorReported = true;
8532
+ const message = error instanceof Error ? error.message : String(error);
8533
+ try {
8534
+ out.write(`Approval progress unavailable: ${message}
8535
+ `);
8536
+ } catch {
8537
+ }
8538
+ }
8539
+ function ensureSpinnerTimer() {
8540
+ if (spinnerTimer) return;
8541
+ spinnerTimer = setInterval(() => {
8542
+ if (!renderEnabled || !currentState.active || currentState.verdict) {
8543
+ return;
8544
+ }
8545
+ spinnerFrameIndex = (spinnerFrameIndex + 1) % SPINNER_FRAMES.length;
8546
+ try {
8547
+ renderFrame(currentState);
8548
+ } catch (error) {
8549
+ disableAfterError(error);
8550
+ }
8551
+ }, SPINNER_INTERVAL_MS);
8552
+ spinnerTimer.unref?.();
8553
+ }
8439
8554
  function update(nextState, { complete = false } = {}) {
8440
- const generation = renderGeneration;
8441
- currentState = complete ? createInitialState() : nextState;
8442
- renderQueue = renderQueue.then(async () => {
8443
- if (generation !== renderGeneration) return;
8444
- const { Box, Text, render } = await loadInk();
8445
- if (generation !== renderGeneration) return;
8446
- const element = /* @__PURE__ */ jsx(ApprovalProgressView, { state: nextState, box: Box, text: Text });
8447
- if (!instance) {
8448
- instance = render(element, {
8449
- stdout: process.stderr,
8450
- stderr: process.stderr
8451
- });
8555
+ try {
8556
+ ensureCursorHidden();
8557
+ renderFrame(nextState);
8558
+ if (complete) {
8559
+ stopSpinnerTimer();
8560
+ restoreCursor();
8561
+ lastFrameLineCount = 0;
8562
+ currentState = createInitialState();
8452
8563
  } else {
8453
- instance.rerender(element);
8564
+ currentState = nextState;
8565
+ ensureSpinnerTimer();
8454
8566
  }
8455
- if (complete) {
8456
- instance.unmount();
8457
- instance = void 0;
8458
- }
8459
- }).catch((error) => {
8460
- if (generation !== renderGeneration) return;
8461
- renderEnabled = false;
8462
- currentState = createInitialState();
8463
- if (renderErrorReported) return;
8464
- renderErrorReported = true;
8465
- const message = error instanceof Error ? error.message : String(error);
8466
- process.stderr.write(`Approval progress unavailable: ${message}
8467
- `);
8468
- });
8567
+ } catch (error) {
8568
+ disableAfterError(error);
8569
+ }
8469
8570
  }
8470
8571
  function dismiss() {
8471
- renderGeneration++;
8572
+ stopSpinnerTimer();
8573
+ try {
8574
+ eraseFrame();
8575
+ } catch {
8576
+ }
8577
+ restoreCursor();
8472
8578
  currentState = createInitialState();
8473
- instance?.unmount();
8474
- instance = void 0;
8475
8579
  }
8476
8580
  return {
8477
8581
  onEvent(event) {
8478
8582
  onEvent?.(event);
8479
- if (!renderEnabled) return;
8583
+ if (disposed || !renderEnabled) return;
8480
8584
  if (event.type === "approval:required") {
8481
8585
  if (event.payload?.mode !== "auto") return;
8482
8586
  update({
@@ -8537,6 +8641,11 @@ function createApprovalProgressRenderer({
8537
8641
  if (event.type === "approval:denied" || event.type === "approval:failed" || event.type === "approval:timeout" || event.type === "approval:error") {
8538
8642
  dismiss();
8539
8643
  }
8644
+ },
8645
+ dispose() {
8646
+ disposed = true;
8647
+ stopSpinnerTimer();
8648
+ restoreCursor();
8540
8649
  }
8541
8650
  };
8542
8651
  }
@@ -8682,6 +8791,8 @@ program.exitOverride();
8682
8791
  console.error("Unexpected error:", error);
8683
8792
  exitCode = 1;
8684
8793
  }
8794
+ } finally {
8795
+ approvalProgress.dispose();
8685
8796
  }
8686
8797
  await versionCheckPromise;
8687
8798
  await disposeSdk(sdk, { exitCode }).catch(() => {
@@ -5109,7 +5109,7 @@ function collectDeprecationNoticeAndForward(event, onEvent) {
5109
5109
  // package.json with { type: 'json' }
5110
5110
  var package_default = {
5111
5111
  name: "@zapier/zapier-sdk-cli",
5112
- version: "0.65.5"};
5112
+ version: "0.65.7"};
5113
5113
 
5114
5114
  // src/sdk.ts
5115
5115
  var warnedDeprecatedMethods = /* @__PURE__ */ new Set();
@@ -5073,7 +5073,7 @@ function collectDeprecationNoticeAndForward(event, onEvent) {
5073
5073
  // package.json with { type: 'json' }
5074
5074
  var package_default = {
5075
5075
  name: "@zapier/zapier-sdk-cli",
5076
- version: "0.65.5"};
5076
+ version: "0.65.7"};
5077
5077
 
5078
5078
  // src/sdk.ts
5079
5079
  var warnedDeprecatedMethods = /* @__PURE__ */ new Set();
package/dist/index.cjs CHANGED
@@ -5109,7 +5109,7 @@ function collectDeprecationNoticeAndForward(event, onEvent) {
5109
5109
  // package.json with { type: 'json' }
5110
5110
  var package_default = {
5111
5111
  name: "@zapier/zapier-sdk-cli",
5112
- version: "0.65.5"};
5112
+ version: "0.65.7"};
5113
5113
 
5114
5114
  // src/sdk.ts
5115
5115
  var warnedDeprecatedMethods = /* @__PURE__ */ new Set();
@@ -5192,7 +5192,7 @@ function createZapierCliSdk(options = {}) {
5192
5192
 
5193
5193
  // package.json
5194
5194
  var package_default2 = {
5195
- version: "0.65.5"};
5195
+ version: "0.65.7"};
5196
5196
 
5197
5197
  // src/telemetry/builders.ts
5198
5198
  function createCliBaseEvent(context = {}) {
package/dist/index.mjs CHANGED
@@ -5073,7 +5073,7 @@ function collectDeprecationNoticeAndForward(event, onEvent) {
5073
5073
  // package.json with { type: 'json' }
5074
5074
  var package_default = {
5075
5075
  name: "@zapier/zapier-sdk-cli",
5076
- version: "0.65.5"};
5076
+ version: "0.65.7"};
5077
5077
 
5078
5078
  // src/sdk.ts
5079
5079
  var warnedDeprecatedMethods = /* @__PURE__ */ new Set();
@@ -5156,7 +5156,7 @@ function createZapierCliSdk(options = {}) {
5156
5156
 
5157
5157
  // package.json
5158
5158
  var package_default2 = {
5159
- version: "0.65.5"};
5159
+ version: "0.65.7"};
5160
5160
 
5161
5161
  // src/telemetry/builders.ts
5162
5162
  function createCliBaseEvent(context = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.65.5",
3
+ "version": "0.65.7",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -81,7 +81,6 @@
81
81
  "esbuild": "^0.25.5",
82
82
  "express": "^5.1.0",
83
83
  "handlebars": "^4.7.8",
84
- "ink": "7.0.5",
85
84
  "inquirer": "^12.6.3",
86
85
  "is-installed-globally": "^1.0.0",
87
86
  "jsonwebtoken": "^9.0.2",
@@ -90,13 +89,12 @@
90
89
  "package-json": "^10.0.1",
91
90
  "pkce-challenge": "^5.0.0",
92
91
  "proper-lockfile": "^4.1.2",
93
- "react": "19.2.6",
94
92
  "semver": "^7.7.3",
95
93
  "typescript": "^5.8.3",
96
94
  "wrap-ansi": "^10.0.0",
97
95
  "zod": "4.3.6",
98
- "@zapier/zapier-sdk": "0.84.0",
99
- "@zapier/zapier-sdk-mcp": "0.18.6"
96
+ "@zapier/zapier-sdk": "0.84.1",
97
+ "@zapier/zapier-sdk-mcp": "0.18.7"
100
98
  },
101
99
  "devDependencies": {
102
100
  "@types/express": "^5.0.3",
@@ -104,7 +102,6 @@
104
102
  "@types/jsonwebtoken": "^9.0.10",
105
103
  "@types/node": "^24.0.1",
106
104
  "@types/proper-lockfile": "^4.1.4",
107
- "@types/react": "19.2.15",
108
105
  "@types/semver": "^7.7.1",
109
106
  "tsup": "^8.5.0",
110
107
  "vitest": "^4.1.4"