@graftland/plugin-remote 0.3.1 → 0.3.3
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/Auth.d.ts +2 -2
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js.map +1 -1
- package/dist/{Bootstrap-Dr6sX7el.js → Bootstrap-H9gDsgsC.js} +2 -2
- package/dist/{Contract-DL2mHvaT.js → Contract-DsJtisvL.js} +2 -2
- package/dist/Contract.js +1 -1
- package/dist/{Errors-BMKmu5Y7.js → Errors-DYhsGZcZ.js} +3 -1
- package/dist/Errors.d.ts +7 -0
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js +3 -1
- package/dist/Errors.js.map +1 -1
- package/dist/{FailureGroup-BcH0XOBi.js → FailureGroup-BgT73AaR.js} +14 -4
- package/dist/{Framing-zaYdOJnT.js → Framing-G9eSaeLb.js} +1 -1
- package/dist/{Graft-CVyueNOf.js → Graft-B71CPA2Y.js} +20 -16
- package/dist/{Packages-JNL34JpS.js → Packages-AgoCGotL.js} +23 -26
- package/dist/{Peer-BT7eAGmh.js → Peer-DXeVrGBh.js} +5 -5
- package/dist/{ProcessObservation-DEGrEMfP.js → ProcessObservation-gLgGirYv.js} +1 -1
- package/dist/{ServeLifecycle-CJM0gG5B.js → ServeLifecycle-Bd1FPJ6e.js} +1 -1
- package/dist/Transport.d.ts +2 -2
- package/dist/Transport.d.ts.map +1 -1
- package/dist/Transport.js.map +1 -1
- package/dist/bin.js +48 -47
- package/dist/bin.js.map +1 -1
- package/dist/{childRuntime-An0HsIzl.js → childRuntime-Bm3iSg_N.js} +29 -26
- package/dist/{connectionEnded-DCpFCjMX.js → connectionEnded-BwcxQ7W8.js} +4 -4
- package/dist/{entry-B89sepMU.js → entry-psOpX3Bj.js} +72 -35
- package/dist/host/auth/bearer.d.ts +9 -1
- package/dist/host/auth/bearer.d.ts.map +1 -1
- package/dist/host/auth/bearer.js +1 -1
- package/dist/host/auth/jwt.d.ts +9 -1
- package/dist/host/auth/jwt.d.ts.map +1 -1
- package/dist/host/auth/jwt.js +1 -1
- package/dist/host/auth/mtls.d.ts +8 -1
- package/dist/host/auth/mtls.d.ts.map +1 -1
- package/dist/host/auth/mtls.js +2 -2
- package/dist/host/auth/none.d.ts +3 -1
- package/dist/host/auth/none.js +1 -1
- package/dist/host/command.d.ts +14 -1
- package/dist/host/command.d.ts.map +1 -1
- package/dist/host/command.js +4 -4
- package/dist/host/local.d.ts +2 -1
- package/dist/host/local.d.ts.map +1 -1
- package/dist/host/local.js +3 -3
- package/dist/host/unix.d.ts +6 -1
- package/dist/host/unix.d.ts.map +1 -1
- package/dist/host/unix.js +3 -3
- package/dist/host/websocket.d.ts +10 -1
- package/dist/host/websocket.d.ts.map +1 -1
- package/dist/host/websocket.js +3 -3
- package/dist/host/worker.d.ts +3 -1
- package/dist/host/worker.d.ts.map +1 -1
- package/dist/host/worker.js +4 -5
- package/dist/{importer-Bk6U_sn4.js → importer-Cvf88eAY.js} +5 -8
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/internal/Certificates.js +4 -4
- package/dist/internal/Certificates.js.map +1 -1
- package/dist/internal/FailureGroup.js +3 -2
- package/dist/internal/FailureGroup.js.map +1 -1
- package/dist/internal/assembly.d.ts +2 -1
- package/dist/internal/assembly.js +9 -2
- package/dist/internal/assembly.js.map +1 -1
- package/dist/internal/auth/mtls.js +1 -1
- package/dist/internal/auth/mtls.js.map +1 -1
- package/dist/internal/auth/tokenCredentials.d.ts +2 -1
- package/dist/internal/auth/tokenCredentials.d.ts.map +1 -1
- package/dist/internal/child.js +20 -17
- package/dist/internal/child.js.map +1 -1
- package/dist/internal/childRuntime.js +4 -4
- package/dist/internal/childRuntime.js.map +1 -1
- package/dist/internal/credentials.d.ts +1 -1
- package/dist/internal/directTransport.d.ts +1 -1
- package/dist/internal/entry.d.ts +415 -3
- package/dist/internal/entry.d.ts.map +1 -1
- package/dist/internal/entry.js +1 -1
- package/dist/internal/entry.js.map +1 -1
- package/dist/internal/execution.js +40 -5
- package/dist/internal/execution.js.map +1 -1
- package/dist/internal/host/runner.js +7 -6
- package/dist/internal/host/runner.js.map +1 -1
- package/dist/internal/host.js +5 -5
- package/dist/internal/host.js.map +1 -1
- package/dist/internal/port.js +5 -5
- package/dist/internal/port.js.map +1 -1
- package/dist/internal/release.js +1 -1
- package/dist/internal/release.js.map +1 -1
- package/dist/internal/runner/Connection.d.ts +1 -1
- package/dist/internal/runner/Connection.js +4 -4
- package/dist/internal/runner/Connection.js.map +1 -1
- package/dist/internal/runner/Execution.js +3 -3
- package/dist/internal/runner/Execution.js.map +1 -1
- package/dist/internal/runner/Framing.js +1 -1
- package/dist/internal/runner/Framing.js.map +1 -1
- package/dist/internal/runner/Local.js +1 -1
- package/dist/internal/runner/Local.js.map +1 -1
- package/dist/internal/runner/Lock.js +1 -1
- package/dist/internal/runner/Lock.js.map +1 -1
- package/dist/internal/runner/Packages.d.ts +1 -1
- package/dist/internal/runner/Packages.js +22 -25
- package/dist/internal/runner/Packages.js.map +1 -1
- package/dist/internal/runner/Processes.js +7 -9
- package/dist/internal/runner/Processes.js.map +1 -1
- package/dist/internal/runner/Store.js +3 -3
- package/dist/internal/runner/Store.js.map +1 -1
- package/dist/internal/runner/Supervisor.js +46 -47
- package/dist/internal/runner/Supervisor.js.map +1 -1
- package/dist/internal/runner/accept.js +3 -3
- package/dist/internal/runner/accept.js.map +1 -1
- package/dist/internal/runner/model.js +1 -1
- package/dist/internal/runner/model.js.map +1 -1
- package/dist/internal/serve.js +1 -1
- package/dist/internal/serve.js.map +1 -1
- package/dist/internal/supervisorPlugin.js +1 -1
- package/dist/internal/watchdogMain.js +5 -5
- package/dist/internal/watchdogMain.js.map +1 -1
- package/dist/internal/websocketServer.js +3 -1
- package/dist/internal/websocketServer.js.map +1 -1
- package/dist/internal/workerMain.js +3 -3
- package/dist/{port-DSVUY8Bq.js → port--3x2zJ4D.js} +8 -8
- package/dist/{release-BY4Mlluy.js → release-DfZPuIcK.js} +1 -1
- package/dist/runner/auth/bearer.d.ts +6 -1
- package/dist/runner/auth/bearer.d.ts.map +1 -1
- package/dist/runner/auth/bearer.js +2 -2
- package/dist/runner/auth/jwt.d.ts +29 -2
- package/dist/runner/auth/jwt.d.ts.map +1 -1
- package/dist/runner/auth/jwt.js +4 -4
- package/dist/runner/auth/jwt.js.map +1 -1
- package/dist/runner/auth/mtls.d.ts +6 -1
- package/dist/runner/auth/mtls.d.ts.map +1 -1
- package/dist/runner/auth/mtls.js +3 -3
- package/dist/runner/auth/none.d.ts +7 -1
- package/dist/runner/auth/none.js +1 -1
- package/dist/runner/index.d.ts +310 -1
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +5 -5
- package/dist/runner/stdio.d.ts +6 -1
- package/dist/runner/stdio.d.ts.map +1 -1
- package/dist/runner/stdio.js +3 -3
- package/dist/runner/unix.d.ts +6 -1
- package/dist/runner/unix.d.ts.map +1 -1
- package/dist/runner/unix.js +3 -3
- package/dist/runner/websocket.d.ts +24 -1
- package/dist/runner/websocket.d.ts.map +1 -1
- package/dist/runner/websocket.js +4 -4
- package/dist/{socketChannel-C_ppdSzz.js → socketChannel-CJvL2DiB.js} +2 -2
- package/dist/{supervisorPlugin-CivhM7x5.js → supervisorPlugin-t6Z6PrhD.js} +72 -76
- package/dist/{token-Cc_1CTbE.js → token-CYBNNlhS.js} +1 -1
- package/dist/{tokenCredentials-CI6mMRRd.js → tokenCredentials-CbCuk-Rt.js} +3 -3
- package/dist/{websocketServer-D2Hk7wsA.js → websocketServer-NQhODlEt.js} +5 -3
- package/dist/{workerChannel-cmLc13vm.js → workerChannel-C8hhBJzA.js} +1 -1
- package/package.json +4 -4
- package/src/Auth.ts +9 -2
- package/src/Errors.ts +8 -0
- package/src/Transport.ts +6 -2
- package/src/bin.ts +28 -30
- package/src/index.ts +5 -3
- package/src/internal/Certificates.ts +10 -13
- package/src/internal/FailureGroup.ts +128 -121
- package/src/internal/assembly.ts +19 -10
- package/src/internal/auth/mtls.ts +19 -20
- package/src/internal/child.ts +248 -239
- package/src/internal/childRuntime.ts +81 -80
- package/src/internal/entry.ts +10 -11
- package/src/internal/execution.ts +69 -12
- package/src/internal/host/runner.ts +153 -153
- package/src/internal/host.ts +116 -120
- package/src/internal/port.ts +100 -103
- package/src/internal/release.ts +3 -2
- package/src/internal/runner/Connection.ts +52 -60
- package/src/internal/runner/Execution.ts +163 -164
- package/src/internal/runner/Framing.ts +9 -10
- package/src/internal/runner/Local.ts +26 -27
- package/src/internal/runner/Lock.ts +23 -25
- package/src/internal/runner/Packages.ts +67 -70
- package/src/internal/runner/Processes.ts +89 -92
- package/src/internal/runner/Store.ts +110 -114
- package/src/internal/runner/Supervisor.ts +392 -405
- package/src/internal/runner/accept.ts +76 -84
- package/src/internal/runner/model.ts +20 -21
- package/src/internal/serve.ts +15 -13
- package/src/internal/watchdogMain.ts +16 -11
- package/src/internal/websocketServer.ts +18 -3
- package/src/runner/auth/jwt.ts +10 -6
- package/dist/cleanup-CXLa1Wd9.js +0 -13
package/dist/bin.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { r as __require, t as __commonJSMin } from "./rolldown-runtime-DYf_mQCB.js";
|
|
3
|
-
import { a as provide, f as CleanupError, i as plugin$1, l as make, n as intercept, r as layer, t as forks } from "./Graft-
|
|
4
|
-
import { n as run$1, r as platform, t as load$1 } from "./childRuntime-
|
|
5
|
-
import {
|
|
6
|
-
import { t as Bootstrap } from "./Bootstrap-
|
|
7
|
-
import { t as make$1 } from "./FailureGroup-
|
|
8
|
-
import { a as ExecutionError } from "./Peer-
|
|
3
|
+
import { a as provide, f as CleanupError, i as plugin$1, l as make, n as intercept, r as layer, t as forks } from "./Graft-B71CPA2Y.js";
|
|
4
|
+
import { n as run$1, r as platform, t as load$1 } from "./childRuntime-Bm3iSg_N.js";
|
|
5
|
+
import { u as TransportError } from "./Errors-DYhsGZcZ.js";
|
|
6
|
+
import { t as Bootstrap } from "./Bootstrap-H9gDsgsC.js";
|
|
7
|
+
import { r as cleanupCause, t as make$1 } from "./FailureGroup-BgT73AaR.js";
|
|
8
|
+
import { a as ExecutionError } from "./Peer-DXeVrGBh.js";
|
|
9
9
|
import { n as Notice } from "./WatchdogProtocol-BZmVxrBP.js";
|
|
10
|
-
import { a as isOnlyFailure, c as Env, d as isSnapshot, f as snapshot, i as make$3, l as resolveEnv, m as isSubtreeActive, o as CurrentId, p as findSubtree, r as ModuleResolver, s as Entry, t as make$2, u as isContainer } from "./importer-
|
|
10
|
+
import { a as isOnlyFailure, c as Env, d as isSnapshot, f as snapshot, i as make$3, l as resolveEnv, m as isSubtreeActive, o as CurrentId, p as findSubtree, r as ModuleResolver, s as Entry, t as make$2, u as isContainer } from "./importer-Cvf88eAY.js";
|
|
11
11
|
import { t as ConfigDirectory } from "./ConfigDirectory-BCC6q2R4.js";
|
|
12
|
-
import { n as StartupError, r as make$4, t as ServeLifecycle } from "./ServeLifecycle-
|
|
13
|
-
import { n as cleanupCause } from "./cleanup-CXLa1Wd9.js";
|
|
12
|
+
import { n as StartupError, r as make$4, t as ServeLifecycle } from "./ServeLifecycle-Bd1FPJ6e.js";
|
|
14
13
|
import { Array as Array$1, Cause, Chunk, Console, Context, Data, DateTime, Deferred, Effect, Equal, Exit, Fiber, FiberMap, FileSystem, Hash, HashMap, HashSet, Layer, Logger, MutableList, Option, Order, Path, Predicate, Queue, Random, Record, Redacted, Ref, Result, Schema, Scope, ScopedRef, Semaphore, Stdio, Stream, String as String$1, SubscriptionRef } from "effect";
|
|
15
14
|
import { NodeRuntime, NodeSink } from "@effect/platform-node";
|
|
16
15
|
import { Argument, CliError, Command, Flag } from "effect/cli";
|
|
@@ -133,11 +132,13 @@ Schema.TaggedError()("InvalidIntercept", {
|
|
|
133
132
|
});
|
|
134
133
|
/** Only registered references may be changed by config-file entries. */
|
|
135
134
|
const Registry = Context.Reference("@graftland/loader/Intercept/Registry", { defaultValue: () => HashMap.empty() });
|
|
136
|
-
const resolve =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
const resolve = Effect.fnUntraced(function* (registry, values) {
|
|
136
|
+
return yield* Effect.forEach(Record.toEntries(values), Effect.fnUntraced(function* ([key, input]) {
|
|
137
|
+
const registration = HashMap.get(registry, key);
|
|
138
|
+
if (Option.isNone(registration)) return yield* UnregisteredReference.make({ key });
|
|
139
|
+
return yield* registration.value.resolve(input);
|
|
140
|
+
}));
|
|
141
|
+
});
|
|
141
142
|
// packages/loader/src/internal/validated.ts
|
|
142
143
|
/** Identity evidence belongs only to snapshots produced by the validation boundary. */
|
|
143
144
|
const trees = /* @__PURE__ */ new WeakSet();
|
|
@@ -389,13 +390,13 @@ const prepare$1 = Effect.fnUntraced(function* (entry, registry) {
|
|
|
389
390
|
};
|
|
390
391
|
});
|
|
391
392
|
/** Both owned cleanup phases finish before caller interruption is restored. */
|
|
392
|
-
const disposeEntry =
|
|
393
|
+
const disposeEntry = Effect.fnUntraced(function* (fork, owner) {
|
|
393
394
|
const lifecycle = yield* Effect.exit(fork.dispose);
|
|
394
395
|
const observation = yield* Effect.exit(Scope.close(owner, lifecycle));
|
|
395
396
|
const lifecycleCause = Exit.isFailure(lifecycle) ? Array$1.reduce(lifecycle.cause.reasons, Cause.empty, (acc, reason) => Cause.combine(acc, Cause.isFailReason(reason) ? reason.error.cause : Cause.fromReasons([reason]))) : Cause.empty;
|
|
396
397
|
const cause = Exit.isFailure(observation) ? Cause.combine(lifecycleCause, observation.cause) : lifecycleCause;
|
|
397
398
|
if (cause.reasons.length > 0) return yield* CleanupError.make({ cause });
|
|
398
|
-
})
|
|
399
|
+
}, Effect.uninterruptible);
|
|
399
400
|
/** A disposed fork is gone even when its cleanup failed; the remaining target must still reconcile. */
|
|
400
401
|
const disposeChild = (child) => child.fork.dispose.pipe(Effect.catchCause((cause) => {
|
|
401
402
|
const reported = Array$1.reduce(cause.reasons, Cause.empty, (acc, reason) => Cause.combine(acc, Cause.isFailReason(reason) ? reason.error.cause : Cause.fromReasons([reason])));
|
|
@@ -410,7 +411,7 @@ const definition = make({
|
|
|
410
411
|
name: "group",
|
|
411
412
|
config: GroupEntries,
|
|
412
413
|
inject: [ModuleResolver],
|
|
413
|
-
apply:
|
|
414
|
+
apply: Effect.fnUntraced(function* (entries) {
|
|
414
415
|
const resolver = yield* ModuleResolver;
|
|
415
416
|
const registry = yield* Registry;
|
|
416
417
|
const context = yield* Effect.context();
|
|
@@ -420,7 +421,7 @@ const definition = make({
|
|
|
420
421
|
const requests = yield* Queue.bounded(1);
|
|
421
422
|
yield* Effect.addFinalizer(() => Queue.end(requests).pipe(Effect.andThen(Queue.collect(requests)), Effect.flatMap((queued) => Effect.forEach(queued, (request) => Deferred.done(request.reply, Exit.interrupt()), { discard: true }))));
|
|
422
423
|
const submit = (request) => Queue.offer(requests, request).pipe(Effect.flatMap((accepted) => accepted ? Deferred.await(request.reply) : Effect.interrupt));
|
|
423
|
-
const refresh = (id, identity, source)
|
|
424
|
+
const refresh = Effect.fnUntraced(function* (id, identity, source) {
|
|
424
425
|
const current = yield* Ref.get(children);
|
|
425
426
|
const child = HashMap.get(current, id);
|
|
426
427
|
if (Option.isNone(child) || child.value.identity !== identity) return;
|
|
@@ -447,7 +448,7 @@ const definition = make({
|
|
|
447
448
|
const lifecycle = make({
|
|
448
449
|
name: entry.name,
|
|
449
450
|
config: Entry,
|
|
450
|
-
apply:
|
|
451
|
+
apply: Effect.fnUntraced(function* (entry) {
|
|
451
452
|
yield* Ref.set(gatedFork, Option.none());
|
|
452
453
|
yield* ScopedRef.set(observations, Effect.scope);
|
|
453
454
|
const observationScope = yield* ScopedRef.get(observations);
|
|
@@ -457,12 +458,12 @@ const definition = make({
|
|
|
457
458
|
const fork = yield* plugin$1(target, input, { intercept: [...intercept$1, intercept(CurrentId, () => Option.some(entry.id))] });
|
|
458
459
|
yield* Ref.set(targetFork, Option.some(fork));
|
|
459
460
|
const update = yield* updateTarget(fork, input, entry.group === true || target !== plugin, refreshEntry);
|
|
460
|
-
return
|
|
461
|
+
return Effect.fnUntraced(function* (next) {
|
|
461
462
|
const nextPatches = yield* patchesOf(next);
|
|
462
463
|
if (!equalConfig(nextPatches, patches)) return false;
|
|
463
464
|
const input = yield* inputOf(next);
|
|
464
465
|
return yield* update(input);
|
|
465
|
-
}
|
|
466
|
+
}, Effect.catchCause((cause) => {
|
|
466
467
|
const unhandled = Cause.fromReasons(Array$1.filter(cause.reasons, (reason) => !Cause.isFailReason(reason)));
|
|
467
468
|
return Effect.logWarning("Preparing an entry update failed", cause).pipe(Effect.andThen(unhandled.reasons.length > 0 ? Effect.failCause(unhandled) : Effect.succeed(false)));
|
|
468
469
|
}));
|
|
@@ -506,7 +507,7 @@ const definition = make({
|
|
|
506
507
|
discard: true
|
|
507
508
|
});
|
|
508
509
|
for (const [id] of removed) current = HashMap.remove(current, id);
|
|
509
|
-
const jobs = yield* Effect.forEach(wanted,
|
|
510
|
+
const jobs = yield* Effect.forEach(wanted, Effect.fnUntraced(function* (description) {
|
|
510
511
|
const entry = withEpoch({ ...description }, epoch);
|
|
511
512
|
const existing = HashMap.get(current, entry.id);
|
|
512
513
|
if (Option.isNone(existing)) {
|
|
@@ -532,12 +533,12 @@ const definition = make({
|
|
|
532
533
|
}) };
|
|
533
534
|
}));
|
|
534
535
|
yield* Ref.set(children, current);
|
|
535
|
-
yield* Effect.
|
|
536
|
+
yield* Effect.forEach(jobs, (job) => job.run, {
|
|
536
537
|
concurrency: "unbounded",
|
|
537
538
|
discard: true
|
|
538
539
|
});
|
|
539
540
|
});
|
|
540
|
-
const applyRequest =
|
|
541
|
+
const applyRequest = Effect.fnUntraced(function* (request) {
|
|
541
542
|
if (request._tag === "Reconcile") return yield* reconcile(request.entries);
|
|
542
543
|
const current = yield* Ref.get(children);
|
|
543
544
|
const child = HashMap.get(current, request.id);
|
|
@@ -547,7 +548,7 @@ const definition = make({
|
|
|
547
548
|
yield* child.value.fork.update(child.value.entry);
|
|
548
549
|
});
|
|
549
550
|
yield* Stream.fromQueue(requests).pipe(Stream.runForEach((request) => (request._tag === "Refresh" ? track(pending, applyRequest(request)) : applyRequest(request)).pipe(Effect.provideContext(context), Effect.onExit((exit) => Deferred.done(request.reply, exit)), Effect.catchCauseIf((cause) => !Cause.hasInterruptsOnly(cause), (cause) => Effect.logError("Reconciling a group request failed", cause)))), Effect.forkScoped);
|
|
550
|
-
const update =
|
|
551
|
+
const update = Effect.fnUntraced(function* (entries) {
|
|
551
552
|
const reply = yield* Deferred.make();
|
|
552
553
|
yield* submit({
|
|
553
554
|
_tag: "Reconcile",
|
|
@@ -7217,7 +7218,7 @@ const start = Effect.fnUntraced(function* (store) {
|
|
|
7217
7218
|
yield* SubscriptionRef.changes(state).pipe(Stream.map((current) => current.version), Stream.changes, Stream.buffer({
|
|
7218
7219
|
capacity: 1,
|
|
7219
7220
|
strategy: "sliding"
|
|
7220
|
-
}), Stream.runForEach(
|
|
7221
|
+
}), Stream.runForEach(Effect.fnUntraced(function* () {
|
|
7221
7222
|
const target = yield* SubscriptionRef.get(state);
|
|
7222
7223
|
if (target.version === target.reconciled) return;
|
|
7223
7224
|
yield* root.update(withEpoch(copyGroup(target.entries), target.epoch));
|
|
@@ -7225,15 +7226,15 @@ const start = Effect.fnUntraced(function* (store) {
|
|
|
7225
7226
|
...current,
|
|
7226
7227
|
reconciled: target.version
|
|
7227
7228
|
}));
|
|
7228
|
-
}
|
|
7229
|
+
}, Effect.catchCause((cause) => Effect.logError("Reconciling loader entries failed", cause)))), Effect.forkScoped);
|
|
7229
7230
|
const edits = yield* Queue.bounded(1);
|
|
7230
7231
|
yield* Stream.fromQueue(edits).pipe(Stream.runForEach(({ op, reply }) => Semaphore.withPermits(lock, 1)(Effect.flatMap(Effect.suspend(() => store.apply(op)), publish)).pipe(Effect.onExit((exit) => Deferred.done(reply, exit)), Effect.catchCause((cause) => Effect.logError("Applying a loader edit failed", cause)))), Effect.forkScoped);
|
|
7231
|
-
yield* Effect.addFinalizer(
|
|
7232
|
+
yield* Effect.addFinalizer(Effect.fnUntraced(function* () {
|
|
7232
7233
|
yield* Queue.end(edits);
|
|
7233
7234
|
const pending = yield* Queue.collect(edits);
|
|
7234
7235
|
yield* Effect.forEach(pending, ({ reply }) => Deferred.done(reply, Exit.fail(LoaderClosed.make())), { discard: true });
|
|
7235
7236
|
}));
|
|
7236
|
-
const edit =
|
|
7237
|
+
const edit = Effect.fnUntraced(function* (op) {
|
|
7237
7238
|
const captured = Op.$match(op, {
|
|
7238
7239
|
Create: (create) => Op.Create({
|
|
7239
7240
|
...create,
|
|
@@ -7256,7 +7257,7 @@ const start = Effect.fnUntraced(function* (store) {
|
|
|
7256
7257
|
onNone: () => Effect.void,
|
|
7257
7258
|
onSome: publish
|
|
7258
7259
|
}))).pipe(Effect.catchCause((cause) => Effect.logError("Refreshing loader entries failed", cause)))), Effect.catchCause((cause) => Effect.logError("Loader change notifications stopped", cause)), Effect.forkScoped);
|
|
7259
|
-
const ready = Stream.mergeAll([Stream.as(SubscriptionRef.changes(state), void 0), Stream.as(SubscriptionRef.changes(pending), void 0)], { concurrency: "unbounded" }).pipe(Stream.filterEffect(
|
|
7260
|
+
const ready = Stream.mergeAll([Stream.as(SubscriptionRef.changes(state), void 0), Stream.as(SubscriptionRef.changes(pending), void 0)], { concurrency: "unbounded" }).pipe(Stream.filterEffect(Effect.fnUntraced(function* () {
|
|
7260
7261
|
const before = yield* SubscriptionRef.get(state);
|
|
7261
7262
|
if (before.version !== before.reconciled) return false;
|
|
7262
7263
|
if ((yield* SubscriptionRef.get(pending)) > 0) return false;
|
|
@@ -7277,7 +7278,7 @@ const start = Effect.fnUntraced(function* (store) {
|
|
|
7277
7278
|
epoch: nextEpoch()
|
|
7278
7279
|
}))),
|
|
7279
7280
|
ready,
|
|
7280
|
-
create:
|
|
7281
|
+
create: Effect.fnUntraced(function* (entry, options) {
|
|
7281
7282
|
const id = entry.id ?? (yield* newId);
|
|
7282
7283
|
yield* edit(Op.Create({
|
|
7283
7284
|
entry: {
|
|
@@ -7299,7 +7300,7 @@ const start = Effect.fnUntraced(function* (store) {
|
|
|
7299
7300
|
make({
|
|
7300
7301
|
name: "loader",
|
|
7301
7302
|
config: Schema.Array(Entry),
|
|
7302
|
-
apply:
|
|
7303
|
+
apply: Effect.fnUntraced(function* (entries) {
|
|
7303
7304
|
const initial = snapshot(entries);
|
|
7304
7305
|
const current = yield* Ref.make(initial);
|
|
7305
7306
|
yield* start({
|
|
@@ -7315,7 +7316,7 @@ make({
|
|
|
7315
7316
|
const fileTarget = Effect.fnUntraced(function* (entry) {
|
|
7316
7317
|
const fs = yield* FileSystem.FileSystem;
|
|
7317
7318
|
const path = yield* Path.Path;
|
|
7318
|
-
return yield* fs.realPath(entry).pipe(Effect.catchCauseIf((cause) => isOnlyFailure(cause, (error) => error.reason._tag === "NotFound"),
|
|
7319
|
+
return yield* fs.realPath(entry).pipe(Effect.catchCauseIf((cause) => isOnlyFailure(cause, (error) => error.reason._tag === "NotFound"), Effect.fnUntraced(function* (cause) {
|
|
7319
7320
|
const info = yield* fs.lstat(entry).pipe(Effect.asSome, Effect.catchCauseIf((cause) => isOnlyFailure(cause, (error) => error.reason._tag === "NotFound"), () => Effect.succeedNone));
|
|
7320
7321
|
if (Option.isSome(info)) return yield* Effect.failCause(cause);
|
|
7321
7322
|
const parent = yield* fs.realPath(path.dirname(entry));
|
|
@@ -7333,7 +7334,7 @@ const atomicWrite = Effect.fnUntraced(function* (target, text, expected, verifyT
|
|
|
7333
7334
|
yield* Effect.acquireUseRelease(Scope.make(), (scope) => Effect.acquireUseRelease(fs.open(temporary, {
|
|
7334
7335
|
flag: "wx",
|
|
7335
7336
|
mode: 384
|
|
7336
|
-
}).pipe(Effect.provideService(Scope.Scope, scope)),
|
|
7337
|
+
}).pipe(Effect.provideService(Scope.Scope, scope)), Effect.fnUntraced(function* (file) {
|
|
7337
7338
|
yield* file.writeAll(new TextEncoder().encode(text)).pipe(Effect.uninterruptible);
|
|
7338
7339
|
if (Option.isSome(previous)) {
|
|
7339
7340
|
const current = yield* file.stat;
|
|
@@ -7436,7 +7437,7 @@ const normalizeGroups = (document) => {
|
|
|
7436
7437
|
* previous version (same name and config) keeps that entry's id, so editing
|
|
7437
7438
|
* an anonymous entry by hand does not restart it under a new identity.
|
|
7438
7439
|
*/
|
|
7439
|
-
const planIds = (document, logical, previous)
|
|
7440
|
+
const planIds = Effect.fnUntraced(function* (document, logical, previous) {
|
|
7440
7441
|
let used = HashSet.empty();
|
|
7441
7442
|
const collectIds = (node) => {
|
|
7442
7443
|
if (!(0, import_dist.isSeq)(node)) return;
|
|
@@ -7461,9 +7462,9 @@ const planIds = (document, logical, previous) => Effect.gen(function* () {
|
|
|
7461
7462
|
const pools = HashMap.map(buckets, Chunk.toReadonlyArray);
|
|
7462
7463
|
let cursors = HashMap.empty();
|
|
7463
7464
|
let assignments = Chunk.empty();
|
|
7464
|
-
const visit = (node, logical, path = [])
|
|
7465
|
+
const visit = Effect.fnUntraced(function* (node, logical, path = []) {
|
|
7465
7466
|
if (!(0, import_dist.isSeq)(node)) return logical === void 0 ? [] : logical;
|
|
7466
|
-
return yield* Effect.forEach(node.items,
|
|
7467
|
+
return yield* Effect.forEach(node.items, Effect.fnUntraced(function* (item, index) {
|
|
7467
7468
|
const raw = Array$1.isArray(logical) ? logical[index] : void 0;
|
|
7468
7469
|
if (!(0, import_dist.isMap)(item)) return raw;
|
|
7469
7470
|
const map = item;
|
|
@@ -7659,7 +7660,7 @@ const Include = make({
|
|
|
7659
7660
|
name: "include",
|
|
7660
7661
|
config: Config$1,
|
|
7661
7662
|
inject: [FileSystem.FileSystem, Path.Path],
|
|
7662
|
-
apply: ({ path: file, watch, initial })
|
|
7663
|
+
apply: Effect.fnUntraced(function* ({ path: file, watch, initial }) {
|
|
7663
7664
|
const fs = yield* FileSystem.FileSystem;
|
|
7664
7665
|
const path = yield* Path.Path;
|
|
7665
7666
|
const directory = yield* ConfigDirectory;
|
|
@@ -7695,12 +7696,12 @@ const Include = make({
|
|
|
7695
7696
|
onNone: () => [],
|
|
7696
7697
|
onSome: (value) => value.entries
|
|
7697
7698
|
});
|
|
7698
|
-
const fresh =
|
|
7699
|
+
const fresh = Effect.fnUntraced(function* (previous) {
|
|
7699
7700
|
const target = yield* resolveTarget;
|
|
7700
7701
|
const disk = yield* fs.readFileString(target);
|
|
7701
7702
|
return Option.isSome(previous) && target === previous.value.target && disk === previous.value.text ? previous.value : yield* read(target, disk, entriesOf(previous)).pipe(Effect.mapError((cause) => Schema.is(StoreError)(cause) || Schema.is(WriteConflict)(cause) ? cause : StoreError.make({ cause })));
|
|
7702
7703
|
});
|
|
7703
|
-
const applyOp =
|
|
7704
|
+
const applyOp = Effect.fnUntraced(function* (op) {
|
|
7704
7705
|
const previous = yield* Ref.get(synced);
|
|
7705
7706
|
return yield* retryWrite(Effect.gen(function* () {
|
|
7706
7707
|
const current = yield* fresh(previous);
|
|
@@ -7768,7 +7769,7 @@ const ready = make({
|
|
|
7768
7769
|
})
|
|
7769
7770
|
});
|
|
7770
7771
|
/** Loader logs child cleanup errors; the supervisor's release signal also reaches the command exit. */
|
|
7771
|
-
const close =
|
|
7772
|
+
const close = Effect.fnUntraced(function* (entries, lifecycle) {
|
|
7772
7773
|
const disposed = yield* Effect.exit(entries.dispose);
|
|
7773
7774
|
const released = yield* Effect.exit(Deferred.await(lifecycle.released));
|
|
7774
7775
|
const cause = Array$1.reduce([disposed, released], Cause.empty, (cause, exit) => Exit.isFailure(exit) ? Cause.combine(cause, exit.cause) : cause);
|
|
@@ -28185,10 +28186,10 @@ const write = Effect.fn("Certificates.write")(function* (base, pair, force = fal
|
|
|
28185
28186
|
yield* fs.writeFileString(base + ".key", Redacted.value(pair.privateKey), {
|
|
28186
28187
|
flag: force ? "w" : "wx",
|
|
28187
28188
|
mode: 384
|
|
28188
|
-
})
|
|
28189
|
-
yield* fs.chmod(base + ".key", 384)
|
|
28190
|
-
yield* fs.writeFileString(base + ".crt", pair.certificate, { flag: force ? "w" : "wx" })
|
|
28191
|
-
});
|
|
28189
|
+
});
|
|
28190
|
+
yield* fs.chmod(base + ".key", 384);
|
|
28191
|
+
yield* fs.writeFileString(base + ".crt", pair.certificate, { flag: force ? "w" : "wx" });
|
|
28192
|
+
}, Effect.uninterruptible);
|
|
28192
28193
|
/** URI-encode names so each identity has a distinct filename, including names with slashes. */
|
|
28193
28194
|
const clientName = (identity) => `client-${encodeURIComponent(identity)}`;
|
|
28194
28195
|
const generate = Effect.fn("Certificates.generate")(function* (options) {
|
|
@@ -28242,7 +28243,7 @@ const child = Command.make("child", {
|
|
|
28242
28243
|
contract: Argument.String("contract"),
|
|
28243
28244
|
session: Argument.String("session"),
|
|
28244
28245
|
bootstrap: Argument.String("bootstrap").pipe(Argument.withSchema(Schema.fromJsonString(Bootstrap)))
|
|
28245
|
-
}, ({ contract, session, bootstrap })
|
|
28246
|
+
}, Effect.fnUntraced(function* ({ contract, session, bootstrap }) {
|
|
28246
28247
|
const watchdog = yield* start$1;
|
|
28247
28248
|
yield* Effect.addFinalizer(() => Effect.sync(() => {
|
|
28248
28249
|
process$1.stdin.destroy();
|
|
@@ -28255,7 +28256,7 @@ const child = Command.make("child", {
|
|
|
28255
28256
|
const cli = Command.make("graft-remote", {
|
|
28256
28257
|
contract: Argument.String("contract").pipe(Argument.optional),
|
|
28257
28258
|
session: Argument.String("session").pipe(Argument.withDefault("local"))
|
|
28258
|
-
}, ({ contract, session })
|
|
28259
|
+
}, Effect.fnUntraced(function* ({ contract, session }) {
|
|
28259
28260
|
if (Option.isNone(contract)) return yield* CliError.UserError.make({
|
|
28260
28261
|
cause: "Missing contract module",
|
|
28261
28262
|
userMessage: "A contract module or the child/serve/certificates subcommand is required"
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","names":["Serve.run","Certificates.generate","Watchdog.start"],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n/** Runs local children and WebSocket supervisors, and issues their deployment certificates. */\nimport { Graft } from \"@graftland/graft\"\nimport { NodeRuntime } from \"@effect/platform-node\"\nimport { Console, Array, Effect, Layer, Logger, Option, Schema } from \"effect\"\nimport { Argument, CliError, Command, Flag } from \"effect/cli\"\nimport process from \"node:process\"\nimport { pathToFileURL } from \"node:url\"\nimport { platform } from \"./internal/platform\"\nimport { bytes } from \"./internal/stdioChannel\"\nimport { load, run } from \"./internal/childRuntime\"\nimport { Bootstrap } from \"./internal/runner/Bootstrap\"\nimport * as Watchdog from \"./internal/runner/Watchdog\"\nimport * as Serve from \"./internal/serve\"\nimport * as Certificates from \"./internal/Certificates\"\n\nconst serve = Command.make(\n\t\"serve\",\n\t{ config: Flag.String(\"config\") },\n\t({ config }) => Serve.run(config),\n)\nconst certificates = Command.make(\n\t\"certificates\",\n\t{\n\t\tout: Flag.String(\"out\").pipe(\n\t\t\tFlag.withDescription(\"Directory for the CA and issued certificates\"),\n\t\t),\n\t\tserver: Flag.String(\"server\").pipe(\n\t\t\tFlag.atLeast(0),\n\t\t\tFlag.withDescription(\n\t\t\t\t\"Runner DNS name or IP address; repeat for additional SANs\",\n\t\t\t),\n\t\t),\n\t\tidentity: Flag.String(\"identity\").pipe(\n\t\t\tFlag.atLeast(0),\n\t\t\tFlag.withDescription(\n\t\t\t\t\"Host identity; repeat to issue multiple client certificates\",\n\t\t\t),\n\t\t),\n\t\tdays: Flag.Int(\"days\").pipe(\n\t\t\tFlag.withDefault(365),\n\t\t\tFlag.filter(\n\t\t\t\t(days) => days > 0,\n\t\t\t\t() => \"Days must be a positive integer\",\n\t\t\t),\n\t\t),\n\t\tforce: Flag.Boolean(\"force\").pipe(\n\t\t\tFlag.withDefault(false),\n\t\t\tFlag.withDescription(\n\t\t\t\t\"Replace requested leaf certificates, keeping the existing CA\",\n\t\t\t),\n\t\t),\n\t},\n\t(options) =>\n\t\tCertificates.generate(options).pipe(\n\t\t\tEffect.andThen(Console.log(`Certificates written to ${options.out}`)),\n\t\t\tEffect.catchTag(\"CertificateExists\", (error) =>\n\t\t\t\tCliError.UserError.make({ cause: error, userMessage: error.message }),\n\t\t\t),\n\t\t),\n)\nconst child = Command.make(\n\t\"child\",\n\t{\n\t\tcontract: Argument.String(\"contract\"),\n\t\tsession: Argument.String(\"session\"),\n\t\tbootstrap: Argument.String(\"bootstrap\").pipe(\n\t\t\tArgument.withSchema(Schema.fromJsonString(Bootstrap)),\n\t\t),\n\t},\n\
|
|
1
|
+
{"version":3,"file":"bin.js","names":["Serve.run","Certificates.generate","Watchdog.start"],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n/** Runs local children and WebSocket supervisors, and issues their deployment certificates. */\nimport { Graft } from \"@graftland/graft\"\nimport { NodeRuntime } from \"@effect/platform-node\"\nimport { Console, Array, Effect, Layer, Logger, Option, Schema } from \"effect\"\nimport { Argument, CliError, Command, Flag } from \"effect/cli\"\nimport process from \"node:process\"\nimport { pathToFileURL } from \"node:url\"\nimport { platform } from \"./internal/platform\"\nimport { bytes } from \"./internal/stdioChannel\"\nimport { load, run } from \"./internal/childRuntime\"\nimport { Bootstrap } from \"./internal/runner/Bootstrap\"\nimport * as Watchdog from \"./internal/runner/Watchdog\"\nimport * as Serve from \"./internal/serve\"\nimport * as Certificates from \"./internal/Certificates\"\n\nconst serve = Command.make(\n\t\"serve\",\n\t{ config: Flag.String(\"config\") },\n\t({ config }) => Serve.run(config),\n)\nconst certificates = Command.make(\n\t\"certificates\",\n\t{\n\t\tout: Flag.String(\"out\").pipe(\n\t\t\tFlag.withDescription(\"Directory for the CA and issued certificates\"),\n\t\t),\n\t\tserver: Flag.String(\"server\").pipe(\n\t\t\tFlag.atLeast(0),\n\t\t\tFlag.withDescription(\n\t\t\t\t\"Runner DNS name or IP address; repeat for additional SANs\",\n\t\t\t),\n\t\t),\n\t\tidentity: Flag.String(\"identity\").pipe(\n\t\t\tFlag.atLeast(0),\n\t\t\tFlag.withDescription(\n\t\t\t\t\"Host identity; repeat to issue multiple client certificates\",\n\t\t\t),\n\t\t),\n\t\tdays: Flag.Int(\"days\").pipe(\n\t\t\tFlag.withDefault(365),\n\t\t\tFlag.filter(\n\t\t\t\t(days) => days > 0,\n\t\t\t\t() => \"Days must be a positive integer\",\n\t\t\t),\n\t\t),\n\t\tforce: Flag.Boolean(\"force\").pipe(\n\t\t\tFlag.withDefault(false),\n\t\t\tFlag.withDescription(\n\t\t\t\t\"Replace requested leaf certificates, keeping the existing CA\",\n\t\t\t),\n\t\t),\n\t},\n\t(options) =>\n\t\tCertificates.generate(options).pipe(\n\t\t\tEffect.andThen(Console.log(`Certificates written to ${options.out}`)),\n\t\t\tEffect.catchTag(\"CertificateExists\", (error) =>\n\t\t\t\tCliError.UserError.make({ cause: error, userMessage: error.message }),\n\t\t\t),\n\t\t),\n)\nconst child = Command.make(\n\t\"child\",\n\t{\n\t\tcontract: Argument.String(\"contract\"),\n\t\tsession: Argument.String(\"session\"),\n\t\tbootstrap: Argument.String(\"bootstrap\").pipe(\n\t\t\tArgument.withSchema(Schema.fromJsonString(Bootstrap)),\n\t\t),\n\t},\n\tEffect.fnUntraced(function* ({ contract, session, bootstrap }) {\n\t\tconst watchdog = yield* Watchdog.start\n\t\t// The executable owns stdin; it must not retain the process after a supervisor stop.\n\t\tyield* Effect.addFinalizer(() =>\n\t\t\tEffect.sync(() => {\n\t\t\t\tprocess.stdin.destroy()\n\t\t\t}),\n\t\t)\n\t\tconst begin = yield* Effect.raceFirst(\n\t\t\twatchdog.begin.pipe(Effect.as(true)),\n\t\t\twatchdog.stop.pipe(Effect.as(false)),\n\t\t)\n\t\tif (!begin) return\n\t\tconst definition = yield* load(pathToFileURL(contract).href)\n\t\tconst channel = yield* bytes\n\t\treturn yield* run(definition, channel, session, bootstrap, watchdog.stop)\n\t}),\n)\nconst cli = Command.make(\n\t\"graft-remote\",\n\t{\n\t\tcontract: Argument.String(\"contract\").pipe(Argument.optional),\n\t\tsession: Argument.String(\"session\").pipe(Argument.withDefault(\"local\")),\n\t},\n\tEffect.fnUntraced(function* ({ contract, session }) {\n\t\tif (Option.isNone(contract))\n\t\t\treturn yield* CliError.UserError.make({\n\t\t\t\tcause: \"Missing contract module\",\n\t\t\t\tuserMessage:\n\t\t\t\t\t\"A contract module or the child/serve/certificates subcommand is required\",\n\t\t\t})\n\t\tconst definition = yield* load(contract.value)\n\t\tconst channel = yield* bytes\n\t\treturn yield* run(definition, channel, session)\n\t}),\n).pipe(Command.withSubcommands([child, serve, certificates]))\n\nNodeRuntime.runMain(\n\tEffect.scoped(\n\t\tEffect.gen(function* () {\n\t\t\tconst context = yield* Layer.build(\n\t\t\t\tLayer.provideMerge(Graft.layer, platform),\n\t\t\t)\n\t\t\treturn yield* Command.run(cli, { version: \"0.0.0\" }).pipe(\n\t\t\t\tEffect.provideContext(context),\n\t\t\t)\n\t\t}),\n\t).pipe(\n\t\t(effect) =>\n\t\t\tEffect.withFiber((main) =>\n\t\t\t\teffect.pipe(\n\t\t\t\t\tEffect.tapCause((cause) =>\n\t\t\t\t\t\t// NodeRuntime uses this fiber's id; a self-interrupt here is indistinguishable, but worker cleanup is not.\n\t\t\t\t\t\tArray.every(\n\t\t\t\t\t\t\tcause.reasons,\n\t\t\t\t\t\t\t(reason) =>\n\t\t\t\t\t\t\t\treason._tag === \"Interrupt\" && reason.fiberId === main.id,\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\tArray.every(\n\t\t\t\t\t\t\tcause.reasons,\n\t\t\t\t\t\t\t(reason) =>\n\t\t\t\t\t\t\t\treason._tag === \"Fail\" && CliError.isCliError(reason.error),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\t? Effect.void\n\t\t\t\t\t\t\t: Effect.logError(cause),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\tEffect.provideService(Logger.LogToStderr, true),\n\t),\n\t// Report inside the stderr context, including failures from resource cleanup.\n\t{ disableErrorReporting: true },\n)\n"],"mappings":"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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as plugin, l as make, s as fromModule } from "./Graft-
|
|
2
|
-
import { a as AlreadyLoaded, i as ActivationFailed, o as ContractNotFound, r as prepare, s as ModuleImportFailed, t as closedNormally } from "./connectionEnded-
|
|
3
|
-
import { n as make$1 } from "./port
|
|
4
|
-
import { c as endpoint, o as endpoints, r as fromModule$1 } from "./Contract-
|
|
5
|
-
import { E as make$2, O as Instance, a as ExecutionError, r as channel } from "./Peer-
|
|
1
|
+
import { i as plugin, l as make, s as fromModule } from "./Graft-B71CPA2Y.js";
|
|
2
|
+
import { a as AlreadyLoaded, i as ActivationFailed, o as ContractNotFound, r as prepare, s as ModuleImportFailed, t as closedNormally } from "./connectionEnded-BwcxQ7W8.js";
|
|
3
|
+
import { n as make$1 } from "./port--3x2zJ4D.js";
|
|
4
|
+
import { c as endpoint, o as endpoints, r as fromModule$1 } from "./Contract-DsJtisvL.js";
|
|
5
|
+
import { E as make$2, O as Instance, a as ExecutionError, r as channel } from "./Peer-DXeVrGBh.js";
|
|
6
6
|
import { Array, Cause, Data, Deferred, Effect, Exit, Fiber, Layer, Logger, MutableRef, Option, Queue, Ref, References, Scope, Stream, SynchronizedRef } from "effect";
|
|
7
7
|
import { NodeServices } from "@effect/platform-node";
|
|
8
8
|
import { Digest, SecureRandom, Signature } from "effect/crypto";
|
|
@@ -28,7 +28,7 @@ const loadModule = Effect.fn("Remote.loadModule")(function* (module) {
|
|
|
28
28
|
// packages/remote/src/internal/child.ts
|
|
29
29
|
const ChildEvent = Data.taggedEnum();
|
|
30
30
|
/** Queue data; serialization belongs to the RPC consumer, outside synchronous logger callbacks. */
|
|
31
|
-
const telemetry =
|
|
31
|
+
const telemetry = Effect.fnUntraced(function* (contract) {
|
|
32
32
|
const events = yield* Queue.bounded(2);
|
|
33
33
|
const logs = yield* Queue.dropping(128);
|
|
34
34
|
const dropped = MutableRef.make(0);
|
|
@@ -63,31 +63,32 @@ const telemetry = (contract) => Effect.gen(function* () {
|
|
|
63
63
|
});
|
|
64
64
|
const Lifecycle = Data.taggedEnum();
|
|
65
65
|
const runningOf = (state) => state._tag === "Running" ? Option.some(state.running) : state._tag === "Withdrawing" || state._tag === "Disposing" ? state.running : Option.none();
|
|
66
|
-
const cleanup =
|
|
66
|
+
const cleanup = Effect.fnUntraced(function* (running, retired) {
|
|
67
67
|
const pluginExit = yield* Effect.exit(running.fork.dispose);
|
|
68
68
|
const bridgeExit = yield* Effect.exit(running.bridge.dispose);
|
|
69
69
|
yield* Fiber.join(running.observation);
|
|
70
70
|
const failed = yield* Ref.get(running.observedFailure);
|
|
71
71
|
return Array.reduce([bridgeExit, pluginExit], retired ? failed : Cause.empty, (cause, exit) => Exit.isFailure(exit) ? Cause.combine(cause, Cause.fromReasons(Array.flatMap(exit.cause.reasons, (reason) => reason._tag === "Fail" ? reason.error.cause.reasons : [reason]))) : cause);
|
|
72
72
|
});
|
|
73
|
-
const lifecycle = (contract, peer, identity, telemetry)
|
|
73
|
+
const lifecycle = Effect.fnUntraced(function* (contract, peer, identity, telemetry) {
|
|
74
74
|
const scope = yield* Effect.scope;
|
|
75
75
|
const instanceScope = yield* Scope.fork(scope);
|
|
76
76
|
const releaseExports = yield* Deferred.make();
|
|
77
77
|
const state = yield* SynchronizedRef.make(Lifecycle.Idle());
|
|
78
|
-
const
|
|
78
|
+
const disposing = (current) => Lifecycle.Disposing({ running: runningOf(current) });
|
|
79
|
+
const release = SynchronizedRef.update(state, disposing).pipe(Effect.andThen(Deferred.succeed(releaseExports, void 0)));
|
|
79
80
|
const exportBridge = plugin(make({
|
|
80
81
|
name: `${contract.name}/exports`,
|
|
81
82
|
inject: Array.map(contract.provides, (service) => service.key),
|
|
82
|
-
apply:
|
|
83
|
+
apply: Effect.fnUntraced(function* () {
|
|
83
84
|
for (const service of contract.provides) yield* service.serve(peer).pipe(Effect.tapCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.void : Queue.offer(telemetry.events, ChildEvent.Failed({ cause }))), Effect.forkScoped);
|
|
84
|
-
yield* Effect.addFinalizer(
|
|
85
|
+
yield* Effect.addFinalizer(Effect.fnUntraced(function* () {
|
|
85
86
|
if (yield* SynchronizedRef.modify(state, (current) => current._tag === "Disposing" ? [false, current] : [true, Lifecycle.Withdrawing({ running: runningOf(current) })])) yield* Queue.offer(telemetry.events, ChildEvent.Withdrawing());
|
|
86
87
|
yield* Deferred.await(releaseExports);
|
|
87
88
|
}));
|
|
88
89
|
})
|
|
89
90
|
})).pipe(Scope.provide(instanceScope));
|
|
90
|
-
const start =
|
|
91
|
+
const start = Effect.fnUntraced(function* (input) {
|
|
91
92
|
for (const service of contract.inject) yield* service.publish(peer).pipe(Scope.provide(scope), Effect.mapError((error) => ActivationFailed.make({
|
|
92
93
|
detail: "Publishing imported services failed",
|
|
93
94
|
cause: Cause.fail(error)
|
|
@@ -108,7 +109,7 @@ const lifecycle = (contract, peer, identity, telemetry) => Effect.gen(function*
|
|
|
108
109
|
observation
|
|
109
110
|
};
|
|
110
111
|
});
|
|
111
|
-
const awaitActive =
|
|
112
|
+
const awaitActive = Effect.fnUntraced(function* (running) {
|
|
112
113
|
const first = yield* running.fork.state.pipe(Stream.filter((state) => state._tag !== "Loading"), Stream.runHead);
|
|
113
114
|
if (Option.isNone(first)) return yield* ActivationFailed.make({ detail: "The remote fork disappeared during startup" });
|
|
114
115
|
if (first.value._tag === "Failed") return yield* Effect.fail(contract.normalizeCause(first.value.cause));
|
|
@@ -121,17 +122,19 @@ const lifecycle = (contract, peer, identity, telemetry) => Effect.gen(function*
|
|
|
121
122
|
});
|
|
122
123
|
if (Option.isNone(exported) || exported.value._tag !== "Active") return yield* ActivationFailed.make({ detail: "The remote export bridge stopped during startup" });
|
|
123
124
|
});
|
|
124
|
-
const load = (input) => Effect.gen(function* () {
|
|
125
|
-
yield* SynchronizedRef.updateEffect(state, (current) => current._tag === "Idle" ? Effect.succeed(Lifecycle.Loading()) : Effect.fail(AlreadyLoaded.make({})));
|
|
126
|
-
const running = yield* start(input);
|
|
127
|
-
yield* SynchronizedRef.update(state, (current) => current._tag === "Withdrawing" ? Lifecycle.Withdrawing({ running: Option.some(running) }) : current._tag === "Disposing" ? Lifecycle.Disposing({ running: Option.some(running) }) : Lifecycle.Running({ running }));
|
|
128
|
-
yield* awaitActive(running);
|
|
129
|
-
}).pipe(Effect.mapError((error) => Cause.isCause(error) ? error : contract.normalizeCause(Cause.fail(error))));
|
|
130
125
|
return {
|
|
131
|
-
load
|
|
126
|
+
load: Effect.fnUntraced(function* (input) {
|
|
127
|
+
yield* SynchronizedRef.updateEffect(state, (current) => current._tag === "Idle" ? Effect.succeed(Lifecycle.Loading()) : Effect.fail(AlreadyLoaded.make({})));
|
|
128
|
+
const running = yield* start(input);
|
|
129
|
+
if (yield* SynchronizedRef.modify(state, (current) => current._tag === "Withdrawing" ? [false, Lifecycle.Withdrawing({ running: Option.some(running) })] : current._tag === "Disposing" ? [true, Lifecycle.Disposing({ running: Option.some(running) })] : [false, Lifecycle.Running({ running })])) {
|
|
130
|
+
const cause = yield* cleanup(running, false);
|
|
131
|
+
return yield* Effect.fail(Cause.combine(Cause.fail(ActivationFailed.make({ detail: "The execution was disposed during load" })), cause));
|
|
132
|
+
}
|
|
133
|
+
yield* awaitActive(running);
|
|
134
|
+
}, Effect.mapError((error) => contract.normalizeCause(Cause.isCause(error) ? error : Cause.fail(error)))),
|
|
132
135
|
dispose: Effect.gen(function* () {
|
|
133
|
-
const previous = yield* SynchronizedRef.
|
|
134
|
-
yield*
|
|
136
|
+
const previous = yield* SynchronizedRef.getAndUpdate(state, disposing);
|
|
137
|
+
yield* Deferred.succeed(releaseExports, void 0);
|
|
135
138
|
const current = runningOf(previous);
|
|
136
139
|
const retired = previous._tag === "Withdrawing";
|
|
137
140
|
const cause = Option.isSome(current) ? yield* cleanup(current.value, retired) : Cause.empty;
|
|
@@ -144,13 +147,13 @@ const lifecycle = (contract, peer, identity, telemetry) => Effect.gen(function*
|
|
|
144
147
|
});
|
|
145
148
|
// packages/remote/src/internal/childRuntime.ts
|
|
146
149
|
/** Import a contract in the runner installation; importing this module performs no I/O. */
|
|
147
|
-
const load =
|
|
150
|
+
const load = Effect.fnUntraced(function* (specifier) {
|
|
148
151
|
const module = yield* loadModule(specifier);
|
|
149
152
|
const contract = fromModule$1(module);
|
|
150
153
|
if (Option.isNone(contract)) return yield* ContractNotFound.make({ module: specifier });
|
|
151
154
|
return contract.value;
|
|
152
155
|
});
|
|
153
|
-
const connect = (contract, channel$1, session, bootstrap)
|
|
156
|
+
const connect = Effect.fnUntraced(function* (contract, channel$1, session, bootstrap) {
|
|
154
157
|
const mux = bootstrap === void 0 ? void 0 : yield* make$2(channel$1);
|
|
155
158
|
return yield* make$1(mux === void 0 ? channel$1 : channel(mux, 1), {
|
|
156
159
|
session,
|
|
@@ -163,7 +166,7 @@ const connect = (contract, channel$1, session, bootstrap) => Effect.gen(function
|
|
|
163
166
|
});
|
|
164
167
|
});
|
|
165
168
|
/** One execution unit; the executable supplies the platform and Graft services. */
|
|
166
|
-
const run = (descriptor, channel, session = "local", bootstrap, stop = Effect.never)
|
|
169
|
+
const run = Effect.fnUntraced(function* (descriptor, channel, session = "local", bootstrap, stop = Effect.never) {
|
|
167
170
|
const contract = prepare(descriptor);
|
|
168
171
|
const telemetry$1 = yield* telemetry(contract);
|
|
169
172
|
const loggers = yield* Logger.CurrentLoggers;
|
|
@@ -185,5 +188,5 @@ const run = (descriptor, channel, session = "local", bootstrap, stop = Effect.ne
|
|
|
185
188
|
cause: error.cause
|
|
186
189
|
}))), stop).pipe(Effect.ensuring(instance.release));
|
|
187
190
|
}).pipe(Effect.provideService(Logger.CurrentLoggers, /* @__PURE__ */ new Set([...loggers, telemetry$1.logger])));
|
|
188
|
-
})
|
|
191
|
+
}, Effect.scoped);
|
|
189
192
|
export { run as n, platform as r, load as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as EndOfStream } from "./Framing-
|
|
3
|
-
import { l as make, n as UndeclaredFailure } from "./Contract-
|
|
4
|
-
import { t as Peer } from "./Peer-
|
|
1
|
+
import { u as TransportError } from "./Errors-DYhsGZcZ.js";
|
|
2
|
+
import { t as EndOfStream } from "./Framing-G9eSaeLb.js";
|
|
3
|
+
import { l as make, n as UndeclaredFailure } from "./Contract-DsJtisvL.js";
|
|
4
|
+
import { t as Peer } from "./Peer-DXeVrGBh.js";
|
|
5
5
|
import { Array, Cause, Effect, Schema } from "effect";
|
|
6
6
|
import { Socket } from "effect/socket";
|
|
7
7
|
// packages/remote/src/internal/childErrors.ts
|