@spacefast/common 0.0.3 → 0.0.6

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 (159) hide show
  1. package/dist/agents/connect-targets.d.ts +133 -0
  2. package/dist/agents/connect-targets.js +224 -0
  3. package/dist/brand.d.ts +1 -0
  4. package/dist/brand.js +5 -0
  5. package/dist/config/domains.d.ts +12 -6
  6. package/dist/config/domains.js +30 -38
  7. package/dist/contracts/access.d.ts +829 -129
  8. package/dist/contracts/access.js +771 -148
  9. package/dist/contracts/activity.d.ts +5 -5
  10. package/dist/contracts/activity.js +28 -2
  11. package/dist/contracts/annotations.d.ts +3 -5
  12. package/dist/contracts/api-keys.d.ts +9 -10
  13. package/dist/contracts/api-keys.js +9 -6
  14. package/dist/contracts/archives.d.ts +22 -16
  15. package/dist/contracts/archives.js +11 -4
  16. package/dist/contracts/billing.d.ts +21 -30
  17. package/dist/contracts/builds.d.ts +21 -17
  18. package/dist/contracts/builds.js +12 -0
  19. package/dist/contracts/channels.d.ts +2 -2
  20. package/dist/contracts/common.d.ts +7 -5
  21. package/dist/contracts/common.js +4 -0
  22. package/dist/contracts/continuation.d.ts +63 -0
  23. package/dist/contracts/continuation.js +91 -0
  24. package/dist/contracts/countries.d.ts +2 -0
  25. package/dist/contracts/countries.js +261 -0
  26. package/dist/contracts/deployments.d.ts +34 -34
  27. package/dist/contracts/device-auth.d.ts +4 -11
  28. package/dist/contracts/device-auth.js +4 -0
  29. package/dist/contracts/docs.d.ts +119 -0
  30. package/dist/contracts/docs.js +51 -0
  31. package/dist/contracts/domains.d.ts +295 -253
  32. package/dist/contracts/domains.js +26 -4
  33. package/dist/contracts/enums.d.ts +17 -18
  34. package/dist/contracts/enums.js +25 -14
  35. package/dist/contracts/error-code-meta.d.ts +84 -0
  36. package/dist/contracts/error-code-meta.js +99 -10
  37. package/dist/contracts/error-codes.d.ts +1 -1
  38. package/dist/contracts/error-codes.js +17 -0
  39. package/dist/contracts/events.d.ts +13 -13
  40. package/dist/contracts/features.d.ts +93 -23
  41. package/dist/contracts/features.js +178 -13
  42. package/dist/contracts/git.d.ts +3 -9
  43. package/dist/contracts/ids.d.ts +5 -0
  44. package/dist/contracts/ids.js +5 -0
  45. package/dist/contracts/internal.d.ts +3 -3
  46. package/dist/contracts/mcp.d.ts +34 -36
  47. package/dist/contracts/me.d.ts +8 -8
  48. package/dist/contracts/me.js +1 -1
  49. package/dist/contracts/oauth-resources.d.ts +19 -8
  50. package/dist/contracts/oauth-resources.js +44 -13
  51. package/dist/contracts/operations.d.ts +2 -2
  52. package/dist/contracts/plan-policy.d.ts +4 -4
  53. package/dist/contracts/platform.d.ts +3 -105
  54. package/dist/contracts/platform.js +0 -50
  55. package/dist/contracts/push-new.d.ts +4 -4
  56. package/dist/contracts/quotas.d.ts +2 -0
  57. package/dist/contracts/quotas.js +8 -0
  58. package/dist/contracts/repository-connections.d.ts +1 -3
  59. package/dist/contracts/resources.d.ts +112 -28
  60. package/dist/contracts/resources.js +26 -2
  61. package/dist/contracts/routes.d.ts +0 -2
  62. package/dist/contracts/runtime-api.d.ts +365 -43
  63. package/dist/contracts/runtime-api.js +275 -6
  64. package/dist/contracts/sites.d.ts +45 -28
  65. package/dist/contracts/sites.js +21 -0
  66. package/dist/contracts/space-config.d.ts +201 -2
  67. package/dist/contracts/space-config.js +135 -5
  68. package/dist/contracts/spaces.d.ts +423 -162
  69. package/dist/contracts/spaces.js +94 -8
  70. package/dist/contracts/superadmin-emails.d.ts +7 -5
  71. package/dist/contracts/superadmin-emails.js +8 -0
  72. package/dist/contracts/superadmin-queues.d.ts +32 -32
  73. package/dist/contracts/superadmin-spaces.d.ts +418 -24
  74. package/dist/contracts/superadmin-spaces.js +24 -0
  75. package/dist/contracts/superadmin-tenants.d.ts +8 -8
  76. package/dist/contracts/superadmin.d.ts +17 -104
  77. package/dist/contracts/superadmin.js +6 -14
  78. package/dist/contracts/tags.d.ts +42 -41
  79. package/dist/contracts/tags.js +2 -1
  80. package/dist/contracts/teams.d.ts +40 -23
  81. package/dist/contracts/teams.js +20 -1
  82. package/dist/contracts/theme-json.d.ts +30 -0
  83. package/dist/contracts/theme-json.js +48 -0
  84. package/dist/contracts/transfers.d.ts +9 -9
  85. package/dist/contracts/variables.d.ts +14 -16
  86. package/dist/contracts/variables.js +0 -5
  87. package/dist/contracts/webhooks.d.ts +6 -4
  88. package/dist/contracts/webhooks.js +1 -1
  89. package/dist/contracts/zero.d.ts +13 -18
  90. package/dist/docs/agent-prose.d.ts +43 -3
  91. package/dist/docs/agent-prose.js +153 -10
  92. package/dist/docs/agent-setup.js +48 -15
  93. package/dist/docs/agent-solutions.d.ts +5 -5
  94. package/dist/docs/agent-solutions.js +2 -2
  95. package/dist/docs/catalog.d.ts +650 -0
  96. package/dist/docs/catalog.js +758 -0
  97. package/dist/docs/error-docs.d.ts +0 -2
  98. package/dist/docs/error-docs.js +89 -35
  99. package/dist/docs/index-build.d.ts +17 -0
  100. package/dist/docs/index-build.js +24 -0
  101. package/dist/docs/search.d.ts +54 -0
  102. package/dist/docs/search.js +96 -0
  103. package/dist/docs/skill-distribution.d.ts +5 -3
  104. package/dist/docs/skill-distribution.js +8 -8
  105. package/dist/utils/access-match.d.ts +39 -0
  106. package/dist/utils/access-match.js +296 -0
  107. package/dist/utils/auth-redirect.d.ts +3 -1
  108. package/dist/utils/auth-redirect.js +21 -1
  109. package/dist/utils/build-settings.d.ts +6 -0
  110. package/dist/utils/build-settings.js +429 -46
  111. package/dist/utils/claim-token.d.ts +8 -0
  112. package/dist/utils/claim-token.js +23 -2
  113. package/dist/utils/content-type.d.ts +1 -0
  114. package/dist/utils/content-type.js +1 -1
  115. package/dist/utils/credential-policy.d.ts +54 -0
  116. package/dist/utils/{access-policy.js → credential-policy.js} +28 -2
  117. package/dist/utils/gate-theme.d.ts +61 -0
  118. package/dist/utils/gate-theme.js +217 -0
  119. package/dist/utils/git-repository.d.ts +0 -1
  120. package/dist/utils/git-repository.js +0 -3
  121. package/dist/utils/id-hints.d.ts +8 -0
  122. package/dist/utils/id-hints.js +61 -0
  123. package/dist/utils/local-space-state.d.ts +91 -0
  124. package/dist/utils/local-space-state.js +251 -0
  125. package/dist/utils/oauth-signed-query.d.ts +8 -0
  126. package/dist/utils/oauth-signed-query.js +26 -0
  127. package/dist/utils/publish-detection.d.ts +0 -8
  128. package/dist/utils/publish-detection.js +0 -93
  129. package/dist/utils/publish-policy.d.ts +6 -5
  130. package/dist/utils/publish-policy.js +71 -7
  131. package/dist/utils/query-keys.d.ts +17 -6
  132. package/dist/utils/query-keys.js +27 -4
  133. package/dist/utils/runtime-paths.d.ts +0 -1
  134. package/dist/utils/runtime-paths.js +0 -1
  135. package/dist/utils/runtime-upload-batch.d.ts +18 -0
  136. package/dist/utils/runtime-upload-batch.js +90 -0
  137. package/dist/utils/runtime-upload.d.ts +2 -0
  138. package/dist/utils/runtime-upload.js +5 -0
  139. package/dist/utils/space-config.d.ts +4 -0
  140. package/dist/utils/space-config.js +10 -1
  141. package/dist/utils/space-theme.d.ts +2 -0
  142. package/dist/utils/space-theme.js +9 -0
  143. package/dist/utils/static-runtime-policy.d.ts +1 -1
  144. package/dist/utils/static-runtime-policy.js +47 -15
  145. package/dist/utils/upload-session.d.ts +1 -1
  146. package/dist/utils/wpcom-auth-redirects.d.ts +32 -2
  147. package/dist/utils/wpcom-auth-redirects.js +26 -10
  148. package/dist/vocabulary.d.ts +130 -30
  149. package/dist/vocabulary.js +77 -36
  150. package/package.json +16 -1
  151. package/dist/contracts/account.d.ts +0 -28
  152. package/dist/contracts/account.js +0 -54
  153. package/dist/contracts/intercom.d.ts +0 -6
  154. package/dist/contracts/intercom.js +0 -5
  155. package/dist/contracts/telemetry.d.ts +0 -2
  156. package/dist/contracts/telemetry.js +0 -1
  157. package/dist/utils/access-policy.d.ts +0 -39
  158. package/dist/utils/error-display.d.ts +0 -7
  159. package/dist/utils/error-display.js +0 -42
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { policyDocSchema } from "./access.js";
2
+ import { accessEventSchema, policyDocSchema } from "./access.js";
3
3
  import { conventionFilesSchema, manifestFileSchema } from "./internal.js";
