@odla-ai/cli 0.11.0 → 0.11.2

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/index.cjs CHANGED
@@ -286,12 +286,16 @@ function handshakeEmail(value, cached) {
286
286
  }
287
287
  return email;
288
288
  }
289
- function approvalBrowser(options) {
289
+ function approvalBrowser(options, host = {}) {
290
290
  if (options.open === true) return { open: true, mode: "forced" };
291
291
  if (options.open === false) return { open: false, reason: "disabled by --no-open" };
292
- if (import_node_process2.default.env.CI) return { open: false, reason: "CI environment" };
293
- const interactive = options.interactive ?? Boolean(import_node_process2.default.stdin.isTTY && import_node_process2.default.stdout.isTTY);
294
- if (!interactive) return { open: false, reason: "non-interactive shell; pass --open to force" };
292
+ const env = host.env ?? import_node_process2.default.env;
293
+ if (env.CI) return { open: false, reason: "CI environment" };
294
+ if (env.SSH_CONNECTION || env.SSH_TTY) return { open: false, reason: "SSH session; pass --open to force" };
295
+ const platform = host.platform ?? import_node_process2.default.platform;
296
+ if (platform !== "darwin" && platform !== "win32" && !env.DISPLAY && !env.WAYLAND_DISPLAY) {
297
+ return { open: false, reason: "no graphical display; pass --open to force" };
298
+ }
295
299
  return { open: true, mode: "auto" };
296
300
  }
297
301
  function handshakeUrl(platformUrl, userCode) {
@@ -388,8 +392,9 @@ async function scopedToken(platform, scope, options, doFetch, out) {
388
392
  onCode: async ({ userCode, expiresIn, verificationUriComplete }) => {
389
393
  const approvalUrl = verificationUriComplete ?? handshakeUrl(audience, userCode);
390
394
  out.log(`Review, then approve scoped request ${userCode} at ${approvalUrl} within ${Math.floor(expiresIn / 60)}m.`);
391
- const shouldOpen = options.open === true || options.open !== false && !import_node_process4.default.env.CI && Boolean(import_node_process4.default.stdin.isTTY && import_node_process4.default.stdout.isTTY);
392
- if (shouldOpen) await (options.openApprovalUrl ?? openUrl)(approvalUrl).catch(() => void 0);
395
+ if (approvalBrowser({ open: options.open }).open) {
396
+ await (options.openApprovalUrl ?? openUrl)(approvalUrl).catch(() => void 0);
397
+ }
393
398
  }
394
399
  });
395
400
  const tokens = cache?.platform === audience ? { ...cache.tokens ?? {} } : {};
@@ -1461,7 +1466,6 @@ async function lifecycleContext(options) {
1461
1466
  token: options.token,
1462
1467
  email: options.email,
1463
1468
  open: options.open,
1464
- interactive: options.interactive,
1465
1469
  openApprovalUrl: options.openConsentUrl
1466
1470
  },
1467
1471
  doFetch,
@@ -1470,7 +1474,7 @@ async function lifecycleContext(options) {
1470
1474
  return { cfg, ctx: { platform: cfg.platformUrl, appId: cfg.app.id, env, token, fetch: doFetch }, out };
1471
1475
  }
1472
1476
  function connectionOptions(options, out) {
1473
- const browser = approvalBrowser({ configPath: "odla.config.mjs", open: options.open, interactive: options.interactive });
1477
+ const browser = approvalBrowser({ open: options.open });
1474
1478
  return {
1475
1479
  out,
1476
1480
  open: browser.open,
@@ -1931,8 +1935,9 @@ Safety:
1931
1935
  Provision caches the approved developer token and service credentials under
1932
1936
  .odla/ with mode 0600, and init adds those paths to .gitignore. Secret push
1933
1937
  preflights Wrangler before any shown-once issuance or destructive rotation.
1934
- Provision opens the approval page automatically in interactive terminals;
1935
- use --open to force browser launch or --no-open to suppress it.
1938
+ Provision opens the approval page in your browser automatically whenever the
1939
+ machine can show one, including agent-driven runs; only CI, SSH, and
1940
+ display-less hosts skip it. Use --open to force or --no-open to suppress.
1936
1941
  A fresh device handshake requires --email <odla-account> or ODLA_USER_EMAIL.
1937
1942
  The email is a non-secret identity hint: never provide a password or session
1938
1943
  token. The matching account must already exist, be signed in, explicitly
@@ -2442,7 +2447,6 @@ ${env}: credentials are already saved; retry "odla-ai secrets push --env ${env}$
2442
2447
  { platform: cfg.platformUrl, appId: cfg.app.id, env, token, fetch: doFetch },
2443
2448
  {
2444
2449
  open: options.open,
2445
- interactive: options.interactive,
2446
2450
  openConsentUrl: options.openApprovalUrl,
2447
2451
  wait: options.calendarPollWait,
2448
2452
  pollTimeoutMs: options.calendarPollTimeoutMs,
@@ -3764,7 +3768,6 @@ async function smoke(options) {
3764
3768
  token: options.token,
3765
3769
  email: options.email,
3766
3770
  open: options.open,
3767
- interactive: options.interactive,
3768
3771
  openApprovalUrl: options.openApprovalUrl
3769
3772
  },
3770
3773
  doFetch,