@defrex/autobuild 1.3.0 → 1.4.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 +1 -1
- package/SPEC.md +302 -26
- package/docs/accounts.md +38 -0
- package/docs/architecture.md +187 -19
- package/docs/build-store.md +18 -0
- package/docs/builds.md +5 -1
- package/docs/cli.md +1 -1
- package/docs/configuration.md +38 -19
- package/docs/dispatcher-hosting.md +42 -0
- package/docs/dispatcher.md +41 -0
- package/docs/forges.md +5 -0
- package/docs/integration-tree.md +8 -0
- package/docs/operating.md +11 -3
- package/docs/operator-api.md +37 -4
- package/docs/plugin-authoring.md +45 -1
- package/docs/remote-store-protocol.md +258 -42
- package/docs/remote-ticket-protocol.md +12 -10
- package/docs/restacking.md +60 -3
- package/docs/setup.md +37 -8
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +37 -3
- package/docs/troubleshooting.md +9 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/availability.ts +96 -0
- package/packages/core/src/accounts/local-owner.ts +49 -2
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary.ts +17 -1
- package/packages/core/src/cli/context.ts +62 -0
- package/packages/core/src/cli/dashboard/model.ts +12 -3
- package/packages/core/src/cli/dashboard/poll.ts +65 -8
- package/packages/core/src/cli/dashboard/refresh.ts +2 -0
- package/packages/core/src/cli/dashboard/render.ts +46 -5
- package/packages/core/src/cli/dispatch-args.ts +27 -3
- package/packages/core/src/cli/dispatch-frontend.ts +178 -52
- package/packages/core/src/cli/dispatch-mode.ts +94 -0
- package/packages/core/src/cli/dispatch-preflight.ts +43 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +45 -9
- package/packages/core/src/cli/dispatch.ts +145 -11
- package/packages/core/src/cli/harvest.ts +2 -1
- package/packages/core/src/cli/help.ts +16 -3
- package/packages/core/src/cli/historical-build-state.ts +6 -0
- package/packages/core/src/cli/main.ts +15 -2
- package/packages/core/src/cli/publication-settlement.ts +17 -0
- package/packages/core/src/cli/remote-poll.ts +11 -1
- package/packages/core/src/cli/repository-status.ts +11 -0
- package/packages/core/src/cli/status.ts +7 -1
- package/packages/core/src/cli/wait.ts +9 -2
- package/packages/core/src/cli/watch.ts +38 -3
- package/packages/core/src/config/roles.ts +16 -1
- package/packages/core/src/events/catalog.ts +7 -0
- package/packages/core/src/events/payloads.ts +85 -2
- package/packages/core/src/events/policy.ts +10 -0
- package/packages/core/src/events/repository.ts +35 -0
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +189 -0
- package/packages/core/src/kernel/dispatch-placement.ts +30 -0
- package/packages/core/src/kernel/engine.ts +19 -12
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +17 -1
- package/packages/core/src/kernel/leaf-restack-state.ts +24 -2
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-landing.ts +27 -10
- package/packages/core/src/kernel/node-restack-demand.ts +1 -0
- package/packages/core/src/kernel/node-restack-state.ts +16 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +14 -0
- package/packages/core/src/kernel/read-facts.ts +114 -9
- package/packages/core/src/kernel/reconcile-head.ts +34 -11
- package/packages/core/src/kernel/reconcile-restack.ts +106 -72
- package/packages/core/src/kernel/reducer-registry.ts +3 -0
- package/packages/core/src/kernel/reducer.ts +20 -2
- package/packages/core/src/kernel/replay-retention.ts +176 -0
- package/packages/core/src/kernel/target-lineage.ts +65 -0
- package/packages/core/src/kernel/target-observation.ts +117 -0
- package/packages/core/src/operator/registry.ts +5 -13
- package/packages/core/src/operator/tickets.ts +8 -2
- package/packages/core/src/plugin-sdk/index.ts +1 -0
- package/packages/core/src/ports/forge/fake.ts +22 -0
- package/packages/core/src/ports/forge/git-rewrite.ts +49 -12
- package/packages/core/src/ports/forge/github.ts +42 -10
- package/packages/core/src/ports/forge/local-git.ts +16 -1
- package/packages/core/src/ports/types.ts +58 -4
- package/packages/core/src/ports/workspace/account-policy.ts +2 -1
- package/packages/core/src/ports/workspace/commit-preservation.ts +175 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/fake.ts +4 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +22 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +304 -56
- package/packages/core/src/processes/build-runner.ts +240 -111
- package/packages/core/src/processes/dispatcher-selectors.ts +3 -2
- package/packages/core/src/processes/dispatcher.ts +262 -80
- package/packages/core/src/processes/execution-no-progress.ts +7 -0
- package/packages/core/src/processes/harvest-runner.ts +6 -7
- package/packages/core/src/processes/publication-state.ts +2 -1
- package/packages/core/src/processes/repo-view.ts +22 -0
- package/packages/core/src/processes/workspace-preservation.ts +164 -0
- package/packages/core/src/scenarios/harness.ts +7 -0
- package/packages/core/src/store/adapter.ts +9 -0
- package/packages/core/src/store/build-scope.ts +28 -0
- package/packages/core/src/store/contract.ts +125 -0
- package/packages/core/src/store/event-reads.ts +156 -0
- package/packages/core/src/store/local/schema.ts +11 -0
- package/packages/core/src/store/local/store.ts +117 -2
- package/packages/core/src/store/memory.ts +237 -0
- package/packages/core/src/store/phase-session.ts +47 -0
- package/packages/core/src/store/reduced-reads.ts +8 -0
- package/packages/core/src/store/reducer-value-shapes.json +6262 -5227
- package/packages/core/src/store/reducer-value-validation.ts +3 -0
- package/packages/core/src/store/reducer-values.ts +62 -2
- package/packages/core/src/store/remote/client.ts +161 -16
- package/packages/core/src/store/remote/compatibility.ts +177 -46
- package/packages/core/src/store/remote/errors.ts +16 -0
- package/packages/core/src/store/remote/index.ts +11 -0
- package/packages/core/src/store/remote/protocol.ts +22 -0
- package/packages/core/src/store/remote/released-clients.json +37 -0
- package/packages/core/src/store/remote/released-clients.ts +88 -0
- package/packages/core/src/store/remote/released-reducer-values/1.3.0.json +25093 -0
- package/packages/core/src/store/remote/released-reducer-values/1.4.0.json +26128 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +13 -0
- package/packages/core/src/store/remote/version.ts +5 -2
- package/packages/core/src/store/repo-state-events.ts +4 -3
- package/packages/core/src/store/scan-cadence.ts +15 -0
- package/packages/core/src/store/session-handle.ts +18 -0
- package/packages/core/src/store/types.ts +27 -6
- package/packages/core/src/testing/dispatch-read-budget.ts +313 -2
- package/packages/core/src/testing/index.ts +5 -0
- package/packages/core/src/testing/reduced-read-budget.ts +728 -5
- package/skills/guide/SKILL.md +177 -16
- package/skills/guide/references/accounts.md +38 -0
- package/skills/guide/references/integration-tree.md +8 -0
- package/skills/guide/references/operator-api.md +37 -4
- package/skills/guide/references/plugin-authoring.md +45 -1
- package/skills/guide/references/remote-store-protocol.md +258 -42
- package/skills/guide/references/remote-ticket-protocol.md +12 -10
- package/skills/guide/references/restacking.md +60 -3
- package/skills/guide/references/setup.md +37 -8
- package/skills/guide/references/spec-standard.md +37 -3
- package/skills/implement/SKILL.md +12 -3
- package/skills/operate/SKILL.md +64 -7
- package/skills/plan/SKILL.md +27 -4
- package/skills/plan-review/SKILL.md +22 -2
- package/skills/reconcile/SKILL.md +10 -1
- package/skills/spec/SKILL.md +7 -4
- package/templates/hosted-service/package.json +2 -2
|
@@ -40,6 +40,7 @@ export class DashboardRefresh {
|
|
|
40
40
|
private readonly refresh: () => Promise<void>,
|
|
41
41
|
private readonly time: RefreshScheduler = scheduler,
|
|
42
42
|
private readonly networkReads = false,
|
|
43
|
+
private readonly cadenceMs?: number,
|
|
43
44
|
) {}
|
|
44
45
|
|
|
45
46
|
get painting(): boolean {
|
|
@@ -141,6 +142,7 @@ export class DashboardRefresh {
|
|
|
141
142
|
|
|
142
143
|
/** Current admission cadence, also used to bound presentation staleness. */
|
|
143
144
|
get intervalMs(): number {
|
|
145
|
+
if (this.cadenceMs !== undefined) return this.cadenceMs
|
|
144
146
|
if (this.networkReads && !this.focused) return 5000
|
|
145
147
|
return this.live || this.time.now() < this.deadline ? 500 : 5000
|
|
146
148
|
}
|
|
@@ -557,6 +557,15 @@ export const DASHBOARD_SESSION_LIVE_LEGEND =
|
|
|
557
557
|
export const DASHBOARD_SESSION_PAUSED_LEGEND =
|
|
558
558
|
'Keys: Up/Down scroll (paused) Esc back Ctrl-C quit'
|
|
559
559
|
|
|
560
|
+
function modeLegend(model: DashboardModel, legend: string): string {
|
|
561
|
+
return model.viewer
|
|
562
|
+
? legend
|
|
563
|
+
.replace('Up/Down select', 'Up/Down')
|
|
564
|
+
.replace('Ctrl-C quit', 'Ctrl-C close viewer')
|
|
565
|
+
.replace(/ {2}/g, ' ')
|
|
566
|
+
: legend
|
|
567
|
+
}
|
|
568
|
+
|
|
560
569
|
function buildLegend(build: DashboardBuild, detail: boolean): string {
|
|
561
570
|
if (build.status === 'aborting' || build.status === 'cleaning') {
|
|
562
571
|
return detail
|
|
@@ -1026,7 +1035,7 @@ function renderDetail(model: DashboardModel, opts: RenderOpts): string[] {
|
|
|
1026
1035
|
const controls =
|
|
1027
1036
|
model.resumeInput !== undefined || model.abortConfirmation !== undefined
|
|
1028
1037
|
? dashboardControls(model, color, width, controlsCapacity(height, top.length))
|
|
1029
|
-
: [truncate(paint(buildLegend(build, true), 'dim', color), width)]
|
|
1038
|
+
: [truncate(paint(modeLegend(model, buildLegend(build, true)), 'dim', color), width)]
|
|
1030
1039
|
if (height !== undefined && height <= 0) return []
|
|
1031
1040
|
if (height !== undefined && height <= top.length) return top.slice(0, height)
|
|
1032
1041
|
if (height !== undefined && height === top.length + 1) return [...top, ...controls]
|
|
@@ -1134,7 +1143,7 @@ function renderTranscript(model: DashboardModel, opts: RenderOpts): string[] {
|
|
|
1134
1143
|
]
|
|
1135
1144
|
const content = transcriptContent(view.transcript, width).map((line) => truncate(line, width))
|
|
1136
1145
|
const controls = truncate(
|
|
1137
|
-
paint('Keys: Up/Down scroll Esc back Ctrl-C quit', 'dim', color),
|
|
1146
|
+
paint(modeLegend(model, 'Keys: Up/Down scroll Esc back Ctrl-C quit'), 'dim', color),
|
|
1138
1147
|
width,
|
|
1139
1148
|
)
|
|
1140
1149
|
if (height !== undefined && height <= 0) return []
|
|
@@ -1212,7 +1221,10 @@ function renderSessionView(model: DashboardModel, opts: RenderOpts): string[] {
|
|
|
1212
1221
|
const content = sessionContentLines(view, width).map((line) => truncate(line, width))
|
|
1213
1222
|
const controls = truncate(
|
|
1214
1223
|
paint(
|
|
1215
|
-
|
|
1224
|
+
modeLegend(
|
|
1225
|
+
model,
|
|
1226
|
+
view.follow ? DASHBOARD_SESSION_LIVE_LEGEND : DASHBOARD_SESSION_PAUSED_LEGEND,
|
|
1227
|
+
),
|
|
1216
1228
|
'dim',
|
|
1217
1229
|
color,
|
|
1218
1230
|
),
|
|
@@ -1562,7 +1574,7 @@ function dashboardControls(
|
|
|
1562
1574
|
? DASHBOARD_HARVEST_ACKNOWLEDGE_LEGEND
|
|
1563
1575
|
: DASHBOARD_HARVEST_LEGEND
|
|
1564
1576
|
: DASHBOARD_GLOBAL_LEGEND
|
|
1565
|
-
return [truncate(paint(legend, 'dim', color), width)]
|
|
1577
|
+
return [truncate(paint(modeLegend(model, legend), 'dim', color), width)]
|
|
1566
1578
|
}
|
|
1567
1579
|
return resumePanel(model, color, width, capacity)
|
|
1568
1580
|
}
|
|
@@ -1812,10 +1824,39 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1812
1824
|
* truncation, and right-pinning share one geometry. Prefixing only after the
|
|
1813
1825
|
* frame is composed preserves its logical line count (including truly blank
|
|
1814
1826
|
* separators) and therefore leaves vertical budgeting unchanged. */
|
|
1827
|
+
export function renderViewerNotice(
|
|
1828
|
+
viewer: { dispatchedBy?: string },
|
|
1829
|
+
message: string,
|
|
1830
|
+
width: number,
|
|
1831
|
+
height: number,
|
|
1832
|
+
): string[] {
|
|
1833
|
+
const contentWidth = dashboardContentWidth(width)
|
|
1834
|
+
return [viewerIndicator(viewer, contentWidth), truncate(displayText(message), contentWidth)]
|
|
1835
|
+
.slice(0, Math.max(0, height))
|
|
1836
|
+
.map((line) => (width > 0 ? ` ${line}` : line))
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
export function viewerIndicator(viewer: { dispatchedBy?: string }, width: number): string {
|
|
1840
|
+
const label =
|
|
1841
|
+
viewer.dispatchedBy === undefined
|
|
1842
|
+
? 'viewer'
|
|
1843
|
+
: `viewer · dispatched by ${displayText(viewer.dispatchedBy)}`
|
|
1844
|
+
return width >= 6 && width < 9 ? 'viewer' : truncate(label, width)
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1815
1847
|
export function renderDashboard(model: DashboardModel, opts: RenderOpts): string[] {
|
|
1816
1848
|
const terminalWidth = Math.max(0, opts.width)
|
|
1817
1849
|
const contentWidth = dashboardContentWidth(terminalWidth)
|
|
1818
|
-
const
|
|
1850
|
+
const viewerRows = model.viewer ? 1 : 0
|
|
1851
|
+
const height = opts.height === undefined ? undefined : Math.max(0, opts.height - viewerRows)
|
|
1852
|
+
const lines = renderDashboardContent(model, {
|
|
1853
|
+
...opts,
|
|
1854
|
+
width: contentWidth,
|
|
1855
|
+
...(height !== undefined ? { height } : {}),
|
|
1856
|
+
})
|
|
1857
|
+
if (model.viewer && (opts.height === undefined || opts.height > 0)) {
|
|
1858
|
+
lines.unshift(viewerIndicator(model.viewer, contentWidth))
|
|
1859
|
+
}
|
|
1819
1860
|
const leftGutter = terminalWidth > 0 ? ' ' : ''
|
|
1820
1861
|
|
|
1821
1862
|
return lines.map((line) => (line === '' ? '' : `${leftGutter}${line}`))
|
|
@@ -4,10 +4,13 @@ export function parseDispatchArgs(
|
|
|
4
4
|
env: Record<string, string | undefined>,
|
|
5
5
|
) {
|
|
6
6
|
const usage =
|
|
7
|
-
'usage: ab dispatch [--once] [--interval <seconds>] [--store <ref>] [--repository <origin>] [--plain] [--intake | --no-intake] [--auto-merge | --no-auto-merge] (§3.3)'
|
|
7
|
+
'usage: ab dispatch [--viewer [--dispatched-by <label>] | --takeover] [--once] [--interval <seconds>] [--store <ref>] [--repository <origin>] [--plain] [--intake | --no-intake] [--auto-merge | --no-auto-merge] (§3.3)'
|
|
8
8
|
const parsed = parseArgs(
|
|
9
9
|
rest,
|
|
10
10
|
{
|
|
11
|
+
viewer: 'boolean',
|
|
12
|
+
takeover: 'boolean',
|
|
13
|
+
'dispatched-by': 'value',
|
|
11
14
|
once: 'boolean',
|
|
12
15
|
interval: 'value',
|
|
13
16
|
store: 'value',
|
|
@@ -22,6 +25,16 @@ export function parseDispatchArgs(
|
|
|
22
25
|
)
|
|
23
26
|
if (parsed.positionals.length > 0) throw new Error(usage)
|
|
24
27
|
|
|
28
|
+
const takeover = parsed.flags.has('takeover')
|
|
29
|
+
const viewer = parsed.flags.has('viewer')
|
|
30
|
+
if (viewer && takeover) throw new Error('--viewer and --takeover cannot be combined')
|
|
31
|
+
const dispatchedBy = stringFlag(parsed, 'dispatched-by')?.trim()
|
|
32
|
+
if (dispatchedBy !== undefined && (!viewer || dispatchedBy === ''))
|
|
33
|
+
throw new Error('--dispatched-by requires --viewer and a nonblank label')
|
|
34
|
+
if (viewer && parsed.flags.has('repository'))
|
|
35
|
+
throw new Error('--viewer requires a local checkout; omit --repository')
|
|
36
|
+
if (viewer && (parsed.flags.has('intake') || parsed.flags.has('no-intake')))
|
|
37
|
+
throw new Error('--viewer cannot set startup intake; use the interactive intake control')
|
|
25
38
|
const once = parsed.flags.has('once')
|
|
26
39
|
const plain = parsed.flags.has('plain')
|
|
27
40
|
const sawIntake = parsed.flags.has('intake')
|
|
@@ -45,9 +58,20 @@ export function parseDispatchArgs(
|
|
|
45
58
|
intervalMs = Math.round(seconds * 1000)
|
|
46
59
|
}
|
|
47
60
|
const storeRef = stringFlag(parsed, 'store')
|
|
48
|
-
const repository = stringFlag(parsed, 'repository') ?? env.AB_REPOSITORY
|
|
61
|
+
const repository = stringFlag(parsed, 'repository') ?? (viewer ? undefined : env.AB_REPOSITORY)
|
|
49
62
|
const intake = sawIntake ? true : sawNoIntake ? false : undefined
|
|
50
63
|
const defaultAutoMerge = sawAutoMerge ? true : sawNoAutoMerge ? false : undefined
|
|
51
64
|
|
|
52
|
-
return {
|
|
65
|
+
return {
|
|
66
|
+
viewer,
|
|
67
|
+
takeover,
|
|
68
|
+
dispatchedBy,
|
|
69
|
+
once,
|
|
70
|
+
plain,
|
|
71
|
+
intake,
|
|
72
|
+
defaultAutoMerge,
|
|
73
|
+
intervalMs,
|
|
74
|
+
storeRef,
|
|
75
|
+
repository,
|
|
76
|
+
}
|
|
53
77
|
}
|
|
@@ -2,7 +2,11 @@ import { normalizeEffectiveConfigArtifact } from '../config/effective-artifact'
|
|
|
2
2
|
import { migrationIdentity, ticketMigrationsReducer } from '../kernel/ticket-migrations'
|
|
3
3
|
import type { DispatchUpgradeState } from '../kernel/dispatch-upgrade'
|
|
4
4
|
import { releaseDispatchPresentation } from './dispatch-presentation-ownership'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
readDispatchUpgrade,
|
|
7
|
+
readRepositoryFacts,
|
|
8
|
+
type RepositoryReadFacts,
|
|
9
|
+
} from '../store/reduced-reads'
|
|
6
10
|
import { DISPATCHER } from '../events/envelope'
|
|
7
11
|
import { launchContext } from './dispatch-launch-contract'
|
|
8
12
|
import { dispatchCapacity } from '../kernel/dispatch-capacity'
|
|
@@ -49,6 +53,8 @@ import {
|
|
|
49
53
|
moveDetailScroll,
|
|
50
54
|
moveTranscriptScroll,
|
|
51
55
|
renderDashboard,
|
|
56
|
+
viewerIndicator,
|
|
57
|
+
renderViewerNotice,
|
|
52
58
|
revealDetailFocus,
|
|
53
59
|
type DashboardRendererResolver,
|
|
54
60
|
} from './dashboard/render'
|
|
@@ -95,6 +101,8 @@ interface ResumePrompt {
|
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
export interface DispatchFrontendOptions {
|
|
104
|
+
viewer?: { dispatchedBy?: string }
|
|
105
|
+
plainOutput?: (line: string) => void
|
|
98
106
|
/** Repository identity (§12): the normalized origin, or the checkout path
|
|
99
107
|
* when there is no origin. Every Store key uses this. */
|
|
100
108
|
repo: string
|
|
@@ -161,11 +169,19 @@ export class DispatchFrontend {
|
|
|
161
169
|
private actionTail: Promise<void> = Promise.resolve()
|
|
162
170
|
private presentationRestored = false
|
|
163
171
|
private operatorStopRequested = false
|
|
172
|
+
private viewerStopped: (() => void) | undefined
|
|
173
|
+
private viewerFacts: RepositoryReadFacts | undefined
|
|
174
|
+
private viewerPosition: string | undefined
|
|
175
|
+
private viewerReadAt = -Infinity
|
|
176
|
+
private lastPlainFrame: string | undefined
|
|
164
177
|
|
|
165
178
|
constructor(private readonly opts: DispatchFrontendOptions) {
|
|
166
179
|
this.runId = launchContext(opts.env)?.run ?? crypto.randomUUID()
|
|
167
180
|
this.dispatchStatus = reduceDispatchStatus([], this.runId)
|
|
168
|
-
this.reader = presentationReader(
|
|
181
|
+
this.reader = presentationReader(
|
|
182
|
+
opts.store,
|
|
183
|
+
() => !this.presentationRestored && (this.refresh?.admitted ?? true),
|
|
184
|
+
)
|
|
169
185
|
this.clock = opts.clock ?? systemClock
|
|
170
186
|
this.repositoryFeed = new DispatchRepositoryFeed(this.reader, opts.repo, this.clock)
|
|
171
187
|
this.standbyResolver = new StandbyIdentityResolver(this.reader, opts.repo, {
|
|
@@ -184,7 +200,20 @@ export class DispatchFrontend {
|
|
|
184
200
|
* operator action. High-frequency dispatcher status is folded from deltas;
|
|
185
201
|
* only the low-volume settings/Harvest facts needed by the dashboard model
|
|
186
202
|
* are retained for their existing replay reducers. */
|
|
187
|
-
private async events(): Promise<RepositoryEvent[]> {
|
|
203
|
+
private async events(sampledPosition?: string): Promise<RepositoryEvent[]> {
|
|
204
|
+
if (this.opts.viewer) {
|
|
205
|
+
const position = sampledPosition ?? (await this.reader.getRepoChangePosition(this.opts.repo))
|
|
206
|
+
if (
|
|
207
|
+
position !== this.viewerPosition ||
|
|
208
|
+
this.clock().getTime() - this.viewerReadAt >= 10_000
|
|
209
|
+
) {
|
|
210
|
+
this.viewerFacts = (await readRepositoryFacts(this.reader, this.opts.repo)).value
|
|
211
|
+
this.viewerPosition = position
|
|
212
|
+
this.viewerReadAt = this.clock().getTime()
|
|
213
|
+
}
|
|
214
|
+
this.dispatchStatus = this.viewerFacts!.status ?? reduceDispatchStatus([], this.runId)
|
|
215
|
+
return []
|
|
216
|
+
}
|
|
188
217
|
const refresh = this.eventRefreshTail.then(async () => {
|
|
189
218
|
const delta = await this.repositoryFeed.refresh(false)
|
|
190
219
|
this.standbyResolver.ingest(this.repositoryFeed.identities)
|
|
@@ -269,7 +298,7 @@ export class DispatchFrontend {
|
|
|
269
298
|
detailScrollLimit(
|
|
270
299
|
next,
|
|
271
300
|
dashboardContentWidth(this.opts.terminal.columns),
|
|
272
|
-
|
|
301
|
+
this.contentHeight(),
|
|
273
302
|
),
|
|
274
303
|
),
|
|
275
304
|
),
|
|
@@ -284,14 +313,26 @@ export class DispatchFrontend {
|
|
|
284
313
|
if (this.refresh !== undefined && !this.refresh.painting) return
|
|
285
314
|
if (this.model === undefined) return
|
|
286
315
|
const renderer = this.opts.resolveDashboardRenderer?.() ?? renderDashboard
|
|
287
|
-
this.
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
316
|
+
const lines = renderer(this.model, {
|
|
317
|
+
color: this.opts.plainOutput === undefined,
|
|
318
|
+
width: this.opts.terminal.columns,
|
|
319
|
+
height: paintableRows(this.opts.terminal.rows),
|
|
320
|
+
now: this.clock().getTime(),
|
|
321
|
+
})
|
|
322
|
+
this.outputFrame(lines)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private outputFrame(lines: string[]): void {
|
|
326
|
+
if (this.presentationRestored) return
|
|
327
|
+
if (this.opts.plainOutput) {
|
|
328
|
+
const frame = lines.join('\n')
|
|
329
|
+
if (frame !== this.lastPlainFrame) this.opts.plainOutput(frame)
|
|
330
|
+
this.lastPlainFrame = frame
|
|
331
|
+
} else this.region.update(lines)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private contentHeight(): number {
|
|
335
|
+
return Math.max(0, paintableRows(this.opts.terminal.rows) - (this.opts.viewer ? 1 : 0))
|
|
295
336
|
}
|
|
296
337
|
|
|
297
338
|
private async loadConfig(kind: string, rev: number): Promise<Config> {
|
|
@@ -316,6 +357,7 @@ export class DispatchFrontend {
|
|
|
316
357
|
private readonly repositoryPoll = new RepositoryPollCache<{
|
|
317
358
|
repositoryEvents: RepositoryEvent[]
|
|
318
359
|
upgrades: DispatchUpgradeState
|
|
360
|
+
repositoryFacts: RepositoryReadFacts
|
|
319
361
|
status: DispatchStatus
|
|
320
362
|
config: Config
|
|
321
363
|
observationCount: number
|
|
@@ -324,8 +366,12 @@ export class DispatchFrontend {
|
|
|
324
366
|
|
|
325
367
|
private async readFrame(): Promise<void> {
|
|
326
368
|
if (this.refresh !== undefined && !this.refresh.admitted) return
|
|
369
|
+
let sampledPosition: string | undefined
|
|
327
370
|
const frame = await this.repositoryPoll.refresh({
|
|
328
|
-
position: () =>
|
|
371
|
+
position: async () => {
|
|
372
|
+
sampledPosition = await this.reader.getRepoChangePosition(this.opts.repo)
|
|
373
|
+
return sampledPosition
|
|
374
|
+
},
|
|
329
375
|
now: () => this.clock().getTime(),
|
|
330
376
|
revision: 0,
|
|
331
377
|
enabled: !this.opts.once,
|
|
@@ -333,14 +379,33 @@ export class DispatchFrontend {
|
|
|
333
379
|
admitted: () => this.refresh === undefined || this.refresh.admitted,
|
|
334
380
|
nextPollMs: this.refresh?.intervalMs ?? 0,
|
|
335
381
|
read: async ({ fullEnrichment }) => {
|
|
336
|
-
const repositoryEvents = await this.events()
|
|
382
|
+
const repositoryEvents = await this.events(sampledPosition)
|
|
337
383
|
// Authority and rollback holds need the full durable reduction, not the
|
|
338
384
|
// low-volume replay feed (which deliberately discards per-tick facts).
|
|
339
|
-
const
|
|
385
|
+
const repositoryFacts =
|
|
386
|
+
this.viewerFacts ??
|
|
387
|
+
(
|
|
388
|
+
await readRepositoryFacts(
|
|
389
|
+
this.reader,
|
|
390
|
+
this.opts.repo,
|
|
391
|
+
repositoryEvents.length || this.repositoryFeed.identities.length ? true : undefined,
|
|
392
|
+
)
|
|
393
|
+
).value
|
|
394
|
+
const upgrades = repositoryFacts.upgrades
|
|
340
395
|
const status = this.dispatchStatus
|
|
341
396
|
const ref = status.effectiveConfig
|
|
342
397
|
if (ref === undefined) {
|
|
343
|
-
if (
|
|
398
|
+
if (this.opts.viewer) {
|
|
399
|
+
this.model = undefined
|
|
400
|
+
this.outputFrame(
|
|
401
|
+
renderViewerNotice(
|
|
402
|
+
this.opts.viewer,
|
|
403
|
+
status.warningNotice ?? 'Waiting for dispatcher configuration',
|
|
404
|
+
this.opts.terminal.columns,
|
|
405
|
+
paintableRows(this.opts.terminal.rows),
|
|
406
|
+
),
|
|
407
|
+
)
|
|
408
|
+
} else if (status.health === 'failed' && status.warningNotice !== undefined)
|
|
344
409
|
this.region.update([status.warningNotice])
|
|
345
410
|
// Startup is incomplete: retry at the same position.
|
|
346
411
|
return undefined
|
|
@@ -350,7 +415,7 @@ export class DispatchFrontend {
|
|
|
350
415
|
try {
|
|
351
416
|
observationCount = unclaimedObservationCount({
|
|
352
417
|
digests: await this.reader.getRepoBuildDigests(this.opts.repo),
|
|
353
|
-
harvestEvents: repositoryEvents,
|
|
418
|
+
harvestEvents: this.opts.viewer ? repositoryFacts.harvest : repositoryEvents,
|
|
354
419
|
})
|
|
355
420
|
} catch {
|
|
356
421
|
// Incomplete snapshots never acknowledge the sampled position.
|
|
@@ -360,19 +425,28 @@ export class DispatchFrontend {
|
|
|
360
425
|
}
|
|
361
426
|
this.cache ??= new DashboardBuildPollCache(this.reader, this.opts.repo, config)
|
|
362
427
|
const snapshot = await this.cache.refresh(config, this.configRevision, fullEnrichment)
|
|
363
|
-
if (!this.opts.once)
|
|
428
|
+
if (!this.opts.once && !this.opts.viewer)
|
|
364
429
|
await this.standbyResolver.refresh(this.runId, status.yieldedHolder, this.clock())
|
|
365
|
-
await this.repositoryFeed.save()
|
|
430
|
+
if (!this.opts.viewer) await this.repositoryFeed.save()
|
|
366
431
|
if (!this.cache.isCurrent(snapshot)) return undefined
|
|
367
|
-
return {
|
|
432
|
+
return {
|
|
433
|
+
repositoryEvents,
|
|
434
|
+
repositoryFacts,
|
|
435
|
+
upgrades,
|
|
436
|
+
status,
|
|
437
|
+
config,
|
|
438
|
+
observationCount,
|
|
439
|
+
snapshot,
|
|
440
|
+
}
|
|
368
441
|
},
|
|
369
442
|
})
|
|
370
443
|
if (frame === undefined) return
|
|
371
|
-
let { repositoryEvents, upgrades, status } = frame
|
|
444
|
+
let { repositoryEvents, repositoryFacts, upgrades, status } = frame
|
|
372
445
|
const { config, snapshot } = frame
|
|
373
|
-
const standby =
|
|
374
|
-
|
|
375
|
-
|
|
446
|
+
const standby =
|
|
447
|
+
this.opts.once || this.opts.viewer
|
|
448
|
+
? undefined
|
|
449
|
+
: this.standbyResolver.current(this.runId, status.yieldedHolder, this.clock())
|
|
376
450
|
this.observationCount = frame.observationCount
|
|
377
451
|
this.refresh?.activity(snapshot.states.size > 0)
|
|
378
452
|
|
|
@@ -388,7 +462,14 @@ export class DispatchFrontend {
|
|
|
388
462
|
if (!validAbortConfirmation(snapshot.states.get(slug))) {
|
|
389
463
|
await this.dismissStaleAbortConfirmation(slug)
|
|
390
464
|
repositoryEvents = await this.events()
|
|
391
|
-
|
|
465
|
+
repositoryFacts = (
|
|
466
|
+
await readRepositoryFacts(
|
|
467
|
+
this.reader,
|
|
468
|
+
this.opts.repo,
|
|
469
|
+
repositoryEvents.length || this.repositoryFeed.identities.length ? true : undefined,
|
|
470
|
+
)
|
|
471
|
+
).value
|
|
472
|
+
upgrades = repositoryFacts.upgrades
|
|
392
473
|
status = this.dispatchStatus
|
|
393
474
|
}
|
|
394
475
|
}
|
|
@@ -414,7 +495,9 @@ export class DispatchFrontend {
|
|
|
414
495
|
config.capacity,
|
|
415
496
|
this.clock(),
|
|
416
497
|
migrationIdentity(
|
|
417
|
-
|
|
498
|
+
this.opts.viewer
|
|
499
|
+
? repositoryFacts.ticketMigrations
|
|
500
|
+
: ticketMigrationsReducer.reduce(repositoryEvents),
|
|
418
501
|
config.tickets.source,
|
|
419
502
|
),
|
|
420
503
|
),
|
|
@@ -425,7 +508,7 @@ export class DispatchFrontend {
|
|
|
425
508
|
: {}),
|
|
426
509
|
...(warningLines.length > 0 ? { warningLines } : {}),
|
|
427
510
|
},
|
|
428
|
-
|
|
511
|
+
repositoryFacts,
|
|
429
512
|
upgrades,
|
|
430
513
|
)
|
|
431
514
|
this.selection = reconcileSelection(previous, dashboardSelections(projected), this.selection)
|
|
@@ -435,7 +518,7 @@ export class DispatchFrontend {
|
|
|
435
518
|
) {
|
|
436
519
|
this.view = undefined
|
|
437
520
|
}
|
|
438
|
-
this.model = projected
|
|
521
|
+
this.model = { ...projected, ...(this.opts.viewer ? { viewer: this.opts.viewer } : {}) }
|
|
439
522
|
this.syncControls()
|
|
440
523
|
this.paint()
|
|
441
524
|
// The session view's live-read cycle rides the poll tick: one immediate
|
|
@@ -450,7 +533,7 @@ export class DispatchFrontend {
|
|
|
450
533
|
const limit = sessionScrollLimit(
|
|
451
534
|
view,
|
|
452
535
|
this.opts.terminal.columns,
|
|
453
|
-
|
|
536
|
+
this.contentHeight(),
|
|
454
537
|
upgrade,
|
|
455
538
|
this.model?.standby !== undefined,
|
|
456
539
|
)
|
|
@@ -458,7 +541,7 @@ export class DispatchFrontend {
|
|
|
458
541
|
const scroll = moveSessionScroll(
|
|
459
542
|
view,
|
|
460
543
|
this.opts.terminal.columns,
|
|
461
|
-
|
|
544
|
+
this.contentHeight(),
|
|
462
545
|
current,
|
|
463
546
|
delta,
|
|
464
547
|
upgrade,
|
|
@@ -478,7 +561,7 @@ export class DispatchFrontend {
|
|
|
478
561
|
scroll: moveTranscriptScroll(
|
|
479
562
|
this.view.transcript,
|
|
480
563
|
this.opts.terminal.columns,
|
|
481
|
-
|
|
564
|
+
this.contentHeight(),
|
|
482
565
|
this.view.scroll,
|
|
483
566
|
delta,
|
|
484
567
|
this.model?.availableUpgrade !== undefined,
|
|
@@ -491,7 +574,7 @@ export class DispatchFrontend {
|
|
|
491
574
|
scroll: moveDetailScroll(
|
|
492
575
|
this.model,
|
|
493
576
|
dashboardContentWidth(this.opts.terminal.columns),
|
|
494
|
-
|
|
577
|
+
this.contentHeight(),
|
|
495
578
|
this.view.scroll,
|
|
496
579
|
delta,
|
|
497
580
|
),
|
|
@@ -519,7 +602,7 @@ export class DispatchFrontend {
|
|
|
519
602
|
scroll: revealDetailFocus(
|
|
520
603
|
{ ...this.model!, view: candidate },
|
|
521
604
|
dashboardContentWidth(this.opts.terminal.columns),
|
|
522
|
-
|
|
605
|
+
this.contentHeight(),
|
|
523
606
|
'session',
|
|
524
607
|
candidate.scroll,
|
|
525
608
|
),
|
|
@@ -579,7 +662,7 @@ export class DispatchFrontend {
|
|
|
579
662
|
scroll: revealDetailFocus(
|
|
580
663
|
{ ...this.model!, view: candidate },
|
|
581
664
|
dashboardContentWidth(this.opts.terminal.columns),
|
|
582
|
-
|
|
665
|
+
this.contentHeight(),
|
|
583
666
|
'message',
|
|
584
667
|
candidate.scroll,
|
|
585
668
|
),
|
|
@@ -643,7 +726,7 @@ export class DispatchFrontend {
|
|
|
643
726
|
const limit = sessionScrollLimit(
|
|
644
727
|
next,
|
|
645
728
|
terminal.columns,
|
|
646
|
-
|
|
729
|
+
this.contentHeight(),
|
|
647
730
|
this.model?.availableUpgrade !== undefined,
|
|
648
731
|
this.model?.standby !== undefined,
|
|
649
732
|
)
|
|
@@ -1006,29 +1089,32 @@ export class DispatchFrontend {
|
|
|
1006
1089
|
},
|
|
1007
1090
|
this.opts.refreshScheduler,
|
|
1008
1091
|
this.opts.store.networkReads,
|
|
1092
|
+
this.opts.viewer ? this.opts.intervalMs : undefined,
|
|
1009
1093
|
)
|
|
1010
|
-
this.listen()
|
|
1011
|
-
this.opts.terminal.modes.enter(FOCUS_REPORTING_MODE)
|
|
1012
|
-
this.
|
|
1013
|
-
this.
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
this.paintTimer.
|
|
1094
|
+
if (!this.opts.plainOutput) this.listen()
|
|
1095
|
+
if (!this.opts.plainOutput) this.opts.terminal.modes.enter(FOCUS_REPORTING_MODE)
|
|
1096
|
+
if (!this.opts.plainOutput)
|
|
1097
|
+
this.suspension = installPresentationSuspension(
|
|
1098
|
+
this.opts.terminal.modes,
|
|
1099
|
+
() => {
|
|
1100
|
+
this.refresh?.suspend()
|
|
1101
|
+
this.cleanupInput?.()
|
|
1102
|
+
this.cleanupInput = undefined
|
|
1103
|
+
},
|
|
1104
|
+
() => {
|
|
1105
|
+
this.listen()
|
|
1106
|
+
this.region.invalidate()
|
|
1107
|
+
this.refresh?.resume()
|
|
1108
|
+
},
|
|
1109
|
+
)
|
|
1110
|
+
if (!this.opts.plainOutput) this.paintTimer = setInterval(() => this.paint(), PAINT_MS)
|
|
1111
|
+
this.paintTimer?.unref?.()
|
|
1027
1112
|
void this.refresh.request()
|
|
1028
1113
|
}
|
|
1029
1114
|
|
|
1030
1115
|
private requestOperatorStop(): void {
|
|
1031
1116
|
this.operatorStopRequested = true
|
|
1117
|
+
this.viewerStopped?.()
|
|
1032
1118
|
this.restorePresentationForStop()
|
|
1033
1119
|
void this.child?.stop(
|
|
1034
1120
|
typeof this.opts.signal?.reason === 'string' ? this.opts.signal.reason : undefined,
|
|
@@ -1082,7 +1168,47 @@ export class DispatchFrontend {
|
|
|
1082
1168
|
}
|
|
1083
1169
|
}
|
|
1084
1170
|
|
|
1171
|
+
private async runViewer(): Promise<void> {
|
|
1172
|
+
// Viewing has no repository creation, lease, child, or dispatcher lifecycle writes.
|
|
1173
|
+
if (this.opts.plainOutput) this.opts.plainOutput(viewerIndicator(this.opts.viewer!, 1000))
|
|
1174
|
+
if (this.opts.signal?.aborted) return
|
|
1175
|
+
const stopped = new Promise<void>((resolve) => {
|
|
1176
|
+
this.viewerStopped = resolve
|
|
1177
|
+
})
|
|
1178
|
+
const stop = () => this.requestOperatorStop()
|
|
1179
|
+
// A pending Promise and the adaptive scheduler's unref timers do not keep
|
|
1180
|
+
// a plain viewer alive. This timer owns only the presentation lifetime.
|
|
1181
|
+
const lifetime = setInterval(() => {}, 60_000)
|
|
1182
|
+
this.opts.signal?.addEventListener('abort', stop, { once: true })
|
|
1183
|
+
try {
|
|
1184
|
+
await this.readFrame()
|
|
1185
|
+
if (!this.opts.once && !this.operatorStopRequested) {
|
|
1186
|
+
this.startPresentation()
|
|
1187
|
+
await stopped
|
|
1188
|
+
}
|
|
1189
|
+
} catch (error) {
|
|
1190
|
+
if (this.operatorStopRequested) return
|
|
1191
|
+
this.outputFrame(
|
|
1192
|
+
renderViewerNotice(
|
|
1193
|
+
this.opts.viewer!,
|
|
1194
|
+
`Viewer unavailable: ${error instanceof Error ? error.message : String(error)}`,
|
|
1195
|
+
this.opts.terminal.columns,
|
|
1196
|
+
paintableRows(this.opts.terminal.rows),
|
|
1197
|
+
),
|
|
1198
|
+
)
|
|
1199
|
+
throw error
|
|
1200
|
+
} finally {
|
|
1201
|
+
clearInterval(lifetime)
|
|
1202
|
+
this.opts.signal?.removeEventListener('abort', stop)
|
|
1203
|
+
this.restorePresentationForStop()
|
|
1204
|
+
await this.refresh?.join()
|
|
1205
|
+
await this.actionTail
|
|
1206
|
+
this.viewerStopped = undefined
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1085
1210
|
async run(): Promise<void> {
|
|
1211
|
+
if (this.opts.viewer) return this.runViewer()
|
|
1086
1212
|
await this.opts.store.ensureRepo(this.opts.repo)
|
|
1087
1213
|
const actor = humanActor(buildControlUser(this.opts.env))
|
|
1088
1214
|
if (this.opts.intake !== undefined) {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Exec } from '../ports/workspace/git-worktree'
|
|
2
|
+
import type { DispatchPlacement } from '../kernel/dispatch-placement'
|
|
3
|
+
import { RemoteBuildStore } from '../store/remote/client'
|
|
4
|
+
import { resolveRepoState, isRemoteStoreRef } from './repo-state'
|
|
5
|
+
import { projectToken } from './project-credentials'
|
|
6
|
+
|
|
7
|
+
export const TAKEOVER_WARNING =
|
|
8
|
+
'Warning: --takeover dispatches locally and can displace the hosted dispatcher.'
|
|
9
|
+
|
|
10
|
+
export class DispatchPlacementStartupError extends Error {
|
|
11
|
+
readonly code = 'DISPATCH_PLACEMENT_UNREADABLE'
|
|
12
|
+
constructor(cause: unknown, secrets: string[] = []) {
|
|
13
|
+
let detail = cause instanceof Error ? cause.message : String(cause)
|
|
14
|
+
for (const secret of secrets) if (secret) detail = detail.split(secret).join('[redacted]')
|
|
15
|
+
detail = detail.replace(/https?:\/\/[^\s]+/g, (url) => {
|
|
16
|
+
try {
|
|
17
|
+
const parsed = new URL(url)
|
|
18
|
+
return `${parsed.origin}${parsed.pathname}`
|
|
19
|
+
} catch {
|
|
20
|
+
return '[redacted URL]'
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
super(
|
|
24
|
+
`Cannot read dispatch placement: ${detail}. Use --viewer to watch, or --takeover to dispatch locally and potentially displace hosted dispatch.`,
|
|
25
|
+
{ cause },
|
|
26
|
+
)
|
|
27
|
+
this.name = 'DispatchPlacementStartupError'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DispatchModeOptions {
|
|
32
|
+
viewer?: boolean
|
|
33
|
+
takeover?: boolean
|
|
34
|
+
dispatchedBy?: string
|
|
35
|
+
repository?: string
|
|
36
|
+
intake?: boolean
|
|
37
|
+
targetRepo: string
|
|
38
|
+
repo?: string
|
|
39
|
+
storeRef?: string
|
|
40
|
+
env: Record<string, string | undefined>
|
|
41
|
+
exec: Exec
|
|
42
|
+
stderr: (message: string) => void
|
|
43
|
+
}
|
|
44
|
+
export interface PlacementReader {
|
|
45
|
+
getDispatchPlacement(repo: string): Promise<DispatchPlacement>
|
|
46
|
+
close(): Promise<void>
|
|
47
|
+
}
|
|
48
|
+
export async function selectDispatchMode(
|
|
49
|
+
opts: DispatchModeOptions,
|
|
50
|
+
deps: {
|
|
51
|
+
resolve?: typeof resolveRepoState
|
|
52
|
+
open?: (url: string, token: string | undefined) => PlacementReader
|
|
53
|
+
} = {},
|
|
54
|
+
): Promise<{ viewer: boolean; dispatchedBy?: string }> {
|
|
55
|
+
if (opts.viewer && opts.takeover) throw new Error('--viewer and --takeover cannot be combined')
|
|
56
|
+
if (opts.viewer)
|
|
57
|
+
return {
|
|
58
|
+
viewer: true,
|
|
59
|
+
...(opts.dispatchedBy !== undefined ? { dispatchedBy: opts.dispatchedBy } : {}),
|
|
60
|
+
}
|
|
61
|
+
if (opts.repository || opts.env.AB_REPOSITORY?.trim()) return { viewer: false }
|
|
62
|
+
if (opts.takeover) {
|
|
63
|
+
opts.stderr(TAKEOVER_WARNING)
|
|
64
|
+
return { viewer: false }
|
|
65
|
+
}
|
|
66
|
+
let token: string | undefined
|
|
67
|
+
let placement: DispatchPlacement
|
|
68
|
+
try {
|
|
69
|
+
const state = await (deps.resolve ?? resolveRepoState)({
|
|
70
|
+
targetRepo: opts.targetRepo,
|
|
71
|
+
exec: opts.exec,
|
|
72
|
+
...(opts.storeRef !== undefined ? { storeRef: opts.storeRef } : {}),
|
|
73
|
+
...(opts.env.AB_STORE !== undefined ? { envStore: opts.env.AB_STORE } : {}),
|
|
74
|
+
})
|
|
75
|
+
if (!isRemoteStoreRef(state.storeRef)) return { viewer: false }
|
|
76
|
+
const repo = opts.repo ?? state.repo
|
|
77
|
+
token = projectToken(state.storeRef, repo, opts.env)
|
|
78
|
+
const reader = (deps.open ?? ((url, token) => new RemoteBuildStore({ url, token })))(
|
|
79
|
+
state.storeRef,
|
|
80
|
+
token,
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
placement = await reader.getDispatchPlacement(repo)
|
|
84
|
+
} finally {
|
|
85
|
+
await reader.close()
|
|
86
|
+
}
|
|
87
|
+
} catch (cause) {
|
|
88
|
+
throw new DispatchPlacementStartupError(cause, [token ?? '', opts.env.AB_TOKEN ?? ''])
|
|
89
|
+
}
|
|
90
|
+
if (placement.status !== 'known' || !placement.placement.hosted) return { viewer: false }
|
|
91
|
+
if (opts.intake !== undefined)
|
|
92
|
+
throw new Error('--viewer cannot set startup intake; use --takeover to dispatch locally')
|
|
93
|
+
return { viewer: true, dispatchedBy: new URL(placement.placement.origin).host }
|
|
94
|
+
}
|