@proagentstore/cli 0.4.112 → 0.4.113

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.js +63 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2956,7 +2956,6 @@ function createRunnerCommand() {
2956
2956
  var runnerCommand = createRunnerCommand();
2957
2957
 
2958
2958
  // src/commands/up.ts
2959
- import { execFileSync as execFileSync3 } from "child_process";
2960
2959
  import { createRequire as createRequire2 } from "module";
2961
2960
  import { Command as Command8 } from "commander";
2962
2961
  import { hostname as hostname6 } from "os";
@@ -3078,6 +3077,65 @@ async function waitForKey(keys, onInterrupt) {
3078
3077
  });
3079
3078
  }
3080
3079
 
3080
+ // src/commands/up-restart.ts
3081
+ import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "child_process";
3082
+ var UP_LAUNCHER_ENV = "PAGS_UP_LAUNCHER";
3083
+ function upRestartMode(env, platform, canExecve) {
3084
+ if (env[SERVICE_ENV] === "1") return "service";
3085
+ if (env[RESTART_COMMAND_ENV]?.trim()) return "command";
3086
+ if (env[UP_LAUNCHER_ENV] === "1") return "launcher-child";
3087
+ return platform !== "win32" && canExecve ? "exec" : "launcher";
3088
+ }
3089
+ function processRestartDeps() {
3090
+ const execve = process.execve;
3091
+ return {
3092
+ env: process.env,
3093
+ platform: process.platform,
3094
+ execPath: process.execPath,
3095
+ execArgv: process.execArgv,
3096
+ script: process.argv[1],
3097
+ execve: typeof execve === "function" ? execve.bind(process) : void 0,
3098
+ spawn: nodeSpawn,
3099
+ spawnSync: nodeSpawnSync,
3100
+ exit: (code) => process.exit(code),
3101
+ log: () => {
3102
+ }
3103
+ };
3104
+ }
3105
+ function restartPagsUp(args, extraEnv, deps) {
3106
+ const env = { ...deps.env, ...extraEnv };
3107
+ const argv = [...deps.execArgv, deps.script, ...args];
3108
+ const mode = upRestartMode(env, deps.platform, !!deps.execve);
3109
+ if (mode === "service" || mode === "command") {
3110
+ leaveForRestart(mode, { spawn: deps.spawn, exit: deps.exit });
3111
+ return;
3112
+ }
3113
+ if (mode === "launcher-child") {
3114
+ deps.exit(RUNNER_RESTART_EXIT_CODE);
3115
+ return;
3116
+ }
3117
+ if (mode === "exec") {
3118
+ try {
3119
+ deps.execve(deps.execPath, [deps.execPath, ...argv], env);
3120
+ } catch (e) {
3121
+ deps.log(`Restart failed (${e instanceof Error ? e.message : String(e)}) \u2014 the runner is NOT running. Run 'pags up' again.`);
3122
+ deps.exit(1);
3123
+ }
3124
+ return;
3125
+ }
3126
+ for (let first = true; ; first = false) {
3127
+ const r = deps.spawnSync(deps.execPath, argv, { stdio: "inherit", env: { ...env, [UP_LAUNCHER_ENV]: "1", ...first ? {} : { PAGS_NO_PROMPT: "1" } } });
3128
+ if (r.status === RUNNER_RESTART_EXIT_CODE) continue;
3129
+ if (r.error || r.status !== 0) {
3130
+ deps.log(`Restart failed${typeof r.status === "number" ? ` (exit ${r.status})` : ""} \u2014 the runner is NOT running. Run 'pags up' again.`);
3131
+ deps.exit(typeof r.status === "number" && r.status !== 0 ? r.status : 1);
3132
+ return;
3133
+ }
3134
+ deps.exit(0);
3135
+ return;
3136
+ }
3137
+ }
3138
+
3081
3139
  // src/runner-replace.ts
3082
3140
  var REPLACE_EXIT_TIMEOUT_MS = 3e4;
3083
3141
  function describeWork(work) {
@@ -3358,16 +3416,10 @@ var upCommand = new Command8("up").description("Start the browser runner for all
3358
3416
  });
3359
3417
  function restartUp(why, env = {}) {
3360
3418
  writeLine(` ${why}`);
3361
- try {
3362
- if (process.stdin.isTTY) process.stdin.setRawMode(false);
3363
- process.stdin.pause();
3364
- execFileSync3(process.execPath, [process.argv[1], ...restartUpArgs(opts)], { stdio: "inherit", env: { ...process.env, ...env } });
3365
- } catch (e) {
3366
- const status = e.status;
3367
- writeLine(` Restart failed${typeof status === "number" ? ` (exit ${status})` : ""} \u2014 the runner is NOT running. Run 'pags up' again.`);
3368
- process.exit(typeof status === "number" && status !== 0 ? status : 1);
3369
- }
3370
- process.exit(0);
3419
+ if (process.stdin.isTTY) process.stdin.setRawMode(false);
3420
+ process.stdin.pause();
3421
+ restartPagsUp(restartUpArgs(opts), env, { ...processRestartDeps(), log: (line) => writeLine(` ${line}`) });
3422
+ process.exit(1);
3371
3423
  }
3372
3424
  const shutdown = () => {
3373
3425
  child.kill();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proagentstore/cli",
3
- "version": "0.4.112",
3
+ "version": "0.4.113",
4
4
  "description": "CLI for creating, publishing, and running ProAgentStore agents",
5
5
  "license": "MIT",
6
6
  "type": "module",