@graftland/plugin-remote 0.3.3 → 0.4.1
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/README.md +18 -54
- package/README.zh-CN.md +17 -51
- package/README.zh-TW.md +17 -51
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js.map +1 -1
- package/dist/Config.d.ts +1151 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +183 -0
- package/dist/Config.js.map +1 -0
- package/dist/Contract.d.ts +1 -1
- package/dist/Contract.d.ts.map +1 -1
- package/dist/Contract.js +32 -1
- package/dist/Contract.js.map +1 -1
- package/dist/Instance.d.ts.map +1 -1
- package/dist/Instance.js.map +1 -1
- package/dist/Testing.d.ts +1 -1
- package/dist/Testing.d.ts.map +1 -1
- package/dist/Testing.js.map +1 -1
- package/dist/Transport.d.ts +1 -1
- package/dist/Transport.d.ts.map +1 -1
- package/dist/Transport.js.map +1 -1
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +25 -0
- package/dist/cli.js.map +1 -0
- package/dist/host/auth/bearer.d.ts.map +1 -1
- package/dist/host/auth/bearer.js +4 -2
- package/dist/host/auth/bearer.js.map +1 -1
- package/dist/host/auth/jwt.d.ts.map +1 -1
- package/dist/host/auth/jwt.js +4 -2
- package/dist/host/auth/jwt.js.map +1 -1
- package/dist/host/auth/mtls.d.ts +3 -7
- package/dist/host/auth/mtls.d.ts.map +1 -1
- package/dist/host/auth/mtls.js +13 -14
- package/dist/host/auth/mtls.js.map +1 -1
- package/dist/host/auth/none.d.ts +1 -1
- package/dist/host/auth/none.js +7 -5
- package/dist/host/auth/none.js.map +1 -1
- package/dist/host/command.d.ts +1 -1
- package/dist/host/command.d.ts.map +1 -1
- package/dist/host/command.js +11 -9
- package/dist/host/command.js.map +1 -1
- package/dist/host/local.d.ts.map +1 -1
- package/dist/host/local.js +9 -30
- package/dist/host/local.js.map +1 -1
- package/dist/host/unix.d.ts +1 -1
- package/dist/host/unix.d.ts.map +1 -1
- package/dist/host/unix.js +13 -9
- package/dist/host/unix.js.map +1 -1
- package/dist/host/websocket.d.ts +1 -1
- package/dist/host/websocket.d.ts.map +1 -1
- package/dist/host/websocket.js +11 -8
- package/dist/host/websocket.js.map +1 -1
- package/dist/host/worker.d.ts +1 -1
- package/dist/host/worker.d.ts.map +1 -1
- package/dist/host/worker.js +13 -9
- package/dist/host/worker.js.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -64
- package/dist/index.js.map +1 -1
- package/dist/internal/Certificates.js.map +1 -1
- package/dist/internal/FailureGroup.js +6 -6
- package/dist/internal/FailureGroup.js.map +1 -1
- package/dist/internal/Peer.js.map +1 -1
- package/dist/internal/{ServeLifecycle.js → RunnerLifecycle.js} +6 -6
- package/dist/internal/RunnerLifecycle.js.map +1 -0
- package/dist/internal/Supervisor.js.map +1 -1
- package/dist/internal/assembly.d.ts +3 -3
- package/dist/internal/assembly.js +8 -8
- package/dist/internal/assembly.js.map +1 -1
- package/dist/internal/auth/config.d.ts +27 -0
- package/dist/internal/auth/config.d.ts.map +1 -0
- package/dist/internal/auth/config.js +29 -0
- package/dist/internal/auth/config.js.map +1 -0
- package/dist/internal/auth/mtls.js.map +1 -1
- package/dist/internal/auth/token.js.map +1 -1
- package/dist/internal/auth/tokenCredentials.d.ts +1 -1
- package/dist/internal/auth/tokenCredentials.d.ts.map +1 -1
- package/dist/internal/auth/tokenCredentials.js +1 -1
- package/dist/internal/auth/tokenCredentials.js.map +1 -1
- package/dist/internal/child.js +3 -3
- package/dist/internal/child.js.map +1 -1
- package/dist/internal/childMain.js +47 -0
- package/dist/internal/childMain.js.map +1 -0
- package/dist/internal/childRuntime.js +8 -8
- package/dist/internal/childRuntime.js.map +1 -1
- package/dist/internal/cleanup.js +3 -3
- package/dist/internal/cleanup.js.map +1 -1
- package/dist/internal/contract.js.map +1 -1
- package/dist/internal/credentials.d.ts +3 -2
- package/dist/internal/credentials.d.ts.map +1 -1
- package/dist/internal/credentials.js +1 -1
- package/dist/internal/credentials.js.map +1 -1
- package/dist/internal/directTransport.js.map +1 -1
- package/dist/internal/entry.d.ts +104 -26
- package/dist/internal/entry.d.ts.map +1 -1
- package/dist/internal/entry.js +22 -9
- package/dist/internal/entry.js.map +1 -1
- package/dist/internal/entryConfig.d.ts +2 -202
- package/dist/internal/entryConfig.js +2 -136
- package/dist/internal/entryConfig.js.map +1 -1
- package/dist/internal/execution.d.ts +4 -4
- package/dist/internal/execution.js +11 -11
- package/dist/internal/execution.js.map +1 -1
- package/dist/internal/follow.js +1 -1
- package/dist/internal/follow.js.map +1 -1
- package/dist/internal/forkTree.js.map +1 -1
- package/dist/internal/host/local.js.map +1 -1
- package/dist/internal/host/runner.js +4 -4
- package/dist/internal/host/runner.js.map +1 -1
- package/dist/internal/host.js +2 -2
- package/dist/internal/host.js.map +1 -1
- package/dist/internal/importer.js +1 -1
- package/dist/internal/importer.js.map +1 -1
- package/dist/internal/listenerStartup.js +1 -1
- package/dist/internal/listenerStartup.js.map +1 -1
- package/dist/internal/loadModule.js.map +1 -1
- package/dist/internal/platform.js +1 -9
- package/dist/internal/port.d.ts +1 -1
- package/dist/internal/port.js +2 -2
- package/dist/internal/port.js.map +1 -1
- package/dist/internal/runner/Bootstrap.js.map +1 -1
- package/dist/internal/runner/Connection.d.ts +3 -2
- package/dist/internal/runner/Connection.js +6 -6
- package/dist/internal/runner/Connection.js.map +1 -1
- package/dist/internal/runner/Execution.js +6 -6
- package/dist/internal/runner/Execution.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.map +1 -1
- package/dist/internal/runner/Multiplex.js.map +1 -1
- package/dist/internal/runner/Packages.js.map +1 -1
- package/dist/internal/runner/ProcessObservation.js.map +1 -1
- package/dist/internal/runner/Processes.js.map +1 -1
- package/dist/internal/runner/Retention.js.map +1 -1
- package/dist/internal/runner/Store.js.map +1 -1
- package/dist/internal/runner/Supervisor.js +5 -5
- package/dist/internal/runner/Supervisor.js.map +1 -1
- package/dist/internal/runner/Watchdog.js.map +1 -1
- package/dist/internal/runner/Wire.d.ts +1 -1
- package/dist/internal/runner/Wire.js.map +1 -1
- package/dist/internal/runner/accept.js +2 -2
- package/dist/internal/runner/accept.js.map +1 -1
- package/dist/internal/runner/command.js +1 -1
- package/dist/internal/runner/command.js.map +1 -1
- package/dist/internal/runner/connectionEnded.js +1 -1
- package/dist/internal/runner/connectionEnded.js.map +1 -1
- package/dist/internal/runner/model.d.ts.map +1 -1
- package/dist/internal/runner/model.js.map +1 -1
- package/dist/internal/services.d.ts.map +1 -1
- package/dist/internal/services.js +1 -1
- package/dist/internal/services.js.map +1 -1
- package/dist/internal/socketChannel.js.map +1 -1
- package/dist/internal/stdioChannel.js.map +1 -1
- package/dist/internal/supervisorPlugin.js +48 -1
- package/dist/internal/supervisorPlugin.js.map +1 -1
- package/dist/internal/transportOptions.d.ts.map +1 -1
- package/dist/internal/watchdogMain.js +5 -3
- package/dist/internal/watchdogMain.js.map +1 -1
- package/dist/internal/websocket.js.map +1 -1
- package/dist/internal/websocketServer.js +1 -1
- package/dist/internal/websocketServer.js.map +1 -1
- package/dist/internal/workerChannel.js.map +1 -1
- package/dist/internal/workerMain.js +13 -6
- package/dist/internal/workerMain.js.map +1 -1
- package/dist/runner/auth/bearer.d.ts +3 -5
- package/dist/runner/auth/bearer.d.ts.map +1 -1
- package/dist/runner/auth/bearer.js +13 -11
- package/dist/runner/auth/bearer.js.map +1 -1
- package/dist/runner/auth/jwt.d.ts +4 -18
- package/dist/runner/auth/jwt.d.ts.map +1 -1
- package/dist/runner/auth/jwt.js +16 -28
- package/dist/runner/auth/jwt.js.map +1 -1
- package/dist/runner/auth/mtls.d.ts +3 -6
- package/dist/runner/auth/mtls.d.ts.map +1 -1
- package/dist/runner/auth/mtls.js +13 -29
- package/dist/runner/auth/mtls.js.map +1 -1
- package/dist/runner/auth/none.d.ts +1 -1
- package/dist/runner/auth/none.js +7 -5
- package/dist/runner/auth/none.js.map +1 -1
- package/dist/runner/index.d.ts +3 -308
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +62 -30
- package/dist/runner/index.js.map +1 -1
- package/dist/runner/stdio.d.ts +1 -1
- package/dist/runner/stdio.d.ts.map +1 -1
- package/dist/runner/stdio.js +11 -9
- package/dist/runner/stdio.js.map +1 -1
- package/dist/runner/unix.d.ts +1 -1
- package/dist/runner/unix.d.ts.map +1 -1
- package/dist/runner/unix.js +10 -8
- package/dist/runner/unix.js.map +1 -1
- package/dist/runner/websocket.d.ts +1 -1
- package/dist/runner/websocket.d.ts.map +1 -1
- package/dist/runner/websocket.js +12 -10
- package/dist/runner/websocket.js.map +1 -1
- package/package.json +14 -12
- package/schema.json +2269 -0
- package/src/Auth.ts +8 -2
- package/src/Config.ts +196 -0
- package/src/Contract.ts +12 -3
- package/src/Instance.ts +1 -0
- package/src/Testing.ts +6 -4
- package/src/Transport.ts +12 -3
- package/src/cli.ts +60 -0
- package/src/host/auth/bearer.ts +1 -0
- package/src/host/auth/jwt.ts +1 -0
- package/src/host/auth/mtls.ts +7 -12
- package/src/host/auth/none.ts +3 -1
- package/src/host/command.ts +8 -5
- package/src/host/local.ts +4 -2
- package/src/host/unix.ts +11 -7
- package/src/host/websocket.ts +10 -7
- package/src/host/worker.ts +8 -5
- package/src/index.ts +36 -23
- package/src/internal/Certificates.ts +1 -0
- package/src/internal/FailureGroup.ts +5 -3
- package/src/internal/Peer.ts +1 -0
- package/src/internal/{ServeLifecycle.ts → RunnerLifecycle.ts} +7 -5
- package/src/internal/Supervisor.ts +5 -4
- package/src/internal/assembly.ts +11 -9
- package/src/internal/auth/config.ts +44 -0
- package/src/internal/auth/mtls.ts +1 -0
- package/src/internal/auth/token.ts +1 -0
- package/src/internal/auth/tokenCredentials.ts +4 -2
- package/src/internal/child.ts +8 -6
- package/src/{bin.ts → internal/childMain.ts} +16 -61
- package/src/internal/childRuntime.ts +12 -10
- package/src/internal/cleanup.ts +3 -2
- package/src/internal/contract.ts +1 -0
- package/src/internal/credentials.ts +3 -1
- package/src/internal/directTransport.ts +9 -2
- package/src/internal/entry.ts +53 -16
- package/src/internal/entryConfig.ts +10 -132
- package/src/internal/execution.ts +17 -15
- package/src/internal/follow.ts +2 -1
- package/src/internal/forkTree.ts +2 -1
- package/src/internal/host/local.ts +1 -0
- package/src/internal/host/runner.ts +7 -5
- package/src/internal/host.ts +9 -8
- package/src/internal/importer.ts +3 -2
- package/src/internal/listenerStartup.ts +4 -2
- package/src/internal/loadModule.ts +1 -0
- package/src/internal/platform.ts +1 -12
- package/src/internal/port.ts +11 -6
- package/src/internal/runner/Bootstrap.ts +1 -0
- package/src/internal/runner/Connection.ts +13 -11
- package/src/internal/runner/Execution.ts +14 -13
- package/src/internal/runner/Local.ts +3 -2
- package/src/internal/runner/Lock.ts +1 -0
- package/src/internal/runner/Multiplex.ts +2 -1
- package/src/internal/runner/Packages.ts +7 -5
- package/src/internal/runner/ProcessObservation.ts +2 -1
- package/src/internal/runner/Processes.ts +3 -1
- package/src/internal/runner/Retention.ts +1 -0
- package/src/internal/runner/Store.ts +3 -2
- package/src/internal/runner/Supervisor.ts +22 -20
- package/src/internal/runner/Watchdog.ts +3 -1
- package/src/internal/runner/Wire.ts +13 -12
- package/src/internal/runner/accept.ts +6 -5
- package/src/internal/runner/command.ts +3 -2
- package/src/internal/runner/connectionEnded.ts +2 -1
- package/src/internal/runner/model.ts +5 -3
- package/src/internal/services.ts +9 -2
- package/src/internal/socketChannel.ts +2 -1
- package/src/internal/stdioChannel.ts +4 -2
- package/src/internal/supervisorPlugin.ts +10 -8
- package/src/internal/transportOptions.ts +1 -0
- package/src/internal/watchdogMain.ts +5 -3
- package/src/internal/websocket.ts +5 -2
- package/src/internal/websocketServer.ts +6 -4
- package/src/internal/workerChannel.ts +1 -0
- package/src/internal/workerMain.ts +21 -5
- package/src/runner/auth/bearer.ts +10 -6
- package/src/runner/auth/jwt.ts +10 -41
- package/src/runner/auth/mtls.ts +6 -3
- package/src/runner/auth/none.ts +3 -1
- package/src/runner/index.ts +102 -11
- package/src/runner/stdio.ts +15 -10
- package/src/runner/unix.ts +7 -4
- package/src/runner/websocket.ts +9 -7
- package/dist/Auth-BElTC9_X.js +0 -6
- package/dist/Bootstrap-H9gDsgsC.js +0 -9
- package/dist/ConfigDirectory-BCC6q2R4.js +0 -5
- package/dist/Contract-DsJtisvL.js +0 -83
- package/dist/Errors-DYhsGZcZ.js +0 -58
- package/dist/FailureGroup-BgT73AaR.js +0 -63
- package/dist/Framing-G9eSaeLb.js +0 -61
- package/dist/Graft-B71CPA2Y.js +0 -996
- package/dist/Packages-AgoCGotL.js +0 -108
- package/dist/Peer-DXeVrGBh.js +0 -342
- package/dist/ProcessObservation-gLgGirYv.js +0 -38
- package/dist/ServeLifecycle-Bd1FPJ6e.js +0 -24
- package/dist/Transport-DULzpsgR.js +0 -6
- package/dist/WatchdogProtocol-BZmVxrBP.js +0 -17
- package/dist/bin.js +0 -28276
- package/dist/bin.js.map +0 -1
- package/dist/childRuntime-Bm3iSg_N.js +0 -192
- package/dist/command-9zrHdbwT.js +0 -7
- package/dist/connectionEnded-BwcxQ7W8.js +0 -54
- package/dist/directTransport-DrexuPSm.js +0 -5
- package/dist/entry-psOpX3Bj.js +0 -736
- package/dist/importer-Cvf88eAY.js +0 -344
- package/dist/internal/ServeLifecycle.js.map +0 -1
- package/dist/internal/entryConfig.d.ts.map +0 -1
- package/dist/internal/platform.js.map +0 -1
- package/dist/internal/release.js +0 -25
- package/dist/internal/release.js.map +0 -1
- package/dist/internal/serve.js +0 -60
- package/dist/internal/serve.js.map +0 -1
- package/dist/port--3x2zJ4D.js +0 -285
- package/dist/release-DfZPuIcK.js +0 -23
- package/dist/rolldown-runtime-DYf_mQCB.js +0 -34
- package/dist/socketChannel-CJvL2DiB.js +0 -3658
- package/dist/supervisorPlugin-t6Z6PrhD.js +0 -733
- package/dist/token-CYBNNlhS.js +0 -17
- package/dist/tokenCredentials-CbCuk-Rt.js +0 -31
- package/dist/websocketServer-NQhODlEt.js +0 -60
- package/dist/workerChannel-C8hhBJzA.js +0 -27
- package/src/internal/release.ts +0 -72
- package/src/internal/serve.ts +0 -119
- /package/dist/{bin.d.ts → internal/childMain.d.ts} +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Context, Deferred, Effect, Exit, Option, Schema, Scope } from "effect"
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import * as Release from "@graftland/graft/Release"
|
|
4
|
+
|
|
3
5
|
import type { TransportError } from "../Errors"
|
|
4
6
|
|
|
5
7
|
export class StartupError extends Schema.TaggedError<
|
|
@@ -14,13 +16,13 @@ export class StartupError extends Schema.TaggedError<
|
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
export class
|
|
18
|
-
|
|
19
|
+
export class RunnerLifecycle extends Context.Service<
|
|
20
|
+
RunnerLifecycle,
|
|
19
21
|
{
|
|
20
22
|
readonly ended: Deferred.Deferred<void, TransportError>
|
|
21
23
|
readonly released: Deferred.Deferred<void, StartupError>
|
|
22
24
|
}
|
|
23
|
-
>()("@graftland/plugin-remote/internal/
|
|
25
|
+
>()("@graftland/plugin-remote/internal/RunnerLifecycle") {}
|
|
24
26
|
|
|
25
27
|
export const make = Effect.all({
|
|
26
28
|
ended: Deferred.make<void, TransportError>(),
|
|
@@ -29,7 +31,7 @@ export const make = Effect.all({
|
|
|
29
31
|
|
|
30
32
|
/** Observe shutdown independently of the loader, which logs child cleanup failures. */
|
|
31
33
|
export const resources = Effect.fnUntraced(function* (
|
|
32
|
-
lifecycle: Option.Option<typeof
|
|
34
|
+
lifecycle: Option.Option<typeof RunnerLifecycle.Service>,
|
|
33
35
|
) {
|
|
34
36
|
return yield* Effect.acquireRelease(Scope.make(), (scope, exit) =>
|
|
35
37
|
Release.close(scope, exit).pipe(
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/** A listener hands an authenticated byte channel to the supervisor. */
|
|
2
|
-
import { Context } from "effect"
|
|
3
|
-
|
|
4
|
-
import type { Peer } from "./Peer"
|
|
5
|
-
import type { Channel } from "../Transport"
|
|
2
|
+
import { Context, type Effect, type Scope } from "effect"
|
|
3
|
+
|
|
6
4
|
import type { TransportError } from "../Errors"
|
|
5
|
+
import type { Channel } from "../Transport"
|
|
6
|
+
import type { Peer } from "./Peer"
|
|
7
|
+
|
|
7
8
|
export class Supervisor extends Context.Service<
|
|
8
9
|
Supervisor,
|
|
9
10
|
{
|
package/src/internal/assembly.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { findSubtree, isSubtreeActive } from "./forkTree"
|
|
2
|
-
import { Peer } from "./Peer"
|
|
3
|
-
import { Graft, Plugin, type Fork } from "@graftland/graft"
|
|
4
1
|
import {
|
|
5
2
|
Array,
|
|
6
3
|
Context,
|
|
@@ -11,12 +8,16 @@ import {
|
|
|
11
8
|
Schema,
|
|
12
9
|
Stream,
|
|
13
10
|
} from "effect"
|
|
11
|
+
|
|
12
|
+
import { Graft, Plugin, type Fork } from "@graftland/graft"
|
|
13
|
+
|
|
14
14
|
import {
|
|
15
15
|
Authenticator,
|
|
16
16
|
Credentials,
|
|
17
17
|
type AuthenticatorApi,
|
|
18
18
|
type CredentialsApi,
|
|
19
19
|
} from "../Auth"
|
|
20
|
+
import { AuthenticationFailed } from "../Errors"
|
|
20
21
|
import {
|
|
21
22
|
Connector,
|
|
22
23
|
Listener,
|
|
@@ -24,11 +25,12 @@ import {
|
|
|
24
25
|
type Properties,
|
|
25
26
|
type Session,
|
|
26
27
|
} from "../Transport"
|
|
27
|
-
import { AuthenticationFailed } from "../Errors"
|
|
28
|
-
import { Supervisor } from "./Supervisor"
|
|
29
28
|
import { follow } from "./follow"
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
29
|
+
import { findSubtree, isSubtreeActive } from "./forkTree"
|
|
30
|
+
import { Peer } from "./Peer"
|
|
31
|
+
import { closedNormally, connectionEnded } from "./runner/connectionEnded"
|
|
32
|
+
import { RunnerLifecycle } from "./RunnerLifecycle"
|
|
33
|
+
import { Supervisor } from "./Supervisor"
|
|
32
34
|
|
|
33
35
|
export class ListenerConfigError extends Schema.TaggedError<
|
|
34
36
|
ListenerConfigError,
|
|
@@ -291,13 +293,13 @@ export const makeListenerConsumer = (
|
|
|
291
293
|
Listener,
|
|
292
294
|
Authenticator,
|
|
293
295
|
Supervisor,
|
|
294
|
-
Plugin.optional(
|
|
296
|
+
Plugin.optional(RunnerLifecycle),
|
|
295
297
|
],
|
|
296
298
|
apply: Effect.fnUntraced(function* () {
|
|
297
299
|
const listener = yield* Listener
|
|
298
300
|
const auth = yield* Authenticator
|
|
299
301
|
const supervisor = yield* Supervisor
|
|
300
|
-
const lifecycle = yield* Effect.serviceOption(
|
|
302
|
+
const lifecycle = yield* Effect.serviceOption(RunnerLifecycle)
|
|
301
303
|
yield* prepare(listener.properties, auth)
|
|
302
304
|
yield* compatible(listener.properties, kind(auth)).pipe(
|
|
303
305
|
Effect.mapError((error) =>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Duration, Effect, Schema } from "effect"
|
|
2
|
+
import { Jwk } from "effect/jose"
|
|
3
|
+
|
|
4
|
+
export const ClockTolerance = Schema.DurationFromString.check(
|
|
5
|
+
Schema.makeFilter(
|
|
6
|
+
(duration) =>
|
|
7
|
+
Duration.isFinite(duration) && Duration.toMillis(duration) >= 0,
|
|
8
|
+
{ expected: "a finite, non-negative duration" },
|
|
9
|
+
),
|
|
10
|
+
)
|
|
11
|
+
export const Jwt = Schema.Struct({
|
|
12
|
+
issuer: Schema.NonEmptyString,
|
|
13
|
+
audience: Schema.NonEmptyArray(Schema.NonEmptyString),
|
|
14
|
+
algorithms: Schema.NonEmptyArray(Jwk.AsymmetricAlgorithm),
|
|
15
|
+
identityClaim: Schema.NonEmptyString.pipe(
|
|
16
|
+
Schema.withDecodingDefaultKey(Effect.succeed("sub")),
|
|
17
|
+
),
|
|
18
|
+
clockTolerance: ClockTolerance.pipe(
|
|
19
|
+
Schema.withDecodingDefaultKey(Effect.succeed("5 seconds")),
|
|
20
|
+
),
|
|
21
|
+
keys: Schema.Union([
|
|
22
|
+
Schema.Struct({
|
|
23
|
+
jwksUrl: Schema.String,
|
|
24
|
+
publicKey: Schema.optionalKey(Schema.Never),
|
|
25
|
+
}),
|
|
26
|
+
Schema.Struct({
|
|
27
|
+
publicKey: Schema.String,
|
|
28
|
+
jwksUrl: Schema.optionalKey(Schema.Never),
|
|
29
|
+
}),
|
|
30
|
+
]),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export const Certificate = Schema.Struct({
|
|
34
|
+
cert: Schema.String,
|
|
35
|
+
key: Schema.String,
|
|
36
|
+
})
|
|
37
|
+
export const Token = Schema.Struct({
|
|
38
|
+
token: Schema.Union([Schema.String, Schema.Struct({ file: Schema.String })]),
|
|
39
|
+
})
|
|
40
|
+
export const Mtls = Schema.Struct({ ca: Schema.String })
|
|
41
|
+
export const Bearer = Schema.Struct({ tokens: Schema.String })
|
|
42
|
+
export const None = Schema.Struct({
|
|
43
|
+
identity: Schema.optionalKey(Schema.String),
|
|
44
|
+
})
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Graft, Plugin } from "@graftland/graft"
|
|
2
|
-
import { ConfigDirectory } from "@graftland/loader"
|
|
3
1
|
import {
|
|
4
2
|
Cause,
|
|
5
3
|
Effect,
|
|
@@ -9,6 +7,10 @@ import {
|
|
|
9
7
|
Redacted,
|
|
10
8
|
Schema,
|
|
11
9
|
} from "effect"
|
|
10
|
+
|
|
11
|
+
import { Graft, Plugin } from "@graftland/graft"
|
|
12
|
+
import { ConfigDirectory } from "@graftland/loader"
|
|
13
|
+
|
|
12
14
|
import { Credentials, type Prepared } from "../../Auth"
|
|
13
15
|
import { CredentialsError } from "../../Errors"
|
|
14
16
|
import { prepare } from "./token"
|
package/src/internal/child.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { loadModule } from "./loadModule"
|
|
2
|
-
import { AlreadyLoaded, ActivationFailed } from "./childErrors"
|
|
3
|
-
import { Graft, Plugin, type Fork } from "@graftland/graft"
|
|
4
1
|
import {
|
|
5
2
|
Array,
|
|
6
3
|
Cause,
|
|
@@ -18,12 +15,17 @@ import {
|
|
|
18
15
|
Scope,
|
|
19
16
|
Stream,
|
|
20
17
|
SynchronizedRef,
|
|
18
|
+
type Schema,
|
|
21
19
|
} from "effect"
|
|
22
|
-
|
|
23
|
-
import { type
|
|
20
|
+
|
|
21
|
+
import { Graft, Plugin, type Fork } from "@graftland/graft"
|
|
22
|
+
|
|
24
23
|
import { Instance, type Identity } from "../Instance"
|
|
25
|
-
import
|
|
24
|
+
import { ActivationFailed, AlreadyLoaded } from "./childErrors"
|
|
25
|
+
import { type RunnerContract } from "./contract"
|
|
26
26
|
import type { Event, Log, LogEvent } from "./control"
|
|
27
|
+
import { loadModule } from "./loadModule"
|
|
28
|
+
import type * as Port from "./port"
|
|
27
29
|
|
|
28
30
|
type Peer = Port.Port
|
|
29
31
|
type ChildEvent = Data.TaggedEnum<{
|
|
@@ -1,64 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
import { Graft } from "@graftland/graft"
|
|
4
|
-
import { NodeRuntime } from "@effect/platform-node"
|
|
5
|
-
import { Console, Array, Effect, Layer, Logger, Option, Schema } from "effect"
|
|
6
|
-
import { Argument, CliError, Command, Flag } from "effect/cli"
|
|
2
|
+
/** Internal executable for local and supervised child runtimes. */
|
|
7
3
|
import process from "node:process"
|
|
8
4
|
import { pathToFileURL } from "node:url"
|
|
9
|
-
import { platform } from "./internal/platform"
|
|
10
|
-
import { bytes } from "./internal/stdioChannel"
|
|
11
|
-
import { load, run } from "./internal/childRuntime"
|
|
12
|
-
import { Bootstrap } from "./internal/runner/Bootstrap"
|
|
13
|
-
import * as Watchdog from "./internal/runner/Watchdog"
|
|
14
|
-
import * as Serve from "./internal/serve"
|
|
15
|
-
import * as Certificates from "./internal/Certificates"
|
|
16
5
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Flag.atLeast(0),
|
|
30
|
-
Flag.withDescription(
|
|
31
|
-
"Runner DNS name or IP address; repeat for additional SANs",
|
|
32
|
-
),
|
|
33
|
-
),
|
|
34
|
-
identity: Flag.String("identity").pipe(
|
|
35
|
-
Flag.atLeast(0),
|
|
36
|
-
Flag.withDescription(
|
|
37
|
-
"Host identity; repeat to issue multiple client certificates",
|
|
38
|
-
),
|
|
39
|
-
),
|
|
40
|
-
days: Flag.Int("days").pipe(
|
|
41
|
-
Flag.withDefault(365),
|
|
42
|
-
Flag.filter(
|
|
43
|
-
(days) => days > 0,
|
|
44
|
-
() => "Days must be a positive integer",
|
|
45
|
-
),
|
|
46
|
-
),
|
|
47
|
-
force: Flag.Boolean("force").pipe(
|
|
48
|
-
Flag.withDefault(false),
|
|
49
|
-
Flag.withDescription(
|
|
50
|
-
"Replace requested leaf certificates, keeping the existing CA",
|
|
51
|
-
),
|
|
52
|
-
),
|
|
53
|
-
},
|
|
54
|
-
(options) =>
|
|
55
|
-
Certificates.generate(options).pipe(
|
|
56
|
-
Effect.andThen(Console.log(`Certificates written to ${options.out}`)),
|
|
57
|
-
Effect.catchTag("CertificateExists", (error) =>
|
|
58
|
-
CliError.UserError.make({ cause: error, userMessage: error.message }),
|
|
59
|
-
),
|
|
60
|
-
),
|
|
61
|
-
)
|
|
6
|
+
import { Array, Effect, Layer, Logger, Option, Schema } from "effect"
|
|
7
|
+
import { Argument, CliError, Command } from "effect/cli"
|
|
8
|
+
import { NodeRuntime } from "@effect/platform-node"
|
|
9
|
+
|
|
10
|
+
import { Graft } from "@graftland/graft"
|
|
11
|
+
|
|
12
|
+
import { load, run } from "./childRuntime"
|
|
13
|
+
import { platform } from "./platform"
|
|
14
|
+
import { Bootstrap } from "./runner/Bootstrap"
|
|
15
|
+
import * as Watchdog from "./runner/Watchdog"
|
|
16
|
+
import { bytes } from "./stdioChannel"
|
|
17
|
+
|
|
62
18
|
const child = Command.make(
|
|
63
19
|
"child",
|
|
64
20
|
{
|
|
@@ -87,7 +43,7 @@ const child = Command.make(
|
|
|
87
43
|
}),
|
|
88
44
|
)
|
|
89
45
|
const cli = Command.make(
|
|
90
|
-
"
|
|
46
|
+
"remote-child",
|
|
91
47
|
{
|
|
92
48
|
contract: Argument.String("contract").pipe(Argument.optional),
|
|
93
49
|
session: Argument.String("session").pipe(Argument.withDefault("local")),
|
|
@@ -96,14 +52,13 @@ const cli = Command.make(
|
|
|
96
52
|
if (Option.isNone(contract))
|
|
97
53
|
return yield* CliError.UserError.make({
|
|
98
54
|
cause: "Missing contract module",
|
|
99
|
-
userMessage:
|
|
100
|
-
"A contract module or the child/serve/certificates subcommand is required",
|
|
55
|
+
userMessage: "A contract module or the child subcommand is required",
|
|
101
56
|
})
|
|
102
57
|
const definition = yield* load(contract.value)
|
|
103
58
|
const channel = yield* bytes
|
|
104
59
|
return yield* run(definition, channel, session)
|
|
105
60
|
}),
|
|
106
|
-
).pipe(Command.withSubcommands([child
|
|
61
|
+
).pipe(Command.withSubcommands([child]))
|
|
107
62
|
|
|
108
63
|
NodeRuntime.runMain(
|
|
109
64
|
Effect.scoped(
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { loadModule } from "./loadModule"
|
|
2
|
-
import { ContractNotFound } from "./childErrors"
|
|
3
|
-
import type { Graft } from "@graftland/graft"
|
|
4
1
|
import { Effect, Logger, Option } from "effect"
|
|
5
2
|
import { RpcServer } from "effect/rpc"
|
|
3
|
+
|
|
4
|
+
import type { Graft } from "@graftland/graft"
|
|
5
|
+
|
|
6
6
|
import { fromModule, type RunnerContract } from "../Contract"
|
|
7
|
-
import * as Port from "./port"
|
|
8
|
-
import { prepare, type RunnerContract as PreparedContract } from "./contract"
|
|
9
|
-
import * as Services from "./services"
|
|
10
7
|
import * as Child from "./child"
|
|
11
|
-
import
|
|
12
|
-
import
|
|
8
|
+
import { ContractNotFound } from "./childErrors"
|
|
9
|
+
import { prepare, type RunnerContract as PreparedContract } from "./contract"
|
|
10
|
+
import { endpoint } from "./control"
|
|
11
|
+
import { loadModule } from "./loadModule"
|
|
12
|
+
import * as Port from "./port"
|
|
13
13
|
import type { Bootstrap } from "./runner/Bootstrap"
|
|
14
|
-
import { ExecutionError } from "./runner/model"
|
|
15
14
|
import { closedNormally } from "./runner/connectionEnded"
|
|
16
|
-
import {
|
|
15
|
+
import { ExecutionError } from "./runner/model"
|
|
16
|
+
import * as Multiplex from "./runner/Multiplex"
|
|
17
|
+
import * as Wire from "./runner/Wire"
|
|
18
|
+
import * as Services from "./services"
|
|
17
19
|
|
|
18
20
|
/** Import a contract in the runner installation; importing this module performs no I/O. */
|
|
19
21
|
export const load = Effect.fnUntraced(function* (specifier: string) {
|
package/src/internal/cleanup.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Fork } from "@graftland/graft"
|
|
2
1
|
import { Array, Cause, Effect, Schema, Scope } from "effect"
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
import { Fork } from "@graftland/graft"
|
|
4
|
+
import * as Release from "@graftland/graft/Release"
|
|
4
5
|
|
|
5
6
|
/** Finalizers have no typed failure channel. Keep reasons and their annotations flat. */
|
|
6
7
|
export const cleanupCause = (cause: Cause.Cause<unknown>): Cause.Cause<never> =>
|
package/src/internal/contract.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Graft, Plugin } from "@graftland/graft"
|
|
2
1
|
import { Cause, Context, Effect, Redacted, Scope } from "effect"
|
|
2
|
+
|
|
3
|
+
import { Graft, Plugin } from "@graftland/graft"
|
|
4
|
+
|
|
3
5
|
import { Credentials, type ClientCertificate, type Prepared } from "../Auth"
|
|
4
6
|
import { CredentialsError } from "../Errors"
|
|
5
7
|
import { prepare } from "./auth/token"
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Context,
|
|
3
|
+
type Effect,
|
|
4
|
+
type Option,
|
|
5
|
+
type PlatformError,
|
|
6
|
+
type Scope,
|
|
7
|
+
} from "effect"
|
|
8
|
+
|
|
3
9
|
import type { ProcessExited, TransportError } from "../Errors"
|
|
4
10
|
import type { Channel } from "../Transport"
|
|
11
|
+
|
|
5
12
|
export interface LocalOptions {
|
|
6
13
|
readonly command?: readonly [string, ...string[]]
|
|
7
14
|
readonly contractModule: string
|
package/src/internal/entry.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { Graft, Plugin, type Fork } from "@graftland/graft"
|
|
2
|
-
import { ConfigDirectory, Entry, ModuleResolver } from "@graftland/loader"
|
|
3
1
|
import {
|
|
4
2
|
Cause,
|
|
5
3
|
Effect,
|
|
6
4
|
Option,
|
|
7
5
|
Path,
|
|
8
|
-
Schema,
|
|
9
6
|
References,
|
|
7
|
+
Schema,
|
|
10
8
|
Scope,
|
|
11
9
|
String,
|
|
12
10
|
} from "effect"
|
|
11
|
+
import { SecureRandom } from "effect/crypto"
|
|
13
12
|
import { ChildProcessSpawner } from "effect/process"
|
|
13
|
+
|
|
14
|
+
import { Graft, Plugin, type Fork } from "@graftland/graft"
|
|
15
|
+
import { ConfigDirectory, Entry, ModuleResolver } from "@graftland/loader"
|
|
16
|
+
|
|
14
17
|
import * as Contract from "../Contract"
|
|
15
|
-
import {
|
|
18
|
+
import { RemoteEntryError as EntryError, MissingInstance } from "../Errors"
|
|
19
|
+
import * as Assembly from "./assembly"
|
|
20
|
+
import { children } from "./cleanup"
|
|
16
21
|
import { LocalTransport, WorkerTransport } from "./directTransport"
|
|
17
22
|
import * as Configuration from "./entryConfig"
|
|
18
|
-
import
|
|
19
|
-
import { executionPlugin } from "./execution"
|
|
23
|
+
import { executionPlugin, type ExecutionOptions } from "./execution"
|
|
20
24
|
import { follow } from "./follow"
|
|
21
|
-
import { children } from "./cleanup"
|
|
22
|
-
import { resolveEntry } from "./runner/Packages"
|
|
23
|
-
import type { LocalTarget, WorkerTarget } from "./runner/Connection"
|
|
24
|
-
import type { ExecutionOptions } from "./execution"
|
|
25
25
|
import * as Importer from "./importer"
|
|
26
|
-
import {
|
|
26
|
+
import type { LocalTarget, WorkerTarget } from "./runner/Connection"
|
|
27
|
+
import { resolveEntry } from "./runner/Packages"
|
|
27
28
|
|
|
28
29
|
export const boundary = Effect.fnUntraced(function* (field: string) {
|
|
29
30
|
const entry = yield* Entry.CurrentId
|
|
@@ -77,7 +78,11 @@ export const loadContract = Effect.fnUntraced(function* (specifier: string) {
|
|
|
77
78
|
/** Direct execution installs only its execution capability in a private realm. */
|
|
78
79
|
export const direct = (
|
|
79
80
|
provider: Plugin.Plugin,
|
|
80
|
-
consumer:
|
|
81
|
+
consumer: Effect.Effect<
|
|
82
|
+
Plugin.Plugin,
|
|
83
|
+
ModuleResolver.ModuleInvalid,
|
|
84
|
+
Scope.Scope
|
|
85
|
+
>,
|
|
81
86
|
input: Schema.Json,
|
|
82
87
|
key: typeof LocalTransport | typeof WorkerTransport,
|
|
83
88
|
): Effect.Effect<Fork.Fork<never, unknown>, never, Graft.Graft | Scope.Scope> =>
|
|
@@ -89,7 +94,8 @@ export const direct = (
|
|
|
89
94
|
yield* follow(capability, (cause) =>
|
|
90
95
|
Effect.fail(Assembly.CapabilityFailed.make({ cause })),
|
|
91
96
|
)
|
|
92
|
-
const
|
|
97
|
+
const definition = yield* consumer
|
|
98
|
+
const execution = yield* Graft.plugin(definition, input)
|
|
93
99
|
yield* follow(execution, (cause) =>
|
|
94
100
|
Effect.fail(Assembly.CapabilityFailed.make({ cause })),
|
|
95
101
|
)
|
|
@@ -132,17 +138,48 @@ const directTarget = Effect.fnUntraced(function* <
|
|
|
132
138
|
},
|
|
133
139
|
"connect",
|
|
134
140
|
)
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
|
|
142
|
+
const watch = yield* ModuleResolver.Watch
|
|
143
|
+
const resolver = yield* Effect.serviceOption(ModuleResolver.ModuleResolver)
|
|
144
|
+
const current: Effect.Effect<
|
|
145
|
+
Contract.Contract<Contract.ConfigSchema, Contract.ErrorSchema>,
|
|
146
|
+
ModuleResolver.ModuleInvalid,
|
|
147
|
+
Scope.Scope
|
|
148
|
+
> = Option.isSome(watch) && Option.isSome(resolver)
|
|
149
|
+
? resolver.value.importModule(module).pipe(
|
|
150
|
+
Effect.flatMap((namespace) =>
|
|
151
|
+
Effect.fromOption(Contract.fromModule(namespace), () =>
|
|
152
|
+
ModuleResolver.ModuleInvalid.make({
|
|
153
|
+
specifier: module,
|
|
154
|
+
cause: "Expected a remote contract",
|
|
155
|
+
}),
|
|
156
|
+
),
|
|
157
|
+
),
|
|
158
|
+
)
|
|
159
|
+
: Effect.succeed(contract)
|
|
160
|
+
const loaded = yield* current
|
|
161
|
+
const consumer = Effect.succeed(
|
|
137
162
|
executionPlugin(
|
|
138
|
-
|
|
163
|
+
loaded,
|
|
139
164
|
{ ...options, contractModule: module },
|
|
140
165
|
selected,
|
|
141
166
|
annotations,
|
|
142
167
|
),
|
|
168
|
+
)
|
|
169
|
+
if (Option.isSome(watch)) {
|
|
170
|
+
const implementation = String.startsWith("file:")(loaded.module)
|
|
171
|
+
? loaded.module
|
|
172
|
+
: yield* resolveEntry(directory, loaded.module)
|
|
173
|
+
yield* ModuleResolver.observe([module, implementation])
|
|
174
|
+
}
|
|
175
|
+
const fork = yield* direct(
|
|
176
|
+
capability.plugin,
|
|
177
|
+
consumer,
|
|
143
178
|
input.config,
|
|
144
179
|
selected._tag === "Local" ? LocalTransport : WorkerTransport,
|
|
145
180
|
)
|
|
181
|
+
|
|
182
|
+
return fork
|
|
146
183
|
})
|
|
147
184
|
const runnerTarget = Effect.fnUntraced(function* <
|
|
148
185
|
S extends Schema.Top & {
|
|
@@ -1,122 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Reference,
|
|
3
|
+
RunnerAuthentication,
|
|
4
|
+
type Authentication,
|
|
5
|
+
type Connect,
|
|
6
|
+
type Listen,
|
|
7
|
+
} from "../Config"
|
|
3
8
|
|
|
4
|
-
export
|
|
5
|
-
name: Schema.String,
|
|
6
|
-
config: Schema.optionalKey(Schema.Unknown),
|
|
7
|
-
})
|
|
8
|
-
export type Reference = typeof Reference.Type
|
|
9
|
-
const absent = Schema.optionalKey(Schema.Never)
|
|
10
|
-
const authFields = {
|
|
11
|
-
name: absent,
|
|
12
|
-
config: absent,
|
|
13
|
-
mtls: absent,
|
|
14
|
-
bearer: absent,
|
|
15
|
-
jwt: absent,
|
|
16
|
-
none: absent,
|
|
17
|
-
}
|
|
18
|
-
export const Authentication = Schema.Union([
|
|
19
|
-
Schema.Struct({
|
|
20
|
-
...authFields,
|
|
21
|
-
name: Schema.String,
|
|
22
|
-
config: Schema.optionalKey(Schema.Unknown),
|
|
23
|
-
}),
|
|
24
|
-
Schema.Struct({ ...authFields, mtls: Schema.Unknown }),
|
|
25
|
-
Schema.Struct({ ...authFields, bearer: Schema.Unknown }),
|
|
26
|
-
Schema.Struct({ ...authFields, jwt: Schema.Unknown }),
|
|
27
|
-
Schema.Struct({ ...authFields, none: Schema.Unknown }),
|
|
28
|
-
])
|
|
29
|
-
const transportFields = {
|
|
30
|
-
url: absent,
|
|
31
|
-
unix: absent,
|
|
32
|
-
command: absent,
|
|
33
|
-
stdio: absent,
|
|
34
|
-
local: absent,
|
|
35
|
-
worker: absent,
|
|
36
|
-
transport: absent,
|
|
37
|
-
}
|
|
38
|
-
const auth = Schema.optionalKey(Authentication)
|
|
39
|
-
const common = {
|
|
40
|
-
instance: Schema.optionalKey(Schema.String),
|
|
41
|
-
lease: Schema.optionalKey(PositiveDuration),
|
|
42
|
-
margin: Schema.optionalKey(PositiveDuration),
|
|
43
|
-
expect: Schema.optionalKey(
|
|
44
|
-
Schema.Struct({
|
|
45
|
-
version: Schema.optionalKey(Schema.String),
|
|
46
|
-
digest: Schema.optionalKey(Schema.String),
|
|
47
|
-
}),
|
|
48
|
-
),
|
|
49
|
-
}
|
|
50
|
-
const network = {
|
|
51
|
-
...transportFields,
|
|
52
|
-
...common,
|
|
53
|
-
auth,
|
|
54
|
-
url: Schema.String,
|
|
55
|
-
ca: Schema.optionalKey(Schema.String),
|
|
56
|
-
servername: Schema.optionalKey(Schema.String),
|
|
57
|
-
}
|
|
58
|
-
export const Connect = Schema.Union([
|
|
59
|
-
Schema.Struct(network),
|
|
60
|
-
Schema.Struct({ ...transportFields, ...common, auth, unix: Schema.String }),
|
|
61
|
-
Schema.Struct({
|
|
62
|
-
...transportFields,
|
|
63
|
-
...common,
|
|
64
|
-
command: Schema.NonEmptyArray(Schema.String),
|
|
65
|
-
auth: Schema.optionalKey(
|
|
66
|
-
Schema.Never.annotate({
|
|
67
|
-
message: "Direct and stdio transports do not accept auth",
|
|
68
|
-
}),
|
|
69
|
-
),
|
|
70
|
-
cwd: Schema.optionalKey(Schema.String),
|
|
71
|
-
env: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
|
|
72
|
-
}),
|
|
73
|
-
Schema.Struct({
|
|
74
|
-
...transportFields,
|
|
75
|
-
auth: Schema.optionalKey(
|
|
76
|
-
Schema.Never.annotate({
|
|
77
|
-
message: "Direct and stdio transports do not accept auth",
|
|
78
|
-
}),
|
|
79
|
-
),
|
|
80
|
-
local: Schema.Struct({
|
|
81
|
-
command: Schema.optionalKey(Schema.NonEmptyArray(Schema.String)),
|
|
82
|
-
}),
|
|
83
|
-
}),
|
|
84
|
-
Schema.Struct({
|
|
85
|
-
...transportFields,
|
|
86
|
-
auth: Schema.optionalKey(
|
|
87
|
-
Schema.Never.annotate({
|
|
88
|
-
message: "Direct and stdio transports do not accept auth",
|
|
89
|
-
}),
|
|
90
|
-
),
|
|
91
|
-
worker: Schema.Struct({
|
|
92
|
-
execArgv: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
93
|
-
}),
|
|
94
|
-
}),
|
|
95
|
-
Schema.Struct({ ...transportFields, ...common, auth, transport: Reference }),
|
|
96
|
-
])
|
|
97
|
-
export type Connect = typeof Connect.Type
|
|
98
|
-
export const Listen = Schema.Union([
|
|
99
|
-
Schema.Struct({
|
|
100
|
-
...transportFields,
|
|
101
|
-
auth,
|
|
102
|
-
url: Schema.String,
|
|
103
|
-
cert: Schema.optionalKey(Schema.String),
|
|
104
|
-
key: Schema.optionalKey(Schema.String),
|
|
105
|
-
}),
|
|
106
|
-
Schema.Struct({ ...transportFields, auth, unix: Schema.String }),
|
|
107
|
-
Schema.Struct({
|
|
108
|
-
...transportFields,
|
|
109
|
-
stdio: Schema.Literal(true),
|
|
110
|
-
auth: Schema.optionalKey(
|
|
111
|
-
Schema.Never.annotate({
|
|
112
|
-
message: "Direct and stdio transports do not accept auth",
|
|
113
|
-
}),
|
|
114
|
-
),
|
|
115
|
-
identity: Schema.optionalKey(Schema.String),
|
|
116
|
-
}),
|
|
117
|
-
Schema.Struct({ ...transportFields, auth, transport: Reference }),
|
|
118
|
-
])
|
|
119
|
-
export type Listen = typeof Listen.Type
|
|
9
|
+
export * from "../Config"
|
|
120
10
|
const capability = (
|
|
121
11
|
side: "host" | "runner",
|
|
122
12
|
name: string,
|
|
@@ -124,7 +14,8 @@ const capability = (
|
|
|
124
14
|
): Reference => ({ name: `@graftland/plugin-remote/${side}/${name}`, config })
|
|
125
15
|
export const authentication = (
|
|
126
16
|
side: "host" | "runner",
|
|
127
|
-
input:
|
|
17
|
+
input:
|
|
18
|
+
typeof Authentication.Type | typeof RunnerAuthentication.Type | undefined,
|
|
128
19
|
): Reference => {
|
|
129
20
|
if (input === undefined) return capability(side, "auth/none", {})
|
|
130
21
|
if (input.name !== undefined) return input
|
|
@@ -169,19 +60,6 @@ export const runnerTransport = (input: Listen): Reference => {
|
|
|
169
60
|
return capability("runner", "unix", { path: input.unix })
|
|
170
61
|
return capability("runner", "stdio", {})
|
|
171
62
|
}
|
|
172
|
-
export const Host = Schema.Struct({
|
|
173
|
-
contract: Schema.String,
|
|
174
|
-
connect: Connect,
|
|
175
|
-
config: Schema.Json.pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
|
|
176
|
-
})
|
|
177
|
-
export const Runner = Schema.Struct({
|
|
178
|
-
root: Schema.String,
|
|
179
|
-
state: Schema.String,
|
|
180
|
-
lease: Schema.optionalKey(PositiveDuration),
|
|
181
|
-
grace: Schema.optionalKey(PositiveDuration),
|
|
182
|
-
listen: Schema.Array(Listen),
|
|
183
|
-
})
|
|
184
|
-
|
|
185
63
|
export const runnerAuthentication = (input: Listen): Reference =>
|
|
186
64
|
input.stdio !== undefined
|
|
187
65
|
? capability("runner", "auth/none", {
|