@volter/world-core 2.0.37 → 3.0.1

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
@@ -1,7 +1,23 @@
1
1
  import { type TwinResource } from './serve.js';
2
+ import { GitObjectStore } from './git/objects.js';
3
+ import { GitRefs } from './git/refs.js';
4
+ import { type SocketDecl, type SocketSession } from './sockets.js';
5
+ import { type MachinePool } from './machines.js';
6
+ import { type ApplicationAnswer, type EventRender, type EventScheme, type EventsDecl, type EventValues } from './events.js';
7
+ import type { RateBudgetDeclaration } from './rateBudget.js';
8
+ import { type HandlerCrypto } from './signing.js';
9
+ import { type ManagedDatabase } from './managed-database.js';
10
+ import { type RedisDialect, type RunItem } from './redis/engine.js';
11
+ import { type Mail, type SmtpRoute } from './smtp.js';
12
+ import { type MultipartPart } from './multipart.js';
13
+ import type { CorsDecl } from './cors.js';
2
14
  import type { DerivedCall, DerivedCoreOutcome, DerivedHandler, DerivedOperation } from './derived.js';
15
+ import type { PackDescriptor } from './packRegistry.js';
16
+ import type { ScenarioDecision, ScenarioHandler } from './scenario.js';
3
17
  /** How a stored field gets its value when the server assigns it. `now` is the world clock in the
4
18
  * manifest's time format; `id` the subject's id; a `value` is stored as given. */
