@volter/world-runtime 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/LICENSE +202 -0
  2. package/dist/known-external-services.json +1108 -0
  3. package/dist/src/ancestry.d.ts +2 -0
  4. package/dist/src/ancestry.js +42 -0
  5. package/dist/src/app-url.d.ts +47 -0
  6. package/dist/src/app-url.js +239 -0
  7. package/dist/src/attach.d.ts +48 -0
  8. package/dist/src/attach.js +87 -0
  9. package/dist/src/branch.d.ts +20 -0
  10. package/dist/src/branch.js +65 -0
  11. package/dist/src/browser-proxy-cli.d.ts +2 -0
  12. package/dist/src/browser-proxy-cli.js +41 -0
  13. package/dist/src/ca-trust.d.ts +5 -0
  14. package/dist/src/ca-trust.js +64 -0
  15. package/dist/src/catalog.d.ts +31 -0
  16. package/dist/src/catalog.js +148 -0
  17. package/dist/src/changeset.d.ts +142 -0
  18. package/dist/src/changeset.js +570 -0
  19. package/dist/src/cli.d.ts +2 -0
  20. package/dist/src/cli.js +1262 -0
  21. package/dist/src/command-lifetime.d.ts +15 -0
  22. package/dist/src/command-lifetime.js +98 -0
  23. package/dist/src/configs.d.ts +18 -0
  24. package/dist/src/configs.js +119 -0
  25. package/dist/src/console-apart.d.ts +38 -0
  26. package/dist/src/console-apart.js +107 -0
  27. package/dist/src/consumers.d.ts +46 -0
  28. package/dist/src/consumers.js +200 -0
  29. package/dist/src/covers.d.ts +183 -0
  30. package/dist/src/covers.js +800 -0
  31. package/dist/src/fixture-env.d.ts +42 -0
  32. package/dist/src/fixture-env.js +221 -0
  33. package/dist/src/host-cli.d.ts +2 -0
  34. package/dist/src/host-cli.js +92 -0
  35. package/dist/src/host-fault-fixture.d.ts +32 -0
  36. package/dist/src/host-fault-fixture.js +100 -0
  37. package/dist/src/host-worker.d.ts +1 -0
  38. package/dist/src/host-worker.js +23 -0
  39. package/dist/src/host.d.ts +38 -0
  40. package/dist/src/host.js +135 -0
  41. package/dist/src/index.d.ts +48 -0
  42. package/dist/src/index.js +35 -0
  43. package/dist/src/infra-cli.d.ts +2 -0
  44. package/dist/src/infra-cli.js +136 -0
  45. package/dist/src/init.d.ts +227 -0
  46. package/dist/src/init.js +1117 -0
  47. package/dist/src/inject-map.d.ts +34 -0
  48. package/dist/src/inject-map.js +56 -0
  49. package/dist/src/lifecycle-record.d.ts +47 -0
  50. package/dist/src/lifecycle-record.js +196 -0
  51. package/dist/src/origin.d.ts +31 -0
  52. package/dist/src/origin.js +139 -0
  53. package/dist/src/pack-facts.d.ts +75 -0
  54. package/dist/src/pack-facts.js +98 -0
  55. package/dist/src/pglite-backing.d.ts +21 -0
  56. package/dist/src/pglite-backing.js +158 -0
  57. package/dist/src/pglite-host.mjs +147 -0
  58. package/dist/src/placeholder.d.ts +20 -0
  59. package/dist/src/placeholder.js +100 -0
  60. package/dist/src/prerequisites.d.ts +21 -0
  61. package/dist/src/prerequisites.js +49 -0
  62. package/dist/src/process-groups.d.ts +4 -0
  63. package/dist/src/process-groups.js +49 -0
  64. package/dist/src/project-inspect.d.ts +109 -0
  65. package/dist/src/project-inspect.js +827 -0
  66. package/dist/src/proxy-daemon.d.ts +2 -0
  67. package/dist/src/proxy-daemon.js +18 -0
  68. package/dist/src/redirect-proxy.d.ts +105 -0
  69. package/dist/src/redirect-proxy.js +665 -0
  70. package/dist/src/reflect.d.ts +74 -0
  71. package/dist/src/reflect.js +392 -0
  72. package/dist/src/resources.d.ts +26 -0
  73. package/dist/src/resources.js +22 -0
  74. package/dist/src/root.d.ts +114 -0
  75. package/dist/src/root.js +312 -0
  76. package/dist/src/run-task-worker.d.ts +1 -0
  77. package/dist/src/run-task-worker.js +38 -0
  78. package/dist/src/run-task.d.ts +18 -0
  79. package/dist/src/run-task.js +48 -0
  80. package/dist/src/runtime-test-support.d.ts +59 -0
  81. package/dist/src/runtime-test-support.js +205 -0
  82. package/dist/src/runtime.d.ts +256 -0
  83. package/dist/src/runtime.js +3502 -0
  84. package/dist/src/schema.d.ts +449 -0
  85. package/dist/src/schema.js +605 -0
  86. package/dist/src/serve.d.ts +30 -0
  87. package/dist/src/serve.js +82 -0
  88. package/dist/src/served-world.d.ts +194 -0
  89. package/dist/src/served-world.js +986 -0
  90. package/dist/src/service-exit.d.ts +46 -0
  91. package/dist/src/service-exit.js +195 -0
  92. package/dist/src/service-recorder.d.ts +1 -0
  93. package/dist/src/service-recorder.js +121 -0
  94. package/dist/src/sibling.d.ts +1 -0
  95. package/dist/src/sibling.js +9 -0
  96. package/dist/src/signals.d.ts +1 -0
  97. package/dist/src/signals.js +11 -0
  98. package/dist/src/storage-capacity.d.ts +8 -0
  99. package/dist/src/storage-capacity.js +61 -0
  100. package/dist/src/tail.d.ts +30 -0
  101. package/dist/src/tail.js +160 -0
  102. package/dist/src/tcp-port.d.ts +2 -0
  103. package/dist/src/tcp-port.js +36 -0
  104. package/dist/src/up-task-worker.d.ts +1 -0
  105. package/dist/src/up-task-worker.js +61 -0
  106. package/dist/src/up-task.d.ts +17 -0
  107. package/dist/src/up-task.js +49 -0
  108. package/dist/src/websocket-relay.d.ts +3 -0
  109. package/dist/src/websocket-relay.js +40 -0
  110. package/known-external-services.json +1108 -0
  111. package/package.json +83 -0
  112. package/src/ancestry.ts +36 -0
  113. package/src/app-url.ts +253 -0
  114. package/src/attach.ts +117 -0
  115. package/src/branch.ts +63 -0
  116. package/src/browser-proxy-cli.ts +44 -0
  117. package/src/ca-trust.ts +57 -0
  118. package/src/catalog.ts +156 -0
  119. package/src/changeset.ts +627 -0
  120. package/src/cli.ts +1111 -0
  121. package/src/command-lifetime.ts +79 -0
  122. package/src/configs.ts +110 -0
  123. package/src/console-apart.ts +90 -0
  124. package/src/consumers.ts +185 -0
  125. package/src/covers.ts +934 -0
  126. package/src/fixture-env.ts +230 -0
  127. package/src/host-cli.ts +90 -0
  128. package/src/host-worker.ts +23 -0
  129. package/src/host.ts +169 -0
  130. package/src/index.ts +171 -0
  131. package/src/infra-cli.ts +133 -0
  132. package/src/init.ts +1316 -0
  133. package/src/inject-map.ts +72 -0
  134. package/src/lifecycle-record.ts +168 -0
  135. package/src/origin.ts +134 -0
  136. package/src/pack-facts.ts +128 -0
  137. package/src/pglite-backing.ts +141 -0
  138. package/src/pglite-host.mjs +147 -0
  139. package/src/placeholder.ts +89 -0
  140. package/src/prerequisites.ts +66 -0
  141. package/src/process-groups.ts +33 -0
  142. package/src/project-inspect.ts +770 -0
  143. package/src/proxy-daemon.ts +21 -0
  144. package/src/redirect-proxy.ts +684 -0
  145. package/src/reflect.ts +440 -0
  146. package/src/resources.ts +22 -0
  147. package/src/root.ts +290 -0
  148. package/src/run-task-worker.ts +27 -0
  149. package/src/run-task.ts +44 -0
  150. package/src/runtime-test-support.ts +208 -0
  151. package/src/runtime.ts +3357 -0
  152. package/src/schema.ts +922 -0
  153. package/src/serve.ts +102 -0
  154. package/src/served-world.ts +812 -0
  155. package/src/service-exit.ts +175 -0
  156. package/src/service-recorder.ts +89 -0
  157. package/src/sibling.ts +10 -0
  158. package/src/signals.ts +10 -0
  159. package/src/storage-capacity.ts +60 -0
  160. package/src/tail.ts +205 -0
  161. package/src/tcp-port.ts +35 -0
  162. package/src/up-task-worker.ts +40 -0
  163. package/src/up-task.ts +45 -0
  164. package/src/websocket-relay.ts +32 -0
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ // Detached entry for the ambient TLS redirect proxy. `activate` spawns this as its own process so a
3
+ // long-lived proxy can serve the activated shell(s) for the world's lifetime; it records its
4
+ // pid/url/CA in the instance dir and is stopped by `volter-world down`. Not a user-facing command.
5
+ import { runProxyDaemon } from "./runtime.js";
6
+ const [name, ...rest] = process.argv.slice(2);
7
+ const rootIndex = rest.indexOf('--root');
8
+ const root = rootIndex >= 0 && rest[rootIndex + 1] ? rest[rootIndex + 1] : process.cwd();
9
+ // `--env-file=<path>`, one argument: Node itself reads a separate `--env-file <path>` pair.
10
+ const envFile = rest.find((arg) => arg.startsWith('--env-file='))?.slice('--env-file='.length) || undefined;
11
+ if (!name) {
12
+ process.stderr.write('proxy-daemon: missing world name\n');
13
+ process.exit(1);
14
+ }
15
+ runProxyDaemon(name, root, envFile).catch((error) => {
16
+ process.stderr.write(`proxy-daemon: ${error instanceof Error ? error.message : String(error)}\n`);
17
+ process.exit(1);
18
+ });
@@ -0,0 +1,105 @@
1
+ import { type CaTrustInputs } from './ca-trust.js';
2
+ /**
3
+ * The body served when a host was MITM'd but no twin serves the PATH.
4
+ *
5
+ * Two deliberate choices, both §9 round 2 findings:
6
+ * • The request path is JSON-escaped and the response is sent as `text/plain`. `req.url` may
7
+ * legally carry `<` and `>`, and an untyped body is MIME-sniffable — so on a machine that has
8
+ * trusted the session CA, a crafted URL could otherwise execute in the vendor's origin. The
9
+ * sibling raw-socket error path already set `text/plain`; this matches it.
10
+ * • It names the SITUATION, not just the miss (the Cal.com finding): this handler only runs after
11
+ * the host was MITM'd, i.e. the host IS twinned in this world — so the bare "no twin for host"
12
+ * sent readers hunting for a `*_TWIN_URL` that was already set. On a shared host the path may
13
+ * belong to a vendor whose twin merely is not configured (youtube vs googleauth), OR to no pack
14
+ * at all (Google Calendar on www.googleapis.com has no twin yet) — the message states both,
15
+ * because this refusal is exactly what replaced the silent mis-route that answered Calendar
16
+ * calls with plausible Google-shaped 404s from the gemini pack.
17
+ */
18
+ export declare function noTwinMessage(host: string, path: string): string;
19
+ /** Resolve which twin origin (if any) a vendor host maps to, given the world env (which carries the
20
+ * `*_TWIN_URL` vars). Returns null for hosts the world doesn't twin — those are tunneled untouched.
21
+ *
22
+ * `pathname` is optional and matters only for hosts TWO vendors share (see `VENDOR_HOSTS` in
23
+ * inject.cjs — `www.googleapis.com` is served by both `googleauth` and `youtube`, split by path).
24
+ * At CONNECT time there is no path yet, so it is omitted and the answer is host-level candidacy:
25
+ * "MITM this host". Once TLS is terminated and the real request line is readable, the caller
26
+ * re-resolves WITH the path so each request reaches the twin that actually serves it. */
27
+ export declare function proxyTargetFor(hostname: string, env: Record<string, string | undefined>, pathname?: string): {
28
+ vendor: string;
29
+ origin: string;
30
+ } | null;
31
+ /** The vendor→twin map this world actively redirects (for diagnostics / activate output). */
32
+ export declare function activeVendorMap(env: Record<string, string | undefined>): Record<string, string>;
33
+ /** A connection from anything but the proxy host's own loopback is a guest's (a World Machine: its forwarder connects
34
+ * from 127.0.0.2 on this host, or from its VM's address): architecture, "The scoped proxy's local pass-through". */
35
+ export declare function isGuestSource(address: string | undefined): boolean;
36
+ /** An address a guest may not be connected to: one of the host's networks (above), or an address of the host's own
37
+ * interfaces; an IPv4 address mapped into IPv6 (in any spelling) is checked as IPv4. */
38
+ export declare function isGuestForbiddenAddress(ip: string): boolean;
39
+ /** Where a guest may be connected for `host`: the address checked (a literal, or what the name resolves to, every
40
+ * answer checked), or the refusal. The caller connects to that address, so a second resolution cannot move it. */
41
+ export declare function guestDestination(host: string): Promise<{
42
+ address: string;
43
+ } | {
44
+ refused: string;
45
+ }>;
46
+ type CaPaths = {
47
+ dir: string;
48
+ caKey: string;
49
+ caCert: string;
50
+ };
51
+ export declare function opensslAvailable(): boolean;
52
+ /** Generate (once) a throwaway CA in `tlsDir`. Idempotent: reuses an existing CA so a re-activate in
53
+ * the same world trusts the same cert. Session/project-scoped — it lives under the instance dir and
54
+ * is removed by `tearDownCa` on `down`. */
55
+ export declare function ensureCa(tlsDir: string): CaPaths;
56
+ /** Remove the session CA + any minted leaf certs. Called on `down` so the trusted CA never outlives
57
+ * the world (it was only ever trusted via the per-shell env, never system-wide). */
58
+ export declare function tearDownCa(tlsDir: string): void;
59
+ /** Mint (and cache) a leaf cert for `host`, signed by the session CA. SAN = the host so the client
60
+ * accepts it for that SNI. */
61
+ export declare function leafCertFor(host: string, ca: CaPaths): {
62
+ key: string;
63
+ cert: string;
64
+ };
65
+ type RedirectProxyOptions = {
66
+ /** The world env — supplies the `*_TWIN_URL` host→twin map. */
67
+ env?: Record<string, string | undefined>;
68
+ /** Keep caller trust separate from persisted World trust so neither overwrites the other. */
69
+ trustEnv?: CaTrustInputs;
70
+ /** Optional dynamic env source. Used by the detached world daemon while services are still adding
71
+ * `*_TWIN_URL` vars during `up`; each proxied request resolves against the latest file-backed env. */
72
+ envLoader?: () => Record<string, string | undefined>;
73
+ /** Where the session CA + leaf certs live (instance dir/tls). */
74
+ tlsDir: string;
75
+ /** Where each refusal and each failed twin request is written (the detached daemon's log), so an app that swallows
76
+ * a 502 still leaves the World a record of it. */
77
+ note?: (line: string) => void;
78
+ /** Listen host (default 127.0.0.1) and port (default 0 = ephemeral). */
79
+ host?: string;
80
+ port?: number;
81
+ };
82
+ type RedirectProxyHandle = {
83
+ port: number;
84
+ host: string;
85
+ caCertPath: string;
86
+ url: string;
87
+ /** Its guests' listener (a World Machine's forwarder targets it): every connection there gets the guest rule. */
88
+ guestUrl: string;
89
+ /** The cert-trust + proxy env an activate/shell session exports to route through this proxy. */
90
+ proxyEnv(): Record<string, string>;
91
+ close(): Promise<void>;
92
+ };
93
+ /** A failed twin request's answer: the twin, its origin, the World and the cause, so the app's error says which service
94
+ * of which World to look at (`doctor`). Shared by every front that relays to twins. */
95
+ export declare function twinUnreachableMessage(vendor: string, origin: string, err: Error, world?: string): string;
96
+ /** Start the ambient redirect proxy. Returns a handle with the listen port + the env to export.
97
+ * - Plain `http://` proxied requests to a vendor host → forwarded to the twin.
98
+ * - `CONNECT host:443` to a vendor host → MITM-terminated with a session-signed leaf, decrypted, and
99
+ * forwarded to the twin. CONNECT to any other host → blind-tunneled to the real origin untouched. */
100
+ export declare function startRedirectProxy(options: RedirectProxyOptions): Promise<RedirectProxyHandle>;
101
+ /** The cert-trust + proxy env that points an unmodified tool through the proxy and trusts the session
102
+ * CA — and ONLY this session (these are per-shell exports; nothing is installed system-wide). Mirrors
103
+ * the env list in WORLD_ACTIVATE.md §"The honest cost: a scoped CA". */
104
+ export declare function proxyEnvFor(proxyUrl: string, caCertPath: string, caller?: CaTrustInputs, guestUrl?: string): Record<string, string>;
105
+ export {};