posipaki 0.33.1 → 0.35.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.
@@ -1,4 +1,5 @@
1
1
  import { r as Message } from "./types-CsE8xK3a.js";
2
+ import { h as MethodOptions, l as ActorDefinition, p as HandlerOptions, v as ReflectionOptions } from "./hooks-CfQ8EhKW.js";
2
3
  //#region src/remote/channel.d.ts
3
4
  interface StringTransport {
4
5
  send(frame: string): void | Promise<void>;
@@ -38,5 +39,9 @@ declare function isExit(msg: Record<string, unknown>): msg is {
38
39
  };
39
40
  };
40
41
  //#endregion
41
- export { isMsg as a, isInit as i, StringTransport as n, isProto as o, isExit as r, isState as s, Channel as t };
42
- //# sourceMappingURL=channel-HCjngMq_.d.ts.map
42
+ //#region src/remote/client.d.ts
43
+ type ClientSpawner<Args> = (args: Args) => Promise<Channel>;
44
+ declare function remoteClient<Args, State, InMsg extends Message, OutMsg extends Message, Methods extends MethodOptions = MethodOptions, Handlers extends HandlerOptions<InMsg> = HandlerOptions<InMsg>, R extends ReflectionOptions = ReflectionOptions>(name: string, spawner: ClientSpawner<Args>): ActorDefinition<Args, State, InMsg, OutMsg, R>;
45
+ //#endregion
46
+ export { isExit as a, isProto as c, StringTransport as i, isState as l, remoteClient as n, isInit as o, Channel as r, isMsg as s, ClientSpawner as t };
47
+ //# sourceMappingURL=client-DHI-6XPF.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-DHI-6XPF.d.ts","names":[],"sources":["../src/remote/channel.ts","../src/remote/client.ts"],"mappings":";;;UAUiB;EACf,KAAK,uBAAuB;EAC5B,UAAU,UAAU;EACpB;;EAEA,QAAQ;EACR,SAAS;;UAGM;EACf,KAAK,OAAO,iCAAiC;EAC7C,UAAU,UAAU,OAAO;EAC3B;;EAEA,QAAQ;EACR,SAAS;;iBAKK,QAAQ,KAAK,0BAA0B;EAAS;;iBAGhD,OAAO,KAAK,0BAA0B;EAAS,OAAO;;iBAGtD,QAAQ,KAAK,0BAA0B;EAAS,QAAQ;;iBAGxD,MACd,KAAK,0BACJ;EAAS;IAAQ;IAAkB,MAAM;;;iBAG5B,OACd,KAAK,0BACJ;EAAS;IAAS;IAAc;;;;;KC/BvB,cAAc,SAAS,MAAM,SAAS,QAAQ;iBAE1C,aACd,MACA,OACA,cAAc,SACd,eAAe,SACf,gBAAgB,gBAAgB,eAChC,iBAAiB,eAAe,SAAS,eAAe,QACxD,UAAU,oBAAoB,mBAE9B,cACA,SAAS,cAAc,QACtB,gBAAgB,MAAM,OAAO,OAAO,QAAQ"}
@@ -1,12 +1,9 @@
1
- import { t as LIB_VERSION } from "./version-W7guWJeR.js";
2
1
  import { c as isProto, i as json1Channel, t as VERSION } from "./json1-DS3xxg13.js";
3
2
  import { mkdtemp, open, rm } from "node:fs/promises";
4
3
  import * as readline from "node:readline";
5
4
  import { execFile, spawn } from "node:child_process";
6
- import { createHash } from "node:crypto";
7
5
  import { tmpdir } from "node:os";
8
- import { dirname, extname, join } from "node:path";
9
- import { fileURLToPath } from "node:url";
6
+ import { basename, join } from "node:path";
10
7
  import { createReadStream, createWriteStream } from "node:fs";
11
8
  import { promisify } from "node:util";
12
9
  //#region src/remote/transports/fifo.ts
@@ -375,228 +372,37 @@ async function serverChannel(streams) {
375
372
  return channel;
376
373
  }
377
374
  //#endregion
