@spacefast/common 0.0.23 → 0.0.26

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 (224) hide show
  1. package/brand-assets/LICENSE-Haskoy.txt +93 -0
  2. package/brand-assets/haskoy-latin-variable.woff2 +0 -0
  3. package/brand-assets/spacefast-favicon.svg +4 -4
  4. package/brand-assets/spacefast-sf-full-bleed.svg +3 -3
  5. package/brand-assets/spacefast-wordmark.svg +2 -4
  6. package/dist/agents/connect-targets.js +1 -1
  7. package/dist/agents/private-key-oauth.d.ts +0 -1
  8. package/dist/agents/private-key-oauth.js +46 -63
  9. package/dist/brand-assets-build.js +4 -6
  10. package/dist/brand-assets.d.ts +5 -15
  11. package/dist/brand-assets.js +15 -14
  12. package/dist/config/domains.d.ts +47 -7
  13. package/dist/config/domains.js +66 -10
  14. package/dist/config/index.d.ts +0 -1
  15. package/dist/config/index.js +0 -1
  16. package/dist/contracts/abuse.d.ts +2 -0
  17. package/dist/contracts/abuse.js +12 -0
  18. package/dist/contracts/access.d.ts +124 -12
  19. package/dist/contracts/access.js +73 -9
  20. package/dist/contracts/activity.d.ts +1 -1
  21. package/dist/contracts/activity.js +5 -12
  22. package/dist/contracts/api-keys.d.ts +21 -21
  23. package/dist/contracts/api-keys.js +2 -2
  24. package/dist/contracts/beta.js +1 -1
  25. package/dist/contracts/billing.d.ts +3 -35
  26. package/dist/contracts/billing.js +33 -52
  27. package/dist/contracts/builds.d.ts +30 -18
  28. package/dist/contracts/builds.js +28 -9
  29. package/dist/contracts/channels.js +1 -1
  30. package/dist/contracts/cli.d.ts +10 -0
  31. package/dist/contracts/cli.js +10 -0
  32. package/dist/contracts/collab-public.d.ts +63 -0
  33. package/dist/contracts/collab-public.js +46 -0
  34. package/dist/contracts/comments.d.ts +282 -53
  35. package/dist/contracts/comments.js +173 -52
  36. package/dist/contracts/common.d.ts +3 -3
  37. package/dist/contracts/common.js +5 -5
  38. package/dist/contracts/crons.d.ts +35 -0
  39. package/dist/contracts/crons.js +42 -0
  40. package/dist/contracts/device-auth.d.ts +6 -6
  41. package/dist/contracts/device-auth.js +2 -2
  42. package/dist/contracts/docs.js +2 -2
  43. package/dist/contracts/domains.d.ts +38 -27
  44. package/dist/contracts/domains.js +29 -2
  45. package/dist/contracts/enums.d.ts +34 -30
  46. package/dist/contracts/enums.js +62 -48
  47. package/dist/contracts/error-code-meta.d.ts +50 -125
  48. package/dist/contracts/error-code-meta.js +29 -41
  49. package/dist/contracts/error-codes.d.ts +1 -1
  50. package/dist/contracts/error-codes.js +14 -33
  51. package/dist/contracts/execution.d.ts +47 -66
  52. package/dist/contracts/execution.js +53 -49
  53. package/dist/contracts/feature-lifecycle-core.d.ts +0 -6
  54. package/dist/contracts/feature-lifecycle-core.js +2 -31
  55. package/dist/contracts/feature-lifecycle.d.ts +12 -52
  56. package/dist/contracts/feature-lifecycle.js +16 -59
  57. package/dist/contracts/features.d.ts +48 -60
  58. package/dist/contracts/features.js +59 -51
  59. package/dist/contracts/functions.d.ts +266 -72
  60. package/dist/contracts/functions.js +260 -37
  61. package/dist/contracts/git.d.ts +28 -34
  62. package/dist/contracts/git.js +10 -11
  63. package/dist/contracts/grants.d.ts +9 -5
  64. package/dist/contracts/grants.js +18 -9
  65. package/dist/contracts/ids.js +2 -2
  66. package/dist/contracts/internal.d.ts +8 -6
  67. package/dist/contracts/internal.js +12 -12
  68. package/dist/contracts/mcp.d.ts +11 -0
  69. package/dist/contracts/mcp.js +5 -0
  70. package/dist/contracts/me.js +1 -1
  71. package/dist/contracts/oauth-resources.d.ts +4 -3
  72. package/dist/contracts/oauth-resources.js +12 -3
  73. package/dist/contracts/operations.d.ts +90 -5
  74. package/dist/contracts/operations.js +77 -3
  75. package/dist/contracts/pages.d.ts +12 -7
  76. package/dist/contracts/pages.js +24 -1
  77. package/dist/contracts/plan-policy.d.ts +0 -2
  78. package/dist/contracts/plan-policy.js +2 -3
  79. package/dist/contracts/platform.d.ts +61 -148
  80. package/dist/contracts/platform.js +70 -126
  81. package/dist/contracts/publish-archive.d.ts +508 -0
  82. package/dist/contracts/publish-archive.js +32 -0
  83. package/dist/contracts/push-new.d.ts +4 -4
  84. package/dist/contracts/quotas.js +2 -2
  85. package/dist/contracts/repository-connections.d.ts +43 -30
  86. package/dist/contracts/repository-connections.js +11 -3
  87. package/dist/contracts/resources.d.ts +12 -24
  88. package/dist/contracts/resources.js +36 -16
  89. package/dist/contracts/runtime-api.d.ts +433 -192
  90. package/dist/contracts/runtime-api.js +421 -356
  91. package/dist/contracts/runtime-app.d.ts +127 -120
  92. package/dist/contracts/runtime-app.js +19 -10
  93. package/dist/contracts/runtime-db.d.ts +5 -5
  94. package/dist/contracts/runtime-db.js +2 -2
  95. package/dist/contracts/runtime-purge.d.ts +8 -0
  96. package/dist/contracts/runtime-purge.js +7 -0
  97. package/dist/contracts/runtime-services.d.ts +219 -0
  98. package/dist/contracts/runtime-services.js +437 -0
  99. package/dist/contracts/runtime-storage.d.ts +46 -32
  100. package/dist/contracts/runtime-storage.js +31 -8
  101. package/dist/contracts/sf-config-v1.d.ts +48 -10
  102. package/dist/contracts/space-config.d.ts +69 -18
  103. package/dist/contracts/space-config.js +226 -27
  104. package/dist/contracts/spaces.d.ts +236 -450
  105. package/dist/contracts/spaces.js +131 -151
  106. package/dist/contracts/superadmin-activity.d.ts +57 -4
  107. package/dist/contracts/superadmin-activity.js +48 -2
  108. package/dist/contracts/superadmin-search.d.ts +126 -0
  109. package/dist/contracts/superadmin-search.js +61 -0
  110. package/dist/contracts/superadmin-spaces.d.ts +361 -92
  111. package/dist/contracts/superadmin-spaces.js +97 -24
  112. package/dist/contracts/superadmin-teams.d.ts +28 -10
  113. package/dist/contracts/superadmin-teams.js +5 -8
  114. package/dist/contracts/superadmin-tenants.d.ts +0 -6
  115. package/dist/contracts/superadmin-tenants.js +1 -7
  116. package/dist/contracts/superadmin.d.ts +135 -54
  117. package/dist/contracts/superadmin.js +46 -23
  118. package/dist/contracts/tags.d.ts +12 -12
  119. package/dist/contracts/tags.js +3 -3
  120. package/dist/contracts/teams.d.ts +49 -14
  121. package/dist/contracts/teams.js +40 -22
  122. package/dist/contracts/transfers.d.ts +0 -49
  123. package/dist/contracts/transfers.js +4 -8
  124. package/dist/contracts/usage.d.ts +61 -0
  125. package/dist/contracts/usage.js +64 -0
  126. package/dist/contracts/variables.d.ts +2 -7
  127. package/dist/contracts/variables.js +9 -8
  128. package/dist/contracts/webhooks.d.ts +2 -2
  129. package/dist/contracts/zero.d.ts +102 -73
  130. package/dist/contracts/zero.js +94 -32
  131. package/dist/dashboard-paths/index.d.ts +1 -1
  132. package/dist/dashboard-paths/index.js +1 -0
  133. package/dist/docs/agent-prose.d.ts +2 -2
  134. package/dist/docs/agent-prose.js +63 -70
  135. package/dist/docs/agent-setup.js +45 -15
  136. package/dist/docs/catalog.d.ts +24 -24
  137. package/dist/docs/catalog.js +35 -24
  138. package/dist/docs/error-docs.js +194 -270
  139. package/dist/docs/skills.d.ts +12 -12
  140. package/dist/docs/skills.js +4 -4
  141. package/dist/test-helpers/fetch-stub.d.ts +16 -0
  142. package/dist/test-helpers/fetch-stub.js +25 -0
  143. package/dist/utils/build-settings.d.ts +5 -1
  144. package/dist/utils/build-settings.js +91 -13
  145. package/dist/utils/canonical-json.d.ts +10 -0
  146. package/dist/utils/canonical-json.js +22 -0
  147. package/dist/utils/cast-transport.d.ts +28 -0
  148. package/dist/utils/cast-transport.js +52 -0
  149. package/dist/utils/claim-token.d.ts +0 -8
  150. package/dist/utils/claim-token.js +3 -15
  151. package/dist/utils/concurrency.js +1 -0
  152. package/dist/utils/credential-policy.d.ts +1 -1
  153. package/dist/utils/credential-policy.js +4 -3
  154. package/dist/utils/dns-instructions.js +9 -9
  155. package/dist/utils/env-file.d.ts +17 -0
  156. package/dist/utils/env-file.js +96 -0
  157. package/dist/utils/error-code.d.ts +2 -0
  158. package/dist/utils/error-code.js +8 -0
  159. package/dist/utils/generate-space-name.d.ts +8 -10
  160. package/dist/utils/generate-space-name.js +206 -21
  161. package/dist/utils/grant-decision.fixtures.json +2938 -0
  162. package/dist/utils/grants.d.ts +2 -0
  163. package/dist/utils/grants.js +26 -1
  164. package/dist/utils/gravatar.d.ts +9 -0
  165. package/dist/utils/gravatar.js +31 -0
  166. package/dist/utils/idempotency.d.ts +6 -0
  167. package/dist/utils/idempotency.js +28 -0
  168. package/dist/utils/local-space-state.d.ts +9 -16
  169. package/dist/utils/local-space-state.js +20 -50
  170. package/dist/utils/one-shot-replay.d.ts +4 -1
  171. package/dist/utils/page-colors.d.ts +14 -12
  172. package/dist/utils/page-colors.js +15 -13
  173. package/dist/utils/page-fonts.d.ts +2 -2
  174. package/dist/utils/page-fonts.js +15 -4
  175. package/dist/utils/pages.d.ts +21 -3
  176. package/dist/utils/pages.js +42 -13
  177. package/dist/utils/publish-form-data.d.ts +12 -0
  178. package/dist/utils/publish-form-data.js +10 -0
  179. package/dist/utils/publish-policy.d.ts +27 -0
  180. package/dist/utils/publish-policy.fixtures.json +403 -0
  181. package/dist/utils/publish-policy.js +45 -20
  182. package/dist/utils/push-new.d.ts +7 -0
  183. package/dist/utils/push-new.js +7 -0
  184. package/dist/utils/query-keys.d.ts +4 -5
  185. package/dist/utils/query-keys.js +2 -3
  186. package/dist/utils/runtime-paths.d.ts +5 -0
  187. package/dist/utils/runtime-paths.js +5 -0
  188. package/dist/utils/runtime-upload-batch.d.ts +0 -5
  189. package/dist/utils/runtime-upload-batch.js +1 -27
  190. package/dist/utils/runtime-upload.d.ts +6 -11
  191. package/dist/utils/runtime-upload.js +10 -13
  192. package/dist/utils/secure-local-file.js +5 -16
  193. package/dist/utils/space-config.d.ts +1 -34
  194. package/dist/utils/space-config.js +8 -326
  195. package/dist/utils/static-runtime-policy.d.ts +9 -3
  196. package/dist/utils/static-runtime-policy.fixtures.json +38 -41
  197. package/dist/utils/static-runtime-policy.js +22 -56
  198. package/dist/utils/storage-policy.d.ts +1 -1
  199. package/dist/utils/storage-policy.js +3 -1
  200. package/dist/utils/structured-error.d.ts +14 -0
  201. package/dist/utils/structured-error.js +22 -0
  202. package/dist/utils/upload-session.d.ts +4 -1
  203. package/dist/utils/upload-session.js +33 -5
  204. package/dist/utils/version-path.js +13 -4
  205. package/dist/vocabulary.d.ts +13 -11
  206. package/dist/vocabulary.js +42 -28
  207. package/package.json +7 -17
  208. package/dist/config/postgres-budget.d.ts +0 -129
  209. package/dist/config/postgres-budget.js +0 -140
  210. package/dist/config/postgres-budget.json +0 -51
  211. package/dist/contracts/archives.d.ts +0 -331
  212. package/dist/contracts/archives.js +0 -120
  213. package/dist/contracts/deployments.d.ts +0 -574
  214. package/dist/contracts/deployments.js +0 -97
  215. package/dist/contracts/sites.d.ts +0 -416
  216. package/dist/contracts/sites.js +0 -168
  217. package/dist/contracts/superadmin-queues.d.ts +0 -414
  218. package/dist/contracts/superadmin-queues.js +0 -202
  219. package/dist/contracts/superadmin-runtime.d.ts +0 -27
  220. package/dist/contracts/superadmin-runtime.js +0 -38
  221. package/dist/index.d.ts +0 -1
  222. package/dist/index.js +0 -1
  223. package/dist/utils/api.d.ts +0 -4
  224. package/dist/utils/api.js +0 -13
