@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/src/bytes.ts ADDED
@@ -0,0 +1,42 @@
1
+ // Bytes a vendor's wire carries compressed, as a handler reads them. Web-standard compression streams where the runtime
2
+ // has them (workerd, the browser, Node), so the kernel's root keeps no static import of Node's zlib — a browser client
3
+ // imports this module too. Bun has neither `CompressionStream` nor `DecompressionStream` (Bun 1.2.20:
4
+ // `bun -e "typeof CompressionStream"` prints `undefined`), and a local World is served by Bun, so there the builtin is
5
+ // reached the way the kernel reaches every builtin: `process.getBuiltinModule`, at call time, never at import (the seam
6
+ // serve-http.ts's `nodeBuiltin` uses).
7
+
8
+ type Zlib = {
9
+ gzipSync(b: Uint8Array): Uint8Array;
10
+ gunzipSync(b: Uint8Array): Uint8Array;
11
+ deflateSync(b: Uint8Array): Uint8Array;
12
+ };
13
+
14
+ function zlib(what: string): Zlib {
15
+ const get = (globalThis as { process?: { getBuiltinModule?: (id: string) => unknown } }).process?.getBuiltinModule;
16
+ if (typeof get !== 'function') throw new Error(`${what}: this runtime has neither the compression streams nor node:zlib (process.getBuiltinModule)`);
17
+ return get('node:zlib') as Zlib;
18
+ }
19
+
20
+ async function streamed(bytes: Uint8Array, stream: CompressionStream | DecompressionStream): Promise<Uint8Array> {
21
+ const piped = new Response(bytes as unknown as BodyInit).body!.pipeThrough(stream as unknown as TransformStream<Uint8Array, Uint8Array>);
22
+ return new Uint8Array(await new Response(piped).arrayBuffer());
23
+ }
24
+
25
+ /** The bytes of a gzip member (a SARIF upload, a tarball's contents, a gzipped request body). */
26
+ export async function gunzip(bytes: Uint8Array): Promise<Uint8Array> {
27
+ if (typeof DecompressionStream === 'function') return streamed(bytes, new DecompressionStream('gzip'));
28
+ return new Uint8Array(zlib('gunzip').gunzipSync(bytes));
29
+ }
30
+
31
+ /** Bytes as a gzip member. */
32
+ export async function gzip(bytes: Uint8Array): Promise<Uint8Array> {
33
+ if (typeof CompressionStream === 'function') return streamed(bytes, new CompressionStream('gzip'));
34
+ return new Uint8Array(zlib('gzip').gzipSync(bytes));
35
+ }
36
+
37
+ /** Bytes as a zlib (deflate) member: git's object and pack framing. Reading one back is git/inflate.ts, which also
38
+ * reports how many bytes it consumed, since a packfile's objects sit one after another with no length. */
39
+ export async function deflate(bytes: Uint8Array): Promise<Uint8Array> {
40
+ if (typeof CompressionStream === 'function') return streamed(bytes, new CompressionStream('deflate'));
41
+ return new Uint8Array(zlib('deflate').deflateSync(bytes));
42
+ }
package/src/changeset.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolveReferences } from './references.ts';
2
- import { withAncestryLock } from './ancestry.ts';
2
+ import { withHistoryLocks } from './ancestry.ts';
3
3
  import { captureParentHistory, historyChanges, historyEntries, historyPrefix, readHistoryView, type HistoryReference } from './history.ts';
4
4
  import { worldPaths } from './storage.ts';
5
5
  // The changeset primitive — "commit" for operational reality (docs/concepts/the-model.md, v0).
@@ -221,7 +221,7 @@ export type Changeset = {
221
221
  pushedBy?: string;
222
222
  /** v3 — set by `rebaseChangeset`: the hash this object was rebased from, and when. Outside the hash. */
223
223
  rebasedFrom?: { contentHash: string; at: string };
224
- /** PROTOCOL 2 — where the parent log stood when this was cut, per state service (its entry count):
224
+ /** Where the parent log stood when this was cut, per state service (its entry count):
225
225
  * a rebase reads the parent's entries since here to name what moved under the changeset. Outside
226
226
  * the hash (metadata of the cut, not of the change). */
227
227
  cut?: Record<string, HistoryReference>;
@@ -262,7 +262,7 @@ export function captureMarker(opts: { id: string; world: string; ledgers: Ledger
262
262
  }
263
263
 
264
264
  function positionKey(service: string, stateService: string): string {
265
- return `${service}${stateService}`;
265
+ return `${service}\u0000${stateService}`;
266
266
  }
267
267
 
268
268
  /** A marker taken in world A says nothing about world B's ledgers — comparing them would
@@ -1001,12 +1001,12 @@ export type RebaseActionResult = {
1001
1001
  export type RebaseReport = { changeset: string; from: string; to: string | null; at: string; outcome: 'unchanged' | 'rebased' | 'conflict'; actions: RebaseActionResult[] };
1002
1002
 
1003
1003
  export function rebaseChangeset(changeset: Changeset, opts: { targets: RebaseTarget[]; at?: string }): { changeset: Changeset; report: RebaseReport } {
1004
- return withAncestryLock(() => rebaseChangesetLocked(changeset, opts));
1004
+ return withHistoryLocks(opts.targets.map((t) => worldPaths(t.stateService, t.controlRoot).dir), () => rebaseChangesetLocked(changeset, opts));
1005
1005
  }
1006
1006
  function rebaseChangesetLocked(changeset: Changeset, opts: { targets: RebaseTarget[]; at?: string }): { changeset: Changeset; report: RebaseReport } {
1007
1007
  const at = opts.at ?? new Date().toISOString();
1008
1008
  const targetFor = new Map(opts.targets.map((t) => [t.service, t]));
1009
- // PROTOCOL 2: what the parent did since the cut, per service — the entries past the cut position.
1009
+ // what the parent did since the cut, per service — the entries past the cut position.
1010
1010
  // A set action conflicts where the parent set the same field of the same subject to something
1011
1011
  // else; a subject the parent touched otherwise is rebased; the rest is unchanged.
1012
1012
  const sinceCut = new Map<string, Entry[]>();
@@ -0,0 +1,6 @@
1
+ // The kernel's ClickHouse® SQL engine (architecture, "The kernel owns shared mechanics"): parsed into an AST and evaluated
2
+ // over rows a pack supplies as a catalog of relations. Tinybird's pipes and PostHog's HogQL are ClickHouse SQL; each pack
3
+ // keeps its own front (Tinybird's templates, HogQL's tables and property access). Importing it does nothing.
4
+ export * from './values.ts';
5
+ export * from './types.ts';
6
+ export * from './sql.ts';