19
+ /** A field the server assigns: the World clock's now, the subject's id, a fixed value, or a template over the stored
20
+ * fields (and `{id}`), base64-encoded when `encode` says (GitHub's `node_id`: `05:Label{id}` in base64). */
5
21
  export type FieldRule = {
6
22
  now: true;
7
23
  } | {
@@ -10,6 +26,7 @@ export type FieldRule = {
10
26
  value: unknown;
11
27
  } | {
12
28
  template: string;
29
+ encode?: 'base64';
13
30
  };
14
31
  /** A move of one state field, as data. `operation` is the operationId that causes it (an update
15
32
  * that requests `to` when absent); `from` the values it leaves; `effects` the other fields it writes;
@@ -28,7 +45,7 @@ export type Transition = {
28
45
  /** placeholders `{from}`, `{to}`, `{field}`, `{id}` */
29
46
  refusal?: {
30
47
  status: number;
31
- code?: string;
48
+ code?: string | number;
32
49
  message: string;
33
50
  };
34
51
  /** a refusal of its own for a particular current value (an invoice already `paid`) */
@@ -67,6 +84,16 @@ export type ResourceDecl = {
67
84
  /** the tree's subject type, when it differs from the resource name */
68
85
  storedAs?: string;
69
86
  idPrefix: string;
87
+ /** a setting held once per parent at a path of its own (`/v1/projects/{ref}/config/auth`, GET and PATCH, which the
88
+ * surface names by the schema its GET answers): keyed by the path's parameter, it answers `defaults` under what was
89
+ * written until first written, and an update merges into it, making it on first write */
90
+ setting?: {
91
+ defaults: Record<string, unknown>;
92
+ };
93
+ /** this resource's id template, when it is not the manifest's (`ids.template`): `{uuid}`, `{letters:20}` (twenty
94
+ * lowercase letters, a Supabase project ref), `{snowflake:<epoch ms>}` (Discord's ids), or a `{prefix}`/`{n}`
95
+ * template */
96
+ ids?: string;
70
97
  /** fields the server assigns on create */
71
98
  assigned?: Record<string, FieldRule>;
72
99
  state?: Record<string, StateField>;
@@ -96,17 +123,19 @@ export type ResourceDecl = {
96
123
  number?: {
97
124
  field: string;
98
125
  };
99
- /** how this resource renders a stored subject, when it differs from the pack's; it sees the subject's
100
- * address, which a stored shape may not carry */
101
- view?: (body: Record<string, unknown>, subject: {
102
- id: string;
103
- type: string;
104
- }) => Record<string, unknown>;
105
- /** an update replaces the fields it names (`replace`) or merges nested objects into them (`merge`, the default) */
106
- update?: 'merge' | 'replace';
126
+ /** the field the vendor's answer names a subject's id by, when it is not `id` (Daily's webhook `uuid`, Twilio's `sid`,
127
+ * Asana's `gid`): the subject's id is answered under it, and no `id` */
128
+ idAs?: string;
129
+ /** an update replaces the fields it names (`replace`), merges a nested object one level into them with `''` removing
130
+ * a key (`merge`, the default: Stripe's metadata), or merges nested objects at every level with `null` removing a key
131
+ * (`deep`: Clerk's metadata, "a deep merge … remove metadata keys at any level by setting their value to null") */
132
+ update?: 'merge' | 'replace' | 'deep';
107
133
  /** the stored subject id when it is not the path's last parameter: a template over the path
108
134
  * parameters (`{vector_store_id}::{file_id}`) */
109
135
  key?: string;
136
+ /** a resource every tenant shares (a catalogue the vendor keeps for all, its countries or currencies): the manifest's
137
+ * `tenant` does not scope it */
138
+ shared?: boolean;
110
139
  /** only subjects whose stored fields match are readable (a resource stored for every call but
111
140
  * answered only when asked to be kept) */
112
141
  readableWhen?: Record<string, unknown>;
@@ -122,11 +151,129 @@ export type ResourceDecl = {
122
151
  field: string;
123
152
  direction: 'asc' | 'desc';
124
153
  };
154
+ /** the list's ordering parameter (`order_by=-created_at`): `[+-]<field>` over `fields`, `default` when absent; any
155
+ * other field is refused with `invalid` (`{fields}` in its message names them), never ignored */
156
+ orderBy?: {
157
+ param: string;
158
+ fields: string[];
159
+ default: string;
160
+ invalid: ErrorSpec;
161
+ };
162
+ /** fields no two live subjects share (a permission's `key`; a membership's `organization_id` and `user_id` together):
163
+ * a create or update that would make a second one is refused with `refusal`, by the core and by `ctx.conflict` */
164
+ unique?: Array<{
165
+ fields: string[];
166
+ refusal: ErrorSpec;
167
+ }>;
168
+ /** the subjects a delete takes with it (an organization's memberships and invitations): each resource whose `field`
169
+ * holds the deleted subject's id, deleted first, each through the write path as its own delete (its events sent) */
170
+ cascade?: Array<{
171
+ resource: string;
172
+ field: string;
173
+ }>;
174
+ /** fields that name a subject as its id does (an organization by its id or its slug): a path's id and `ctx.find`
175
+ * match either */
176
+ alternateKeys?: string[];
177
+ /** the list's search parameter (`query`): a row matches on an `exact` field's whole value or a `partial` field's
178
+ * substring, case-insensitively */
179
+ search?: {
180
+ param: string;
181
+ exact?: string[];
182
+ partial?: string[];
183
+ };
184
+ /** fields that count this subject's children (an App's `installations_count`): the live subjects of `of` whose `by`
185
+ * holds this one's id, only those with `present` set when it is named, plus `plus` (a customer's
186
+ * `next_invoice_sequence` is one past its numbered invoices). The kernel keeps each whenever a child is written. */
187
+ counts?: Record<string, {
188
+ of: string;
189
+ by: string;
190
+ present?: string;
191
+ plus?: number;
192
+ }>;
193
+ /** how the vendor's state of this type is read back into a root (the real-system adapters, "Refresh"): the list that
194
+ * enumerates it (once per parent, under `parent`; `complete: false` when it is not the whole type; `items`, the answer's
195
+ * path to them, when the spec does not name the list it answers), the one read of a singleton, or `none` with why the
196
+ * vendor offers no read-back. Every stored resource the vendor holds declares one. */
197
+ refresh?: {
198
+ list: string;
199
+ complete?: false;
200
+ items?: string;
201
+ } | {
202
+ get: string;
203
+ } | {
204
+ none: string;
205
+ };
206
+ /** the other resources one create of this one makes, and where its answer names each's id (a JSON path) */
207
+ companions?: Record<string, string>;
208
+ /** the field telling a newer copy of a subject from an older (an `updated_at`): an ingested event older than the
209
+ * root's copy folds nothing */
210
+ version?: string;
211
+ };
212
+ /** How a vendor's signed webhooks are folded into a root (the real-system adapters, "Ingest"). */
213
+ export type IngestDecl = {
214
+ scheme: EventScheme | ReadonlyArray<EventScheme>;
215
+ /** where the event names its type: a header, a body path, and a sub-action path joined to it with `.` */
216
+ type: {
217
+ header?: string;
218
+ body?: string;
219
+ action?: string;
220
+ };
221
+ /** the JSON path of the event's object */
222
+ object: string;
223
+ /** event type → the resource it carries, where `events.types` read backwards and `<resource>.created|updated|deleted`
224
+ * do not say it */
225
+ types?: Record<string, {
226
+ resource: string;
227
+ deleted?: true;
228
+ }>;
229
+ /** an event answered instead of folded (Slack's url_verification): the body fields it matches, and the answer, a
230
+ * `$body.<path>` read from the event or a literal */
231
+ handshake?: {
232
+ when: Record<string, string>;
233
+ answer: string;
234
+ };
235
+ };
236
+ /** Which lane a request is the vendor's gateway's to send ("Other wires: lanes"), each condition it names holding: a
237
+ * path under `path` (Supabase's `/rest/v1`), a host matching `host` (a regular expression: `^secretsmanager\.`), a
238
+ * header starting with `header.prefix` (AWS's `x-amz-target: secretsmanager.`), and a host not in `exceptHosts`. */
239
+ export type LaneRoute = {
240
+ lane: string;
241
+ path?: string;
242
+ host?: string;
243
+ exceptHosts?: ReadonlyArray<string>;
244
+ /** a header starting with `prefix`, or, with `absent`, a request whose header does not (Clerk's Frontend API is asked
245
+ * without a Backend API secret key) */
246
+ header?: {
247
+ name: string;
248
+ prefix: string;
249
+ absent?: true;
250
+ };
251
+ /** where two of the vendor's APIs share one address: the route passes a path only the root's API serves (the lane's
252
+ * surface does not), which is the root's */
253
+ unlessOnlyRoot?: true;
254
+ };
255
+ /** A vendor's lanes: its routes, first match first, the lane that takes what no route names (`default`), and the
256
+ * gateway's CORS. A `/_twin/` door goes to the lane whose manifest declares it. */
257
+ export type LanesDecl = {
258
+ cors?: CorsDecl;
259
+ routes: ReadonlyArray<LaneRoute>;
260
+ default?: string;
125
261
  };
262
+ /** The manifest of a vendor whose every API is a lane (Cloudflare's API v4 and R2, AWS's services): no API of its own,
263
+ * only what the vendor's front says — its discovery facts, its lanes and its descriptor. */
264
+ export type VendorManifest = {
265
+ vendor: string;
266
+ discovery?: DerivedManifest['discovery'];
267
+ lanes: LanesDecl;
268
+ descriptor: Omit<PackDescriptor, 'vendor'>;
269
+ ingest?: IngestDecl;
270
+ rateBudget?: RateBudgetDeclaration;
271
+ };
272
+ /** `code` as the vendor writes it: a string, or a number (Discord's JSON error codes are integers) */
126
273
  export type ErrorSpec = {
127
274
  status: number;
128
275
  message: string;
129
- code?: string;
276
+ code?: string | number;
130
277
  param?: string;
131
278
  kind?: string;
132
279
  };
@@ -136,8 +283,12 @@ export type ErrorSpec = {
136
283
  * vendor's way, each a (screen, control) cell. */
137
284
  export type ScreenDecl = {
138
285
  id: string;
139
- kind: 'flow' | 'workspace';
286
+ /** a hosted flow a person is sent through, a workspace they work in, or a content host serving what the vendor stores
287
+ * (its CDN: an uploaded image, a video, a default avatar) */
288
+ kind: 'flow' | 'workspace' | 'content';
140
289
  host: string;
290
+ /** every other host the screen answers on (a sandbox's dashboard and production's, one page) */
291
+ hosts?: string[];
141
292
  path: string;
142
293
  demand: string;
143
294
  status: 'done' | 'todo';
@@ -146,15 +297,35 @@ export type ScreenDecl = {
146
297
  source: string;
147
298
  };
148
299
  export type DerivedManifest = {
300
+ /** The pack's descriptor, as data (docs/contributing/architecture.md, "The descriptor"), every field but `vendor`, which
301
+ * is the manifest's: the pack registers `packOf(manifest)`, so its index is a fixed file. A lane has none. */
302
+ descriptor?: Omit<PackDescriptor, 'vendor'>;
149
303
  vendor: string;
150
304
  /** the kernel service the pack writes */
151
305
  service: string;
152
306
  /** `json: 'always'` reads a body as JSON whatever its content type (GitHub does) */
307
+ /** `strict`: a vendor that refuses a body field its operation does not declare, a value of another type, or a number
308
+ * outside the spec's bounds (a NestJS validation pipe: Supabase's "property x should not exist"), with its messages;
309
+ * `{name}`, `{type}` (`a string`, `an integer`), `{min}` and `{max}` are filled. `ctx.fields` checks a body so. */
153
310
  body: {
154
311
  form?: {
155
312
  coerce: boolean;
156
313
  };
157
314
  json?: 'always';
315
+ validation?: {
316
+ operations?: ReadonlyArray<string>;
317
+ status: number;
318
+ missing: unknown;
319
+ type: unknown;
320
+ range: unknown;
321
+ };
322
+ strict?: {
323
+ status: number;
324
+ code?: string;
325
+ unknown: string;
326
+ type: string;
327
+ range: string;
328
+ };
158
329
  };
159
330
  /** `acceptProvided`: a create that names its own `id` keeps it (a vendor that seeds by id). The template counts
160
331
  * (`{prefix}_{n}`), or is `{uuid}` for a vendor whose ids are UUIDs: the next is derived from the resource and its
@@ -168,7 +339,22 @@ export type DerivedManifest = {
168
339
  /** operations that only read though nothing in the spec says so (a POST that returns data):
169
340
  * a read-only twin answers them */
170
341
  reads?: string[];
171
- time: 'unix' | 'iso';
342
+ /** how the vendor writes an instant: Unix seconds, Unix milliseconds (Clerk's `created_at`), or ISO 8601 */
343
+ time: 'unix' | 'unix-ms' | 'iso';
344
+ /** the vendor's CORS, as its gateway answers a browser (cors.ts): the pack's fetch is served behind `withCors` */
345
+ cors?: CorsDecl;
346
+ /** the HTTP status a vendor answers every error below `below` with, when its body names the error's own status
347
+ * (storage-api: 400 for every error but a 500, the body's `statusCode` the error's: `{ status: 400, below: 500 }`) */
348
+ errorsAnsweredAs?: {
349
+ status: number;
350
+ below: number;
351
+ };
352
+ /** the texts the vendor reads as a boolean in a parameter, compared without case (Supabase: `true`, `1`, `yes`, `on`,
353
+ * `y`, `enabled` and their opposites); absent, `true` and `false`. `ctx.flag` reads with them. */
354
+ booleans?: {
355
+ truthy: string[];
356
+ falsy: string[];
357
+ };
172
358
  /** the vendor's error body, with `{message}`, `{code}`, `{param}`, `{kind}` placeholders; a
173
359
  * placeholder with no value is left out when `errorOmitsAbsent` */
174
360
  error: unknown;
@@ -186,6 +372,18 @@ export type DerivedManifest = {
186
372
  pattern: string;
187
373
  error: ErrorSpec;
188
374
  };
375
+ /** request headers that carry meaning to the vendor (a tenant header such as `Stripe-Account`): recorded with a write
376
+ * so its perform sends them again (the real-system adapters, "What a pack declares"); `version.header` is too */
377
+ headers?: string[];
378
+ /** the vendor's signed webhooks, folded into a root */
379
+ ingest?: IngestDecl;
380
+ /** the vendor's documented limits, charged by the executor on every live call (D8) */
381
+ rateBudget?: RateBudgetDeclaration;
382
+ /** a pack whose wire has no derived perform (a socket, a line protocol, a managed database): binding a root is refused
383
+ * with this reason */
384
+ vendorBacked?: {
385
+ none: string;
386
+ };
189
387
  /** `withParam`: the error names the path parameter that held the unknown id */
190
388
  notFound: {
191
389
  status: number;
@@ -214,7 +412,7 @@ export type DerivedManifest = {
214
412
  encoding: 'base64-offset';
215
413
  };
216
414
  /** numbered pages (1-based `page`, the size in `limit.param`), with the vendor's `Link` header
217
- * naming the first, previous, next and last pages */
415
+ * naming the first, previous, next and last pages (`link`); the envelope may name `{total_count}` and `{max_page}` */
218
416
  page?: {
219
417
  param: string;
220
418
  link: boolean;
@@ -264,15 +462,38 @@ export type DerivedManifest = {
264
462
  };
265
463
  /** how the vendor reads its credential, and what it answers without one or with a key the twin
266
464
  * reserves as invalid, or one of a shape the vendor never issues (`keyFormat`, a pattern every key it issues
267
- * matches: Resend's begin `re_`); a request that presents no such header at all is a trusted in-process call */
465
+ * matches: Resend's begin `re_`); a request that presents no such header at all is a trusted in-process call.
466
+ * `held`: the key must be one the account holds, kept by its SHA-256 in a stored type's field (a token a Tokens page
467
+ * made: `{ storedAs: '_access_token', hashField: 'sha256' }`), or one of the World's `standing` keys (the one its
468
+ * seeds and init hand the app); any other is `invalid`. */
469
+ /** how the vendor reads its credential: the `header`, after its `scheme` (`''`: the header's whole value, an
470
+ * `x-api-key`), or any of `also` (ElevenLabs' `xi-api-key` beside `Authorization`, Google's `?key=`); `paths` (a
471
+ * regular expression) the paths it gates, every other passing ungated; a key the World issued is `held` by its hash */
268
472
  auth?: {
269
473
  header: string;
270
474
  scheme: string;
475
+ also?: Array<{
476
+ header?: string;
477
+ scheme?: string;
478
+ query?: string;
479
+ }>;
480
+ paths?: string;
271
481
  missing: ErrorSpec;
272
482
  invalidKeys: string[];
273
483
  keyFormat?: string;
274
484
  invalid: ErrorSpec;
275
485
  gateWhenAbsent: boolean;
486
+ held?: {
487
+ storedAs: string;
488
+ hashField: string;
489
+ standing?: string[]; /** a field set true on a key no longer held (OpenRouter's `disabled`) */
490
+ unless?: string;
491
+ };
492
+ /** operations that check a credential of their own, not the account's (Cloudflare's asset upload reads its upload
493
+ * session's JWT from the same header): the gate leaves them to their handler */
494
+ exempt?: string[];
495
+ /** the vendor checks the key before it routes: a path it does not have is refused a missing or invalid key first */
496
+ beforeRouting?: boolean;
276
497
  };
277
498
  /** the twin door that makes the next request answer the vendor's rate-limit refusal */
278
499
  /** headers every answer carries (a request id) */
@@ -282,12 +503,105 @@ export type DerivedManifest = {
282
503
  origin?: {
283
504
  placeholder: string;
284
505
  };
285
- /** while a pack moves, how its existing code renders a stored subject (named by its stored
286
- * type), so moved and unmoved operations answer the same shape */
287
- view?: (storedType: string, body: Record<string, unknown>) => Record<string, unknown>;
288
506
  resources: Record<string, ResourceDecl>;
507
+ /** Read-only cross-pack credential subjects of the same vendor (architecture A3); no root is exposed to handlers. */
508
+ ownerReads?: ReadonlyArray<{
509
+ owner: string;
510
+ resource: string;
511
+ }>;
289
512
  /** the vendor's screens this pack serves or owes (demand decides which exist) */
290
513
  screens?: ScreenDecl[];
514
+ /** The discovery door's facts (`GET /twin`): what the twin is of, what it stores, and how it is authenticated. */
515
+ discovery?: {
516
+ twinOf: string;
517
+ stores: string;
518
+ identity?: string;
519
+ notes?: string;
520
+ /** a model vendor's: what its scenario scripts (the `on` keys and the `respond` shape), and a handler as an example */
521
+ behavior?: string;
522
+ exampleHandler?: ScenarioHandler;
523
+ };
524
+ /** The World's doors (architecture, "Doors, screens and the gap"): each a method and a path under `/_twin/` (with
525
+ * `{param}` segments), answered by the export of `semantics/doors.ts` its id names, over the contract's context. */
526
+ doors?: Array<{
527
+ id: string;
528
+ method: string;
529
+ path: string;
530
+ note?: string;
531
+ }>;
532
+ /** The vendor's GraphQL API beside its REST one (`semantics/graphql.ts` over `generated/graphql-sdl.gen.json`): the
533
+ * paths it is POSTed to, and the answer to a query selecting a field nothing models (`{field}`, `{type}`). */
534
+ graphql?: {
535
+ paths: ReadonlyArray<string>;
536
+ unmodeled: {
537
+ message: string;
538
+ type?: string;
539
+ status?: number;
540
+ };
541
+ };
542
+ /** The vendor's answer for a path nothing serves and an operation nothing models, `{method}` and `{path}` filled
543
+ * (OpenAI's `Unknown request URL: {method} {path}`); the manifest's `notFound` when it names none. */
544
+ gap?: ErrorSpec;
545
+ /** The vendor's answer for a path its API serves under other methods than the request's (`405 Method not allowed:
546
+ * {method} {path}`), `{method}` and `{path}` filled; the gap when it names none. */
547
+ wrongMethod?: ErrorSpec;
548
+ /** The content codings the vendor reads a request's body in (its Content-Encoding: Tinybird's "Gzip or Zstandard"
549
+ * events) and answers in when the request accepts one (Accept-Encoding), and its answer for a body that does not
550
+ * decode as its Content-Encoding says. The kernel decodes before routing and encodes the API's answer. */
551
+ encodings?: {
552
+ request?: ReadonlyArray<'gzip' | 'zstd' | 'deflate' | 'br'>;
553
+ response?: ReadonlyArray<'gzip'>;
554
+ undecodable?: ErrorSpec;
555
+ };
556
+ /** The content type the vendor labels a JSON answer with, when it is not the runtime's (Clerk's exact
557
+ * `application/json`, which @clerk/backend reads a body as JSON only on): every JSON answer relabelled. */
558
+ jsonContentType?: string;
559
+ /** The vendor's tenancy (architecture, "The derived core"): each stored subject belongs to the tenant it was made in —
560
+ * an organization, a team, an account — and a caller reaches only its own tenant's, as a parent's children are
561
+ * reached under it. `field` holds it on each subject; `semantics/tenant.ts` names the caller's. The core scopes every
562
+ * read, list, update and delete by it and stamps it on every create, for each resource not `shared`. */
563
+ tenant?: {
564
+ field: string;
565
+ };
566
+ /** The vendor's own lanes behind this manifest's API ("Other wires: lanes"), dispatched by the kernel before the
567
+ * vendor's own doors, clock and API (LanesDecl). */
568
+ lanes?: LanesDecl;
569
+ /** A host whose first label is part of the path, as a regular expression over the request's vendor host whose first
570
+ * capture is put in front of the path before routing (S3's virtual-hosted addressing: `<bucket>.<endpoint>/<key>` is
571
+ * `/<bucket>/<key>`); the host itself is left as it came. */
572
+ pathFromHost?: string;
573
+ /** A prefix the vendor's hosts may put before a path (turbopuffer's region, `/aws-us-east-1`), as a regular expression
574
+ * matched at the path's start: stripped before routing, so the operation it names is the one served. Its named groups
575
+ * (Jira's `/ex/jira/(?<cloudId>[^/]+)`) are the operation's parameters as well. */
576
+ pathPrefix?: string;
577
+ /** A pattern over the request's vendor host whose named groups are the operation's parameters (E2B's envd answers each
578
+ * sandbox at `49983-<sandboxID>.e2b.app`: `^\\d+-(?<sandboxID>[a-z0-9]+)\\.`). */
579
+ hostParams?: string;
580
+ /** The persistent wires the vendor's clients hold open (sockets.ts: Discord's Gateway): each served at its path by
581
+ * the pack's `semantics/sockets.ts`, which the kernel offers every write after its webhooks. */
582
+ sockets?: ReadonlyArray<SocketDecl>;
583
+ /** The vendor speaks gRPC (architecture, "Other wires": gRPC): its server answers HTTP/2 and HTTP/1 on one port, each
584
+ * rpc (by its proto unit's schema, `src/generated/proto.gen.json`) through the pack's own fetch. */
585
+ grpc?: true;
586
+ /** The vendor runs its customers' images (machines.ts: Fly's Machines): the kernel serves `POST /_twin/machine-pool`
587
+ * and hands handlers the World's pool as `ctx.machines`. */
588
+ machines?: boolean;
589
+ /** A lane routed by host ("Other wires: lanes"): the hosts it serves, each exact or a suffix. The vendor's server sends
590
+ * them here, and SHAPE judges the lane on them alone, never on a page or door of the vendor on another host. */
591
+ hosts?: ReadonlyArray<{
592
+ host?: string;
593
+ suffix?: string;
594
+ }>;
595
+ /** The path parameters whose values span segments where the spec cannot say so (an OpenAPI path has no greedy label:
596
+ * GitHub's `{ref}`, QStash's `{destination}`); a Smithy model's greedy labels are the surface's own `spanning`. */
597
+ spanning?: ReadonlyArray<string>;
598
+ /** The webhooks the vendor sends for its writes, as data the kernel renders, signs, delivers and records (events.ts);
599
+ * `render` is the pack's `semantics/events.ts`, how the vendor renders an event's `data` when it is not the written
600
+ * object. */
601
+ events?: EventsDecl & {
602
+ render?: EventRender<WriteHookContext>;
603
+ values?: EventValues<WriteHookContext>;
604
+ };
291
605
  /** called after every stored write with the rendered resource, its stored type and the kernel operation name */
292
606
  onWrite?: (write: {
293
607
  operation: string;
@@ -301,6 +615,15 @@ export type DerivedManifest = {
301
615
  context(): Promise<WriteHookContext>;
302
616
  }) => Promise<void>;
303
617
  };
618
+ /** A body's fields as a strict vendor checks them (`ctx.fields`, the manifest's `body.strict`). Without `strict`, every
619
+ * field passes. An object or array field is not typed here: its own shape is the handler's. */
620
+ export declare function strictFields(m: DerivedManifest, operation: DerivedOperation, body: Record<string, unknown>): {
621
+ fields: Record<string, unknown>;
622
+ } | {
623
+ refused: Response;
624
+ };
625
+ /** A value as the vendor reads a boolean (`ctx.flag`, the manifest's `booleans`). */
626
+ export declare function flagOf(m: Pick<DerivedManifest, 'booleans'>, value: unknown): boolean | undefined;
304
627
  /** A form body's bracket notation (`a[b][0][c]=v`, `expand[]=x`) as nested objects and arrays. A form carries only
305
628
  * text: a field the operation's spec types as a number or a boolean (`scalars`, by bracket path, written by
306
629
  * world-tooling's formScalarsOf) is read as one when its text is that literal; every other field stays the text sent
@@ -311,6 +634,7 @@ export declare function parseBracketForm(text: string, scalars?: Readonly<Record
311
634
  * every form value is its text. */
312
635
  export declare function readParams(manifest: DerivedManifest, request: Request, operation?: DerivedOperation): Promise<Record<string, unknown>>;
313
636
  export declare function vendorError(manifest: DerivedManifest, e: ErrorSpec): Response;
637
+ export declare const storedType: (m: DerivedManifest, resource: string) => string;
314
638
  /** A service's resources of one type, each the reader's own copy: `twinResources` filtered by type, from an index
315
639
  * that follows each write rather than projecting the whole tree per call. */
316
640
  export declare function resourcesOfType(service: string, type: string, root?: string): TwinResource[];
@@ -320,19 +644,33 @@ export declare function resourcesOfType(service: string, type: string, root?: st
320
644
  export declare function render(r: TwinResource): Record<string, unknown>;
321
645
  /** Where the core runs: the World root it reads and writes, and its clock (the World's by default;
322
646
  * a caller that pins an instant passes its own). */
647
+ /** One call of a protocol-3 pack's default data (`src/semantics/seed.ts` exports `seed: SeedCall[]`): a request to the
648
+ * vendor's own operation (or the pack's door), made in order against the twin by the runner `volter-world init` writes
649
+ * beside the copied data. */
650
+ export type SeedCall = {
651
+ method: string;
652
+ path: string;
653
+ body?: unknown;
654
+ headers?: Record<string, string>;
655
+ };
656
+ /** Where a call is answered: the World's root, its clock, and the managed Postgres the runtime binds to the pack
657
+ * (`database`, the descriptor's `managedDatabase`), which a handler reaches as `ctx.engine` — READ ONLY in every
658
+ * transaction when the twin is (`readOnly`) or the request is (x-volter-read-only). */
323
659
  export type CoreScope = {
324
660
  root?: string;
325
661
  clock?: () => string;
662
+ database?: string;
663
+ readOnly?: boolean;
664
+ /** `semantics/tenant.ts`: the tenant the caller acts in (the manifest's `tenant`), or undefined for none */
665
+ tenant?: (ctx: HandlerContext) => string | undefined | Promise<string | undefined>;
326
666
  };
667
+ /** The lane a vendor's router sent a request to (pack-fetch's laneRouter sets it). */
668
+ export declare const LANE_HEADER = "x-volter-lane";
327
669
  /** What a coverage measurement sees of a pack's declared state logic: each move a request made and each refusal a
328
670
  * guard gave, by the transition that decided it. Nothing is observed unless a measurement installs an observer
329
671
  * (scripts/life-coverage.ts); serving never depends on it. */
330
672
  export type TransitionObserver = (decl: StateField, transition: Transition, outcome: 'moved' | 'refused', from: string) => void;
331
673
  export declare function observeTransitions(observer: TransitionObserver | undefined): void;
332
- /** The transition a request asks for on one state field, or the vendor's refusal when none applies. */
333
- /** What a declared machine says to one move: the transition that allows it, or the refusal it gives (and
334
- * nothing when it declares neither). The derived core and `legal` ask it; so does an engine that is not
335
- * HTTP-shaped (a line protocol's session), so one machine rules every wire. */
336
674
  export declare function transitionFor(field: string, decl: StateField, operationId: string, current: unknown, requested: unknown, id?: string, actor?: Actor): {
337
675
  move?: Transition;
338
676
  refusal?: ErrorSpec;
@@ -342,7 +680,7 @@ export type CoreOutcome = {
342
680
  } | {
343
681
  unmodeled: string;
344
682
  };
345
- /** Serve one operation from the manifest, or say why the core cannot. */
683
+ export declare function mergeField(rule: ResourceDecl['update'], prior: unknown, next: unknown): unknown;
346
684
  export declare function serveCore(m: DerivedManifest, call: DerivedCall, scope?: CoreScope): Promise<CoreOutcome>;
347
685
  /** Server-sent events in the manifest's framing. The events are known when the answer starts: the
348
686
  * twin decides deterministically, so the stream carries a decided answer, never a model's. */
@@ -363,13 +701,69 @@ export type SemanticsContext = {
363
701
  text: string;
364
702
  root: string | undefined;
365
703
  occurredAt: string;
704
+ /** The twin's own base URL as this request reached it (its links and redirects to its own pages carry it). */
705
+ publicBase: string;
706
+ /** What the World's scenario decided for this turn (a model vendor's answer: the handler matched, or the miss), on an
707
+ * operation the pack's `semantics/scenario.ts` names; undefined elsewhere, or when the World carries no scenario. */
708
+ scenario: ScenarioDecision | undefined;
709
+ /** A message the vendor sends the application's own server that no declared event is (a push notification), through
710
+ * the World's route and egress rule: the receiver's status, or 0 when refused or unreachable. */
711
+ deliver(url: string, init: RequestInit): Promise<number>;
712
+ /** A message the vendor sends the application's server and decides by its answer, waited on for at most `within`
713
+ * milliseconds (a real-time authorization request): its status and body, or why there was none. */
714
+ ask(url: string, init: RequestInit, within: number): Promise<ApplicationAnswer>;
715
+ /** A git repository of the World, by the pack's name for it (the git plane, world-core git/): its objects in the
716
+ * World's content-addressed object store (one per service), its refs in the World's store. Served over smart HTTP
717
+ * (`git.serveSmartHttp`), read and written through the library's codecs. */
718
+ git(name: string): {
719
+ store: GitObjectStore;
720
+ refs: GitRefs;
721
+ };
722
+ /** A value the World set for its application (world-env.ts): what the app was given and the vendor must agree with (a
723
+ * webhook signing secret the app verifies with), never the caller's own shell; undefined when the World sets none. */
724
+ worldEnv(name: string): string | undefined;
725
+ /** Runs `fn` as the vendor's own move, not the caller's: what time makes due (a renewal a read catches up) is
726
+ * recorded with no caller, wherever a handler reaches it. */
727
+ asVendor<T>(fn: () => Promise<T>): Promise<T>;
728
+ /** A mail the vendor sends a person, over SMTP to the route its settings name (smtp.ts), under the World's egress rule;
729
+ * throws when it cannot be delivered. */
730
+ mail(route: SmtpRoute, mail: Mail, headers?: Record<string, string>): Promise<void>;
366
731
  /** who is calling, when the manifest says how to tell */
367
732
  actor: string | undefined;
368
733
  now(): unknown;
369
734
  get(resource: string, id: string): Record<string, unknown> | undefined;
735
+ /** One credential subject in a manifest-declared owner's World store. Ambiguous stores refuse the read. */
736
+ ownerRow(owner: string, resource: string, id: string): Record<string, unknown> | undefined;
370
737
  rows(resource: string): Array<Record<string, unknown>>;
371
738
  mint(resource: string): string;
739
+ /** An id the vendor issues for what it does not keep (a completion's, a request's): minted, and its subject recorded,
740
+ * so the next is another; a read-only request mints without recording. The resource is a declared bookkeeping type. */
741
+ issue(resource: string): Promise<string>;
742
+ /** The vendor's open sessions of one of its sockets in this World (a request answered by a session: sockets.ts). */
743
+ sockets(id: string): SocketSession[];
744
+ /** A secret for `label` (an app's client secret, a store's read token): an HMAC under a seed the World makes once, at
745
+ * random, and keeps as bookkeeping no door answers. The same label gives the same secret for the World's whole life,
746
+ * and no one can compute it from ids the World shows, as they can a value derived from them alone. */
747
+ secret(label: string): Promise<string>;
748
+ /** The World's machine pool (machines.ts), as the pack's `machine-pool` door enrolled it; `none` when none was. */
749
+ machines: MachinePool;
750
+ /** A signing key pair for `label` (an issuer's ID tokens, a provider's JWTs, a CA's or a log's key), PEM: RSA 2048
751
+ * (the default) or Ed25519, made once, at random, when the label is first asked for, and kept as bookkeeping no door
752
+ * answers, so what it signs verifies against the World's published key (ctx.crypto.jwks of the public half) and no
753
+ * one can forge it from anything the pack or the World shows, as they can with a key written in the pack. */
754
+ signingKey(label: string, alg?: 'RS256' | 'Ed25519'): Promise<{
755
+ privatePem: string;
756
+ publicPem: string;
757
+ }>;
758
+ /** The signing key for `label` when the World has made it (`signingKey`), else undefined: for code that signs where it
759
+ * cannot wait (a cookie's token, read everywhere), after a front made the key before anything is answered. */
760
+ heldSigningKey(label: string, alg?: 'RS256' | 'Ed25519'): {
761
+ privatePem: string;
762
+ publicPem: string;
763
+ } | undefined;
372
764
  write(resource: string, id: string, fields: Record<string, unknown>, operation: string): Promise<Record<string, unknown>>;
765
+ /** Add numeric deltas to an existing bookkeeping row under the kernel's atomic write seam. */
766
+ accumulate(resource: string, id: string, deltas: Record<string, number>, operation: string): Promise<void>;
373
767
  /** `write`, with what a live vendor answered when the head performed it */
374
768
  writeDetailed(resource: string, id: string, fields: Record<string, unknown>, operation: string): Promise<{
375
769
  body: Record<string, unknown>;
@@ -378,6 +772,9 @@ export type SemanticsContext = {
378
772
  }>;
379
773
  /** The id a subject has now, for an id a caller may still use from before the vendor minted its own
380
774
  * (a branch naming a message by the ts it minted locally). */
775
+ /** The tree's type a resource's rows are kept under (the manifest's `storedAs`, else its name): what an operation on
776
+ * it is named by (`issuing_card.create`), as the vendor names the events it sends. */
777
+ storedType(resource: string): string;
381
778
  resolve(resource: string, id: string): string;
382
779
  /** Answer the vendor's success envelope around several fields (`{ ok: true, ts, channel, message }`). */
383
780
  ok(fields: Record<string, unknown>): Response;
@@ -418,6 +815,8 @@ export type SemanticsContext = {
418
815
  /** Whether the machine lets `operationId` move `field` from `current` (to `to`): nothing when it
419
816
  * does, the vendor's refusal when it does not. A move the machine does not declare throws. */
420
817
  legal(resource: string, field: string, operationId: string, current: unknown, to?: string, id?: string, actor?: Actor): ErrorSpec | undefined;
818
+ /** Validate the request body's top-level derived schema under body.validation, before a write. */
819
+ validate(): Response | undefined;
421
820
  refuse(e: ErrorSpec): Response;
422
821
  notFound(resource: string, id: string, param?: string): Response;
423
822
  reply(body: unknown, status?: number): Response;
@@ -428,7 +827,7 @@ export type SemanticsContext = {
428
827
  event?: string;
429
828
  data: unknown;
430
829
  }>): Response;
431
- expand(resource: string, body: Record<string, unknown>): Record<string, unknown>;
830
+ expand(resource: string, body: Record<string, unknown>, paths?: string[]): Record<string, unknown>;
432
831
  /** This context at another moment of the World clock (ISO): a move time makes is written at the moment it fell due. */
433
832
  at(when: string): Promise<SemanticsContext>;
434
833
  /** This call's context over another manifest of the same service, at the same moment: a lane over its vendor's
@@ -438,6 +837,61 @@ export type SemanticsContext = {
438
837
  core(): Promise<Response | undefined>;
439
838
  /** A stored row's own fields, as the vendor's object carries them (an `id`, `type` or `updatedAt` of its own restored). */
440
839
  own(row: Record<string, unknown>): Record<string, unknown>;
840
+ /** A handler's own rows (views) answered as the call's list: the resource's filters, search and order, then the
841
+ * manifest's paging and envelope; the vendor's refusal when the call orders by a field the resource does not take. */
842
+ list(resource: string, rows: Array<Record<string, unknown>>): Response;
843
+ /** The vendor's refusal when these fields would make a second live subject where the resource's `unique` rules allow
844
+ * one (`except`: the subject being updated), or nothing. */
845
+ conflict(resource: string, fields: Record<string, unknown>, except?: string): Response | undefined;
846
+ /** A subject deleted as the vendor deletes it: every subject its resource's `cascade` names deleted first, then it,
847
+ * each through the write path (`operation` names the subject's own delete when it is not `<stored type>.delete`). */
848
+ remove(resource: string, id: string, operation?: string): Promise<void>;
849
+ /** The subject a key names, by its id (an alias the caller may still use resolved) or one of the resource's
850
+ * `alternateKeys` (an organization by its slug), as the vendor serves it. */
851
+ find(resource: string, key: string): Record<string, unknown> | undefined;
852
+ /** A field's new value as the resource's `update` rule merges it into the stored one (`deep`: Clerk's metadata). */
853
+ merge(resource: string, prior: unknown, next: unknown): unknown;
854
+ /** What a handler signs and hashes with (signing.ts): JWTs with a pack's key, their verification, a JWKS, an HMAC and
855
+ * a SHA-256, deterministic, so no pack reaches `node:crypto` itself. */
856
+ crypto: HandlerCrypto;
857
+ /** The World's managed Postgres (managed-database.ts): one transaction per batch, as a role with its settings, or a
858
+ * script. A World that binds none refuses every use with the reason (EngineUnavailableError). */
859
+ engine: ManagedDatabase;
860
+ /** A vendor's Redis (the kernel's Redis library, redis/engine.ts): a request's commands run in order over this call's
861
+ * tree and clock, in the pack's own service, under its wire's dialect, in one of its databases (`database`: its keys
862
+ * and scripts apart from the others'); each answered `{result}` or `{error}`, and whether any wrote. A read-only
863
+ * World raises ReadOnlyError at the first write. The wire around it (Upstash's REST envelope) is the pack's. */
864
+ redis(commands: string[][], options: {
865
+ dialect: RedisDialect;
866
+ database?: string;
867
+ }): Promise<{
868
+ items: RunItem[];
869
+ wrote: boolean;
870
+ }>;
871
+ /** Another vendor's own URL answered by the World's twin of it (vendor-call.ts): a vendor's call to another as part of
872
+ * its behaviour (Clerk exchanging a Google sign-in's code). A vendor the World runs no twin of is refused
873
+ * (VendorUnreachableError); nothing leaves the World. */
874
+ vendorFetch(url: string | URL, init?: RequestInit): Promise<Response>;
875
+ /** A multipart/form-data body's parts in order (multipart.ts: field name, filename, media type, bytes), a part with an
876
+ * empty field name included; none for any other body. */
877
+ parts(): Promise<MultipartPart[]>;
878
+ /** The pack's resource blobs (an object's bytes), by key, on the World's branch: they branch with the World, and a
879
+ * read falls back to an ancestor's. The row that names a blob is the pack's; the bytes are here. */
880
+ blobs: {
881
+ put(key: string, bytes: Uint8Array): Promise<void>;
882
+ get(key: string): Promise<Uint8Array | null>;
883
+ remove(key: string): Promise<void>;
884
+ };
885
+ /** A body's fields checked against the operation's declared ones under the manifest's `body.strict`: the fields, or
886
+ * the vendor's refusal of the first that is unknown, of another type or out of its bounds. */
887
+ fields(body: Record<string, unknown>): {
888
+ fields: Record<string, unknown>;
889
+ } | {
890
+ refused: Response;
891
+ };
892
+ /** A parameter as the vendor reads a boolean (the manifest's `booleans`): true, false, or undefined for a value that
893
+ * is neither (absent, or text the vendor does not read as one). A boolean passes as itself. */
894
+ flag(value: unknown): boolean | undefined;
441
895
  };
442
896
  export type Semantics = (ctx: SemanticsContext) => Promise<Response>;
443
897
  /** The context a derived pack's handler is given ("What an author writes, and how"): the kernel's own members
@@ -453,9 +907,11 @@ export type HandlerContext = Omit<SemanticsContext, 'now' | 'core' | 'atomically
453
907
  };
454
908
  /** What a write hook reads: the writing call's context without its ways to write, so a hook that renders an event
455
909
  * cannot write again (and run itself again). */
456
- export type WriteHookContext = Omit<HandlerContext, 'write' | 'record' | 'at' | 'over'>;
910
+ export type WriteHookContext = Omit<HandlerContext, 'write' | 'record' | 'accumulate' | 'at' | 'over'>;
457
911
  /** A derived pack's handler: one operation, by its operationId, over the contract's context. */
458
912
  export type Handler = (ctx: HandlerContext) => Promise<Response>;
913
+ /** The context the kernel opens for a call (a handler's, a door's, a screen's). Kernel-internal: packs are given it. */
914
+ export declare function contextFor(m: DerivedManifest, call: DerivedCall, scope: CoreScope): Promise<SemanticsContext>;
459
915
  /** A pack's semantics handlers as the dispatch's handlers. */
460
916
  export declare function bindSemantics(m: DerivedManifest, handlers: Record<string, Semantics>, scope?: CoreScope): Record<string, DerivedHandler>;
461
917
  /** The derived core as the dispatch's core: it owns every operation on a resource the manifest declares. */
@@ -465,6 +921,13 @@ export declare function coreFor(m: DerivedManifest, scope?: CoreScope): {
465
921
  };
466
922
  /** Read-only refusal, API-version validation and idempotent replay, applied once around every
467
923
  * operation a handler or the core serves. */
924
+ /** The vendor's refusal of a request's credential under the manifest's `auth`, or undefined when it passes: what the
925
+ * cross-cutting gate answers for an operation, and what a pack whose vendor checks the credential before routing (an
926
+ * unknown path answers 401, as Supabase's recording shows) calls in front of its dispatch. */
927
+ /** The header the kernel names a scenario's decision in, set by createPackFetch alone (it strips it from every request it
928
+ * is sent). */
929
+ export declare const SCENARIO_DECISION_HEADER = "x-volter-scenario-decision";
930
+ export declare function authRefusal(m: DerivedManifest, request: Request, root?: string): Response | undefined;
468
931
  export declare function crossCutting(m: DerivedManifest, opts?: CoreScope & {
469
932
  readOnly?: boolean;
470
933
  }): (call: DerivedCall, next: () => Promise<Response>) => Promise<Response>;