@mutagent/cli 0.1.7 → 0.1.8

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/bin/cli.js CHANGED
@@ -14041,7 +14041,11 @@ async function performBrowserAuth(options, onStatusUpdate) {
14041
14041
  }
14042
14042
  }
14043
14043
  }
14044
- onStatusUpdate?.("Or visit: " + authUrl);
14044
+ console.log("");
14045
+ console.log(" Open this URL to authenticate:");
14046
+ console.log("");
14047
+ console.log(" " + authUrl);
14048
+ console.log("");
14045
14049
  onStatusUpdate?.("Waiting for browser authentication...");
14046
14050
  const startTime = Date.now();
14047
14051
  while (Date.now() - startTime < timeout) {
@@ -14115,16 +14119,18 @@ Examples:
14115
14119
  ${chalk2.dim("$")} mutagent auth status
14116
14120
  ${chalk2.dim("$")} mutagent auth logout
14117
14121
  `);
14118
- auth.command("login").description("Authenticate and store API key").option("--api-key <key>", "API key (non-interactive)").option("--browser", "Force browser-based authentication").option("--endpoint <url>", "API endpoint", "https://api.mutagent.io").addHelpText("after", `
14122
+ auth.command("login").description("Authenticate and store API key").option("--api-key <key>", "API key (non-interactive)").option("--browser", "Force browser-based authentication").option("--non-interactive", "Disable interactive prompts (auto-selects browser auth)").option("--endpoint <url>", "API endpoint", "https://api.mutagent.io").addHelpText("after", `
14119
14123
  Examples:
14120
14124
  ${chalk2.dim("$")} mutagent auth login ${chalk2.dim("# Interactive (choose method)")}
14121
14125
  ${chalk2.dim("$")} mutagent auth login --browser ${chalk2.dim("# Browser OAuth flow")}
14122
14126
  ${chalk2.dim("$")} mutagent auth login --api-key mg_live_xxx ${chalk2.dim("# Direct API key (CI/CD)")}
14127
+ ${chalk2.dim("$")} mutagent auth login --non-interactive ${chalk2.dim("# Auto browser flow (AI agents)")}
14123
14128
 
14124
14129
  Environment Variables:
14125
- MUTAGENT_API_KEY API key (skips login entirely)
14126
- MUTAGENT_ENDPOINT Custom API endpoint
14127
- CI=true Enables non-interactive mode
14130
+ MUTAGENT_API_KEY API key (skips login entirely)
14131
+ MUTAGENT_ENDPOINT Custom API endpoint
14132
+ MUTAGENT_NON_INTERACTIVE=true Non-interactive mode (auto browser auth)
14133
+ CI=true Enables non-interactive mode
14128
14134
  `).action(async (options) => {
14129
14135
  const isJson = getJsonFlag(auth);
14130
14136
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -14160,10 +14166,11 @@ Environment Variables:
14160
14166
  }
14161
14167
  return;
14162
14168
  }
14163
- if (isJson || process.env.MUTAGENT_NON_INTERACTIVE === "true") {
14164
- throw new MutagentError2("INTERACTIVE_REQUIRED", "Interactive login required. Use --api-key flag or set MUTAGENT_API_KEY env var.", "Run: mutagent auth login --api-key <key> or export MUTAGENT_API_KEY=<key>");
14169
+ const isNonInteractive = options.nonInteractive === true || process.env.MUTAGENT_NON_INTERACTIVE === "true" || process.env.CI === "true" || !process.stdin.isTTY;
14170
+ if (isJson && !options.browser && isNonInteractive) {
14171
+ throw new MutagentError2("INTERACTIVE_REQUIRED", "No API key provided. Use --api-key flag, set MUTAGENT_API_KEY env var, or add --browser for browser auth.", "Run: mutagent auth login --api-key <key> or mutagent auth login --browser --non-interactive");
14165
14172
  }
14166
- if (!hasCredentials()) {
14173
+ if (!isNonInteractive && !hasCredentials()) {
14167
14174
  console.log(`
14168
14175
  ` + chalk2.bold.cyan(" Welcome to MutagenT CLI!") + `
14169
14176
  `);
@@ -14171,6 +14178,10 @@ Environment Variables:
14171
14178
  `);
14172
14179
  }
14173
14180
  let useLocalBrowserAuth = options.browser === true;
14181
+ if (!useLocalBrowserAuth && isNonInteractive) {
14182
+ output.info("Non-interactive environment detected. Using browser authentication.");
14183
+ useLocalBrowserAuth = true;
14184
+ }
14174
14185
  if (!useLocalBrowserAuth && !options.apiKey) {
14175
14186
  const methodAnswer = await inquirer.prompt([
14176
14187
  {
@@ -14372,11 +14383,12 @@ import inquirer2 from "inquirer";
14372
14383
  import chalk3 from "chalk";
14373
14384
  import ora2 from "ora";
14374
14385
  function createLoginCommand() {
14375
- const login = new Command2("login").description("Login to MutagenT platform").option("--api-key <key>", "API key (non-interactive)").option("--browser", "Force browser-based authentication").option("--endpoint <url>", "API endpoint", "https://api.mutagent.io").addHelpText("after", `
14386
+ const login = new Command2("login").description("Login to MutagenT platform").option("--api-key <key>", "API key (non-interactive)").option("--browser", "Force browser-based authentication").option("--non-interactive", "Disable interactive prompts (auto-selects browser auth)").option("--endpoint <url>", "API endpoint", "https://api.mutagent.io").addHelpText("after", `
14376
14387
  Examples:
14377
14388
  ${chalk3.dim("$")} mutagent login
14378
14389
  ${chalk3.dim("$")} mutagent login --browser
14379
14390
  ${chalk3.dim("$")} mutagent login --api-key <key>
14391
+ ${chalk3.dim("$")} mutagent login --non-interactive ${chalk3.dim("# Auto browser flow (AI agents)")}
14380
14392
  `).action(async (options) => {
14381
14393
  const isJson = getJsonFlag(login);
14382
14394
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -14396,10 +14408,11 @@ Examples:
14396
14408
  }
14397
14409
  return;
14398
14410
  }
14399
- if (isJson || process.env.MUTAGENT_NON_INTERACTIVE === "true") {
14400
- throw new MutagentError2("INTERACTIVE_REQUIRED", "Interactive login required. Use --api-key flag or set MUTAGENT_API_KEY env var.", "Run: mutagent login --api-key <key> or export MUTAGENT_API_KEY=<key>");
14411
+ const isNonInteractive = options.nonInteractive === true || process.env.MUTAGENT_NON_INTERACTIVE === "true" || process.env.CI === "true" || !process.stdin.isTTY;
14412
+ if (isJson && !options.browser && isNonInteractive) {
14413
+ throw new MutagentError2("INTERACTIVE_REQUIRED", "No API key provided. Use --api-key flag, set MUTAGENT_API_KEY env var, or add --browser for browser auth.", "Run: mutagent login --api-key <key> or mutagent login --browser --non-interactive");
14401
14414
  }
14402
- if (!hasCredentials()) {
14415
+ if (!isNonInteractive && !hasCredentials()) {
14403
14416
  console.log(`
14404
14417
  ` + chalk3.bold.cyan(" Welcome to MutagenT CLI!") + `
14405
14418
  `);
@@ -14407,6 +14420,10 @@ Examples:
14407
14420
  `);
14408
14421
  }
14409
14422
  let useBrowserAuth = options.browser === true;
14423
+ if (!useBrowserAuth && isNonInteractive) {
14424
+ output.info("Non-interactive environment detected. Using browser authentication.");
14425
+ useBrowserAuth = true;
14426
+ }
14410
14427
  if (!useBrowserAuth && !options.apiKey) {
14411
14428
  const methodAnswer = await inquirer2.prompt([
14412
14429
  {
@@ -17233,7 +17250,7 @@ program.hook("preAction", (thisCommand) => {
17233
17250
  if (globalOpts.endpoint && !process.env.MUTAGENT_ENDPOINT) {
17234
17251
  process.env.MUTAGENT_ENDPOINT = globalOpts.endpoint;
17235
17252
  }
17236
- if (globalOpts.nonInteractive || process.env.CI === "true") {
17253
+ if (globalOpts.nonInteractive || process.env.CI === "true" || !process.stdin.isTTY) {
17237
17254
  process.env.MUTAGENT_NON_INTERACTIVE = "true";
17238
17255
  }
17239
17256
  });
@@ -17249,5 +17266,5 @@ program.addCommand(createWorkspacesCommand());
17249
17266
  program.addCommand(createProvidersCommand());
17250
17267
  program.parse();
17251
17268
 
17252
- //# debugId=85FF8A4C20F0E5A464756E2164756E21
17269
+ //# debugId=13725F651A7F917D64756E2164756E21
17253
17270
  //# sourceMappingURL=cli.js.map