@opencode-ai/util 0.0.0-dev-18523 → 0.0.0-dev-18532

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.
@@ -261,6 +261,16 @@ const makeCrossSpawnSpawner = Effect.gen(function* () {
261
261
  return Effect.void;
262
262
  return Effect.fail(toPlatformError("kill", new Error("Failed to kill child process"), command));
263
263
  });
264
+ const stop = (command, proc, exit, opts) => {
265
+ const send = (signal) => Effect.catch(killGroup(command, proc, signal), () => killOne(command, proc, signal));
266
+ const attempt = send(opts?.killSignal ?? "SIGTERM").pipe(Effect.andThen(Deferred.await(exit)), Effect.asVoid);
267
+ if (!opts?.forceKillAfter)
268
+ return attempt;
269
+ return Effect.timeoutOrElse(attempt, {
270
+ duration: opts.forceKillAfter,
271
+ orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(exit)), Effect.asVoid),
272
+ });
273
+ };
264
274
  const timeout = (proc, command, opts) => (f) => {
265
275
  const signal = opts?.killSignal ?? "SIGTERM";
266
276
  if (Predicate.isUndefined(opts?.forceKillAfter))
@@ -311,16 +321,7 @@ const makeCrossSpawnSpawner = Effect.gen(function* () {
311
321
  return yield* Effect.ignore(kill(killGroup));
312
322
  return yield* Effect.void;
313
323
  }
314
- const send = (s) => Effect.catch(killGroup(command, proc, s), () => killOne(command, proc, s));
315
- const sig = command.options.killSignal ?? "SIGTERM";
316
- const attempt = send(sig).pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid);
317
- const escalated = command.options.forceKillAfter
318
- ? Effect.timeoutOrElse(attempt, {
319
- duration: command.options.forceKillAfter,
320
- orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
321
- })
322
- : attempt;
323
- return yield* Effect.ignore(escalated);
324
+ return yield* Effect.ignore(stop(command, proc, signal, command.options));
324
325
  }));
325
326
  const fd = yield* setupFds(command, proc, extra);
326
327
  const out = setupOutput(command, proc, sout, serr);
@@ -339,17 +340,7 @@ const makeCrossSpawnSpawner = Effect.gen(function* () {
339
340
  return Effect.succeed(ExitCode(code));
340
341
  return Effect.fail(toPlatformError("exitCode", new Error(`Process interrupted due to receipt of signal: '${signal}'`), command));
341
342
  }),
342
- kill: (opts) => {
343
- const sig = opts?.killSignal ?? "SIGTERM";
344
- const send = (s) => Effect.catch(killGroup(command, proc, s), () => killOne(command, proc, s));
345
- const attempt = send(sig).pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid);
346
- if (!opts?.forceKillAfter)
347
- return attempt;
348
- return Effect.timeoutOrElse(attempt, {
349
- duration: opts.forceKillAfter,
350
- orElse: () => send("SIGKILL").pipe(Effect.andThen(Deferred.await(signal)), Effect.asVoid),
351
- });
352
- },
343
+ kill: (opts) => stop(command, proc, signal, opts),
353
344
  unref: Effect.sync(() => {
354
345
  if (ref) {
355
346
  proc.unref();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode-ai/util",
4
- "version": "0.0.0-dev-18523",
4
+ "version": "0.0.0-dev-18532",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {