@volter/world-core 2.0.37 → 3.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 (205) hide show
  1. package/README.md +4 -5
  2. package/app-route.cjs +12 -6
  3. package/app-route.d.cts +1 -1
  4. package/dist/app-route.cjs +12 -6
  5. package/dist/app-route.d.cts +1 -1
  6. package/dist/generated/pack-facts.json +1410 -3069
  7. package/dist/inject.cjs +64 -9
  8. package/dist/pack-facts.cjs +44 -0
  9. package/dist/src/actions.d.ts +3 -3
  10. package/dist/src/actions.js +22 -16
  11. package/dist/src/ancestry.d.ts +14 -2
  12. package/dist/src/ancestry.js +92 -2
  13. package/dist/src/anthropic-wire.d.ts +39 -0
  14. package/dist/src/anthropic-wire.js +136 -0
  15. package/dist/src/bytes.d.ts +7 -0
  16. package/dist/src/bytes.js +35 -0
  17. package/dist/src/changeset.d.ts +1 -1
  18. package/dist/src/changeset.js +0 -0
  19. package/dist/src/clickhouse/index.d.ts +3 -0
  20. package/dist/src/clickhouse/index.js +6 -0
  21. package/dist/src/clickhouse/sql.d.ts +233 -0
  22. package/dist/src/clickhouse/sql.js +4329 -0
  23. package/dist/src/clickhouse/types.d.ts +18 -0
  24. package/dist/src/clickhouse/types.js +47 -0
  25. package/dist/src/clickhouse/values.d.ts +146 -0
  26. package/dist/src/clickhouse/values.js +858 -0
  27. package/dist/src/client-bundle.js +2 -3
  28. package/dist/src/cors.d.ts +15 -0
  29. package/dist/src/cors.js +31 -0
  30. package/dist/src/derived-core.d.ts +487 -24
  31. package/dist/src/derived-core.js +788 -144
  32. package/dist/src/derived-real.d.ts +13 -0
  33. package/dist/src/derived-real.js +518 -0
  34. package/dist/src/derived.d.ts +35 -1
  35. package/dist/src/derived.js +61 -9
  36. package/dist/src/emit.js +1 -2
  37. package/dist/src/events.d.ts +206 -0
  38. package/dist/src/events.js +341 -0
  39. package/dist/src/executor.d.ts +3 -0
  40. package/dist/src/executor.js +19 -2
  41. package/dist/src/file-response.d.ts +6 -0
  42. package/dist/src/file-response.js +30 -0
  43. package/dist/src/fork.js +3 -2
  44. package/dist/src/git/history.d.ts +7 -0
  45. package/dist/src/git/history.js +24 -0
  46. package/dist/src/git/index.d.ts +1 -0
  47. package/dist/src/git/index.js +1 -0
  48. package/dist/src/git/lfs.d.ts +28 -0
  49. package/dist/src/git/lfs.js +66 -0
  50. package/dist/src/git/objects.js +3 -8
  51. package/dist/src/git/smart-http.d.ts +3 -1
  52. package/dist/src/git/smart-http.js +67 -6
  53. package/dist/src/graphql-wire.d.ts +29 -0
  54. package/dist/src/graphql-wire.js +101 -0
  55. package/dist/src/grpc-wire.d.ts +67 -0
  56. package/dist/src/grpc-wire.js +170 -0
  57. package/dist/src/h2.d.ts +40 -0
  58. package/dist/src/h2.js +656 -0
  59. package/dist/src/head.d.ts +32 -3
  60. package/dist/src/head.js +161 -40
  61. package/dist/src/history.d.ts +1 -1
  62. package/dist/src/history.js +6 -6
  63. package/dist/src/hpack.json +1 -0
  64. package/dist/src/index.d.ts +64 -75
  65. package/dist/src/index.js +58 -101
  66. package/dist/src/log.js +28 -19
  67. package/dist/src/machines.d.ts +50 -0
  68. package/dist/src/machines.js +151 -0
  69. package/dist/src/managed-database.d.ts +86 -0
  70. package/dist/src/managed-database.js +283 -0
  71. package/dist/src/multipart.d.ts +11 -0
  72. package/dist/src/multipart.js +51 -0
  73. package/dist/src/observe.d.ts +15 -5
  74. package/dist/src/observe.js +23 -9
  75. package/dist/src/openai-wire.d.ts +108 -0
  76. package/dist/src/openai-wire.js +337 -0
  77. package/dist/src/pack-assets.d.ts +3 -4
  78. package/dist/src/pack-assets.js +15 -10
  79. package/dist/src/pack-fetch.d.ts +77 -0
  80. package/dist/src/pack-fetch.js +449 -0
  81. package/dist/src/pack-paths.d.ts +12 -0
  82. package/dist/src/pack-paths.js +86 -0
  83. package/dist/src/packRegistry.d.ts +69 -162
  84. package/dist/src/packRegistry.js +55 -20
  85. package/dist/src/people.d.ts +13 -0
  86. package/dist/src/people.js +18 -0
  87. package/dist/src/placeholder-image.d.ts +5 -0
  88. package/dist/src/placeholder-image.js +114 -0
  89. package/dist/src/protobuf.d.ts +28 -0
  90. package/dist/src/protobuf.js +332 -0
  91. package/dist/src/redis/engine.js +1 -1
  92. package/dist/src/request-scope.d.ts +1 -1
  93. package/dist/src/request-scope.js +6 -4
  94. package/dist/src/resource-blob.d.ts +5 -0
  95. package/dist/src/resource-blob.js +11 -0
  96. package/dist/src/runtime.d.ts +85 -0
  97. package/dist/src/runtime.js +104 -0
  98. package/dist/src/s3/wire.d.ts +60 -0
  99. package/dist/src/s3/wire.js +157 -0
  100. package/dist/src/scenario.d.ts +3 -0
  101. package/dist/src/scenario.js +2 -0
  102. package/dist/src/schema-sample.d.ts +1 -0
  103. package/dist/src/schema-sample.js +21 -0
  104. package/dist/src/sealed-box.d.ts +14 -0
  105. package/dist/src/sealed-box.js +225 -0
  106. package/dist/src/serve-http.d.ts +14 -0
  107. package/dist/src/serve-http.js +27 -3
  108. package/dist/src/serve.d.ts +6 -0
  109. package/dist/src/serve.js +69 -14
  110. package/dist/src/signing.d.ts +135 -0
  111. package/dist/src/signing.js +222 -0
  112. package/dist/src/sigv4.d.ts +48 -0
  113. package/dist/src/sigv4.js +167 -0
  114. package/dist/src/smtp.d.ts +16 -0
  115. package/dist/src/smtp.js +72 -0
  116. package/dist/src/sockets.d.ts +51 -0
  117. package/dist/src/sockets.js +90 -0
  118. package/dist/src/state-system.d.ts +1 -0
  119. package/dist/src/state-system.js +1 -1
  120. package/dist/src/storage.d.ts +1 -1
  121. package/dist/src/storage.js +3 -3
  122. package/dist/src/trace-context.js +1 -1
  123. package/dist/src/twin-fetch.d.ts +0 -7
  124. package/dist/src/twin-fetch.js +0 -14
  125. package/dist/src/vendor-call.d.ts +6 -0
  126. package/dist/src/vendor-call.js +41 -0
  127. package/dist/src/world-store.js +1 -1
  128. package/dist/vendor-hosts.cjs +36 -125
  129. package/dist/vendor-hosts.d.cts +8 -0
  130. package/generated/pack-facts.json +1410 -3069
  131. package/inject.cjs +64 -9
  132. package/pack-facts.cjs +44 -0
  133. package/package.json +17 -3
  134. package/src/actions.ts +23 -16
  135. package/src/ancestry.ts +74 -2
  136. package/src/anthropic-wire.ts +137 -0
  137. package/src/bytes.ts +42 -0
  138. package/src/changeset.ts +5 -5
  139. package/src/clickhouse/index.ts +6 -0
  140. package/src/clickhouse/sql.ts +3059 -0
  141. package/src/clickhouse/types.ts +44 -0
  142. package/src/clickhouse/values.ts +697 -0
  143. package/src/client-bundle.ts +2 -3
  144. package/src/cors.ts +34 -0
  145. package/src/derived-core.ts +1013 -146
  146. package/src/derived-real.ts +434 -0
  147. package/src/derived.ts +73 -3
  148. package/src/emit.ts +1 -2
  149. package/src/events.ts +449 -0
  150. package/src/executor.ts +24 -2
  151. package/src/file-response.ts +27 -0
  152. package/src/fork.ts +3 -2
  153. package/src/git/history.ts +19 -0
  154. package/src/git/index.ts +1 -0
  155. package/src/git/lfs.ts +67 -0
  156. package/src/git/objects.ts +3 -5
  157. package/src/git/smart-http.ts +56 -6
  158. package/src/graphql-wire.ts +106 -0
  159. package/src/grpc-wire.ts +159 -0
  160. package/src/h2.ts +627 -0
  161. package/src/head.ts +132 -41
  162. package/src/history.ts +6 -6
  163. package/src/hpack.json +1 -0
  164. package/src/index.ts +82 -329
  165. package/src/log.ts +27 -18
  166. package/src/machines.ts +151 -0
  167. package/src/managed-database.ts +299 -0
  168. package/src/multipart.ts +51 -0
  169. package/src/observe.ts +31 -15
  170. package/src/openai-wire.ts +371 -0
  171. package/src/pack-assets.ts +15 -11
  172. package/src/pack-fetch.ts +458 -0
  173. package/src/pack-paths.ts +72 -0
  174. package/src/packRegistry.ts +79 -167
  175. package/src/people.ts +31 -0
  176. package/src/placeholder-image.ts +88 -0
  177. package/src/protobuf.ts +251 -0
  178. package/src/redis/engine.ts +1 -1
  179. package/src/request-scope.ts +8 -4
  180. package/src/resource-blob.ts +13 -0
  181. package/src/runtime.ts +344 -0
  182. package/src/s3/wire.ts +172 -0
  183. package/src/scenario.ts +4 -0
  184. package/src/schema-sample.ts +24 -0
  185. package/src/sealed-box.ts +182 -0
  186. package/src/serve-http.ts +31 -3
  187. package/src/serve.ts +58 -14
  188. package/src/signing.ts +231 -0
  189. package/src/sigv4.ts +158 -0
  190. package/src/smtp.ts +76 -0
  191. package/src/sockets.ts +140 -0
  192. package/src/state-system.ts +2 -2
  193. package/src/storage.ts +3 -3
  194. package/src/trace-context.ts +1 -1
  195. package/src/twin-fetch.ts +0 -20
  196. package/src/vendor-call.ts +41 -0
  197. package/src/world-store.ts +1 -1
  198. package/vendor-hosts.cjs +36 -125
  199. package/vendor-hosts.d.cts +8 -0
  200. package/dist/src/mirror-shell.d.ts +0 -2
  201. package/dist/src/mirror-shell.js +0 -13
  202. package/dist/src/v1-removed.d.ts +0 -159
  203. package/dist/src/v1-removed.js +0 -124
  204. package/src/mirror-shell.ts +0 -15
  205. package/src/v1-removed.ts +0 -172
