@akterjs/cli 0.0.0-stage → 0.1.0

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 (108) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +47 -2
  3. package/dist/Argument-D81dqizB.mjs +57 -0
  4. package/dist/Array-B4kuTQeW.mjs +2323 -0
  5. package/dist/Boolean-kILIvmhE.mjs +26 -0
  6. package/dist/ChildProcess-BCIwxPGc.mjs +577 -0
  7. package/dist/CliError-Cf5xqkkj.mjs +633 -0
  8. package/dist/Command-Dzq9KM-h.mjs +5135 -0
  9. package/dist/Config-B6OND9WR.mjs +854 -0
  10. package/dist/Console-BKHUkH6a.mjs +141 -0
  11. package/dist/Data-CeCULr0-.mjs +251 -0
  12. package/dist/Digest-CBd3uv5B.mjs +348 -0
  13. package/dist/Duration-EH9Vy4U6.mjs +791 -0
  14. package/dist/Effect-CKFpqbmw.mjs +12911 -0
  15. package/dist/FileSystem-4pPcEb_i.mjs +1366 -0
  16. package/dist/HttpClientError-BUeMWx70.mjs +303 -0
  17. package/dist/HttpClientResponse-D5ZKICVV.mjs +855 -0
  18. package/dist/Match-CGPLZYrV.mjs +434 -0
  19. package/dist/MutableHashMap-f8nW8AJR.mjs +376 -0
  20. package/dist/MutableHashSet-_HI572Ya.mjs +155 -0
  21. package/dist/MutableRef-D4Qv592C.mjs +107 -0
  22. package/dist/Number-BvkRkfc-.mjs +137 -0
  23. package/dist/Option-DkxSnBhp.mjs +3967 -0
  24. package/dist/Order-C1JC991I.mjs +481 -0
  25. package/dist/Path-Djdv_eF5.mjs +130 -0
  26. package/dist/Queue-CO5UQ6os.mjs +1394 -0
  27. package/dist/Redacted-RkJrG5Me.mjs +160 -0
  28. package/dist/Ref-BIPOxJNH.mjs +267 -0
  29. package/dist/Runtime-BInIAwK3.mjs +297 -0
  30. package/dist/Schema-MiKt5K1v.mjs +10999 -0
  31. package/dist/SecureRandom-B_U4ysO3.mjs +279 -0
  32. package/dist/Semaphore-DOVJ4ZGS.mjs +177 -0
  33. package/dist/Stdio-KylmOBX_.mjs +74 -0
  34. package/dist/Stream-bK9QIETN.mjs +4012 -0
  35. package/dist/String-q5dcsVe4.mjs +351 -0
  36. package/dist/TerminalCapabilities-w_44MAca.mjs +1769 -0
  37. package/dist/WebCrypto-ZI_GNVlw.mjs +33 -0
  38. package/dist/actor-call.service-CGM_vD9u.mjs +1269 -0
  39. package/dist/actor-client.adapter-Coem7gF1.mjs +3691 -0
  40. package/dist/akter-program.config-C4cXx4Fr.mjs +7034 -0
  41. package/dist/akter.cli.mjs +5 -0
  42. package/dist/app-cli.config.mjs +49 -0
  43. package/dist/app-entry.pure.mjs +31 -0
  44. package/dist/archive/akter-archive.schema.mjs +65 -0
  45. package/dist/archive/akter-archive.service.mjs +309 -0
  46. package/dist/archive/archive-cli.config.mjs +45 -0
  47. package/dist/archive/archive-invalid.errors.mjs +5 -0
  48. package/dist/archive/archived-lineage.pure.mjs +13 -0
  49. package/dist/archive/tar.pure.mjs +291 -0
  50. package/dist/archive/zstd.adapter.mjs +46 -0
  51. package/dist/bench/bench-report.pure.mjs +120 -0
  52. package/dist/bench/bench-runner.pure.mjs +89 -0
  53. package/dist/bench/bench.service.mjs +301 -0
  54. package/dist/cli-runtime.layer-BqK2mmVL.mjs +1191 -0
  55. package/dist/cli-runtime.layer.mjs +1 -0
  56. package/dist/cloud-client.adapter-Cy1BjDbG.mjs +3186 -0
  57. package/dist/cloud-client.adapter-DOVMoYAj.mjs +304 -0
  58. package/dist/command/akter-commands.config.mjs +32 -0
  59. package/dist/command/akter-program.config.mjs +1 -0
  60. package/dist/credentials/credentials.service.mjs +226 -0
  61. package/dist/credentials/keychain.adapter.mjs +92 -0
  62. package/dist/credentials/login.config.mjs +251 -0
  63. package/dist/deploy/auth/api-attempt.service.mjs +30 -0
  64. package/dist/deploy/auth/token-refresh.errors.mjs +4 -0
  65. package/dist/deploy/build-bundle.adapter.mjs +133 -0
  66. package/dist/deploy/build-manifest.pure.mjs +44 -0
  67. package/dist/deploy/cloud-client.adapter.mjs +1 -0
  68. package/dist/deploy/cloud-url.pure.mjs +17 -0
  69. package/dist/deploy/deploy-failed.errors.mjs +17 -0
  70. package/dist/deploy/deploy.service.mjs +156 -0
  71. package/dist/deploy/request-failure.pure.mjs +87 -0
  72. package/dist/dev-runner.pure.mjs +30 -0
  73. package/dist/docs/doc-topics.pure.mjs +21 -0
  74. package/dist/docs/docs.config.mjs +1 -0
  75. package/dist/docs.config-_21Xi6HU.mjs +190 -0
  76. package/dist/export/actor-export.service.mjs +267 -0
  77. package/dist/export/export-failed.errors.mjs +4 -0
  78. package/dist/export/export-failure.pure.mjs +18 -0
  79. package/dist/export/ordered-lines.pure.mjs +43 -0
  80. package/dist/export/ranged-download.pure.mjs +66 -0
  81. package/dist/export/snapshot-download.pure.mjs +86 -0
  82. package/dist/history-runner.pure.mjs +186 -0
  83. package/dist/history-since.pure.mjs +17 -0
  84. package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
  85. package/dist/local/environment-cli.config.mjs +90 -0
  86. package/dist/local/environment-runner.pure.mjs +75 -0
  87. package/dist/local/local-cli.config.mjs +159 -0
  88. package/dist/logs/log-follow.config.mjs +21 -0
  89. package/dist/logs/log-follow.service.mjs +87 -0
  90. package/dist/logs/log-lines.pure.mjs +44 -0
  91. package/dist/migrate-runner.pure.mjs +28 -0
  92. package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
  93. package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
  94. package/dist/registry/actor-call.service.mjs +1 -0
  95. package/dist/registry/actor-commands.config.mjs +127 -0
  96. package/dist/registry/actor-refusal.pure.mjs +34 -0
  97. package/dist/registry/approval.service.mjs +80 -0
  98. package/dist/registry/cloud-commands.config.mjs +151 -0
  99. package/dist/registry/cloud-served.pure.mjs +31 -0
  100. package/dist/registry/operation-call.service.mjs +262 -0
  101. package/dist/registry/operation-input.pure.mjs +1 -0
  102. package/dist/registry/operation-output.pure.mjs +91 -0
  103. package/dist/registry/served-command.config.mjs +57 -0
  104. package/dist/runner-exited.errors.mjs +10 -0
  105. package/dist/terminal/cli-exit.errors.mjs +38 -0
  106. package/dist/terminal/cli-failure.pure.mjs +31 -0
  107. package/dist/terminal/confirm.adapter.mjs +27 -0
  108. package/package.json +61 -3
