@spacefast/common 0.2.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/dist/agents/marketplace-prompts.d.ts +1 -0
  2. package/dist/agents/marketplace-prompts.js +6 -0
  3. package/dist/agents/registry/core.d.ts +4 -12
  4. package/dist/agents/registry/core.js +7 -28
  5. package/dist/config/domains.d.ts +10 -8
  6. package/dist/config/domains.js +4 -7
  7. package/dist/contracts/access-core.d.ts +135 -0
  8. package/dist/contracts/access-core.js +242 -0
  9. package/dist/contracts/access-profiles.d.ts +8 -8
  10. package/dist/contracts/access-profiles.js +8 -8
  11. package/dist/contracts/access.d.ts +14 -103
  12. package/dist/contracts/access.js +10 -210
  13. package/dist/contracts/activity.d.ts +54 -55
  14. package/dist/contracts/activity.js +38 -9
  15. package/dist/contracts/api-keys.d.ts +69 -26
  16. package/dist/contracts/api-keys.js +29 -2
  17. package/dist/contracts/application-journal.d.ts +197 -4
  18. package/dist/contracts/application-journal.js +97 -16
  19. package/dist/contracts/auth.d.ts +20 -0
  20. package/dist/contracts/auth.js +18 -0
  21. package/dist/contracts/beta.d.ts +13 -0
  22. package/dist/contracts/beta.js +28 -0
  23. package/dist/contracts/billing.d.ts +2 -2
  24. package/dist/contracts/bootstrap.d.ts +23 -6
  25. package/dist/contracts/builds.d.ts +24 -4
  26. package/dist/contracts/builds.js +16 -4
  27. package/dist/contracts/channels.d.ts +43 -0
  28. package/dist/contracts/channels.js +22 -6
  29. package/dist/contracts/comments.d.ts +49 -0
  30. package/dist/contracts/comments.js +61 -2
  31. package/dist/contracts/commerce.d.ts +19 -13
  32. package/dist/contracts/connector-access.d.ts +28 -0
  33. package/dist/contracts/connector-access.js +31 -0
  34. package/dist/contracts/connectors.d.ts +2382 -0
  35. package/dist/contracts/connectors.js +941 -0
  36. package/dist/contracts/content-contract-verification.d.ts +112 -58
  37. package/dist/contracts/content-contract-verification.js +42 -54
  38. package/dist/contracts/content-model-emit.d.ts +97 -0
  39. package/dist/contracts/content-model-emit.js +306 -0
  40. package/dist/contracts/content-model-sdk.d.ts +101 -0
  41. package/dist/contracts/content-model-sdk.js +232 -0
  42. package/dist/contracts/{content-program.d.ts → content-model.d.ts} +338 -82
  43. package/dist/contracts/{content-program.js → content-model.js} +291 -63
  44. package/dist/contracts/content-platform-fixture.d.ts +380 -110
  45. package/dist/contracts/content-platform-fixture.js +8 -8
  46. package/dist/contracts/content-sync.d.ts +197 -74
  47. package/dist/contracts/content-sync.js +98 -37
  48. package/dist/contracts/content.d.ts +30 -422
  49. package/dist/contracts/content.js +34 -294
  50. package/dist/contracts/dashboard-prefs.d.ts +10 -3
  51. package/dist/contracts/dashboard-prefs.js +6 -3
  52. package/dist/contracts/data-location.d.ts +9 -0
  53. package/dist/contracts/data-location.js +7 -0
  54. package/dist/contracts/deployment-comparison.d.ts +67 -0
  55. package/dist/contracts/deployment-comparison.js +68 -0
  56. package/dist/contracts/device-auth.d.ts +55 -11
  57. package/dist/contracts/domains.d.ts +40 -16
  58. package/dist/contracts/domains.js +23 -0
  59. package/dist/contracts/enums.d.ts +1 -10
  60. package/dist/contracts/enums.js +0 -15
  61. package/dist/contracts/error-code-meta.d.ts +388 -20
  62. package/dist/contracts/error-code-meta.js +201 -5
  63. package/dist/contracts/error-codes.d.ts +17 -4
  64. package/dist/contracts/error-codes.js +109 -10
  65. package/dist/contracts/events.d.ts +5 -0
  66. package/dist/contracts/events.js +12 -3
  67. package/dist/contracts/execution.d.ts +5 -1
  68. package/dist/contracts/execution.js +4 -0
  69. package/dist/contracts/feature-lifecycle.d.ts +53 -20
  70. package/dist/contracts/feature-lifecycle.js +65 -23
  71. package/dist/contracts/features.d.ts +57 -31
  72. package/dist/contracts/features.js +0 -1
  73. package/dist/contracts/feedback.d.ts +124 -0
  74. package/dist/contracts/feedback.js +64 -0
  75. package/dist/contracts/fixtures/content-model-sdk-v1.generated.d.ts +129 -0
  76. package/dist/contracts/fixtures/content-model-sdk-v1.generated.js +48 -0
  77. package/dist/contracts/fixtures/content-platform-v1.json +101 -49
  78. package/dist/contracts/frame-session.d.ts +60 -10
  79. package/dist/contracts/frame-session.js +52 -12
  80. package/dist/contracts/functions.d.ts +28 -2
  81. package/dist/contracts/functions.js +25 -2
  82. package/dist/contracts/grant-copy.d.ts +2 -0
  83. package/dist/contracts/grant-copy.js +2 -0
  84. package/dist/contracts/grants-core.d.ts +95 -0
  85. package/dist/contracts/grants-core.js +435 -0
  86. package/dist/contracts/grants.d.ts +13 -84
  87. package/dist/contracts/grants.js +21 -369
  88. package/dist/contracts/ids-core.d.ts +11 -0
  89. package/dist/contracts/ids-core.js +14 -0
  90. package/dist/contracts/ids.d.ts +7 -4
  91. package/dist/contracts/ids.js +12 -4
  92. package/dist/contracts/internal.d.ts +18 -0
  93. package/dist/contracts/internal.js +19 -0
  94. package/dist/contracts/mcp.d.ts +8 -18
  95. package/dist/contracts/mcp.js +2 -23
  96. package/dist/contracts/notifications.d.ts +4 -1
  97. package/dist/contracts/notifications.js +1 -0
  98. package/dist/contracts/oauth-resources.d.ts +55 -9
  99. package/dist/contracts/oauth-resources.js +64 -1
  100. package/dist/contracts/oauth-scope-actions.d.ts +27 -3
  101. package/dist/contracts/oauth-scope-actions.js +18 -8
  102. package/dist/contracts/operations.d.ts +1 -1
  103. package/dist/contracts/partner-account.d.ts +629 -0
  104. package/dist/contracts/partner-account.js +18 -0
  105. package/dist/contracts/principal-assertion.d.ts +74 -1
  106. package/dist/contracts/principal-assertion.js +67 -3
  107. package/dist/contracts/publish-archive.d.ts +22 -1
  108. package/dist/contracts/push-new.d.ts +3 -3
  109. package/dist/contracts/push-new.js +1 -1
  110. package/dist/contracts/quotas.js +2 -1
  111. package/dist/contracts/repository-connections.d.ts +10 -6
  112. package/dist/contracts/repository-connections.js +15 -0
  113. package/dist/contracts/resources.d.ts +6 -5
  114. package/dist/contracts/resources.js +7 -0
  115. package/dist/contracts/route-inventory.d.ts +74 -19
  116. package/dist/contracts/route-inventory.js +20 -6
  117. package/dist/contracts/runtime-api.d.ts +415 -4
  118. package/dist/contracts/runtime-api.js +60 -15
  119. package/dist/contracts/runtime-app.d.ts +6 -1
  120. package/dist/contracts/runtime-components.d.ts +646 -18
  121. package/dist/contracts/runtime-components.js +304 -188
  122. package/dist/contracts/runtime-services.d.ts +15 -0
  123. package/dist/contracts/runtime-services.js +25 -0
  124. package/dist/contracts/runtime-storage.d.ts +32 -0
  125. package/dist/contracts/runtime-storage.js +37 -0
  126. package/dist/contracts/source-workspaces.d.ts +511 -0
  127. package/dist/contracts/source-workspaces.js +276 -0
  128. package/dist/contracts/space-config-spacefast.d.ts +394 -0
  129. package/dist/contracts/space-config-spacefast.js +70 -0
  130. package/dist/contracts/space-config.d.ts +177 -90
  131. package/dist/contracts/space-config.js +77 -92
  132. package/dist/contracts/spaces.d.ts +132 -24
  133. package/dist/contracts/spaces.js +77 -13
  134. package/dist/contracts/superadmin-connectors.d.ts +371 -0
  135. package/dist/contracts/superadmin-connectors.js +61 -0
  136. package/dist/contracts/superadmin-emails.d.ts +1 -1
  137. package/dist/contracts/superadmin-emails.js +1 -1
  138. package/dist/contracts/superadmin-entities.d.ts +105 -0
  139. package/dist/contracts/superadmin-entities.js +64 -0
  140. package/dist/contracts/superadmin-runtime.d.ts +35 -116
  141. package/dist/contracts/superadmin-runtime.js +13 -69
  142. package/dist/contracts/superadmin-search.d.ts +12 -14
  143. package/dist/contracts/superadmin-search.js +2 -2
  144. package/dist/contracts/superadmin-spaces.d.ts +15 -72
  145. package/dist/contracts/superadmin-spaces.js +2 -7
  146. package/dist/contracts/superadmin-teams.d.ts +12 -0
  147. package/dist/contracts/superadmin-teams.js +7 -1
  148. package/dist/contracts/superadmin-tenants.d.ts +44 -16
  149. package/dist/contracts/superadmin.d.ts +2 -2
  150. package/dist/contracts/tags.d.ts +12 -12
  151. package/dist/contracts/teams.d.ts +29 -1
  152. package/dist/contracts/teams.js +24 -2
  153. package/dist/contracts/tenants.d.ts +98 -0
  154. package/dist/contracts/tenants.js +20 -0
  155. package/dist/contracts/transfers.d.ts +92 -0
  156. package/dist/contracts/transfers.js +37 -0
  157. package/dist/contracts/usage.d.ts +9 -1
  158. package/dist/contracts/usage.js +2 -0
  159. package/dist/contracts/visual-review.d.ts +448 -0
  160. package/dist/contracts/visual-review.js +156 -0
  161. package/dist/contracts/wordpress-php-toolkit.json +9 -0
  162. package/dist/contracts/work-mode.d.ts +24 -0
  163. package/dist/contracts/work-mode.js +17 -0
  164. package/dist/contracts/wp-cli.d.ts +66 -0
  165. package/dist/contracts/wp-cli.js +68 -0
  166. package/dist/contracts/zero-catalog.d.ts +29 -0
  167. package/dist/contracts/zero-catalog.js +55 -0
  168. package/dist/contracts/zero-platform-abilities.generated.d.ts +31 -0
  169. package/dist/contracts/zero-platform-abilities.generated.js +373 -0
  170. package/dist/contracts/zero-spacefast.d.ts +444 -0
  171. package/dist/contracts/zero-spacefast.js +149 -0
  172. package/dist/contracts/zero-types.d.ts +47 -0
  173. package/dist/contracts/zero-types.js +263 -0
  174. package/dist/contracts/zero.d.ts +781 -14
  175. package/dist/contracts/zero.js +204 -10
  176. package/dist/dashboard-paths/index.d.ts +2 -2
  177. package/dist/dashboard-paths/route-reservations.generated.d.ts +2 -2
  178. package/dist/dashboard-paths/route-reservations.generated.js +5 -0
  179. package/dist/docs/agent-prose.d.ts +1 -1
  180. package/dist/docs/agent-prose.js +15 -18
  181. package/dist/docs/agent-setup.d.ts +1 -1
  182. package/dist/docs/agent-setup.js +5 -13
  183. package/dist/docs/catalog.d.ts +64 -28
  184. package/dist/docs/catalog.js +155 -28
  185. package/dist/docs/error-docs.d.ts +365 -17
  186. package/dist/docs/error-docs.js +369 -21
  187. package/dist/docs/reference-urls.js +1 -1
  188. package/dist/docs/skills.d.ts +84 -84
  189. package/dist/docs/skills.js +66 -47
  190. package/dist/docs/start-prompts.d.ts +14 -0
  191. package/dist/docs/start-prompts.js +20 -0
  192. package/dist/utils/account-labels.d.ts +7 -0
  193. package/dist/utils/account-labels.js +15 -0
  194. package/dist/utils/auth.d.ts +1 -0
  195. package/dist/utils/auth.js +1 -0
  196. package/dist/utils/credential-policy.d.ts +22 -1
  197. package/dist/utils/credential-policy.js +55 -6
  198. package/dist/utils/local-space-state.d.ts +7 -0
  199. package/dist/utils/local-space-state.js +7 -0
  200. package/dist/utils/logger.d.ts +34 -0
  201. package/dist/utils/logger.js +144 -0
  202. package/dist/utils/page-routes.d.ts +9 -0
  203. package/dist/utils/page-routes.js +82 -0
  204. package/dist/utils/pages.d.ts +2 -0
  205. package/dist/utils/pages.js +7 -0
  206. package/dist/utils/publish-form-data.d.ts +2 -0
  207. package/dist/utils/publish-form-data.js +2 -0
  208. package/dist/utils/publish-policy-spacefast.d.ts +13 -0
  209. package/dist/utils/publish-policy-spacefast.js +117 -0
  210. package/dist/utils/publish-policy.d.ts +22 -16
  211. package/dist/utils/publish-policy.fixtures.json +15 -0
  212. package/dist/utils/publish-policy.js +62 -139
  213. package/dist/utils/query-client.js +9 -1
  214. package/dist/utils/runtime-upload.d.ts +4 -0
  215. package/dist/utils/runtime-upload.js +5 -0
  216. package/dist/utils/space-config.d.ts +2 -3
  217. package/dist/utils/space-config.js +1 -1
  218. package/dist/utils/uploaded-source.d.ts +4 -0
  219. package/dist/utils/uploaded-source.js +12 -0
  220. package/dist/visual-review.d.ts +4 -0
  221. package/dist/visual-review.js +208 -0
  222. package/dist/vocabulary.d.ts +38 -0
  223. package/dist/vocabulary.js +55 -0
  224. package/package.json +7 -2
  225. package/dist/agents/registry/deeplink-probes.d.ts +0 -23
  226. package/dist/agents/registry/deeplink-probes.js +0 -18