@@ -1,23 +1,66 @@
1
1
  import { z } from "zod";
2
2
  import { SPACE_SLUG_MAX_LENGTH } from "../slug-policy/index.js";
3
+ import { normalizeVersionPath } from "../utils/version-path.js";
3
4
  import { publishedAccessSchema } from "./access.js";
4
5
  import { AsyncOperationSchema, baseDiagnosticSchema, CursorPaginationSchema, cursorListQuerySchema, } from "./common.js";
5
6
  import { versionStatus, spaceStatus } from "./enums.js";
6
- import { runtimeKindSchema } from "./execution.js";
7
- import { conventionFilesSchema, uploadInstructionsSchema, manifestFileSchema } from "./internal.js";
7
+ import { uploadInstructionsSchema, manifestFileSchema } from "./internal.js";
8
8
  import { VersionSchema, PublishSourceSchema, SpaceSchema, spaceSettingsDigestSchema, } from "./resources.js";
9
9
  import { runtimeAppSchema } from "./runtime-app.js";
10
10
  import { SPACE_CONFIG_ACCEPTED_FILES, spaceConfigSchema, spacePlacementConfigSchema, } from "./space-config.js";
11
11
  import { principalIdSchema } from "./transfers.js";
12
+ export const VERSION_BUILD_LOG_MAX_LENGTH = 512 * 1024;
13
+ // Capacity accounting for the provider site a space runs on. A space IS a
14
+ // site, so occupancy is not a question — storage is. Warm-pool inventory rows
15
+ // carry the same shape before a space adopts them.
16
+ export const SpaceCapacitySchema = z
17
+ .object({
18
+ storageBytes: z
19
+ .number()
20
+ .int()
21
+ .nonnegative()
22
+ .optional()
23
+ .describe("Storage budget for the space in bytes."),
24
+ })
25
+ .describe("Capacity accounting for a space's provider site.");
26
+ export const SpacePressureSchema = z
27
+ .object({
28
+ ewmaLimitedPct: z.number().nonnegative().optional(),
29
+ ewma429: z.number().nonnegative().optional(),
30
+ ewma429PerMin: z.number().nonnegative().optional(),
31
+ ewmaWorkersMax: z.number().nonnegative().optional(),
32
+ ewmaCpuPct: z.number().nonnegative().optional(),
33
+ lastSampleAt: z.string().datetime().optional(),
34
+ consecutivePressured: z.number().int().nonnegative().optional(),
35
+ consecutiveClean: z.number().int().nonnegative().optional(),
36
+ // Monotonic CAS token shared by explicit operator hold actions and the
37
+ // pressure sampler. Every durable hold transition advances it, including
38
+ // transitions that restore a prior timestamp.
39
+ placementHoldRevision: z.number().int().nonnegative().optional(),
40
+ // Provenance stamp for the sampler's automatic hold: set on trip to the
41
+ // exact hold instant it wrote, so release only clears holds the pressure
42
+ // pipeline itself set — never an operator-set placement hold.
43
+ pressureHoldUntil: z.string().datetime().optional(),
44
+ // Last time a bulk-lane engine job on this space reported activity via the
45
+ // job callbacks (runtime/callback-events.ts); the sampler discounts the
46
+ // CPU signal while this is within the sampling window.
47
+ lastBulkLaneActivityAt: z.string().datetime().optional(),
48
+ })
49
+ .passthrough()
50
+ .describe("Placement pressure signals computed outside the request path.");
12
51
  export const spaceClaimReceiptSchema = z.object({
13
- token: z
52
+ key: z
14
53
  .string()
15
54
  .min(1)
16
- .describe("One-time, space-scoped credential returned only at anonymous space creation. Save it immediately. The server never shows it again. You need it to publish and manage the space until the space is claimed."),
55
+ .describe("The space key (sfc_…): the one credential for this unclaimed space. Bearer auth for publish, update, status, sharing, rotation, and the one-time continuation exchange. Returned only at creation and rotation; save it immediately."),
17
56
  url: z
18
57
  .string()
19
58
  .url()
20
- .describe("Browser-only claim link with a short-lived, one-use path token. The access origin consumes it into an HttpOnly handoff, then redirects to a clean claim page. API clients use the separate claim token as bearer auth for publish, update, status, and exchange."),
59
+ .describe("The site door: the live URL with the space key in /__/<key> form. Opening it exchanges the key for a private view session and lands on the site. Same key, URL form share it as carefully as the key."),
60
+ claimUrl: z
61
+ .string()
62
+ .url()
63
+ .describe("Claim page link in /claim#<key> form. The fragment is the key; browsers never send it to a server and the claim page strips it before analytics. Works until expiresAt and can be opened more than once."),
21
64
  expiresAt: z.string().datetime(),
22
65
  });