@@ -0,0 +1,1191 @@
1
+ import { On as pipeArguments, Sn as identity, d as fromUndefinedOr, dn as isUndefined, en as isNotNull, nn as isNotUndefined, rn as isNullish, vn as constVoid, x as match } from "./Option-DkxSnBhp.mjs";
2
+ import { $t as suspend, A as ensuring, At as provideContext, B as flatMap, Br as done, C as catch_, Dr as isFailure, F as failSync, Fn as catchDone, Gn as mergeAll, Gt as scoped, Jn as succeed$2, K as forEach, Lr as UnknownError, M as fail$1, Mr as void_, Nr as Done, Nt as raceFirst, Or as isSuccess, Qn as close, Rn as isDoneCause, St as onExit, Vn as effect, W as fnUntraced, Wt as scope, X as forkScoped, Xn as addFinalizer, Xt as succeed, Yn as Scope, Yt as sleep, Zn as addFinalizerExit, ca as get$2, dt as map, en as sync, et as gen, fn as uninterruptible, gn as void_$1, gr as makeUnsafe$1, ht as mapError, i as addFinalizer$1, jr as succeed$1, l as as, ln as try_, lr as doneUnsafe, mr as isDoneUnsafe, n as acquireRelease, nt as ignoreCause, o as andThen, oa as add, p as callback, pn as uninterruptibleMask, pr as isDone, q as forever, qn as provideMerge, rr as makeUnsafe, rt as interrupt, sr as _await, tt as ignore, ur as fail$2, xr as fail, xt as onError, yn as withFiber, zt as runForkWith } from "./Effect-CKFpqbmw.mjs";
3
+ import { F as of } from "./Array-B4kuTQeW.mjs";
4
+ import { a as isFinite, m as toMillis, n as fromInputUnsafe } from "./Duration-EH9Vy4U6.mjs";
5
+ import { A as merge, J as suspend$1, Z as tapError, _ as fromChannel, at as mapDone, bt as runIn, f as fail$3, ft as makeUnsafe$2, gt as interrupt$1, ht as getCurrent, it as fromTransform, l as empty, nt as unwrap$1, tt as transduce, w as isStream, yt as join, z as run } from "./Stream-bK9QIETN.mjs";
6
+ import { c as make$4, d as offerUnsafe, f as poll, g as take, h as sliding, i as endUnsafe } from "./Queue-CO5UQ6os.mjs";
7
+ import { n as layerWebCrypto } from "./SecureRandom-B_U4ysO3.mjs";
8
+ import { c as handleErrnoException, o as layer$7, s as layer$6 } from "./hosted-runtime.layer-Cx3IPsEd.mjs";
9
+ import { a as drain, l as badArgument, o as fromChannel$1, s as isSink, t as FileSystem, u as systemError } from "./FileSystem-4pPcEb_i.mjs";
10
+ import { n as layerWebCrypto$1 } from "./Digest-CBd3uv5B.mjs";
11
+ import { i as value, t as isRedacted } from "./Redacted-RkJrG5Me.mjs";
12
+ import { a as ChildProcessSpawner, c as make$6, i as display, l as makeHandle, n as make$5, o as ExitCode, r as parseFdName, s as ProcessId, t as fdName } from "./ChildProcess-BCIwxPGc.mjs";
13
+ import { t as make$7 } from "./MutableRef-D4Qv592C.mjs";
14
+ import { t as Path } from "./Path-Djdv_eF5.mjs";
15
+ import { n as make$8, t as Stdio } from "./Stdio-KylmOBX_.mjs";
16
+ import { S as Terminal, w as make$9, x as QuitError } from "./TerminalCapabilities-w_44MAca.mjs";
17
+ import { r as layer$8 } from "./cloud-client.adapter-DOVMoYAj.mjs";
18
+ import { AkterArchive } from "./archive/akter-archive.service.mjs";
19
+ import { Bench } from "./bench/bench.service.mjs";
20
+ import { Deployment } from "./deploy/deploy.service.mjs";
21
+ import { ActorExport } from "./export/actor-export.service.mjs";
22
+ import { t as ActorCall } from "./actor-call.service-CGM_vD9u.mjs";
23
+ import { OperationCall } from "./registry/operation-call.service.mjs";
24
+ import * as NodeChildProcess from "node:child_process";
25
+ import { PassThrough, finished } from "node:stream";
26
+ import * as readline from "node:readline";
27
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/rcRef.js
28
+ const TypeId = "~effect/RcRef";
29
+ const stateEmpty = { _tag: "Empty" };
30
+ const stateClosed = { _tag: "Closed" };
31
+ const variance = {
32
+ _A: identity,
33
+ _E: identity
34
+ };
35
+ var RcRefImpl = class {
36
+ [TypeId] = variance;
37
+ pipe() {
38
+ return pipeArguments(this, arguments);
39
+ }
40
+ state = stateEmpty;
41
+ acquire;
42
+ context;
43
+ scope;
44
+ idleTimeToLive;
45
+ constructor(acquire, context, scope, idleTimeToLive) {
46
+ this.acquire = acquire;
47
+ this.context = context;
48
+ this.scope = scope;
49
+ this.idleTimeToLive = idleTimeToLive;
50
+ }
51
+ };
52
+ /** @internal */
53
+ const make$3 = (options) => withFiber((fiber) => {
54
+ const context = fiber.context;
55
+ const scope = get$2(context, Scope);
56
+ const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== void 0 ? fromInputUnsafe(options.idleTimeToLive) : void 0);
57
+ return as(addFinalizerExit(scope, () => {
58
+ const state = ref.state;
59
+ ref.state = stateClosed;
60
+ if (state._tag === "Acquired") return close(state.scope, void_);
61
+ if (state._tag === "Acquiring") return interrupt$1(state.fiber);
62
+ return void_$1;
63
+ }), ref);
64
+ });
65
+ const getState = (self, restore) => {
66
+ switch (self.state._tag) {
67
+ case "Closed": return interrupt;
68
+ case "Acquired": {
69
+ const state = self.state;
70
+ state.refCount++;
71
+ return state.fiber ? as(interrupt$1(state.fiber), state) : succeed(state);
72
+ }
73
+ case "Acquiring": {
74
+ const state = self.state;
75
+ state.awaiters++;
76
+ return awaitAcquiring(self, state, restore);
77
+ }
78
+ case "Empty": {
79
+ const acquiring = {
80
+ _tag: "Acquiring",
81
+ fiber: void 0,
82
+ awaiters: 1,
83
+ acquired: void 0
84
+ };
85
+ self.state = acquiring;
86
+ const scope = makeUnsafe();
87
+ const acquire = provideContext(self.acquire, add(self.context, Scope, scope)).pipe(flatMap((value) => {
88
+ if (self.state !== acquiring) return interrupt;
89
+ const state = {
90
+ _tag: "Acquired",
91
+ value,
92
+ scope,
93
+ fiber: void 0,
94
+ refCount: acquiring.awaiters,
95
+ invalidated: false
96
+ };
97
+ self.state = state;
98
+ acquiring.acquired = state;
99
+ return succeed(state);
100
+ }), onExit((exit) => {
101
+ if (isSuccess(exit)) return void_$1;
102
+ if (self.state === acquiring) self.state = stateEmpty;
103
+ return close(scope, exit);
104
+ }));
105
+ acquiring.fiber = runForkWith(getCurrent().context)(acquire);
106
+ return awaitAcquiring(self, acquiring, restore);
107
+ }
108
+ }
109
+ };
110
+ const awaitAcquiring = (self, acquiring, restore) => onExit(restore(join(acquiring.fiber)), (exit) => {
111
+ const acquired = acquiring.acquired;
112
+ if (acquired !== void 0) return isFailure(exit) ? release(self, acquired) : void_$1;
113
+ if (--acquiring.awaiters > 0 || self.state !== acquiring) return void_$1;
114
+ self.state = stateEmpty;
115
+ return interrupt$1(acquiring.fiber);
116
+ });
117
+ /** @internal */
118
+ const get$1 = (self_) => {
119
+ const self = self_;
120
+ return uninterruptibleMask((restore) => flatMap(scope, (scope) => flatMap(getState(self, restore), (state) => as(addFinalizerExit(scope, () => release(self, state)), state.value))));
121
+ };
122
+ const release = (self, state) => {
123
+ state.refCount--;
124
+ if (state.refCount > 0) return void_$1;
125
+ const idleTimeToLive = self.idleTimeToLive;
126
+ if (idleTimeToLive === void 0 || state.invalidated) {
127
+ if (self.state === state) self.state = stateEmpty;
128
+ return close(state.scope, void_);
129
+ } else if (!isFinite(idleTimeToLive)) return void_$1;
130
+ state.fiber = uninterruptibleMask((restore) => flatMap(restore(sleep(idleTimeToLive)), () => {
131
+ if (self.state === state && state.refCount === 0) {
132
+ self.state = stateEmpty;
133
+ return ignoreCause(close(state.scope, void_), {
134
+ log: "Unhandled",
135
+ message: "Unhandled error in RcRef finalizer"
136
+ });
137
+ }
138
+ return void_$1;
139
+ })).pipe(ensuring(sync(() => {
140
+ state.fiber = void 0;
141
+ })), runForkWith(self.context), runIn(self.scope));
142
+ return void_$1;
143
+ };
144
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/RcRef.js
145
+ /**
146
+ * Creates an `RcRef` from an acquire effect.
147
+ *
148
+ * **When to use**
149
+ *
150
+ * Use to create a lazily acquired, reference-counted resource from an acquire
151
+ * effect.
152
+ *
153
+ * **Details**
154
+ *
155
+ * The resource is acquired lazily on the first `get` and shared by subsequent
156
+ * gets while it remains cached. Each `get` adds a reference to the current
157
+ * `Scope`. When the last reference is released, the resource is closed
158
+ * immediately by default, or after `idleTimeToLive` when that option is
159
+ * provided.
160
+ *
161
+ * **Example** (Creating a reference-counted resource)
162
+ *
163
+ * ```ts import.meta.vitest
164
+ * import { Effect, RcRef } from "effect"
165
+ *
166
+ * const events: Array<string> = []
167
+ *
168
+ * const program = Effect.gen(function*() {
169
+ * const ref = yield* RcRef.make({
170
+ * acquire: Effect.acquireRelease(
171
+ * Effect.succeed("foo"),
172
+ * () => Effect.sync(() => events.push("released foo"))
173
+ * )
174
+ * })
175
+ *
176
+ * // will only acquire the resource once, and release it
177
+ * // when the scope is closed
178
+ * yield* RcRef.get(ref).pipe(
179
+ * Effect.andThen(RcRef.get(ref)),
180
+ * Effect.scoped
181
+ * )
182
+ * })
183
+ *
184
+ * await Effect.runPromise(Effect.scoped(program))
185
+ * events // => ["released foo"]
186
+ * ```
187
+ *
188
+ * @stability stable
189
+ * @category constructors
190
+ * @since 3.5.0
191
+ */
192
+ const make$2 = make$3;
193
+ /**
194
+ * Gets the value from an `RcRef`, acquiring it first if needed.
195
+ *
196
+ * **When to use**
197
+ *
198
+ * Use to borrow the current resource within a `Scope`, acquiring it first if
199
+ * necessary.
200
+ *
201
+ * **Details**
202
+ *
203
+ * The reference count is incremented for the current `Scope`, and a release
204
+ * finalizer is added to that scope. When the current scope closes, the
205
+ * reference is released; the resource is closed when the final reference is
206
+ * released, subject to any configured idle time-to-live.
207
+ *
208
+ * **Example** (Sharing one acquired value)
209
+ *
210
+ * ```ts import.meta.vitest
211
+ * import { Effect, RcRef } from "effect"
212
+ *
213
+ * const events: Array<string> = []
214
+ *
215
+ * const program = Effect.gen(function*() {
216
+ * // Create an RcRef with a resource
217
+ * const ref = yield* RcRef.make({
218
+ * acquire: Effect.acquireRelease(
219
+ * Effect.succeed("shared resource"),
220
+ * (resource) => Effect.sync(() => events.push(`released ${resource}`))
221
+ * )
222
+ * })
223
+ *
224
+ * // Get the value from the RcRef
225
+ * const value1 = yield* RcRef.get(ref)
226
+ * const value2 = yield* RcRef.get(ref)
227
+ *
228
+ * return [value1 === value2, events] as const
229
+ * })
230
+ *
231
+ * await Effect.runPromise(Effect.scoped(program)) // => [true, ["released shared resource"]]
232
+ * ```
233
+ *
234
+ * @stability stable
235
+ * @category combinators
236
+ * @since 3.5.0
237
+ */
238
+ const get = get$1;
239
+ // ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488_9ec8b663d83a20b2301217607fca650e/node_modules/@effect/platform-node-shared/dist/internal/nodeChildProcessSpawner.js
240
+ const buildSpawnOptions = (options, base, platform) => {
241
+ const detached = options.detached ?? platform !== "win32";
242
+ return {
243
+ ...base,
244
+ detached,
245
+ shell: options.shell,
246
+ windowsHide: options.windowsHide ?? !detached
247
+ };
248
+ };
249
+ // ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488_9ec8b663d83a20b2301217607fca650e/node_modules/@effect/platform-node-shared/dist/internal/stream.js
250
+ const destroyStream = (stream, cleanup, onDestroyed) => {
251
+ if (!("closed" in stream)) {
252
+ cleanup();
253
+ onDestroyed?.();
254
+ return;
255
+ }
256
+ const onDone = () => {
257
+ clearImmediate(immediate);
258
+ stream.off("error", onDone);
259
+ stream.off("close", onDone);
260
+ onDestroyed?.();
261
+ };
262
+ const onClosed = () => {
263
+ if (stream.closed) onDone();
264
+ else {
265
+ immediate = setImmediate(onClosed);
266
+ if (!onDestroyed) immediate.unref();
267
+ }
268
+ };
269
+ let immediate = setImmediate(onClosed);
270
+ if (!onDestroyed) immediate.unref();
271
+ stream.once("error", onDone);
272
+ stream.once("close", onDone);
273
+ cleanup();
274
+ if (!stream.closed) stream.destroy();
275
+ };
276
+ // ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488_9ec8b663d83a20b2301217607fca650e/node_modules/@effect/platform-node-shared/dist/NodeSink.js
277
+ /**
278
+ * Creates a `Sink` that writes chunks to a Node writable stream, respecting
279
+ * backpressure and mapping writable errors with `onError`. Unless `endOnDone`
280
+ * is `false`, the writable is ended on completion and destroyed on upstream
281
+ * failure or interruption.
282
+ *
283
+ * @stability unstable
284
+ * @category constructors
285
+ * @since 4.0.0
286
+ */
287
+ const fromWritable = (options) => fromChannel$1(mapDone(fromWritableChannel(options), (_) => [_]));
288
+ /**
289
+ * Creates a `Channel` that pulls chunks from upstream and writes them to a
290
+ * Node writable stream, respecting backpressure. Unless `endOnDone` is
291
+ * `false`, the writable is ended when upstream is done and destroyed on
292
+ * upstream failure or interruption.
293
+ *
294
+ * @stability unstable
295
+ * @category constructors
296
+ * @since 4.0.0
297
+ */
298
+ const fromWritableChannel = (options) => fromTransform((pull) => {
299
+ const writable = options.evaluate();
300
+ const write = pullIntoWritable({
301
+ ...options,
302
+ writable,
303
+ pull
304
+ });
305
+ return succeed(options.endOnDone === false ? write : onError(write, (cause) => isDoneCause(cause) ? void_$1 : releaseWritable(writable)));
306
+ });
307
+ const releaseWritable = (writable) => callback((resume) => {
308
+ const onDestroyed = () => resume(void_$1);
309
+ if (writable.closed) {
310
+ const cleanup = finished(writable, { readable: false }, () => {
311
+ cleanup();
312
+ onDestroyed();
313
+ });
314
+ } else destroyStream(writable, constVoid, onDestroyed);
315
+ });
316
+ /**
317
+ * Writes Effect chunks into a Node writable stream.
318
+ *
319
+ * **When to use**
320
+ *
321
+ * Use to implement custom Node stream adapters that already have an upstream
322
+ * pull and need direct control over a writable stream.
323
+ *
324
+ * **Details**
325
+ *
326
+ * The loop waits for `drain` when needed, fails on writable errors, and ends
327
+ * the writable on upstream completion unless `endOnDone` is `false`.
328
+ *
329
+ * @stability unstable
330
+ * @category converting
331
+ * @since 4.0.0
332
+ */
333
+ const pullIntoWritable = (options) => withFiber((fiber) => {
334
+ const dispatcher = fiber.currentDispatcher;
335
+ const completion = makeUnsafe$1();
336
+ const failure = makeUnsafe$1();
337
+ const onError = (error) => doneUnsafe(failure, failSync(() => options.onError(error)));
338
+ let errorEmitted = false;
339
+ const onStreamError = (error) => {
340
+ errorEmitted = true;
341
+ onError(error);
342
+ };
343
+ options.writable.on("error", onStreamError);
344
+ const cleanup = finished(options.writable, { readable: false }, (error) => {
345
+ if (error) onError(error);
346
+ else doneUnsafe(completion, void_$1);
347
+ });
348
+ return options.pull.pipe(flatMap((chunk) => {
349
+ let i = 0;
350
+ return callback((resume) => {
351
+ let cancelled = false;
352
+ const onFinish = () => dispatcher.scheduleTask(loop, 0);
353
+ const loop = () => {
354
+ options.writable.off("drain", loop);
355
+ options.writable.off("finish", onFinish);
356
+ for (; i < chunk.length;) {
357
+ if (cancelled) return;
358
+ if (!options.writable.write(chunk[i++], options.encoding, (error) => {
359
+ if (!error) return;
360
+ if (options.writable.closed) onError(error);
361
+ else dispatcher.scheduleTask(() => onError(error), 0);
362
+ })) {
363
+ if (!cancelled) {
364
+ options.writable.once("drain", loop);
365
+ options.writable.once("finish", onFinish);
366
+ }
367
+ return;
368
+ }
369
+ }
370
+ if (!cancelled) resume(void_$1);
371
+ };
372
+ loop();
373
+ return sync(() => {
374
+ cancelled = true;
375
+ options.writable.off("drain", loop);
376
+ options.writable.off("finish", onFinish);
377
+ });
378
+ });
379
+ }), forever({ disableYield: true }), options.endOnDone !== false ? catchDone((_) => {
380
+ options.writable.end();
381
+ return andThen(_await(completion), done(_));
382
+ }) : identity, raceFirst(_await(failure)), ensuring(sync(() => {
383
+ cleanup();
384
+ const removeErrorListener = () => {
385
+ options.writable.off("error", onStreamError);
386
+ options.writable.off("error", removeErrorListener);
387
+ options.writable.off("close", removeErrorListener);
388
+ };
389
+ if (options.writable.errored && !options.writable.closed && !errorEmitted) {
390
+ options.writable.once("error", removeErrorListener);
391
+ options.writable.once("close", removeErrorListener);
392
+ } else removeErrorListener();
393
+ })));
394
+ });
395
+ // ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488_9ec8b663d83a20b2301217607fca650e/node_modules/@effect/platform-node-shared/dist/NodeStream.js
396
+ /**
397
+ * Adapters between Node streams and Effect streams, channels, and readables.
398
+ *
399
+ * This module is the stream boundary for Node APIs. It wraps `Readable` and
400
+ * `Duplex` values as Effect `Stream`s and `Channel`s, pipes Effect streams
401
+ * through Node duplex streams, exposes an Effect `Stream` back to Node as a
402
+ * `Readable`, and collects readable payloads into strings, array buffers, or
403
+ * `Uint8Array`s with optional byte limits.
404
+ *
405
+ * @stability unstable
406
+ * @since 4.0.0
407
+ */
408
+ /**
409
+ * Converts a Node readable stream into an Effect `Stream`, reading chunks with
410
+ * independent read sizes and batch limits, mapping stream errors with `onError`,
411
+ * and destroying the readable on completion unless `closeOnDone` is `false`.
412
+ *
413
+ * @stability unstable
414
+ * @category constructors
415
+ * @since 4.0.0
416
+ */
417
+ const fromReadable = (options) => fromChannel(fromReadableChannel(options));
418
+ /**
419
+ * Creates a `Channel` that pulls chunks from a Node readable stream, mapping
420
+ * errors with `onError` and destroying the readable on completion unless
421
+ * `closeOnDone` is `false`.
422
+ *
423
+ * @stability unstable
424
+ * @category constructors
425
+ * @since 4.0.0
426
+ */
427
+ const fromReadableChannel = (options) => fromTransform((_, scope) => readableToPullUnsafe({
428
+ scope,
429
+ readable: options.evaluate(),
430
+ onError: options.onError ?? defaultOnError,
431
+ chunkSize: options.chunkSize,
432
+ readSize: options.readSize,
433
+ closeOnDone: options.closeOnDone
434
+ }));
435
+ const readableToPullUnsafe = (options) => {
436
+ const readable = options.readable;
437
+ const chunkSize = options.chunkSize ?? 4096;
438
+ const closeOnDone = options.closeOnDone ?? true;
439
+ const exit = options.exit ?? make$7(void 0);
440
+ const latch = options.latch ?? makeUnsafe$2(false);
441
+ function onReadable() {
442
+ latch.openUnsafe();
443
+ }
444
+ readable.on("readable", onReadable);
445
+ const cleanup = finished(readable, {
446
+ readable: true,
447
+ writable: false
448
+ }, (error) => {
449
+ exit.current ??= fail(error ? options.onError(error) : Done());
450
+ latch.openUnsafe();
451
+ });
452
+ const pull = suspend(function loop() {
453
+ let item = options.readable.read(options.readSize);
454
+ if (item === null) {
455
+ if (exit.current) return exit.current;
456
+ if (readable.readableEnded) return fail$1(Done());
457
+ latch.closeUnsafe();
458
+ return flatMap(latch.await, loop);
459
+ }
460
+ const chunk = of(item);
461
+ while (chunk.length < chunkSize) {
462
+ item = options.readable.read(options.readSize);
463
+ if (item === null) break;
464
+ chunk.push(item);
465
+ }
466
+ return succeed(chunk);
467
+ });
468
+ return as(addFinalizer(options.scope, sync(() => {
469
+ readable.off("readable", onReadable);
470
+ if (closeOnDone) destroyStream(readable, cleanup);
471
+ else cleanup();
472
+ })), pull);
473
+ };
474
+ const defaultOnError = (error) => new UnknownError(error);
475
+ // ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488_9ec8b663d83a20b2301217607fca650e/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
476
+ const toError = (error) => error instanceof globalThis.Error ? error : new globalThis.Error(String(error));
477
+ const toPlatformError = (method, error, command) => {
478
+ const { commands } = flattenCommand(command);
479
+ const format = globalThis.process.platform === "win32" ? "windows" : "posix";
480
+ const commandStr = commands.map((cmd) => display([cmd.command, ...cmd.args], { format })).join(" | ");
481
+ return handleErrnoException("ChildProcess", method)(error, [commandStr]);
482
+ };
483
+ const unwrap = (value$1) => isRedacted(value$1) ? value(value$1) : value$1;
484
+ const findNulCharacter = (command) => {
485
+ if (command.command.includes("\0")) return "The command contains a NUL character";
486
+ const index = command.args.findIndex((arg) => unwrap(arg).includes("\0"));
487
+ if (index !== -1) return `Argument ${index + 1} contains a NUL character`;
488
+ for (const [name, value] of Object.entries(command.options.env ?? {})) if (value !== void 0 && unwrap(value).includes("\0")) return `The environment variable ${name} contains a NUL character`;
489
+ };
490
+ const processGroupGraceMillis = 1e3;
491
+ const processGroupPollIntervalMillis = 10;
492
+ const handleInputErrors = (writable) => {
493
+ const onError = () => {};
494
+ writable.on("error", onError);
495
+ writable.once("close", () => writable.off("error", onError));
496
+ };
497
+ /** Node has recorded the leader's exit, after which its PID may be reused by an unrelated process. */
498
+ const hasExited = (childProcess) => childProcess.exitCode !== null || childProcess.signalCode !== null;
499
+ /**
500
+ * A non-detached leader shares its parent's process group, so once it has
501
+ * exited there is no group of its own left to signal or poll.
502
+ */
503
+ const ownsProcessGroup = (command, childProcess) => command.options.detached !== false || !hasExited(childProcess);
504
+ /**
505
+ * The process group exists but has no member that can be signalled, such as
506
+ * on macOS when its remaining members are zombies.
507
+ */
508
+ const isUnsignallableProcessGroup = (error) => error?.code === "EPERM";
509
+ /** The leader has not exited, or a member of its process group still exists. */
510
+ const isProcessAlive = (command, childProcess) => {
511
+ if (!hasExited(childProcess)) return true;
512
+ if (globalThis.process.platform === "win32" || !ownsProcessGroup(command, childProcess)) return false;
513
+ try {
514
+ globalThis.process.kill(-childProcess.pid, 0);
515
+ return true;
516
+ } catch (error) {
517
+ return isUnsignallableProcessGroup(error);
518
+ }
519
+ };
520
+ const taskkill = (childProcess, onExit = () => {}) => {
521
+ if (hasExited(childProcess)) {
522
+ onExit(null);
523
+ return;
524
+ }
525
+ NodeChildProcess.execFile("taskkill", [
526
+ "/pid",
527
+ String(childProcess.pid),
528
+ "/T",
529
+ "/F"
530
+ ], { windowsHide: true }, onExit);
531
+ };
532
+ /**
533
+ * Layer that provides the `NodeChildProcessSpawner` implementation.
534
+ *
535
+ * @stability unstable
536
+ * @category layers
537
+ * @since 4.0.0
538
+ */
539
+ const layer$5 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(function* () {
540
+ const fs = yield* FileSystem;
541
+ const path = yield* Path;
542
+ const resolveWorkingDirectory = fnUntraced(function* (options) {
543
+ if (isUndefined(options.cwd)) return void 0;
544
+ yield* fs.access(options.cwd);
545
+ return path.resolve(options.cwd);
546
+ });
547
+ const resolveEnvironment = (options) => {
548
+ if (options.env === void 0) return void 0;
549
+ const env = options.extendEnv === true ? { ...globalThis.process.env } : {};
550
+ for (const [key, value] of Object.entries(options.env)) if (value === void 0) delete env[key];
551
+ else env[key] = unwrap(value);
552
+ return env;
553
+ };
554
+ const inputToStdioOption = (input) => isStream(input) ? "pipe" : input;
555
+ const outputToStdioOption = (input) => isSink(input) ? "pipe" : input;
556
+ const resolveStdinOption = (options) => {
557
+ const defaultConfig = {
558
+ stream: "pipe",
559
+ encoding: "utf-8",
560
+ endOnDone: true
561
+ };
562
+ if (isUndefined(options.stdin)) return defaultConfig;
563
+ if (typeof options.stdin === "string") return {
564
+ ...defaultConfig,
565
+ stream: options.stdin
566
+ };
567
+ if (isStream(options.stdin)) return {
568
+ ...defaultConfig,
569
+ stream: options.stdin
570
+ };
571
+ return {
572
+ stream: options.stdin.stream,
573
+ encoding: options.stdin.encoding ?? defaultConfig.encoding,
574
+ endOnDone: options.stdin.endOnDone ?? defaultConfig.endOnDone
575
+ };
576
+ };
577
+ const resolveOutputOption = (options, streamName) => {
578
+ const option = options[streamName];
579
+ if (isUndefined(option)) return { stream: "pipe" };
580
+ if (typeof option === "string") return { stream: option };
581
+ if (isSink(option)) return { stream: option };
582
+ return { stream: option.stream };
583
+ };
584
+ const resolveAdditionalFds = (options) => {
585
+ if (isUndefined(options.additionalFds)) return [];
586
+ const result = [];
587
+ for (const [name, config] of Object.entries(options.additionalFds)) {
588
+ const fd = parseFdName(name);
589
+ if (isNotUndefined(fd)) result.push({
590
+ fd,
591
+ config
592
+ });
593
+ }
594
+ return result.sort((a, b) => a.fd - b.fd);
595
+ };
596
+ const buildStdioArray = (stdinConfig, stdoutConfig, stderrConfig, additionalFds) => {
597
+ const stdio = [
598
+ inputToStdioOption(stdinConfig.stream),
599
+ outputToStdioOption(stdoutConfig.stream),
600
+ outputToStdioOption(stderrConfig.stream)
601
+ ];
602
+ if (additionalFds.length === 0) return stdio;
603
+ const maxFd = additionalFds.reduce((max, { fd }) => Math.max(max, fd), 2);
604
+ for (let i = 3; i <= maxFd; i++) stdio[i] = "ignore";
605
+ for (const { fd } of additionalFds) stdio[fd] = "pipe";
606
+ return stdio;
607
+ };
608
+ const runInputStream = (stream, sink, inputFailure) => forkScoped(run(tapError(stream, (error) => fail$2(inputFailure, error)), sink));
609
+ const setupAdditionalFds = fnUntraced(function* (command, childProcess, additionalFds, inputFailure) {
610
+ if (additionalFds.length === 0) return {
611
+ getInputFd: () => drain,
612
+ getOutputFd: () => empty
613
+ };
614
+ const inputSinks = /* @__PURE__ */ new Map();
615
+ const outputStreams = /* @__PURE__ */ new Map();
616
+ const setupInput = (fd, nodeStream, stream) => suspend(() => {
617
+ let sink = drain;
618
+ if (nodeStream && "write" in nodeStream) {
619
+ handleInputErrors(nodeStream);
620
+ sink = fromWritable({
621
+ evaluate: () => nodeStream,
622
+ onError: (error) => toPlatformError(`fromWritable(fd${fd})`, toError(error), command)
623
+ });
624
+ }
625
+ if (stream) return map(runInputStream(stream, sink, inputFailure), () => {
626
+ inputSinks.set(fd, sink);
627
+ });
628
+ inputSinks.set(fd, sink);
629
+ return void_$1;
630
+ });
631
+ const setupOutput = (fd, nodeStream, sink) => {
632
+ let stream = empty;
633
+ if (nodeStream && "read" in nodeStream) {
634
+ const passThrough = new PassThrough();
635
+ let error = void 0;
636
+ passThrough.on("error", (cause) => {
637
+ error ??= cause;
638
+ });
639
+ nodeStream.on("error", (cause) => passThrough.destroy(cause));
640
+ nodeStream.pipe(passThrough);
641
+ const onError = (cause) => toPlatformError(`fromReadable(fd${fd})`, toError(cause), command);
642
+ stream = suspend$1(() => error === void 0 ? fromReadable({
643
+ evaluate: () => passThrough,
644
+ onError
645
+ }) : fail$3(onError(error)));
646
+ }
647
+ if (sink) stream = transduce(stream, sink);
648
+ outputStreams.set(fd, stream);
649
+ };
650
+ for (const { config, fd } of additionalFds) {
651
+ const nodeStream = childProcess.stdio[fd];
652
+ switch (config.type) {
653
+ case "input":
654
+ yield* setupInput(fd, nodeStream, config.stream);
655
+ break;
656
+ case "output":
657
+ setupOutput(fd, nodeStream, config.sink);
658
+ break;
659
+ case "duplex":
660
+ if (nodeStream && "allowHalfOpen" in nodeStream) nodeStream.allowHalfOpen = true;
661
+ setupOutput(fd, nodeStream, config.sink);
662
+ yield* setupInput(fd, nodeStream, config.stream);
663
+ }
664
+ }
665
+ return {
666
+ getInputFd: (fd) => inputSinks.get(fd) ?? drain,
667
+ getOutputFd: (fd) => outputStreams.get(fd) ?? empty
668
+ };
669
+ });
670
+ const setupChildStdin = (command, childProcess, config, inputFailure) => suspend(() => {
671
+ let sink = drain;
672
+ if (isNotNull(childProcess.stdin)) {
673
+ handleInputErrors(childProcess.stdin);
674
+ sink = fromWritable({
675
+ evaluate: () => childProcess.stdin,
676
+ onError: (error) => toPlatformError("fromWritable(stdin)", toError(error), command),
677
+ endOnDone: config.endOnDone,
678
+ encoding: config.encoding
679
+ });
680
+ }
681
+ if (isStream(config.stream)) return as(runInputStream(config.stream, sink, inputFailure), sink);
682
+ return succeed(sink);
683
+ });
684
+ const setupChildOutputStreams = (command, childProcess, stdoutConfig, stderrConfig) => {
685
+ let stdout = childProcess.stdout ? (() => {
686
+ const passThrough = new PassThrough();
687
+ childProcess.stdout.on("error", (error) => passThrough.destroy(error));
688
+ childProcess.stdout.pipe(passThrough);
689
+ return fromReadable({
690
+ evaluate: () => passThrough,
691
+ onError: (error) => toPlatformError("fromReadable(stdout)", toError(error), command)
692
+ });
693
+ })() : empty;
694
+ let stderr = childProcess.stderr ? (() => {
695
+ const passThrough = new PassThrough();
696
+ childProcess.stderr.on("error", (error) => passThrough.destroy(error));
697
+ childProcess.stderr.pipe(passThrough);
698
+ return fromReadable({
699
+ evaluate: () => passThrough,
700
+ onError: (error) => toPlatformError("fromReadable(stderr)", toError(error), command)
701
+ });
702
+ })() : empty;
703
+ if (isSink(stdoutConfig.stream)) stdout = transduce(stdout, stdoutConfig.stream);
704
+ if (isSink(stderrConfig.stream)) stderr = transduce(stderr, stderrConfig.stream);
705
+ const all = merge(stdout, stderr);
706
+ return {
707
+ stdout,
708
+ stderr,
709
+ all
710
+ };
711
+ };
712
+ const spawn = (command, spawnOptions) => callback((resume) => {
713
+ const deferred = makeUnsafe$1();
714
+ const handle = NodeChildProcess.spawn(command.command, command.args.map(unwrap), spawnOptions);
715
+ handle.on("error", (error) => {
716
+ if (command.args.some(isRedacted)) Object.assign(error, { spawnargs: [command.command, ...command.args.map((arg) => isRedacted(arg) ? "<redacted>" : arg)] });
717
+ resume(fail$1(toPlatformError("spawn", error, command)));
718
+ });
719
+ handle.on("exit", (...args) => {
720
+ doneUnsafe(deferred, succeed$1(args));
721
+ });
722
+ handle.on("spawn", () => {
723
+ resume(succeed([handle, deferred]));
724
+ });
725
+ return sync(() => {
726
+ handle.kill("SIGTERM");
727
+ });
728
+ });
729
+ const killProcessGroup = (command, childProcess, signal) => {
730
+ if (globalThis.process.platform === "win32") return callback((resume) => {
731
+ taskkill(childProcess, (error) => {
732
+ if (error) resume(fail$1(toPlatformError("kill", toError(error), command)));
733
+ else resume(void_$1);
734
+ });
735
+ });
736
+ return try_({
737
+ try: () => {
738
+ globalThis.process.kill(-childProcess.pid, signal);
739
+ },
740
+ catch: (error) => toPlatformError("kill", toError(error), command)
741
+ });
742
+ };
743
+ const killProcessGroupOnExit = (childProcess, signal) => {
744
+ if (globalThis.process.platform === "win32") {
745
+ taskkill(childProcess);
746
+ return;
747
+ }
748
+ try {
749
+ globalThis.process.kill(-childProcess.pid, signal);
750
+ } catch {}
751
+ };
752
+ const killProcess = (command, childProcess, signal) => suspend(() => {
753
+ if (!childProcess.kill(signal)) {
754
+ const error = new globalThis.Error("Failed to kill child process");
755
+ return fail$1(toPlatformError("kill", error, command));
756
+ }
757
+ return void_$1;
758
+ });
759
+ /** Waits for the leader and its process group, bounded by native time. */
760
+ const awaitProcessExit = (command, childProcess, timeoutMillis) => callback((resume) => {
761
+ const deadline = Date.now() + timeoutMillis;
762
+ let timer;
763
+ const stop = () => {
764
+ clearTimeout(timer);
765
+ childProcess.removeListener("exit", poll);
766
+ };
767
+ const poll = () => {
768
+ clearTimeout(timer);
769
+ if (Date.now() >= deadline || !isProcessAlive(command, childProcess)) {
770
+ stop();
771
+ resume(void_$1);
772
+ return;
773
+ }
774
+ timer = setTimeout(poll, processGroupPollIntervalMillis);
775
+ };
776
+ childProcess.on("exit", poll);
777
+ poll();
778
+ return sync(stop);
779
+ });
780
+ const terminateProcessGroup = fnUntraced(function* (command, childProcess, exitSignal, options) {
781
+ const signalGroup = (signal) => ownsProcessGroup(command, childProcess) ? killProcessGroup(command, childProcess, signal).pipe(catch_((error) => hasExited(childProcess) && isUnsignallableProcessGroup(error.cause) ? void_$1 : killProcess(command, childProcess, signal))) : killProcess(command, childProcess, signal);
782
+ yield* signalGroup(options?.killSignal ?? "SIGTERM");
783
+ if (isUndefined(options?.forceKillAfter)) {
784
+ yield* _await(exitSignal);
785
+ yield* awaitProcessExit(command, childProcess, processGroupGraceMillis);
786
+ } else {
787
+ yield* awaitProcessExit(command, childProcess, toMillis(options.forceKillAfter));
788
+ if (isProcessAlive(command, childProcess)) {
789
+ yield* signalGroup("SIGKILL");
790
+ yield* awaitProcessExit(command, childProcess, processGroupGraceMillis);
791
+ }
792
+ }
793
+ yield* _await(exitSignal);
794
+ });
795
+ /**
796
+ * Get the appropriate source stream from a process handle based on the
797
+ * `from` pipe option.
798
+ */
799
+ const getSourceStream = (handle, from) => {
800
+ const fromOption = from ?? "stdout";
801
+ switch (fromOption) {
802
+ case "stdout": return handle.stdout;
803
+ case "stderr": return handle.stderr;
804
+ case "all": return handle.all;
805
+ default: {
806
+ const fd = parseFdName(fromOption);
807
+ if (isNotUndefined(fd)) return handle.getOutputFd(fd);
808
+ return handle.stdout;
809
+ }
810
+ }
811
+ };
812
+ const spawnCommand = fnUntraced(function* (cmd) {
813
+ switch (cmd._tag) {
814
+ case "StandardCommand": {
815
+ if (cmd.options.shell !== void 0 && cmd.options.shell !== false && cmd.args.length > 0) return yield* fail$1(badArgument({
816
+ module: "ChildProcess",
817
+ method: "spawn",
818
+ description: "The shell option cannot be combined with arguments; pass the whole script as the command"
819
+ }));
820
+ const nulCharacter = findNulCharacter(cmd);
821
+ if (nulCharacter !== void 0) return yield* fail$1(badArgument({
822
+ module: "ChildProcess",
823
+ method: "spawn",
824
+ description: nulCharacter
825
+ }));
826
+ const stdinConfig = resolveStdinOption(cmd.options);
827
+ const stdoutConfig = resolveOutputOption(cmd.options, "stdout");
828
+ const stderrConfig = resolveOutputOption(cmd.options, "stderr");
829
+ const resolvedAdditionalFds = resolveAdditionalFds(cmd.options);
830
+ let isReferenced = true;
831
+ const cwd = yield* resolveWorkingDirectory(cmd.options);
832
+ const env = resolveEnvironment(cmd.options);
833
+ const stdio = buildStdioArray(stdinConfig, stdoutConfig, stderrConfig, resolvedAdditionalFds);
834
+ const [childProcess, exitSignal] = yield* acquireRelease(spawn(cmd, buildSpawnOptions(cmd.options, {
835
+ cwd,
836
+ env,
837
+ stdio
838
+ }, process.platform)), fnUntraced(function* ([childProcess, exitSignal]) {
839
+ if (yield* isDone(exitSignal)) {
840
+ const [code] = yield* _await(exitSignal);
841
+ if (code !== 0 && isNotNull(code)) yield* ignore(terminateProcessGroup(cmd, childProcess, exitSignal, cmd.options));
842
+ else if (isReferenced && process.platform !== "win32" && cmd.options.detached !== false) yield* ignore(terminateProcessGroup(cmd, childProcess, exitSignal, cmd.options));
843
+ return;
844
+ }
845
+ if (!isReferenced) return;
846
+ yield* ignore(terminateProcessGroup(cmd, childProcess, exitSignal, cmd.options));
847
+ }));
848
+ const pid = ProcessId(childProcess.pid);
849
+ if (cmd.options.detached !== false) childProcess.on("exit", (code) => {
850
+ if (code !== 0 && isNotNull(code)) killProcessGroupOnExit(childProcess, cmd.options.killSignal ?? "SIGTERM");
851
+ });
852
+ const reref = sync(() => {
853
+ if (!isReferenced) {
854
+ childProcess.ref();
855
+ isReferenced = true;
856
+ }
857
+ });
858
+ const unref = sync(() => {
859
+ if (isReferenced) {
860
+ childProcess.unref();
861
+ isReferenced = false;
862
+ }
863
+ return reref;
864
+ });
865
+ const inputFailure = makeUnsafe$1();
866
+ const stdin = yield* setupChildStdin(cmd, childProcess, stdinConfig, inputFailure);
867
+ const { all, stderr, stdout } = setupChildOutputStreams(cmd, childProcess, stdoutConfig, stderrConfig);
868
+ const { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds, inputFailure);
869
+ const isRunning = map(isDone(exitSignal), (done) => !done);
870
+ const exitCode = flatMap(raceFirst(_await(exitSignal), _await(inputFailure)), ([code, signal]) => {
871
+ if (isDoneUnsafe(inputFailure)) return _await(inputFailure);
872
+ if (isNotNull(code)) return succeed(ExitCode(code));
873
+ const error = new globalThis.Error(`Process interrupted due to receipt of signal: '${signal}'`);
874
+ return fail$1(toPlatformError("exitCode", error, cmd));
875
+ });
876
+ const kill = (options) => terminateProcessGroup(cmd, childProcess, exitSignal, options);
877
+ return makeHandle({
878
+ pid,
879
+ exitCode,
880
+ isRunning,
881
+ kill,
882
+ stdin,
883
+ stdout,
884
+ stderr,
885
+ all,
886
+ getInputFd,
887
+ getOutputFd,
888
+ unref
889
+ });
890
+ }
891
+ case "PipedCommand": {
892
+ const { commands, pipeOptions } = flattenCommand(cmd);
893
+ const [root, ...pipeline] = commands;
894
+ const handles = [yield* spawnCommand(root)];
895
+ for (let i = 0; i < pipeline.length; i++) {
896
+ const command = pipeline[i];
897
+ const options = pipeOptions[i] ?? {};
898
+ const stdinConfig = resolveStdinOption(command.options);
899
+ const sourceStream = unwrap$1(succeed(getSourceStream(handles[handles.length - 1], options.from)));
900
+ const toOption = options.to ?? "stdin";
901
+ if (toOption === "stdin") handles.push(yield* spawnCommand(make$5(command.command, command.args, {
902
+ ...command.options,
903
+ stdin: {
904
+ ...stdinConfig,
905
+ stream: sourceStream
906
+ }
907
+ })));
908
+ else {
909
+ const fd = parseFdName(toOption);
910
+ if (isNotUndefined(fd)) {
911
+ const fdName$1 = fdName(fd);
912
+ const existingFds = command.options.additionalFds ?? {};
913
+ const existingFd = existingFds[fdName$1];
914
+ const fdConfig = existingFd?.type === "duplex" ? {
915
+ ...existingFd,
916
+ stream: sourceStream
917
+ } : {
918
+ type: "input",
919
+ stream: sourceStream
920
+ };
921
+ handles.push(yield* spawnCommand(make$5(command.command, command.args, {
922
+ ...command.options,
923
+ additionalFds: {
924
+ ...existingFds,
925
+ [fdName$1]: fdConfig
926
+ }
927
+ })));
928
+ } else handles.push(yield* spawnCommand(make$5(command.command, command.args, {
929
+ ...command.options,
930
+ stdin: {
931
+ ...stdinConfig,
932
+ stream: sourceStream
933
+ }
934
+ })));
935
+ }
936
+ }
937
+ const handle = handles[handles.length - 1];
938
+ const kill = (options) => forEach([...handles].reverse(), (handle) => ignore(handle.kill(options)), { discard: true });
939
+ const unref = gen(function* () {
940
+ const rerefs = [];
941
+ for (const handle of handles) rerefs.push(yield* handle.unref);
942
+ return forEach([...rerefs].reverse(), (reref) => reref, { discard: true });
943
+ });
944
+ return makeHandle({
945
+ pid: handle.pid,
946
+ exitCode: handle.exitCode,
947
+ isRunning: handle.isRunning,
948
+ kill,
949
+ stdin: handles[0].stdin,
950
+ stdout: handle.stdout,
951
+ stderr: handle.stderr,
952
+ all: handle.all,
953
+ getInputFd: handle.getInputFd,
954
+ getOutputFd: handle.getOutputFd,
955
+ unref
956
+ });
957
+ }
958
+ }
959
+ });
960
+ return make$6(spawnCommand);
961
+ }));
962
+ /**
963
+ * Flattens a `Command` into an array of `StandardCommand`s along with pipe
964
+ * options for each connection.
965
+ *
966
+ * @stability unstable
967
+ * @category transforming
968
+ * @since 4.0.0
969
+ */
970
+ const flattenCommand = (command) => {
971
+ const commands = [];
972
+ const pipeOptions = [];
973
+ const flatten = (cmd) => {
974
+ switch (cmd._tag) {
975
+ case "StandardCommand":
976
+ commands.push(cmd);
977
+ break;
978
+ case "PipedCommand":
979
+ flatten(cmd.left);
980
+ pipeOptions.push(cmd.options);
981
+ flatten(cmd.right);
982
+ }
983
+ };
984
+ flatten(command);
985
+ if (commands.length === 0) throw new Error("flattenCommand produced empty commands array");
986
+ const [first, ...rest] = commands;
987
+ return {
988
+ commands: [first, ...rest],
989
+ pipeOptions
990
+ };
991
+ };
992
+ // ../../node_modules/.pnpm/@effect+platform-node@4.1.2_effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d795198_40a01a95710c8b08d9f921ebf3a75b9f/node_modules/@effect/platform-node/dist/NodeStdio.js
993
+ /**
994
+ * Node.js `Stdio` layer for the current process.
995
+ *
996
+ * The exported layer reuses the shared Node stdio implementation. It satisfies
997
+ * the platform-independent `Stdio` service by reading command-line arguments
998
+ * from `process.argv`, consuming input from `process.stdin`, and writing output
999
+ * streams to `process.stdout` and `process.stderr`.
1000
+ *
1001
+ * @stability unstable
1002
+ * @since 4.0.0
1003
+ */
1004
+ /**
1005
+ * Provides the `Stdio` service backed by the current process arguments,
1006
+ * stdin, stdout, and stderr streams.
1007
+ *
1008
+ * @stability unstable
1009
+ * @category layers
1010
+ * @since 4.0.0
1011
+ */
1012
+ const layer$3 = /* @__PURE__ */ succeed$2(Stdio, /*#__PURE__*/ make$8({
1013
+ args: /*#__PURE__*/ sync(() => process.argv.slice(2)),
1014
+ stdinIsTerminal: /*#__PURE__*/ sync(() => process.stdin.isTTY === true),
1015
+ stdoutIsTerminal: /*#__PURE__*/ sync(() => process.stdout.isTTY === true),
1016
+ stderrIsTerminal: /*#__PURE__*/ sync(() => process.stderr.isTTY === true),
1017
+ stdout: (options) => fromWritable({
1018
+ evaluate: () => process.stdout,
1019
+ onError: (cause) => systemError({
1020
+ module: "Stdio",
1021
+ method: "stdout",
1022
+ _tag: "Unknown",
1023
+ cause
1024
+ }),
1025
+ endOnDone: options?.endOnDone ?? false
1026
+ }),
1027
+ stderr: (options) => fromWritable({
1028
+ evaluate: () => process.stderr,
1029
+ onError: (cause) => systemError({
1030
+ module: "Stdio",
1031
+ method: "stderr",
1032
+ _tag: "Unknown",
1033
+ cause
1034
+ }),
1035
+ endOnDone: options?.endOnDone ?? false
1036
+ }),
1037
+ stdin: /*#__PURE__*/ fromReadable({
1038
+ evaluate: () => process.stdin,
1039
+ onError: (cause) => systemError({
1040
+ module: "Stdio",
1041
+ method: "stdin",
1042
+ _tag: "Unknown",
1043
+ cause
1044
+ }),
1045
+ closeOnDone: false
1046
+ })
1047
+ }));
1048
+ /**
1049
+ * Provides the default process-backed `Terminal` service, ending key input on
1050
+ * bare Esc, Ctrl+C, or Ctrl+D.
1051
+ *
1052
+ * @stability unstable
1053
+ * @category layers
1054
+ * @since 4.0.0
1055
+ */
1056
+ const layer$2 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShouldQuit) {
1057
+ const stdin = process.stdin;
1058
+ const stdout = process.stdout;
1059
+ const lines = yield* make$4();
1060
+ let inputEnded = stdin.readableEnded;
1061
+ let readlineActive = false;
1062
+ const onStdinEnd = () => {
1063
+ inputEnded = true;
1064
+ if (!readlineActive) endUnsafe(lines);
1065
+ };
1066
+ stdin.once("end", onStdinEnd);
1067
+ yield* addFinalizer$1(() => sync(() => stdin.off("end", onStdinEnd)));
1068
+ const rlRef = yield* make$2({
1069
+ acquire: acquireRelease(sync(() => {
1070
+ const rl = readline.createInterface({
1071
+ input: stdin,
1072
+ escapeCodeTimeout: 50
1073
+ });
1074
+ const onLine = (line) => offerUnsafe(lines, line);
1075
+ const onClose = () => {
1076
+ readlineActive = false;
1077
+ endUnsafe(lines);
1078
+ };
1079
+ readlineActive = true;
1080
+ readline.emitKeypressEvents(stdin, rl);
1081
+ rl.on("line", onLine);
1082
+ rl.once("close", onClose);
1083
+ return {
1084
+ rl,
1085
+ onClose,
1086
+ onLine
1087
+ };
1088
+ }), ({ rl, onClose, onLine }) => sync(() => {
1089
+ readlineActive = false;
1090
+ rl.off("line", onLine);
1091
+ rl.off("close", onClose);
1092
+ rl.close();
1093
+ if (inputEnded) endUnsafe(lines);
1094
+ })),
1095
+ idleTimeToLive: "10 millis"
1096
+ });
1097
+ const setRawMode = (enabled) => sync(() => {
1098
+ if (stdin.isTTY) stdin.setRawMode(enabled);
1099
+ });
1100
+ const rawModeRef = yield* make$2({
1101
+ acquire: acquireRelease(setRawMode(true), () => setRawMode(false)),
1102
+ idleTimeToLive: "10 millis"
1103
+ });
1104
+ const columns = sync(() => stdout.columns ?? 0);
1105
+ const rows = sync(() => stdout.rows ?? 0);
1106
+ const size = gen(function* () {
1107
+ const queue = yield* sliding(1);
1108
+ const onResize = () => offerUnsafe(queue, {
1109
+ columns: stdout.columns ?? 0,
1110
+ rows: stdout.rows ?? 0
1111
+ });
1112
+ yield* addFinalizer$1(() => sync(() => {
1113
+ stdout.off("resize", onResize);
1114
+ endUnsafe(queue);
1115
+ }));
1116
+ stdout.on("resize", onResize);
1117
+ onResize();
1118
+ return queue;
1119
+ });
1120
+ const readInput = gen(function* () {
1121
+ const queue = yield* make$4();
1122
+ const handleKeypress = (s, k) => {
1123
+ const userInput = {
1124
+ input: fromUndefinedOr(s),
1125
+ key: {
1126
+ name: k.name ?? "",
1127
+ ctrl: !!k.ctrl,
1128
+ meta: !!k.meta,
1129
+ shift: !!k.shift
1130
+ }
1131
+ };
1132
+ offerUnsafe(queue, userInput);
1133
+ if (shouldQuit(userInput)) endUnsafe(queue);
1134
+ };
1135
+ const keepAlive = setInterval(() => {}, 2147483647);
1136
+ const handleEnd = () => {
1137
+ clearInterval(keepAlive);
1138
+ endUnsafe(queue);
1139
+ };
1140
+ yield* addFinalizer$1(() => sync(() => {
1141
+ clearInterval(keepAlive);
1142
+ stdin.off("keypress", handleKeypress);
1143
+ stdin.off("end", handleEnd);
1144
+ }));
1145
+ stdin.on("keypress", handleKeypress);
1146
+ if (inputEnded) handleEnd();
1147
+ else {
1148
+ yield* get(rlRef);
1149
+ yield* get(rawModeRef);
1150
+ stdin.once("end", handleEnd);
1151
+ }
1152
+ return queue;
1153
+ });
1154
+ const readLine = suspend(() => poll(lines).pipe(flatMap(match({
1155
+ onNone: () => scoped(andThen(get(rlRef), take(lines))),
1156
+ onSome: succeed
1157
+ })), mapError(() => new QuitError({}))));
1158
+ const display = (prompt) => uninterruptible(callback((resume) => {
1159
+ stdout.write(prompt, (err) => isNullish(err) ? resume(void_$1) : resume(fail$1(badArgument({
1160
+ module: "Terminal",
1161
+ method: "display",
1162
+ description: "Failed to write prompt to stdout",
1163
+ cause: err
1164
+ }))));
1165
+ }));
1166
+ return make$9({
1167
+ columns,
1168
+ rows,
1169
+ size,
1170
+ readInput,
1171
+ readLine,
1172
+ display
1173
+ });
1174
+ }))(defaultShouldQuit));
1175
+ function defaultShouldQuit(input) {
1176
+ const key = input.key;
1177
+ return key.name === "escape" || key.ctrl && (key.name === "c" || key.name === "d");
1178
+ }
1179
+ // ../../node_modules/.pnpm/@effect+platform-node@4.1.2_effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d795198_40a01a95710c8b08d9f921ebf3a75b9f/node_modules/@effect/platform-node/dist/NodeServices.js
1180
+ /**
1181
+ * Provides the default Node implementations for child process spawning,
1182
+ * filesystem, path, stdio, and terminal services.
1183
+ *
1184
+ * @stability unstable
1185
+ * @category layers
1186
+ * @since 4.0.0
1187
+ */
1188
+ const layer = /*#__PURE__*/ provideMerge(layer$5, /*#__PURE__*/ mergeAll(layer$6, layer$7, layer$3, layer$2));
1189
+ // src/cli-runtime.layer.ts
1190
+ const cliRuntime = mergeAll(AkterArchive.layer, Bench.layer, Deployment.layer, ActorExport.layer, ActorCall.layer).pipe(provideMerge(OperationCall.layer), provideMerge(mergeAll(layer, layer$8, layerWebCrypto$1, layerWebCrypto)));
1191
+ export { cliRuntime as t };