kubeagent 0.1.18 → 0.1.20

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/auth.js CHANGED
@@ -129,7 +129,8 @@ export async function loginBrowser(serverUrl, appUrl) {
129
129
  // fallback: just print the URL
130
130
  }
131
131
  console.log(`\nOpening browser for authentication...`);
132
- console.log(`If the browser didn't open, visit:\n ${authUrl}\n`);
132
+ console.log(`If the browser didn't open, visit:\n ${authUrl}`);
133
+ console.log(`Or on a headless/remote machine, run: kubeagent login --device\n`);
133
134
  });
134
135
  // Timeout after 5 minutes
135
136
  const timeoutId = setTimeout(() => {
package/dist/cli.js CHANGED
@@ -102,7 +102,7 @@ program
102
102
  console.log(chalk.dim(" │") + bannerInner + " ".repeat(pad) + chalk.dim("│"));
103
103
  console.log(chalk.dim(" └" + "─".repeat(bannerWidth) + "┘"));
104
104
  console.log(chalk.dim(" Ctrl+C to stop\n"));
105
- const noInteractive = opts.noInteractive === true;
105
+ const noInteractive = opts.interactive === false || !process.stdin.isTTY;
106
106
  if (noInteractive) {
107
107
  console.log(chalk.dim(" Non-interactive mode — approvals auto-denied, questions skipped\n"));
108
108
  }
@@ -390,6 +390,13 @@ program
390
390
  .option("--device", "Use device code flow (for remote/headless machines — no browser required)")
391
391
  .action(async (opts) => {
392
392
  try {
393
+ // Auto-detect headless/SSH environments and switch to device flow
394
+ const isHeadless = process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY;
395
+ const isSsh = !!(process.env.SSH_TTY || process.env.SSH_CONNECTION || process.env.SSH_CLIENT);
396
+ if (!opts.device && (isHeadless || isSsh)) {
397
+ console.log(chalk.yellow("Headless/SSH environment detected — using device code flow."));
398
+ opts.device = true;
399
+ }
393
400
  const auth = opts.device
394
401
  ? await loginDevice(opts.server, opts.appUrl)
395
402
  : await loginBrowser(opts.server, opts.appUrl);
@@ -23,11 +23,20 @@ export async function pickContext() {
23
23
  contexts = await listContexts();
24
24
  }
25
25
  catch {
26
+ if (!process.stdin.isTTY)
27
+ throw new Error("No Kubernetes contexts found and stdin is not interactive");
26
28
  return ask("Kubernetes context to use:");
27
29
  }
28
30
  if (contexts.length === 0) {
31
+ if (!process.stdin.isTTY)
32
+ throw new Error("No Kubernetes contexts found");
29
33
  return ask("Kubernetes context to use:");
30
34
  }
35
+ // Non-interactive: auto-select current context without prompting
36
+ if (!process.stdin.isTTY) {
37
+ const current = contexts.find((c) => c.current);
38
+ return current?.name ?? contexts[0].name;
39
+ }
31
40
  console.log(chalk.bold("\nAvailable Kubernetes contexts:\n"));
32
41
  contexts.forEach((ctx, i) => {
33
42
  const marker = ctx.current ? chalk.green(" (current)") : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubeagent",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "AI-powered Kubernetes management CLI",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",