378
- //#region src/remote/kit.ts
379
- /** Runtimes a kit is happy to be run with, best first. A caller may override. */
380
- const DEFAULT_RUNTIMES = [
381
- "node",
382
- "nodejs",
383
- "bun"
384
- ];
385
- /** Layout of a staged kit — the contract's own version, recorded in `version.json`. */
386
- const KIT_LAYOUT = 1;
387
- /** Where kits live on a host, relative to `$HOME`, unless the caller says otherwise. */
388
- const DEFAULT_KIT_PARENT = "bin/posipaki";
389
- /** Hex sha256 of some content. */
390
- function sha256Hex(content) {
391
- return createHash("sha256").update(content).digest("hex");
392
- }
393
- /** The directory name a kit with these contents, this owner and this posipaki gets. */
394
- function kitName(app, manifestHash) {
395
- return `${app.name}-${app.version}-posipaki-${LIB_VERSION}-${manifestHash.slice(0, 8)}`;
396
- }
397
- /**
398
- * One line naming a staged artifact: what it is, which posipaki it speaks, which
399
- * kit layout it was built for. A client that staged it can judge compatibility
400
- * from this alone — nothing else is claimed.
401
- */
402
- function versionLine(app, role, proto) {
403
- return `${app.name}-${role} ${app.version} posipaki ${LIB_VERSION} proto ${proto} layout 1`;
404
- }
405
- /** Wrap base64 at a comfortable width; `base64 -d` ignores the newlines. */
406
- function wrapped(base64, width = 76) {
407
- const lines = [];
408
- for (let at = 0; at < base64.length; at += width) lines.push(base64.slice(at, at + width));
409
- return lines.join("\n");
410
- }
411
- /**
412
- * Describe a kit around its files. The manifest hash covers the files only, so
413
- * `version.json` — which records that hash — can be one of them without chasing
414
- * its own tail.
415
- */
416
- function makeKit(files, options) {
417
- const raw = files.map((file) => ({
418
- name: file.name,
419
- bytes: Buffer.byteLength(file.content),
420
- sha256: sha256Hex(file.content),
421
- base64: Buffer.from(file.content).toString("base64")
422
- }));
423
- const manifestHash = sha256Hex(raw.map((f) => `${f.name} ${f.sha256} ${f.bytes}`).join("\n"));
424
- const kit = {
425
- name: kitName(options.app, manifestHash),
426
- manifestHash,
427
- files: raw,
428
- runtimes: [...options.runtimes ?? DEFAULT_RUNTIMES],
429
- parent: options.parent ?? "bin/posipaki",
430
- app: options.app
431
- };
432
- const version = Buffer.from(`${JSON.stringify(kitVersion(kit), null, 2)}\n`);
433
- return {
434
- ...kit,
435
- files: [...kit.files, {
436
- name: "version.json",
437
- bytes: version.byteLength,
438
- sha256: sha256Hex(version),
439
- base64: version.toString("base64")
440
- }]
441
- };
442
- }
443
- /** What `version.json` says: identity, versions, and the exact content hashes. */
444
- function kitVersion(kit) {
445
- return {
446
- kit: kit.name,
447
- app: kit.app,
448
- posipaki: LIB_VERSION,
449
- layout: 1,
450
- manifestHash: kit.manifestHash,
451
- files: kit.files.map((file) => ({
452
- name: file.name,
453
- sha256: file.sha256,
454
- bytes: file.bytes
455
- }))
456
- };
457
- }
458
- /** The `[ -f … ] && [ "$(wc -c < …)" -eq … ]` test for one file. */
459
- function presentTest(file) {
460
- return `[ -f "$kit_dir/${file.name}" ] && [ "$(wc -c < "$kit_dir/${file.name}")" -eq ${file.bytes} ]`;
461
- }
462
- /** One file: write it to a temp name, then move it into place. */
463
- function writeFile(file) {
464
- return [
465
- ` base64 -d > "$tmp" <<'KIT_FILE'`,
466
- wrapped(file.base64),
467
- "KIT_FILE",
468
- ` mv "$tmp" "$kit_dir/${file.name}" || { echo "error cannot install ${file.name}"; exit 73; }`
469
- ].join("\n");
470
- }
471
- /**
472
- * The bootstrap, as one POSIX sh script.
473
- *
474
- * Staging is the whole job. The script always arrives on stdin, never in argv,
475
- * and that is also why it cannot carry the wire: the caller runs the payload on a
476
- * second channel into the same environment once this one has reported.
477
- */
478
- function bootstrapScript(kit) {
479
- const checks = kit.files.map(presentTest).join(" && \\\n ");
480
- return `${[
481
- "# ── kit bootstrap ─────────────────────────────────────────────────────────",
482
- "# probe, stage what is missing, report every step as one machine-readable line.",
483
- "set -u",
484
- "",
485
- "if [ -z \"${HOME:-}\" ]; then echo \"error HOME is not set\"; exit 74; fi",
486
- `kit_dir="$HOME/${kit.parent}/${kit.name}"`,
487
- "",
488
- "runtime=\"\"",
489
- `for candidate in ${kit.runtimes.join(" ")}; do`,
490
- " if command -v \"$candidate\" >/dev/null 2>&1; then runtime=\"$(command -v \"$candidate\")\"; break; fi",
491
- "done",
492
- `if [ -z "$runtime" ]; then echo "error no runtime among: ${kit.runtimes.join(" ")}"; exit 75; fi`,
493
- "if ! command -v base64 >/dev/null 2>&1; then echo \"error base64 is missing\"; exit 76; fi",
494
- "",
495
- `if ${checks}; then`,
496
- " echo \"present\"",
497
- "else",
498
- ` mkdir -p "$kit_dir" || { echo "error cannot create $kit_dir"; exit 73; }`,
499
- " tmp=\"$kit_dir/.staging.$$\"",
500
- ...kit.files.map(writeFile),
501
- " echo \"staged\"",
502
- "fi",
503
- "echo \"kit $kit_dir\"",
504
- "echo \"runtime $runtime\""
505
- ].join("\n")}\n`;
506
- }
507
- /** Read the script's report back. Missing or unknown lines are an error. */
508
- function parseBootstrapReport(stdout) {
509
- let kitDir = "";
510
- let runtime = "";
511
- let staged = null;
512
- for (const raw of stdout.split("\n")) {
513
- const line = raw.trim();
514
- if (line === "") continue;
515
- if (line.startsWith("error ")) return {
516
- kind: "error",
517
- reason: line.slice(6)
518
- };
519
- if (line === "staged") {
520
- staged = true;
521
- continue;
522
- }
523
- if (line === "present") {
524
- staged = false;
525
- continue;
526
- }
527
- if (line.startsWith("kit ")) {
528
- kitDir = line.slice(4);
529
- continue;
530
- }
531
- if (line.startsWith("runtime ")) {
532
- runtime = line.slice(8);
533
- continue;
534
- }
535
- }
536
- if (kitDir === "" || runtime === "" || staged === null) {
537
- const seen = stdout.trim();
538
- return {
539
- kind: "error",
540
- reason: seen === "" ? "no report at all" : `incomplete report: ${seen}`
541
- };
542
- }
543
- return {
544
- kind: "ready",
545
- kitDir,
546
- runtime,
547
- staged
548
- };
549
- }
550
- //#endregion
551
375
  //#region src/remote/gateway.ts
552
376
  const run = promisify(execFile);
553
377
  /** Exit code for "this environment could not be set up". */
554
378
  const GATEWAY_FAILED = 1;
555
- /**
556
- * Absolute path to the gateway's entry point — the file a client runs as a
557
- * program. It is this module's sibling, under whatever name this module has:
558
- * `gateway-cli.ts` from source, `gateway-cli.js` in a build.
559
- */
560
- const GATEWAY_SCRIPT = join(dirname(fileURLToPath(import.meta.url)), `gateway-cli${extname(fileURLToPath(import.meta.url)) || ".js"}`);
561
379
  function errorText(err) {
562
380
  return err instanceof Error ? err.message : String(err);
563
381
  }
