@spacefast/common 0.0.5 → 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 (150) 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 +825 -125
  8. package/dist/contracts/access.js +771 -148
  9. package/dist/contracts/activity.d.ts +1 -1
  10. package/dist/contracts/activity.js +28 -2
  11. package/dist/contracts/annotations.d.ts +2 -4
  12. package/dist/contracts/api-keys.d.ts +3 -4
  13. package/dist/contracts/api-keys.js +9 -6
  14. package/dist/contracts/archives.d.ts +8 -2
  15. package/dist/contracts/archives.js +11 -4
  16. package/dist/contracts/billing.d.ts +0 -9
  17. package/dist/contracts/builds.d.ts +25 -21
  18. package/dist/contracts/builds.js +12 -0
  19. package/dist/contracts/common.d.ts +2 -0
  20. package/dist/contracts/common.js +4 -0
  21. package/dist/contracts/continuation.d.ts +0 -3
  22. package/dist/contracts/countries.d.ts +2 -0
  23. package/dist/contracts/countries.js +261 -0
  24. package/dist/contracts/deployments.d.ts +34 -34
  25. package/dist/contracts/device-auth.d.ts +4 -11
  26. package/dist/contracts/device-auth.js +4 -0
  27. package/dist/contracts/docs.d.ts +119 -0
  28. package/dist/contracts/docs.js +51 -0
  29. package/dist/contracts/domains.d.ts +96 -54
  30. package/dist/contracts/domains.js +26 -4
  31. package/dist/contracts/enums.d.ts +15 -16
  32. package/dist/contracts/enums.js +25 -14
  33. package/dist/contracts/error-code-meta.d.ts +72 -0
  34. package/dist/contracts/error-code-meta.js +96 -10
  35. package/dist/contracts/error-codes.d.ts +1 -1
  36. package/dist/contracts/error-codes.js +14 -0
  37. package/dist/contracts/events.d.ts +1 -1
  38. package/dist/contracts/features.d.ts +76 -6
  39. package/dist/contracts/features.js +178 -13
  40. package/dist/contracts/git.d.ts +2 -8
  41. package/dist/contracts/ids.d.ts +5 -0
  42. package/dist/contracts/ids.js +5 -0
  43. package/dist/contracts/mcp.d.ts +8 -10
  44. package/dist/contracts/me.js +1 -1
  45. package/dist/contracts/oauth-resources.d.ts +19 -8
  46. package/dist/contracts/oauth-resources.js +44 -13
  47. package/dist/contracts/platform.d.ts +0 -102
  48. package/dist/contracts/platform.js +0 -50
  49. package/dist/contracts/push-new.d.ts +4 -4
  50. package/dist/contracts/quotas.d.ts +2 -0
  51. package/dist/contracts/quotas.js +8 -0
  52. package/dist/contracts/repository-connections.d.ts +6 -8
  53. package/dist/contracts/resources.d.ts +97 -13
  54. package/dist/contracts/resources.js +26 -2
  55. package/dist/contracts/routes.d.ts +0 -2
  56. package/dist/contracts/runtime-api.d.ts +361 -39
  57. package/dist/contracts/runtime-api.js +275 -6
  58. package/dist/contracts/sites.d.ts +19 -2
  59. package/dist/contracts/sites.js +21 -0
  60. package/dist/contracts/space-config.d.ts +201 -2
  61. package/dist/contracts/space-config.js +135 -5
  62. package/dist/contracts/spaces.d.ts +364 -193
  63. package/dist/contracts/spaces.js +40 -8
  64. package/dist/contracts/superadmin-emails.d.ts +4 -2
  65. package/dist/contracts/superadmin-emails.js +8 -0
  66. package/dist/contracts/superadmin-queues.d.ts +26 -26
  67. package/dist/contracts/superadmin-spaces.d.ts +170 -42
  68. package/dist/contracts/superadmin.d.ts +6 -93
  69. package/dist/contracts/superadmin.js +6 -14
  70. package/dist/contracts/tags.d.ts +10 -9
  71. package/dist/contracts/tags.js +2 -1
  72. package/dist/contracts/teams.d.ts +21 -22
  73. package/dist/contracts/teams.js +0 -1
  74. package/dist/contracts/theme-json.d.ts +30 -0
  75. package/dist/contracts/theme-json.js +48 -0
  76. package/dist/contracts/variables.d.ts +0 -2
  77. package/dist/contracts/variables.js +0 -5
  78. package/dist/contracts/webhooks.d.ts +2 -0
  79. package/dist/contracts/webhooks.js +1 -1
  80. package/dist/contracts/zero.d.ts +5 -10
  81. package/dist/docs/agent-prose.d.ts +43 -3
  82. package/dist/docs/agent-prose.js +146 -7
  83. package/dist/docs/agent-setup.js +45 -13
  84. package/dist/docs/agent-solutions.d.ts +5 -5
  85. package/dist/docs/agent-solutions.js +2 -2
  86. package/dist/docs/catalog.d.ts +650 -0
  87. package/dist/docs/catalog.js +758 -0
  88. package/dist/docs/error-docs.d.ts +0 -2
  89. package/dist/docs/error-docs.js +77 -35
  90. package/dist/docs/index-build.d.ts +17 -0
  91. package/dist/docs/index-build.js +24 -0
  92. package/dist/docs/search.d.ts +54 -0
  93. package/dist/docs/search.js +96 -0
  94. package/dist/docs/skill-distribution.d.ts +5 -3
  95. package/dist/docs/skill-distribution.js +8 -8
  96. package/dist/utils/access-match.d.ts +39 -0
  97. package/dist/utils/access-match.js +296 -0
  98. package/dist/utils/auth-redirect.d.ts +3 -1
  99. package/dist/utils/auth-redirect.js +21 -1
  100. package/dist/utils/build-settings.d.ts +6 -0
  101. package/dist/utils/build-settings.js +429 -46
  102. package/dist/utils/claim-token.d.ts +8 -0
  103. package/dist/utils/claim-token.js +23 -2
  104. package/dist/utils/content-type.d.ts +1 -0
  105. package/dist/utils/content-type.js +1 -1
  106. package/dist/utils/credential-policy.d.ts +54 -0
  107. package/dist/utils/{access-policy.js → credential-policy.js} +28 -2
  108. package/dist/utils/gate-theme.d.ts +61 -0
  109. package/dist/utils/gate-theme.js +217 -0
  110. package/dist/utils/git-repository.d.ts +0 -1
  111. package/dist/utils/git-repository.js +0 -3
  112. package/dist/utils/id-hints.d.ts +8 -0
  113. package/dist/utils/id-hints.js +61 -0
  114. package/dist/utils/local-space-state.d.ts +91 -0
  115. package/dist/utils/local-space-state.js +251 -0
  116. package/dist/utils/oauth-signed-query.d.ts +8 -0
  117. package/dist/utils/oauth-signed-query.js +26 -0
  118. package/dist/utils/publish-detection.d.ts +0 -8
  119. package/dist/utils/publish-detection.js +0 -93
  120. package/dist/utils/publish-policy.d.ts +6 -5
  121. package/dist/utils/publish-policy.js +71 -7
  122. package/dist/utils/query-keys.d.ts +15 -4
  123. package/dist/utils/query-keys.js +27 -4
  124. package/dist/utils/runtime-paths.d.ts +0 -1
  125. package/dist/utils/runtime-paths.js +0 -1
  126. package/dist/utils/runtime-upload-batch.d.ts +18 -0
  127. package/dist/utils/runtime-upload-batch.js +90 -0
  128. package/dist/utils/runtime-upload.d.ts +2 -0
  129. package/dist/utils/runtime-upload.js +5 -0
  130. package/dist/utils/space-config.d.ts +4 -0
  131. package/dist/utils/space-config.js +10 -1
  132. package/dist/utils/space-theme.d.ts +2 -0
  133. package/dist/utils/space-theme.js +9 -0
  134. package/dist/utils/static-runtime-policy.d.ts +0 -21
  135. package/dist/utils/static-runtime-policy.js +19 -103
  136. package/dist/utils/upload-session.d.ts +1 -1
  137. package/dist/utils/wpcom-auth-redirects.d.ts +32 -2
  138. package/dist/utils/wpcom-auth-redirects.js +26 -10
  139. package/dist/vocabulary.d.ts +130 -30
  140. package/dist/vocabulary.js +77 -36
  141. package/package.json +16 -1
  142. package/dist/contracts/account.d.ts +0 -28
  143. package/dist/contracts/account.js +0 -54
  144. package/dist/contracts/intercom.d.ts +0 -6
  145. package/dist/contracts/intercom.js +0 -5
  146. package/dist/contracts/telemetry.d.ts +0 -2
  147. package/dist/contracts/telemetry.js +0 -1
  148. package/dist/utils/access-policy.d.ts +0 -39
  149. package/dist/utils/error-display.d.ts +0 -7
  150. 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,6 +5,19 @@ 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;
@@ -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>;
@@ -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>;
@@ -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