@@ -1,199 +1,315 @@
1
+ // src/contracts/runtime-components.ts
1
2
  import { z } from "zod";
2
- import { contentProgramSha256Schema } from "./content-program.js";
3
- import { registeredIdSchema } from "./ids.js";
4
- export const runtimeCapabilityIdSchema = z
5
- .string()
6
- .min(1)
7
- .max(160)
8
- .regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/)
9
- .brand();
10
- export const runtimeComponentIdSchema = z
11
- .string()
12
- .min(1)
13
- .max(160)
14
- .regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/)
15
- .brand();
16
- export const RUNTIME_COMPONENT_V1_REQUIRED_IDS = [
17
- "wordpress-core",
18
- "runtime-engine",
19
- "immutable-loader",
20
- "content-kernel",
21
- "managed-theme",
22
- "secure-custom-fields",
23
- "redirection",
24
- "block-transformer",
25
- "quickjs-abi",
3
+ import {
4
+ compiledContentModelV1Schema,
5
+ contentExecutableSetV1Schema,
6
+ contentModelReleaseV1Schema,
7
+ contentModelSha256Schema,
8
+ contentRouteContributionSetV1Schema,
9
+ contentSdkDescriptorSetV1Schema
10
+ } from "./content-model.js";
11
+ import { prefixedIdSchema } from "./ids-core.js";
12
+
13
+ // src/contracts/wordpress-php-toolkit.json
14
+ var wordpress_php_toolkit_default = {
15
+ version: "0.9.0",
16
+ archiveUrl: "https://github.com/WordPress/php-toolkit/releases/download/v0.9.0/data-liberation.zip",
17
+ archiveBytes: 883739,
18
+ archiveSha256: "sha256:ba6e691936699ae7f5ceaa0129ef7e7a10f1db77c559a32f824e8307747b7b54",
19
+ archivePath: "data-liberation/php-toolkit.phar",
20
+ embeddedPath: "engine/vendor/php-toolkit.phar",
21
+ sha256: "sha256:bd452b61fd6ee9f4838ff416a3d225e6c82a742ffaf325a57ad327828eda446a"
22
+ };
23
+
24
+ // src/contracts/runtime-components.ts
25
+ var runtimeCapabilityIdSchema = z.string().min(1).max(160).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/).brand();
26
+ var runtimeComponentIdSchema = z.string().min(1).max(160).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/).brand();
27
+ var RUNTIME_ACCESS_BROWSER_STATE_CAPABILITY = runtimeCapabilityIdSchema.parse(
28
+ "runtime.access.browser-state.v1"
29
+ );
30
+ var SPACEFAST_WORDPRESS_COMPONENT_RELEASE = {
31
+ wordpress: {
32
+ version: "7.1",
33
+ archiveUrl: "https://wordpress.org/wordpress-7.1.zip",
34
+ archiveBytes: 37216004,
35
+ archiveSha256: "sha256:d1ae02b5ae18428031ffc3943659fa87ab361d827f4aa804adf9276e4dc75df6"
36
+ },
37
+ secureCustomFields: {
38
+ version: "6.9.5",
39
+ software: "plugin://https://downloads.wordpress.org/plugin/secure-custom-fields.6.9.5.zip",
40
+ archiveUrl: "https://downloads.wordpress.org/plugin/secure-custom-fields.6.9.5.zip",
41
+ archiveBytes: 5532990,
42
+ archiveSha256: "sha256:2f3c6be871e23192bbcaf0f0870a8103678b078d168983cb39d95e0b0d25dbf3"
43
+ },
44
+ redirection: {
45
+ version: "5.10.0",
46
+ software: "plugin://https://downloads.wordpress.org/plugin/redirection.5.10.0.zip",
47
+ archiveUrl: "https://downloads.wordpress.org/plugin/redirection.5.10.0.zip",
48
+ archiveBytes: 494067,
49
+ archiveSha256: "sha256:966ac6267cd6a99f2d79ec05db1dee2e0aa0cddb6060b1c32cde2ffde739e333"
50
+ },
51
+ blockTransformer: {
52
+ version: "0.6.2",
53
+ software: "plugin://https://codeload.github.com/Automattic/blocks-engine-php-transformer/zip/refs/tags/v0.6.2",
54
+ archiveUrl: "https://codeload.github.com/Automattic/blocks-engine-php-transformer/zip/refs/tags/v0.6.2",
55
+ archiveBytes: 786827,
56
+ archiveSha256: "sha256:16492638259e8f0c1676332e52df27dd005552cca4a3f50055274363030a5a49"
57
+ },
58
+ phpToolkit: wordpress_php_toolkit_default,
59
+ // Jetpack is the one component the platform locks but does not always
60
+ // install: it is a per-team feature, and wp.cloud ships its own managed build
61
+ // rather than an archive we pin. The lock therefore names the software lane,
62
+ // not a version — licenses attach to whatever Jetpack the platform ships.
63
+ jetpack: {
64
+ version: "latest",
65
+ software: "plugins/jetpack/latest"
66
+ },
67
+ quickjsAbi: "rquickjs-0.12",
68
+ managedTheme: "spacefast-managed"
69
+ };
70
+ var RUNTIME_COMPONENT_V1_REQUIRED_IDS = [
71
+ "wordpress-core",
72
+ "runtime-engine",
73
+ "immutable-loader",
74
+ "content-kernel",
75
+ "managed-theme",
76
+ "secure-custom-fields",
77
+ "redirection",
78
+ "block-transformer",
79
+ "php-toolkit",
80
+ "jetpack",
81
+ "quickjs-abi"
26
82
  ];
