@knpkv/hub-app 0.3.1 → 0.4.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.
- package/README.md +8 -3
- package/dist/handshake.d.ts +28 -0
- package/dist/handshake.d.ts.map +1 -0
- package/dist/handshake.js +59 -0
- package/dist/handshake.js.map +1 -0
- package/dist/hub-client.d.ts +5 -5
- package/dist/hub-client.d.ts.map +1 -1
- package/dist/hub-client.js +3 -4
- package/dist/hub-client.js.map +1 -1
- package/dist/main.js +3 -3
- package/dist/main.js.map +1 -1
- package/dist/manifest.d.ts +75 -10
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +57 -6
- package/dist/manifest.js.map +1 -1
- package/dist/node.d.ts +10 -19
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +56 -48
- package/dist/node.js.map +1 -1
- package/dist/standalone-shell.js +20 -20
- package/dist/wire.d.ts +7 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +16 -1
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,14 @@ An app is always its own process:
|
|
|
6
6
|
|
|
7
7
|
- **standalone**: `my-app [serve] [--port <n>] [--no-open]` listens on loopback, prints a one-time sign-in link and
|
|
8
8
|
serves a minimal shell at `/`.
|
|
9
|
-
- **attached**: `my-app --
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
- **attached**: the hub starts `my-app --attach` itself and writes one handshake line on its stdin: the endpoint to
|
|
10
|
+
listen on (a unix socket, or a named pipe on Windows), the hub's URL, a token and a secret, all fresh per start.
|
|
11
|
+
The app answers only requests that carry the secret. The hub authenticates each browser request, proxies it
|
|
12
|
+
there with the caller in `x-hub-caller` and a grant in `x-hub-grant`, and mounts the app's client in its own
|
|
13
|
+
shell. When the hub closes stdin, the app stops.
|
|
14
|
+
|
|
15
|
+
An app's package.json names its script for the hub: `"hubApp": { "bin": "dist/bin.js", "contract": 1, "services":
|
|
16
|
+
[...] }`.
|
|
12
17
|
|
|
13
18
|
## Write an app
|
|
14
19
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attached app's stdin: line 1 is the hub's {@link HubHandshake}; after it, stdin only signals stop.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - The hub writes one JSON line at spawn and keeps the pipe open. The app waits at most 5 s for it and reads at
|
|
7
|
+
* most 4 KiB, so a process started by hand with `--attach` and no hub exits with a message instead of hanging.
|
|
8
|
+
* - After line 1, further bytes are read and dropped. The end of stdin (the hub stopped it, or the hub died) is
|
|
9
|
+
* the app's stop signal: `closed` completes and the runner shuts its listener down.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { Effect, type PlatformError, Stream } from "effect";
|
|
14
|
+
import { AppStartError, HubHandshake } from "./manifest.js";
|
|
15
|
+
/** How long the app waits for line 1, and its largest size. */
|
|
16
|
+
export declare const handshakeLimits: {
|
|
17
|
+
millis: number;
|
|
18
|
+
bytes: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Start reading `stdin` in the caller's scope. `handshake` is line 1 (or `AppStartError{handshake}`); `closed`
|
|
22
|
+
* completes when stdin ends.
|
|
23
|
+
*/
|
|
24
|
+
export declare const readHandshake: (stdin: Stream.Stream<Uint8Array<ArrayBufferLike>, PlatformError.PlatformError, never>) => Effect.Effect<{
|
|
25
|
+
handshake: Effect.Effect<HubHandshake, AppStartError, never>;
|
|
26
|
+
closed: Effect.Effect<void, never, never>;
|
|
27
|
+
}, never, import("effect/Scope").Scope>;
|
|
28
|
+
//# sourceMappingURL=handshake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../src/handshake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAY,MAAM,EAAS,KAAK,aAAa,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAA;AACzF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE3D,+DAA+D;AAC/D,eAAO,MAAM,eAAe;IAAK,MAAM;IAAS,KAAK;CAAS,CAAA;AAY9D;;;GAGG;AACH,eAAO,MAAM,aAAa;;;uCAyCxB,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attached app's stdin: line 1 is the hub's {@link HubHandshake}; after it, stdin only signals stop.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - The hub writes one JSON line at spawn and keeps the pipe open. The app waits at most 5 s for it and reads at
|
|
7
|
+
* most 4 KiB, so a process started by hand with `--attach` and no hub exits with a message instead of hanging.
|
|
8
|
+
* - After line 1, further bytes are read and dropped. The end of stdin (the hub stopped it, or the hub died) is
|
|
9
|
+
* the app's stop signal: `closed` completes and the runner shuts its listener down.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { Deferred, Effect, Fiber, Ref, Schema, Stream } from "effect";
|
|
14
|
+
import { AppStartError, HubHandshake } from "./manifest.js";
|
|
15
|
+
/** How long the app waits for line 1, and its largest size. */
|
|
16
|
+
export const handshakeLimits = { millis: 5_000, bytes: 4_096 };
|
|
17
|
+
const decodeHandshake = Schema.decodeUnknownEffect(Schema.fromJsonString(HubHandshake));
|
|
18
|
+
const handshakeError = (cause) => new AppStartError({ reason: "handshake", cause });
|
|
19
|
+
const concat = (left, right) => {
|
|
20
|
+
const joined = new Uint8Array(left.length + right.length);
|
|
21
|
+
joined.set(left);
|
|
22
|
+
joined.set(right, left.length);
|
|
23
|
+
return joined;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Start reading `stdin` in the caller's scope. `handshake` is line 1 (or `AppStartError{handshake}`); `closed`
|
|
27
|
+
* completes when stdin ends.
|
|
28
|
+
*/
|
|
29
|
+
export const readHandshake = Effect.fn("HubApp.readHandshake")(function* (stdin) {
|
|
30
|
+
const first = yield* Deferred.make();
|
|
31
|
+
// The bytes of line 1 read so far, or null once line 1 is decided.
|
|
32
|
+
const pending = yield* Ref.make(new Uint8Array(0));
|
|
33
|
+
const take = (chunk) => Ref.modify(pending, (buffer) => {
|
|
34
|
+
if (buffer === null)
|
|
35
|
+
return [Effect.void, null];
|
|
36
|
+
const joined = concat(buffer, chunk);
|
|
37
|
+
const newline = joined.indexOf(10);
|
|
38
|
+
if (newline === -1 || newline > handshakeLimits.bytes) {
|
|
39
|
+
return joined.length > handshakeLimits.bytes
|
|
40
|
+
? [Deferred.fail(first, handshakeError("the handshake line is over 4 KiB")), null]
|
|
41
|
+
: [Effect.void, joined];
|
|
42
|
+
}
|
|
43
|
+
const line = new TextDecoder().decode(joined.subarray(0, newline));
|
|
44
|
+
// A fixed cause: the decoder's message would quote the line, token and secret included, into the app's log.
|
|
45
|
+
return [
|
|
46
|
+
Deferred.complete(first, decodeHandshake(line).pipe(Effect.mapError(() => handshakeError("the handshake line does not decode")))),
|
|
47
|
+
null
|
|
48
|
+
];
|
|
49
|
+
}).pipe(Effect.flatten);
|
|
50
|
+
const reader = yield* stdin.pipe(Stream.runForEach(take), Effect.exit, Effect.andThen(Deferred.fail(first, handshakeError("stdin closed before the handshake"))), Effect.forkScoped);
|
|
51
|
+
return {
|
|
52
|
+
handshake: Deferred.await(first).pipe(Effect.timeoutOrElse({
|
|
53
|
+
duration: handshakeLimits.millis,
|
|
54
|
+
orElse: () => Effect.fail(handshakeError("no handshake within 5 seconds: start this app from the hub"))
|
|
55
|
+
})),
|
|
56
|
+
closed: Fiber.await(reader).pipe(Effect.asVoid)
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=handshake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handshake.js","sourceRoot":"","sources":["../src/handshake.ts"],"names":[],"mappings":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AAmC,CAAC,CAAC,CAAC,EACzF,MAAM,CAAC,UAAU,CAClB,CAAA;IACD,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CACnC,MAAM,CAAC,aAAa,CAAC;YACnB,QAAQ,EAAE,eAAe,CAAC,MAAM;YAChC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,4DAA4D,CAAC,CAAC;SACxG,CAAC,CACH;QACD,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;KAChD,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/dist/hub-client.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
|
-
import { Context, Effect,
|
|
15
|
+
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
16
16
|
import { HttpClient } from "effect/http";
|
|
17
17
|
import { type AppId, GrantInvalid, type ShellService, ShellServiceUnavailable } from "./manifest.js";
|
|
18
18
|
import { type FleetReadKind, HostInfo, JobAccepted } from "./wire.js";
|
|
@@ -40,13 +40,13 @@ export declare const standaloneShellServices: (host: HostInfo) => ShellServiceCa
|
|
|
40
40
|
export interface AttachedOptions {
|
|
41
41
|
readonly app: AppId;
|
|
42
42
|
readonly hubUrl: string;
|
|
43
|
-
/**
|
|
44
|
-
readonly
|
|
43
|
+
/** This spawn's hub token, from the handshake. */
|
|
44
|
+
readonly token: Redacted.Redacted<string>;
|
|
45
45
|
readonly declared: ReadonlyArray<ShellService>;
|
|
46
46
|
}
|
|
47
47
|
/** Attached: every call goes to the hub's loopback listener with this app's current token. */
|
|
48
|
-
export declare const attachedShellServices: (options: AttachedOptions) => Effect.Effect<ShellServiceCalls, never,
|
|
49
|
-
export declare const attachedLayer: (options: AttachedOptions) => Layer.Layer<ShellServices, never,
|
|
48
|
+
export declare const attachedShellServices: (options: AttachedOptions) => Effect.Effect<ShellServiceCalls, never, HttpClient.HttpClient>;
|
|
49
|
+
export declare const attachedLayer: (options: AttachedOptions) => Layer.Layer<ShellServices, never, HttpClient.HttpClient>;
|
|
50
50
|
export declare const standaloneLayer: (host: HostInfo) => Layer.Layer<ShellServices, never, never>;
|
|
51
51
|
export {};
|
|
52
52
|
//# sourceMappingURL=hub-client.d.ts.map
|
package/dist/hub-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-client.d.ts","sourceRoot":"","sources":["../src/hub-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"hub-client.d.ts","sourceRoot":"","sources":["../src/hub-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACjE,OAAO,EAAE,UAAU,EAA8C,MAAM,aAAa,CAAA;AACpF,OAAO,EAAE,KAAK,KAAK,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAEpG,OAAO,EAAsC,KAAK,aAAa,EAAE,QAAQ,EAAc,WAAW,EAAE,MAAM,WAAW,CAAA;;;;;AAErH,sGAAsG;AACtG,qBAAa,mBAAoB,SAAQ,wBAGvC;CAAG;AAEL,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAA;IAC/D,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,CAClB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,uBAAuB,GAAG,mBAAmB,CAAC,CAAA;IAC9E,qEAAqE;IACrE,QAAQ,CAAC,SAAS,EAAE,CAClB,OAAO,EAAE,MAAM,CAAC,IAAI,KACjB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,uBAAuB,GAAG,mBAAmB,GAAG,YAAY,CAAC,CAAA;IAC7F,iFAAiF;IACjF,QAAQ,CAAC,SAAS,EAAE,CAClB,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,IAAI,EAAE,MAAM,KACT,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,uBAAuB,GAAG,mBAAmB,GAAG,YAAY,CAAC,CAAA;CACvF;;AAED,qBAAa,aAAc,SAAQ,kBAElC;CAAG;AAEJ,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,SAAU,QAAQ,KAAG,iBAQxD,CAAA;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACzC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;CAC/C;AAED,8FAA8F;AAC9F,eAAO,MAAM,qBAAqB,8FA2FhC,CAAA;AAEF,eAAO,MAAM,aAAa,YAAa,eAAe,6DAAgE,CAAA;AAEtH,eAAO,MAAM,eAAe,SAAU,QAAQ,6CAAgE,CAAA"}
|
package/dist/hub-client.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
|
-
import { Context, Effect,
|
|
15
|
+
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
16
16
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
17
17
|
import { GrantInvalid, ShellServiceUnavailable } from "./manifest.js";
|
|
18
18
|
import { CurrentGrant } from "./route.js";
|
|
@@ -38,9 +38,8 @@ export const standaloneShellServices = (host) => {
|
|
|
38
38
|
/** Attached: every call goes to the hub's loopback listener with this app's current token. */
|
|
39
39
|
export const attachedShellServices = Effect.fn("HubApp.attachedShellServices")(function* (options) {
|
|
40
40
|
const client = yield* HttpClient.HttpClient;
|
|
41
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
42
41
|
const url = (path) => new URL(path, options.hubUrl).href;
|
|
43
|
-
const authorized = (request) =>
|
|
42
|
+
const authorized = (request) => request.pipe(HttpClientRequest.bearerToken(Redacted.value(options.token)), HttpClientRequest.setHeader(hubHeaders.app, options.app));
|
|
44
43
|
const declare = (service) => options.declared.includes(service)
|
|
45
44
|
? Effect.void
|
|
46
45
|
: Effect.fail(new ShellServiceUnavailable({ service, reason: "undeclared" }));
|
|
@@ -48,7 +47,7 @@ export const attachedShellServices = Effect.fn("HubApp.attachedShellServices")(f
|
|
|
48
47
|
/** One request; a refusal body maps to its typed failure, anything else non-2xx is the hub being down. */
|
|
49
48
|
const send = (service, request, success) => Effect.gen(function* () {
|
|
50
49
|
yield* declare(service);
|
|
51
|
-
const response = yield* request.pipe(Effect.
|
|
50
|
+
const response = yield* request.pipe(Effect.map(authorized), Effect.flatMap((built) => client.execute(built)), Effect.mapError(hubDown(service)));
|
|
52
51
|
const body = yield* response.json.pipe(Effect.mapError(hubDown(service)));
|
|
53
52
|
if (response.status >= 200 && response.status < 300) {
|
|
54
53
|
return yield* Schema.decodeUnknownEffect(success)(body).pipe(Effect.mapError(hubDown(service)));
|
package/dist/hub-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-client.js","sourceRoot":"","sources":["../src/hub-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"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,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAClB,CAAA;QACH,CAAC,CAAC;KACL,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAwB,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAA;AAEtH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAc,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAA"}
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The process boundary of every app: `runApp(app, platform)` reads argv,
|
|
2
|
+
* The process boundary of every app: `runApp(app, platform)` reads argv, stdin and the terminal,
|
|
3
3
|
* then serves until SIGINT or SIGTERM. `platform` supplies whatever the app's handlers need beyond
|
|
4
4
|
* `ShellServices`. Call it from the app's `bin` entry.
|
|
5
5
|
*
|
|
@@ -13,11 +13,11 @@ import process from "node:process";
|
|
|
13
13
|
import { readRunMode, serveApp } from "./node.js";
|
|
14
14
|
export const runApp = (app, platform) => {
|
|
15
15
|
const program = Effect.gen(function* () {
|
|
16
|
-
const mode = readRunMode(app.manifest, process.argv.slice(2)
|
|
16
|
+
const mode = readRunMode(app.manifest, process.argv.slice(2));
|
|
17
17
|
if (Result.isFailure(mode))
|
|
18
18
|
return yield* mode.failure;
|
|
19
19
|
const launch = browserLaunch({
|
|
20
|
-
noOpen: mode.success._tag
|
|
20
|
+
noOpen: mode.success._tag !== "Standalone" || !mode.success.open,
|
|
21
21
|
browser: process.env.BROWSER,
|
|
22
22
|
ci: process.env.CI,
|
|
23
23
|
interactive: process.stdout.isTTY === true
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],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AAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC7D,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAA;QACtD,MAAM,MAAM,GAAG,aAAa,CAAC;YAC3B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI;YAChE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;YAC5B,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;YAClB,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI;SAC3C,CAAC,CAAA;QACF,OAAO,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACnD,CAAC,CAAC,CAAA;IACF,WAAW,CAAC,OAAO,CACjB,OAAO,CAAC,IAAI,CACV,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,OAAO,CACZ,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CACvE,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CACvC,CACF,CACF,CACF,CAAA;AACH,CAAC,CAAA"}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* **Mental model**
|
|
5
5
|
*
|
|
6
|
-
* - `apps.json` (written by
|
|
7
|
-
* `GET /app/manifest`, so the file can't disagree with
|
|
6
|
+
* - `apps.json` (written by the `herdr-hub apps` CLI or by nix) says which packages are installed, where, and how
|
|
7
|
+
* the hub runs them. What an app *is* comes from its own `GET /app/manifest`, so the file can't disagree with
|
|
8
|
+
* the code.
|
|
8
9
|
* - `contract` is one integer for the whole shell ↔ app surface: manifest shape, wire paths, shell
|
|
9
10
|
* services and `ShellContext`. Additive changes keep it; the hub supports the current and previous one.
|
|
10
11
|
* - Every per-app problem becomes an {@link AppState} `Unavailable`, never a hub failure.
|
|
@@ -61,17 +62,81 @@ export interface AppManifest extends Schema.Schema.Type<typeof AppManifest> {
|
|
|
61
62
|
}
|
|
62
63
|
/** What an app declares in code; the runner adds `client` from its build output. */
|
|
63
64
|
export type AppManifestInput = Omit<AppManifest, "client">;
|
|
64
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* One installed app in `apps.json` v2: the prefix holding its `node_modules`, the script the hub runs with its
|
|
67
|
+
* own node, and how it runs.
|
|
68
|
+
*/
|
|
69
|
+
export declare const InstalledApp: Schema.Struct<{
|
|
70
|
+
readonly id: Schema.brand<Schema.String, "AppId">;
|
|
71
|
+
readonly package: Schema.String;
|
|
72
|
+
/** Exact, resolved. */
|
|
73
|
+
readonly version: Schema.String;
|
|
74
|
+
/** The prefix holding `node_modules`. */
|
|
75
|
+
readonly dir: Schema.String;
|
|
76
|
+
/** The app's script relative to `dir`: `node_modules/<package>/<hubApp.bin>`. Run with the hub's own node. */
|
|
77
|
+
readonly bin: Schema.String;
|
|
78
|
+
readonly enabled: Schema.Boolean;
|
|
79
|
+
/** V8 heap cap (`--max-old-space-size`); native and RSS growth are not capped. */
|
|
80
|
+
readonly memoryMb: Schema.Int;
|
|
81
|
+
readonly allowScripts: Schema.Boolean;
|
|
82
|
+
}>;
|
|
83
|
+
export interface InstalledApp extends Schema.Schema.Type<typeof InstalledApp> {
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `apps.json` (v2; there is no v1 reader): the hub starts and supervises each app itself. One writer, named in the file: the `herdr-hub
|
|
87
|
+
* apps` CLI (`cli`) or nix (`nix`, which the CLI then refuses to edit). `trust.scopes` holds npm scopes
|
|
88
|
+
* (`@knpkv`) or exact package names the CLI installs from without `apps trust add`.
|
|
89
|
+
*/
|
|
65
90
|
export declare const AppsConfig: Schema.Struct<{
|
|
66
|
-
readonly v: Schema.Literal<
|
|
91
|
+
readonly v: Schema.Literal<2>;
|
|
92
|
+
readonly managedBy: Schema.Literals<readonly ["cli", "nix"]>;
|
|
93
|
+
readonly trust: Schema.Struct<{
|
|
94
|
+
readonly scopes: Schema.$Array<Schema.String>;
|
|
95
|
+
}>;
|
|
67
96
|
readonly apps: Schema.$Array<Schema.Struct<{
|
|
68
97
|
readonly id: Schema.brand<Schema.String, "AppId">;
|
|
69
|
-
readonly
|
|
98
|
+
readonly package: Schema.String;
|
|
99
|
+
/** Exact, resolved. */
|
|
100
|
+
readonly version: Schema.String;
|
|
101
|
+
/** The prefix holding `node_modules`. */
|
|
102
|
+
readonly dir: Schema.String;
|
|
103
|
+
/** The app's script relative to `dir`: `node_modules/<package>/<hubApp.bin>`. Run with the hub's own node. */
|
|
104
|
+
readonly bin: Schema.String;
|
|
105
|
+
readonly enabled: Schema.Boolean;
|
|
106
|
+
/** V8 heap cap (`--max-old-space-size`); native and RSS growth are not capped. */
|
|
107
|
+
readonly memoryMb: Schema.Int;
|
|
108
|
+
readonly allowScripts: Schema.Boolean;
|
|
70
109
|
}>>;
|
|
71
110
|
}>;
|
|
72
111
|
export interface AppsConfig extends Schema.Schema.Type<typeof AppsConfig> {
|
|
73
112
|
}
|
|
74
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Line 1 of an attached app's stdin, written by the hub at spawn; the pipe then stays open until stop. The
|
|
115
|
+
* endpoint is a socket path or a `\\.\pipe\` name picked per spawn. The token and secret are fresh per spawn
|
|
116
|
+
* and never touch disk, env or argv.
|
|
117
|
+
*/
|
|
118
|
+
export declare const HubHandshake: Schema.Struct<{
|
|
119
|
+
readonly v: Schema.Literal<1>;
|
|
120
|
+
readonly endpoint: Schema.String;
|
|
121
|
+
readonly hubUrl: Schema.String;
|
|
122
|
+
readonly hubToken: Schema.RedactedFromValue<Schema.String>;
|
|
123
|
+
readonly appSecret: Schema.RedactedFromValue<Schema.String>;
|
|
124
|
+
}>;
|
|
125
|
+
export interface HubHandshake extends Schema.Schema.Type<typeof HubHandshake> {
|
|
126
|
+
}
|
|
127
|
+
/** The `hubApp` field of an app's package.json: what the installer checks before and after install. */
|
|
128
|
+
export declare const HubAppPackageField: Schema.Struct<{
|
|
129
|
+
/**
|
|
130
|
+
* The script the hub runs, as a file path inside the package (`dist/bin.js`). Not a `bin` key: the hub runs it
|
|
131
|
+
* with its own node, so it never depends on npm's bin links or `.cmd` shims.
|
|
132
|
+
*/
|
|
133
|
+
readonly bin: Schema.String;
|
|
134
|
+
readonly contract: Schema.Literals<readonly [1]>;
|
|
135
|
+
readonly services: Schema.$Array<Schema.Literals<readonly ["fleet.read", "host", "jobs.submit", "relay.post", "needs-you", "badge"]>>;
|
|
136
|
+
}>;
|
|
137
|
+
export interface HubAppPackageField extends Schema.Schema.Type<typeof HubAppPackageField> {
|
|
138
|
+
}
|
|
139
|
+
export declare const AppUnavailableReason: Schema.Literals<readonly ["starting", "not_running", "crashloop", "disabled", "install_missing", "health", "timeout", "invalid_manifest", "id_mismatch", "incompatible", "duplicate", "client_failed"]>;
|
|
75
140
|
export type AppUnavailableReason = typeof AppUnavailableReason.Type;
|
|
76
141
|
/**
|
|
77
142
|
* The hub's view of one registered app, served by `GET /v1/apps`. `Unavailable` keeps the last good
|
|
@@ -140,7 +205,7 @@ export declare const AppState: Schema.Union<readonly [Schema.TaggedStruct<"Ready
|
|
|
140
205
|
readonly defaultPort: Schema.Int;
|
|
141
206
|
}>;
|
|
142
207
|
}>>;
|
|
143
|
-
readonly reason: Schema.Literals<readonly ["not_running", "timeout", "invalid_manifest", "id_mismatch", "incompatible", "duplicate", "client_failed"]>;
|
|
208
|
+
readonly reason: Schema.Literals<readonly ["starting", "not_running", "crashloop", "disabled", "install_missing", "health", "timeout", "invalid_manifest", "id_mismatch", "incompatible", "duplicate", "client_failed"]>;
|
|
144
209
|
readonly detail: Schema.String;
|
|
145
210
|
}>]>;
|
|
146
211
|
export type AppState = typeof AppState.Type;
|
|
@@ -209,7 +274,7 @@ export declare const AppStates: Schema.Struct<{
|
|
|
209
274
|
readonly defaultPort: Schema.Int;
|
|
210
275
|
}>;
|
|
211
276
|
}>>;
|
|
212
|
-
readonly reason: Schema.Literals<readonly ["not_running", "timeout", "invalid_manifest", "id_mismatch", "incompatible", "duplicate", "client_failed"]>;
|
|
277
|
+
readonly reason: Schema.Literals<readonly ["starting", "not_running", "crashloop", "disabled", "install_missing", "health", "timeout", "invalid_manifest", "id_mismatch", "incompatible", "duplicate", "client_failed"]>;
|
|
213
278
|
readonly detail: Schema.String;
|
|
214
279
|
}>]>>;
|
|
215
280
|
}>;
|
|
@@ -223,7 +288,7 @@ export declare class AppsConfigInvalid extends AppsConfigInvalid_base {
|
|
|
223
288
|
}
|
|
224
289
|
declare const AppProbeFailed_base: Schema.Class<AppProbeFailed, Schema.TaggedStruct<"AppProbeFailed", {
|
|
225
290
|
readonly id: Schema.brand<Schema.String, "AppId">;
|
|
226
|
-
readonly reason: Schema.Literals<readonly ["not_running", "timeout", "invalid_manifest", "id_mismatch", "incompatible", "duplicate", "client_failed"]>;
|
|
291
|
+
readonly reason: Schema.Literals<readonly ["starting", "not_running", "crashloop", "disabled", "install_missing", "health", "timeout", "invalid_manifest", "id_mismatch", "incompatible", "duplicate", "client_failed"]>;
|
|
227
292
|
readonly detail: Schema.String;
|
|
228
293
|
}>, import("effect/Cause").YieldableError>;
|
|
229
294
|
/** One probe's outcome other than `Ready`. */
|
|
@@ -252,7 +317,7 @@ declare const ShellServiceUnavailable_base: Schema.Class<ShellServiceUnavailable
|
|
|
252
317
|
export declare class ShellServiceUnavailable extends ShellServiceUnavailable_base {
|
|
253
318
|
}
|
|
254
319
|
declare const AppStartError_base: Schema.Class<AppStartError, Schema.TaggedStruct<"AppStartError", {
|
|
255
|
-
readonly reason: Schema.Literals<readonly ["invalid_manifest", "invalid_arguments", "listen", "layer"]>;
|
|
320
|
+
readonly reason: Schema.Literals<readonly ["invalid_manifest", "invalid_arguments", "listen", "layer", "handshake"]>;
|
|
256
321
|
readonly cause: Schema.Defect;
|
|
257
322
|
}>, import("effect/Cause").YieldableError>;
|
|
258
323
|
/** The app couldn't start: its manifest, its listener, or its handler layer. */
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,gGAAgG;AAChG,eAAO,MAAM,WAAW,+BAAuB,CAAA;AAC/C,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD,eAAO,MAAM,KAAK,sCAEjB,CAAA;AACD,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAErC,0GAA0G;AAC1G,eAAO,MAAM,YAAY,qGAA6F,CAAA;AACtH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAInD,kGAAkG;AAClG,eAAO,MAAM,eAAe;;;EAG1B,CAAA;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA;AAEzD,6FAA6F;AAC7F,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EActB,CAAA;AACF,MAAM,WAAW,WAAY,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC;CAAG;AAE9E,oFAAoF;AACpF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;AAE1D;;;GAGG;AACH,eAAO,MAAM,YAAY;;;IAGvB,uBAAuB;;IAEv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AAa,iBAAkB,SAAQ,sBAErC;CAAG;;;;;;AAEL,8CAA8C;AAC9C,qBAAa,cAAe,SAAQ,mBAIlC;CAAG;;;;AAEL,sGAAsG;AACtG,qBAAa,cAAe,SAAQ,mBAAqE;CAAG;;;;AAE5G;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAEhC;CAAG;;;;;AAEL,oGAAoG;AACpG,qBAAa,uBAAwB,SAAQ,4BAM5C;CAAG;;;;;AAEJ,gFAAgF;AAChF,qBAAa,aAAc,SAAQ,kBAGjC;CAAG"}
|
package/dist/manifest.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* **Mental model**
|
|
5
5
|
*
|
|
6
|
-
* - `apps.json` (written by
|
|
7
|
-
* `GET /app/manifest`, so the file can't disagree with
|
|
6
|
+
* - `apps.json` (written by the `herdr-hub apps` CLI or by nix) says which packages are installed, where, and how
|
|
7
|
+
* the hub runs them. What an app *is* comes from its own `GET /app/manifest`, so the file can't disagree with
|
|
8
|
+
* the code.
|
|
8
9
|
* - `contract` is one integer for the whole shell ↔ app surface: manifest shape, wire paths, shell
|
|
9
10
|
* services and `ShellContext`. Additive changes keep it; the hub supports the current and previous one.
|
|
10
11
|
* - Every per-app problem becomes an {@link AppState} `Unavailable`, never a hub failure.
|
|
@@ -40,14 +41,64 @@ export const AppManifest = Schema.Struct({
|
|
|
40
41
|
}),
|
|
41
42
|
standalone: Schema.Struct({ defaultPort: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65_535 })) })
|
|
42
43
|
});
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* One installed app in `apps.json` v2: the prefix holding its `node_modules`, the script the hub runs with its
|
|
46
|
+
* own node, and how it runs.
|
|
47
|
+
*/
|
|
48
|
+
export const InstalledApp = Schema.Struct({
|
|
49
|
+
id: AppId,
|
|
50
|
+
package: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(214)),
|
|
51
|
+
/** Exact, resolved. */
|
|
52
|
+
version: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(64)),
|
|
53
|
+
/** The prefix holding `node_modules`. */
|
|
54
|
+
dir: Schema.String.check(Schema.isNonEmpty()),
|
|
55
|
+
/** The app's script relative to `dir`: `node_modules/<package>/<hubApp.bin>`. Run with the hub's own node. */
|
|
56
|
+
bin: Schema.String.check(Schema.isNonEmpty()),
|
|
57
|
+
enabled: Schema.Boolean,
|
|
58
|
+
/** V8 heap cap (`--max-old-space-size`); native and RSS growth are not capped. */
|
|
59
|
+
memoryMb: Schema.Int.check(Schema.isBetween({ minimum: 64, maximum: 16_384 })),
|
|
60
|
+
allowScripts: Schema.Boolean
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* `apps.json` (v2; there is no v1 reader): the hub starts and supervises each app itself. One writer, named in the file: the `herdr-hub
|
|
64
|
+
* apps` CLI (`cli`) or nix (`nix`, which the CLI then refuses to edit). `trust.scopes` holds npm scopes
|
|
65
|
+
* (`@knpkv`) or exact package names the CLI installs from without `apps trust add`.
|
|
66
|
+
*/
|
|
45
67
|
export const AppsConfig = Schema.Struct({
|
|
68
|
+
v: Schema.Literal(2),
|
|
69
|
+
managedBy: Schema.Literals(["cli", "nix"]),
|
|
70
|
+
trust: Schema.Struct({ scopes: Schema.Array(Schema.String) }),
|
|
71
|
+
apps: Schema.Array(InstalledApp)
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Line 1 of an attached app's stdin, written by the hub at spawn; the pipe then stays open until stop. The
|
|
75
|
+
* endpoint is a socket path or a `\\.\pipe\` name picked per spawn. The token and secret are fresh per spawn
|
|
76
|
+
* and never touch disk, env or argv.
|
|
77
|
+
*/
|
|
78
|
+
export const HubHandshake = Schema.Struct({
|
|
46
79
|
v: Schema.Literal(1),
|
|
47
|
-
|
|
80
|
+
endpoint: Schema.String.check(Schema.isNonEmpty()),
|
|
81
|
+
hubUrl: Schema.String.check(Schema.isNonEmpty()),
|
|
82
|
+
hubToken: Schema.RedactedFromValue(Schema.String),
|
|
83
|
+
appSecret: Schema.RedactedFromValue(Schema.String)
|
|
84
|
+
});
|
|
85
|
+
/** The `hubApp` field of an app's package.json: what the installer checks before and after install. */
|
|
86
|
+
export const HubAppPackageField = Schema.Struct({
|
|
87
|
+
/**
|
|
88
|
+
* The script the hub runs, as a file path inside the package (`dist/bin.js`). Not a `bin` key: the hub runs it
|
|
89
|
+
* with its own node, so it never depends on npm's bin links or `.cmd` shims.
|
|
90
|
+
*/
|
|
91
|
+
bin: Schema.String.check(Schema.isNonEmpty()),
|
|
92
|
+
contract: AppContract,
|
|
93
|
+
services: Schema.Array(ShellService)
|
|
48
94
|
});
|
|
49
95
|
export const AppUnavailableReason = Schema.Literals([
|
|
96
|
+
"starting",
|
|
50
97
|
"not_running",
|
|
98
|
+
"crashloop",
|
|
99
|
+
"disabled",
|
|
100
|
+
"install_missing",
|
|
101
|
+
"health",
|
|
51
102
|
"timeout",
|
|
52
103
|
"invalid_manifest",
|
|
53
104
|
"id_mismatch",
|
|
@@ -100,7 +151,7 @@ export class ShellServiceUnavailable extends Schema.TaggedError()("ShellServiceU
|
|
|
100
151
|
}
|
|
101
152
|
/** The app couldn't start: its manifest, its listener, or its handler layer. */
|
|
102
153
|
export class AppStartError extends Schema.TaggedError()("AppStartError", {
|
|
103
|
-
reason: Schema.Literals(["invalid_manifest", "invalid_arguments", "listen", "layer"]),
|
|
154
|
+
reason: Schema.Literals(["invalid_manifest", "invalid_arguments", "listen", "layer", "handshake"]),
|
|
104
155
|
cause: Schema.Defect()
|
|
105
156
|
}) {
|
|
106
157
|
}
|
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG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,WAAW,EAAkB,CAAC,gBAAgB,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;CAAG;AAE5G;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,EAAgB,CAAC,cAAc,EAAE;IACnF,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;CACrF,CAAC;CAAG;AAEL,oGAAoG;AACpG,MAAM,OAAO,uBAAwB,SAAQ,MAAM,CAAC,WAAW,EAA2B,CACxF,yBAAyB,EACzB;IACE,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;CAClE,CACF;CAAG;AAEJ,gFAAgF;AAChF,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,WAAW,EAAiB,CAAC,eAAe,EAAE;IACtF,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAClG,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;CACvB,CAAC;CAAG"}
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BrowserLaunch } from "@knpkv/browser-pairing/launch";
|
|
2
|
-
import { Effect, FileSystem, Layer, Path, Result, Schema } from "effect";
|
|
2
|
+
import { Effect, FileSystem, Layer, Path, Result, Schema, Stdio } from "effect";
|
|
3
3
|
import type { ShellServices } from "./hub-client.js";
|
|
4
4
|
import { type AppManifestInput, AppStartError } from "./manifest.js";
|
|
5
5
|
import { ModuleHandlers } from "./route.js";
|
|
@@ -14,37 +14,28 @@ export interface AppServer<E, R> {
|
|
|
14
14
|
/** The built client: a directory holding `client.js` and, optionally, `client.css`. */
|
|
15
15
|
readonly clientDirectory: string;
|
|
16
16
|
}
|
|
17
|
-
export declare const RunMode: Schema.Union<readonly [Schema.TaggedStruct<"Attached", {
|
|
18
|
-
readonly socket: Schema.String;
|
|
19
|
-
readonly hubUrl: Schema.String;
|
|
20
|
-
readonly tokenFile: Schema.String;
|
|
21
|
-
}>, Schema.TaggedStruct<"Standalone", {
|
|
17
|
+
export declare const RunMode: Schema.Union<readonly [Schema.TaggedStruct<"Attached", {}>, Schema.TaggedStruct<"Standalone", {
|
|
22
18
|
readonly port: Schema.Int;
|
|
23
19
|
readonly open: Schema.Boolean;
|
|
24
20
|
}>]>;
|
|
25
21
|
export type RunMode = typeof RunMode.Type;
|
|
26
|
-
/** Read the mode from argv
|
|
27
|
-
export declare const readRunMode: (manifest: AppManifestInput, argv: ReadonlyArray<string
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
readonly tokenFile: string;
|
|
34
|
-
}) => Effect.Effect<never, AppStartError | import("effect/PlatformError").PlatformError | import("effect/http/HttpServerError").ServeError, FileSystem.FileSystem | import("effect/http/HttpClient").HttpClient | Path.Path | import("effect/Scope").Scope | Exclude<R, ShellServices>>;
|
|
22
|
+
/** Read the mode from argv. `--attach` means attached; anything else is standalone. */
|
|
23
|
+
export declare const readRunMode: (manifest: AppManifestInput, argv: ReadonlyArray<string>) => Result.Result<RunMode, AppStartError>;
|
|
24
|
+
/**
|
|
25
|
+
* Attached mode: read the hub's handshake from stdin, listen on its endpoint, and stop when stdin ends. Needs no
|
|
26
|
+
* browser opener.
|
|
27
|
+
*/
|
|
28
|
+
export declare const serveAttached: <E, R>(app: AppServer<E, R>) => Effect.Effect<void, AppStartError | import("effect/PlatformError").PlatformError | import("effect/http/HttpServerError").ServeError, FileSystem.FileSystem | import("effect/http/HttpClient").HttpClient | Path.Path | import("effect/Scope").Scope | Stdio.Stdio | Exclude<R, ShellServices>>;
|
|
35
29
|
/**
|
|
36
30
|
* Serve the app in `mode` until interrupted. `launch` says whether standalone mode opens a browser for its
|
|
37
31
|
* sign-in link; the executable decides it from its terminal and environment.
|
|
38
32
|
*/
|
|
39
33
|
export declare const serveApp: <E, R>(app: AppServer<E, R>, mode: {
|
|
40
34
|
readonly _tag: "Attached";
|
|
41
|
-
readonly socket: string;
|
|
42
|
-
readonly hubUrl: string;
|
|
43
|
-
readonly tokenFile: string;
|
|
44
35
|
} | {
|
|
45
36
|
readonly _tag: "Standalone";
|
|
46
37
|
readonly port: number;
|
|
47
38
|
readonly open: boolean;
|
|
48
|
-
}, launch: BrowserLaunch) => Effect.Effect<void, AppStartError, import("@knpkv/browser-pairing/launch").BrowserOpener | import("effect/Crypto").Crypto | FileSystem.FileSystem | import("effect/http/HttpClient").HttpClient | Path.Path | import("effect/Scope").Scope |
|
|
39
|
+
}, launch: BrowserLaunch) => Effect.Effect<void, AppStartError, import("@knpkv/browser-pairing/launch").BrowserOpener | import("effect/Crypto").Crypto | FileSystem.FileSystem | import("effect/http/HttpClient").HttpClient | Path.Path | import("effect/Scope").Scope | Stdio.Stdio | Exclude<R, ShellServices>>;
|
|
49
40
|
export { runApp } from "./main.js";
|
|
50
41
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAA4B,MAAM,+BAA+B,CAAA;AAG5F,OAAO,EAAqB,MAAM,EAAE,UAAU,EAAE,KAAK,EAAU,IAAI,EAAY,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAcpH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAe,KAAK,gBAAgB,EAAE,aAAa,EAAE,MAAM,eA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