@defrex/autobuild 1.1.0 → 1.3.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.
- package/README.md +5 -13
- package/SPEC.md +249 -15
- package/bin/ab-dispatch-generation.ts +11 -2
- package/docs/accounts.md +130 -0
- package/docs/agent-runtimes.md +4 -4
- package/docs/answering-blocked-builds.md +4 -1
- package/docs/architecture.md +224 -12
- package/docs/build-store.md +3 -41
- package/docs/builds.md +2 -0
- package/docs/cli.md +14 -0
- package/docs/configuration-overview.md +117 -0
- package/docs/configuration.md +266 -141
- package/docs/dispatcher-hosting.md +18 -33
- package/docs/intake.md +2 -0
- package/docs/integration-tree.md +16 -5
- package/docs/merge-policy.md +1 -3
- package/docs/operating.md +1 -2
- package/docs/operator-api.md +144 -53
- package/docs/operator-surfaces.md +32 -20
- package/docs/overview.md +1 -1
- package/docs/plugin-authoring.md +27 -1
- package/docs/remote-store-protocol.md +259 -91
- package/docs/remote-ticket-protocol.md +29 -49
- package/docs/restacking.md +45 -0
- package/docs/seams.md +8 -8
- package/docs/setup.md +34 -129
- package/docs/spec-standard.md +4 -2
- package/docs/ticket-dependencies.md +8 -0
- package/docs/ticket-sources.md +18 -0
- package/docs/troubleshooting.md +7 -11
- package/docs/upgrading.md +1 -1
- package/docs/workspaces.md +4 -4
- package/package.json +14 -5
- package/packages/core/src/accounts/chatgpt-oauth.ts +216 -0
- package/packages/core/src/accounts/chatgpt-state.ts +41 -0
- package/packages/core/src/accounts/local-credentials.ts +194 -0
- package/packages/core/src/accounts/local-inference.ts +106 -0
- package/packages/core/src/accounts/local-owner.ts +123 -0
- package/packages/core/src/accounts/sensitive.ts +2 -0
- package/packages/core/src/cli/accounts.ts +147 -0
- package/packages/core/src/cli/binary.ts +3 -1
- package/packages/core/src/cli/connect.ts +3 -3
- package/packages/core/src/cli/dispatch-frontend.ts +1 -0
- package/packages/core/src/cli/dispatch-handoff.ts +125 -44
- package/packages/core/src/cli/dispatch-launch-contract.ts +187 -0
- package/packages/core/src/cli/dispatch-launcher.ts +54 -21
- package/packages/core/src/cli/dispatch-preflight.ts +6 -1
- package/packages/core/src/cli/dispatch-repository-feed.ts +107 -26
- package/packages/core/src/cli/dispatch.ts +135 -27
- package/packages/core/src/cli/dispatcher-liveness.ts +6 -1
- package/packages/core/src/cli/forge-clear.ts +30 -0
- package/packages/core/src/cli/help.ts +17 -0
- package/packages/core/src/cli/init-readiness-remote.ts +22 -1
- package/packages/core/src/cli/init-readiness-shared.ts +5 -1
- package/packages/core/src/cli/init-validation.ts +160 -18
- package/packages/core/src/cli/main.ts +72 -0
- package/packages/core/src/cli/publication-settlement.ts +4 -1
- package/packages/core/src/cli/secrets.ts +173 -0
- package/packages/core/src/cli/store-opening.ts +11 -1
- package/packages/core/src/cli/upgrade-agent.ts +9 -1
- package/packages/core/src/cli/watch.ts +12 -14
- package/packages/core/src/config/accounts.ts +101 -0
- package/packages/core/src/config/live.ts +14 -1
- package/packages/core/src/config/roles.ts +54 -3
- package/packages/core/src/config/schema.ts +60 -0
- package/packages/core/src/events/catalog.ts +1 -0
- package/packages/core/src/events/compatibility.ts +2 -1
- package/packages/core/src/events/forge-degradation-policy.ts +11 -0
- package/packages/core/src/events/payloads.ts +13 -0
- package/packages/core/src/events/policy.ts +9 -0
- package/packages/core/src/events/repository.ts +75 -2
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +278 -0
- package/packages/core/src/kernel/change-presence.ts +74 -8
- package/packages/core/src/kernel/engine.ts +8 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +14 -0
- package/packages/core/src/kernel/node-polling.ts +40 -7
- package/packages/core/src/kernel/node-restack-demand.ts +74 -0
- package/packages/core/src/kernel/node-restack-state.ts +5 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +33 -1
- package/packages/core/src/kernel/read-facts.ts +6 -0
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer.ts +4 -1
- package/packages/core/src/kernel/ticket-preparation.ts +66 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +20 -0
- package/packages/core/src/operator/index.ts +4 -0
- package/packages/core/src/operator/protocol.ts +6 -0
- package/packages/core/src/operator/registry.ts +42 -1
- package/packages/core/src/operator/tickets.ts +25 -4
- package/packages/core/src/plugins/manifest.ts +2 -1
- package/packages/core/src/ports/runner/account-env.ts +139 -0
- package/packages/core/src/ports/runner/chatgpt-provider.ts +85 -0
- package/packages/core/src/ports/runner/claude.ts +70 -42
- package/packages/core/src/ports/runner/codex.ts +63 -31
- package/packages/core/src/ports/runner/one-shot.ts +2 -0
- package/packages/core/src/ports/runner/provider-error.ts +5 -0
- package/packages/core/src/ports/runner/routing.ts +35 -4
- package/packages/core/src/ports/tickets/contract.ts +58 -0
- package/packages/core/src/ports/tickets/tree.ts +1 -1
- package/packages/core/src/ports/types.ts +28 -7
- package/packages/core/src/ports/workspace/account-policy.ts +72 -0
- package/packages/core/src/ports/workspace/build-execution.ts +6 -1
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +6 -1
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +125 -35
- package/packages/core/src/processes/build-runner.ts +32 -1
- package/packages/core/src/processes/dispatcher.ts +493 -121
- package/packages/core/src/processes/execution-no-progress.ts +1 -0
- package/packages/core/src/processes/execution-settlement.ts +21 -3
- package/packages/core/src/processes/harvest-runner.ts +68 -8
- package/packages/core/src/processes/harvest.ts +11 -16
- package/packages/core/src/processes/repo-view.ts +3 -0
- package/packages/core/src/project-secrets.ts +105 -0
- package/packages/core/src/secret-name.ts +41 -0
- package/packages/core/src/store/account-redaction.ts +156 -0
- package/packages/core/src/store/artifact-meta.ts +7 -0
- package/packages/core/src/store/contract.ts +60 -1
- package/packages/core/src/store/memory.ts +4 -0
- package/packages/core/src/store/reducer-value-shapes.json +7389 -6647
- package/packages/core/src/store/reducer-value-validation.ts +106 -6
- package/packages/core/src/store/remote/client.ts +85 -50
- package/packages/core/src/store/remote/compatibility.ts +57 -0
- package/packages/core/src/store/remote/index.ts +6 -0
- package/packages/core/src/store/remote/protocol.ts +8 -1
- package/packages/core/src/store/remote/released-reducer-values/1.2.0.json +8129 -0
- package/packages/core/src/store/remote/version.ts +4 -0
- package/packages/core/src/store/repo-state-events.ts +4 -2
- package/packages/core/src/store/snapshots.ts +16 -3
- package/packages/core/src/store/types.ts +2 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +266 -5
- package/packages/core/src/testing/index.ts +2 -1
- package/packages/core/src/testing/reduced-read-budget.ts +560 -5
- package/skills/guide/SKILL.md +164 -37
- package/skills/guide/references/accounts.md +130 -0
- package/skills/guide/references/integration-tree.md +16 -5
- package/skills/guide/references/merge-policy.md +1 -3
- package/skills/guide/references/operator-api.md +144 -53
- package/skills/guide/references/plugin-authoring.md +27 -1
- package/skills/guide/references/remote-store-protocol.md +259 -91
- package/skills/guide/references/remote-ticket-protocol.md +29 -49
- package/skills/guide/references/restacking.md +45 -0
- package/skills/guide/references/setup.md +34 -129
- package/skills/guide/references/spec-standard.md +4 -2
- package/skills/guide/references/ticket-dependencies.md +8 -0
- package/skills/harvest/SKILL.md +3 -1
- package/skills/harvest-review/SKILL.md +3 -1
- package/skills/operate/SKILL.md +26 -11
- package/skills/reconcile/SKILL.md +6 -0
- package/skills/spec/SKILL.md +1 -1
- package/skills/tickets/SKILL.md +10 -5
- package/templates/hosted-service/package.json +2 -2
- package/docs/hosted-dispatcher-cutover-validation.md +0 -178
- package/docs/hosted-dispatcher.md +0 -278
- package/docs/hosted-service.md +0 -304
- package/docs/mcp.md +0 -150
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { accountPolicy, accountGuestEnvironment } from './account-policy'
|
|
1
2
|
import { gitRewrite, parseRemoteHead } from '../forge/git-rewrite'
|
|
2
3
|
import { delegateCredential } from '../../store/remote/credentials'
|
|
3
4
|
import type { ExecutionLaunchAuth } from './build-execution'
|
|
@@ -741,6 +742,7 @@ async function preflightBun(sandbox: VercelSandboxHandle, image: string): Promis
|
|
|
741
742
|
}
|
|
742
743
|
|
|
743
744
|
export interface VercelReadinessOptions {
|
|
745
|
+
accounts?: import('../../config/accounts').Accounts
|
|
744
746
|
config: VercelSandboxConfig
|
|
745
747
|
env: Record<string, string | undefined>
|
|
746
748
|
storeRef: string
|
|
@@ -838,6 +840,9 @@ export async function validateVercelSandbox(
|
|
|
838
840
|
if (facade.createFresh === undefined) {
|
|
839
841
|
throw new Error('the configured Vercel SDK facade does not support fresh validation sandboxes')
|
|
840
842
|
}
|
|
843
|
+
const readinessAccountPolicy = accountPolicy('allow-all', options.accounts ?? {}, options.env)
|
|
844
|
+
if (readinessAccountPolicy.missing.length)
|
|
845
|
+
throw new Error(`Missing credentials: ${readinessAccountPolicy.missing.join('; ')}`)
|
|
841
846
|
const sandbox = await facade.createFresh({
|
|
842
847
|
source: {
|
|
843
848
|
type: 'git',
|
|
@@ -853,7 +858,7 @@ export async function validateVercelSandbox(
|
|
|
853
858
|
...(config.snapshotExpirationSeconds === undefined
|
|
854
859
|
? {}
|
|
855
860
|
: { snapshotExpiration: config.snapshotExpirationSeconds * 1000 }),
|
|
856
|
-
networkPolicy:
|
|
861
|
+
networkPolicy: readinessAccountPolicy.policy,
|
|
857
862
|
keepLastSnapshots: { count: VERCEL_KEEP_LAST_SNAPSHOTS, deleteEvicted: true },
|
|
858
863
|
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
859
864
|
})
|
|
@@ -930,7 +935,11 @@ export async function validateVercelSandbox(
|
|
|
930
935
|
await bootstrapRuntimes(
|
|
931
936
|
sandbox,
|
|
932
937
|
config,
|
|
933
|
-
|
|
938
|
+
accountGuestEnvironment(
|
|
939
|
+
runtimeEnvironment(config, options.env),
|
|
940
|
+
options.accounts ?? {},
|
|
941
|
+
options.env,
|
|
942
|
+
),
|
|
934
943
|
options.runtimeReferences ?? [],
|
|
935
944
|
true,
|
|
936
945
|
options.signal,
|
|
@@ -944,13 +953,18 @@ export async function validateVercelSandbox(
|
|
|
944
953
|
`PATH=${VERCEL_BUN_BIN_PATH}:$PATH exec ${VERCEL_BUN_EXECUTABLE} ${VERCEL_AUTOBUILD_PATH}/bin/ab-init-probe.ts`,
|
|
945
954
|
],
|
|
946
955
|
cwd: VERCEL_WORKSPACE_PATH,
|
|
947
|
-
env:
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
.
|
|
952
|
-
|
|
953
|
-
|
|
956
|
+
env: {
|
|
957
|
+
...accountGuestEnvironment(
|
|
958
|
+
runtimeEnvironment(config, options.env),
|
|
959
|
+
options.accounts ?? {},
|
|
960
|
+
options.env,
|
|
961
|
+
),
|
|
962
|
+
AB_STORE: options.storeRef,
|
|
963
|
+
AB_TOKEN: options.storeToken,
|
|
964
|
+
...(options.env.AB_CHATGPT_HOSTED_READINESS
|
|
965
|
+
? { AB_CHATGPT_HOSTED_READINESS: options.env.AB_CHATGPT_HOSTED_READINESS }
|
|
966
|
+
: {}),
|
|
967
|
+
},
|
|
954
968
|
}),
|
|
955
969
|
)
|
|
956
970
|
readiness = {
|
|
@@ -1122,6 +1136,7 @@ export interface VercelSandboxProviderOptions {
|
|
|
1122
1136
|
facade?: VercelSandboxFacade
|
|
1123
1137
|
exec?: Exec
|
|
1124
1138
|
packageArchive?: () => Promise<Uint8Array>
|
|
1139
|
+
accounts?: () => import('../../config/accounts').Accounts
|
|
1125
1140
|
runtimeReferences?: RuntimeReferencesSource
|
|
1126
1141
|
/** Checkout-less seam: the repository's HTTPS GitHub origin. Default reads
|
|
1127
1142
|
* `git remote get-url origin` from `repo` on the host. */
|
|
@@ -1168,6 +1183,25 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1168
1183
|
private readonly facade: VercelSandboxFacade
|
|
1169
1184
|
private readonly exec: Exec
|
|
1170
1185
|
private readonly active = new Set<string>()
|
|
1186
|
+
private readonly policyLocks = new Map<string, Promise<void>>()
|
|
1187
|
+
|
|
1188
|
+
private async withPolicyLock<T>(ref: string, action: () => Promise<T>): Promise<T> {
|
|
1189
|
+
const previous = this.policyLocks.get(ref) ?? Promise.resolve()
|
|
1190
|
+
let release!: () => void
|
|
1191
|
+
const held = new Promise<void>((resolve) => {
|
|
1192
|
+
release = resolve
|
|
1193
|
+
})
|
|
1194
|
+
const queued = previous.then(() => held)
|
|
1195
|
+
this.policyLocks.set(ref, queued)
|
|
1196
|
+
await previous
|
|
1197
|
+
try {
|
|
1198
|
+
return await action()
|
|
1199
|
+
} finally {
|
|
1200
|
+
release()
|
|
1201
|
+
if (this.policyLocks.get(ref) === queued) this.policyLocks.delete(ref)
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1171
1205
|
/** A failed stop leaves execution state unknown until a later stop/delete succeeds. */
|
|
1172
1206
|
private readonly uncertain = new Set<string>()
|
|
1173
1207
|
private readonly origins = new Map<string, ReturnType<typeof cleanGithubOrigin>>()
|
|
@@ -1204,11 +1238,13 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1204
1238
|
this.observeWaitMs = options.observeWaitMs ?? VERCEL_OBSERVE_WAIT_MS
|
|
1205
1239
|
this.buildExecution = {
|
|
1206
1240
|
start: (input, auth) => this.start(input, auth),
|
|
1207
|
-
observe: (identity) =>
|
|
1241
|
+
observe: (identity) =>
|
|
1242
|
+
this.withPolicyLock(identity.workspaceRef, () => this.observeExecution(identity)),
|
|
1208
1243
|
}
|
|
1209
1244
|
this.harvestExecution = {
|
|
1210
1245
|
start: (input, auth) => this.startHarvestExecution(input, auth),
|
|
1211
|
-
observe: (identity) =>
|
|
1246
|
+
observe: (identity) =>
|
|
1247
|
+
this.withPolicyLock(identity.workspaceRef, () => this.observeExecution(identity)),
|
|
1212
1248
|
}
|
|
1213
1249
|
this.orchestratorSandbox = {
|
|
1214
1250
|
describe: (input) => this.describeOperatorSandbox(input),
|
|
@@ -1233,9 +1269,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1233
1269
|
}
|
|
1234
1270
|
this.publication = {
|
|
1235
1271
|
rewrite: (input: Parameters<NonNullable<WorkspacePublication['rewrite']>>[0]) =>
|
|
1236
|
-
this.publish(input),
|
|
1272
|
+
this.withPolicyLock(input.ref, () => this.publish(input)),
|
|
1237
1273
|
isPublished: (input: { sha: string; branch: string }) => this.isPublished(input),
|
|
1238
|
-
publish: (input: { ref: string; sha: string; branch: string }) =>
|
|
1274
|
+
publish: (input: { ref: string; sha: string; branch: string }) =>
|
|
1275
|
+
this.withPolicyLock(input.ref, () => this.publish(input)),
|
|
1239
1276
|
}
|
|
1240
1277
|
// The operator-sandbox publication path reuses the SAME capability: its
|
|
1241
1278
|
// publish pushes an exact sha from any sandbox ref, including an operator
|
|
@@ -1353,7 +1390,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1353
1390
|
...(this.options.config.snapshotExpirationSeconds === undefined
|
|
1354
1391
|
? {}
|
|
1355
1392
|
: { snapshotExpiration: this.options.config.snapshotExpirationSeconds * 1000 }),
|
|
1356
|
-
networkPolicy: uploadPackPolicy(origin, readAuth),
|
|
1393
|
+
networkPolicy: this.billingPolicy(uploadPackPolicy(origin, readAuth)),
|
|
1357
1394
|
keepLastSnapshots: { count: VERCEL_KEEP_LAST_SNAPSHOTS, deleteEvicted: true },
|
|
1358
1395
|
signal: this.operationSignal(),
|
|
1359
1396
|
})
|
|
@@ -1400,7 +1437,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1400
1437
|
await bootstrapRuntimes(
|
|
1401
1438
|
sandbox,
|
|
1402
1439
|
this.options.config,
|
|
1403
|
-
{ ...
|
|
1440
|
+
{ ...this.guestEnvironment(), AB_TOKEN: scopedToken },
|
|
1404
1441
|
currentRuntimeReferences(this.options.runtimeReferences),
|
|
1405
1442
|
true,
|
|
1406
1443
|
)
|
|
@@ -1519,6 +1556,21 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1519
1556
|
this.origins.delete(ref)
|
|
1520
1557
|
}
|
|
1521
1558
|
|
|
1559
|
+
private guestEnvironment(): Record<string, string> {
|
|
1560
|
+
return accountGuestEnvironment(
|
|
1561
|
+
runtimeEnvironment(this.options.config, this.options.env),
|
|
1562
|
+
this.options.accounts?.() ?? {},
|
|
1563
|
+
this.options.env,
|
|
1564
|
+
)
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
private billingPolicy(base: NetworkPolicy, ref?: string): NetworkPolicy {
|
|
1568
|
+
if (ref?.startsWith('autobuild-sandbox-')) return base
|
|
1569
|
+
const result = accountPolicy(base, this.options.accounts?.() ?? {}, this.options.env)
|
|
1570
|
+
if (result.missing.length) throw new Error(`Missing credentials: ${result.missing.join('; ')}`)
|
|
1571
|
+
return result.policy
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1522
1574
|
private async normalNetworkPolicy(ref: string): Promise<{
|
|
1523
1575
|
origin: ReturnType<typeof cleanGithubOrigin>
|
|
1524
1576
|
policy: NetworkPolicy
|
|
@@ -1527,11 +1579,14 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1527
1579
|
this.origins.set(ref, origin)
|
|
1528
1580
|
return {
|
|
1529
1581
|
origin,
|
|
1530
|
-
policy:
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1582
|
+
policy: this.billingPolicy(
|
|
1583
|
+
uploadPackPolicy(
|
|
1584
|
+
origin,
|
|
1585
|
+
this.options.config.gitPasswordEnv === undefined
|
|
1586
|
+
? undefined
|
|
1587
|
+
: `Basic ${Buffer.from(`${requireVercelEnvironmentValue(this.options.env, this.options.config.gitUsernameEnv!)}:${requireVercelEnvironmentValue(this.options.env, this.options.config.gitPasswordEnv)}`).toString('base64')}`,
|
|
1588
|
+
),
|
|
1589
|
+
ref,
|
|
1535
1590
|
),
|
|
1536
1591
|
}
|
|
1537
1592
|
}
|
|
@@ -1591,7 +1646,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1591
1646
|
await bootstrapRuntimes(
|
|
1592
1647
|
sandbox,
|
|
1593
1648
|
this.options.config,
|
|
1594
|
-
{ ...
|
|
1649
|
+
{ ...this.guestEnvironment(), AB_TOKEN: scopedToken },
|
|
1595
1650
|
currentRuntimeReferences(this.options.runtimeReferences),
|
|
1596
1651
|
false,
|
|
1597
1652
|
)
|
|
@@ -1604,9 +1659,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1604
1659
|
supervision: { kind: 'environment' },
|
|
1605
1660
|
}),
|
|
1606
1661
|
}
|
|
1607
|
-
|
|
1608
|
-
if (!['AB_TOKEN', 'AB_TICKET_URL', 'AB_TICKET_TOKEN'].includes(name))
|
|
1609
|
-
env[name] = requireVercelEnvironmentValue(this.options.env, name)
|
|
1662
|
+
Object.assign(env, this.guestEnvironment())
|
|
1610
1663
|
const command = (await sandbox.runCommand({
|
|
1611
1664
|
cmd: 'sh',
|
|
1612
1665
|
args: [
|
|
@@ -1814,7 +1867,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1814
1867
|
...(this.options.config.snapshotExpirationSeconds === undefined
|
|
1815
1868
|
? {}
|
|
1816
1869
|
: { snapshotExpiration: this.options.config.snapshotExpirationSeconds * 1000 }),
|
|
1817
|
-
networkPolicy: uploadPackPolicy(origin, readAuth),
|
|
1870
|
+
networkPolicy: this.billingPolicy(uploadPackPolicy(origin, readAuth)),
|
|
1818
1871
|
keepLastSnapshots: { count: VERCEL_KEEP_LAST_SNAPSHOTS, deleteEvicted: true },
|
|
1819
1872
|
signal: this.operationSignal(),
|
|
1820
1873
|
})
|
|
@@ -1855,7 +1908,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1855
1908
|
await bootstrapRuntimes(
|
|
1856
1909
|
sandbox,
|
|
1857
1910
|
this.options.config,
|
|
1858
|
-
{ ...
|
|
1911
|
+
{ ...this.guestEnvironment(), AB_TOKEN: scopedToken },
|
|
1859
1912
|
currentRuntimeReferences(this.options.runtimeReferences),
|
|
1860
1913
|
true,
|
|
1861
1914
|
)
|
|
@@ -1892,7 +1945,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1892
1945
|
await bootstrapRuntimes(
|
|
1893
1946
|
sandbox,
|
|
1894
1947
|
this.options.config,
|
|
1895
|
-
{ ...
|
|
1948
|
+
{ ...this.guestEnvironment(), AB_TOKEN: scopedToken },
|
|
1896
1949
|
currentRuntimeReferences(this.options.runtimeReferences),
|
|
1897
1950
|
false,
|
|
1898
1951
|
)
|
|
@@ -1915,9 +1968,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1915
1968
|
: {}),
|
|
1916
1969
|
[HARVEST_RUNNER_OPTIONS_ENV]: JSON.stringify(envelope),
|
|
1917
1970
|
}
|
|
1918
|
-
|
|
1919
|
-
if (!['AB_TOKEN', 'AB_TICKET_URL', 'AB_TICKET_TOKEN'].includes(envName))
|
|
1920
|
-
env[envName] = requireVercelEnvironmentValue(this.options.env, envName)
|
|
1971
|
+
Object.assign(env, this.guestEnvironment())
|
|
1921
1972
|
const command = (await sandbox.runCommand({
|
|
1922
1973
|
cmd: 'sh',
|
|
1923
1974
|
args: [
|
|
@@ -1988,6 +2039,39 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
1988
2039
|
)
|
|
1989
2040
|
}
|
|
1990
2041
|
}
|
|
2042
|
+
let attention: string | undefined
|
|
2043
|
+
const accounts = this.options.accounts?.() ?? {}
|
|
2044
|
+
// Preserve legacy observation: without accounts there is no credential
|
|
2045
|
+
// policy to refresh, and no additional provider write or failure point.
|
|
2046
|
+
if (Object.keys(accounts).length) {
|
|
2047
|
+
const origin =
|
|
2048
|
+
this.origins.get(identity.workspaceRef) ?? cleanGithubOrigin(await this.origin())
|
|
2049
|
+
const base = uploadPackPolicy(
|
|
2050
|
+
origin,
|
|
2051
|
+
this.options.config.gitPasswordEnv === undefined
|
|
2052
|
+
? undefined
|
|
2053
|
+
: `Basic ${Buffer.from(`${requireVercelEnvironmentValue(this.options.env, this.options.config.gitUsernameEnv!)}:${requireVercelEnvironmentValue(this.options.env, this.options.config.gitPasswordEnv)}`).toString('base64')}`,
|
|
2054
|
+
)
|
|
2055
|
+
const refreshed = accountPolicy(base, accounts, this.options.env)
|
|
2056
|
+
try {
|
|
2057
|
+
await sandbox.update(
|
|
2058
|
+
{ networkPolicy: refreshed.policy },
|
|
2059
|
+
{ signal: this.operationSignal() },
|
|
2060
|
+
)
|
|
2061
|
+
} catch {
|
|
2062
|
+
await sandbox.stop({ signal: this.operationSignal() })
|
|
2063
|
+
return { state: 'lost', attention: 'Account policy renewal failed; sandbox stopped' }
|
|
2064
|
+
}
|
|
2065
|
+
if (refreshed.missing.length) {
|
|
2066
|
+
attention = `Missing credentials: ${refreshed.missing.join('; ')}`
|
|
2067
|
+
// The updated policy fences the missing account by removing its bearer
|
|
2068
|
+
// transform. Its next request fails authentication through the runtime's
|
|
2069
|
+
// account-specific recovery path. Keep other routes in this guest alive:
|
|
2070
|
+
// declarations include unused accounts and do not identify active sessions.
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
const diagnosed = (observation: ExecutionObservation): ExecutionObservation =>
|
|
2074
|
+
attention === undefined ? observation : { ...observation, attention }
|
|
1991
2075
|
let observation: ExecutionObservation
|
|
1992
2076
|
try {
|
|
1993
2077
|
const command = await sandbox.getCommand(identity.commandId, {
|
|
@@ -2006,7 +2090,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2006
2090
|
observation = { state: 'ended', exitCode: finished.exitCode }
|
|
2007
2091
|
} catch (error) {
|
|
2008
2092
|
if (isMissingVercelSandbox(error)) observation = { state: 'lost' }
|
|
2009
|
-
else if (isInterruptedLongPoll(error)) return { state: 'running' }
|
|
2093
|
+
else if (isInterruptedLongPoll(error)) return diagnosed({ state: 'running' })
|
|
2010
2094
|
else throw error
|
|
2011
2095
|
}
|
|
2012
2096
|
}
|
|
@@ -2017,7 +2101,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2017
2101
|
// Deliberately outside the lookup/wait catch: an ambiguous stop must not
|
|
2018
2102
|
// become proof of loss or command exit, even when its error resembles a
|
|
2019
2103
|
// transport interruption.
|
|
2020
|
-
return settled(observation)
|
|
2104
|
+
return settled(diagnosed(observation))
|
|
2021
2105
|
}
|
|
2022
2106
|
|
|
2023
2107
|
// ── Operator sandbox capability (AUT-340) ─────────────────────────
|
|
@@ -2581,7 +2665,7 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2581
2665
|
if (!token) {
|
|
2582
2666
|
throw new Error('vercel-sandbox publication requires GITHUB_TOKEN or GH_TOKEN')
|
|
2583
2667
|
}
|
|
2584
|
-
const { origin
|
|
2668
|
+
const { origin } = await this.normalNetworkPolicy(input.ref)
|
|
2585
2669
|
const sandbox =
|
|
2586
2670
|
this.sessions.get(input.ref) ?? (await this.facade.get(input.ref, this.operationSignal()))
|
|
2587
2671
|
if (sandbox === null) throw new Error(`unknown sandbox ${input.ref}`)
|
|
@@ -2633,7 +2717,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2633
2717
|
},
|
|
2634
2718
|
}
|
|
2635
2719
|
try {
|
|
2636
|
-
await sandbox.update(
|
|
2720
|
+
await sandbox.update(
|
|
2721
|
+
{ networkPolicy: this.billingPolicy(publicationPolicy, input.ref) },
|
|
2722
|
+
{ signal: this.operationSignal() },
|
|
2723
|
+
)
|
|
2637
2724
|
if (input.expected !== undefined) {
|
|
2638
2725
|
const capability = gitRewrite(async (cmd) => {
|
|
2639
2726
|
const result = await sandbox.runCommand({
|
|
@@ -2685,7 +2772,10 @@ export class VercelSandboxProvider implements WorkspaceProvider {
|
|
|
2685
2772
|
await sandbox.stop({ signal: this.operationSignal() })
|
|
2686
2773
|
} finally {
|
|
2687
2774
|
try {
|
|
2688
|
-
await sandbox.update(
|
|
2775
|
+
await sandbox.update(
|
|
2776
|
+
{ networkPolicy: (await this.normalNetworkPolicy(input.ref)).policy },
|
|
2777
|
+
{ signal: this.operationSignal() },
|
|
2778
|
+
)
|
|
2689
2779
|
} finally {
|
|
2690
2780
|
await sandbox.stop({ signal: this.operationSignal() })
|
|
2691
2781
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { accountRedactor, redactAccountStore } from '../store/account-redaction'
|
|
1
2
|
import {
|
|
2
3
|
capturedBuildConfig,
|
|
3
4
|
refreshVerifyCycle,
|
|
@@ -755,6 +756,7 @@ export class BuildRunner {
|
|
|
755
756
|
runtime: old.runner,
|
|
756
757
|
model: old.model,
|
|
757
758
|
args: old.args ?? [],
|
|
759
|
+
account: old.account,
|
|
758
760
|
sessionBudgetSeconds: (old.budgetMs ?? resolved.sessionBudgetSeconds * 1000) / 1000,
|
|
759
761
|
}
|
|
760
762
|
}
|
|
@@ -908,6 +910,15 @@ export class BuildRunner {
|
|
|
908
910
|
private boundaryResolver: RuntimeResolver
|
|
909
911
|
|
|
910
912
|
constructor(private readonly deps: BuildRunnerDeps) {
|
|
913
|
+
const redactor = accountRedactor(
|
|
914
|
+
() => this.boundaryConfig?.accounts ?? deps.config.accounts,
|
|
915
|
+
() => ({
|
|
916
|
+
...process.env,
|
|
917
|
+
...deps.sessionEnv,
|
|
918
|
+
}),
|
|
919
|
+
)
|
|
920
|
+
deps.store = redactAccountStore(deps.store, redactor)
|
|
921
|
+
|
|
911
922
|
this.deps = {
|
|
912
923
|
...deps,
|
|
913
924
|
store: withDrainingExecution(
|
|
@@ -926,6 +937,7 @@ export class BuildRunner {
|
|
|
926
937
|
deps.runtimes,
|
|
927
938
|
deps.config.roles,
|
|
928
939
|
deps.config.policy.sessionBudgetSeconds,
|
|
940
|
+
deps.config.accounts,
|
|
929
941
|
)
|
|
930
942
|
}
|
|
931
943
|
|
|
@@ -938,6 +950,7 @@ export class BuildRunner {
|
|
|
938
950
|
this.deps.runtimes,
|
|
939
951
|
config.roles,
|
|
940
952
|
config.policy.sessionBudgetSeconds,
|
|
953
|
+
config.accounts,
|
|
941
954
|
)
|
|
942
955
|
return config
|
|
943
956
|
}
|
|
@@ -2722,6 +2735,7 @@ export class BuildRunner {
|
|
|
2722
2735
|
session,
|
|
2723
2736
|
role: step,
|
|
2724
2737
|
runner: target.runtime,
|
|
2738
|
+
...(target.account === undefined ? {} : { account: target.account }),
|
|
2725
2739
|
...(target.model !== undefined ? { model: target.model } : {}),
|
|
2726
2740
|
phase: 'finalize',
|
|
2727
2741
|
round: 1,
|
|
@@ -2734,6 +2748,7 @@ export class BuildRunner {
|
|
|
2734
2748
|
session,
|
|
2735
2749
|
role: step,
|
|
2736
2750
|
runner: target.runtime,
|
|
2751
|
+
...(target.account === undefined ? {} : { account: target.account }),
|
|
2737
2752
|
...(target.model !== undefined ? { model: target.model } : {}),
|
|
2738
2753
|
args: [...target.args],
|
|
2739
2754
|
phase: 'finalize',
|
|
@@ -2757,6 +2772,7 @@ export class BuildRunner {
|
|
|
2757
2772
|
invocation: slug,
|
|
2758
2773
|
buildSlug: slug,
|
|
2759
2774
|
workspacePath,
|
|
2775
|
+
...(target.account === undefined ? {} : { account: target.account }),
|
|
2760
2776
|
...(target.model !== undefined ? { model: target.model } : {}),
|
|
2761
2777
|
...(target.args !== undefined ? { args: target.args } : {}),
|
|
2762
2778
|
env: await this.sessionEnvFor('finalize@1', session, step),
|
|
@@ -2835,6 +2851,7 @@ export class BuildRunner {
|
|
|
2835
2851
|
index,
|
|
2836
2852
|
session,
|
|
2837
2853
|
runner: target.runtime,
|
|
2854
|
+
...(target.account === undefined ? {} : { account: target.account }),
|
|
2838
2855
|
...(target.model !== undefined ? { model: target.model } : {}),
|
|
2839
2856
|
error: failure.message,
|
|
2840
2857
|
...(failure.cause !== undefined ? { cause: failure.cause } : {}),
|
|
@@ -2872,6 +2889,7 @@ export class BuildRunner {
|
|
|
2872
2889
|
session,
|
|
2873
2890
|
role: step,
|
|
2874
2891
|
runner: runnerName,
|
|
2892
|
+
...(resolved.account === undefined ? {} : { account: resolved.account }),
|
|
2875
2893
|
...(model !== undefined ? { model } : {}),
|
|
2876
2894
|
phase: 'finalize',
|
|
2877
2895
|
round: 1,
|
|
@@ -2885,6 +2903,7 @@ export class BuildRunner {
|
|
|
2885
2903
|
session,
|
|
2886
2904
|
role: step,
|
|
2887
2905
|
runner: runnerName,
|
|
2906
|
+
...(resolved.account === undefined ? {} : { account: resolved.account }),
|
|
2888
2907
|
...(model !== undefined ? { model } : {}),
|
|
2889
2908
|
args: [...args],
|
|
2890
2909
|
phase: 'finalize',
|
|
@@ -2905,6 +2924,7 @@ export class BuildRunner {
|
|
|
2905
2924
|
invocation: slug,
|
|
2906
2925
|
buildSlug: slug,
|
|
2907
2926
|
workspacePath,
|
|
2927
|
+
...(resolved.account === undefined ? {} : { account: resolved.account }),
|
|
2908
2928
|
...(model !== undefined ? { model } : {}),
|
|
2909
2929
|
...(args !== undefined ? { args } : {}),
|
|
2910
2930
|
env: await this.sessionEnvFor('finalize@1', session, step),
|
|
@@ -3482,6 +3502,7 @@ export class BuildRunner {
|
|
|
3482
3502
|
runtime: primary.runtime,
|
|
3483
3503
|
model: primary.model,
|
|
3484
3504
|
args: primary.args,
|
|
3505
|
+
account: primary.account,
|
|
3485
3506
|
})
|
|
3486
3507
|
let primaryLive =
|
|
3487
3508
|
spec.producerPhase !== undefined ? this.producerSessions.get(spec.producerPhase) : undefined
|
|
@@ -3507,6 +3528,7 @@ export class BuildRunner {
|
|
|
3507
3528
|
session,
|
|
3508
3529
|
role: spec.role,
|
|
3509
3530
|
runner: target.runtime,
|
|
3531
|
+
...(target.account === undefined ? {} : { account: target.account }),
|
|
3510
3532
|
...(target.model !== undefined ? { model: target.model } : {}),
|
|
3511
3533
|
phase: spec.phase,
|
|
3512
3534
|
round: spec.round,
|
|
@@ -3519,6 +3541,7 @@ export class BuildRunner {
|
|
|
3519
3541
|
session,
|
|
3520
3542
|
role: spec.role,
|
|
3521
3543
|
runner: target.runtime,
|
|
3544
|
+
...(target.account === undefined ? {} : { account: target.account }),
|
|
3522
3545
|
...(target.model !== undefined ? { model: target.model } : {}),
|
|
3523
3546
|
args: [...target.args],
|
|
3524
3547
|
phase: spec.phase,
|
|
@@ -3554,6 +3577,7 @@ export class BuildRunner {
|
|
|
3554
3577
|
invocation: slug,
|
|
3555
3578
|
buildSlug: slug,
|
|
3556
3579
|
workspacePath,
|
|
3580
|
+
...(target.account === undefined ? {} : { account: target.account }),
|
|
3557
3581
|
...(target.model !== undefined ? { model: target.model } : {}),
|
|
3558
3582
|
...(target.args !== undefined ? { args: target.args } : {}),
|
|
3559
3583
|
env: await this.sessionEnvFor(spec.abPhase, session),
|
|
@@ -3747,6 +3771,7 @@ export class BuildRunner {
|
|
|
3747
3771
|
index,
|
|
3748
3772
|
session,
|
|
3749
3773
|
runner: target.runtime,
|
|
3774
|
+
...(target.account === undefined ? {} : { account: target.account }),
|
|
3750
3775
|
...(target.model !== undefined ? { model: target.model } : {}),
|
|
3751
3776
|
error: failure.message,
|
|
3752
3777
|
...(failure.cause !== undefined ? { cause: failure.cause } : {}),
|
|
@@ -3785,13 +3810,14 @@ export class BuildRunner {
|
|
|
3785
3810
|
// the runtime/model on the same payload say what was resolved.
|
|
3786
3811
|
const resolved = this.resolveSessionRole(spec.role, ...(spec.roleAliases ?? []))
|
|
3787
3812
|
const { runner, runtime: runnerName, model, args, sessionBudgetSeconds } = resolved
|
|
3788
|
-
const route = JSON.stringify({ runtime: runnerName, model, args })
|
|
3813
|
+
const route = JSON.stringify({ runtime: runnerName, model, args, account: resolved.account })
|
|
3789
3814
|
// SPEC §9: the stream opens before the bracket's first turn — its id is
|
|
3790
3815
|
// already known when `session.started` appends.
|
|
3791
3816
|
const streamBracket = await this.openSessionStream(resolved, {
|
|
3792
3817
|
session,
|
|
3793
3818
|
role: spec.role,
|
|
3794
3819
|
runner: runnerName,
|
|
3820
|
+
...(resolved.account === undefined ? {} : { account: resolved.account }),
|
|
3795
3821
|
...(model !== undefined ? { model } : {}),
|
|
3796
3822
|
phase: spec.phase,
|
|
3797
3823
|
round: spec.round,
|
|
@@ -3818,6 +3844,7 @@ export class BuildRunner {
|
|
|
3818
3844
|
session,
|
|
3819
3845
|
role: spec.role,
|
|
3820
3846
|
runner: runnerName,
|
|
3847
|
+
...(resolved.account === undefined ? {} : { account: resolved.account }),
|
|
3821
3848
|
...(model !== undefined ? { model } : {}),
|
|
3822
3849
|
args: [...args],
|
|
3823
3850
|
phase: spec.phase,
|
|
@@ -3857,6 +3884,7 @@ export class BuildRunner {
|
|
|
3857
3884
|
invocation: slug,
|
|
3858
3885
|
buildSlug: slug,
|
|
3859
3886
|
workspacePath,
|
|
3887
|
+
...(resolved.account === undefined ? {} : { account: resolved.account }),
|
|
3860
3888
|
...(model !== undefined ? { model } : {}),
|
|
3861
3889
|
...(args !== undefined ? { args } : {}),
|
|
3862
3890
|
env: await this.sessionEnvFor(spec.abPhase, session),
|
|
@@ -4229,6 +4257,9 @@ export class BuildRunner {
|
|
|
4229
4257
|
)
|
|
4230
4258
|
: undefined
|
|
4231
4259
|
return {
|
|
4260
|
+
AB_ACCOUNT_CREDENTIAL_ENVS: JSON.stringify(
|
|
4261
|
+
Object.values(this.boundaryConfig.accounts).map((account) => account.credentialEnv),
|
|
4262
|
+
),
|
|
4232
4263
|
AB_STORE: 'local',
|
|
4233
4264
|
...this.deps.sessionEnv,
|
|
4234
4265
|
...(token ? { AB_TOKEN: token } : {}),
|