@defrex/autobuild 0.8.0 → 0.10.0

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 (182) hide show
  1. package/README.md +1 -1
  2. package/SPEC.md +323 -26
  3. package/bin/ab-build-runner.ts +8 -2
  4. package/docs/architecture.md +166 -14
  5. package/docs/assets/headline-wide.png +0 -0
  6. package/docs/configuration.md +175 -28
  7. package/docs/hosted-dispatcher.md +69 -13
  8. package/docs/operator-api.md +2 -2
  9. package/docs/remote-store-protocol.md +204 -16
  10. package/docs/remote-ticket-protocol.md +1 -1
  11. package/docs/setup.md +12 -9
  12. package/docs/website.md +14 -0
  13. package/package.json +45 -23
  14. package/packages/core/src/cli/artifact.ts +130 -6
  15. package/packages/core/src/cli/binary.ts +9 -1
  16. package/packages/core/src/cli/build-control.ts +110 -13
  17. package/packages/core/src/cli/context.ts +46 -0
  18. package/packages/core/src/cli/dashboard/facts.ts +215 -0
  19. package/packages/core/src/cli/dashboard/frame-parse.ts +223 -0
  20. package/packages/core/src/cli/dashboard/model.ts +141 -153
  21. package/packages/core/src/cli/dashboard/poll.ts +76 -12
  22. package/packages/core/src/cli/dashboard/render.ts +34 -5
  23. package/packages/core/src/cli/dispatch-frontend.ts +54 -5
  24. package/packages/core/src/cli/dispatch-process.ts +1 -13
  25. package/packages/core/src/cli/dispatch.ts +392 -75
  26. package/packages/core/src/cli/harvest.ts +122 -8
  27. package/packages/core/src/cli/help.ts +62 -9
  28. package/packages/core/src/cli/init-readiness-remote.ts +110 -0
  29. package/packages/core/src/cli/init-readiness-shared.ts +72 -0
  30. package/packages/core/src/cli/init-validation.ts +266 -222
  31. package/packages/core/src/cli/installation.ts +50 -8
  32. package/packages/core/src/cli/main.ts +70 -11
  33. package/packages/core/src/cli/mcp.ts +23 -1
  34. package/packages/core/src/cli/plugin.ts +7 -4
  35. package/packages/core/src/cli/remote-poll.ts +277 -0
  36. package/packages/core/src/cli/repo-state.ts +22 -0
  37. package/packages/core/src/cli/repository-status.ts +39 -1
  38. package/packages/core/src/cli/self-update.ts +77 -2
  39. package/packages/core/src/cli/status.ts +150 -28
  40. package/packages/core/src/cli/terminals.ts +2 -1
  41. package/packages/core/src/cli/ticket-assets.ts +247 -0
  42. package/packages/core/src/cli/ticket.ts +453 -8
  43. package/packages/core/src/cli/wait.ts +157 -41
  44. package/packages/core/src/cli/watch.ts +138 -168
  45. package/packages/core/src/config/live.ts +23 -0
  46. package/packages/core/src/config/pipeline-source.ts +388 -0
  47. package/packages/core/src/config/schema.ts +251 -19
  48. package/packages/core/src/events/catalog.ts +1 -0
  49. package/packages/core/src/events/globs.ts +47 -0
  50. package/packages/core/src/events/payloads.ts +52 -2
  51. package/packages/core/src/events/repository.ts +52 -1
  52. package/packages/core/src/events/sessions.ts +69 -10
  53. package/packages/core/src/events/workspace-remote.ts +12 -0
  54. package/packages/core/src/integration/harness.ts +115 -2
  55. package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +1369 -0
  56. package/packages/core/src/kernel/auto-merge-default.ts +157 -0
  57. package/packages/core/src/kernel/auto-merge.ts +99 -22
  58. package/packages/core/src/kernel/dispatch-settings.ts +42 -17
  59. package/packages/core/src/kernel/dispatch-status.ts +23 -0
  60. package/packages/core/src/kernel/engine.ts +9 -438
  61. package/packages/core/src/kernel/generators/build-log.ts +259 -0
  62. package/packages/core/src/kernel/generators/repository-journals.ts +206 -0
  63. package/packages/core/src/kernel/generators/session-log.ts +72 -0
  64. package/packages/core/src/kernel/harvest.ts +62 -18
  65. package/packages/core/src/kernel/incremental-contract.ts +75 -0
  66. package/packages/core/src/kernel/incremental-fixtures.ts +211 -0
  67. package/packages/core/src/kernel/incremental.ts +53 -0
  68. package/packages/core/src/kernel/log-index.ts +620 -0
  69. package/packages/core/src/kernel/phases.ts +16 -2
  70. package/packages/core/src/kernel/pr-attachments.ts +164 -46
  71. package/packages/core/src/kernel/reducer-registry.ts +164 -0
  72. package/packages/core/src/kernel/reducer.ts +254 -73
  73. package/packages/core/src/operator/annotations.ts +6 -0
  74. package/packages/core/src/operator/control.ts +19 -5
  75. package/packages/core/src/operator/index.ts +71 -6
  76. package/packages/core/src/operator/query.ts +253 -24
  77. package/packages/core/src/operator/read-view.ts +98 -0
  78. package/packages/core/src/operator/registry.ts +55 -10
  79. package/packages/core/src/operator/requests.ts +9 -6
  80. package/packages/core/src/operator/sandbox-host.ts +140 -0
  81. package/packages/core/src/operator/sandbox.ts +247 -14
  82. package/packages/core/src/operator/ticket-source-backend.ts +47 -0
  83. package/packages/core/src/orchestrator/approvals.ts +115 -0
  84. package/packages/core/src/orchestrator/conversation.ts +167 -0
  85. package/packages/core/src/orchestrator/model.ts +86 -0
  86. package/packages/core/src/orchestrator/prompt.ts +61 -0
  87. package/packages/core/src/orchestrator/tools.ts +117 -0
  88. package/packages/core/src/orchestrator/turn-runner.ts +457 -0
  89. package/packages/core/src/plugin-sdk/index.ts +51 -1
  90. package/packages/core/src/plugins/load.ts +135 -7
  91. package/packages/core/src/plugins/manifest.ts +183 -10
  92. package/packages/core/src/plugins/registry.ts +73 -4
  93. package/packages/core/src/ports/forge/create.ts +1 -1
  94. package/packages/core/src/ports/forge/fake.ts +31 -0
  95. package/packages/core/src/ports/forge/github-transport.ts +13 -2
  96. package/packages/core/src/ports/forge/github.ts +13 -2
  97. package/packages/core/src/ports/forge/local-git.ts +31 -1
  98. package/packages/core/src/ports/runner/claude.ts +2 -2
  99. package/packages/core/src/ports/runner/codex.ts +6 -2
  100. package/packages/core/src/ports/runner/fake.ts +7 -1
  101. package/packages/core/src/ports/runner/pi.ts +8 -6
  102. package/packages/core/src/ports/runner/provider-error.ts +13 -3
  103. package/packages/core/src/ports/tickets/fake.ts +5 -1
  104. package/packages/core/src/ports/tickets/file.ts +169 -48
  105. package/packages/core/src/ports/tickets/{remote-index.ts → hosted-index.ts} +3 -2
  106. package/packages/core/src/ports/tickets/linear.ts +33 -1
  107. package/packages/core/src/ports/tickets/operations.ts +1 -1
  108. package/packages/core/src/ports/tickets/remote.ts +8 -1
  109. package/packages/core/src/ports/types.ts +49 -3
  110. package/packages/core/src/ports/workspace/builtin-capabilities.ts +114 -0
  111. package/packages/core/src/ports/workspace/create.ts +74 -39
  112. package/packages/core/src/ports/workspace/distribution-archive.ts +171 -12
  113. package/packages/core/src/ports/workspace/fake.ts +169 -4
  114. package/packages/core/src/ports/workspace/git-worktree.ts +246 -26
  115. package/packages/core/src/ports/workspace/github-origin.ts +36 -0
  116. package/packages/core/src/ports/workspace/operator-sandbox.ts +7 -1
  117. package/packages/core/src/ports/workspace/provider-capabilities.ts +171 -0
  118. package/packages/core/src/ports/workspace/vercel-capabilities.ts +110 -0
  119. package/packages/core/src/ports/workspace/vercel-sandbox.ts +142 -114
  120. package/packages/core/src/processes/build-child.ts +17 -2
  121. package/packages/core/src/processes/build-execution-state.ts +68 -15
  122. package/packages/core/src/processes/build-runner.ts +238 -93
  123. package/packages/core/src/processes/dispatcher-selectors.ts +123 -0
  124. package/packages/core/src/processes/dispatcher.ts +501 -201
  125. package/packages/core/src/processes/execution-settlement.ts +72 -39
  126. package/packages/core/src/processes/harvest-child.ts +5 -0
  127. package/packages/core/src/processes/harvest-execution-state.ts +41 -29
  128. package/packages/core/src/processes/harvest-runner.ts +66 -19
  129. package/packages/core/src/processes/harvest.ts +196 -24
  130. package/packages/core/src/processes/infrastructure-failure-budget.ts +31 -18
  131. package/packages/core/src/processes/orchestrator-tick.ts +360 -0
  132. package/packages/core/src/processes/publication-state.ts +164 -52
  133. package/packages/core/src/processes/repo-view.ts +1436 -0
  134. package/packages/core/src/processes/sandbox-state.ts +36 -2
  135. package/packages/core/src/processes/tick-state.ts +33 -0
  136. package/packages/core/src/store/adapter.ts +41 -0
  137. package/packages/core/src/store/build-scope.ts +90 -0
  138. package/packages/core/src/store/contract.ts +1205 -0
  139. package/packages/core/src/store/digest.ts +102 -0
  140. package/packages/core/src/store/local/schema.ts +46 -2
  141. package/packages/core/src/store/local/store.ts +445 -4
  142. package/packages/core/src/store/memory.ts +246 -0
  143. package/packages/core/src/store/new-build.ts +17 -0
  144. package/packages/core/src/store/phase-session.ts +94 -0
  145. package/packages/core/src/store/remote/client.ts +310 -2
  146. package/packages/core/src/store/remote/index.ts +14 -2
  147. package/packages/core/src/store/remote/protocol.ts +115 -12
  148. package/packages/core/src/store/remote/version.ts +6 -2
  149. package/packages/core/src/store/repo-state-events.ts +205 -0
  150. package/packages/core/src/store/retention.ts +7 -0
  151. package/packages/core/src/store/session-handle.ts +94 -0
  152. package/packages/core/src/{sessions/reducer.ts → store/session-reducer.ts} +79 -19
  153. package/packages/core/src/store/snapshots.ts +88 -0
  154. package/packages/core/src/store/streams/session-writer.ts +42 -2
  155. package/packages/core/src/store/streams/wait.ts +4 -5
  156. package/packages/core/src/store/ticket-assets.ts +458 -0
  157. package/packages/core/src/store/types.ts +160 -1
  158. package/packages/core/src/testing/index.ts +59 -0
  159. package/skills/code-review/SKILL.md +5 -1
  160. package/skills/guide/SKILL.md +152 -40
  161. package/skills/guide/references/operator-api.md +2 -2
  162. package/skills/guide/references/plugin-authoring.md +17 -0
  163. package/skills/guide/references/remote-store-protocol.md +204 -16
  164. package/skills/guide/references/remote-ticket-protocol.md +1 -1
  165. package/skills/guide/references/setup.md +12 -9
  166. package/skills/implement/SKILL.md +3 -0
  167. package/skills/operate/SKILL.md +126 -0
  168. package/skills/plan/SKILL.md +4 -0
  169. package/skills/plan-review/SKILL.md +5 -1
  170. package/skills/spec/SKILL.md +46 -3
  171. package/skills/tickets/SKILL.md +57 -5
  172. package/packages/core/src/cli/dashboard/frame-image.ts +0 -373
  173. package/packages/core/src/cli/store-opening.contract.ts +0 -289
  174. package/packages/core/src/cli/testkit.ts +0 -194
  175. package/packages/core/src/markdown.ts +0 -67
  176. package/packages/core/src/operator/client.ts +0 -311
  177. package/packages/core/src/operator/server.ts +0 -616
  178. package/packages/core/src/operator/sessions.ts +0 -223
  179. package/packages/core/src/ports/runner/live-contract-fixture.ts +0 -176
  180. package/packages/core/src/ports/tickets/remote-server.ts +0 -185
  181. package/packages/core/src/store/remote/server.ts +0 -923
  182. package/packages/core/src/testing/store-failures.ts +0 -32
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Declarative capabilities a workspace-provider registration can supply, plus
3
+ * the readiness contract those capabilities speak. Core honours these
4
+ * declarations at registry-aware seams without naming any provider, which is
5
+ * what lets a third-party remote provider receive the same treatment as the
6
+ * builtin `vercel-sandbox` registration (AUT-516).
7
+ *
8
+ * This module is a leaf: runtime imports are limited to `config/roles`
9
+ * helpers, everything else is types. `config/schema.ts` imports the message
10
+ * builders below, and `builtin-capabilities.ts` imports `config/schema.ts` —
11
+ * so nothing here may import either, or module evaluation would cycle.
12
+ */
13
+ import type { z } from 'zod'
14
+ import { displayName, tomlKey, type RuntimeReferenceGroup } from '../../config/roles'
15
+ import type { Config } from '../../config/schema'
16
+ import type { Exec } from './git-worktree'
17
+
18
+ /** Host-derived effective routes; consumed only by remote providers. */
19
+ export type RuntimeReferencesSource =
20
+ | readonly RuntimeReferenceGroup[]
21
+ | (() => readonly RuntimeReferenceGroup[])
22
+
23
+ export function currentRuntimeReferences(
24
+ source: RuntimeReferencesSource | undefined,
25
+ ): readonly RuntimeReferenceGroup[] {
26
+ if (source === undefined) return []
27
+ return typeof source === 'function' ? source() : source
28
+ }
29
+
30
+ /** The `[workspace.config.runtimeProvisioning]` map of a parsed provider
31
+ * config, `{}` when the provider declares no such table. */
32
+ export function runtimeProvisioningMap(parsedConfig: unknown): Record<string, unknown> {
33
+ if (parsedConfig === null || typeof parsedConfig !== 'object') return {}
34
+ const table = (parsedConfig as { runtimeProvisioning?: unknown }).runtimeProvisioning
35
+ return table !== null && typeof table === 'object' ? (table as Record<string, unknown>) : {}
36
+ }
37
+
38
+ /** Verbatim `configSchema` diagnostic for a referenced runtime with no
39
+ * provisioning entry. Shared by the config parse and the construction seam so
40
+ * the two cannot drift. */
41
+ export function runtimeProvisioningMissingMessage(group: RuntimeReferenceGroup): string {
42
+ return (
43
+ `runtime ${displayName(group.runtime)} is selected by ${group.references.join(', ')} but has no sandbox provisioning; add ` +
44
+ `[workspace.config.runtimeProvisioning.${tomlKey(group.runtime)}] with nonblank install and preflight commands`
45
+ )
46
+ }
47
+
48
+ /** Verbatim credential-free operator-sandbox diagnostic (AUT-340). Shared by
49
+ * the config parse and the construction seam so the two cannot drift. */
50
+ export function sandboxForbiddenEnvMessage(name: string): string {
51
+ return `environment variable ${JSON.stringify(name)} is a store, forge, ticket-provider, model, or Vercel credential and may never be forwarded into an operator sandbox`
52
+ }
53
+
54
+ // ── Readiness contract ───────────────────────────────────────────────────────
55
+
56
+ export interface ReadinessCheck {
57
+ name: string
58
+ status: 'pass' | 'fail' | 'absent'
59
+ detail: string
60
+ }
61
+
62
+ export interface InitValidationReport {
63
+ provider: string
64
+ context: 'local worktree' | 'Vercel Sandbox'
65
+ workspace?: string
66
+ revision?: string
67
+ checks: ReadinessCheck[]
68
+ exitCode: number
69
+ /** Vercel only: automatic snapshots deleted while releasing the disposable
70
+ * environment; zero proves no snapshot storage was left behind. */
71
+ snapshotsDeleted?: number
72
+ }
73
+
74
+ export interface GuestProbeReport {
75
+ checks: ReadinessCheck[]
76
+ }
77
+
78
+ // ── Capability declarations ──────────────────────────────────────────────────
79
+
80
+ /** One required-environment group: alternatives are tried in order, and one
81
+ * is satisfied when EVERY named variable in it is set nonempty. The group must
82
+ * carry at least one message — a group with neither `dispatchMessage` nor
83
+ * `validationMessage` is rejected at manifest parse (AUT-554), because both
84
+ * enforcement sites skip it and the declaration would never be enforced. */
85
+ export interface WorkspaceProviderEnvRequirement {
86
+ alternatives: readonly (readonly string[])[]
87
+ /** Verbatim dispatch-preflight text (`cli/dispatch.ts`). */
88
+ dispatchMessage?: string
89
+ /** Verbatim init-preflight text (`validateInitReadiness`'s hostPreflight). */
90
+ validationMessage?: string
91
+ }
92
+
93
+ /**
94
+ * Everything a workspace-provider registration can declare about its own
95
+ * behavior, so core can enforce it without naming the provider. Field texts
96
+ * are verbatim today's messages; a capability absent means "no check".
97
+ */
98
+ export interface WorkspaceProviderCapabilities {
99
+ /** Strict schema applied to `[workspace.config]`. Mutually exclusive with
100
+ * `configRefusal`. */
101
+ configSchema?: z.ZodType
102
+ /** Construction-site refusal (`createWorkspaceProvider`) for a provider
103
+ * that rejects `[workspace.config]` outright. Distinct from the parse-site
104
+ * refusal text, which lives on the builtin config table in
105
+ * `config/schema.ts` — the two strings differ by design. */
106
+ configRefusal?: string
107
+ /** Referenced runtimes must have `[workspace.config.runtimeProvisioning]`
108
+ * entries. */
109
+ requireRuntimeProvisioning?: boolean
110
+ /** Names added to the operator-sandbox forbidden-forwarding set beyond
111
+ * `SANDBOX_FORBIDDEN_ENV`. Enforced at the two registry-aware seams —
112
+ * `createWorkspaceProvider` construction and the registry-aware
113
+ * `validateInitReadiness` check — not at config parse: plugins are not
114
+ * loaded when config is parsed, and no site loads plugins earlier to widen
115
+ * parse-time coverage. The shared `SANDBOX_FORBIDDEN_ENV` names are
116
+ * rejected at parse time for every provider (AUT-536). */
117
+ sandboxForbiddenEnv?: readonly string[]
118
+ supportedForges?: readonly string[]
119
+ /** Verbatim texts; dispatch and init validation emit different sentences. */
120
+ forgeDispatchMessage?: string
121
+ forgeValidationMessage?: string
122
+ requiredEnv?: readonly WorkspaceProviderEnvRequirement[]
123
+ /** Variables that must exist in the launcher process environment, never
124
+ * only in a loaded `.env`. */
125
+ processEnvOnly?: readonly { name: string; message: string }[]
126
+ /** Store requirements for checkout-less providers, with each site's
127
+ * verbatim text. */
128
+ storeRequirements?: {
129
+ constructionMessage: string
130
+ storeRefMessage: string
131
+ storeTokenMessage: string
132
+ }
133
+ /** Validates the git origin URL before dispatch (throws the provider's own
134
+ * message) and returns the normalized origin coordinates. */
135
+ validateOrigin?: (raw: string) => { url: string; host: string; path: string; directory: string }
136
+ originReadFailureMessage?: string
137
+ /** Env names the provider forwards into the guest (readiness redaction). */
138
+ guestEnvNames?: (config: unknown) => readonly string[]
139
+ /** Readiness summary stdout lines printed after the report. The config
140
+ * argument is the `[workspace.config]` parsed with the declared
141
+ * `configSchema`, or the raw `[workspace.config]` table when no schema is
142
+ * declared — mirroring `guestEnvNames`. */
143
+ describeEnvironment?: (
144
+ config: unknown,
145
+ env: Record<string, string | undefined>,
146
+ ) => readonly string[]
147
+ /** Remote readiness validation for `ab init --validate`. */
148
+ validateReadiness?: (ctx: WorkspaceReadinessContext) => Promise<InitValidationReport>
149
+ }
150
+
151
+ /** Everything a readiness implementation reads. `facade` and `packageArchive`
152
+ * are the host's test seams, passed opaquely — the vercel implementation
153
+ * narrows them. */
154
+ export interface WorkspaceReadinessContext {
155
+ config: Config
156
+ /** The `[workspace.config]` parsed with the declared `configSchema`. */
157
+ providerConfig: unknown
158
+ env: Record<string, string | undefined>
159
+ storeRef: string
160
+ storeToken: string
161
+ repo: string
162
+ baseBranch: string
163
+ configBytes: string
164
+ exec: Exec
165
+ redact: (value: unknown) => string
166
+ runtimeReferences: readonly RuntimeReferenceGroup[]
167
+ stdout: (line: string) => void
168
+ signal?: AbortSignal
169
+ facade?: unknown
170
+ packageArchive?: () => Promise<Uint8Array>
171
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * The single shared capability object for the `vercel-sandbox` workspace
3
+ * provider (AUT-517). During the transitional state in which the builtin
4
+ * hosts the provider implementation, both the builtin registration (in
5
+ * `builtin-capabilities.ts`) and the `@defrex/autobuild-vercel-sandbox`
6
+ * plugin reference THIS object, so the two declarations cannot drift: any
7
+ * future divergence is a compile-time split, not a silently duplicated
8
+ * closure.
9
+ *
10
+ * The parse-time subset comes from `BUILTIN_WORKSPACE_PROVIDER_CONFIG` in
11
+ * `config/schema.ts`; the registry-seam behaviors and the closures
12
+ * (`validateOrigin`, `guestEnvNames`, `describeEnvironment`,
13
+ * `validateReadiness`) are assembled here once.
14
+ *
15
+ * Import graph discipline: this module imports `config/schema.ts`,
16
+ * `github-origin.ts`, and `init-readiness-remote.ts`; nothing imports it
17
+ * from `schema.ts`, so no cycle exists.
18
+ */
19
+ import { BUILTIN_WORKSPACE_PROVIDER_CONFIG, type VercelSandboxConfig } from '../../config/schema'
20
+ import { validateRemoteReadiness } from '../../cli/init-readiness-remote'
21
+ import type {
22
+ WorkspaceProviderCapabilities,
23
+ WorkspaceReadinessContext,
24
+ } from './provider-capabilities'
25
+ import { validateVercelGithubOrigin } from './github-origin'
26
+
27
+ /** The parse-time declaration subset from the config table, without the
28
+ * parse-site refusal text (which never belongs on the capability). */
29
+ function pickConfigDeclaration(name: string): WorkspaceProviderCapabilities {
30
+ const declaration = BUILTIN_WORKSPACE_PROVIDER_CONFIG.get(name)
31
+ if (declaration === undefined) return {}
32
+ return {
33
+ ...(declaration.configSchema !== undefined ? { configSchema: declaration.configSchema } : {}),
34
+ ...(declaration.requireRuntimeProvisioning === true
35
+ ? { requireRuntimeProvisioning: true }
36
+ : {}),
37
+ ...(declaration.sandboxForbiddenEnv !== undefined
38
+ ? { sandboxForbiddenEnv: declaration.sandboxForbiddenEnv }
39
+ : {}),
40
+ }
41
+ }
42
+
43
+ export const VERCEL_SANDBOX_CAPABILITIES: WorkspaceProviderCapabilities = {
44
+ // Parse-time subset comes from the config table; the capability carries
45
+ // no configRefusal because the provider accepts [workspace.config]
46
+ // through its schema.
47
+ ...pickConfigDeclaration('vercel-sandbox'),
48
+ supportedForges: ['github'],
49
+ forgeDispatchMessage: 'vercel-sandbox requires the builtin github forge',
50
+ forgeValidationMessage:
51
+ 'vercel-sandbox supports forge = "github" only; configure GitHub publication before validating',
52
+ requiredEnv: [
53
+ {
54
+ alternatives: [['GITHUB_TOKEN'], ['GH_TOKEN']],
55
+ dispatchMessage:
56
+ 'vercel-sandbox publication requires GITHUB_TOKEN or GH_TOKEN in the dispatcher environment',
57
+ validationMessage:
58
+ 'vercel-sandbox publication requires push-capable GITHUB_TOKEN or GH_TOKEN',
59
+ },
60
+ {
61
+ alternatives: [
62
+ ['VERCEL_OIDC_TOKEN'],
63
+ ['VERCEL_TOKEN', 'VERCEL_TEAM_ID', 'VERCEL_PROJECT_ID'],
64
+ ],
65
+ validationMessage:
66
+ 'Vercel authentication requires VERCEL_OIDC_TOKEN or the durable VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID set',
67
+ },
68
+ ],
69
+ processEnvOnly: [
70
+ {
71
+ name: 'VERCEL_OIDC_TOKEN',
72
+ message:
73
+ 'VERCEL_OIDC_TOKEN loaded only from the target .env is unavailable to the Vercel SDK; export it in the launcher environment or configure VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID',
74
+ },
75
+ ],
76
+ storeRequirements: {
77
+ constructionMessage:
78
+ 'vercel-sandbox requires an HTTPS BuildStore and scoped AB_TOKEN authority',
79
+ storeRefMessage: 'vercel-sandbox requires AB_STORE to be an HTTPS URL reachable from Vercel',
80
+ storeTokenMessage: 'vercel-sandbox requires nonempty AB_TOKEN for the hosted Store',
81
+ },
82
+ validateOrigin: validateVercelGithubOrigin,
83
+ originReadFailureMessage: 'vercel-sandbox requires a readable Git origin',
84
+ guestEnvNames: (raw) => {
85
+ const config = raw as VercelSandboxConfig
86
+ return [
87
+ ...config.environmentVariables,
88
+ ...(config.gitUsernameEnv === undefined ? [] : [config.gitUsernameEnv]),
89
+ ...(config.gitPasswordEnv === undefined ? [] : [config.gitPasswordEnv]),
90
+ ]
91
+ },
92
+ describeEnvironment: (raw, env) => {
93
+ const config = raw as VercelSandboxConfig
94
+ return [
95
+ `Vercel auth: ${env.VERCEL_OIDC_TOKEN ? 'OIDC' : 'access token'}; team=${env.VERCEL_TEAM_ID ?? '(linked)'}; project=${env.VERCEL_PROJECT_ID ?? '(linked)'}`,
96
+ `Private clone variables: ${
97
+ config.gitUsernameEnv === undefined
98
+ ? '(public repository)'
99
+ : `${config.gitUsernameEnv}, ${config.gitPasswordEnv}`
100
+ }`,
101
+ `Guest environment variable names: ${config.environmentVariables.join(', ') || '(none)'}`,
102
+ `Runtime provisioning names: ${
103
+ Object.keys(config.runtimeProvisioning ?? {})
104
+ .sort()
105
+ .join(', ') || '(none)'
106
+ }`,
107
+ ]
108
+ },
109
+ validateReadiness: (ctx: WorkspaceReadinessContext) => validateRemoteReadiness(ctx),
110
+ }