opencode-supertask 0.1.32-rc.1 → 0.1.33

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/cli/index.js CHANGED
@@ -21232,6 +21232,26 @@ function isMacLaunchAgentConfigured(expectedPm2Home, expectedRuntime) {
21232
21232
  return false;
21233
21233
  }
21234
21234
  }
21235
+ function bootstrapMacLaunchAgent(domain, path) {
21236
+ const retryDeadline = Date.now() + 2e3;
21237
+ const sleeper = new Int32Array(new SharedArrayBuffer(4));
21238
+ let result = spawnSync2(launchctlBin(), ["bootstrap", domain, path], {
21239
+ encoding: "utf8",
21240
+ timeout: pm2CommandTimeoutMs(),
21241
+ killSignal: "SIGKILL"
21242
+ });
21243
+ while (result.status !== 0 && Date.now() < retryDeadline) {
21244
+ const output = `${result.stdout ?? ""}${result.stderr ?? ""}`;
21245
+ if (result.status !== 5 && !output.includes("Bootstrap failed: 5:")) break;
21246
+ Atomics.wait(sleeper, 0, 0, 100);
21247
+ result = spawnSync2(launchctlBin(), ["bootstrap", domain, path], {
21248
+ encoding: "utf8",
21249
+ timeout: pm2CommandTimeoutMs(),
21250
+ killSignal: "SIGKILL"
21251
+ });
21252
+ }
21253
+ return result;
21254
+ }
21235
21255
  function installMacLaunchAgent(expectedRuntime = currentGatewayRuntime()) {
21236
21256
  if (typeof process.getuid !== "function") {
21237
21257
  throw new Error("[supertask] \u5F53\u524D\u8FD0\u884C\u65F6\u65E0\u6CD5\u83B7\u53D6 macOS \u7528\u6237 ID");
@@ -21299,11 +21319,7 @@ function installMacLaunchAgent(expectedRuntime = currentGatewayRuntime()) {
21299
21319
  timeout: pm2CommandTimeoutMs(),
21300
21320
  killSignal: "SIGKILL"
21301
21321
  });
21302
- const loaded = spawnSync2(launchctlBin(), ["bootstrap", domain, path], {
21303
- encoding: "utf8",
21304
- timeout: pm2CommandTimeoutMs(),
21305
- killSignal: "SIGKILL"
21306
- });
21322
+ const loaded = bootstrapMacLaunchAgent(domain, path);
21307
21323
  const configuredVerifyTimeout = Number(process.env.SUPERTASK_LAUNCH_AGENT_VERIFY_TIMEOUT_MS ?? 2e3);
21308
21324
  const verifyTimeoutMs = Number.isFinite(configuredVerifyTimeout) && configuredVerifyTimeout > 0 ? configuredVerifyTimeout : 2e3;
21309
21325
  const verifyDeadline = Date.now() + verifyTimeoutMs;
@@ -21329,11 +21345,7 @@ function installMacLaunchAgent(expectedRuntime = currentGatewayRuntime()) {
21329
21345
  }
21330
21346
  let rollbackFailure = "";
21331
21347
  if (wasLoaded && previousPlist != null) {
21332
- const restored = spawnSync2(launchctlBin(), ["bootstrap", domain, path], {
21333
- encoding: "utf8",
21334
- timeout: pm2CommandTimeoutMs(),
21335
- killSignal: "SIGKILL"
21336
- });
21348
+ const restored = bootstrapMacLaunchAgent(domain, path);
21337
21349
  if (restored.status !== 0) {
21338
21350
  rollbackFailure = `\uFF1B\u65E7 LaunchAgent \u6062\u590D\u5931\u8D25: ${`${restored.stdout ?? ""}${restored.stderr ?? ""}`.trim() || `\u9000\u51FA\u7801 ${restored.status}`}`;
21339
21351
  }