@scheduler-systems/gal-run 0.0.662 → 0.0.663

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 +114 -32
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -3881,7 +3881,7 @@ var cliVersion, defaultApiUrl, BUILD_CONSTANTS, constants_default;
3881
3881
  var init_constants = __esm({
3882
3882
  "module_6"() {
3883
3883
  "use strict";
3884
- cliVersion = true ? "0.0.662" : "0.0.0-dev";
3884
+ cliVersion = true ? "0.0.663" : "0.0.0-dev";
3885
3885
  defaultApiUrl = true ? "https://api.gal.run" : "http://localhost:3000";
3886
3886
  BUILD_CONSTANTS = Object.freeze([cliVersion, defaultApiUrl]);
3887
3887
  constants_default = BUILD_CONSTANTS;
@@ -4235,6 +4235,74 @@ function buildWindowsNativeCommand(version2, force) {
4235
4235
  ].join("; ");
4236
4236
  return `powershell -NoProfile -ExecutionPolicy Bypass -Command "${command}"`;
4237
4237
  }
4238
+ function quoteShellArg(value) {
4239
+ if (process.platform === "win32") {
4240
+ return `"${value.replace(/(["^%])/g, "^$1")}"`;
4241
+ }
4242
+ return `'${value.replace(/'/g, "'\\''")}'`;
4243
+ }
4244
+ function createShellCommandError(command, exitCode, stdout, stderr) {
4245
+ const message = stderr || stdout || `Command failed with ${exitCode === null ? "no exit code" : `exit code ${exitCode}`}: ${command}`;
4246
+ const error2 = new Error(message);
4247
+ error2.stdout = stdout;
4248
+ error2.stderr = stderr;
4249
+ error2.exitCode = exitCode;
4250
+ return error2;
4251
+ }
4252
+ function getShellCommandErrorOutput(error2) {
4253
+ if (error2 instanceof Error) {
4254
+ const shellError = error2;
4255
+ return [shellError.stderr, shellError.stdout, shellError.message].filter(Boolean).join("\n");
4256
+ }
4257
+ return String(error2);
4258
+ }
4259
+ function runShellCommand(command) {
4260
+ return new Promise((resolve23, reject) => {
4261
+ const child = (0, import_child_process.spawn)(command, [], {
4262
+ shell: true,
4263
+ timeout: 12e4
4264
+ });
4265
+ let stdout = "";
4266
+ let stderr = "";
4267
+ child.stdout?.on("data", (data) => {
4268
+ stdout += data.toString();
4269
+ });
4270
+ child.stderr?.on("data", (data) => {
4271
+ stderr += data.toString();
4272
+ });
4273
+ child.on("close", (code) => {
4274
+ if (code === 0) {
4275
+ resolve23({ stdout, stderr });
4276
+ } else {
4277
+ reject(createShellCommandError(command, code, stdout, stderr));
4278
+ }
4279
+ });
4280
+ child.on("error", (err) => {
4281
+ reject(err);
4282
+ });
4283
+ });
4284
+ }
4285
+ function parsePnpmUnexpectedStoreError(output) {
4286
+ if (!output.includes("ERR_PNPM_UNEXPECTED_STORE") && !output.includes("Unexpected store location")) {
4287
+ return null;
4288
+ }
4289
+ const linkedStoreDir = output.match(/currently linked from the store at "([^"]+)"/)?.[1];
4290
+ const wantedStoreDir = output.match(/pnpm now wants to use the store at "([^"]+)"/)?.[1];
4291
+ return {
4292
+ linkedStoreDir,
4293
+ wantedStoreDir
4294
+ };
4295
+ }
4296
+ function buildPnpmUnexpectedStoreRetryCommand(command, output) {
4297
+ if (/\s--store-dir(?:=|\s)/.test(command)) {
4298
+ return null;
4299
+ }
4300
+ const parsed = parsePnpmUnexpectedStoreError(output);
4301
+ if (!parsed?.linkedStoreDir) {
4302
+ return null;
4303
+ }
4304
+ return `${command} --store-dir ${quoteShellArg(parsed.linkedStoreDir)}`;
4305
+ }
4238
4306
  function buildInstallCommand(method, operation, options = {}) {
4239
4307
  const version2 = normalizeInstallVersion(options.version);
4240
4308
  const registryUrl = options.registryUrl || getRegistryUrl();
@@ -4268,31 +4336,32 @@ function executeInstallCommand(method, operation, options = {}) {
4268
4336
  }
4269
4337
  async function executeInstallCommandAsync(method, operation, options = {}) {
4270
4338
  const command = buildInstallCommand(method, operation, options);
4271
- return new Promise((resolve23, reject) => {
4272
- const child = (0, import_child_process.spawn)(command, [], {
4273
- shell: true,
4274
- timeout: 12e4
4275
- });
4276
- let stdout = "";
4277
- let stderr = "";
4278
- child.stdout?.on("data", (data) => {
4279
- stdout += data.toString();
4280
- });
4281
- child.stderr?.on("data", (data) => {
4282
- stderr += data.toString();
4283
- });
4284
- child.on("close", (code) => {
4285
- if (code === 0) {
4286
- resolve23(stdout);
4287
- } else {
4288
- const error2 = new Error(stderr || `Command failed with exit code ${code}`);
4289
- reject(error2);
4290
- }
4291
- });
4292
- child.on("error", (err) => {
4293
- reject(err);
4294
- });
4295
- });
4339
+ try {
4340
+ const result = await runShellCommand(command);
4341
+ return result.stdout;
4342
+ } catch (error2) {
4343
+ const output = getShellCommandErrorOutput(error2);
4344
+ const retryCommand = method === "pnpm" ? buildPnpmUnexpectedStoreRetryCommand(command, output) : null;
4345
+ if (!retryCommand) {
4346
+ throw error2;
4347
+ }
4348
+ try {
4349
+ const retryResult = await runShellCommand(retryCommand);
4350
+ const note = `Recovered from pnpm global store mismatch by retrying with: ${retryCommand}`;
4351
+ return [note, retryResult.stdout].filter(Boolean).join("\n");
4352
+ } catch (retryError) {
4353
+ const retryOutput = getShellCommandErrorOutput(retryError);
4354
+ throw new Error(
4355
+ [
4356
+ output.trim(),
4357
+ "",
4358
+ "Detected pnpm global store mismatch and retry with the existing store also failed.",
4359
+ `Retry manually with: ${retryCommand}`,
4360
+ retryOutput.trim()
4361
+ ].filter(Boolean).join("\n")
4362
+ );
4363
+ }
4364
+ }
4296
4365
  }
4297
4366
  function describeInstallMethod(method) {
4298
4367
  switch (method) {
@@ -11842,7 +11911,7 @@ function detectEnvironment() {
11842
11911
  return "dev";
11843
11912
  }
11844
11913
  try {
11845
- const version2 = true ? "0.0.662" : void 0;
11914
+ const version2 = true ? "0.0.663" : void 0;
11846
11915
  if (version2 && version2.includes("-local")) {
11847
11916
  return "dev";
11848
11917
  }
@@ -14523,7 +14592,7 @@ function getId() {
14523
14592
  }
14524
14593
  function getCliVersion() {
14525
14594
  try {
14526
- return true ? "0.0.662" : "0.0.0-dev";
14595
+ return true ? "0.0.663" : "0.0.0-dev";
14527
14596
  } catch {
14528
14597
  return "0.0.0-dev";
14529
14598
  }
@@ -187600,7 +187669,7 @@ var init_gal_code_session_collection = __esm({
187600
187669
  });
187601
187670
 
187602
187671
  function resolveCliVersion() {
187603
- return true ? "0.0.662" : "0.0.0-dev";
187672
+ return true ? "0.0.663" : "0.0.0-dev";
187604
187673
  }
187605
187674
  function resolveGalCodeRunnerAsset(version2) {
187606
187675
  const platformMap = {
@@ -187975,7 +188044,7 @@ async function uploadSessionArchive(config, cwd, commandArgs, startedAt, exitCod
187975
188044
  return;
187976
188045
  }
187977
188046
  const endedAt = /* @__PURE__ */ new Date();
187978
- const wrapperVersion = true ? "0.0.662" : "0.0.0-dev";
188047
+ const wrapperVersion = true ? "0.0.663" : "0.0.0-dev";
187979
188048
  const model = childEnv.GAL_CODE_MODEL ?? "glm-vertex/glm-5";
187980
188049
  await uploadGalCodeSessionArchive(
187981
188050
  {
@@ -214688,8 +214757,21 @@ function createUpdateCommand() {
214688
214757
  updateSpinner.fail(source_default.red("Update failed"));
214689
214758
  const msg = error2 instanceof Error ? error2.message : String(error2);
214690
214759
  console.error(source_default.dim(msg));
214691
- console.log(`
214760
+ const pnpmRetryCommand = method === "pnpm" ? buildPnpmUnexpectedStoreRetryCommand(installCommand, msg) : null;
214761
+ const pnpmStoreMismatch = method === "pnpm" ? parsePnpmUnexpectedStoreError(msg) : null;
214762
+ if (pnpmRetryCommand) {
214763
+ console.log(`
214764
+ Retry manually with existing pnpm store: ${source_default.cyan(pnpmRetryCommand)}`);
214765
+ } else if (pnpmStoreMismatch) {
214766
+ console.log(
214767
+ `
214768
+ Detected a pnpm global store mismatch. Use the store path shown in pnpm's "currently linked from the store at" line:
214769
+ ${source_default.cyan(`${installCommand} --store-dir <linked-store-dir>`)}`
214770
+ );
214771
+ } else {
214772
+ console.log(`
214692
214773
  Retry manually with: ${source_default.cyan(installCommand)}`);
214774
+ }
214693
214775
  const isBackground = process.env.GAL_AUTO_UPDATE === "1";
214694
214776
  trackUpdate({
214695
214777
  success: false,
@@ -239643,7 +239725,7 @@ var init_index = __esm({
239643
239725
  }
239644
239726
  });
239645
239727
 
239646
- var cliVersion10 = true ? "0.0.662" : "0.0.0-dev";
239728
+ var cliVersion10 = true ? "0.0.663" : "0.0.0-dev";
239647
239729
  var args = process.argv.slice(2);
239648
239730
  var requestedGlobalHelp = args.length === 1 && (args[0] === "--help" || args[0] === "-h");
239649
239731
  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.662",
3
+ "version": "0.0.663",
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,