4
4
  const runtimeConventionFilesSchema = conventionFilesSchema.omit({ routes: true }).strict();
5
5
  const hostCanonicalRedirectSchema = z.object({
@@ -111,15 +111,62 @@ const runtimeRouteConfigSchema = z.object({
111
111
  // alike. Carries platform + file + cloud rules (platform prepended, always
112
112
  // wins). Explicit null clears the stored policy; absence leaves it untouched.
113
113
  policy: policyDocSchema.nullable().optional(),
114
- // Serving-secret map (name -> value) the policy's password rules reference by
115
- // `auth.password.ref` = "secret:<name>". Carries the space-password bcrypt
116
- // verifier hash the runtime resolves and `password_verify`s. Explicit null
117
- // clears stored secrets; absence leaves them untouched.
114
+ // Serving-secret map (name -> value) the policy's password acquires
115
+ // reference by `ref` = "secret:<name>". Carries the space-password bcrypt
116
+ // verifier hash (and the compiled `_headers` basicAuth credential hashes)
117
+ // the runtime resolves and `password_verify`s. Explicit null clears stored
118
+ // secrets; absence leaves them untouched.
118
119
  secrets: z.record(z.string().min(1), z.string().min(1)).nullable().optional(),
120
+ // Space session version (access-plan §3.1): the runtime rejects a visitor
121
+ // token whose `sv` claim mismatches this, and derives the space-local `pw:`
122
+ // key from the password secret + this value. Absent = 0.
123
+ session_version: z.number().int().nonnegative().nullable().optional(),
119
124
  // Anonymous claim-window countdown (ISO timestamp), compiled into serving
120
125
  // state so the runtime can render the expiry-rescue banner for visitors
121
126
  // holding the claim-link viewer session. Null/absent once claimed.
122
127
  anonymous_expires_at: z.string().nullable().optional(),
128
+ // Serve-time content-type allowlist. Generic serving policy: the engine has
129
+ // no notion of WHY a space is restricted — it refuses (403, blocked_message
130
+ // body) any file whose stored Content-Type matches no pattern. Patterns are
131
+ // exact types or `prefix/*` wildcards ("text/*"). The control plane pushes
132
+ // it for unclaimed anonymous spaces (no opaque binaries pre-claim); explicit
133
+ // null clears the stored policy — route config is rebuilt wholesale, so a
134
+ // claim clears it structurally on the next sync.
135
+ content_types: z
136
+ .object({
137
+ allowed: z.array(z.string().min(1)),
138
+ blocked_message: z.string().optional(),
139
+ })
140
+ .nullable()
141
+ .optional(),
142
+ // Per-space admission-control override (plan §5/§25; contract A1): the
143
+ // in-flight concurrency limit the engine enforces on uncacheable requests
144
+ // for this space, superseding SPACEFAST_UNCACHEABLE_CONC_PER_SPACE. Ops-only
145
+ // in V1 (set via the superadmin admission endpoint); absent means the
146
+ // env-knob default applies.
147
+ admission: z.object({ concurrency: z.number().int().positive() }).optional(),
148
+ // Durable revocation SET (access-plan revocation hardening): every
149
+ // currently-revoked link:/invite:/svc: grant id, computed from the
150
+ // control-plane's Postgres projection (access/resolve.ts
151
+ // `revocationsForSpace`). The runtime REPLACES its revocations store's
152
+ // grant bucket with exactly this set on every sync — the backstop that
153
+ // converges even when the instant best-effort revoke_grant/unrevoke_grant
154
+ // call was dropped. `subs` (JWT-subject revocations) are left untouched.
155
+ // Absence leaves the stored set untouched.
156
+ revocations: z.array(z.string().min(1)).optional(),
157
+ // Serve-time plan entitlements (proxy-routes.md: "the rule stays in your
158
+ // config and activates the moment you upgrade — no redeploy needed"). Stored
159
+ // per space beside `policy`; a `planGated` compiled proxy rule
160
+ // (packages/routing plan.ts) is checked against this doc at REQUEST time by
161
+ // runtime/redirects.php, never baked into the compiled artifact. Explicit
162
+ // null clears the stored doc (falls back to fail-closed); absence leaves it
163
+ // untouched.
164
+ entitlements: z
165
+ .object({
166
+ externalProxy: z.boolean(),
167
+ })
168
+ .nullable()
169
+ .optional(),
123
170
  });
124
171
  // Compiled SpaceConfig serving primitives (spec "Serving resolution"): the finalize
125
172
  // compiler resolves content defaults -> sf.jsonc -> space overlay into this shape;
@@ -140,6 +187,10 @@ const runtimeServingConfigSchema = z.object({
140
187
  })
141
188
  .nullable()
142
189
  .optional(),
190
+ clean_urls: z
191
+ .boolean()
192
+ .optional()
193
+ .describe("Serve flat `<name>.html` files at their extensionless URLs (W7.1). Absent = default: on unless the fallback is the 200-status SPA shape."),
143
194
  listing: z
144
195
  .boolean()
145
196
  .optional()
@@ -157,6 +208,32 @@ const runtimeServingConfigSchema = z.object({
157
208
  .nullable()
158
209
  .optional()
159
210
  .describe("Finalize-resolved listing/viewer/OG metadata (effective SpaceConfig meta); wins over session metadata."),
211
+ // Gate-page presentation (access-plan §5.7, X-16): finalize-compiled theme
212
+ // tokens (tier 1) plus the plan-gated white-label flag (tier 2). The runtime
213
+ // reads this shape defensively from the version's serving_config and defaults
214
+ // per-field; platform-LANE pages (tombstones, plan expiry, claim, invariant
215
+ // errors) never consume it (X-17).
216
+ pages: z
217
+ .object({
218
+ theme: z
219
+ .object({
220
+ accent: z.string().max(64).optional(),
221
+ background: z.string().max(64).optional(),
222
+ logo: z.string().max(2000).optional(),
223
+ name: z.string().max(120).optional(),
224
+ // Free tier ("basic color scheme + fonts"): a validated font-family
225
+ // stack, same grammar as pages.theme.accent/background.
226
+ fontFamily: z.string().max(256).optional(),
227
+ })
228
+ .optional(),
229
+ // Additive theme.json palette/font-family CSS custom properties
230
+ // (access-plan §8 tier 3 middle rung): exposes the full WP-compatible
231
+ // palette to custom 401.html/403.html/layout.html authors beyond the
232
+ // flat accent/background tokens above.
233
+ theme_vars: z.string().max(8192).optional(),
234
+ white_label: z.boolean().optional(),
235
+ })
236
+ .optional(),
160
237
  // Hidden experimental build-pipeline flag: absent on every version finalized
161
238
  // without it (byte-identical payload to today). Only ever sent as true.
162
239
  experimental_gutenberg: z.boolean().optional(),
@@ -218,8 +295,14 @@ const runtimeZeroRunSchema = z.object({
218
295
  capabilities: runtimeZeroEndpointCapabilitiesSchema.optional(),
219
296
  db: z.record(z.string(), z.unknown()).optional(),
220
297
  });
298
+ // Gated-activation mode (plan §9, Placement V2): whether a version/import
299
+ // installs as immediately live ("active") or staged pending an explicit
300
+ // activation call ("activating", the engine's own fail-safe default when
301
+ // absent). Shared by finalize and import — do not re-inline this enum.
302
+ export const runtimeZeroModeSchema = z.enum(["active", "activating"]);
221
303
  export const runtimeVersionFinalizeRequestSchema = z.object({
222
304
  upload_id: z.string().min(1),
305
+ zero_mode: runtimeZeroModeSchema.optional(),
223
306
  // The version's authoritative ready timestamp (epoch seconds), passed by the
224
307
  // control plane when the version already reached ready (re-finalize, import
225
308
  // re-materialization, provider migration). The engine stamps it ONCE into the
@@ -266,6 +349,46 @@ export const runtimeVersionFinalizeRequestSchema = z.object({
266
349
  })
267
350
  .optional()
268
351
  .describe("Channel-variant template contents, keyed by runtime route name."),
352
+ // Publish-baked custom gate pages (access-plan §5.7 tier 3, X-35): the
353
+ // finalize compiler validates the version's 401.html/403.html slot element
354
+ // (`<div data-sf="challenge">` / `<div data-sf="deny">`), replaces the slot's
355
+ // contents with the opaque v1 marker comment, and ships the baked document
356
+ // here. The engine stores each under the version root as
357
+ // `access-pages/{challenge,deny}.html` (sibling of serving.php — never a
358
+ // publicly served path) and unlinks stale ones on re-finalize; serving is a
359
+ // single str_replace of the marker with the runtime-owned functional
360
+ // fragment. A version finalized without a key here has no override — the
361
+ // default platform page renders.
362
+ access_pages: z
363
+ .object({
364
+ challenge: z
365
+ .string()
366
+ .max(2 * 1024 * 1024)
367
+ .optional()
368
+ .describe("Baked 401.html carrying <!--spacefast:slot:challenge:v1-->."),
369
+ deny: z
370
+ .string()
371
+ .max(2 * 1024 * 1024)
372
+ .optional()
373
+ .describe("Baked 403.html carrying <!--spacefast:slot:deny:v1-->."),
374
+ })
375
+ .optional(),
376
+ // Custom gate-page chrome (access-plan §8 tier 2): the finalize compiler
377
+ // validates `.spacefast/templates/layout.html`'s `<div data-sf="content">`
378
+ // slot, replaces its contents with the opaque v1 marker comment, and ships
379
+ // the baked document here. The engine stores it as
380
+ // `access-pages/layout.html` (sibling of the challenge/deny overrides,
381
+ // never a publicly served path) and unlinks it when a re-finalize omits it.
382
+ // Serving wraps the runtime-owned gate-page content (brand row + heading +
383
+ // functional fragment) in the layout's content slot with one str_replace;
384
+ // a missing/invalid layout falls back to the platform default chrome. Only
385
+ // consulted when no full custom 401.html/403.html override wins for that
386
+ // page (tier 1 > tier 2).
387
+ layout_template: z
388
+ .string()
389
+ .max(2 * 1024 * 1024)
390
+ .optional()
391
+ .describe("Baked .spacefast/templates/layout.html carrying <!--spacefast:slot:layout-content:v1-->."),
269
392
  serving: z
270
393
  .object({
271
394
  headers_exact: z.record(z.string(), z.array(z.record(z.string(), z.unknown()))).default({}),
@@ -308,6 +431,9 @@ export const runtimeVersionFinalizeResponseSchema = z.object({
308
431
  space_id: z.string(),
309
432
  version_id: z.string(),
310
433
  status: z.literal("ready"),
434
+ // Runtime-compiled truth from zero/endpoints-index.json. Optional so older
435
+ // runtimes remain parseable during rolling deploys.
436
+ zero_endpoint_count: z.number().int().nonnegative().optional(),
311
437
  // Open sessions: the manifest derived from what was actually uploaded
312
438
  // (path, size, streaming sha256). Absent for declared sessions.
313
439
  manifest: z.array(manifestFileSchema).optional(),
@@ -323,11 +449,22 @@ export const runtimeRouteUpdateRequestSchema = z.object({
323
449
  host_canonical_redirects: runtimeRouteIntentSchema.shape.host_canonical_redirects,
324
450
  proxy_host_routes: runtimeRouteIntentSchema.shape.proxy_host_routes,
325
451
  });
452
+ export const runtimeHostnameIntentUpdateRequestSchema = z.object({
453
+ production_hostnames: runtimeRouteIntentSchema.shape.production_hostnames,
454
+ noindex_production_hostnames: runtimeRouteIntentSchema.shape.noindex_production_hostnames,
455
+ version_hostnames: runtimeRouteIntentSchema.shape.version_hostnames,
456
+ host_canonical_redirects: runtimeRouteIntentSchema.shape.host_canonical_redirects,
457
+ proxy_host_routes: runtimeRouteIntentSchema.shape.proxy_host_routes,
458
+ });
326
459
  export const runtimeRouteUpdateResponseSchema = z.object({
327
460
  space_id: z.string(),
328
461
  route_name: z.string(),
329
462
  version_id: z.string(),
330
463
  });
464
+ export const runtimeHostnameIntentUpdateResponseSchema = z.object({
465
+ space_id: z.string(),
466
+ route_count: z.number().int().nonnegative(),
467
+ });
331
468
  export const runtimeTombstonesUpdateRequestSchema = z.object({
332
469
  hostnames: runtimeRouteIntentSchema.shape.production_hostnames,
333
470
  mode: z.enum(["replace", "add", "remove"]).default("replace"),
@@ -342,6 +479,31 @@ export const runtimeTombstonesUpdateResponseSchema = z.object({
342
479
  space_id: z.string(),
343
480
  tombstone_count: z.number().int().nonnegative(),
344
481
  });
482
+ // Retention/pruning policy artifact (Placement V2 tiering, plan §8/§26): the
483
+ // control plane computes prunable version ids; the engine stores the list and
484
+ // its housekeeping tick prunes trees after re-checking live route pointers.
485
+ // An empty list clears the policy.
486
+ export const runtimeRetentionPolicyUpdateRequestSchema = z.object({
487
+ prunable_version_ids: z.array(z.string()),
488
+ });
489
+ export const runtimeRetentionPolicyUpdateResponseSchema = z.object({
490
+ space_id: z.string(),
491
+ prunable_count: z.number().int().nonnegative(),
492
+ });
493
+ // Instant per-grant tombstone (access-plan revocation hardening): the
494
+ // control plane's best-effort synchronous call at revoke/unrevoke time,
495
+ // hitting the SAME `revocations.json` the durable `config.revocations` full
496
+ // replace (above) also converges. `grant` must be a `link:`/`invite:`/`svc:`
497
+ // row id — the runtime rejects anything else.
498
+ export const runtimeGrantRevocationRequestSchema = z.object({
499
+ grant: z.string().min(1),
500
+ });
501
+ export const runtimeGrantRevocationResponseSchema = z.object({
502
+ space_id: z.string(),
503
+ target_type: z.literal("grant"),
504
+ grant: z.string(),
505
+ revoked: z.boolean(),
506
+ });
345
507
  export const runtimeSpaceDeleteResponseSchema = z.object({
346
508
  space_id: z.string(),
347
509
  status: z.literal("deleted"),
@@ -391,14 +553,21 @@ export const runtimeSpaceExportResponseSchema = z.object({
391
553
  export const runtimeSpaceImportStartRequestSchema = z
392
554
  .object({
393
555
  version_id_map: z.record(z.string(), z.string()).optional(),
556
+ // Plan §9 gated activation, extended to import (I-4): shares
557
+ // runtimeZeroModeSchema with runtimeVersionFinalizeRequestSchema.
558
+ // Absent/anything other than 'active' is the engine's own fail-safe
559
+ // 'activating'.
560
+ zero_mode: runtimeZeroModeSchema.optional(),
394
561
  })
395
562
  .strict();
396
563
  // Deferred version-id mapping: control-plane-driven uploads land on the
397
564
  // runtime before the control plane has read the archive, so the freshly
398
- // minted target ids are supplied here before the first step.
565
+ // minted target ids (and, for upload-sourced imports, zero_mode) are
566
+ // supplied here before the first step.
399
567
  export const runtimeSpaceImportMapRequestSchema = z
400
568
  .object({
401
569
  version_id_map: z.record(z.string(), z.string()),
570
+ zero_mode: runtimeZeroModeSchema.optional(),
402
571
  })
403
572
  .strict();
404
573
  export const runtimeSpaceImportResponseSchema = z.object({
@@ -414,6 +583,42 @@ export const runtimeSpaceImportResponseSchema = z.object({
414
583
  updated_at: z.string(),
415
584
  completed_at: z.string().optional(),
416
585
  });
586
+ const runtimeTransferBundleFileSchema = z.object({
587
+ path: z.string().min(1),
588
+ content_b64: z.string(),
589
+ });
590
+ export const runtimeTransferBundleSourceRequestSchema = z.object({
591
+ space_id: z.string().min(1),
592
+ version_ids: z.array(z.string().min(1)),
593
+ cursor: z.string().nullable(),
594
+ });
595
+ export const runtimeTransferBundleTargetRequestSchema = z.object({
596
+ space_id: z.string().min(1),
597
+ store: z.literal(true),
598
+ files: z.array(runtimeTransferBundleFileSchema),
599
+ done: z.boolean(),
600
+ });
601
+ export const runtimeTransferBundleResponseSchema = z.object({
602
+ chunk: z.object({ files: z.array(runtimeTransferBundleFileSchema) }),
603
+ next_cursor: z.string().nullable(),
604
+ });
605
+ export const runtimeTransferBundleStoredResponseSchema = z.object({
606
+ stored: z.literal(true),
607
+ });
608
+ export const runtimeTransferCommitRequestSchema = z.object({
609
+ space_id: z.string().min(1),
610
+ version_ids: z.array(z.string().min(1)),
611
+ live_version_id: z.string().nullable(),
612
+ });
613
+ export const runtimeTransferCommitResponseSchema = z.object({
614
+ installed: z.literal(true),
615
+ });
616
+ export const runtimeTransferAbortRequestSchema = z.object({
617
+ space_id: z.string().min(1),
618
+ });
619
+ export const runtimeTransferAbortResponseSchema = z.object({
620
+ aborted: z.boolean().optional(),
621
+ });
417
622
  // Per-space generation state reported by the authed state endpoint. The
418
623
  // reconciliation sweep compares this against control-plane expectations
419
624
  // (space liveVersionId vs the runtime's route pointers) and repairs targeted
@@ -511,3 +716,67 @@ export const runtimeEventsDrainResponseSchema = z.object({
511
716
  }))
512
717
  .optional(),
513
718
  });
719
+ // Engine job runner (plan §22, Placement V2): the box-local job runner behind
720
+ // the two-lane tick. The control plane creates a job, drives it with repeated
721
+ // ticks (kick-on-enqueue; the site-cron watchdog ticks the same route), and
722
+ // reads status from either the tick response or a direct GET. Field names
723
+ // mirror the engine's job record (§22 "Storage layout & job record").
724
+ export const runtimeEngineJobLaneSchema = z.enum(["interactive", "bulk"]);
725
+ export const runtimeEngineJobStatusSchema = z.enum(["pending", "running", "complete", "failed"]);
726
+ export const runtimeEngineJobErrorSchema = z.object({
727
+ code: z.string().min(1),
728
+ message: z.string().min(1),
729
+ });
730
+ export const runtimeEngineJobRecordSchema = z.object({
731
+ id: z.string().min(1),
732
+ type: z.string().min(1),
733
+ lane: runtimeEngineJobLaneSchema,
734
+ space_id: z.string().nullable().optional(),
735
+ operation_id: z.string().nullable().optional(),
736
+ status: runtimeEngineJobStatusSchema,
737
+ attempt: z.number().int().nonnegative().default(0),
738
+ max_attempts: z.number().int().positive().optional(),
739
+ progress: z
740
+ .object({
741
+ done: z.number().nonnegative().default(0),
742
+ total: z.number().nonnegative().default(0),
743
+ })
744
+ .optional(),
745
+ result: z.record(z.string(), z.unknown()).nullable().optional(),
746
+ error: runtimeEngineJobErrorSchema.nullable().optional(),
747
+ created_at: z.string().optional(),
748
+ updated_at: z.string().optional(),
749
+ });
750
+ export const runtimeEngineJobCreateRequestSchema = z.object({
751
+ type: z.string().min(1),
752
+ payload: z.record(z.string(), z.unknown()).default({}),
753
+ // Unique per (type, space, operation) — create is upsert-by-key (§22).
754
+ idempotency_key: z.string().min(1),
755
+ });
756
+ export const runtimeEngineJobResponseSchema = z.object({
757
+ job: runtimeEngineJobRecordSchema,
758
+ });
759
+ // The tick response carries the ticked job's fresh state when one was
760
+ // claimed/advanced this call, so a driver loop can usually avoid a follow-up
761
+ // GET; `job` is absent/null when the lane had nothing eligible to run.
762
+ export const runtimeEngineJobTickResponseSchema = z.object({
763
+ lane: runtimeEngineJobLaneSchema,
764
+ job: runtimeEngineJobRecordSchema.nullable().optional(),
765
+ drained: z.boolean().optional(),
766
+ });
767
+ // The management pull action for the Views panel (access-plan §5.6b, X-37):
768
+ // `GET /access-events?file&offset&limit` — a cursor-resumed read of the
769
+ // runtime's own per-hostname NDJSON access-event journal. `cursor` is the
770
+ // position after the last returned event (feed it back verbatim); `done` is
771
+ // false only when the response was truncated by `limit`; `dropped` totals the
772
+ // writer's `.dropped` sidecars (events skipped past the per-file byte cap).
773
+ export const runtimeAccessEventsCursorSchema = z.object({
774
+ file: z.string().min(1).nullable(),
775
+ offset: z.number().int().nonnegative(),
776
+ });
777
+ export const runtimeAccessEventsResponseSchema = z.object({
778
+ events: z.array(accessEventSchema).default([]),
779
+ cursor: runtimeAccessEventsCursorSchema,
780
+ done: z.boolean(),
781
+ dropped: z.number().int().nonnegative().default(0),
782
+ });
@@ -5,14 +5,27 @@ export declare const SiteCapacitySchema: z.ZodObject<{
5
5
  storageBytes: z.ZodOptional<z.ZodNumber>;
6
6
  }, z.core.$strip>;
7
7
  export type SiteCapacity = z.infer<typeof SiteCapacitySchema>;
8
+ export declare const SitePressureSchema: z.ZodObject<{
9
+ ewmaLimitedPct: z.ZodOptional<z.ZodNumber>;
10
+ ewma429: z.ZodOptional<z.ZodNumber>;
11
+ ewma429PerMin: z.ZodOptional<z.ZodNumber>;
12
+ ewmaWorkersMax: z.ZodOptional<z.ZodNumber>;
13
+ ewmaCpuPct: z.ZodOptional<z.ZodNumber>;
14
+ lastSampleAt: z.ZodOptional<z.ZodString>;
15
+ consecutivePressured: z.ZodOptional<z.ZodNumber>;
16
+ consecutiveClean: z.ZodOptional<z.ZodNumber>;
17
+ pressureHoldUntil: z.ZodOptional<z.ZodString>;
18
+ lastBulkLaneActivityAt: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$loose>;
20
+ export type SitePressure = z.infer<typeof SitePressureSchema>;
8
21
  export declare const SiteSchema: z.ZodObject<{
9
22
  id: z.ZodString;
10
23
  tenantId: z.ZodString;
11
24
  principal: z.ZodNullable<z.ZodObject<{
12
25
  tenantId: z.ZodString;
13
26
  principalType: z.ZodEnum<{
14
- external: "external";
15
27
  team: "team";
28
+ external: "external";
16
29
  }>;
17
30
  principalId: z.ZodString;
18
31
  }, z.core.$strip>>;
@@ -20,16 +33,16 @@ export declare const SiteSchema: z.ZodObject<{
20
33
  static_runtime: "static_runtime";
21
34
  }>;
22
35
  isolation: z.ZodEnum<{
23
- space: "space";
24
36
  site: "site";
37
+ space: "space";
25
38
  }>;
26
39
  status: z.ZodEnum<{
27
40
  active: "active";
28
41
  provisioning: "provisioning";
42
+ suspended: "suspended";
29
43
  deleted: "deleted";
30
- degraded: "degraded";
31
44
  ready_pool: "ready_pool";
32
- suspended: "suspended";
45
+ degraded: "degraded";
33
46
  }>;
34
47
  region: z.ZodString;
35
48
  managementHostname: z.ZodNullable<z.ZodString>;
@@ -45,10 +58,10 @@ export declare const SiteSchema: z.ZodObject<{
45
58
  kind: z.ZodString;
46
59
  status: z.ZodEnum<{
47
60
  failed: "failed";
61
+ canceled: "canceled";
48
62
  queued: "queued";
49
63
  running: "running";
50
64
  succeeded: "succeeded";
51
- canceled: "canceled";
52
65
  }>;
53
66
  resources: z.ZodArray<z.ZodObject<{
54
67
  type: z.ZodString;
@@ -69,9 +82,9 @@ export declare const SiteSchema: z.ZodObject<{
69
82
  message: z.ZodString;
70
83
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
84
  provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
85
+ registrar: "registrar";
72
86
  wpcloud: "wpcloud";
73
87
  dns: "dns";
74
- registrar: "registrar";
75
88
  runtime: "runtime";
76
89
  }>>>;
77
90
  details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
@@ -93,8 +106,8 @@ export declare const siteCreateSchema: z.ZodObject<{
93
106
  static_runtime: "static_runtime";
94
107
  }>>;
95
108
  isolation: z.ZodDefault<z.ZodEnum<{
96
- space: "space";
97
109
  site: "site";
110
+ space: "space";
98
111
  }>>;
99
112
  region: z.ZodOptional<z.ZodString>;
100
113
  provisioning: z.ZodOptional<z.ZodObject<{
@@ -108,8 +121,8 @@ export declare const siteListSchema: z.ZodObject<{
108
121
  principal: z.ZodNullable<z.ZodObject<{
109
122
  tenantId: z.ZodString;
110
123
  principalType: z.ZodEnum<{
111
- external: "external";
112
124
  team: "team";
125
+ external: "external";
113
126
  }>;
114
127
  principalId: z.ZodString;
115
128
  }, z.core.$strip>>;
@@ -117,16 +130,16 @@ export declare const siteListSchema: z.ZodObject<{
117
130
  static_runtime: "static_runtime";
118
131
  }>;
119
132
  isolation: z.ZodEnum<{
120
- space: "space";
121
133
  site: "site";
134
+ space: "space";
122
135
  }>;
123
136
  status: z.ZodEnum<{
124
137
  active: "active";
125
138
  provisioning: "provisioning";
139
+ suspended: "suspended";
126
140
  deleted: "deleted";
127
- degraded: "degraded";
128
141
  ready_pool: "ready_pool";
129
- suspended: "suspended";
142
+ degraded: "degraded";
130
143
  }>;
131
144
  region: z.ZodString;
132
145
  managementHostname: z.ZodNullable<z.ZodString>;
@@ -142,10 +155,10 @@ export declare const siteListSchema: z.ZodObject<{
142
155
  kind: z.ZodString;
143
156
  status: z.ZodEnum<{
144
157
  failed: "failed";
158
+ canceled: "canceled";
145
159
  queued: "queued";
146
160
  running: "running";
147
161
  succeeded: "succeeded";
148
- canceled: "canceled";
149
162
  }>;
150
163
  resources: z.ZodArray<z.ZodObject<{
151
164
  type: z.ZodString;
@@ -166,9 +179,9 @@ export declare const siteListSchema: z.ZodObject<{
166
179
  message: z.ZodString;
167
180
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
168
181
  provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
182
+ registrar: "registrar";
169
183
  wpcloud: "wpcloud";
170
184
  dns: "dns";
171
- registrar: "registrar";
172
185
  runtime: "runtime";
173
186
  }>>>;
174
187
  details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
@@ -199,8 +212,8 @@ export declare const SuperadminSiteSchema: z.ZodObject<{
199
212
  principal: z.ZodNullable<z.ZodObject<{
200
213
  tenantId: z.ZodString;
201
214
  principalType: z.ZodEnum<{
202
- external: "external";
203
215
  team: "team";
216
+ external: "external";
204
217
  }>;
205
218
  principalId: z.ZodString;
206
219
  }, z.core.$strip>>;
@@ -208,16 +221,16 @@ export declare const SuperadminSiteSchema: z.ZodObject<{
208
221
  static_runtime: "static_runtime";
209
222
  }>;
210
223
  isolation: z.ZodEnum<{
211
- space: "space";
212
224
  site: "site";
225
+ space: "space";
213
226
  }>;
214
227
  status: z.ZodEnum<{
215
228
  active: "active";
216
229
  provisioning: "provisioning";
230
+ suspended: "suspended";
217
231
  deleted: "deleted";
218
- degraded: "degraded";
219
232
  ready_pool: "ready_pool";
220
- suspended: "suspended";
233
+ degraded: "degraded";
221
234
  }>;
222
235
  region: z.ZodString;
223
236
  managementHostname: z.ZodNullable<z.ZodString>;
@@ -233,10 +246,10 @@ export declare const SuperadminSiteSchema: z.ZodObject<{
233
246
  kind: z.ZodString;
234
247
  status: z.ZodEnum<{
235
248
  failed: "failed";
249
+ canceled: "canceled";
236
250
  queued: "queued";
237
251
  running: "running";
238
252
  succeeded: "succeeded";
239
- canceled: "canceled";
240
253
  }>;
241
254
  resources: z.ZodArray<z.ZodObject<{
242
255
  type: z.ZodString;
@@ -257,9 +270,9 @@ export declare const SuperadminSiteSchema: z.ZodObject<{
257
270
  message: z.ZodString;
258
271
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
259
272
  provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
273
+ registrar: "registrar";
260
274
  wpcloud: "wpcloud";
261
275
  dns: "dns";
262
- registrar: "registrar";
263
276
  runtime: "runtime";
264
277
  }>>>;
265
278
  details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
@@ -272,8 +285,10 @@ export declare const SuperadminSiteSchema: z.ZodObject<{
272
285
  createdAt: z.ZodString;
273
286
  updatedAt: z.ZodString;
274
287
  class: z.ZodEnum<{
275
- anonymous_pool: "anonymous_pool";
288
+ shared: "shared";
289
+ dedicated: "dedicated";
276
290
  shared_org: "shared_org";
291
+ anonymous_pool: "anonymous_pool";
277
292
  dedicated_space: "dedicated_space";
278
293
  }>;
279
294
  providerClientId: z.ZodNullable<z.ZodString>;
@@ -286,8 +301,8 @@ export declare const SuperadminSiteListSchema: z.ZodObject<{
286
301
  principal: z.ZodNullable<z.ZodObject<{
287
302
  tenantId: z.ZodString;
288
303
  principalType: z.ZodEnum<{
289
- external: "external";
290
304
  team: "team";
305
+ external: "external";
291
306
  }>;
292
307
  principalId: z.ZodString;
293
308
  }, z.core.$strip>>;
@@ -295,16 +310,16 @@ export declare const SuperadminSiteListSchema: z.ZodObject<{
295
310
  static_runtime: "static_runtime";
296
311
  }>;
297
312
  isolation: z.ZodEnum<{
298
- space: "space";
299
313
  site: "site";
314
+ space: "space";
300
315
  }>;
301
316
  status: z.ZodEnum<{
302
317
  active: "active";
303
318
  provisioning: "provisioning";
319
+ suspended: "suspended";
304
320
  deleted: "deleted";
305
- degraded: "degraded";
306
321
  ready_pool: "ready_pool";
307
- suspended: "suspended";
322
+ degraded: "degraded";
308
323
  }>;
309
324
  region: z.ZodString;
310
325
  managementHostname: z.ZodNullable<z.ZodString>;
@@ -320,10 +335,10 @@ export declare const SuperadminSiteListSchema: z.ZodObject<{
320
335
  kind: z.ZodString;
321
336
  status: z.ZodEnum<{
322
337
  failed: "failed";
338
+ canceled: "canceled";
323
339
  queued: "queued";
324
340
  running: "running";
325
341
  succeeded: "succeeded";
326
- canceled: "canceled";
327
342
  }>;
328
343
  resources: z.ZodArray<z.ZodObject<{
329
344
  type: z.ZodString;
@@ -344,9 +359,9 @@ export declare const SuperadminSiteListSchema: z.ZodObject<{
344
359
  message: z.ZodString;
345
360
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
346
361
  provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
362
+ registrar: "registrar";
347
363
  wpcloud: "wpcloud";
348
364
  dns: "dns";
349
- registrar: "registrar";
350
365
  runtime: "runtime";
351
366
  }>>>;
352
367
  details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
@@ -359,8 +374,10 @@ export declare const SuperadminSiteListSchema: z.ZodObject<{
359
374
  createdAt: z.ZodString;
360
375
  updatedAt: z.ZodString;
361
376
  class: z.ZodEnum<{
362
- anonymous_pool: "anonymous_pool";
377
+ shared: "shared";
378
+ dedicated: "dedicated";
363
379
  shared_org: "shared_org";
380
+ anonymous_pool: "anonymous_pool";
364
381
  dedicated_space: "dedicated_space";
365
382
  }>;
366
383
  providerClientId: z.ZodNullable<z.ZodString>;
@@ -372,8 +389,8 @@ export declare const superadminSiteCreateSchema: z.ZodObject<{
372
389
  static_runtime: "static_runtime";
373
390
  }>>;
374
391
  isolation: z.ZodDefault<z.ZodEnum<{
375
- space: "space";
376
392
  site: "site";
393
+ space: "space";
377
394
  }>>;
378
395
  region: z.ZodOptional<z.ZodString>;
379
396
  provisioning: z.ZodOptional<z.ZodObject<{
@@ -26,6 +26,27 @@ export const SiteCapacitySchema = z
26
26
  .describe("Storage budget for the site in bytes."),
27
27
  })
28
28
  .describe("Capacity accounting for shared-pool sites.");
29
+ export const SitePressureSchema = z
30
+ .object({
31
+ ewmaLimitedPct: z.number().nonnegative().optional(),
32
+ ewma429: z.number().nonnegative().optional(),
33
+ ewma429PerMin: z.number().nonnegative().optional(),
34
+ ewmaWorkersMax: z.number().nonnegative().optional(),
35
+ ewmaCpuPct: z.number().nonnegative().optional(),
36
+ lastSampleAt: z.string().datetime().optional(),
37
+ consecutivePressured: z.number().int().nonnegative().optional(),
38
+ consecutiveClean: z.number().int().nonnegative().optional(),
39
+ // Provenance stamp for the sampler's automatic hold: set on trip to the
40
+ // exact hold instant it wrote, so release only clears holds the pressure
41
+ // pipeline itself set — never an operator-set placement hold.
42
+ pressureHoldUntil: z.string().datetime().optional(),
43
+ // Last time a bulk-lane engine job on this site reported activity via the
44
+ // job callbacks (runtime/callback-events.ts); the sampler discounts the
45
+ // CPU signal while this is within the sampling window.
46
+ lastBulkLaneActivityAt: z.string().datetime().optional(),
47
+ })
48
+ .passthrough()
49
+ .describe("Placement pressure signals computed outside the request path.");
29
50
  // A Site is THE placement unit (internal-docs/platform.md "Site", `site_`):
30
51
  // one WP.Cloud site per row. Spaces are placed onto a site via `space.siteId`.
31
52
  // Provider linkage (`providerClientId`, `providerRef`) is operator-only and