@zapier/zapier-sdk-cli 0.86.7 → 0.87.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -33,6 +33,7 @@ var url = require('url');
33
33
  var packageJsonLib = require('package-json');
34
34
  var semver = require('semver');
35
35
  var crossSpawn = require('cross-spawn');
36
+ var module$1 = require('module');
36
37
  var Table = require('cli-table3');
37
38
  var experimental = require('@zapier/zapier-sdk/experimental');
38
39
  var beta = require('@zapier/zapier-sdk/beta');
@@ -606,7 +607,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
606
607
 
607
608
  // package.json
608
609
  var package_default = {
609
- version: "0.86.7"};
610
+ version: "0.87.1"};
610
611
  var PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
611
612
  var LOCKFILES = [
612
613
  ["pnpm-lock.yaml", "pnpm"],
@@ -1124,6 +1125,7 @@ var SENSITIVE_FLAGS = [
1124
1125
  "--credentials-client-id",
1125
1126
  "--credentials-base-url",
1126
1127
  "--callback-url",
1128
+ "--answer",
1127
1129
  "--user",
1128
1130
  "--header",
1129
1131
  "-H",
@@ -1339,11 +1341,11 @@ function analyzeZodField(name, schema) {
1339
1341
  let deprecationMessage;
1340
1342
  let nullable = false;
1341
1343
  while (true) {
1342
- const meta = baseSchema.meta?.();
1344
+ const meta = zod.z.globalRegistry.get(baseSchema);
1343
1345
  if (meta?.deprecated) {
1344
1346
  isDeprecated = true;
1345
1347
  }
1346
- if (meta?.deprecationMessage && !deprecationMessage) {
1348
+ if (typeof meta?.deprecationMessage === "string" && !deprecationMessage) {
1347
1349
  deprecationMessage = meta.deprecationMessage;
1348
1350
  }
1349
1351
  if (baseSchema instanceof zod.z.ZodOptional) {
@@ -1404,6 +1406,7 @@ function analyzeZodField(name, schema) {
1404
1406
  elementType,
1405
1407
  deprecationMessage,
1406
1408
  isDeprecated,
1409
+ isInternal: zapierSdk.isInternalField(schema),
1407
1410
  negatable: zapierSdk.getNegatable(schema),
1408
1411
  nullable
1409
1412
  };
@@ -1862,6 +1865,7 @@ function addCommand(program2, commandName, config2) {
1862
1865
  param.description || `${kebabName} parameter`
1863
1866
  );
1864
1867
  } else {
1868
+ const hideFromHelp = param.isDeprecated || param.isInternal;
1865
1869
  const flags = [];
1866
1870
  const alias = config2.aliases?.[param.name];
1867
1871
  if (alias && alias.length === 1) {
@@ -1870,7 +1874,7 @@ function addCommand(program2, commandName, config2) {
1870
1874
  flags.push(`--${kebabName}`);
1871
1875
  if (param.type === "boolean") {
1872
1876
  const opt = new commander.Option(flags.join(", "), param.description);
1873
- if (param.isDeprecated) opt.hideHelp();
1877
+ if (hideFromHelp) opt.hideHelp();
1874
1878
  command.addOption(opt);
1875
1879
  const negationKebab = negationKebabName(param);
1876
1880
  if (negationKebab !== void 0) {
@@ -1881,7 +1885,7 @@ function addCommand(program2, commandName, config2) {
1881
1885
  if (!negationKebab.startsWith("no-")) {
1882
1886
  negation.conflicts(param.name);
1883
1887
  }
1884
- if (param.isDeprecated) negation.hideHelp();
1888
+ if (hideFromHelp) negation.hideHelp();
1885
1889
  command.addOption(negation);
1886
1890
  }
1887
1891
  booleanFlags2.push({
@@ -1897,7 +1901,7 @@ function addCommand(program2, commandName, config2) {
1897
1901
  opt.argParser(
1898
1902
  (value, previous) => (previous || []).concat([value])
1899
1903
  );
1900
- if (param.isDeprecated) opt.hideHelp();
1904
+ if (hideFromHelp) opt.hideHelp();
1901
1905
  command.addOption(opt);
1902
1906
  } else {
1903
1907
  const flagSignature = flags.join(", ") + ` <${param.type}>`;
@@ -1905,7 +1909,7 @@ function addCommand(program2, commandName, config2) {
1905
1909
  if (param.default !== void 0) {
1906
1910
  opt.default(param.default);
1907
1911
  }
1908
- if (param.isDeprecated) opt.hideHelp();
1912
+ if (hideFromHelp) opt.hideHelp();
1909
1913
  command.addOption(opt);
1910
1914
  }
1911
1915
  }
@@ -3109,6 +3113,7 @@ async function setupClientCredentials({
3109
3113
  }
3110
3114
  return { clientId };
3111
3115
  }
3116
+ var CREDENTIALS_PICKER_QUESTION = "Select credentials or add a new account:";
3112
3117
  function isSameCredentials(left, right) {
3113
3118
  return left.name === right.name && left.baseUrl === right.baseUrl;
3114
3119
  }
@@ -3214,7 +3219,7 @@ async function promptForCredentials({
3214
3219
  activeCredentials
3215
3220
  }) {
3216
3221
  return searchSelect({
3217
- message: "Select credentials or add a new account:",
3222
+ message: CREDENTIALS_PICKER_QUESTION,
3218
3223
  source: (term) => buildCredentialsChoices({
3219
3224
  credentials: credentials2,
3220
3225
  activeCredentials,
@@ -3277,14 +3282,15 @@ async function switchCredentials({
3277
3282
  async function chooseStoredLoginCredentialsAtBaseUrl({
3278
3283
  baseUrl: baseUrl2,
3279
3284
  options,
3280
- resolvedCredentials
3285
+ resolvedCredentials,
3286
+ prompt = promptForCredentials
3281
3287
  }) {
3282
3288
  if (resolvedCredentials !== void 0 || authFlowOnlyOptions(options).length > 0) {
3283
3289
  return "none";
3284
3290
  }
3285
3291
  const storedCredentials = listStoredCredentials({ baseUrl: baseUrl2 });
3286
3292
  if (storedCredentials.length === 0) return "none";
3287
- const selection = await promptForCredentials({
3293
+ const selection = await prompt({
3288
3294
  credentials: storedCredentials,
3289
3295
  activeCredentials: getActiveCredentials({ baseUrl: baseUrl2 })
3290
3296
  });
@@ -3298,7 +3304,8 @@ async function chooseStoredLoginCredentialsAtBaseUrl({
3298
3304
  }
3299
3305
  async function chooseStoredLoginCredentials({
3300
3306
  imports,
3301
- options
3307
+ options,
3308
+ prompt
3302
3309
  }) {
3303
3310
  const resolvedCredentials = await imports.resolveCredentials();
3304
3311
  const credentialsBaseUrl2 = await resolveCredentialsBaseUrl({
@@ -3308,7 +3315,8 @@ async function chooseStoredLoginCredentials({
3308
3315
  return chooseStoredLoginCredentialsAtBaseUrl({
3309
3316
  baseUrl: credentialsBaseUrl2,
3310
3317
  options,
3311
- resolvedCredentials
3318
+ resolvedCredentials,
3319
+ prompt
3312
3320
  });
3313
3321
  }
3314
3322
  async function confirmNewCredentialsName(name) {
@@ -3679,6 +3687,7 @@ var PendingOauthTransactionSchema = zod.z.object({
3679
3687
  credentialName: zod.z.string().optional(),
3680
3688
  useApprovals: zod.z.boolean(),
3681
3689
  headless: zod.z.boolean().default(false),
3690
+ preserveExistingCredentials: zod.z.boolean().default(false),
3682
3691
  transaction: OauthTransactionSchema
3683
3692
  });
3684
3693
  function savePendingOauthTransaction({
@@ -3688,7 +3697,8 @@ function savePendingOauthTransaction({
3688
3697
  credentialsBaseUrl: credentialsBaseUrl2,
3689
3698
  credentialName,
3690
3699
  useApprovals,
3691
- headless
3700
+ headless,
3701
+ preserveExistingCredentials = false
3692
3702
  }) {
3693
3703
  const pendingTransaction = {
3694
3704
  version: 1,
@@ -3696,6 +3706,7 @@ function savePendingOauthTransaction({
3696
3706
  expiresAt,
3697
3707
  useApprovals,
3698
3708
  headless,
3709
+ preserveExistingCredentials,
3699
3710
  transaction,
3700
3711
  ...credentialsBaseUrl2 !== void 0 && { credentialsBaseUrl: credentialsBaseUrl2 },
3701
3712
  ...credentialName !== void 0 && { credentialName }
@@ -3714,6 +3725,7 @@ function clearPendingOauthTransaction() {
3714
3725
  }
3715
3726
 
3716
3727
  // src/utils/auth/oauth-flow.ts
3728
+ var OAUTH_CALLBACK_QUESTION = "Paste the final OAuth callback URL:";
3717
3729
  var PENDING_OAUTH_RECOVERY_MESSAGE = "Start a new non-interactive login or signup flow to generate a fresh URL.";
3718
3730
  var LOGIN_OAUTH_COPY = {
3719
3731
  flowName: "Login",
@@ -3777,7 +3789,9 @@ async function startPendingOauthFlow({
3777
3789
  entryPoint,
3778
3790
  credentialName,
3779
3791
  useApprovals,
3780
- headless
3792
+ headless,
3793
+ preserveExistingCredentials = false,
3794
+ silent = false
3781
3795
  }) {
3782
3796
  const copy = entryPoint === "signup" ? SIGNUP_OAUTH_COPY : LOGIN_OAUTH_COPY;
3783
3797
  const port = LOGIN_PORTS[0];
@@ -3794,8 +3808,10 @@ async function startPendingOauthFlow({
3794
3808
  credentialsBaseUrl: baseUrl2,
3795
3809
  credentialName,
3796
3810
  useApprovals,
3797
- headless
3811
+ headless,
3812
+ preserveExistingCredentials
3798
3813
  });
3814
+ if (silent) return pending;
3799
3815
  process.stderr.write(
3800
3816
  `Open this ${copy.urlLabel} in a browser to continue:
3801
3817
  `
@@ -3821,23 +3837,24 @@ async function startPendingOauthFlow({
3821
3837
  return pending;
3822
3838
  }
3823
3839
  function getPendingOauthFlow({
3824
- entryPoint
3840
+ entryPoint,
3841
+ recoveryMessage = PENDING_OAUTH_RECOVERY_MESSAGE
3825
3842
  }) {
3826
3843
  const pending = getPendingOauthTransaction();
3827
3844
  if (!pending) {
3828
3845
  throw new ZapierCliValidationError(
3829
- `No pending ${entryPoint} OAuth flow found. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
3846
+ `No pending ${entryPoint} OAuth flow found. ${recoveryMessage}`
3830
3847
  );
3831
3848
  }
3832
3849
  if (Date.now() > pending.expiresAt) {
3833
3850
  clearPendingOauthTransaction();
3834
3851
  throw new ZapierCliValidationError(
3835
- `Pending ${pending.entryPoint} OAuth flow has expired. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
3852
+ `Pending ${pending.entryPoint} OAuth flow has expired. ${recoveryMessage}`
3836
3853
  );
3837
3854
  }
3838
3855
  if (pending.entryPoint !== entryPoint) {
3839
3856
  throw new ZapierCliValidationError(
3840
- `Pending OAuth flow is for ${pending.entryPoint}, not ${entryPoint}. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
3857
+ `Pending OAuth flow is for ${pending.entryPoint}, not ${entryPoint}. ${recoveryMessage}`
3841
3858
  );
3842
3859
  }
3843
3860
  return pending;
@@ -4000,7 +4017,7 @@ async function readHeadlessCallbackUrl({
4000
4017
  process.once("SIGINT", handleCancellation);
4001
4018
  process.once("SIGTERM", handleCancellation);
4002
4019
  if (interactive) {
4003
- void rl.question("Paste the final OAuth callback URL: ", {
4020
+ void rl.question(`${OAUTH_CALLBACK_QUESTION} `, {
4004
4021
  signal: abortController.signal
4005
4022
  }).then(settleResolve).catch((error) => {
4006
4023
  if (error instanceof Error && error.name === "AbortError") {
@@ -4487,7 +4504,7 @@ async function runOauthForEntryPoint({
4487
4504
  if (event.type === "callback_accepted") {
4488
4505
  emitSignupSuccess({
4489
4506
  imports,
4490
- isNonInteractive: false,
4507
+ isNonInteractive: !interactive,
4491
4508
  isHeadless: headless === true
4492
4509
  });
4493
4510
  }
@@ -4569,7 +4586,9 @@ async function runAccountAuth({
4569
4586
  options,
4570
4587
  entryPoint,
4571
4588
  storedCredentialsMode = "choose",
4572
- preserveExistingCredentials = false
4589
+ preserveExistingCredentials = false,
4590
+ useBrowserCallback = false,
4591
+ silent = false
4573
4592
  }) {
4574
4593
  if (options.callbackUrl !== void 0) {
4575
4594
  const { callbackUrl } = options;
@@ -4602,7 +4621,8 @@ async function runAccountAuth({
4602
4621
  imports,
4603
4622
  baseUrl: pending.credentialsBaseUrl,
4604
4623
  interactive: false,
4605
- entryPoint
4624
+ entryPoint,
4625
+ preserveExistingCredentials: pending.preserveExistingCredentials
4606
4626
  })) {
4607
4627
  return;
4608
4628
  }
@@ -4679,7 +4699,7 @@ async function runAccountAuth({
4679
4699
  );
4680
4700
  }
4681
4701
  }
4682
- if (entryPoint === "login" && !interactive && providedName === void 0) {
4702
+ if (entryPoint === "login" && !interactive && providedName === void 0 && !preserveExistingCredentials) {
4683
4703
  const activeCredentials = getActiveCredentials({
4684
4704
  baseUrl: credentialsBaseUrl2
4685
4705
  });
@@ -4696,7 +4716,7 @@ async function runAccountAuth({
4696
4716
  }
4697
4717
  const timeoutSeconds = parseTimeoutSeconds(options.timeout);
4698
4718
  const useApprovals = options.useApprovals === true;
4699
- if (!interactive) {
4719
+ if (!interactive && (headless || !useBrowserCallback)) {
4700
4720
  await startPendingOauthFlow({
4701
4721
  entryPoint,
4702
4722
  timeoutMs: timeoutSeconds * 1e3,
@@ -4704,7 +4724,9 @@ async function runAccountAuth({
4704
4724
  baseUrl: credentialsBaseUrl2,
4705
4725
  credentialName: providedName,
4706
4726
  useApprovals,
4707
- headless
4727
+ headless,
4728
+ preserveExistingCredentials,
4729
+ silent
4708
4730
  });
4709
4731
  return;
4710
4732
  }
@@ -4725,7 +4747,7 @@ async function runAccountAuth({
4725
4747
  credentialName: providedName,
4726
4748
  interactive,
4727
4749
  useApprovals,
4728
- isNonInteractive: false,
4750
+ isNonInteractive: !interactive,
4729
4751
  isHeadless: headless
4730
4752
  });
4731
4753
  }
@@ -6565,6 +6587,7 @@ function createProjectDir({
6565
6587
  var TEMPLATES_DIR = url.fileURLToPath(
6566
6588
  new URL("../templates", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)))
6567
6589
  );
6590
+ var SOURCE_CLI_PATH = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)).endsWith(".ts") ? url.fileURLToPath(new URL("./cli.ts", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)))) : void 0;
6568
6591
 
6569
6592
  // src/plugins/init/steps.ts
6570
6593
  var DEFAULT_TEMPLATE = "basic";
@@ -7025,84 +7048,6 @@ async function checkAndNotifyUpdates({
7025
7048
  const versionInfo = await checkForUpdates({ packageName, currentVersion });
7026
7049
  displayUpdateNotification(versionInfo, packageName);
7027
7050
  }
7028
- var BRAILLE_BLANK = "\u2800";
7029
- var LIGHTNING_INTERVAL_MILLISECONDS = 140;
7030
- var boltRows = [
7031
- "\u2800\u2800\u2880\u28FE\u2800\u2800\u2800\u2800",
7032
- "\u2800\u2800\u28E0\u28FF\u28FF\u2800\u2800\u2800",
7033
- "\u2800\u28FC\u28FF\u28FF\u28FF\u28C0\u28C0\u2840",
7034
- "\u2808\u2809\u2809\u28FF\u28FF\u28FF\u285F\u2800",
7035
- "\u2800\u2800\u2800\u28FF\u28FF\u280B\u2800\u2800",
7036
- "\u2800\u2800\u2800\u287F\u2801\u2800\u2800\u2800"
7037
- ];
7038
- var boltFillOrder = boltRows.flatMap(
7039
- (row, rowIndex) => [...row].flatMap(
7040
- (cell, columnIndex) => cell === BRAILLE_BLANK ? [] : rowIndex * row.length + columnIndex
7041
- )
7042
- );
7043
- var fillStages = [
7044
- ...Array.from({ length: boltFillOrder.length + 1 }, (_, index) => index),
7045
- boltFillOrder.length,
7046
- 0
7047
- ];
7048
- var boltFillRanks = new Map(
7049
- boltFillOrder.map((cellIndex, fillIndex) => [cellIndex, fillIndex])
7050
- );
7051
- var STATUS_ROW_INDEX = Math.floor(boltRows.length / 2);
7052
- function formatPhase({ label, detail }) {
7053
- return detail ? `${chalk10__default.default.bold(label)} ${chalk10__default.default.dim(detail)}` : chalk10__default.default.bold(label);
7054
- }
7055
- function formatLoaderFrame({
7056
- phase,
7057
- fillStage
7058
- }) {
7059
- return boltRows.map((row, rowIndex) => {
7060
- const bolt = [...row].map((cell, columnIndex) => {
7061
- if (cell === BRAILLE_BLANK) return cell;
7062
- const cellIndex = rowIndex * row.length + columnIndex;
7063
- const fillRank = boltFillRanks.get(cellIndex);
7064
- const isFilled = fillRank !== void 0 && fillRank < fillStage;
7065
- return isFilled ? chalk10__default.default.bold.yellow(cell) : chalk10__default.default.dim.yellow(cell);
7066
- }).join("");
7067
- const status = rowIndex === STATUS_ROW_INDEX ? ` ${formatPhase(phase)}` : "";
7068
- return `${bolt}${status}`;
7069
- }).join("\n");
7070
- }
7071
- async function runWithSetupLoader({
7072
- promise,
7073
- ...phase
7074
- }) {
7075
- const startedAt = Date.now();
7076
- let fillFrameIndex = 0;
7077
- const loader = ora__default.default({
7078
- isEnabled: process.stderr.isTTY === true,
7079
- spinner: { interval: 80, frames: [""] },
7080
- text: formatLoaderFrame({
7081
- phase,
7082
- fillStage: fillStages[fillFrameIndex]
7083
- })
7084
- }).start();
7085
- const animationTimer = setInterval(() => {
7086
- fillFrameIndex = (fillFrameIndex + 1) % fillStages.length;
7087
- loader.text = formatLoaderFrame({
7088
- phase,
7089
- fillStage: fillStages[fillFrameIndex]
7090
- });
7091
- }, LIGHTNING_INTERVAL_MILLISECONDS);
7092
- animationTimer.unref?.();
7093
- try {
7094
- const result = await promise;
7095
- clearInterval(animationTimer);
7096
- const elapsedSeconds = ((Date.now() - startedAt) / 1e3).toFixed(1);
7097
- loader.succeed(`${formatPhase(phase)} ${chalk10__default.default.dim(`${elapsedSeconds}s`)}`);
7098
- return result;
7099
- } catch (error) {
7100
- clearInterval(animationTimer);
7101
- const elapsedSeconds = ((Date.now() - startedAt) / 1e3).toFixed(1);
7102
- loader.fail(`${formatPhase(phase)} ${chalk10__default.default.dim(`${elapsedSeconds}s`)}`);
7103
- throw error;
7104
- }
7105
- }
7106
7051
  function isRecord(value) {
7107
7052
  return typeof value === "object" && value !== null && !Array.isArray(value);
7108
7053
  }
@@ -7388,7 +7333,7 @@ async function offerPackageUpdate({
7388
7333
  }) {
7389
7334
  const { currentVersion, dependency } = packageState;
7390
7335
  if (!currentVersion || !dependency.checkForUpdates) return;
7391
- const update = await runWithSetupLoader({
7336
+ const update = await context.load({
7392
7337
  promise: context.checkForUpdates({
7393
7338
  packageName: dependency.name,
7394
7339
  currentVersion
@@ -7413,28 +7358,108 @@ async function offerPackageUpdate({
7413
7358
  })
7414
7359
  );
7415
7360
  }
7416
- async function prepareDependencies(context) {
7361
+ function getPackageStates(context) {
7417
7362
  const declaredPackageNames = getDeclaredPackageNames(context.cwd);
7418
7363
  const requiredPackages = REQUIRED_PACKAGES.filter(
7419
7364
  ({ typescriptOnly }) => !typescriptOnly || context.projectLanguage === "typescript"
7420
7365
  );
7421
- const packages = requiredPackages.map((dependency) => ({
7366
+ return requiredPackages.map((dependency) => ({
7422
7367
  dependency,
7368
+ declared: declaredPackageNames.has(dependency.name),
7423
7369
  currentVersion: declaredPackageNames.has(dependency.name) ? getInstalledPackageVersion({
7424
7370
  cwd: context.cwd,
7425
7371
  packageName: dependency.name
7426
7372
  }) : void 0
7427
7373
  }));
7374
+ }
7375
+ async function prepareDependencies(context) {
7376
+ const packages = getPackageStates(context);
7428
7377
  await offerMissingPackageInstall({
7429
7378
  context,
7430
- packages: packages.filter(
7431
- ({ dependency }) => !declaredPackageNames.has(dependency.name)
7432
- )
7379
+ packages: packages.filter(({ declared }) => !declared)
7433
7380
  });
7434
7381
  for (const packageState of packages) {
7435
7382
  await offerPackageUpdate({ context, packageState });
7436
7383
  }
7437
7384
  }
7385
+ var BRAILLE_BLANK = "\u2800";
7386
+ var LIGHTNING_INTERVAL_MILLISECONDS = 140;
7387
+ var boltRows = [
7388
+ "\u2800\u2800\u2880\u28FE\u2800\u2800\u2800\u2800",
7389
+ "\u2800\u2800\u28E0\u28FF\u28FF\u2800\u2800\u2800",
7390
+ "\u2800\u28FC\u28FF\u28FF\u28FF\u28C0\u28C0\u2840",
7391
+ "\u2808\u2809\u2809\u28FF\u28FF\u28FF\u285F\u2800",
7392
+ "\u2800\u2800\u2800\u28FF\u28FF\u280B\u2800\u2800",
7393
+ "\u2800\u2800\u2800\u287F\u2801\u2800\u2800\u2800"
7394
+ ];
7395
+ var boltFillOrder = boltRows.flatMap(
7396
+ (row, rowIndex) => [...row].flatMap(
7397
+ (cell, columnIndex) => cell === BRAILLE_BLANK ? [] : rowIndex * row.length + columnIndex
7398
+ )
7399
+ );
7400
+ var fillStages = [
7401
+ ...Array.from({ length: boltFillOrder.length + 1 }, (_, index) => index),
7402
+ boltFillOrder.length,
7403
+ 0
7404
+ ];
7405
+ var boltFillRanks = new Map(
7406
+ boltFillOrder.map((cellIndex, fillIndex) => [cellIndex, fillIndex])
7407
+ );
7408
+ var STATUS_ROW_INDEX = Math.floor(boltRows.length / 2);
7409
+ function formatPhase({ label, detail }) {
7410
+ return detail ? `${chalk10__default.default.bold(label)} ${chalk10__default.default.dim(detail)}` : chalk10__default.default.bold(label);
7411
+ }
7412
+ function formatLoaderFrame({
7413
+ phase,
7414
+ fillStage
7415
+ }) {
7416
+ return boltRows.map((row, rowIndex) => {
7417
+ const bolt = [...row].map((cell, columnIndex) => {
7418
+ if (cell === BRAILLE_BLANK) return cell;
7419
+ const cellIndex = rowIndex * row.length + columnIndex;
7420
+ const fillRank = boltFillRanks.get(cellIndex);
7421
+ const isFilled = fillRank !== void 0 && fillRank < fillStage;
7422
+ return isFilled ? chalk10__default.default.bold.yellow(cell) : chalk10__default.default.dim.yellow(cell);
7423
+ }).join("");
7424
+ const status = rowIndex === STATUS_ROW_INDEX ? ` ${formatPhase(phase)}` : "";
7425
+ return `${bolt}${status}`;
7426
+ }).join("\n");
7427
+ }
7428
+ async function runWithSetupLoader({
7429
+ promise,
7430
+ ...phase
7431
+ }) {
7432
+ const startedAt = Date.now();
7433
+ let fillFrameIndex = 0;
7434
+ const loader = ora__default.default({
7435
+ isEnabled: process.stderr.isTTY === true,
7436
+ spinner: { interval: 80, frames: [""] },
7437
+ text: formatLoaderFrame({
7438
+ phase,
7439
+ fillStage: fillStages[fillFrameIndex]
7440
+ })
7441
+ }).start();
7442
+ const animationTimer = setInterval(() => {
7443
+ fillFrameIndex = (fillFrameIndex + 1) % fillStages.length;
7444
+ loader.text = formatLoaderFrame({
7445
+ phase,
7446
+ fillStage: fillStages[fillFrameIndex]
7447
+ });
7448
+ }, LIGHTNING_INTERVAL_MILLISECONDS);
7449
+ animationTimer.unref?.();
7450
+ try {
7451
+ const result = await promise;
7452
+ clearInterval(animationTimer);
7453
+ const elapsedSeconds = ((Date.now() - startedAt) / 1e3).toFixed(1);
7454
+ loader.succeed(`${formatPhase(phase)} ${chalk10__default.default.dim(`${elapsedSeconds}s`)}`);
7455
+ return result;
7456
+ } catch (error) {
7457
+ clearInterval(animationTimer);
7458
+ const elapsedSeconds = ((Date.now() - startedAt) / 1e3).toFixed(1);
7459
+ loader.fail(`${formatPhase(phase)} ${chalk10__default.default.dim(`${elapsedSeconds}s`)}`);
7460
+ throw error;
7461
+ }
7462
+ }
7438
7463
 
7439
7464
  // src/plugins/setup/package-commands.ts
7440
7465
  function createLocalPackageCommand({
@@ -7473,7 +7498,10 @@ function formatPackageCommand({
7473
7498
  command,
7474
7499
  args
7475
7500
  }) {
7476
- return [command, ...args].join(" ");
7501
+ return [command, ...args].map(quoteShellArgument).join(" ");
7502
+ }
7503
+ function quoteShellArgument(value) {
7504
+ return /^[a-zA-Z0-9_@%+=:,./-]+$/.test(value) ? value : `'${value.replace(/'/g, `'"'"'`)}'`;
7477
7505
  }
7478
7506
 
7479
7507
  // src/plugins/setup/project.ts
@@ -7578,13 +7606,14 @@ async function runCommand({
7578
7606
  args = [],
7579
7607
  cwd,
7580
7608
  capture = true,
7581
- input
7609
+ input,
7610
+ load = runWithSetupLoader
7582
7611
  }) {
7583
7612
  const commandLabel = `$ ${command} ${args.join(" ")}`.trim();
7584
7613
  const execute = capture ? executeCapturedCommand({ command, args, cwd, input }) : executeStreamingCommand({ command, args, cwd, input });
7585
7614
  try {
7586
7615
  if (capture) {
7587
- return await runWithSetupLoader({
7616
+ return await load({
7588
7617
  promise: execute,
7589
7618
  label: "Running command",
7590
7619
  detail: commandLabel
@@ -7668,7 +7697,7 @@ function detectProjectLanguage({
7668
7697
  );
7669
7698
  return hasTypeScript ? "typescript" : "javascript";
7670
7699
  }
7671
- async function prepareProject(context) {
7700
+ async function initializeProject(context) {
7672
7701
  context.packageManager = detectPackageManager(context.cwd).name;
7673
7702
  console.log(`Using ${context.packageManager} for dependency installs.`);
7674
7703
  const hasExistingProject = fs.existsSync(path.join(context.cwd, "package.json"));
@@ -7684,182 +7713,157 @@ async function prepareProject(context) {
7684
7713
  cwd: context.cwd
7685
7714
  });
7686
7715
  }
7716
+ }
7717
+ async function prepareProject(context) {
7718
+ await initializeProject(context);
7687
7719
  await prepareDependencies(context);
7688
7720
  }
7689
7721
 
7690
7722
  // src/plugins/setup/context.ts
7691
7723
  function createWizardContext({
7692
- imports
7724
+ imports,
7725
+ agent = false
7693
7726
  }) {
7694
- return {
7727
+ const context = {
7695
7728
  cwd: process.cwd(),
7729
+ load: agent ? ({ promise }) => promise : runWithSetupLoader,
7696
7730
  imports,
7697
7731
  createAnswer: () => createCliAnswer({ mode: "closed-list" }),
7698
7732
  setupController: createSetupController(),
7699
- selectStoredLoginCredentials: () => chooseStoredLoginCredentials({ imports, options: {} }),
7700
- authenticateNewAccount: ({ entryPoint, headless }) => runAccountAuth({
7733
+ selectStoredLoginCredentials: () => chooseStoredLoginCredentials({
7734
+ imports,
7735
+ options: {},
7736
+ ...agent ? {
7737
+ prompt: async (options) => {
7738
+ const credentialChoices = buildCredentialsChoices(options);
7739
+ const choices = credentialChoices.map(({ name, value }) => ({
7740
+ label: name,
7741
+ value: value.action === "create" ? "create" : `account:${value.credentials.name}`,
7742
+ result: value
7743
+ }));
7744
+ const selected = await resolveSetupSelect({
7745
+ answer: context.createAnswer(),
7746
+ controller: context.setupController,
7747
+ message: CREDENTIALS_PICKER_QUESTION,
7748
+ choices
7749
+ });
7750
+ const selectedIndex = choices.findIndex(
7751
+ ({ value }) => value === selected
7752
+ );
7753
+ return choices[selectedIndex].result;
7754
+ }
7755
+ } : {}
7756
+ }),
7757
+ authenticateNewAccount: ({ entryPoint, ...options }) => runAccountAuth({
7701
7758
  imports,
7702
- options: { headless },
7759
+ options,
7703
7760
  entryPoint,
7704
7761
  storedCredentialsMode: "fresh",
7705
- preserveExistingCredentials: true
7762
+ preserveExistingCredentials: true,
7763
+ useBrowserCallback: agent && options.headless === false,
7764
+ silent: agent && options.headless
7706
7765
  }),
7707
7766
  checkForUpdates,
7708
7767
  openUrl: async (url) => {
7709
7768
  await open__default.default(url);
7710
7769
  },
7711
- runCommand,
7770
+ runCommand: agent ? (options) => runCommand({
7771
+ ...options,
7772
+ capture: true,
7773
+ load: ({ promise, detail }) => {
7774
+ console.log(detail);
7775
+ return promise;
7776
+ }
7777
+ }) : runCommand,
7712
7778
  packageManager: detectPackageManager(process.cwd()).name,
7713
7779
  projectLanguage: "typescript"
7714
7780
  };
7781
+ return context;
7782
+ }
7783
+ var SetupStepSchema = zod.z.enum([
7784
+ "directory",
7785
+ "project",
7786
+ "install",
7787
+ "sdk-update",
7788
+ "cli-update",
7789
+ "skill",
7790
+ "account",
7791
+ "account-flow",
7792
+ "account-environment",
7793
+ "authorize",
7794
+ "confirm-account",
7795
+ "connections",
7796
+ "slack",
7797
+ "slack-overwrite",
7798
+ "slack-existing",
7799
+ "slack-retry",
7800
+ "handoff"
7801
+ ]);
7802
+ var SetupSchema = zod.z.object({
7803
+ agent: zod.z.boolean().optional().describe(
7804
+ "For AI agents and callers without a terminal: print the next setup question and the exact command to run for each answer."
7805
+ ),
7806
+ step: SetupStepSchema.optional().describe(
7807
+ "Setup operation to inspect or execute."
7808
+ ),
7809
+ nonInteractive: zod.z.boolean().optional().describe("Execute the named setup step without terminal prompts."),
7810
+ answer: zod.z.string().optional().describe(
7811
+ "User selection or input for a non-interactive setup step. Omitted confirmations use the terminal wizard's default."
7812
+ ),
7813
+ flow: zod.z.enum(["login", "signup"]).optional().describe(
7814
+ "Account flow selected for the environment and OAuth callback steps."
7815
+ ),
7816
+ language: zod.z.enum(["javascript", "typescript"]).optional().describe(
7817
+ "Project language for dependency installation and the Slack demo."
7818
+ )
7819
+ }).describe(
7820
+ "Set up the Zapier SDK in an existing or new project. Runs an interactive terminal wizard; AI agents should use --agent instead."
7821
+ );
7822
+ var agentLabels = {
7823
+ claude: "Claude Code",
7824
+ codex: "Codex",
7825
+ cursor: "Cursor",
7826
+ "vscode-copilot": "VS Code Copilot"
7827
+ };
7828
+ function buildAgentPrompt({
7829
+ context
7830
+ }) {
7831
+ const listConnectionsCommand = formatPackageCommand(
7832
+ createLocalPackageCommand({
7833
+ packageManager: context.packageManager,
7834
+ binary: "zapier-sdk",
7835
+ args: ["list-connections", "--owner", "me", "--json"]
7836
+ })
7837
+ );
7838
+ const listActionsCommand = formatPackageCommand(
7839
+ createLocalPackageCommand({
7840
+ packageManager: context.packageManager,
7841
+ binary: "zapier-sdk",
7842
+ args: ["list-actions", "APP_KEY"]
7843
+ })
7844
+ );
7845
+ return `Start by running this command to discover my active connected apps outside of your sandbox:
7846
+
7847
+ ${listConnectionsCommand}
7848
+
7849
+ Using the connected apps returned by that command:
7850
+
7851
+ - Pick 1-3 apps and show commands I can use to explore their actions, such as: ${listActionsCommand}
7852
+ - Do not run those list-actions commands.
7853
+ - Suggest 3 specific ideas based on my connected apps. Each idea should read from one app, optionally process data, and write to another.
7854
+ - Do not suggest event-driven workflows.
7855
+ - Keep each idea to one sentence. Example: "pull in-progress Jira issues and DM yourself a summary on Slack".
7856
+
7857
+ Do not inspect files or modify the project. If fewer than two distinct apps are listed, explain that cross-app ideas require another active connection instead of inventing apps.`;
7715
7858
  }
7716
- var SetupSchema = zod.z.object({}).describe("Set up the Zapier SDK in an existing or new project");
7717
- function printAuthCommand({
7859
+ function printAgentPrompt({
7718
7860
  context,
7719
- flow,
7720
- headless
7861
+ message
7721
7862
  }) {
7722
- const command = createLocalPackageCommand({
7723
- packageManager: context.packageManager,
7724
- binary: "zapier-sdk",
7725
- args: [flow, ...headless ? ["--headless"] : []]
7726
- });
7727
- console.log(`$ ${formatPackageCommand(command)}`);
7728
- if (headless) {
7729
- console.log(
7730
- "Open the printed URL in another browser, then paste the final OAuth callback URL when prompted."
7731
- );
7732
- }
7733
- }
7734
- function isCredentialWriteError(error) {
7735
- const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : "";
7736
- if (/^(eacces|eperm)$/i.test(code)) return true;
7737
- const message = error instanceof Error ? error.message : String(error);
7738
- return /permission|sandbox|eacces|eperm/i.test(message);
7739
- }
7740
- async function confirmAuthentication(context) {
7741
- const { data: profile } = await runWithSetupLoader({
7742
- promise: context.imports.getProfile({}),
7743
- label: "Confirming Zapier account"
7744
- });
7745
- context.accountEmail = profile.email;
7746
- console.log(`Authenticated as ${profile.email}.`);
7747
- }
7748
- async function authenticate(context) {
7749
- const activeProfile = await runWithSetupLoader({
7750
- promise: context.imports.getProfile({}).then(({ data }) => data).catch((error) => {
7751
- if (zapierSdk.isZapierAuthenticationError(error)) return void 0;
7752
- throw error;
7753
- }),
7754
- label: "Checking Zapier authentication"
7755
- });
7756
- const storedCredentialsSelection = await context.selectStoredLoginCredentials();
7757
- if (storedCredentialsSelection === "switch") {
7758
- await confirmAuthentication(context);
7759
- return;
7760
- }
7761
- if (storedCredentialsSelection === "none" && activeProfile) {
7762
- const shouldLogout = await resolveSetupConfirm({
7763
- answer: context.createAnswer(),
7764
- controller: context.setupController,
7765
- message: `You are already logged in as "${activeProfile.email}".
7766
- Logging out will delete these credentials and may interrupt other Zapier SDK or CLI sessions using them.
7767
- Log out and use a different account?`,
7768
- defaultValue: false
7769
- });
7770
- if (!shouldLogout) {
7771
- context.accountEmail = activeProfile.email;
7772
- console.log(`Continuing as ${activeProfile.email}.`);
7773
- return;
7774
- }
7775
- const logoutCommand = createLocalPackageCommand({
7776
- packageManager: context.packageManager,
7777
- binary: "zapier-sdk",
7778
- args: ["logout"]
7779
- });
7780
- console.log(`$ ${formatPackageCommand(logoutCommand)}`);
7781
- await context.imports.logout({});
7782
- }
7783
- const flow = await resolveSetupSelect({
7784
- answer: context.createAnswer(),
7785
- controller: context.setupController,
7786
- message: "Zapier account:",
7787
- choices: [
7788
- { label: "Log in to an existing account", value: "login" },
7789
- { label: "Create a new Zapier account", value: "signup" }
7790
- ]
7791
- });
7792
- const environment = await resolveSetupSelect({
7793
- answer: context.createAnswer(),
7794
- controller: context.setupController,
7795
- message: "Environment:",
7796
- choices: [
7797
- { label: "Local machine with a browser", value: "local" },
7798
- { label: "Remote or headless", value: "headless" }
7799
- ]
7800
- });
7801
- const headless = environment === "headless";
7802
- printAuthCommand({ context, flow, headless });
7803
- try {
7804
- if (storedCredentialsSelection === "create") {
7805
- await context.authenticateNewAccount({ entryPoint: flow, headless });
7806
- } else {
7807
- const runAuth = flow === "login" ? context.imports.login : context.imports.signup;
7808
- await runAuth({ headless });
7809
- }
7810
- } catch (error) {
7811
- if (isCredentialWriteError(error)) {
7812
- console.error(
7813
- "Authentication could not write credentials. A permissions or sandbox restriction may be blocking disk access."
7814
- );
7815
- }
7816
- throw error;
7817
- }
7818
- await confirmAuthentication(context);
7819
- }
7820
- var agentLabels = {
7821
- claude: "Claude Code",
7822
- codex: "Codex",
7823
- cursor: "Cursor",
7824
- "vscode-copilot": "VS Code Copilot"
7825
- };
7826
- function buildAgentPrompt({ context }) {
7827
- const listConnectionsCommand = formatPackageCommand(
7828
- createLocalPackageCommand({
7829
- packageManager: context.packageManager,
7830
- binary: "zapier-sdk",
7831
- args: ["list-connections", "--owner", "me", "--json"]
7832
- })
7833
- );
7834
- const listActionsCommand = formatPackageCommand(
7835
- createLocalPackageCommand({
7836
- packageManager: context.packageManager,
7837
- binary: "zapier-sdk",
7838
- args: ["list-actions", "APP_KEY"]
7839
- })
7840
- );
7841
- return `Start by running this command to discover my active connected apps outside of your sandbox:
7842
-
7843
- ${listConnectionsCommand}
7844
-
7845
- Using the connected apps returned by that command:
7846
-
7847
- - Pick 1-3 apps and show commands I can use to explore their actions, such as: ${listActionsCommand}
7848
- - Do not run those list-actions commands.
7849
- - Suggest 3 specific ideas based on my connected apps. Each idea should read from one app, optionally process data, and write to another.
7850
- - Do not suggest event-driven workflows.
7851
- - Keep each idea to one sentence. Example: "pull in-progress Jira issues and DM yourself a summary on Slack".
7852
-
7853
- Do not inspect files or modify the project. If fewer than two distinct apps are listed, explain that cross-app ideas require another active connection instead of inventing apps.`;
7854
- }
7855
- function printAgentPrompt({
7856
- context,
7857
- message
7858
- }) {
7859
- console.log();
7860
- console.log(chalk10__default.default.bgYellow.black.bold(message));
7861
- console.log();
7862
- console.log(buildAgentPrompt({ context }));
7863
+ console.log();
7864
+ console.log(chalk10__default.default.bgYellow.black.bold(message));
7865
+ console.log();
7866
+ console.log(buildAgentPrompt({ context }));
7863
7867
  }
7864
7868
  async function openAgentHandoff(context) {
7865
7869
  const agent = await resolveSetupSelect({
@@ -7930,27 +7934,291 @@ async function openAgentHandoff(context) {
7930
7934
  message: "If it didn't load correctly, paste this prompt into your agent:"
7931
7935
  });
7932
7936
  }
7937
+
7938
+ // src/plugins/setup/agent-output.ts
7939
+ var REQUIRED_STEPS = [
7940
+ "directory",
7941
+ "install"
7942
+ ];
7943
+ function formatSetupCommand({
7944
+ context,
7945
+ target,
7946
+ answer
7947
+ }) {
7948
+ const args = [
7949
+ "setup",
7950
+ "--step",
7951
+ target.step,
7952
+ "--non-interactive",
7953
+ ...target.flow ? ["--flow", target.flow] : [],
7954
+ "--language",
7955
+ context.projectLanguage,
7956
+ ...answer !== void 0 ? ["--answer", answer] : []
7957
+ ];
7958
+ return formatPackageCommand(
7959
+ SOURCE_CLI_PATH ? {
7960
+ command: process.execPath,
7961
+ args: [
7962
+ "--import",
7963
+ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))).resolve("tsx"),
7964
+ "--conditions",
7965
+ "source",
7966
+ SOURCE_CLI_PATH,
7967
+ ...args
7968
+ ]
7969
+ } : createPackageRunnerCommand({
7970
+ packageManager: context.packageManager,
7971
+ packageName: `@zapier/zapier-sdk-cli@${package_default.version}`,
7972
+ args
7973
+ })
7974
+ );
7975
+ }
7976
+ function printAgentStep({
7977
+ context,
7978
+ target,
7979
+ question
7980
+ }) {
7981
+ console.log(
7982
+ `Step: ${target.step}
7983
+ Working directory: ${context.cwd}
7984
+ Detected package manager: ${context.packageManager}
7985
+ Project language: ${context.projectLanguage}`
7986
+ );
7987
+ if (!question) {
7988
+ console.log(
7989
+ `Run this exact command:
7990
+ ${formatSetupCommand({ context, target })}`
7991
+ );
7992
+ } else {
7993
+ if (target.step === "authorize" && context.authorizationUrl)
7994
+ console.log(
7995
+ `Give the user this URL to open in a browser where they can sign in to Zapier:
7996
+ ${context.authorizationUrl}
7997
+ After they approve, the browser opens a localhost page that may fail to load. That is expected: ask them to copy the full address from the browser's address bar. Pass that address only to the command below; do not save it or repeat it elsewhere.`
7998
+ );
7999
+ console.log(`Ask the user this question verbatim: "${question.message}"`);
8000
+ if (question.type === "select") {
8001
+ for (const { value, label } of question.choices)
8002
+ console.log(`${JSON.stringify(value)}: ${label}`);
8003
+ for (const { value } of question.choices) {
8004
+ const decision = value === "true" ? "agrees" : value === "false" ? "declines" : `chooses ${JSON.stringify(value)}`;
8005
+ if (value === "false" && REQUIRED_STEPS.includes(target.step))
8006
+ console.log("If the user declines, stop setup.");
8007
+ else
8008
+ console.log(
8009
+ `If the user ${decision}, run this exact command:
8010
+ ${formatSetupCommand({ context, target, answer: value })}`
8011
+ );
8012
+ }
8013
+ } else {
8014
+ console.log(
8015
+ `Run this exact command with their answer as one shell-quoted argument (an empty answer is ''):
8016
+ ${formatSetupCommand({ context, target, answer: "<answer>" })}`
8017
+ );
8018
+ }
8019
+ if (target.step === "account-environment")
8020
+ console.log(
8021
+ `The local command opens a browser and waits up to ${LOGIN_TIMEOUT_MILLISECONDS / 1e3} seconds for authorization, using the terminal login flow. Keep the process running until it completes and allow extra time for credential creation. If the browser does not open, use its printed fallback URL or choose headless instead.`
8022
+ );
8023
+ console.log(
8024
+ "Use your tool for asking the user questions if you have one. Do not answer on the user's behalf."
8025
+ );
8026
+ }
8027
+ console.log(
8028
+ "On success, follow the next step's guidance printed by that operation. On failure, stop and report the error; do not proceed or retry automatically. Ignore CLI update notices; setup offers package updates as their own steps."
8029
+ );
8030
+ }
8031
+ function printAgentCompletion({
8032
+ context,
8033
+ cancelled = false
8034
+ }) {
8035
+ console.log(
8036
+ cancelled ? "Setup cancelled." : `Setup walkthrough finished. Report which operations succeeded, failed, or were skipped based on their command results.
8037
+ Learn more: https://docs.zapier.com/sdk
8038
+
8039
+ Continue in this agent. Do not open another agent or ask the user to choose one.
8040
+ ${buildAgentPrompt({ context })}`
8041
+ );
8042
+ }
8043
+
8044
+ // src/plugins/setup/authentication.ts
8045
+ function printAuthCommand({
8046
+ context,
8047
+ flow,
8048
+ headless = false
8049
+ }) {
8050
+ const command = createLocalPackageCommand({
8051
+ packageManager: context.packageManager,
8052
+ binary: "zapier-sdk",
8053
+ args: [flow, ...headless ? ["--headless"] : []]
8054
+ });
8055
+ console.log(`$ ${formatPackageCommand(command)}`);
8056
+ if (headless) {
8057
+ console.log(
8058
+ "Open the printed URL in another browser, then paste the final OAuth callback URL when prompted."
8059
+ );
8060
+ }
8061
+ }
8062
+ function isCredentialWriteError(error) {
8063
+ const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : "";
8064
+ if (/^(eacces|eperm)$/i.test(code)) return true;
8065
+ const message = error instanceof Error ? error.message : String(error);
8066
+ return /permission|sandbox|eacces|eperm/i.test(message);
8067
+ }
8068
+ async function confirmAuthentication(context) {
8069
+ const { data: profile } = await context.load({
8070
+ promise: context.imports.getProfile({}),
8071
+ label: "Confirming Zapier account"
8072
+ });
8073
+ context.accountEmail = profile.email;
8074
+ console.log(`Authenticated as ${profile.email}.`);
8075
+ }
8076
+ function selectAccountFlow(context) {
8077
+ return resolveSetupSelect({
8078
+ answer: context.createAnswer(),
8079
+ controller: context.setupController,
8080
+ message: "Zapier account:",
8081
+ choices: [
8082
+ { label: "Log in to an existing account", value: "login" },
8083
+ { label: "Create a new Zapier account", value: "signup" }
8084
+ ]
8085
+ });
8086
+ }
8087
+ function selectAuthenticationEnvironment(context) {
8088
+ return resolveSetupSelect({
8089
+ answer: context.createAnswer(),
8090
+ controller: context.setupController,
8091
+ message: "Environment:",
8092
+ choices: [
8093
+ { label: "Local machine with a browser", value: "local" },
8094
+ { label: "Remote or headless", value: "headless" }
8095
+ ]
8096
+ });
8097
+ }
8098
+ async function selectAccount(context) {
8099
+ const activeProfile = await context.load({
8100
+ promise: context.imports.getProfile({}).then(({ data }) => data).catch((error) => {
8101
+ if (zapierSdk.isZapierAuthenticationError(error)) return void 0;
8102
+ throw error;
8103
+ }),
8104
+ label: "Checking Zapier authentication"
8105
+ });
8106
+ const storedCredentialsSelection = await context.selectStoredLoginCredentials();
8107
+ if (storedCredentialsSelection === "none" && activeProfile) {
8108
+ const shouldLogout = await resolveSetupConfirm({
8109
+ answer: context.createAnswer(),
8110
+ controller: context.setupController,
8111
+ message: `You are already logged in as "${activeProfile.email}".
8112
+ Logging out will delete these credentials and may interrupt other Zapier SDK or CLI sessions using them.
8113
+ Log out and use a different account?`,
8114
+ defaultValue: false
8115
+ });
8116
+ if (!shouldLogout) {
8117
+ context.accountEmail = activeProfile.email;
8118
+ console.log(`Continuing as ${activeProfile.email}.`);
8119
+ return "continue";
8120
+ }
8121
+ printAuthCommand({ context, flow: "logout" });
8122
+ await context.imports.logout({});
8123
+ }
8124
+ return storedCredentialsSelection;
8125
+ }
8126
+ async function authenticate(context) {
8127
+ const next = await runAuthenticationStep({ context, options: {} });
8128
+ if (next.step === "confirm-account") await confirmAuthentication(context);
8129
+ }
8130
+ async function runAuthenticationStep({
8131
+ context,
8132
+ options
8133
+ }) {
8134
+ const { step } = options;
8135
+ let newAccount = step === "account-environment";
8136
+ if (!step || step === "account") {
8137
+ const selection = await selectAccount(context);
8138
+ if (selection === "switch") return { step: "confirm-account" };
8139
+ if (selection === "continue")
8140
+ return { step: step ? "confirm-account" : "connections" };
8141
+ if (step) return { step: "account-flow" };
8142
+ newAccount = selection === "create";
8143
+ }
8144
+ if (step === "confirm-account") {
8145
+ await confirmAuthentication(context);
8146
+ return { step: "connections" };
8147
+ }
8148
+ const flow = !step || step === "account-flow" ? await selectAccountFlow(context) : options.flow;
8149
+ if (step === "account-flow")
8150
+ return {
8151
+ step: "account-environment",
8152
+ flow
8153
+ };
8154
+ if (!flow)
8155
+ throw new ZapierCliValidationError(
8156
+ "This setup step requires --flow login or --flow signup."
8157
+ );
8158
+ let headless = true;
8159
+ let callbackUrl;
8160
+ let recoveryMessage;
8161
+ if (step === "authorize") {
8162
+ recoveryMessage = `Generate a fresh authorization URL with \`${formatSetupCommand(
8163
+ {
8164
+ context,
8165
+ target: { step: "account-environment", flow },
8166
+ answer: "headless"
8167
+ }
8168
+ )}\`.`;
8169
+ const pending = getPendingOauthFlow({ entryPoint: flow, recoveryMessage });
8170
+ context.authorizationUrl = pending.transaction.browserAuthUrl;
8171
+ callbackUrl = await resolveSetupInput({
8172
+ answer: context.createAnswer(),
8173
+ controller: context.setupController,
8174
+ message: OAUTH_CALLBACK_QUESTION
8175
+ });
8176
+ } else {
8177
+ headless = await selectAuthenticationEnvironment(context) === "headless";
8178
+ if (!step) printAuthCommand({ context, flow, headless });
8179
+ }
8180
+ const authOptions = {
8181
+ headless,
8182
+ ...step ? { nonInteractive: true } : {},
8183
+ ...callbackUrl !== void 0 ? { callbackUrl } : {}
8184
+ };
8185
+ try {
8186
+ if (newAccount) {
8187
+ await context.authenticateNewAccount({
8188
+ entryPoint: flow,
8189
+ ...authOptions
8190
+ });
8191
+ } else {
8192
+ await context.imports[flow](authOptions);
8193
+ }
8194
+ } catch (error) {
8195
+ if (recoveryMessage) console.error(recoveryMessage);
8196
+ if (isCredentialWriteError(error)) {
8197
+ console.error(
8198
+ "Authentication could not write credentials. A permissions or sandbox restriction may be blocking disk access."
8199
+ );
8200
+ }
8201
+ throw error;
8202
+ }
8203
+ return step === "account-environment" && headless ? { step: "authorize", flow } : { step: "confirm-account" };
8204
+ }
7933
8205
  var CONNECTIONS_URL = "https://zapier.com/app/assets/connections";
7934
8206
  var CONNECTION_DISPLAY_LIMIT = 10;
7935
- async function ensureConnectionsAvailable(context) {
7936
- const page = await runWithSetupLoader({
8207
+ async function showActiveConnections(context) {
8208
+ const page = await context.load({
7937
8209
  promise: context.imports.listConnections({
7938
8210
  owner: "me",
7939
8211
  maxItems: CONNECTION_DISPLAY_LIMIT
7940
8212
  }),
7941
8213
  label: "Loading app connections"
7942
8214
  });
7943
- if (page.data.length === 0) {
7944
- console.log(
7945
- `No active connections found. Connect or reconnect an app at ${CONNECTIONS_URL}, then come back and run setup again.`
7946
- );
7947
- throw new ZapierCliExitError(
7948
- "Setup stopped before completion because no active connections are available."
7949
- );
7950
- }
8215
+ if (page.data.length === 0) return false;
7951
8216
  const table = new Table__default.default({
7952
8217
  head: ["App", "Connection"],
7953
- style: { compact: true }
8218
+ style: {
8219
+ compact: true,
8220
+ ...process.stdout.isTTY ? {} : { head: [], border: [] }
8221
+ }
7954
8222
  });
7955
8223
  table.push(
7956
8224
  ...page.data.map((connection) => [
@@ -7962,11 +8230,22 @@ async function ensureConnectionsAvailable(context) {
7962
8230
  `Active Zapier connections (showing up to ${CONNECTION_DISPLAY_LIMIT}):`
7963
8231
  );
7964
8232
  console.log(table.toString());
8233
+ return true;
8234
+ }
8235
+ async function ensureConnectionsAvailable(context) {
8236
+ if (await showActiveConnections(context)) return;
8237
+ console.log(
8238
+ `No active connections found. Connect or reconnect an app at ${CONNECTIONS_URL}, then come back and run setup again.`
8239
+ );
8240
+ throw new ZapierCliExitError(
8241
+ "Setup stopped before completion because no active connections are available."
8242
+ );
7965
8243
  }
7966
8244
  var CONNECTION_PLACEHOLDER = "__ZAPIER_SDK_SLACK_CONNECTION__";
7967
8245
  var EMAIL_PLACEHOLDER = "__ZAPIER_SDK_ACCOUNT_EMAIL__";
7968
8246
  var APP_PLACEHOLDER = "__ZAPIER_SDK_SLACK_APP__";
7969
8247
  var SLACK_SLUG = "slack";
8248
+ var SLACK_RETRY_QUESTION = "Slack email for one retry after the failed test:";
7970
8249
  function getSlackTestPath(context) {
7971
8250
  const extension = context.projectLanguage === "typescript" ? "ts" : "mjs";
7972
8251
  return path.join("src", "sdk-demo", `zapier-slack-test.${extension}`);
@@ -7976,7 +8255,7 @@ function getSlackTestTemplatePath(context) {
7976
8255
  return path.join(TEMPLATES_DIR, "setup", `zapier-slack-test.${extension}`);
7977
8256
  }
7978
8257
  async function findSlackConnection(context) {
7979
- const page = await runWithSetupLoader({
8258
+ const page = await context.load({
7980
8259
  promise: context.imports.listConnections({
7981
8260
  owner: "me",
7982
8261
  app: SLACK_SLUG,
@@ -7997,17 +8276,22 @@ function renderSlackTest({
7997
8276
  }) {
7998
8277
  return fs.readFileSync(getSlackTestTemplatePath(context), "utf8").replace(APP_PLACEHOLDER, () => toTemplateString(app)).replace(CONNECTION_PLACEHOLDER, () => toTemplateString(connection)).replace(EMAIL_PLACEHOLDER, () => toTemplateString(email));
7999
8278
  }
8000
- function writeSlackTest({
8279
+ async function createAndRunSlackTest({
8001
8280
  context,
8002
- app,
8003
8281
  connection,
8004
- email
8282
+ email,
8283
+ overwrite = true
8005
8284
  }) {
8006
8285
  const slackTestPath = getSlackTestPath(context);
8007
8286
  const path2 = path.join(context.cwd, slackTestPath);
8008
8287
  if (!fs.existsSync(path.dirname(path2))) fs.mkdirSync(path.dirname(path2), { recursive: true });
8009
- fs.writeFileSync(path2, renderSlackTest({ context, app, connection, email }));
8288
+ fs.writeFileSync(
8289
+ path2,
8290
+ renderSlackTest({ context, app: SLACK_SLUG, connection, email }),
8291
+ { flag: overwrite ? "w" : "wx" }
8292
+ );
8010
8293
  console.log(`Created ${slackTestPath}.`);
8294
+ return trySlackTest(context);
8011
8295
  }
8012
8296
  async function executeSlackTest(context) {
8013
8297
  const slackTestPath = getSlackTestPath(context);
@@ -8035,75 +8319,76 @@ async function executeSlackTest(context) {
8035
8319
  async function trySlackTest(context) {
8036
8320
  try {
8037
8321
  await executeSlackTest(context);
8322
+ (context.outcomes ?? (context.outcomes = {})).slack = "succeeded";
8038
8323
  return true;
8039
8324
  } catch (error) {
8325
+ (context.outcomes ?? (context.outcomes = {})).slack = "failed";
8040
8326
  const message = error instanceof Error ? error.message : String(error);
8041
8327
  console.warn(`Slack demo failed: ${message}. Setup will continue.`);
8042
8328
  return false;
8043
8329
  }
8044
8330
  }
8045
- async function offerSlackTest(context) {
8331
+ async function runSlackStep({
8332
+ context,
8333
+ step,
8334
+ connection
8335
+ }) {
8046
8336
  if (!context.accountEmail) {
8047
8337
  console.log("No account email found; skipping the Slack demo.");
8048
- return;
8338
+ return "handoff";
8049
8339
  }
8050
- const slackConnection = await findSlackConnection(context);
8051
- if (!slackConnection) {
8340
+ if (!connection) {
8052
8341
  console.log("No active Slack connection found; skipping the Slack demo.");
8053
- return;
8342
+ return "handoff";
8054
8343
  }
8055
- const slackTestPath = getSlackTestPath(context);
8056
- const shouldRun = await resolveSetupConfirm({
8057
- answer: context.createAnswer(),
8058
- controller: context.setupController,
8059
- message: `Run the Slack self-DM test using ${context.accountEmail}?`,
8060
- defaultValue: true
8061
- });
8062
- if (!shouldRun) return;
8063
- const path2 = path.join(context.cwd, slackTestPath);
8064
- if (fs.existsSync(path2)) {
8065
- const shouldOverwrite = await resolveSetupConfirm({
8344
+ if (step === "slack-retry") {
8345
+ const email = await resolveSetupInput({
8066
8346
  answer: context.createAnswer(),
8067
8347
  controller: context.setupController,
8068
- message: `${slackTestPath} already exists. Is it okay to overwrite it?`,
8069
- defaultValue: false
8348
+ message: SLACK_RETRY_QUESTION
8070
8349
  });
8071
- if (!shouldOverwrite) {
8072
- console.log("Keeping the existing Slack test file.");
8073
- const shouldRunExisting = await resolveSetupConfirm({
8074
- answer: context.createAnswer(),
8075
- controller: context.setupController,
8076
- message: `Run the existing ${slackTestPath}?`,
8077
- defaultValue: false
8350
+ if (email)
8351
+ await createAndRunSlackTest({
8352
+ context,
8353
+ connection: connection.id,
8354
+ email
8078
8355
  });
8079
- if (shouldRunExisting) await trySlackTest(context);
8080
- return;
8081
- }
8356
+ else console.log("Skipping the Slack test.");
8357
+ return "handoff";
8082
8358
  }
8083
- let email = context.accountEmail;
8084
- writeSlackTest({
8085
- context,
8086
- app: SLACK_SLUG,
8087
- connection: slackConnection.id,
8088
- email
8089
- });
8090
- if (await trySlackTest(context)) return;
8091
- email = await resolveSetupInput({
8359
+ const slackTestPath = getSlackTestPath(context);
8360
+ const shouldRun = await resolveSetupConfirm({
8092
8361
  answer: context.createAnswer(),
8093
8362
  controller: context.setupController,
8094
- message: "Slack email for one retry after the failed test:"
8363
+ message: step === "slack" ? `Run the Slack self-DM test using ${context.accountEmail}?` : step === "slack-overwrite" ? `${slackTestPath} already exists. Is it okay to overwrite it?` : `Run the existing ${slackTestPath}?`,
8364
+ defaultValue: step === "slack"
8095
8365
  });
8096
- if (!email) {
8097
- console.log("Skipping the Slack test.");
8098
- return;
8366
+ if (!shouldRun) {
8367
+ if (step === "slack-overwrite") {
8368
+ console.log("Keeping the existing Slack test file.");
8369
+ return "slack-existing";
8370
+ }
8371
+ return "handoff";
8372
+ }
8373
+ if (step === "slack" && fs.existsSync(path.join(context.cwd, slackTestPath)))
8374
+ return "slack-overwrite";
8375
+ if (step === "slack-existing") {
8376
+ await trySlackTest(context);
8377
+ return "handoff";
8099
8378
  }
8100
- writeSlackTest({
8379
+ const succeeded = await createAndRunSlackTest({
8101
8380
  context,
8102
- app: SLACK_SLUG,
8103
- connection: slackConnection.id,
8104
- email
8381
+ connection: connection.id,
8382
+ email: context.accountEmail,
8383
+ overwrite: step === "slack-overwrite"
8105
8384
  });
8106
- await trySlackTest(context);
8385
+ return succeeded ? "handoff" : "slack-retry";
8386
+ }
8387
+ async function offerSlackTest(context) {
8388
+ const connection = context.accountEmail ? await findSlackConnection(context) : void 0;
8389
+ let step = "slack";
8390
+ while (step !== "handoff")
8391
+ step = await runSlackStep({ context, step, connection });
8107
8392
  }
8108
8393
 
8109
8394
  // src/plugins/setup/skill.ts
@@ -8129,7 +8414,9 @@ async function installOptionalSkill(context) {
8129
8414
  cwd: context.cwd,
8130
8415
  capture: true
8131
8416
  });
8417
+ (context.outcomes ?? (context.outcomes = {})).skill = "succeeded";
8132
8418
  } catch {
8419
+ (context.outcomes ?? (context.outcomes = {})).skill = "failed";
8133
8420
  console.warn(
8134
8421
  `Could not install the optional Zapier SDK skill. To install it manually, run: ${formatPackageCommand(command)}`
8135
8422
  );
@@ -8186,6 +8473,177 @@ async function runWizard(context) {
8186
8473
  console.log(chalk10__default.default.bgCyan.black.bold(" Next steps "));
8187
8474
  await openAgentHandoff(context);
8188
8475
  }
8476
+ var UNPROMPTED_STEPS = [
8477
+ "project",
8478
+ "confirm-account",
8479
+ "connections"
8480
+ ];
8481
+ var ZapierSetupQuestionSignal = class extends zapierSdk.ZapierSignal {
8482
+ constructor(question) {
8483
+ super(question.message);
8484
+ this.question = question;
8485
+ this.name = "ZapierSetupQuestionSignal";
8486
+ this.code = "ZAPIER_SETUP_QUESTION";
8487
+ }
8488
+ };
8489
+ function isZapierSetupQuestionSignal(error) {
8490
+ return zapierSdk.isZapierSignal(error) && error.code === "ZAPIER_SETUP_QUESTION";
8491
+ }
8492
+ function createSetupAnswer({
8493
+ answer,
8494
+ execute
8495
+ }) {
8496
+ let answered = false;
8497
+ return async ({ result: { question } }) => {
8498
+ if (question.type === "collection")
8499
+ throw new ZapierCliValidationError(
8500
+ "Setup expects a selection or text input."
8501
+ );
8502
+ if (!execute) throw new ZapierSetupQuestionSignal(question);
8503
+ if (answered)
8504
+ throw new ZapierCliValidationError(
8505
+ "Each setup step can answer only one question. Inspect the next question with --agent and run it in a separate command."
8506
+ );
8507
+ answered = true;
8508
+ const confirmation = question.type === "select" && question.choices.some(({ value }) => value === "true") && question.choices.some(({ value }) => value === "false");
8509
+ if (answer === void 0 && !confirmation)
8510
+ throw new ZapierCliValidationError(
8511
+ "This setup step requires --answer. Inspect it with --agent and pass the user's selection or input."
8512
+ );
8513
+ if (question.type === "input")
8514
+ return { type: "custom", value: answer?.trim() ?? "" };
8515
+ const selected = answer?.trim() ?? question.choices[0].value;
8516
+ if (!question.choices.some(({ value }) => value === selected))
8517
+ throw new ZapierCliValidationError(
8518
+ `Answer must be one of: ${question.choices.map(({ value }) => value).join(", ")}.`
8519
+ );
8520
+ return { type: "choose", value: selected };
8521
+ };
8522
+ }
8523
+ async function runSetupStep({
8524
+ context,
8525
+ target
8526
+ }) {
8527
+ switch (target.step) {
8528
+ case "directory":
8529
+ await chooseDirectory(context);
8530
+ return { step: "project" };
8531
+ case "project":
8532
+ await ensureSupportedNode(context);
8533
+ await initializeProject(context);
8534
+ return { step: "install" };
8535
+ case "install":
8536
+ await offerMissingPackageInstall({
8537
+ context,
8538
+ packages: getPackageStates(context).filter(({ declared }) => !declared)
8539
+ });
8540
+ return { step: "sdk-update" };
8541
+ case "sdk-update":
8542
+ case "cli-update": {
8543
+ const name = target.step === "sdk-update" ? "@zapier/zapier-sdk" : "@zapier/zapier-sdk-cli";
8544
+ const packageState = getPackageStates(context).find(
8545
+ ({ dependency }) => dependency.name === name
8546
+ );
8547
+ if (packageState) await offerPackageUpdate({ context, packageState });
8548
+ return { step: target.step === "sdk-update" ? "cli-update" : "skill" };
8549
+ }
8550
+ case "skill":
8551
+ await installOptionalSkill(context);
8552
+ return { step: "account" };
8553
+ case "account":
8554
+ case "account-flow":
8555
+ case "account-environment":
8556
+ case "authorize":
8557
+ case "confirm-account":
8558
+ return runAuthenticationStep({ context, options: target });
8559
+ case "connections":
8560
+ if (!await showActiveConnections(context)) {
8561
+ console.log(
8562
+ `No active connections found. Ask the user to connect or reconnect an app at ${CONNECTIONS_URL}. After they confirm, run this exact command:
8563
+ ${formatSetupCommand({ context, target })}
8564
+ Success means it prints the active connections table.`
8565
+ );
8566
+ throw new ZapierCliExitError(
8567
+ "Setup stopped until an app connection is active."
8568
+ );
8569
+ }
8570
+ console.log(
8571
+ "Show the user every app and connection title in the table above before continuing. Do not just report that connections were found."
8572
+ );
8573
+ return { step: "slack" };
8574
+ case "slack":
8575
+ case "slack-overwrite":
8576
+ case "slack-existing":
8577
+ case "slack-retry": {
8578
+ const { data: profile } = await context.imports.getProfile({});
8579
+ context.accountEmail = profile.email;
8580
+ return {
8581
+ step: await runSlackStep({
8582
+ context,
8583
+ step: target.step,
8584
+ connection: await findSlackConnection(context)
8585
+ })
8586
+ };
8587
+ }
8588
+ }
8589
+ }
8590
+ async function runAgentSetup({
8591
+ context,
8592
+ options
8593
+ }) {
8594
+ if (options.agent && options.nonInteractive)
8595
+ throw new ZapierCliValidationError(
8596
+ "Use --agent to inspect a step or --non-interactive to execute it, not both."
8597
+ );
8598
+ if (!options.agent && !options.nonInteractive)
8599
+ throw new ZapierCliValidationError(
8600
+ options.step ? "Use --agent to inspect the named step or --non-interactive to execute it." : "--answer, --flow, and --language require a setup step."
8601
+ );
8602
+ if (options.nonInteractive && !options.step)
8603
+ throw new ZapierCliValidationError(
8604
+ "--non-interactive requires --step. Start with setup --agent and follow its printed commands."
8605
+ );
8606
+ if (options.answer !== void 0 && !options.nonInteractive)
8607
+ throw new ZapierCliValidationError("--answer requires --non-interactive.");
8608
+ context.cwd = fs.realpathSync(context.cwd);
8609
+ context.projectLanguage = options.language ?? detectProjectLanguage({
8610
+ cwd: context.cwd,
8611
+ hasExistingProject: fs.existsSync(path.join(context.cwd, "package.json"))
8612
+ });
8613
+ let target = {
8614
+ step: options.step ?? "directory",
8615
+ flow: options.flow
8616
+ };
8617
+ let execute = options.nonInteractive === true;
8618
+ while (true) {
8619
+ const { step, flow } = target;
8620
+ if (step === "handoff") return printAgentCompletion({ context });
8621
+ if (!execute && UNPROMPTED_STEPS.includes(step))
8622
+ return printAgentStep({ context, target });
8623
+ const answer = createSetupAnswer({
8624
+ answer: execute ? options.answer : void 0,
8625
+ execute
8626
+ });
8627
+ context.createAnswer = () => answer;
8628
+ try {
8629
+ const next = await runSetupStep({ context, target: { step, flow } });
8630
+ if (options.language) context.projectLanguage = options.language;
8631
+ if (execute)
8632
+ for (const [operation, outcome] of Object.entries(
8633
+ context.outcomes ?? {}
8634
+ ))
8635
+ console.log(`${operation}: ${outcome}`);
8636
+ target = next;
8637
+ execute = false;
8638
+ } catch (error) {
8639
+ if (isZapierSetupQuestionSignal(error))
8640
+ return printAgentStep({ context, target, question: error.question });
8641
+ if (error instanceof ZapierCliUserCancellationError)
8642
+ return printAgentCompletion({ context, cancelled: true });
8643
+ throw error;
8644
+ }
8645
+ }
8646
+ }
8189
8647
 
8190
8648
  // src/plugins/setup/index.ts
8191
8649
  var getProfileRef = zapierSdk.declareMethod({ id: "getProfile" });
@@ -8210,10 +8668,19 @@ var setupPlugin = zapierSdk.defineMethod({
8210
8668
  supportsJsonOutput: false,
8211
8669
  inputSchema: SetupSchema,
8212
8670
  output: "raw",
8213
- run: async ({ imports }) => {
8671
+ run: async ({ imports, input }) => {
8672
+ if (input.agent || input.nonInteractive || [input.step, input.answer, input.flow, input.language].some(
8673
+ (value) => value !== void 0
8674
+ )) {
8675
+ await runAgentSetup({
8676
+ context: createWizardContext({ imports, agent: true }),
8677
+ options: input
8678
+ });
8679
+ return;
8680
+ }
8214
8681
  if (process.stdin.isTTY !== true || process.stdout.isTTY !== true) {
8215
- throw new ZapierCliExitError(
8216
- "`zapier-sdk setup` requires an interactive terminal."
8682
+ throw new ZapierCliValidationError(
8683
+ "`zapier-sdk setup` requires an interactive terminal. AI agents and other callers without a terminal should run `zapier-sdk setup --agent` and follow its printed steps."
8217
8684
  );
8218
8685
  }
8219
8686
  await runWizard(createWizardContext({ imports }));
@@ -8693,59 +9160,6 @@ var watchTriggerInboxCliPlugin = zapierSdk.defineMethod({
8693
9160
  return doWatch();
8694
9161
  }
8695
9162
  });
8696
- var createWorkflowRef = experimental.declareMethod({ id: "createWorkflow" });
8697
- function createPublicInputSchema(schema) {
8698
- const publicSchema = zod.z.object(
8699
- Object.fromEntries(
8700
- Object.entries(schema.shape).filter(
8701
- ([name]) => !experimental.INTERNAL_CREATE_WORKFLOW_FIELDS.includes(
8702
- name
8703
- )
8704
- )
8705
- )
8706
- );
8707
- return schema.description === void 0 ? publicSchema : publicSchema.describe(schema.description);
8708
- }
8709
- var CreateWorkflowCliOptionsSchema = createPublicInputSchema(
8710
- experimental.CreateWorkflowOptionsSchema
8711
- );
8712
- var createWorkflowCliPlugin = experimental.defineMethod({
8713
- namespace: "cli",
8714
- name: "createWorkflow",
8715
- imports: [createWorkflowRef],
8716
- type: "create",
8717
- itemType: "Workflow",
8718
- categories: ["code-workflow"],
8719
- stability: "experimental",
8720
- inputSchema: CreateWorkflowCliOptionsSchema,
8721
- outputSchema: experimental.CreateWorkflowResponseSchema,
8722
- skipOutputValidation: true,
8723
- output: "raw",
8724
- run: ({ imports, input }) => imports.createWorkflow({
8725
- ...input,
8726
- creationHarness: experimental.getAgent(),
8727
- creationAccessMethod: "sdk_cli"
8728
- })
8729
- });
8730
- var importWorkflowRef = experimental.declareMethod({ id: "importWorkflow" });
8731
- var importWorkflowCliPlugin = experimental.defineMethod({
8732
- namespace: "cli",
8733
- name: "importWorkflow",
8734
- imports: [importWorkflowRef],
8735
- type: "create",
8736
- itemType: "Workflow",
8737
- categories: ["code-workflow"],
8738
- stability: "experimental",
8739
- inputSchema: createPublicInputSchema(experimental.ImportWorkflowOptionsSchema),
8740
- outputSchema: experimental.ImportWorkflowResponseSchema,
8741
- skipOutputValidation: true,
8742
- output: "raw",
8743
- run: ({ imports, input }) => imports.importWorkflow({
8744
- ...input,
8745
- creationHarness: experimental.getAgent(),
8746
- creationAccessMethod: "sdk_cli"
8747
- })
8748
- });
8749
9163
  var BOX_WIDTH = 72;
8750
9164
  var BOX_TITLE = "ZAPIER SDK DEPRECATION NOTICE";
8751
9165
  var activeNotices = /* @__PURE__ */ new Map();
@@ -8788,7 +9202,7 @@ function buildBoxLines(message) {
8788
9202
  // package.json with { type: 'json' }
8789
9203
  var package_default2 = {
8790
9204
  name: "@zapier/zapier-sdk-cli",
8791
- version: "0.86.7"};
9205
+ version: "0.87.1"};
8792
9206
 
8793
9207
  // src/sdk.ts
8794
9208
  var warnedDeprecatedMethods = /* @__PURE__ */ new Set();
@@ -8954,14 +9368,10 @@ function createZapierCliSdk3(options = {}) {
8954
9368
  exports: [
8955
9369
  experimental.omitExports(experimental.zapierExperimentalSdkPlugin, [
8956
9370
  "drainTriggerInbox",
8957
- "watchTriggerInbox",
8958
- "createWorkflow",
8959
- "importWorkflow"
9371
+ "watchTriggerInbox"
8960
9372
  ]),
8961
9373
  drainTriggerInboxCliPlugin,
8962
9374
  watchTriggerInboxCliPlugin,
8963
- createWorkflowCliPlugin,
8964
- importWorkflowCliPlugin,
8965
9375
  loginPlugin,
8966
9376
  signupPlugin,
8967
9377
  logoutPlugin,