27
- export const RUNTIME_COMPONENT_KINDS = [
28
- "wordpress-core",
29
- "runtime-engine",
30
- "mu-plugin",
31
- "plugin",
32
- "theme",
33
- "block-transformer",
34
- "quickjs-abi",
83
+ var JETPACK_RUNTIME_COMPONENT_ID = runtimeComponentIdSchema.parse("jetpack");
84
+ var RUNTIME_COMPONENT_KINDS = [
85
+ "wordpress-core",
86
+ "runtime-engine",
87
+ "mu-plugin",
88
+ "plugin",
89
+ "theme",
90
+ "block-transformer",
91
+ "quickjs-abi",
92
+ "runtime-library"
35
93
  ];
36
- export const runtimeComponentKindSchema = z.enum(RUNTIME_COMPONENT_KINDS);
37
- const runtimeComponentV1RequiredKinds = {
38
- "wordpress-core": "wordpress-core",
39
- "runtime-engine": "runtime-engine",
40
- "immutable-loader": "mu-plugin",
41
- "content-kernel": "mu-plugin",
42
- "managed-theme": "theme",
43
- "secure-custom-fields": "plugin",
44
- redirection: "plugin",
45
- "block-transformer": "block-transformer",
46
- "quickjs-abi": "quickjs-abi",
94
+ var runtimeComponentKindSchema = z.enum(RUNTIME_COMPONENT_KINDS);
95
+ var runtimeComponentV1RequiredKinds = {
96
+ "wordpress-core": "wordpress-core",
97
+ "runtime-engine": "runtime-engine",
98
+ "immutable-loader": "mu-plugin",
99
+ "content-kernel": "mu-plugin",
100
+ "managed-theme": "theme",
101
+ "secure-custom-fields": "plugin",
102
+ redirection: "plugin",
103
+ "block-transformer": "block-transformer",
104
+ "php-toolkit": "runtime-library",
105
+ jetpack: "plugin",
106
+ "quickjs-abi": "quickjs-abi"
47
107
  };
48
- const runtimeComponentSourceSchema = z.discriminatedUnion("kind", [
49
- z
50
- .object({
51
- kind: z.literal("archive"),
52
- url: z.string().url(),
53
- bytes: z.number().int().positive(),
108
+ var runtimeComponentSourceSchema = z.discriminatedUnion("kind", [
109
+ z.object({
110
+ kind: z.literal("archive"),
111
+ url: z.string().url(),
112
+ bytes: z.number().int().positive()
113
+ }).strict(),
114
+ z.object({
115
+ kind: z.literal("embedded"),
116
+ path: z.string().min(1).max(512).refine((path) => !path.startsWith("/") && !path.split("/").includes(".."), {
117
+ message: "embedded component paths must be relative and cannot traverse"
54
118
  })
55
- .strict(),
56
- z
57
- .object({
58
- kind: z.literal("embedded"),
59
- path: z
60
- .string()
61
- .min(1)
62
- .max(512)
63
- .refine((path) => !path.startsWith("/") && !path.split("/").includes(".."), {
64
- message: "embedded component paths must be relative and cannot traverse",
65
- }),
66
- })
67
- .strict(),
119
+ }).strict(),
120
+ // The provider owns the bytes: wp.cloud installs and updates this component
121
+ // from its own managed build, so the lock pins the software lane it may come
122
+ // from and readiness is proven by observation instead of a byte digest.
123
+ z.object({
124
+ kind: z.literal("provider-managed"),
125
+ software: z.string().min(1).max(255)
126
+ }).strict()
68
127
  ]);
69
- export const runtimeComponentV1Schema = z
70
- .object({
71
- id: runtimeComponentIdSchema,
72
- kind: runtimeComponentKindSchema,
73
- version: z.string().min(1).max(160),
74
- sha256: contentProgramSha256Schema,
75
- source: runtimeComponentSourceSchema,
76
- provides: z.array(runtimeCapabilityIdSchema).max(100),
77
- activation: z.enum(["always", "on-demand"]),
78
- })
79
- .strict()
80
- .refine((component) => new Set(component.provides).size === component.provides.length, {
81
- path: ["provides"],
82
- message: "provided capabilities must be unique",
83
- });
84
- export const runtimeComponentInventoryV1Schema = z
85
- .object({
86
- format: z.literal("spacefast.wordpress-components"),
87
- version: z.literal(1),
88
- platformRelease: z.string().min(1).max(160),
89
- digest: contentProgramSha256Schema,
90
- components: z.array(runtimeComponentV1Schema).min(1).max(100),
91
- })
92
- .strict()
93
- .superRefine((inventory, context) => {
94
- const ids = inventory.components.map((component) => component.id);
95
- if (new Set(ids).size !== ids.length) {
96
- context.addIssue({
97
- code: "custom",
98
- path: ["components"],
99
- message: "component ids must be unique",
100
- });
101
- }
102
- for (const required of RUNTIME_COMPONENT_V1_REQUIRED_IDS) {
103
- const matching = inventory.components.filter((component) => component.id === required);
104
- if (matching.length !== 1) {
105
- context.addIssue({
106
- code: "custom",
107
- path: ["components"],
108
- message: `component inventory requires exactly one ${required} component`,
109
- });
110
- }
111
- else if (matching[0]?.kind !== runtimeComponentV1RequiredKinds[required]) {
112
- context.addIssue({
113
- code: "custom",
114
- path: ["components"],
115
- message: `${required} must use component kind ${runtimeComponentV1RequiredKinds[required]}`,
116
- });
117
- }
128
+ var runtimeComponentV1Schema = z.object({
129
+ id: runtimeComponentIdSchema,
130
+ kind: runtimeComponentKindSchema,
131
+ version: z.string().min(1).max(160),
132
+ sha256: contentModelSha256Schema,
133
+ source: runtimeComponentSourceSchema,
134
+ installedArtifact: z.object({
135
+ path: z.string().min(1).max(512).refine((path) => !path.startsWith("/") && !path.split("/").includes(".."), {
136
+ message: "installed component paths must be relative and cannot traverse"
137
+ }),
138
+ sha256: contentModelSha256Schema
139
+ }).strict().optional(),
140
+ provides: z.array(runtimeCapabilityIdSchema).max(100),
141
+ activation: z.enum(["always", "installed", "on-demand"])
142
+ }).strict().refine((component) => new Set(component.provides).size === component.provides.length, {
143
+ path: ["provides"],
144
+ message: "provided capabilities must be unique"
145
+ }).refine(
146
+ (component) => component.activation === "installed" === (component.installedArtifact !== void 0),
147
+ {
148
+ path: ["installedArtifact"],
149
+ message: "installed activation requires exactly one installed artifact receipt"
150
+ }
151
+ ).refine(
152
+ (component) => component.activation !== "installed" || component.source.kind === "archive",
153
+ {
154
+ path: ["source"],
155
+ message: "installed components must come from a pinned archive"
156
+ }
157
+ );
158
+ var runtimeComponentInventoryV1Schema = z.object({
159
+ format: z.literal("spacefast.wordpress-components"),
160
+ version: z.literal(1),
161
+ platformRelease: z.string().min(1).max(160),
162
+ digest: contentModelSha256Schema,
163
+ components: z.array(runtimeComponentV1Schema).min(1).max(100)
164
+ }).strict().superRefine((inventory, context) => {
165
+ const ids = inventory.components.map((component) => component.id);
166
+ if (new Set(ids).size !== ids.length) {
167
+ context.addIssue({
168
+ code: "custom",
169
+ path: ["components"],
170
+ message: "component ids must be unique"
171
+ });
172
+ }
173
+ for (const required of RUNTIME_COMPONENT_V1_REQUIRED_IDS) {
174
+ const matching = inventory.components.filter((component) => component.id === required);
175
+ if (matching.length !== 1) {
176
+ context.addIssue({
177
+ code: "custom",
178
+ path: ["components"],
179
+ message: `component inventory requires exactly one ${required} component`
180
+ });
181
+ } else if (matching[0]?.kind !== runtimeComponentV1RequiredKinds[required]) {
182
+ context.addIssue({
183
+ code: "custom",
184
+ path: ["components"],
185
+ message: `${required} must use component kind ${runtimeComponentV1RequiredKinds[required]}`
186
+ });
118
187
  }
188
+ }
119
189
  });
120
- export const programRequirementsV1Schema = z
121
- .object({
122
- format: z.literal("spacefast.program-requirements"),
123
- version: z.literal(1),
124
- inputDigest: contentProgramSha256Schema,
125
- wordpressAbi: z.literal(1),
126
- capabilities: z.array(runtimeCapabilityIdSchema).max(100),
127
- })
128
- .strict()
129
- .refine((requirements) => new Set(requirements.capabilities).size === requirements.capabilities.length, {
190
+ var contentModelRequirementsV1Schema = z.object({
191
+ format: z.literal("spacefast.content-model-requirements"),
192
+ version: z.literal(1),
193
+ inputDigest: contentModelSha256Schema,
194
+ wordpressAbi: z.literal(1),
195
+ capabilities: z.array(runtimeCapabilityIdSchema).max(100)
196
+ }).strict().refine(
197
+ (requirements) => new Set(requirements.capabilities).size === requirements.capabilities.length,
198
+ {
130
199
  path: ["capabilities"],
131
- message: "program capabilities must be unique",
132
- });
133
- export const runtimeComponentPlacementTargetV1Schema = z
134
- .object({
135
- spaceId: registeredIdSchema("spc"),
136
- runtimeInstanceId: z.string().min(1).max(255),
137
- siteId: z.string().min(1).max(255),
138
- })
139
- .strict();
140
- const runtimeComponentPlacementReceiptFields = {
141
- format: z.literal("spacefast.component-placement"),
142
- version: z.literal(1),
143
- operationId: z.string().min(1).max(160),
144
- target: runtimeComponentPlacementTargetV1Schema,
145
- platformRelease: z.string().min(1).max(160),
146
- expectedInventoryDigest: contentProgramSha256Schema,
200
+ message: "content model capabilities must be unique"
201
+ }
202
+ );
203
+ var compiledContentModelArtifactsV1Schema = z.object({
204
+ compiled: compiledContentModelV1Schema,
205
+ model: contentModelReleaseV1Schema,
206
+ executables: contentExecutableSetV1Schema,
207
+ sdk: contentSdkDescriptorSetV1Schema,
208
+ routes: contentRouteContributionSetV1Schema,
209
+ requirements: contentModelRequirementsV1Schema
210
+ }).strict();
211
+ var runtimeComponentPlacementTargetV1Schema = z.object({
212
+ spaceId: prefixedIdSchema("spc", "Space"),
213
+ runtimeInstanceId: z.string().min(1).max(255),
214
+ siteId: z.string().min(1).max(255)
215
+ }).strict();
216
+ var runtimeComponentPoolPlacementTargetV1Schema = z.object({
217
+ sitePoolId: prefixedIdSchema("site", "Site"),
218
+ runtimeInstanceId: z.string().min(1).max(255),
219
+ siteId: z.string().min(1).max(255)
220
+ }).strict();
221
+ var runtimeComponentReceiptTargetV1Schema = z.union([
222
+ runtimeComponentPlacementTargetV1Schema,
223
+ runtimeComponentPoolPlacementTargetV1Schema
224
+ ]);
225
+ var runtimeComponentPlacementReceiptFields = {
226
+ format: z.literal("spacefast.component-placement"),
227
+ version: z.literal(1),
228
+ operationId: z.string().min(1).max(160),
229
+ target: runtimeComponentReceiptTargetV1Schema,
230
+ platformRelease: z.string().min(1).max(160),
231
+ expectedInventoryDigest: contentModelSha256Schema
147
232
  };
148
- const readyPlacementSubstrateV1Schema = z
149
- .object({
150
- wordpress: z
151
- .object({
152
- boot: z.literal("ready"),
153
- database: z.literal("ready"),
154
- tables: z.literal("ready"),
155
- })
156
- .strict(),
157
- routing: z
158
- .object({
159
- state: z.literal("ready"),
160
- snapshotRevision: contentProgramSha256Schema,
161
- inventoryDigest: contentProgramSha256Schema,
162
- })
163
- .strict(),
164
- mail: z.object({ state: z.literal("ready") }).strict(),
165
- journal: z.object({ state: z.literal("ready") }).strict(),
166
- })
167
- .strict();
168
- export const runtimeComponentPlacementReceiptV1Schema = z
169
- .discriminatedUnion("status", [
170
- z
171
- .object({
172
- ...runtimeComponentPlacementReceiptFields,
173
- status: z.literal("ready"),
174
- observedInventoryDigest: contentProgramSha256Schema,
175
- substrate: readyPlacementSubstrateV1Schema,
176
- })
177
- .strict(),
178
- z
179
- .object({
180
- ...runtimeComponentPlacementReceiptFields,
181
- status: z.literal("blocked"),
182
- problems: z
183
- .array(z
184
- .object({
185
- componentId: runtimeComponentIdSchema.optional(),
186
- code: z.string().min(1).max(160),
187
- detail: z.string().min(1).max(2_000),
188
- })
189
- .strict())
190
- .min(1)
191
- .max(100),
192
- })
193
- .strict(),
194
- ])
195
- .refine((receipt) => receipt.status !== "ready" ||
196
- receipt.observedInventoryDigest === receipt.expectedInventoryDigest, {
233
+ var readyPlacementSubstrateV1Schema = z.object({
234
+ wordpress: z.object({
235
+ boot: z.literal("ready"),
236
+ database: z.literal("ready"),
237
+ tables: z.literal("ready")
238
+ }).strict(),
239
+ routing: z.object({
240
+ state: z.literal("ready"),
241
+ snapshotRevision: contentModelSha256Schema,
242
+ inventoryDigest: contentModelSha256Schema
243
+ }).strict(),
244
+ mail: z.object({ state: z.literal("ready") }).strict(),
245
+ journal: z.object({ state: z.literal("ready") }).strict(),
246
+ // Which `on-demand` components the box actually runs. Always components are
247
+ // covered by the inventory digest; these are not installed everywhere, so
248
+ // the receipt reports what is there and the control plane decides whether
249
+ // that matches what it has converged.
250
+ onDemandActive: z.array(runtimeComponentIdSchema).max(20)
251
+ }).strict();
252
+ var runtimeComponentPlacementReceiptV1Schema = z.discriminatedUnion("status", [
253
+ z.object({
254
+ ...runtimeComponentPlacementReceiptFields,
255
+ status: z.literal("ready"),
256
+ observedInventoryDigest: contentModelSha256Schema,
257
+ substrate: readyPlacementSubstrateV1Schema
258
+ }).strict(),
259
+ z.object({
260
+ ...runtimeComponentPlacementReceiptFields,
261
+ status: z.literal("blocked"),
262
+ // A pre-receipt Space has no control-plane routing baseline yet. New
263
+ // engines return the routing they observed so that one guarded retry
264
+ // can bind the first receipt without pretending the route set is
265
+ // empty. Optional keeps the control plane compatible with engines
266
+ // published before this adoption field existed.
267
+ observedRouting: z.object({
268
+ snapshotRevision: contentModelSha256Schema,
269
+ inventoryDigest: contentModelSha256Schema
270
+ }).strict().optional(),
271
+ problems: z.array(
272
+ z.object({
273
+ componentId: runtimeComponentIdSchema.optional(),
274
+ code: z.string().min(1).max(160),
275
+ detail: z.string().min(1).max(2e3)
276
+ }).strict()
277
+ ).min(1).max(100)
278
+ }).strict()
279
+ ]).refine(
280
+ (receipt) => receipt.status !== "ready" || receipt.observedInventoryDigest === receipt.expectedInventoryDigest,
281
+ {
197
282
  path: ["observedInventoryDigest"],
198
- message: "a ready receipt must observe the expected inventory digest",
199
- });
283
+ message: "a ready receipt must observe the expected inventory digest"
284
+ }
285
+ );
286
+ var runtimeComponentStageRequestV1Schema = z.object({
287
+ format: z.literal("spacefast.component-stage"),
288
+ version: z.literal(1),
289
+ operationId: z.string().min(1).max(160),
290
+ target: runtimeComponentPlacementReceiptFields.target,
291
+ expectedInventoryDigest: contentModelSha256Schema,
292
+ routing: z.object({
293
+ snapshotRevision: contentModelSha256Schema,
294
+ inventoryDigest: contentModelSha256Schema
295
+ }).strict()
296
+ }).strict();
297
+ export {
298
+ JETPACK_RUNTIME_COMPONENT_ID,
299
+ RUNTIME_ACCESS_BROWSER_STATE_CAPABILITY,
300
+ RUNTIME_COMPONENT_KINDS,
301
+ RUNTIME_COMPONENT_V1_REQUIRED_IDS,
302
+ SPACEFAST_WORDPRESS_COMPONENT_RELEASE,
303
+ compiledContentModelArtifactsV1Schema,
304
+ contentModelRequirementsV1Schema,
305
+ runtimeCapabilityIdSchema,
306
+ runtimeComponentIdSchema,
307
+ runtimeComponentInventoryV1Schema,
308
+ runtimeComponentKindSchema,
309
+ runtimeComponentPlacementReceiptV1Schema,
310
+ runtimeComponentPlacementTargetV1Schema,
311
+ runtimeComponentPoolPlacementTargetV1Schema,
312
+ runtimeComponentReceiptTargetV1Schema,
313
+ runtimeComponentStageRequestV1Schema,
314
+ runtimeComponentV1Schema
315
+ };
@@ -1,3 +1,18 @@
1
+ import { type ConnectorCallState, type ConnectorRun, type ConnectorJsonValue } from "./connectors.js";
2
+ export type ConnectorToolProxy = {
3
+ (args?: Record<string, ConnectorJsonValue>): Promise<ConnectorJsonValue | null>;
4
+ [tool: string]: ConnectorToolProxy;
5
+ };
6
+ export type Connectors = Record<string, ConnectorToolProxy> & {
7
+ call(role: string, tool: string, args: Record<string, ConnectorJsonValue>, handler?: {
8
+ name: string;
9
+ mode: "read" | "write";
10
+ callIndex?: number;
11
+ }): Promise<{
12
+ state: ConnectorCallState;
13
+ run?: ConnectorRun;
14
+ }>;
15
+ };
1
16
  /**
2
17
  * Platform services that tenant code reaches through the runtime rather than
3
18
  * through a credential of its own: Gravatar, spam checking, and mail.
@@ -1,3 +1,4 @@
1
+ import { CONNECTOR_CALL_STATE_COPY, } from "./connectors.js";
1
2
  /**
2
3
  * Platform services that tenant code reaches through the runtime rather than
3
4
  * through a credential of its own: Gravatar, spam checking, and mail.
@@ -77,6 +78,28 @@ export const SPAM_CONTENT_TYPES = [
77
78
  * one tier and a string on the other.
78
79
  */
79
80
  export const RUNTIME_SERVICE_CLIENT_SOURCE = String.raw `
81
+ class ConnectorCallError extends Error {
82
+ constructor(state) { super(state.message); this.name = "ConnectorCallError"; this.state = state; }
83
+ }
84
+
85
+ const CONNECTOR_STATE_COPY = ${JSON.stringify(CONNECTOR_CALL_STATE_COPY)};
86
+
87
+ function makeConnectorProxy(call, handler) {
88
+ let callIndex = 0;
89
+ const tool = (role, path) => new Proxy(async (args = {}) => {
90
+ let answer;
91
+ try { answer = await call(role, path.join("."), args, { ...handler, callIndex: callIndex++ }); }
92
+ catch (error) {
93
+ const code = ["connector_write_in_read_handler", "connector_forbidden", "service_capability_denied"].includes(error?.code) ? "forbidden" : "unavailable";
94
+ throw new ConnectorCallError({ code, role, message: CONNECTOR_STATE_COPY[code] });
95
+ }
96
+ if (answer.state.code !== "ok") throw new ConnectorCallError({ ...answer.state, role });
97
+ return answer.run?.result ?? null;
98
+ }, { get: (_, name) => name === "then" ? undefined : typeof name === "string" ? tool(role, [...path, name]) : undefined });
99
+ return new Proxy({ call }, { get: (target, role) => role === "call" ? target.call : typeof role === "string" && role !== "then" ? tool(role, []) : undefined });
100
+ }
101
+
102
+
80
103
  const SERVICE_DEFAULTS = ${JSON.stringify(GRAVATAR_DEFAULTS)};
81
104
  const SERVICE_RATINGS = ${JSON.stringify(GRAVATAR_RATINGS)};
82
105
  const SPAM_TYPES = ${JSON.stringify(SPAM_CONTENT_TYPES)};
@@ -409,6 +432,8 @@ function makeEmail(call) {
409
432
 
410
433
  function makeRuntimeServices(call, requestContext) {
411
434
  return {
435
+ connectors: makeConnectorProxy((role, tool, args, handler) =>
436
+ call("connectors", "call", { role, tool, args, handler })),
412
437
  gravatar: makeGravatar(call),
413
438
  spam: makeSpam(call, requestContext),
414
439
  email: makeEmail(call),
@@ -18,10 +18,19 @@ export declare const runtimeStorageListQuerySchema: z.ZodObject<{
18
18
  cursor: z.ZodOptional<z.ZodString>;
19
19
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
20
20
  }, z.core.$strict>;
21
+ /**
22
+ * The uploader's own name for an object: presentation only, never a path.
23
+ *
24
+ * The id is the identity — this is what a person reads in a list and what a
25
+ * download is saved as. Separators are refused rather than stripped so the
26
+ * value the caller sent is the value that comes back.
27
+ */
28
+ export declare const runtimeStorageFilenameSchema: z.ZodString;
21
29
  export declare const runtimeStorageObjectSchema: z.ZodObject<{
22
30
  id: z.ZodString;
23
31
  contentType: z.ZodString;
24
32
  createdAt: z.ZodString;
33
+ filename: z.ZodOptional<z.ZodString>;
25
34
  size: z.ZodNumber;
26
35
  uploaderId: z.ZodString;
27
36
  sha256: z.ZodString;
@@ -33,6 +42,7 @@ export declare const runtimeStorageListResponseSchema: z.ZodObject<{
33
42
  id: z.ZodString;
34
43
  contentType: z.ZodString;
35
44
  createdAt: z.ZodString;
45
+ filename: z.ZodOptional<z.ZodString>;
36
46
  size: z.ZodNumber;
37
47
  uploaderId: z.ZodString;
38
48
  sha256: z.ZodString;
@@ -42,11 +52,33 @@ export declare const runtimeStorageListResponseSchema: z.ZodObject<{
42
52
  hasMore: z.ZodBoolean;
43
53
  }, z.core.$strict>;
44
54
  export type RuntimeStorageListResponse = z.infer<typeof runtimeStorageListResponseSchema>;
55
+ /**
56
+ * The upload's metadata rides the URL because the body is the file.
57
+ *
58
+ * `contentType` comes from the request's own `Content-Type`, which is where a
59
+ * raw-body upload already states it; only the name has nowhere else to go.
60
+ */
61
+ export declare const runtimeStorageUploadQuerySchema: z.ZodObject<{
62
+ filename: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strict>;
64
+ export declare const runtimeStorageUploadPublicResponseSchema: z.ZodObject<{
65
+ data: z.ZodObject<{
66
+ id: z.ZodString;
67
+ contentType: z.ZodString;
68
+ createdAt: z.ZodString;
69
+ filename: z.ZodOptional<z.ZodString>;
70
+ size: z.ZodNumber;
71
+ uploaderId: z.ZodString;
72
+ sha256: z.ZodString;
73
+ url: z.ZodString;
74
+ }, z.core.$strict>;
75
+ }, z.core.$strip>;
45
76
  export declare const runtimeStorageListPublicResponseSchema: z.ZodObject<{
46
77
  data: z.ZodArray<z.ZodObject<{
47
78
  id: z.ZodString;
48
79
  contentType: z.ZodString;
49
80
  createdAt: z.ZodString;
81
+ filename: z.ZodOptional<z.ZodString>;
50
82
  size: z.ZodNumber;
51
83
  uploaderId: z.ZodString;
52
84
  sha256: z.ZodString;