@opencode-ai/util 0.0.0-dev-18636 → 0.0.0-dev-18650
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/bom.d.ts +1 -1
- package/dist/bom.js +0 -1
- package/dist/cross-spawn-spawner.js +3 -3
- package/dist/effect-flock.js +4 -3
- package/dist/process.js +10 -5
- package/package.json +1 -1
package/dist/bom.d.ts
CHANGED
package/dist/bom.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isArrayNonEmpty } from "effect/Array";
|
|
1
2
|
import * as NodeSink from "@effect/platform-node/NodeSink";
|
|
2
3
|
import * as NodeStream from "@effect/platform-node/NodeStream";
|
|
3
4
|
import { Deferred, Effect, Exit, FileSystem, Layer, Path, PlatformError, Predicate, Sink, Stream } from "effect";
|
|
@@ -46,11 +47,10 @@ const flatten = (command) => {
|
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
walk(command);
|
|
49
|
-
if (commands
|
|
50
|
+
if (!isArrayNonEmpty(commands))
|
|
50
51
|
throw new Error("flatten produced empty commands array");
|
|
51
|
-
const [head, ...tail] = commands;
|
|
52
52
|
return {
|
|
53
|
-
commands
|
|
53
|
+
commands,
|
|
54
54
|
opts,
|
|
55
55
|
};
|
|
56
56
|
};
|
package/dist/effect-flock.js
CHANGED
|
@@ -171,9 +171,10 @@ export var EffectFlock;
|
|
|
171
171
|
// acquireRelease: acquire is uninterruptible, release is guaranteed
|
|
172
172
|
const handle = yield* Effect.acquireRelease(acquireHandle(lockfile, key, { staleMs, timeoutMs }), (handle) => release(handle));
|
|
173
173
|
// Heartbeat fiber — scoped, so it's interrupted before release runs
|
|
174
|
-
yield*
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
yield* Effect.suspend(() => {
|
|
175
|
+
const now = new Date();
|
|
176
|
+
return fs.utimes(handle.heartbeatPath, now, now);
|
|
177
|
+
}).pipe(Effect.ignore, Effect.repeat(Schedule.spaced(Math.max(100, Math.floor(staleMs / 3)))), Effect.forkScoped);
|
|
177
178
|
});
|
|
178
179
|
const withLock = Function.dual((args) => Effect.isEffect(args[0]), (body, key, dir) => Effect.scoped(Effect.gen(function* () {
|
|
179
180
|
yield* acquire(key, dir);
|
package/dist/process.js
CHANGED
|
@@ -115,7 +115,7 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
|
115
115
|
const aborted = options?.signal
|
|
116
116
|
? timed.pipe(Effect.raceFirst(waitForAbort(options.signal).pipe(Effect.mapError((cause) => wrapError(description, cause)))))
|
|
117
117
|
: timed;
|
|
118
|
-
return aborted.pipe(Effect.
|
|
118
|
+
return aborted.pipe(Effect.mapError((cause) => wrapError(description, cause)));
|
|
119
119
|
};
|
|
120
120
|
const run = Effect.fn("AppProcess.run")(function* (command, options) {
|
|
121
121
|
if (options?.stdin === undefined)
|
|
@@ -137,9 +137,14 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
|
137
137
|
const okExitCodes = options?.okExitCodes;
|
|
138
138
|
const built = Stream.unwrap(Effect.gen(function* () {
|
|
139
139
|
const handle = yield* spawner.spawn(command);
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
const streams = options?.includeStderr === true
|
|
141
|
+
? yield* handle.stderr.pipe(Stream.broadcastN({ n: 2, capacity: 16 }), Effect.map((copies) => ({
|
|
142
|
+
source: Stream.merge(handle.stdout, copies[0]),
|
|
143
|
+
diagnostics: copies[1],
|
|
144
|
+
})))
|
|
145
|
+
: { source: handle.stdout, diagnostics: handle.stderr };
|
|
146
|
+
const stderrFiber = yield* Effect.forkScoped(collectStream(streams.diagnostics, options?.maxErrorBytes).pipe(Effect.map((x) => x.buffer.toString("utf8"))));
|
|
147
|
+
const lines = streams.source.pipe(Stream.decodeText, Stream.splitLines, Stream.filter((line) => line.length > 0));
|
|
143
148
|
const tail = Stream.unwrap(Effect.gen(function* () {
|
|
144
149
|
const code = yield* handle.exitCode;
|
|
145
150
|
if (okExitCodes && okExitCodes.length > 0 && !okExitCodes.includes(code)) {
|
|
@@ -150,7 +155,7 @@ const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
|
150
155
|
}));
|
|
151
156
|
return Stream.concat(lines, tail);
|
|
152
157
|
}));
|
|
153
|
-
const mapped = built.pipe(Stream.
|
|
158
|
+
const mapped = built.pipe(Stream.mapError((cause) => wrapError(description, cause)));
|
|
154
159
|
if (!options?.signal)
|
|
155
160
|
return mapped;
|
|
156
161
|
const signal = options.signal;
|