564
- function flagValue(argv, name) {
565
- const prefix = `--${name}=`;
566
- return argv.find((a) => a.startsWith(prefix))?.slice(prefix.length);
567
- }
568
- /** A `--flag=<positive integer>` argument, or undefined. */
569
- function positiveInt(value) {
570
- const n = Number(value);
571
- return value !== void 0 && Number.isFinite(n) && n >= 1 ? Math.floor(n) : void 0;
382
+ /**
383
+ * A label for the gateway's own temp directory: the program this environment was made for.
384
+ * It is the gateway's business alone — the payload is not told which label it is.
385
+ */
386
+ function label(worker) {
387
+ const name = basename(worker).replace(/[^A-Za-z0-9.+@_-]/g, "-").slice(0, 60);
388
+ return name === "" ? "payload" : name;
572
389
  }
573
390
  /**
574
391
  * The argv that boots this gateway — built by the client, read by
575
392
  * {@link gatewayBoot}, so the two halves cannot drift apart.
393
+ *
394
+ * The payload comes first and its arguments after it, so a positional argument of the
395
+ * payload's own can never be mistaken for the payload.
576
396
  */
577
397
  function gatewayArgs(boot) {
578
- return [
579
- `--worker=${boot.worker}`,
580
- `--env=${boot.env}`,
581
- `--app-name=${boot.app.name}`,
582
- `--app-version=${boot.app.version}`,
583
- ...boot.poolSize === void 0 ? [] : [`--pool-size=${boot.poolSize}`]
584
- ];
398
+ return [boot.worker, ...boot.passthrough];
585
399
  }
586
400
  /** The boot a gateway was started with, or the reason it cannot start. */
587
401
  function gatewayBoot(argv) {
588
- const worker = flagValue(argv, "worker");
589
- if (!worker) throw new Error("no --worker=<script>: the gateway needs a payload to relay to");
590
- const name = flagValue(argv, "app-name");
591
- const version = flagValue(argv, "app-version");
592
- if (!name || !version) throw new Error("no --app-name=<name> and --app-version=<version>: the gateway names its artifact");
402
+ const [worker, ...passthrough] = argv;
403
+ if (worker === void 0 || worker.startsWith("--")) throw new Error("no <payload>: the gateway relays to a payload, named as its first argument");
593
404
  return {
594
- app: {
595
- name,
596
- version
597
- },
598
- env: flagValue(argv, "env") ?? "unnamed",
599
- poolSize: positiveInt(flagValue(argv, "pool-size")),
405
+ passthrough,
600
406
  worker
601
407
  };
602
408
  }
@@ -627,16 +433,7 @@ function forwardOutput(stream, wire, fd) {
627
433
  * Serve one environment over stdin/stdout. Returns the exit code; the caller
628
434
  * turns it into `process.exitCode`.
629
435
  */
630
- async function runGateway(argv = process.argv) {
631
- if (argv.includes("--version")) {
632
- const name = flagValue(argv, "app-name") ?? "posipaki";
633
- const version = flagValue(argv, "app-version") ?? "-";
634
- process.stdout.write(`${versionLine({
635
- name,
636
- version
637
- }, "gateway", VERSION)}\n`);
638
- return 0;
639
- }
436
+ async function runGateway(argv = process.argv.slice(2)) {
640
437
  const wire = new LineTransport({
641
438
  read: process.stdin,
642
439
  write: process.stdout
@@ -648,8 +445,8 @@ async function runGateway(argv = process.argv) {
648
445
  await fail(wire, errorText(err));
649
446
  abandon();
650
447
  }
651
- const { env, poolSize, worker } = booted;
652
- const dir = await mkdtemp(join(tmpdir(), `posipaki-${env.replace(/\//g, "-")}-`));
448
+ const { passthrough, worker } = booted;
449
+ const dir = await mkdtemp(join(tmpdir(), `posipaki-${label(worker)}-`));
653
450
  const fifoIn = join(dir, "in");
654
451
  const fifoOut = join(dir, "out");
655
452
  let child = null;
@@ -695,12 +492,11 @@ async function runGateway(argv = process.argv) {
695
492
  const connection = FifoUtf8NlineTransport.beginConnect(fifoIn, fifoOut);
696
493
  const workerArgs = [
697
494
  worker,
698
- `--env=${env}`,
699
- ...poolSize === void 0 ? [] : [`--pool-size=${poolSize}`],
495
+ ...passthrough,
700
496
  `--fifo-in=${fifoIn}`,
701
497
  `--fifo-out=${fifoOut}`
702
498
  ];
703
- const workerProc = spawn(process.execPath, workerArgs, { stdio: [
499
+ const workerProc = spawn(workerArgs[0], workerArgs.slice(1), { stdio: [
704
500
  "ignore",
705
501
  "pipe",
706
502
  "pipe"
@@ -736,6 +532,6 @@ async function runGateway(argv = process.argv) {
736
532
  return code;
737
533
  }
738
534
  //#endregion
739
- export { fdStreams as C, stderrSink as D, serverChannel as E, FifoUtf8NlineTransport as O, errorReason as S, parseOutputFrame as T, LineTransport as _, runGateway as a, clientChannel as b, KIT_LAYOUT as c, kitVersion as d, makeKit as f, HANDSHAKE_TIMEOUT_MS as g, versionLine as h, gatewayBoot as i, bootstrapScript as l, sha256Hex as m, GATEWAY_SCRIPT as n, DEFAULT_KIT_PARENT as o, parseBootstrapReport as p, gatewayArgs as r, DEFAULT_RUNTIMES as s, GATEWAY_FAILED as t, kitName as u, OutputFilter as v, outputFrame as w, errorFrame as x, StdioWireError as y };
535
+ export { FifoUtf8NlineTransport as _, HANDSHAKE_TIMEOUT_MS as a, StdioWireError as c, errorReason as d, fdStreams as f, stderrSink as g, serverChannel as h, runGateway as i, clientChannel as l, parseOutputFrame as m, gatewayArgs as n, LineTransport as o, outputFrame as p, gatewayBoot as r, OutputFilter as s, GATEWAY_FAILED as t, errorFrame as u };
740
536
 
741
- //# sourceMappingURL=gateway-BGdUHktZ.js.map
537
+ //# sourceMappingURL=gateway-Cj3HSrl3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-Cj3HSrl3.js","names":["errorText","Lines"],"sources":["../src/remote/transports/fifo.ts","../src/remote/stdio.ts","../src/remote/gateway.ts"],"sourcesContent":["// ── FIFO transport ─────────────────────────────────────────────────────────\n//\n// Newline-delimited UTF-8 over named fifos. Strict handler lifecycle:\n// onMessage() throws if a handler is already set; call removeHandler() first.\n\nimport { open, type FileHandle } from \"node:fs/promises\";\nimport type { ReadStream, WriteStream } from \"node:fs\";\nimport * as readline from \"node:readline\";\nimport type { StringTransport } from \"../channel.js\";\n\nexport class FifoUtf8NlineTransport implements StringTransport {\n private readFd: FileHandle | null;\n private writeFd: FileHandle | null;\n private rl: readline.Interface | null;\n private rs: ReadStream | null;\n private ws: WriteStream | null;\n private pvtOnMessage: ((line: string) => void) | null = null;\n private pvtOnClose: (() => void) | null = null;\n private closed = false;\n private closingPromise: Promise<void> | null = null;\n private pvtError: Error | null = null;\n\n private constructor(opts: { readFd?: FileHandle; writeFd?: FileHandle }) {\n this.readFd = opts.readFd ?? null;\n this.writeFd = opts.writeFd ?? null;\n\n if (this.readFd) {\n this.rs = this.readFd.createReadStream({ encoding: \"utf-8\" });\n this.rl = readline.createInterface({ input: this.rs });\n\n this.rl.on(\"line\", (line) => {\n if (this.pvtOnMessage && !this.closed) this.pvtOnMessage(line);\n });\n\n this.rl.on(\"close\", () => {\n this.pvtOnClose?.();\n this.close();\n });\n\n this.rs.on(\"error\", (err: Error) => {\n this.pvtError = err;\n this.close();\n });\n } else {\n this.rs = null;\n this.rl = null;\n }\n\n if (this.writeFd) {\n this.ws = this.writeFd.createWriteStream({ encoding: \"utf-8\" });\n this.ws.on(\"error\", (err: Error) => {\n this.pvtError = err;\n this.close();\n });\n } else {\n this.ws = null;\n }\n }\n\n // ── factories ──────────────────────────────────────────────────────────\n\n static openReaderFd(readFd: FileHandle): FifoUtf8NlineTransport {\n return new FifoUtf8NlineTransport({ readFd });\n }\n\n static openWriterFd(writeFd: FileHandle): FifoUtf8NlineTransport {\n return new FifoUtf8NlineTransport({ writeFd });\n }\n\n static fromFds(readFd: FileHandle, writeFd: FileHandle): FifoUtf8NlineTransport {\n return new FifoUtf8NlineTransport({ readFd, writeFd });\n }\n\n // ── bidirectional connection ───────────────────────────────────────────\n\n /**\n * Start opening a bidirectional connection. Opens readPath for reading\n * in the background, returns a promise. The caller should do whatever\n * setup is needed to unblock the read (e.g. spawn a process that opens\n * readPath for writing), then await the returned transport.\n *\n * The transport itself is built only once both directions are open. A read\n * stream created while no writer exists on its fifo is handed an immediate\n * end-of-stream by some runtimes (bun), which closes a channel that has not\n * carried a byte yet — so the writes side is opened before the reader exists.\n */\n static beginConnect(\n readPath: string,\n writePath: string,\n ): { transport: Promise<FifoUtf8NlineTransport> } {\n const readFdPromise = open(readPath, \"r\");\n\n const transport = readFdPromise.then(async (readFd) => {\n const writeFd = await open(writePath, \"w\");\n return FifoUtf8NlineTransport.fromFds(readFd, writeFd);\n });\n\n return { transport };\n }\n\n /**\n * Open a bidirectional connection. Opens writePath for writing first\n * (unblocking the peer's read), starts reading readPath in the\n * background, then awaits both.\n *\n * Use this when you are the side that responds to the peer's beginConnect\n * (i.e. you don't need to interleave any setup between the read and write\n * opens). Built like `beginConnect`: the transport exists only after both\n * directions do.\n */\n static async connect(readPath: string, writePath: string): Promise<FifoUtf8NlineTransport> {\n const readFdPromise = open(readPath, \"r\");\n const writeFd = await open(writePath, \"w\");\n const readFd = await readFdPromise;\n return FifoUtf8NlineTransport.fromFds(readFd, writeFd);\n }\n\n // ── public API ─────────────────────────────────────────────────────────\n\n get canSend(): boolean {\n return this.writeFd !== null && !this.closed;\n }\n\n onMessage(handler: (line: string) => void): void {\n if (this.closed) throw new Error(\"FifoUtf8NlineTransport: closed\");\n if (this.readFd === null) throw new Error(\"FifoUtf8NlineTransport: not a reader\");\n if (this.pvtOnMessage !== null) {\n throw new Error(\"FifoUtf8NlineTransport: handler already set — call removeHandler() first\");\n }\n this.pvtOnMessage = handler;\n }\n\n removeHandler(): ((line: string) => void) | null {\n const prev = this.pvtOnMessage;\n this.pvtOnMessage = null;\n return prev;\n }\n\n onClose(handler: () => void): void {\n this.pvtOnClose = handler;\n }\n\n get hasHandler(): boolean {\n return this.pvtOnMessage !== null;\n }\n\n get lastError(): Error | null {\n return this.pvtError;\n }\n\n async send(line: string): Promise<void> {\n if (this.closed) throw new Error(\"FifoUtf8NlineTransport: closed\");\n if (this.writeFd === null) throw new Error(\"FifoUtf8NlineTransport: not a writer\");\n if (!line.endsWith(\"\\n\")) line += \"\\n\";\n await this.ws?.write(line);\n }\n\n async close(): Promise<void> {\n this.closingPromise = this.closingPromise || this.pvtClose();\n await this.closingPromise;\n this.closed = true;\n }\n\n private async pvtClose(): Promise<void> {\n // tranfser control back to caller\n // so they can capture the promise reference\n // and prevent reentry\n await Promise.resolve();\n\n if (this.rl) {\n this.rl.close();\n this.rl = null;\n }\n if (this.rs) {\n this.rs.destroy();\n this.rs = null;\n }\n if (this.ws) {\n await new Promise<void>((resolve) => {\n try {\n this.ws?.end(\"\", resolve);\n } catch {\n resolve();\n }\n });\n this.ws = null;\n }\n\n if (this.readFd) {\n try {\n await this.readFd.close();\n } catch {}\n this.readFd = null;\n }\n if (this.writeFd) {\n try {\n await this.writeFd.close();\n } catch {}\n this.writeFd = null;\n }\n }\n}\n","// ── stdio wire ─────────────────────────────────────────────────────────────\n//\n// A newline-delimited JSON channel over a pair of streams: the one wire every\n// way into a foreign execution context can carry. Two callers rely on it, and\n// they are two halves of the same thing:\n//\n// * the client of a spawn we make ourselves, on fds handed to the child (see\n// `fdStreams`) — private fds, so the child's own stdout stays free;\n// * a first-stage command on its own stdin/stdout, over ssh, under `sudo`, in\n// a container — where stdio is the only channel there is.\n//\n// Frames are one JSON object per line. Whatever the far end prints is carried\n// as an *output frame* (`$fd`), so it can never be mistaken for a frame of the\n// protocol itself; a failed start is carried as an `$error` frame.\n//\n// Why the client filters output frames before handing the transport to the\n// seam: `json1Channel` decodes every line it sees, and the first frame of a\n// session is the peer's `$proto`. Stripping output frames in the transport\n// keeps the protocol view clean without the seam knowing anything about them.\n\nimport { createReadStream, createWriteStream } from \"node:fs\";\nimport * as readline from \"node:readline\";\nimport type { Readable, Writable } from \"node:stream\";\nimport { isProto, type Channel, type StringTransport } from \"./channel.js\";\nimport { VERSION, json1Channel } from \"./protocols/json1.js\";\n\n/** The stream pair a line transport talks over. */\nexport interface LineStreams {\n read: Readable;\n write: Writable;\n}\n\n/** A stream of the far end's process: its stdout or its stderr. */\nexport type OutputFd = 1 | 2;\n\n/** Where the far end's own output goes. */\nexport type OutputSink = (fd: OutputFd, data: string) => void;\n\n/** How long to wait for the far end's first protocol frame. */\nexport const HANDSHAKE_TIMEOUT_MS = 15_000;\n\nconst OUTPUT_KEY = \"$fd\";\n\nconst ERROR_KEY = \"$error\";\n\n/** Raised when the wire itself fails: no frame, the wrong protocol, a peer that went away. */\nexport class StdioWireError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"StdioWireError\";\n }\n}\n\n// ── output frames ──────────────────────────────────────────────────────────\n\n/** One frame of the far end's own output. */\nexport interface OutputFrame {\n fd: OutputFd;\n data: string;\n}\n\nexport function outputFrame(fd: OutputFd, data: string): string {\n return JSON.stringify({ [OUTPUT_KEY]: fd, data });\n}\n\n/** The output frame a line carries, or null when it carries something else. */\nexport function parseOutputFrame(line: string): OutputFrame | null {\n // Cheap reject first: almost every line of a session is protocol traffic.\n if (!line.startsWith('{\"$fd\"')) return null;\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n return null;\n }\n if (typeof parsed !== \"object\" || parsed === null) return null;\n const frame = parsed as Record<string, unknown>;\n const fd = frame[OUTPUT_KEY];\n const data = frame.data;\n if (fd !== 1 && fd !== 2) return null;\n return { fd, data: typeof data === \"string\" ? data : JSON.stringify(data) };\n}\n\nexport function errorFrame(reason: string): string {\n return JSON.stringify({ [ERROR_KEY]: reason });\n}\n\n/** The reason an `$error` frame carries, or null when it is not one. */\nexport function errorReason(frame: Record<string, unknown>): string | null {\n const reason = frame[ERROR_KEY];\n return typeof reason === \"string\" ? reason : null;\n}\n\n// ── transports ─────────────────────────────────────────────────────────────\n\n/** Is this write error just a peer that already left? */\nfunction peerGone(code: unknown): boolean {\n return (\n code === \"EPIPE\" ||\n code === \"ERR_STREAM_DESTROYED\" ||\n code === \"ERR_STREAM_WRITE_AFTER_END\" ||\n code === \"ERR_STREAM_ALREADY_FINISHED\"\n );\n}\n\nfunction errorText(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/**\n * A `StringTransport` over a read/write stream pair, one JSON frame per line.\n *\n * `close()` is idempotent and never throws: teardown races are normal here —\n * the peer exits, the read side ends, and a write arrives a moment later.\n */\nexport class LineTransport implements StringTransport {\n private readonly streams: LineStreams;\n private pvtOnMessage: ((line: string) => void) | null = null;\n private pvtOnClose: (() => void) | null = null;\n private pvtClosed = false;\n private pvtClosing: Promise<void> | null = null;\n\n constructor(streams: LineStreams) {\n this.streams = streams;\n const lines = readline.createInterface({ input: streams.read });\n lines.on(\"line\", (line) => {\n if (this.pvtOnMessage && !this.pvtClosed) this.pvtOnMessage(line);\n });\n lines.on(\"close\", () => {\n this.pvtOnClose?.();\n void this.close();\n });\n // A stream error is a peer that went away, not a reason to take the process\n // down with an unhandled 'error' event.\n streams.read.on(\"error\", () => {\n void this.close();\n });\n streams.write.on(\"error\", () => {\n void this.close();\n });\n }\n\n get closed(): boolean {\n return this.pvtClosed;\n }\n\n get hasHandler(): boolean {\n return this.pvtOnMessage !== null;\n }\n\n onMessage(handler: (line: string) => void): void {\n if (this.pvtClosed) throw new StdioWireError(\"stdio transport: closed\");\n if (this.pvtOnMessage !== null) {\n throw new StdioWireError(\"stdio transport: handler already set — call removeHandler()\");\n }\n this.pvtOnMessage = handler;\n }\n\n removeHandler(): ((line: string) => void) | null {\n const previous = this.pvtOnMessage;\n this.pvtOnMessage = null;\n return previous;\n }\n\n onClose(handler: () => void): void {\n this.pvtOnClose = handler;\n }\n\n send(frame: string): Promise<void> {\n if (this.pvtClosed) {\n return Promise.resolve();\n }\n const line = frame.endsWith(\"\\n\") ? frame : `${frame}\\n`;\n return new Promise<void>((resolve, reject) => {\n try {\n this.streams.write.write(line, (err?: Error | null) => {\n if (!err) return resolve();\n const code = (err as { code?: unknown }).code;\n // A peer that has hung up cannot be told anything; the write that\n // races its exit is not an error in this transport.\n if (peerGone(code)) {\n return resolve();\n }\n reject(new StdioWireError(`stdio transport: ${err.message}`));\n });\n } catch (err) {\n reject(new StdioWireError(`stdio transport: ${errorText(err)}`));\n }\n });\n }\n\n async close(): Promise<void> {\n this.pvtClosing ??= this.pvtClose();\n await this.pvtClosing;\n }\n\n private async pvtClose(): Promise<void> {\n await Promise.resolve();\n\n this.pvtClosed = true;\n // Best effort: a half-open stream (the peer is already gone) must not turn\n // teardown into an exception.\n try {\n this.streams.read.destroy?.();\n } catch {\n /* already gone */\n }\n try {\n if (!this.streams.write.writableEnded) this.streams.write.end();\n } catch {\n /* already gone */\n }\n }\n}\n\n/** Streams over two fds of *our own* process — the child side of an fd wire. */\nexport function fdStreams(readFd: number, writeFd: number): LineStreams {\n const read = createReadStream(\"\", { fd: readFd, encoding: \"utf-8\", autoClose: false });\n const write = createWriteStream(\"\", { fd: writeFd, encoding: \"utf-8\", autoClose: false });\n return { read, write };\n}\n\n/**\n * A transport that lifts output frames out of the stream: everything else is\n * passed through untouched, so the protocol sees frames and only frames.\n */\nexport class OutputFilter implements StringTransport {\n private readonly inner: StringTransport;\n private readonly sink: OutputSink;\n\n constructor(inner: StringTransport, sink: OutputSink) {\n this.inner = inner;\n this.sink = sink;\n }\n\n send(frame: string): void | Promise<void> {\n return this.inner.send(frame);\n }\n\n onMessage(handler: (frame: string) => void): void {\n this.inner.onMessage((line) => {\n const output = parseOutputFrame(line);\n if (output) this.sink(output.fd, output.data);\n else handler(line);\n });\n }\n\n removeHandler(): void {\n this.inner.removeHandler();\n }\n\n onClose(handler: () => void): void {\n this.inner.onClose(handler);\n }\n\n close(): Promise<void> {\n return this.inner.close();\n }\n}\n\n// ── sinks ──────────────────────────────────────────────────────────────────\n\n/** Write the far end's output to our stderr, tagged with its name. */\nexport function stderrSink(name = \"\"): OutputSink {\n const tag = name ? `[${name}] ` : \"\";\n return (fd, data) => {\n const lead = fd === 1 ? tag : `${tag}err: `;\n for (const line of data.split(\"\\n\")) {\n if (line.length > 0) process.stderr.write(`${lead}${line}\\n`);\n }\n };\n}\n\n// ── handshakes ─────────────────────────────────────────────────────────────\n\n/** The next frame that arrives, or a timeout. */\nasync function nextFrame(channel: Channel, timeoutMs: number): Promise<Record<string, unknown>> {\n return await new Promise((resolve, reject) => {\n const timer = setTimeout(\n () => reject(new StdioWireError(`no protocol frame within ${timeoutMs}ms`)),\n timeoutMs,\n );\n timer.unref?.();\n channel.onMessage((frame) => {\n clearTimeout(timer);\n resolve(frame);\n });\n });\n}\n\nexport interface ClientChannelOptions {\n /** Where the far end's own output goes. Defaults to our stderr. */\n onOutput?: OutputSink;\n /** How long to wait for the peer's protocol frame. Defaults to {@link HANDSHAKE_TIMEOUT_MS}. */\n timeoutMs?: number;\n}\n\n/**\n * The client end of the wire: hand the streams to the seam (minus output\n * frames) and wait for the peer's `$proto`. A first stage reports a failed\n * start as an `$error` frame instead.\n */\nexport async function clientChannel(\n streams: LineStreams,\n opts: ClientChannelOptions = {},\n): Promise<Channel> {\n const transport = new LineTransport(streams);\n const channel = json1Channel(new OutputFilter(transport, opts.onOutput ?? stderrSink()));\n const frame = await nextFrame(channel, opts.timeoutMs ?? HANDSHAKE_TIMEOUT_MS);\n channel.removeHandler();\n\n const reason = errorReason(frame);\n if (reason) throw new StdioWireError(reason);\n if (!isProto(frame)) {\n throw new StdioWireError(`unexpected first frame: ${JSON.stringify(frame).slice(0, 120)}`);\n }\n if (frame.$proto !== VERSION) {\n throw new StdioWireError(`unsupported protocol ${String(frame.$proto)}, expected ${VERSION}`);\n }\n return channel;\n}\n\n/** The server end of the wire — a payload speaking stdio itself. */\nexport async function serverChannel(streams: LineStreams): Promise<Channel> {\n const channel = json1Channel(new LineTransport(streams));\n await channel.send({ $proto: VERSION });\n return channel;\n}\n","// ── Gateway ────────────────────────────────────────────────────────────────\n//\n// The first-stage command. Run this *inside* a foreign environment — directly,\n// under `sudo`, over ssh, in a container — and it:\n//\n// 1. creates the channel to the payload (fifo paths it makes itself, in a\n// private temp dir, so they belong to the uid that will open them),\n// 2. starts the payload — the first argument, required — hands it everything else it was\n// given (the host version among it) and relays frames between stdin/stdout,\n// 3. carries whatever the payload prints to the client as output frames\n// (`$fd`), so the payload's own stdout can never be mistaken for protocol.\n//\n// Why a gateway at all: a fifo path created on the client side is useless when the\n// payload runs as another uid (it cannot open it) or on another host (the path is\n// not there). stdio is the one channel every way into an environment gives us, so\n// the wire is stdio and the fifo stays inside the environment.\n//\n// The gateway reads nothing out of what it carries and owns no flag: the payload's path and\n// every argument after it go through verbatim, in order. The payload is the one who refuses a\n// host version it is not, and a relay that judged would be a second place for that decision.\n//\n// Directories and processes are cleaned up on every exit path, which is also why\n// the client never sees a transport being closed twice.\n//\n// It imports nothing but node builtins and this package, so the payload behind it\n// can be anything the runtime there can start.\n\nimport { execFile, spawn } from \"node:child_process\";\nimport type { ChildProcess } from \"node:child_process\";\nimport { mkdtemp, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, join } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { errorFrame, outputFrame } from \"./stdio.js\";\nimport type { LineTransport, OutputFd } from \"./stdio.js\";\nimport { LineTransport as Lines } from \"./stdio.js\";\nimport { FifoUtf8NlineTransport } from \"./transports/fifo.js\";\n\nconst run = promisify(execFile);\n\n/** Exit code for \"this environment could not be set up\". */\nexport const GATEWAY_FAILED = 1;\n\nexport interface GatewayBoot {\n /**\n * The program to start for the payload: the first word of the command the client composed —\n * a runtime, or a program that runs itself. Required, and first, and the gateway has no\n * opinion of its own about which it is.\n */\n worker: string;\n /**\n * Everything after the payload, carried to it **as is** and in order: the consumer's own\n * arguments, and posipaki's own facts among them (the host version travels this way). The\n * gateway reads nothing by name and owns no flag, so nothing of the caller's is interpreted,\n * eaten, re-ordered or re-spelled — and the next fact added to that line needs no new\n * vocabulary here.\n */\n passthrough: string[];\n}\n\nfunction errorText(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/**\n * A label for the gateway's own temp directory: the program this environment was made for.\n * It is the gateway's business alone — the payload is not told which label it is.\n */\nfunction label(worker: string): string {\n const name = basename(worker).replace(/[^A-Za-z0-9.+@_-]/g, \"-\").slice(0, 60);\n return name === \"\" ? \"payload\" : name;\n}\n\n/**\n * The argv that boots this gateway — built by the client, read by\n * {@link gatewayBoot}, so the two halves cannot drift apart.\n *\n * The payload comes first and its arguments after it, so a positional argument of the\n * payload's own can never be mistaken for the payload.\n */\nexport function gatewayArgs(boot: GatewayBoot): string[] {\n return [boot.worker, ...boot.passthrough];\n}\n\n/** The boot a gateway was started with, or the reason it cannot start. */\nexport function gatewayBoot(argv: string[]): GatewayBoot {\n const [worker, ...passthrough] = argv;\n if (worker === undefined || worker.startsWith(\"--\")) {\n throw new Error(\"no <payload>: the gateway relays to a payload, named as its first argument\");\n }\n return { passthrough, worker };\n}\n\n/**\n * End a start that failed. The reason has already gone out on the wire, and\n * returning is not enough: the `open()` on a fifo no payload will ever write sits\n * in the threadpool forever, so the loop never drains and the gateway would linger\n * with a dead payload on its books.\n */\nfunction abandon(): never {\n process.exit(GATEWAY_FAILED);\n}\n\n/** Carry a failed start to the client, then let the caller exit non-zero. */\nasync function fail(wire: LineTransport, reason: string): Promise<void> {\n process.stderr.write(`gateway: ${reason}\\n`);\n try {\n await wire.send(errorFrame(reason));\n } catch {\n /* the client is gone too — the exit code still says what happened */\n }\n}\n\n/** Copy everything the payload prints onto the wire as output frames. */\nfunction forwardOutput(stream: NodeJS.ReadableStream, wire: LineTransport, fd: OutputFd): void {\n stream.setEncoding(\"utf-8\");\n stream.on(\"data\", (chunk: string) => {\n void wire.send(outputFrame(fd, chunk)).catch(() => {\n /* the client hung up: the payload's exit is what matters now */\n });\n });\n}\n\n/**\n * Serve one environment over stdin/stdout. Returns the exit code; the caller\n * turns it into `process.exitCode`.\n */\nexport async function runGateway(argv: string[] = process.argv.slice(2)): Promise<number> {\n const wire = new Lines({ read: process.stdin, write: process.stdout });\n\n let booted: GatewayBoot;\n try {\n booted = gatewayBoot(argv);\n } catch (err) {\n // Nothing has been started yet, so there is nothing to tear down — but the\n // client still deserves the reason rather than a channel that closes on it,\n // and the loop can outlive us: an open stdin nobody will close keeps the\n // process alive, so this is an exit, not a return.\n await fail(wire, errorText(err));\n abandon();\n }\n const { passthrough, worker } = booted;\n\n const dir = await mkdtemp(join(tmpdir(), `posipaki-${label(worker)}-`));\n const fifoIn = join(dir, \"in\"); // the payload writes, we read\n const fifoOut = join(dir, \"out\"); // we write, the payload reads\n\n let child: ChildProcess | null = null;\n let fifo: FifoUtf8NlineTransport | null = null;\n\n /**\n * Everything this gateway owns, undone. All of it is idempotent, because the\n * exit path and the signal path can both arrive.\n */\n const teardown = async (): Promise<void> => {\n child?.kill();\n await fifo?.close().catch(() => {});\n await rm(dir, { recursive: true, force: true }).catch(() => {});\n };\n\n /**\n * A client that gives up stops us with a signal, and a gateway that died on the\n * spot would leave its payload behind in the environment — a process holding a\n * fifo nobody will ever write, which is a leak the environment cannot clean up\n * for us. So the signals do what the exit path does.\n */\n const onTerminate = () => {\n void teardown()\n .catch(() => {})\n .then(() => process.exit(GATEWAY_FAILED));\n };\n for (const signal of [\"SIGTERM\", \"SIGINT\", \"SIGHUP\"] as const) process.on(signal, onTerminate);\n\n try {\n await run(\"mkfifo\", [\"-m\", \"600\", fifoIn, fifoOut]);\n } catch (err) {\n await fail(wire, `cannot create the environment's fifos: ${errorText(err)}`);\n await teardown();\n abandon();\n }\n\n // Open the read side in the background, then start the payload that unblocks\n // it — the order the fifo handshake requires.\n const connection = FifoUtf8NlineTransport.beginConnect(fifoIn, fifoOut);\n const workerArgs = [worker, ...passthrough, `--fifo-in=${fifoIn}`, `--fifo-out=${fifoOut}`];\n // Whatever the client said starts the payload, run as it said: a runtime with a script of\n // ours, or a program of the caller's own. The gateway does not know which it is, and does\n // not choose a runtime on the far end's behalf.\n const workerProc = spawn(workerArgs[0]!, workerArgs.slice(1), {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n child = workerProc;\n forwardOutput(workerProc.stdout, wire, 1);\n forwardOutput(workerProc.stderr, wire, 2);\n\n const exited = new Promise<number>((settle) => {\n // A payload killed by a signal (the client hung up, and we killed it) has no\n // code — for us that is a clean end, not a failure.\n workerProc.once(\"exit\", (code) => settle(code ?? 0));\n });\n\n try {\n fifo = await Promise.race([\n connection.transport,\n exited.then((code) => {\n throw new Error(`the payload exited with code ${code} before it opened its channel`);\n }),\n ]);\n } catch (err) {\n await fail(wire, errorText(err));\n await teardown();\n abandon();\n }\n\n // Relay: the protocol is the client's and the payload's business, not ours.\n const relay = fifo;\n relay.onMessage((line) => {\n void wire.send(line).catch(() => {\n /* client gone */\n });\n });\n wire.onMessage((line) => {\n void relay.send(line).catch(() => {\n /* the payload is gone; its exit path cleans up */\n });\n });\n wire.onClose(() => {\n child?.kill();\n });\n\n const code = await exited;\n await teardown();\n await wire.close();\n return code;\n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,yBAAb,MAAa,uBAAkD;CAY7D,YAAoB,M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,CAAC;CACxC,cAAc,WAAW,QAAQ,MAAM,CAAC;CAExC,MAAM,SAAS,IAAI,SAAiB,WAAW;EAG7C,WAAW,KAAK,SAAS,SAAS,OAAO,QAAQ,CAAC,CAAC;CACrD,CAAC;CAED,IAAI;EACF,OAAO,MAAM,QAAQ,KAAK,CACxB,WAAW,WACX,OAAO,MAAM,SAAS;GACpB,MAAM,IAAI,MAAM,gCAAgC,KAAK,8BAA8B;EACrF,CAAC,CACH,CAAC;CACH,SAAS,KAAK;EACZ,MAAM,KAAK,MAAM,UAAU,GAAG,CAAC;EAC/B,MAAM,SAAS;EACf,QAAQ;CACV;CAGA,MAAM,QAAQ;CACd,MAAM,WAAW,SAAS;EACxB,KAAU,KAAK,IAAI,CAAC,CAAC,YAAY,CAEjC,CAAC;CACH,CAAC;CACD,KAAK,WAAW,SAAS;EACvB,MAAW,KAAK,IAAI,CAAC,CAAC,YAAY,CAElC,CAAC;CACH,CAAC;CACD,KAAK,cAAc;EACjB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,OAAO,MAAM;CACnB,MAAM,SAAS;CACf,MAAM,KAAK,MAAM;CACjB,OAAO;AACT"}
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ declare function defineActor<Args, InternalState, InMsg extends Message, OutMsg
20
20
  //#endregion
21
21
  //#region src/version.d.ts
22
22
  /** posipaki's release version. Must equal package.json's `version`. */
23
- declare const LIB_VERSION = "0.33.0";
23
+ declare const LIB_VERSION = "0.35.0";
24
24
  //#endregion
25
25
  export { type ActorConfig, type ActorContext, type ActorDecorated, type ActorDefinition, type ActorPlugin, type ActorReflection, type AnyProcess, AsyncProcess, type AsyncProcessFn, type ExitMessage, type HandlerFn, type HandlerOptions, type HookResult, LIB_VERSION, type Message, type MethodOptions, type PluginTransform, Process, type ProcessCtx, type ProcessFn, type SenderInfo, type SenderOrigin, type SpawnedFrom, type StopMessage, type WithSender, type WithoutSender, asyncify, callHook, chainHook, defineActor, defineMessages, mergeConfigs, propagateError, runDispatch, runDispatchAsync, spawn, spawnAsync, stopPropagation };
26
26
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { i as runDispatch } from "./util-Brtfgv68.js";
2
2
  import { a as spawnAsync, i as runDispatchAsync, n as defineMessages, o as asyncify, r as AsyncProcess, t as defineActor } from "./define-actor-DqOW2StX.js";
3
3
  import { n as chainHook, o as propagateError, r as mergeConfigs, s as stopPropagation, t as callHook } from "./hooks-CgXhmY4r.js";
4
- import { t as LIB_VERSION } from "./version-W7guWJeR.js";
4
+ import { t as LIB_VERSION } from "./version-DDAdqTTr.js";
5
5
  //#region src/process.ts
6
6
  /** @deprecated Use {@link spawnAsync} instead. */
7
7
  function spawn(fn, pname, tp) {
@@ -1,4 +1,4 @@
1
- import { a as runGateway } from "../gateway-BGdUHktZ.js";
1
+ import { i as runGateway } from "../gateway-Cj3HSrl3.js";
2
2
  //#region src/remote/gateway-cli.ts
3
3
  (async () => {
4
4
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"gateway-cli.js","names":[],"sources":["../../src/remote/gateway-cli.ts"],"sourcesContent":["// ── The gateway, as a program ──────────────────────────────────────────────\n//\n// A gateway is something a client runs: the first-stage command that makes a fifo\n// inside a foreign environment and relays frames between its own stdin/stdout and\n// the payload. That is this file's whole job — it always serves, and it exits with\n// the code the run ended in.\n//\n// Serving lives in ./gateway.js and starts nothing by itself. A file cannot decide\n// \"am I the program?\" from where it is: a consumer that bundles the node surface\n// into its own program carries this code along, and there the bundle *is* the\n// program — a payload would find a gateway booting on its wire. So the decision is\n// in the layout instead: importing a module never starts anything, and running this\n// one always does.\n\nimport { GATEWAY_FAILED, runGateway } from \"./gateway.js\";\n\nvoid (async () => {\n try {\n process.exitCode = await runGateway();\n } catch (err) {\n process.stderr.write(`gateway: ${err instanceof Error ? err.message : String(err)}\\n`);\n process.exitCode = GATEWAY_FAILED;\n }\n})();\n"],"mappings":";;CAgBM,YAAY;CAChB,IAAI;EACF,QAAQ,WAAW,MAAM,WAAW;CACtC,SAAS,KAAK;EACZ,QAAQ,OAAO,MAAM,YAAY,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,EAAE,GAAG;EACrF,QAAQ,WAAA;CACV;AACF,EAAA,CAAG"}
1
+ {"version":3,"file":"gateway-cli.js","names":[],"sources":["../../src/remote/gateway-cli.ts"],"sourcesContent":["// ── The gateway, as a program ──────────────────────────────────────────────\n//\n// A gateway is something a client runs: the first-stage command that makes a fifo\n// inside a foreign environment and relays frames between its own stdin/stdout and\n// the payload. That is this file's whole job — it always serves, and it exits with\n// the code the run ended in.\n//\n// Serving lives in ./gateway.js and starts nothing by itself. A file cannot decide\n// \"am I the program?\" from where it is: a consumer that bundles the node surface\n// into its own program carries this code along, and there the bundle *is* the\n// program — a payload would find a gateway booting on its wire. So the decision is\n// in the layout instead: importing a module never starts anything, and running this\n// one always does.\n//\n// The client names it either way: `posipaki/remote/gateway-cli.js` is a published\n// specifier, so `import.meta.resolve` answers with the built file, and a consumer\n// with a program of its own stages that instead. Nothing here works out its own\n// location — a path derived from `import.meta.url` is a guess about a layout the\n// bundler owns, and the guess is wrong the moment the module moves into a chunk.\n\nimport { GATEWAY_FAILED, runGateway } from \"./gateway.js\";\n\nvoid (async () => {\n try {\n process.exitCode = await runGateway();\n } catch (err) {\n process.stderr.write(`gateway: ${err instanceof Error ? err.message : String(err)}\\n`);\n process.exitCode = GATEWAY_FAILED;\n }\n})();\n"],"mappings":";;CAsBM,YAAY;CAChB,IAAI;EACF,QAAQ,WAAW,MAAM,WAAW;CACtC,SAAS,KAAK;EACZ,QAAQ,OAAO,MAAM,YAAY,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,EAAE,GAAG;EACrF,QAAQ,WAAA;CACV;AACF,EAAA,CAAG"}
@@ -1,6 +1,6 @@
1
1
  import { r as Message } from "../types-CsE8xK3a.js";
2
- import { h as MethodOptions, l as ActorDefinition, p as HandlerOptions, v as ReflectionOptions } from "../hooks-CfQ8EhKW.js";
3
- import { a as isMsg, i as isInit, n as StringTransport, o as isProto, r as isExit, s as isState, t as Channel } from "../channel-HCjngMq_.js";
2
+ import { l as ActorDefinition, v as ReflectionOptions } from "../hooks-CfQ8EhKW.js";
3
+ import { a as isExit, c as isProto, i as StringTransport, l as isState, n as remoteClient, o as isInit, r as Channel, s as isMsg, t as ClientSpawner } from "../client-DHI-6XPF.js";
4
4
  //#region src/remote/server.d.ts
5
5
  type Spawner = () => Promise<Channel>;
6
6
  declare function makeSender(fromName: string, parentName: string | null, parentId: symbol | null): {
@@ -9,10 +9,6 @@ declare function makeSender(fromName: string, parentName: string | null, parentI
9
9
  };
10
10
  declare function serveRemoteActor<Args, State, InMsg extends Message, OutMsg extends Message, R extends ReflectionOptions>(actor: ActorDefinition<Args, State, InMsg, OutMsg, R>, spawner: Spawner): Promise<void>;
11
11
  //#endregion
12
- //#region src/remote/client.d.ts
13
- type ClientSpawner<Args> = (args: Args) => Promise<Channel>;
14
- declare function remoteClient<Args, State, InMsg extends Message, OutMsg extends Message, Methods extends MethodOptions = MethodOptions, Handlers extends HandlerOptions<InMsg> = HandlerOptions<InMsg>, R extends ReflectionOptions = ReflectionOptions>(name: string, spawner: ClientSpawner<Args>): ActorDefinition<Args, State, InMsg, OutMsg, R>;
15
- //#endregion
16
12
  //#region src/remote/protocols/json1.d.ts
17
13
  declare const VERSION = "json.v1";
18
14
  declare function encode(frame: Record<string, unknown>): string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/remote/server.ts","../../src/remote/client.ts","../../src/remote/protocols/json1.ts","../../src/remote/transports/websocket.ts","../../src/remote/transports/worker.ts","../../src/remote/spawners/ws-client.ts","../../src/remote/spawners/ws-server.ts","../../src/remote/spawners/worker-client.ts","../../src/remote/spawners/worker-self.ts"],"mappings":";;;;KAWY,gBAAgB,QAAQ;iBAEpB,WACd,kBACA,2BACA;EACG;EAAkB;;iBAOD,iBACpB,MACA,OACA,cAAc,SACd,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Y,aACX,cAAc;;;iBCRD,kBAAkB,YAAW,aAAmD"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/remote/server.ts","../../src/remote/protocols/json1.ts","../../src/remote/transports/websocket.ts","../../src/remote/transports/worker.ts","../../src/remote/spawners/ws-client.ts","../../src/remote/spawners/ws-server.ts","../../src/remote/spawners/worker-client.ts","../../src/remote/spawners/worker-self.ts"],"mappings":";;;;KAWY,gBAAgB,QAAQ;iBAEpB,WACd,kBACA,2BACA;EACG;EAAkB;;iBAOD,iBACpB,MACA,OACA,cAAc,SACd,eAAe,SACf,UAAU,mBACV,OAAO,gBAAgB,MAAM,OAAO,OAAO,QAAQ,IAAI,SAAS,UAAU;;;cCtB/D;iBAEG,OAAO,OAAO;iBAId,OAAO,cAAc;iBAIrB,aAAa,WAAW,kBAAkB;;;;;;;;UCJzC;EACf,KAAK;EACL,MAAM,eAAe;WACZ;EACT,aAAa;IAAS;;EACtB;;;cAIW;cAEA,8BAA8B;UACjC;UACA;UACA;UACA;EAER,YAAY,IAAI;MAWZ;EAIJ,UAAU,UAAU;EAQpB,mBAAmB;EAMnB,QAAQ;MAIJ;EAIE,KAAK,gBAAgB;EAMrB,SAAS;;;;;cC/DJ;;;;;;UAOI;EACf,YAAY;EACZ,aAAa;IAAS;;EACtB,YAAY;EACZ;;cAGW,2BAA2B;UAC9B;UACA;UACA;UACA;EAER,YAAY,QAAQ;MAgBhB;EAIJ,UAAU,UAAU,OAAO;EAQ3B,mBAAmB,OAAO;EAM1B,QAAQ;MAIJ;EAIE,KAAK,OAAO,0BAA0B;EAKtC,SAAS;;;;KClEL,qBAAqB;WACtB;EACT,KAAK;EACL,MAAM,eAAe;EACrB;EACA,WAAW;EACX,aAAa;IAAS;;EACtB;;iBAac,gBAAgB,gBAC9B,gBAAgB,MAAM,kBACtB,gBAAe,gBACd,cAAc;;;iBCzBD,gBAAgB,IAAI,gBAAgB;;;;;;;UAcnC;EACf,KAAK;EACL,MAAM,eAAe;WACZ;EACT;;;;;;;;;;;;;;;;;;;;;iBAsBc,mBAAmB,IAAI,yBAAyB;;;KCxCpD,kBAAkB,gBAAgB;iBAI9B,oBAAoB,gBAClC,gBAAgB,MAAM,kBACtB,aAAY,aACX,cAAc;;;iBCRD,kBAAkB,YAAW,aAAmD"}