@scheduler-systems/gal-run 0.0.305 → 0.0.306

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.
Files changed (2) hide show
  1. package/dist/index.cjs +94 -15
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -3970,7 +3970,7 @@ var cliVersion, defaultApiUrl, BUILD_CONSTANTS, constants_default;
3970
3970
  var init_constants = __esm({
3971
3971
  "src/constants.ts"() {
3972
3972
  "use strict";
3973
- cliVersion = true ? "0.0.305" : "0.0.0-dev";
3973
+ cliVersion = true ? "0.0.306" : "0.0.0-dev";
3974
3974
  defaultApiUrl = true ? "https://api.gal.run" : "http://localhost:3000";
3975
3975
  BUILD_CONSTANTS = Object.freeze([cliVersion, defaultApiUrl]);
3976
3976
  constants_default = BUILD_CONSTANTS;
@@ -4859,7 +4859,7 @@ function detectEnvironment() {
4859
4859
  return "dev";
4860
4860
  }
4861
4861
  try {
4862
- const version = true ? "0.0.305" : void 0;
4862
+ const version = true ? "0.0.306" : void 0;
4863
4863
  if (version && version.includes("-local")) {
4864
4864
  return "dev";
4865
4865
  }
@@ -5228,7 +5228,7 @@ function getId() {
5228
5228
  }
5229
5229
  function getCliVersion() {
5230
5230
  try {
5231
- return true ? "0.0.305" : "0.0.0-dev";
5231
+ return true ? "0.0.306" : "0.0.0-dev";
5232
5232
  } catch {
5233
5233
  return "0.0.0-dev";
5234
5234
  }
@@ -48692,8 +48692,8 @@ async function startInteractiveSession(sandbox) {
48692
48692
  }
48693
48693
  console.log();
48694
48694
  }
48695
- const readline3 = await import("readline");
48696
- const rl = readline3.createInterface({
48695
+ const readline4 = await import("readline");
48696
+ const rl = readline4.createInterface({
48697
48697
  input: process.stdin,
48698
48698
  output: process.stdout,
48699
48699
  prompt: source_default.cyan("sandbox> ")
@@ -54284,7 +54284,41 @@ function showUpdateNotification(currentVersion, latestVersion) {
54284
54284
  function isPreReleaseVersion(version) {
54285
54285
  return /-(preview|pr|rc|dev)/i.test(version);
54286
54286
  }
54287
- function checkForUpdates() {
54287
+ async function promptUpdateInteractive(currentVersion, latestVersion) {
54288
+ return new Promise((resolve8) => {
54289
+ const rl = import_readline5.default.createInterface({
54290
+ input: process.stdin,
54291
+ output: process.stdout
54292
+ });
54293
+ rl.question(
54294
+ `
54295
+ ${source_default.bgYellow.black(" UPDATE AVAILABLE ")} ${source_default.dim(currentVersion)} \u2192 ${source_default.green(latestVersion)}
54296
+ Update now? [Y/n] `,
54297
+ (answer) => {
54298
+ rl.close();
54299
+ const trimmed = answer.trim().toLowerCase();
54300
+ resolve8(trimmed !== "n" && trimmed !== "no");
54301
+ }
54302
+ );
54303
+ });
54304
+ }
54305
+ async function runInlineUpdate() {
54306
+ return new Promise((resolve8, reject) => {
54307
+ const child = (0, import_child_process13.spawn)("gal", ["update"], {
54308
+ stdio: "inherit",
54309
+ env: { ...process.env, GAL_AUTO_UPDATE: "0" }
54310
+ });
54311
+ child.on("close", (code) => {
54312
+ if (code === 0) {
54313
+ resolve8();
54314
+ } else {
54315
+ reject(new Error(`gal update exited with code ${code}`));
54316
+ }
54317
+ });
54318
+ child.on("error", reject);
54319
+ });
54320
+ }
54321
+ async function checkForUpdates() {
54288
54322
  if (isPreReleaseVersion(cliVersion9)) {
54289
54323
  return;
54290
54324
  }
@@ -54292,24 +54326,68 @@ function checkForUpdates() {
54292
54326
  const cache = readUpdateCache();
54293
54327
  const shouldRefresh = !cache || Date.now() - cache.lastCheck > ONE_DAY;
54294
54328
  const now = Date.now();
54295
- const shouldShowNotification = shouldShowUpdateNotification({
54329
+ const isUpdateCommand = process.argv.includes("update") || process.argv[2] === "update";
54330
+ const isCI = process.env.CI === "true";
54331
+ const isAutoUpdateDisabled = process.env.GAL_NO_AUTO_UPDATE === "1";
54332
+ const isInteractiveTTY = process.stdin.isTTY === true;
54333
+ const canShowInteractivePrompt = !isCI && !isAutoUpdateDisabled && !hasJsonFlag && isInteractiveTTY && !isUpdateCommand;
54334
+ const updateAvailable = cache?.latestVersion && shouldShowUpdateNotification({
54296
54335
  cache,
54297
54336
  currentVersion: cliVersion9,
54298
54337
  hasJsonFlag,
54299
54338
  now
54300
54339
  });
54301
- if (shouldShowNotification && cache?.latestVersion) {
54340
+ if (updateAvailable && cache?.latestVersion) {
54341
+ if (canShowInteractivePrompt) {
54342
+ const ONE_HOUR = 60 * 60 * 1e3;
54343
+ const lastInteractiveShown = cache.lastInteractivePromptShown || 0;
54344
+ const interactiveThrottled = now - lastInteractiveShown < ONE_HOUR;
54345
+ if (!interactiveThrottled) {
54346
+ writeUpdateCache({
54347
+ lastCheck: cache.lastCheck,
54348
+ latestVersion: cache.latestVersion,
54349
+ lastNotificationShown: cache.lastNotificationShown,
54350
+ lastInteractivePromptShown: now
54351
+ });
54352
+ const userWantsUpdate = await promptUpdateInteractive(
54353
+ cliVersion9,
54354
+ cache.latestVersion
54355
+ );
54356
+ if (userWantsUpdate) {
54357
+ try {
54358
+ await runInlineUpdate();
54359
+ const args2 = process.argv.slice(2).filter((a) => a !== "update");
54360
+ console.log(source_default.dim("\nRestarting with new version...\n"));
54361
+ if (args2.length > 0) {
54362
+ const child = (0, import_child_process13.spawn)("gal", args2, { stdio: "inherit" });
54363
+ child.on("exit", (code) => process.exit(code || 0));
54364
+ } else {
54365
+ process.exit(0);
54366
+ }
54367
+ await new Promise(() => {
54368
+ });
54369
+ } catch {
54370
+ console.log(
54371
+ source_default.dim(
54372
+ "\n Update failed, continuing with current version...\n"
54373
+ )
54374
+ );
54375
+ }
54376
+ return;
54377
+ }
54378
+ return;
54379
+ }
54380
+ }
54302
54381
  process.on("exit", () => {
54303
54382
  showUpdateNotification(cliVersion9, cache.latestVersion);
54304
54383
  });
54305
54384
  writeUpdateCache({
54306
54385
  lastCheck: cache.lastCheck,
54307
54386
  latestVersion: cache.latestVersion,
54308
- lastNotificationShown: now
54387
+ lastNotificationShown: now,
54388
+ lastInteractivePromptShown: cache.lastInteractivePromptShown
54309
54389
  });
54310
- const isUpdateCommand = process.argv.includes("update");
54311
- const autoUpdateDisabled = process.env.GAL_NO_AUTO_UPDATE === "1" || process.env.CI === "true";
54312
- if (!isUpdateCommand && !autoUpdateDisabled) {
54390
+ if (!isUpdateCommand && !isCI && !isAutoUpdateDisabled) {
54313
54391
  try {
54314
54392
  const lockFile = (0, import_path39.join)((0, import_os26.homedir)(), ".gal", "update.lock");
54315
54393
  if (!(0, import_fs40.existsSync)(lockFile)) {
@@ -54476,13 +54554,14 @@ function refreshOrgMemberships() {
54476
54554
  } catch {
54477
54555
  }
54478
54556
  }
54479
- var import_dotenv, import_https2, import_child_process13, import_fs40, import_path39, import_os26, originalEmit, GLOBAL_TIMEOUT_MS, globalTimeout, cliVersion9, UPDATE_CACHE_DIR, UPDATE_CACHE_FILE, ONE_DAY, REGISTRY_URL2, REGISTRY_HOST, sessionStartTime, isReadOnlyStatusCommand, isMachineMode, exitHooksRan, featureFlags, knownCommands, isKnownCommand, program2, allInternalFlags;
54557
+ var import_dotenv, import_https2, import_readline5, import_child_process13, import_fs40, import_path39, import_os26, originalEmit, GLOBAL_TIMEOUT_MS, globalTimeout, cliVersion9, UPDATE_CACHE_DIR, UPDATE_CACHE_FILE, ONE_DAY, REGISTRY_URL2, REGISTRY_HOST, sessionStartTime, isReadOnlyStatusCommand, isMachineMode, exitHooksRan, featureFlags, knownCommands, isKnownCommand, program2, allInternalFlags;
54480
54558
  var init_index = __esm({
54481
54559
  "src/index.ts"() {
54482
54560
  "use strict";
54483
54561
  init_esm();
54484
54562
  import_dotenv = __toESM(require_main(), 1);
54485
54563
  import_https2 = __toESM(require("https"), 1);
54564
+ import_readline5 = __toESM(require("readline"), 1);
54486
54565
  import_child_process13 = require("child_process");
54487
54566
  import_fs40 = require("fs");
54488
54567
  import_path39 = require("path");
@@ -54536,7 +54615,6 @@ var init_index = __esm({
54536
54615
  return null;
54537
54616
  }
54538
54617
  })();
54539
- checkForUpdates();
54540
54618
  checkPathConflicts();
54541
54619
  refreshOrgMemberships();
54542
54620
  initSentry(cliVersion9);
@@ -54654,6 +54732,7 @@ var init_index = __esm({
54654
54732
  try {
54655
54733
  await checkTermsAcceptance();
54656
54734
  process.argv = process.argv.filter((a) => a !== "--accept-terms");
54735
+ await checkForUpdates();
54657
54736
  program2.parse();
54658
54737
  } catch (error2) {
54659
54738
  captureException(error2 instanceof Error ? error2 : new Error(String(error2)));
@@ -54664,7 +54743,7 @@ var init_index = __esm({
54664
54743
  });
54665
54744
 
54666
54745
  // src/bootstrap.ts
54667
- var cliVersion10 = true ? "0.0.305" : "0.0.0-dev";
54746
+ var cliVersion10 = true ? "0.0.306" : "0.0.0-dev";
54668
54747
  var args = process.argv.slice(2);
54669
54748
  var requestedGlobalHelp = args.length === 1 && (args[0] === "--help" || args[0] === "-h");
54670
54749
  var requestedVersion = args.length === 1 && (args[0] === "--version" || args[0] === "-V");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scheduler-systems/gal-run",
3
- "version": "0.0.305",
3
+ "version": "0.0.306",
4
4
  "description": "GAL CLI - Command-line tool for managing AI agent configurations across your organization",
5
5
  "license": "Elastic-2.0",
6
6
  "private": false,