23
66
  export const SpaceCreateResponseSchema = z.object({
@@ -42,10 +85,6 @@ export const principalRefInputSchema = z.object({
42
85
  });
43
86
  export const spaceCreateSchema = z
44
87
  .object({
45
- // `siteId` selects the static site the space lives under. Optional today:
46
- // when omitted the tenant's default static site is resolved (internal-docs/platform.md "Site
47
- // Context Resolution"). Spaces are valid only under static sites.
48
- siteId: z.string().min(1).optional(),
49
88
  teamId: z.string().nullable().optional(),
50
89
  principal: principalRefInputSchema.optional(),
51
90
  slug: z.string().min(2).max(55).optional(),
@@ -108,50 +147,25 @@ export const spacePatchSchema = z
108
147
  });
109
148
  }
110
149
  });
111
- export const spaceClaimSchema = z
112
- .object({
113
- claimToken: z
114
- .string()
115
- .min(1)
116
- .describe("One-time claim token returned at anonymous creation. API clients send it as bearer auth; browser claim links carry a separate browser handoff credential."),
117
- teamId: z
150
+ // The one claim endpoint (POST /v1/claim). A converging loop: the caller sends
151
+ // what it has decided so far; the server either commits the claim or answers
152
+ // with the single decision still missing (`login_required`, `team_required`,
153
+ // `consent_required`).
154
+ export const anonymousClaimSchema = z.object({
155
+ key: z
118
156
  .string()
119
157
  .min(1)
120
158
  .optional()
121
- .describe("Team receiving the space. Inferred when you belong to exactly one team; otherwise required (`team_required`)."),
122
- targetTeamId: z
159
+ .describe("The space key, when not sent as bearer auth. Browser claim pages send it here after reading the /claim#<key> fragment."),
160
+ teamId: z
123
161
  .string()
124
162
  .min(1)
125
163
  .optional()
126
- .describe("Alias of teamId; must match when both are provided."),
127
- agentContinuation: z
128
- .boolean()
129
- .optional()
130
- .describe("User consent to keep the publishing agent authorized after the claim. The server independently proves continuation eligibility. Consent cannot grant continuation for an ineligible space."),
131
- })
132
- .superRefine((value, ctx) => {
133
- if (value.teamId && value.targetTeamId && value.teamId !== value.targetTeamId) {
134
- ctx.addIssue({
135
- code: z.ZodIssueCode.custom,
136
- path: ["teamId"],
137
- message: "teamId and targetTeamId must match when both are provided.",
138
- });
139
- }
140
- });
141
- export const anonymousClaimAssignSchema = z.object({
142
- teamId: z.string().min(1).optional(),
143
- nonce: z.string().min(1).optional().describe("Browser claim nonce from the claim handoff."),
164
+ .describe("Team receiving the space. Inferred when the caller has exactly one writable team; otherwise the response answers `team_required` with the choices."),
144
165
  agentContinuation: z
145
166
  .boolean()
146
167
  .optional()
147
- .describe("User consent to keep the publishing agent authorized after the claim. The server independently proves continuation eligibility. Consent cannot grant continuation for an ineligible space."),
148
- });
149
- export const anonymousClaimResolveSchema = z.object({
150
- nonce: z.string().min(1).optional().describe("Browser claim nonce from the claim handoff."),
151
- agentContinuation: z
152
- .boolean()
153
- .optional()
154
- .describe("User consent applied when resolve auto-claims. The server independently proves continuation eligibility. Consent cannot grant continuation for an ineligible space."),
168
+ .describe("User consent to keep the publishing agent authorized after the claim. Required (true or false) when the space is continuation-eligible; the server independently proves eligibility, so consent cannot grant continuation to an ineligible space."),
155
169
  });
156
170
  export const anonymousClaimTeamSchema = z.object({
157
171
  id: z.string(),
@@ -185,18 +199,20 @@ export const anonymousClaimSharingSummarySchema = z.object({
185
199
  });
186
200
  export const anonymousClaimResponseSchema = z.object({
187
201
  state: z.enum(["unclaimed", "claimed"]),
188
- action: z.enum(["claimed", "login_required", "team_required", "confirm_assign"]),
202
+ action: z.enum(["claimed", "login_required", "team_required", "consent_required"]),
189
203
  space: anonymousClaimSpacePreviewSchema,
190
204
  claim: z.object({
191
205
  expiresAt: z.string().datetime().nullable(),
192
206
  claimedAt: z.string().datetime().nullable(),
193
207
  }),
194
- access: publishedAccessSchema,
208
+ access: publishedAccessSchema
209
+ .optional()
210
+ .describe("The space's reusable Open link, returned once the claim commits so the page can open the (private-by-default) site. Pre-claim callers already hold the key and its door URL."),
195
211
  continuation: z
196
212
  .object({
197
213
  eligible: z
198
214
  .boolean()
199
- .describe("Server-proven continuation eligibility. Eligible means the publish intent records an originating agent that holds the claim token, the one-time exchange is unredeemed, and a safe secretless return exists. Only then can the UI offer continuation."),
215
+ .describe("Server-proven continuation eligibility. Eligible means the publish intent records an originating agent that holds the space key, the one-time exchange is unredeemed, and a safe secretless return exists. Only then can the UI offer continuation."),
200
216
  granted: z
201
217
  .boolean()
202
218
  .describe("Whether the claim left the one-time continuation exchange open for the originating agent."),
@@ -224,14 +240,16 @@ export const anonymousClaimStatusResponseSchema = z.object({
224
240
  }),
225
241
  claim: z.object({
226
242
  state: z.enum(["unclaimed", "claimed"]),
227
- url: z.string().nullable(),
243
+ url: z
244
+ .string()
245
+ .nullable()
246
+ .describe("Claim page link (/claim#<key>) while the space is unclaimed; null after."),
228
247
  expiresAt: z.string().datetime().nullable(),
229
248
  continuation: z
230
249
  .enum(["available", "used", "unavailable"])
231
250
  .optional()
232
- .describe("Present once the space is claimed. Whether this claim token can still be exchanged once for a durable API key (POST /v1/anonymous-claim/exchange)."),
251
+ .describe("Present once the space is claimed. Whether this key can still be exchanged once for a durable API key (POST /v1/claim/exchange)."),
233
252
  }),
234
- access: publishedAccessSchema,
235
253
  });
236
254
  export const anonymousClaimExchangeResponseSchema = z.object({
237
255
  space: z.object({
@@ -253,14 +271,7 @@ export const anonymousClaimRotateSchema = z.object({
253
271
  });
254
272
  export const anonymousClaimRotateResponseSchema = z.object({
255
273
  spaceId: z.string(),
256
- claimToken: z
257
- .string()
258
- .describe("Replacement claim token. Shown exactly once; store it before leaving this response."),
259
- claimNonce: z
260
- .string()
261
- .describe("Replacement browser claim nonce embedded in claimUrl. Shown exactly once."),
262
- claimUrl: z.string().url(),
263
- expiresAt: z.string().datetime(),
274
+ claim: spaceClaimReceiptSchema.describe("Replacement space key, door URL, and claim link. Shown exactly once; the previous key, its URLs, and its view sessions stop working."),
264
275
  });
265
276
  export const spaceClaimReminderSchema = z.object({
266
277
  email: z
@@ -309,19 +320,16 @@ export const spaceVersionCreateSchema = z
309
320
  .describe("Additional control-plane-only provenance for build and deploy read models."),
310
321
  buildLog: z
311
322
  .string()
312
- .max(64_000)
323
+ .max(VERSION_BUILD_LOG_MAX_LENGTH)
313
324
  .optional()
314
325
  .describe("Build transcript truncated to a bounded size for deploys that ran a local build before publishing."),
315
- conventionFiles: conventionFilesSchema
316
- .optional()
317
- .describe("Routing convention contents used when deciding whether this publish is unchanged. The same values are supplied again when the version is finalized."),
318
326
  finalize: z
319
327
  .object({ channel: z.literal("live").nullable().optional() })
320
328
  .optional()
321
329
  .describe("Finalize intent for a declared upload. When every declared file lands, the version finalizes itself; the explicit finalize call remains available for recovery and replay."),
322
330
  files: z
323
331
  .array(manifestFileSchema)
324
- .describe("The complete desired file manifest. For first deploys, send `path`, `size`, and `contentType` without hashes so upload can begin immediately. For updates, include `sha256` so the server can skip unchanged files."),
332
+ .describe("The complete desired file manifest. `sha256` is optional: omit it to upload by path and let the runtime hash the bytes, or include it to upload by content address, with the digest verified as the bytes land. A `sourceUrl` entry is fetched and hashed by the runtime."),
325
333
  ...manifestMutationFieldsSchema,
326
334
  })
327
335
  .superRefine(refineManifestMutationRules);
@@ -348,7 +356,6 @@ export const versionLogEntrySchema = z.object({
348
356
  code: z.string().describe("Stable version.{status} code for the line."),
349
357
  message: z.string().describe("Human-readable log line."),
350
358
  });
351
- export const VERSION_BUILD_LOG_MAX_LENGTH = 512 * 1024;
352
359
  export const versionLogListResponseSchema = z.object({
353
360
  data: z.array(versionLogEntrySchema),
354
361
  pagination: CursorPaginationSchema,
@@ -408,36 +415,57 @@ export const spaceFilesResponseSchema = z.object({
408
415
  export const spaceVersionFilePathQuerySchema = z.object({
409
416
  path: z.string().min(1),
410
417
  });
411
- export const spaceVersionFileQuerySchema = spaceVersionFilePathQuerySchema.extend({
412
- download: z.string().optional(),
413
- });
414
- export const spaceVersionFileResponseSchema = z.object({
415
- versionId: z.string(),
416
- path: z.string(),
417
- size: z.number().int().nonnegative(),
418
- contentType: z.string().nullable(),
419
- sha256: z.string().nullable(),
420
- encoding: z.enum(["utf8", "base64"]),
421
- content: z.string(),
422
- truncated: z.boolean(),
423
- cached: z.boolean(),
418
+ /**
419
+ * Which representation of a path the runtime should hand back: `source` is the
420
+ * uploaded, pre-substitution object; `served` is the immutable byte the
421
+ * version actually serves. A private config input exists in `source` and is
422
+ * absent from `served`.
423
+ */
424
+ export const spaceVersionFileViewSchema = z.enum(["source", "served"]);
425
+ // Minting is a read, so it rides the URL — and a URL has a practical ceiling
426
+ // that a JSON body does not. Clients chunk; each chunk is one authorization.
427
+ export const VERSION_FILE_LINKS_MAX_PATHS = 200;
428
+ // Structural admission only. Whether the version HOLDS a path is the runtime's
429
+ // answer, given when the link is followed — the control plane keeps no catalog
430
+ // to check against and does not round-trip per path to fake one.
431
+ const spaceVersionFileLinkPathSchema = z
432
+ .string()
433
+ .min(1)
434
+ .refine((value) => {
435
+ try {
436
+ normalizeVersionPath(value);
437
+ return true;
438
+ }
439
+ catch {
440
+ return false;
441
+ }
442
+ }, { message: "Path must be version-relative, without traversal or control characters." });
443
+ /**
444
+ * Repeated `path` query parameters — `?path=index.html&path=about.html`. One
445
+ * path arrives as a bare string, so it is lifted into the batch shape before
446
+ * the per-path rules run.
447
+ */
448
+ export const spaceVersionFileLinksQuerySchema = z.object({
449
+ path: z
450
+ .preprocess((value) => (typeof value === "string" ? [value] : value), z.array(spaceVersionFileLinkPathSchema).min(1).max(VERSION_FILE_LINKS_MAX_PATHS))
451
+ .describe("Version-relative file paths to mint read links for; repeat the parameter per path."),
452
+ view: spaceVersionFileViewSchema
453
+ .default("source")
454
+ .describe("Which representation to read: the uploaded source or the served byte."),
455
+ });
456
+ export const spaceVersionFileLinkSchema = z.object({
457
+ url: z.string().url().describe("Short-lived signed URL that serves the file's bytes."),
458
+ expiresAt: z.string().describe("When the link stops working."),
424
459
  });
425
- export const spaceVersionFileUrlPreviewSchema = z.object({
460
+ /**
461
+ * Minting is blind to path validity — the control plane authorizes the version,
462
+ * not the path. A path that is not in the selected catalog view answers
463
+ * `version_file_not_found` when the link is followed.
464
+ */
465
+ export const spaceVersionFileLinksResponseSchema = z.object({
426
466
  versionId: z.string(),
427
- path: z.string(),
428
- sha256: z.string().nullable(),
429
- source: z.enum(["internet-shortcut", "webloc", "plain-url"]),
430
- url: z.string().url(),
431
- fetchedUrl: z.string().url().nullable(),
432
- title: z.string().nullable(),
433
- description: z.string().nullable(),
434
- siteName: z.string().nullable(),
435
- providerName: z.string().nullable(),
436
- authorName: z.string().nullable(),
437
- imageUrl: z.string().url().nullable(),
438
- oEmbedUrl: z.string().url().nullable(),
439
- status: z.enum(["ready", "unavailable"]),
440
- cached: z.boolean(),
467
+ view: spaceVersionFileViewSchema,
468
+ links: z.record(z.string(), spaceVersionFileLinkSchema),
441
469
  });
442
470
  export const spaceVersionConventionArtifactKindSchema = z.enum(["redirects", "headers"]);
443
471
  export const spaceVersionConventionArtifactPathSchema = z.enum(["_redirects", "_headers"]);
@@ -500,62 +528,16 @@ export const spaceVersionComputedRoutingSummarySchema = z.object({
500
528
  source: z.object({
501
529
  artifacts: z.array(spaceVersionConventionArtifactMetadataSchema),
502
530
  }),
531
+ // Finalize-written scalars, not a replay of a stored compiled-routing blob:
532
+ // the runtime owns the compile and reports these counts on its receipt.
503
533
  compiled: z.object({
504
534
  redirectRuleCount: z.number().int().nonnegative(),
505
535
  headerRuleCount: z.number().int().nonnegative(),
506
- staticRedirectCount: z.number().int().nonnegative(),
507
- dynamicRedirectCount: z.number().int().nonnegative(),
508
536
  proxyRuleCount: z.number().int().nonnegative(),
509
537
  }),
510
538
  diagnostics: z.array(spaceVersionRoutingDiagnosticSchema),
511
539
  });
512
- export const spaceVersionFileDiffStatusSchema = z.enum([
513
- "added",
514
- "modified",
515
- "deleted",
516
- "renamed",
517
- "unchanged",
518
- "binary",
519
- "too_large",
520
- ]);
521
- export const spaceVersionFileDiffEntrySchema = z.object({
522
- path: z.string(),
523
- oldPath: z.string().nullable(),
524
- status: spaceVersionFileDiffStatusSchema,
525
- before: spaceVersionFileSchema.nullable(),
526
- after: spaceVersionFileSchema.nullable(),
527
- patch: z
528
- .object({
529
- format: z.literal("unified"),
530
- content: z.string(),
531
- truncated: z.boolean(),
532
- truncationReason: z.literal("patch_byte_limit").nullable(),
533
- })
534
- .nullable(),
535
- patchOmission: z
536
- .enum(["input_too_large", "not_previewable", "content_unavailable", "patch_budget_exhausted"])
537
- .nullable(),
538
- });
539
- export const spaceVersionFileDiffQuerySchema = cursorListQuerySchema.extend({
540
- baseVersionId: z.string().optional(),
541
- });
542
- export const spaceVersionFileDiffResponseSchema = z.object({
543
- versionId: z.string(),
544
- baseVersionId: z.string().nullable(),
545
- files: z.array(spaceVersionFileDiffEntrySchema),
546
- pagination: CursorPaginationSchema,
547
- limits: z.object({
548
- maxFiles: z.number().int().positive(),
549
- maxInputBytes: z.number().int().positive(),
550
- maxPatchBytes: z.number().int().positive(),
551
- readConcurrency: z.number().int().positive(),
552
- }),
553
- usage: z.object({
554
- inputBytes: z.number().int().nonnegative(),
555
- patchBytes: z.number().int().nonnegative(),
556
- }),
557
- });
558
- // Upload state is inferable (internal-docs/platform.md L2216): `upload` present means bytes are
540
+ // Upload state is inferable (the platform spec): `upload` present means bytes are
559
541
  // still needed (then finalize); `versionId` null means the manifest matched and nothing changed.
560
542
  // No redundant booleans ride along.
561
543
  export const spaceVersionIntentResponseSchema = z.object({
@@ -574,12 +556,11 @@ export const spaceVersionIntentResponseSchema = z.object({
574
556
  export const publishRequestSchema = z
575
557
  .object({
576
558
  spaceId: z.string().min(1).optional(),
577
- siteId: z.string().min(1).optional(),
578
559
  teamId: z.string().nullable().optional(),
579
560
  principal: principalRefInputSchema.optional(),
580
561
  files: z
581
562
  .array(manifestFileSchema)
582
- .describe("Desired file manifest for a declared publish session. Clients upload returned paths, then finalize."),
563
+ .describe("Desired file manifest for a declared publish session. `sha256` is optional: omitted local bytes receive path-addressed upload targets and are hashed by the runtime; declared hashes receive content-addressed targets and can reuse existing bytes. Clients upload returned targets, then finalize."),
583
564
  ...manifestMutationFieldsSchema,
584
565
  source: PublishSourceSchema.optional().describe('Publish provenance recorded on the version; defaults to {kind: "direct_upload"}.'),
585
566
  // Same fields, same bounds as spaceVersionCreateSchema: a publish that ran
@@ -591,7 +572,7 @@ export const publishRequestSchema = z
591
572
  .describe("Additional control-plane-only provenance for build/deploy read models."),
592
573
  buildLog: z
593
574
  .string()
594
- .max(64_000)
575
+ .max(VERSION_BUILD_LOG_MAX_LENGTH)
595
576
  .optional()
596
577
  .describe("Bounded build transcript for deploys that ran a local build before publishing."),
597
578
  publishMode: z
@@ -634,6 +615,7 @@ export const publishUploadReceiptSchema = z.object({
634
615
  export const publishReceiptSpaceSchema = z.object({
635
616
  id: z.string(),
636
617
  slug: z.string(),
618
+ title: z.string(),
637
619
  publicName: z.string(),
638
620
  defaultHostname: z.string(),
639
621
  liveUrl: z.string().nullable(),
@@ -680,7 +662,9 @@ export const publishNextSchema = z.object({
680
662
  });
681
663
  export const publishReceiptSchema = z.object({
682
664
  space: publishReceiptSpaceSchema,
683
- access: publishedAccessSchema.optional(),
665
+ access: publishedAccessSchema
666
+ .optional()
667
+ .describe("Reusable Open link for owned (team/external) publishes. Anonymous publishes get no separate access object: the space key in `claim` is the credential, and `claim.url` is the door."),
684
668
  version: publishReceiptVersionSchema,
685
669
  activation: publishActivationSchema,
686
670
  next: publishNextSchema,
@@ -711,7 +695,7 @@ export const publishReceiptSchema = z.object({
711
695
  status: z
712
696
  .string()
713
697
  .optional()
714
- .describe("Claim-token-authenticated anonymous publish status endpoint."),
698
+ .describe("Space-key-authenticated anonymous publish status endpoint."),
715
699
  })
716
700
  .optional()
717
701
  .describe("Follow-up links so agents can act on the receipt without knowing the full API."),
@@ -744,7 +728,6 @@ export const versionPromoteSchema = z
744
728
  .default({});
745
729
  export const spaceFinalizeSchema = z
746
730
  .object({
747
- conventionFiles: conventionFilesSchema.optional(),
748
731
  channel: z
749
732
  .enum(["live"])
750
733
  .nullable()
@@ -768,14 +751,11 @@ export const spaceRuntimeStatusSchema = z.object({
768
751
  .describe("Live space URL. It moves to the latest version after a successful publish to `live`."),
769
752
  runtimeState: spaceStatus.describe("Space operation-lifecycle status."),
770
753
  liveVersionStatus: versionStatus.nullable(),
771
- liveRuntimeKind: runtimeKindSchema
772
- .nullable()
773
- .describe("Runtime kind declared by the live version, if any."),
774
754
  pendingVersionStatus: versionStatus.nullable(),
775
755
  operation: AsyncOperationSchema.nullable(),
776
756
  app: runtimeAppSchema
777
757
  .nullable()
778
- .describe("What the live version runs: its Zero capsule or Functions worker, discriminated by `runtimeKind`. Null for a static space. Also null for callers whose credential does not carry `versions:read`, because app details read version contents, not serving state."),
758
+ .describe("What the live version runs: its Zero capsule and its Functions worker, each null when the published tree carries none of that product (both null for a space without a runtime). The whole object is null for callers whose credential does not carry `versions:read`, because app details read version contents, not serving state."),
779
759
  });
780
760
  export const spaceApplyChangeBaseSchema = z.object({
781
761
  kind: z.enum(["variable", "routing", "access", "settings"]),
@@ -2,6 +2,61 @@ import { z } from "zod";
2
2
  export declare const superadminActivityListQuerySchema: z.ZodObject<{
3
3
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
4
4
  }, z.core.$strip>;
5
+ export declare const superadminActivityEventQuerySchema: z.ZodObject<{
6
+ spaceId: z.ZodOptional<z.ZodString>;
7
+ tenantId: z.ZodOptional<z.ZodString>;
8
+ principalType: z.ZodOptional<z.ZodEnum<{
9
+ team: "team";
10
+ external: "external";
11
+ }>>;
12
+ principalId: z.ZodOptional<z.ZodString>;
13
+ actorType: z.ZodOptional<z.ZodEnum<{
14
+ system: "system";
15
+ user: "user";
16
+ api_key: "api_key";
17
+ oauth_client: "oauth_client";
18
+ anonymous_claim: "anonymous_claim";
19
+ }>>;
20
+ actorId: z.ZodOptional<z.ZodString>;
21
+ code: z.ZodOptional<z.ZodString>;
22
+ since: z.ZodOptional<z.ZodString>;
23
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
24
+ cursor: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strip>;
26
+ export declare const SuperadminActivityEventSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ sequence: z.ZodNumber;
29
+ tenantId: z.ZodString;
30
+ principalType: z.ZodNullable<z.ZodString>;
31
+ principalId: z.ZodNullable<z.ZodString>;
32
+ spaceId: z.ZodNullable<z.ZodString>;
33
+ actorType: z.ZodString;
34
+ actorId: z.ZodString;
35
+ code: z.ZodString;
36
+ message: z.ZodString;
37
+ details: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
+ createdAt: z.ZodString;
39
+ }, z.core.$strip>;
40
+ export declare const SuperadminActivityEventListSchema: z.ZodObject<{
41
+ data: z.ZodArray<z.ZodObject<{
42
+ id: z.ZodString;
43
+ sequence: z.ZodNumber;
44
+ tenantId: z.ZodString;
45
+ principalType: z.ZodNullable<z.ZodString>;
46
+ principalId: z.ZodNullable<z.ZodString>;
47
+ spaceId: z.ZodNullable<z.ZodString>;
48
+ actorType: z.ZodString;
49
+ actorId: z.ZodString;
50
+ code: z.ZodString;
51
+ message: z.ZodString;
52
+ details: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
53
+ createdAt: z.ZodString;
54
+ }, z.core.$strip>>;
55
+ pagination: z.ZodObject<{
56
+ nextCursor: z.ZodNullable<z.ZodString>;
57
+ hasMore: z.ZodBoolean;
58
+ }, z.core.$strip>;
59
+ }, z.core.$strip>;
5
60
  export declare const SuperadminLatestUserSchema: z.ZodObject<{
6
61
  id: z.ZodString;
7
62
  name: z.ZodString;
@@ -43,9 +98,7 @@ export declare const SuperadminLatestSpaceSchema: z.ZodObject<{
43
98
  teamSlug: z.ZodNullable<z.ZodString>;
44
99
  teamName: z.ZodNullable<z.ZodString>;
45
100
  externalCustomerId: z.ZodNullable<z.ZodString>;
46
- placementMode: z.ZodString;
47
101
  siteId: z.ZodNullable<z.ZodString>;
48
- siteClass: z.ZodNullable<z.ZodString>;
49
102
  siteStatus: z.ZodNullable<z.ZodString>;
50
103
  liveHostname: z.ZodNullable<z.ZodString>;
51
104
  disabledAt: z.ZodNullable<z.ZodString>;
@@ -65,9 +118,7 @@ export declare const SuperadminLatestSpaceListSchema: z.ZodObject<{
65
118
  teamSlug: z.ZodNullable<z.ZodString>;
66
119
  teamName: z.ZodNullable<z.ZodString>;
67
120
  externalCustomerId: z.ZodNullable<z.ZodString>;
68
- placementMode: z.ZodString;
69
121
  siteId: z.ZodNullable<z.ZodString>;
70
- siteClass: z.ZodNullable<z.ZodString>;
71
122
  siteStatus: z.ZodNullable<z.ZodString>;
72
123
  liveHostname: z.ZodNullable<z.ZodString>;
73
124
  disabledAt: z.ZodNullable<z.ZodString>;
@@ -198,6 +249,8 @@ export declare const SuperadminBadExperienceListSchema: z.ZodObject<{
198
249
  safetyReviews: z.ZodNumber;
199
250
  }, z.core.$strip>;
200
251
  }, z.core.$strip>;
252
+ export type SuperadminActivityEvent = z.infer<typeof SuperadminActivityEventSchema>;
253
+ export type SuperadminActivityEventQuery = z.infer<typeof superadminActivityEventQuerySchema>;
201
254
  export type SuperadminLatestUser = z.infer<typeof SuperadminLatestUserSchema>;
202
255
  export type SuperadminLatestSpace = z.infer<typeof SuperadminLatestSpaceSchema>;
203
256
  export type SuperadminLatestVersion = z.infer<typeof SuperadminLatestVersionSchema>;
@@ -1,7 +1,55 @@
1
1
  import { z } from "zod";
2
+ import { AnyObjectSchema, CursorPaginationSchema } from "./common.js";
2
3
  export const superadminActivityListQuerySchema = z.object({
3
4
  limit: z.coerce.number().int().min(1).max(100).default(50),
4
5
  });
6
+ // Cross-tenant reader over the `activity_events` audit log. Every superadmin
7
+ // mutation appends there, but only tenant-scoped /v1 readers existed; this is
8
+ // the operator's view of the same rows. At least one selective filter is
9
+ // required (see the route) so a query lands on one of the table's indexes
10
+ // instead of scanning the whole log.
11
+ export const superadminActivityEventQuerySchema = z.object({
12
+ spaceId: z.string().min(1).optional().describe("Filter to events for one Space, cross-tenant."),
13
+ tenantId: z.string().min(1).optional().describe("Filter to one tenant."),
14
+ principalType: z
15
+ .enum(["team", "external"])
16
+ .optional()
17
+ .describe("Owning principal kind; must be paired with principalId."),
18
+ principalId: z
19
+ .string()
20
+ .min(1)
21
+ .optional()
22
+ .describe("Owning principal id; must be paired with principalType."),
23
+ actorType: z
24
+ .enum(["user", "api_key", "oauth_client", "anonymous_claim", "system"])
25
+ .optional()
26
+ .describe("Actor kind; must be paired with actorId."),
27
+ actorId: z.string().min(1).optional().describe("Actor id; must be paired with actorType."),
28
+ code: z.string().min(1).optional().describe("Filter to one event code, e.g. `space.created`."),
29
+ since: z.string().datetime().optional().describe("Only events at or after this time."),
30
+ limit: z.coerce.number().int().min(1).max(200).default(50),
31
+ cursor: z.string().min(1).optional(),
32
+ });
33
+ // Operator surface: `message` and `details` are the raw audit payloads, not the
34
+ // tenant-facing projection. Nothing here widens any /v1 response.
35
+ export const SuperadminActivityEventSchema = z.object({
36
+ id: z.string(),
37
+ sequence: z.number().int().nonnegative(),
38
+ tenantId: z.string(),
39
+ principalType: z.string().nullable(),
40
+ principalId: z.string().nullable(),
41
+ spaceId: z.string().nullable(),
42
+ actorType: z.string(),
43
+ actorId: z.string(),
44
+ code: z.string(),
45
+ message: z.string(),
46
+ details: AnyObjectSchema.nullable(),
47
+ createdAt: z.string().datetime(),
48
+ });
49
+ export const SuperadminActivityEventListSchema = z.object({
50
+ data: z.array(SuperadminActivityEventSchema),
51
+ pagination: CursorPaginationSchema,
52
+ });
5
53
  export const SuperadminLatestUserSchema = z.object({
6
54
  id: z.string(),
7
55
  name: z.string(),
@@ -30,9 +78,7 @@ export const SuperadminLatestSpaceSchema = z.object({
30
78
  teamSlug: z.string().nullable(),
31
79
  teamName: z.string().nullable(),
32
80
  externalCustomerId: z.string().nullable(),
33
- placementMode: z.string(),
34
81
  siteId: z.string().nullable(),
35
- siteClass: z.string().nullable(),
36
82
  siteStatus: z.string().nullable(),
37
83
  liveHostname: z.string().nullable(),
38
84
  disabledAt: z.string().datetime().nullable(),