package/README.md CHANGED
@@ -18,12 +18,11 @@ execution. Payloads use the [blob storage contract](../../docs/contributing/arch
18
18
 
19
19
  ## Building a twin
20
20
 
21
- A protocol-2 twin implements its vendor's request/response semantics while the shared kernel
21
+ A twin implements its vendor's request/response semantics while the shared kernel
22
22
  owns log ordering, checkpoints, branching and the head's state system. Use the tree readers and
23
23
  write path exported by [`src/index.ts`](./src/index.ts); do not reconstruct a serve-time view by
24
24
  folding the log or use removed v1 confirmation/suppression APIs.
25
25
 
26
- [Architecture](../../docs/contributing/architecture.md) owns the boundaries and
27
- [adding a twin](../../docs/contributing/adding-a-twin.md) owns the implementation and verification
28
- process. Package protocol standing is recorded in the [generated index](../../generated/INDEX.md).
29
- Conformance tooling is a development dependency in `@volter/world-tooling`.
26
+ [Architecture](../../docs/contributing/architecture.md) owns the boundaries and the procedure a twin is built by
27
+ ([Creating a pack](../../docs/contributing/architecture.md#creating-a-pack)); [gates](../../docs/contributing/gates.md)
28
+ owns verification. Development tooling is in `@volter/world-tooling`.
package/app-route.cjs CHANGED
@@ -32,7 +32,7 @@ function readRoutes(instanceFile) {
32
32
  const now = Date.now();
33
33
  let held = APP_ROUTES.get(instanceFile);
34
34
  if (held && now - held.checkedAt < 1000) return held;
35
- if (!held) { held = { checkedAt: 0, mtimeMs: -1, routes: [], services: {}, twins: {} }; APP_ROUTES.set(instanceFile, held); }
35
+ if (!held) { held = { checkedAt: 0, mtimeMs: -1, routes: [], app: null, services: {}, twins: {} }; APP_ROUTES.set(instanceFile, held); }
36
36
  held.checkedAt = now;
37
37
  const fs = require('fs');
38
38
  const path = require('path');
@@ -50,28 +50,34 @@ function readRoutes(instanceFile) {
50
50
  const record = JSON.parse(fs.readFileSync(file, 'utf8'));
51
51
  const others = record.apps && typeof record.apps === 'object' ? Object.entries(record.apps) : [];
52
52
  held.routes = [entryRoute('app', record), ...others.map(([name, entry]) => entryRoute(name, entry))].filter(Boolean);
53
+ // the application itself, hosts recorded or not: where a name a hosting twin serves as it (claimedAppHosts) goes
54
+ held.app = { name: 'app', url: typeof record.url === 'string' ? record.url : null, hosts: new Set() };
53
55
  }
54
56
  // a route with hosts and no URL names the World's service of the application's name, wherever this boot put it
55
57
  const services = held.services;
56
- for (const route of held.routes) {
58
+ for (const route of [...held.routes, ...(held.app ? [held.app] : [])]) {
57
59
  const at = route.url ?? services[route.name]?.url;
58
60
  route.origin = typeof at === 'string' ? at.replace(/\/$/, '') : null;
59
61
  }
60
62
  } catch (error) {
61
63
  // gone: no route; caught mid-write: the last one read stands until the next look
62
64
  held.mtimeMs = -1;
63
- if (error && error.code === 'ENOENT') held.routes = [];
65
+ if (error && error.code === 'ENOENT') { held.routes = []; held.app = null; }
64
66
  }
65
67
  return held;
66
68
  }
67
69
 
68
70
  /** The application that answers `host` in the instance `instanceFile`, or null: never a name a vendor's host rule gives
69
71
  * a twin the World runs, which the twin answers instead. The twins are those the instance's env points at, with the
70
- * caller's own (`twins`: vendor keys as `twinOrigins` reads them, the injector's map). */
71
- function appRouteFor(instanceFile, host, twins = {}) {
72
+ * caller's own (`twins`: vendor keys as `twinOrigins` reads them, the injector's map). A host no record names that a
73
+ * hosting twin serves as the customer's application (`claimedAppHosts`, the `appHosts` its hostsClaimed door lists: a
74
+ * domain the app added to its own Vercel project) answers as the application itself, as the host's DNS sends it to
75
+ * the deployment in production. */
76
+ function appRouteFor(instanceFile, host, twins = {}, claimedAppHosts = null) {
72
77
  const bare = String(host || '').toLowerCase().replace(/\.$/, '');
73
78
  const held = readRoutes(instanceFile);
74
- const route = held.routes.find((r) => r.origin && appHostMatch(r.hosts, bare));
79
+ let route = held.routes.find((r) => r.origin && appHostMatch(r.hosts, bare));
80
+ if (!route && claimedAppHosts && held.app && held.app.origin && appHostMatch(claimedAppHosts, bare)) route = held.app;
75
81
  if (!route) return null;
76
82
  const runs = (vendor) => Object.hasOwn(held.twins, vendor) || Object.hasOwn(twins, vendor);
77
83
  return require('./vendor-hosts.cjs').vendorsOfHost(bare).some(runs) ? null : route;
package/app-route.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export interface AppRoute { readonly name: string; readonly origin: string; readonly url: string | null; readonly hosts: ReadonlySet<string> }
2
2
  export interface AppAnswer { readonly status: number; readonly headers: Record<string, string>; readonly body: string }
3
- export function appRouteFor(instanceFile: string | undefined, host: string, twins?: Readonly<Record<string, string>>): AppRoute | null;
3
+ export function appRouteFor(instanceFile: string | undefined, host: string, twins?: Readonly<Record<string, string>>, claimedAppHosts?: ReadonlySet<string> | null): AppRoute | null;
4
4
  export function appHostMatch(hosts: ReadonlySet<string>, host: string): boolean;
5
5
  export function appForwardHeaders(url: URL): Record<string, string>;
6
6
  export function appDestination(value: string | URL, env?: Readonly<Record<string, string | undefined>>): AppRoute | null;
@@ -32,7 +32,7 @@ function readRoutes(instanceFile) {
32
32
  const now = Date.now();
33
33
  let held = APP_ROUTES.get(instanceFile);
34
34
  if (held && now - held.checkedAt < 1000) return held;
35
- if (!held) { held = { checkedAt: 0, mtimeMs: -1, routes: [], services: {}, twins: {} }; APP_ROUTES.set(instanceFile, held); }
35
+ if (!held) { held = { checkedAt: 0, mtimeMs: -1, routes: [], app: null, services: {}, twins: {} }; APP_ROUTES.set(instanceFile, held); }
36
36
  held.checkedAt = now;
37
37
  const fs = require('fs');
38
38
  const path = require('path');
@@ -50,28 +50,34 @@ function readRoutes(instanceFile) {
50
50
  const record = JSON.parse(fs.readFileSync(file, 'utf8'));
51
51
  const others = record.apps && typeof record.apps === 'object' ? Object.entries(record.apps) : [];
52
52
  held.routes = [entryRoute('app', record), ...others.map(([name, entry]) => entryRoute(name, entry))].filter(Boolean);
53
+ // the application itself, hosts recorded or not: where a name a hosting twin serves as it (claimedAppHosts) goes
54
+ held.app = { name: 'app', url: typeof record.url === 'string' ? record.url : null, hosts: new Set() };
53
55
  }
54
56
  // a route with hosts and no URL names the World's service of the application's name, wherever this boot put it
55
57
  const services = held.services;
56
- for (const route of held.routes) {
58
+ for (const route of [...held.routes, ...(held.app ? [held.app] : [])]) {
57
59
  const at = route.url ?? services[route.name]?.url;
58
60
  route.origin = typeof at === 'string' ? at.replace(/\/$/, '') : null;
59
61
  }
60
62
  } catch (error) {
61
63
  // gone: no route; caught mid-write: the last one read stands until the next look
62
64
  held.mtimeMs = -1;
63
- if (error && error.code === 'ENOENT') held.routes = [];
65
+ if (error && error.code === 'ENOENT') { held.routes = []; held.app = null; }
64
66
  }
65
67
  return held;
66
68
  }
67
69
 
68
70
  /** The application that answers `host` in the instance `instanceFile`, or null: never a name a vendor's host rule gives
69
71
  * a twin the World runs, which the twin answers instead. The twins are those the instance's env points at, with the
70
- * caller's own (`twins`: vendor keys as `twinOrigins` reads them, the injector's map). */
71
- function appRouteFor(instanceFile, host, twins = {}) {
72
+ * caller's own (`twins`: vendor keys as `twinOrigins` reads them, the injector's map). A host no record names that a
73
+ * hosting twin serves as the customer's application (`claimedAppHosts`, the `appHosts` its hostsClaimed door lists: a
74
+ * domain the app added to its own Vercel project) answers as the application itself, as the host's DNS sends it to
75
+ * the deployment in production. */
76
+ function appRouteFor(instanceFile, host, twins = {}, claimedAppHosts = null) {
72
77
  const bare = String(host || '').toLowerCase().replace(/\.$/, '');
73
78
  const held = readRoutes(instanceFile);
74
- const route = held.routes.find((r) => r.origin && appHostMatch(r.hosts, bare));
79
+ let route = held.routes.find((r) => r.origin && appHostMatch(r.hosts, bare));
80
+ if (!route && claimedAppHosts && held.app && held.app.origin && appHostMatch(claimedAppHosts, bare)) route = held.app;
75
81
  if (!route) return null;
76
82
  const runs = (vendor) => Object.hasOwn(held.twins, vendor) || Object.hasOwn(twins, vendor);
77
83
  return require('./vendor-hosts.cjs').vendorsOfHost(bare).some(runs) ? null : route;
@@ -1,6 +1,6 @@
1
1
  export interface AppRoute { readonly name: string; readonly origin: string; readonly url: string | null; readonly hosts: ReadonlySet<string> }
2
2
  export interface AppAnswer { readonly status: number; readonly headers: Record<string, string>; readonly body: string }
3
- export function appRouteFor(instanceFile: string | undefined, host: string, twins?: Readonly<Record<string, string>>): AppRoute | null;
3
+ export function appRouteFor(instanceFile: string | undefined, host: string, twins?: Readonly<Record<string, string>>, claimedAppHosts?: ReadonlySet<string> | null): AppRoute | null;
4
4
  export function appHostMatch(hosts: ReadonlySet<string>, host: string): boolean;
5
5
  export function appForwardHeaders(url: URL): Record<string, string>;
6
6
  export function appDestination(value: string | URL, env?: Readonly<Record<string, string | undefined>>): AppRoute | null;