agl 43.3.2 → 43.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.
Files changed (76) hide show
  1. package/changelog.md +12 -0
  2. package/dist_serve/bundle.js +1377 -1375
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_ts/00_commitinfo_data.js +1 -1
  5. package/dist_ts/aglapi/interfaces.d.ts +5 -0
  6. package/dist_ts/aglapi/interfaces.js +2 -1
  7. package/dist_ts/classes.authstore.js +5 -2
  8. package/dist_ts/classes.claudeharness.js +4 -3
  9. package/dist_ts/classes.codexclientadapter.d.ts +5 -0
  10. package/dist_ts/classes.codexclientadapter.js +12 -6
  11. package/dist_ts/classes.controller.d.ts +22 -5
  12. package/dist_ts/classes.controller.js +149 -61
  13. package/dist_ts/classes.mcpclient.d.ts +2 -2
  14. package/dist_ts/classes.mcpclient.js +14 -9
  15. package/dist_ts/classes.mcptools.d.ts +1 -1
  16. package/dist_ts/classes.mcptools.js +2 -1
  17. package/dist_ts/classes.opencodeclient.js +20 -4
  18. package/dist_ts/driver/functions.driverinstructions.d.ts +1 -1
  19. package/dist_ts/driver/functions.driverinstructions.js +2 -1
  20. package/dist_ts/fleet/classes.deploymodels.d.ts +58 -1
  21. package/dist_ts/fleet/classes.deploymodels.js +121 -2
  22. package/dist_ts/fleet/classes.deploymonitor.d.ts +193 -47
  23. package/dist_ts/fleet/classes.deploymonitor.js +548 -180
  24. package/dist_ts/fleet/classes.gitfacts.d.ts +4 -1
  25. package/dist_ts/fleet/classes.gitfacts.js +13 -10
  26. package/dist_ts/fleet/classes.service.d.ts +2 -0
  27. package/dist_ts/fleet/classes.service.js +6 -3
  28. package/dist_ts/fleet/functions.deployprobes.js +21 -2
  29. package/dist_ts/fleet/functions.deploystatus.d.ts +26 -0
  30. package/dist_ts/fleet/functions.deploystatus.js +33 -0
  31. package/dist_ts/fleet/functions.deployvalidation.d.ts +1 -0
  32. package/dist_ts/fleet/functions.deployvalidation.js +5 -2
  33. package/dist_ts/functions.deploycli.js +3 -2
  34. package/dist_ts/functions.deviceapi.d.ts +7 -6
  35. package/dist_ts/functions.deviceapi.js +13 -5
  36. package/dist_ts/functions.mcpdeploytools.js +3 -1
  37. package/dist_ts/functions.promptreply.d.ts +13 -0
  38. package/dist_ts/functions.promptreply.js +17 -0
  39. package/dist_ts_interfaces/deployments.d.ts +38 -6
  40. package/dist_ts_interfaces/deployments.js +7 -3
  41. package/dist_ts_interfaces/devices.d.ts +2 -1
  42. package/dist_ts_interfaces/devices.js +1 -1
  43. package/dist_ts_interfaces/inbox.d.ts +10 -1
  44. package/dist_ts_interfaces/inbox.js +1 -1
  45. package/dist_ts_interfaces/mcprequests.d.ts +1 -1
  46. package/package.json +1 -1
  47. package/readme.md +29 -11
  48. package/ts/00_commitinfo_data.ts +1 -1
  49. package/ts/aglapi/interfaces.ts +1 -0
  50. package/ts/classes.authstore.ts +4 -1
  51. package/ts/classes.claudeharness.ts +3 -2
  52. package/ts/classes.codexclientadapter.ts +11 -5
  53. package/ts/classes.controller.ts +161 -72
  54. package/ts/classes.mcpclient.ts +14 -5
  55. package/ts/classes.mcptools.ts +1 -0
  56. package/ts/classes.opencodeclient.ts +23 -3
  57. package/ts/driver/functions.driverinstructions.ts +1 -0
  58. package/ts/fleet/classes.deploymodels.ts +113 -1
  59. package/ts/fleet/classes.deploymonitor.ts +565 -179
  60. package/ts/fleet/classes.gitfacts.ts +10 -8
  61. package/ts/fleet/classes.service.ts +7 -1
  62. package/ts/fleet/functions.deployprobes.ts +16 -1
  63. package/ts/fleet/functions.deploystatus.ts +56 -0
  64. package/ts/fleet/functions.deployvalidation.ts +4 -1
  65. package/ts/functions.deploycli.ts +2 -1
  66. package/ts/functions.deviceapi.ts +19 -9
  67. package/ts/functions.mcpdeploytools.ts +2 -0
  68. package/ts/functions.promptreply.ts +20 -0
  69. package/ts_interfaces/deployments.ts +39 -6
  70. package/ts_interfaces/devices.schema.json +1 -1
  71. package/ts_interfaces/devices.ts +2 -1
  72. package/ts_interfaces/inbox.ts +8 -1
  73. package/ts_web/00_commitinfo_data.ts +1 -1
  74. package/ts_web/elements.deployments.ts +20 -4
  75. package/ts_web/elements.harnesscontrollerapp.ts +43 -13
  76. package/ts_web/elements.inbox.ts +3 -3
@@ -53,19 +53,21 @@ export class FleetGitFacts {
53
53
  return result.code === 0 ? undefined : (result.stderr.trim() || `git fetch exited with ${result.code}`).slice(0, 512);
54
54
  }
55
55
 
56
- /** Remote main and the remote's release tags as the last fetch mirrored them. */
56
+ /**
57
+ * Remote main and the remote's release tags as the last fetch mirrored them. Remote main is absent before the first
58
+ * fetch; tags that cannot be listed throw, since no release is not the same as releases that could not be read.
59
+ */
57
60
  public async remote(repoArg: IFleetRepository): Promise<IFleetRemoteState> {
58
61
  const main = await this.git('git', ['rev-parse', '--verify', '--quiet', `${fleetRemoteMainRef}^{commit}`], repoArg.path);
59
62
  const tags = await this.git('git', ['for-each-ref', '--format=%(refname:lstrip=3)%09%(objectname)%09%(*objectname)%09%(creatordate:iso-strict)',
60
63
  `${fleetRemoteTagRefs}/v*`], repoArg.path);
64
+ if (tags.code !== 0) throw new Error((tags.stderr.trim() || `git for-each-ref exited with ${tags.code}`).slice(0, 512));
61
65
  const releases: IFleetDeployRelease[] = [];
62
- if (tags.code === 0) {
63
- for (const line of tags.stdout.split('\n')) {
64
- const [name = '', object = '', peeled = '', taggedAt = ''] = line.split('\t');
65
- const version = fleetVersion(name);
66
- if (!version || !name.startsWith('v')) continue;
67
- releases.push({ version, sha: peeled || object, ...(taggedAt ? { taggedAt: new Date(taggedAt).toISOString() } : {}) });
68
- }
66
+ for (const line of tags.stdout.split('\n')) {
67
+ const [name = '', object = '', peeled = '', taggedAt = ''] = line.split('\t');
68
+ const version = fleetVersion(name);
69
+ if (!version || !name.startsWith('v')) continue;
70
+ releases.push({ version, sha: peeled || object, ...(taggedAt ? { taggedAt: new Date(taggedAt).toISOString() } : {}) });
69
71
  }
70
72
  const sha = main.code === 0 ? main.stdout.trim() : '';
71
73
  return { ...(fullSha.test(sha) ? { main: sha } : {}), releases: releases.sort((leftArg, rightArg) => compareFleetVersions(rightArg.version, leftArg.version)) };
@@ -22,6 +22,8 @@ export interface IFleetServiceOptions {
22
22
  tickets?: (signal: AbortSignal) => Promise<ITicket[]>;
23
23
  /** A release went out: the release reconciler links and releases the landed tickets its tag holds, now rather than at its next pass. */
24
24
  released?: (repo: IFleetRepository) => void;
25
+ /** A landing pushed remote main: the deploy status says what the next release ships from it now rather than at its next pass. */
26
+ landed?: (repo: IFleetRepository) => void;
25
27
  }
26
28
  interface IFleetOwnedOperation { owner: string; snapshot: IFleetOperation; completion: Promise<void> }
27
29
  const queues = new Map<string, Promise<unknown>>();
@@ -131,7 +133,11 @@ export class FleetService {
131
133
  const repo = withHostEnvironment(repositories[0]!, configuration.environment);
132
134
  return this.exclusive(runtime, repo, async () => {
133
135
  running();
134
- if (operation === 'land') return await this.land(runtime, repo, input as IFleetLandRequest) as TFleetResult<T>;
136
+ if (operation === 'land') {
137
+ const landing = await this.land(runtime, repo, input as IFleetLandRequest);
138
+ this.options.landed?.(repo);
139
+ return landing as TFleetResult<T>;
140
+ }
135
141
  if (operation === 'tooling') return await toolingFleetRepository(runtime, repo, input as TFleetRequest<'tooling'>) as TFleetResult<T>;
136
142
  const release = await releaseFleetRepository(runtime, repo, input as TFleetRequest<'release'>, {},
137
143
  await this.releaseGuard(runtime, repo, input as TFleetRequest<'release'>));
@@ -60,6 +60,21 @@ export const readJsonPointer = (valueArg: unknown, pointerArg: string): unknown
60
60
 
61
61
  export type TFleetDeployProbeResult = { state: 'up'; version: string; sha?: string } | { state: 'down'; error: string };
62
62
 
63
+ /**
64
+ * A probe's failure text without its URL's query and fragment (AGL-1704): the Configuration master may give a probe a
65
+ * token there, and the text reaches the views, the stored deploy status and the driver. The URL is named without them.
66
+ */
67
+ const probeErrorWithoutSecrets = (textArg: string, urlArg: string): string => {
68
+ if (!URL.canParse(urlArg)) return textArg.replaceAll(urlArg, 'the probe URL');
69
+ const url = new URL(urlArg);
70
+ const shown = new URL(urlArg);
71
+ shown.search = ''; shown.hash = '';
72
+ let text = textArg;
73
+ for (const full of new Set([urlArg, url.href])) text = text.replaceAll(full, shown.href);
74
+ for (const part of [url.search, url.hash]) if (part.length > 1) text = text.replaceAll(part, '');
75
+ return text;
76
+ };
77
+
63
78
  /**
64
79
  * Asks an HTTP target what it runs: a GET of its URL, the version at `versionPointer` (default `/version`) and the commit
65
80
  * at `shaPointer`. An error status, an answer that is no JSON or holds no semantic version is down, with the reason.
@@ -71,7 +86,7 @@ export const probeFleetHttpTarget = async (probeArg: Extract<TFleetDeployProbe,
71
86
  try { answer = await fetchFleetProbe(probeArg.url, optionsArg, { json: true, redirect: 'error' }); }
72
87
  catch (errorArg) {
73
88
  optionsArg.signal.throwIfAborted();
74
- return { state: 'down', error: fleetProbeErrorText(errorArg).slice(0, 1024) };
89
+ return { state: 'down', error: probeErrorWithoutSecrets(fleetProbeErrorText(errorArg), probeArg.url).slice(0, 1024) };
75
90
  }
76
91
  if (answer.status >= 400) return { state: 'down', error: `HTTP ${answer.status}` };
77
92
  const pointer = probeArg.versionPointer ?? '/version';
@@ -0,0 +1,56 @@
1
+ import type {
2
+ IFleetDeployPlan, IFleetDeployStatus, IFleetDeployTargetStatus, IFleetDeployWindow, TFleetMaintenanceWindowState,
3
+ } from '../../ts_interfaces/deployments.js';
4
+ import type { TDeployStatusContent, TDeployStoredPlan, TDeployStoredTarget, TDeployStoredWindow } from './classes.deploymodels.js';
5
+
6
+ /**
7
+ * What the deploy monitor computed, as the views read it at a moment (AGL-1704): the stored content and when it was
8
+ * computed. Where a window stands, whether a deploy may run and the busy sessions depend on the clock and the sessions,
9
+ * never on what was computed, so they are derived here when read, never stored.
10
+ */
11
+ export interface IDeployStatusModel {
12
+ computedAt: string;
13
+ content: TDeployStatusContent;
14
+ }
15
+
16
+ /** Where a maintenance window stands at `nowArg`: before it, in it, or after it. */
17
+ export const deployWindowState = (windowArg: Pick<TDeployStoredWindow, 'from' | 'to'>, nowArg: number): TFleetMaintenanceWindowState => (
18
+ nowArg < Date.parse(windowArg.from) ? 'scheduled' : nowArg < Date.parse(windowArg.to) ? 'active' : 'done'
19
+ );
20
+
21
+ /** A stored window as the views show it at `nowArg`. */
22
+ export const deployWindowAt = (windowArg: TDeployStoredWindow, nowArg: number): IFleetDeployWindow => ({
23
+ ...structuredClone(windowArg), state: deployWindowState(windowArg, nowArg),
24
+ });
25
+
26
+ /** The windows planned for a target that have not ended, the earliest first as `windowsArg` lists them. */
27
+ export const deployTargetWindows = (windowsArg: IFleetDeployWindow[], targetIdArg: string): IFleetDeployWindow[] => (
28
+ windowsArg.filter((windowArg) => windowArg.state !== 'done' && windowArg.targets.includes(targetIdArg))
29
+ );
30
+
31
+ /** A target's deploy plans, each queued for `window` into the next window the owner gave for the target. */
32
+ export const deployPlansAt = (plansArg: TDeployStoredPlan[], targetWindowsArg: IFleetDeployWindow[]): IFleetDeployPlan[] => {
33
+ const next = targetWindowsArg.find((windowArg) => windowArg.go === 'given');
34
+ return plansArg.map((planArg) => ({ ...structuredClone(planArg), ...(planArg.go === 'window' && next ? { window: structuredClone(next) } : {}) }));
35
+ };
36
+
37
+ /**
38
+ * A stored target as the views show it, given every window at the moment read and the busy sessions: any time; in a
39
+ * window, open while one the owner gave is active; the AGL controller when no session is busy (AGL-909).
40
+ */
41
+ export const deployTargetAt = (targetArg: TDeployStoredTarget, windowsArg: IFleetDeployWindow[], busySessionsArg: number): IFleetDeployTargetStatus => {
42
+ const { deployPlans, ...stored } = targetArg;
43
+ const windows = deployTargetWindows(windowsArg, targetArg.target.id);
44
+ const busySessions = targetArg.deployWhen === 'idle' ? busySessionsArg : undefined;
45
+ const deployOpen = targetArg.deployWhen === 'anytime'
46
+ || (targetArg.deployWhen === 'window' ? windows.some((windowArg) => windowArg.state === 'active' && windowArg.go === 'given') : busySessions === 0);
47
+ return { ...structuredClone(stored), ...(busySessions === undefined ? {} : { busySessions }), deployOpen, windows: structuredClone(windows),
48
+ deployPlans: deployPlansAt(deployPlans, windows) };
49
+ };
50
+
51
+ /** The deploy status at `nowArg` with `busySessionsArg` sessions busy, from what was computed; it reads nothing else. */
52
+ export const deployStatusAt = (modelArg: IDeployStatusModel, nowArg: number, busySessionsArg: number): IFleetDeployStatus => {
53
+ const windows = modelArg.content.status.windows.map((windowArg) => deployWindowAt(windowArg, nowArg));
54
+ return { checkedAt: modelArg.computedAt, targets: modelArg.content.status.targets.map((targetArg) => deployTargetAt(targetArg, windows, busySessionsArg)),
55
+ windows };
56
+ };
@@ -11,6 +11,7 @@ export const fleetDeployRequestSchemas = {
11
11
  probe: plugins.z.object({ targetId }).strict(),
12
12
  release: plugins.z.object({ repo: plugins.z.string().min(1).max(1024).refine((valueArg) => !/[\0\r\n]/u.test(valueArg)).optional() }).strict(),
13
13
  ticket: plugins.z.object({ ticketKey: plugins.z.string().regex(/^AGL-[1-9][0-9]*$/u) }).strict(),
14
+ refresh: plugins.z.object({}).strict(),
14
15
  } as const satisfies Record<TFleetDeployOperation, plugins.z.ZodType>;
15
16
 
16
17
  export const assertFleetDeployRequest = <TOperation extends TFleetDeployOperation>(
@@ -37,7 +38,8 @@ export const assertFleetDeployResponse = (methodArg: string, valueArg: unknown):
37
38
  probe: plugins.z.object({ state: plugins.z.enum(['up', 'down', 'unknown']) }).passthrough() }).passthrough();
38
39
  const schemas = {
39
40
  status: plugins.z.object({ checkedAt: plugins.z.string(), targets: plugins.z.array(target),
40
- windows: plugins.z.array(plugins.z.object({ key: plugins.z.string(), from: plugins.z.string(), to: plugins.z.string() }).passthrough()) }).strict(),
41
+ windows: plugins.z.array(plugins.z.object({ key: plugins.z.string(), from: plugins.z.string(), to: plugins.z.string() }).passthrough()),
42
+ failure: plugins.z.object({ at: plugins.z.string(), message: plugins.z.string(), reference: plugins.z.string() }).strict().optional() }).strict(),
41
43
  history: plugins.z.object({ targetId, observations: plugins.z.array(plugins.z.object({ targetId, version: plugins.z.string(),
42
44
  observedAt: plugins.z.string() }).passthrough()) }).strict(),
43
45
  probe: target,
@@ -45,6 +47,7 @@ export const assertFleetDeployResponse = (methodArg: string, valueArg: unknown):
45
47
  id: plugins.z.string() }).passthrough()) }).strict(),
46
48
  ticket: plugins.z.object({ ticketKey: plugins.z.string(), landed: plugins.z.array(plugins.z.unknown()), runs: plugins.z.array(plugins.z.unknown()),
47
49
  foundIn: plugins.z.array(plugins.z.unknown()) }).passthrough(),
50
+ refresh: plugins.z.object({ state: plugins.z.enum(['refreshed', 'refreshing']), checkedAt: plugins.z.string().optional() }).strict(),
48
51
  };
49
52
  schemas[operation].parse(valueArg);
50
53
  };
@@ -114,7 +114,8 @@ export const deployStatusLines = (statusArg: IFleetDeployStatus): string[] => [.
114
114
  deployWhenText(targetArg),
115
115
  targetArg.deployPlans.map(deployPlanText).join('; ') || '-',
116
116
  ]),
117
- ]), ...windowLines(statusArg.windows)];
117
+ ]), ...windowLines(statusArg.windows), ...(statusArg.failure ? ['', `The last check failed at ${minute(statusArg.failure.at)}: ${statusArg.failure.message} `
118
+ + `What is shown is from ${minute(statusArg.checkedAt)}. (ref ${statusArg.failure.reference})`] : [])];
118
119
 
119
120
  export const deployHistoryLines = (historyArg: { targetId: string; observations: IFleetDeployObservation[] }): string[] => (
120
121
  historyArg.observations.length ? historyArg.observations.map((observationArg) => [minute(observationArg.observedAt), observationArg.version,
@@ -121,6 +121,7 @@ import { ticketColumns, ticketAutoLabels, type ticketErrorMessages } from '../ts
121
121
  import type { TAuthErrorCode } from './interfaces.auth.js';
122
122
  import { configurationErrorCodes, type TConfigurationErrorCode } from './configuration/classes.configurationerror.js';
123
123
  import type { ControllerElicitationReplyError } from './functions.elicitation.js';
124
+ import type { ControllerPromptReplyError } from './functions.promptreply.js';
124
125
  import type { FleetNativeTurnError } from './fleet/interfaces.workers.js';
125
126
  import type { TClaudeDispatchRefusal } from './classes.claudeharness.js';
126
127
  import type { INativeSessionFailedErrorData } from './classes.nativesessions.js';
@@ -178,14 +179,15 @@ export const deviceRefusalCodes: ReadonlySet<string> = new Set([...Object.keys({
178
179
  /**
179
180
  * Every code the controller refuses a device's request with before the device error translation: the codes of the
180
181
  * typed errors `asTypedResponseError` passes on as their own (the auth store's, the configuration authority's, an
181
- * elicitation reply's, a native Codex turn's), the codes it gives the others (`controller_operation_failed` for a fault
182
- * under a failure journal reference), and the codes the browser's shared functions a device runs refuse with (session
183
- * reads and sends, native sessions, answers, direct children).
182
+ * elicitation reply's, a permission or question reply's, a native Codex turn's), the codes it gives the others
183
+ * (`controller_operation_failed` for a fault under a failure journal reference), and the codes the browser's shared
184
+ * functions a device runs refuse with (session reads and sends, native sessions, answers, direct children).
184
185
  */
185
186
  export type TControllerRefusalCode =
186
187
  | TAuthErrorCode
187
188
  | TConfigurationErrorCode
188
189
  | ControllerElicitationReplyError['code']
190
+ | ControllerPromptReplyError['code']
189
191
  | FleetNativeTurnError['code']
190
192
  | typeof controllerOperationFailedErrorCode
191
193
  | 'concurrent_change'
@@ -268,7 +270,8 @@ export const deviceControllerRefusals: Readonly<Record<Exclude<TControllerRefusa
268
270
  // The configuration authority the driver, the direct reports and the deploy monitor read.
269
271
  invalid_argument: 'controller_failed',
270
272
  conflict: 'concurrent_change',
271
- // A prompt answered or withdrawn meanwhile (a native session's, an elicitation's), or a configuration record gone.
273
+ // An elicitation answered or withdrawn meanwhile, or a configuration record gone (a permission or question the session
274
+ // no longer holds is refused `concurrent_change` already).
272
275
  not_found: 'concurrent_change',
273
276
  unsupported: 'controller_failed',
274
277
  unbound: 'controller_unavailable',
@@ -666,8 +669,8 @@ const deviceAuthorityUnavailable: Readonly<Record<Exclude<TControllerAuthorityDa
666
669
 
667
670
  /** What `device.host.get` reads besides the AGL and the device, each section from its owner. */
668
671
  export interface IDeviceHostSources {
669
- /** The deploy monitor's status of every target, as the Deployments view reads it; never a probe. */
670
- deployStatus: () => Promise<IFleetDeployStatus>;
672
+ /** The deploy monitor's stored status of every target, as the Deployments view reads it; never a probe. */
673
+ deployStatus: (signalArg: AbortSignal) => Promise<IFleetDeployStatus>;
671
674
  /** The inference proxy's pools; absent while no proxy runs here. */
672
675
  capacity: ((signalArg: AbortSignal) => Promise<IProxyCapacityAnswer>) | undefined;
673
676
  /** The accounts service as the controller holds it. */
@@ -720,10 +723,12 @@ const readDeviceApiKeys = async (sourcesArg: Pick<IDeviceHostSources, 'authority
720
723
 
721
724
  /**
722
725
  * Why a section's owner did not answer, when that is a state of the host rather than a fault: the configuration
723
- * service the deploy monitor reads its targets from, or the inference proxy and the accounts service behind it.
726
+ * service the deploy monitor reads its targets from, or the inference proxy and the accounts service behind it. A
727
+ * deploy monitor whose first computation still runs or failed is running (AGL-1704): it reads as `failed`, with the
728
+ * monitor's own reference when it failed (see `readDeviceSection`).
724
729
  */
725
730
  const deviceHostUnavailableReason = (errorArg: unknown): Exclude<TDeviceHostUnavailableReason, 'failed'> | undefined => {
726
- if (errorArg instanceof DeployError) return errorArg.code === 'deploy_unavailable' ? 'not_running' : undefined;
731
+ if (errorArg instanceof DeployError) return errorArg.unavailable === 'not_running' ? 'not_running' : undefined;
727
732
  if (errorArg instanceof AglProxyUnavailableError) return 'not_running';
728
733
  if (errorArg instanceof AglProxyRefusedError) return errorArg.code === 'authority_unavailable' ? 'not_running' : undefined;
729
734
  if (errorArg instanceof AglProxyOutdatedError) return 'outdated';
@@ -744,6 +749,11 @@ const readDeviceSection = async <T>(operationArg: string, whatArg: string, signa
744
749
  if (signalArg.aborted) throw errorArg;
745
750
  const reason = deviceHostUnavailableReason(errorArg);
746
751
  if (reason !== undefined) return { state: 'unavailable', reason };
752
+ // A deploy monitor without a stored status (AGL-1704) is no fault of this read: nothing is journaled. A first
753
+ // computation that failed was journaled once by the monitor, whose reference the device gets; one that still runs has none.
754
+ if (errorArg instanceof DeployError && errorArg.unavailable) {
755
+ return { state: 'unavailable', reason: 'failed', ...(errorArg.reference ? { reference: errorArg.reference } : {}) };
756
+ }
747
757
  const reference = controllerFailureJournal.record({ operation: operationArg, cause: errorArg });
748
758
  console.error(`Reading ${whatArg} for a device failed (ref ${reference}):`, errorArg);
749
759
  return { state: 'unavailable', reason: 'failed', reference };
@@ -759,7 +769,7 @@ const readDeviceHostSection = <T>(sectionArg: string, signalArg: AbortSignal,
759
769
  export const readDeviceHostSections = async (sourcesArg: IDeviceHostSources, nowArg: number, signalArg: AbortSignal):
760
770
  Promise<Pick<IReq_DeviceHostGet['response'], 'deploys' | 'pools' | 'apiKeys'>> => {
761
771
  const [deploys, pools, apiKeys] = await Promise.all([
762
- readDeviceHostSection<IDeviceHostDeploys>('deploys', signalArg, async () => deviceHostDeploys(await sourcesArg.deployStatus())),
772
+ readDeviceHostSection<IDeviceHostDeploys>('deploys', signalArg, async () => deviceHostDeploys(await sourcesArg.deployStatus(signalArg))),
763
773
  readDeviceHostSection<IDeviceHostPools>('pools', signalArg, async () => (
764
774
  sourcesArg.capacity === undefined ? { state: 'unavailable', reason: 'not_running' } : deviceHostPools(await sourcesArg.capacity(signalArg))
765
775
  )),
@@ -13,6 +13,8 @@ export const deployToolDefinitions: readonly { name: string; operation: TFleetDe
13
13
  description: 'The versions a deploy target ran, newest first: one observation each time its probe answered another version, with the version before it (a newer one means a rollback).' },
14
14
  { name: 'deploy_probe', operation: 'probe', readOnly: false, inputSchema: fleetDeployRequestSchemas.probe,
15
15
  description: 'Probe one deploy target now and answer its status. Run it after any deploy; it records what the target answers and claims nothing itself.' },
16
+ { name: 'deploy_refresh', operation: 'refresh', readOnly: false, inputSchema: fleetDeployRequestSchemas.refresh,
17
+ description: 'Check every deploy target now: fetch the repositories\' remotes and release tags, probe every target and compute the deploy status again, as the five-minute check does; a check already running is followed by one this call shares with any other. It waits at most 60 seconds: refreshed once the check ended, refreshing while it runs on (deploy_status then shows the stored status until it ends). checkedAt says when the status was computed. Call it when deploy_status must show a change at once, not by habit.' },
16
18
  { name: 'release_status', operation: 'release', readOnly: true, inputSchema: fleetDeployRequestSchemas.release,
17
19
  description: 'The release state of a repository (repo as org/name, fleet id or checkout path), or of every repository a deploy target runs, a ticket plans or a landed ticket names: its newest release tag, the tickets planning its next release, and the landed tickets the newest release does not hold.' },
18
20
  ];
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A refused answer to a permission or question (AGL-1687): the session no longer holds the request, because it was
3
+ * answered meanwhile (in another client, or by auto-accept) or withdrawn as its turn moved on. AGL lost a race before it
4
+ * sent anything, so `concurrent_change`: nothing was done; read again, then decide. The component that holds the
5
+ * request throws it (Claude Code's harness, the Codex adapter, the OpenCode client), and the controller hands it on as
6
+ * the typed refusal it is, as it does `ControllerElicitationReplyError`.
7
+ */
8
+ export class ControllerPromptReplyError extends Error {
9
+ public readonly code = 'concurrent_change';
10
+
11
+ constructor(messageArg: string) {
12
+ super(messageArg);
13
+ this.name = 'ControllerPromptReplyError';
14
+ }
15
+ }
16
+
17
+ /** The refusal of an answer to a permission or question the session no longer holds; nothing was sent. */
18
+ export const promptNoLongerPending = (kindArg: 'permission' | 'question'): ControllerPromptReplyError => (
19
+ new ControllerPromptReplyError(`This ${kindArg} was answered or changed meanwhile, so nothing was sent. Read it again, then decide.`)
20
+ );
@@ -4,7 +4,9 @@ import type { ITicketReleasePlan, TTicketColumn, TTicketPriority } from './ticke
4
4
  /**
5
5
  * Deployments (AGL-909): what runs where, observed rather than claimed. A release is the repository's tag `v<version>`;
6
6
  * what a target runs is what its probe answers, recorded as an observation whenever it changes. Everything else (what a
7
- * release holds, how far a target is behind, open bugs on the running version) is computed when it is read.
7
+ * release holds, how far a target is behind, open bugs on the running version) is computed by the controller in the
8
+ * background and stored as its deploy status (AGL-1704), which the views read; what depends on the clock or the busy
9
+ * sessions is applied when it is read.
8
10
  */
9
11
 
10
12
  /**
@@ -100,7 +102,7 @@ export interface IFleetDeployObservation {
100
102
  artifacts: IFleetDeployArtifact[];
101
103
  }
102
104
 
103
- /** What the last probe of a target found; held by the controller, never stored. */
105
+ /** What the last probe of a target found, as the controller's last computation of the deploy status holds it. */
104
106
  export interface IFleetDeployProbeState {
105
107
  state: 'up' | 'down' | 'unknown';
106
108
  checkedAt?: string;
@@ -185,7 +187,7 @@ export interface IFleetDeployBug extends IFleetDeployTicket {
185
187
  fixedIn?: string;
186
188
  }
187
189
 
188
- /** One target as `agl deploy status` and the Deployments view show it, computed when it is read. */
190
+ /** One target as `agl deploy status` and the Deployments view show it, from the stored deploy status. */
189
191
  export interface IFleetDeployTargetStatus {
190
192
  target: IFleetDeployTarget & { builtIn?: true };
191
193
  /** The repository's `org/name` as fleet discovery found its checkout; absent when no checkout holds it. */
@@ -216,11 +218,24 @@ export interface IFleetDeployTargetStatus {
216
218
  deployPlans: IFleetDeployPlan[];
217
219
  }
218
220
 
221
+ /**
222
+ * The newest computation of the deploy status, when it failed (AGL-1704): when, why in AGL's own words (naming the
223
+ * repository it could not read), and the failure journal reference its cause is kept under.
224
+ */
225
+ export interface IFleetDeployStatusFailure {
226
+ at: string;
227
+ message: string;
228
+ reference: string;
229
+ }
230
+
219
231
  export interface IFleetDeployStatus {
232
+ /** When the stored status was computed: at least once per pass, so when the targets were last checked. */
220
233
  checkedAt: string;
221
234
  targets: IFleetDeployTargetStatus[];
222
235
  /** Every maintenance window on a ticket that is not done, scheduled, active or done, the earliest first. */
223
236
  windows: IFleetDeployWindow[];
237
+ /** While the newest computation failed: that failure. The status is the last one computed, from `checkedAt`. */
238
+ failure?: IFleetDeployStatusFailure;
224
239
  }
225
240
 
226
241
  /** A repository's release state, as `agl release status` shows it. */
@@ -258,6 +273,22 @@ export interface IFleetDeployTicketPlacement {
258
273
  deployPlan?: { plan: IFleetDeployPlan; targetName: string; environment?: string; deployWhen: TFleetDeployCondition };
259
274
  }
260
275
 
276
+ /** How long `refresh` waits for its check before it answers `refreshing`; the check goes on, and `deployments.changed` tells of it. */
277
+ export const fleetDeployRefreshWaitMs = 60_000;
278
+
279
+ /** How much longer than `fleetDeployRefreshWaitMs` a caller waits for a `refresh` answer, so the controller's own bound answers first. */
280
+ export const fleetDeployRefreshClientMarginMs = 15_000;
281
+
282
+ /**
283
+ * A `refresh` answer: `refreshed` once a full check that started after the request (fetch, probes, computation) ended
284
+ * within `fleetDeployRefreshWaitMs`, `refreshing` while it still runs. `checkedAt` is the stored status's, absent only
285
+ * while none is stored yet.
286
+ */
287
+ export interface IFleetDeployRefreshResult {
288
+ state: 'refreshed' | 'refreshing';
289
+ checkedAt?: string;
290
+ }
291
+
261
292
  /** Every request of the deploy views; the browser sends the `controller.deploy.*` ones, `agl deploy` the `agl.mcp.deploy.*` ones. */
262
293
  export interface IFleetDeployOperations {
263
294
  status: { request: { targetId?: string }; response: IFleetDeployStatus };
@@ -265,13 +296,15 @@ export interface IFleetDeployOperations {
265
296
  probe: { request: { targetId: string }; response: IFleetDeployTargetStatus };
266
297
  release: { request: { repo?: string }; response: IFleetReleaseStatus };
267
298
  ticket: { request: { ticketKey: string }; response: IFleetDeployTicketPlacement };
299
+ refresh: { request: Record<never, never>; response: IFleetDeployRefreshResult };
268
300
  }
269
301
  export type TFleetDeployOperation = keyof IFleetDeployOperations;
270
- export const fleetDeployOperations = ['status', 'history', 'probe', 'release', 'ticket'] as const satisfies readonly TFleetDeployOperation[];
302
+ export const fleetDeployOperations = ['status', 'history', 'probe', 'release', 'ticket', 'refresh'] as const satisfies readonly TFleetDeployOperation[];
271
303
 
272
304
  /**
273
305
  * The deploy views in the browser. `status` and `history` read; `probe` asks for a probe of one target now and claims
274
- * nothing (a deploy path calls it after a deploy); `release` reads a repository's release state.
306
+ * nothing (a deploy path calls it after a deploy); `release` reads a repository's release state; `refresh` asks for one
307
+ * full check now and waits for it, at most `fleetDeployRefreshWaitMs` (AGL-1704).
275
308
  */
276
309
  export type TControllerDeployRequest<TOperation extends TFleetDeployOperation> = {
277
310
  method: `controller.deploy.${TOperation}`;
@@ -282,7 +315,7 @@ export type TControllerDeployTypedRequest = { [TOperation in TFleetDeployOperati
282
315
 
283
316
  /** The same through the controller's private channel, for `agl deploy` and `agl release status`: the local owner capability. */
284
317
  export const controllerMcpDeployMethods = ['agl.mcp.deploy.status', 'agl.mcp.deploy.history', 'agl.mcp.deploy.probe', 'agl.mcp.deploy.release',
285
- 'agl.mcp.deploy.ticket'] as const;
318
+ 'agl.mcp.deploy.ticket', 'agl.mcp.deploy.refresh'] as const;
286
319
  export type TControllerMcpDeployMethod = (typeof controllerMcpDeployMethods)[number];
287
320
  export type TControllerMcpDeployRequest<TOperation extends TFleetDeployOperation> = {
288
321
  method: `agl.mcp.deploy.${TOperation}`;
@@ -3906,7 +3906,7 @@
3906
3906
  "ticket",
3907
3907
  "none"
3908
3908
  ],
3909
- "description": "How a device answers an item: `session` with `device.permission.reply`, `device.question.reply` or `device.elicitation.reply` for the session; `child` with the same replies and the child's `childSessionId`; `ticket` with `device.ticket.answer`; `none` not on a device (the driver's turn, the driver's own prompts, a native wait, an item whose payload was left out, or a session the feed does not list)."
3909
+ "description": "How a device answers an item: `session` with `device.permission.reply`, `device.question.reply` or `device.elicitation.reply` for the session; `child`, only ever a permission or a question, with `device.permission.reply` or `device.question.reply` for the session and the child's `childSessionId`; `ticket` with `device.ticket.answer`; `none` not on a device (the driver's turn, the driver's own prompts, a native wait, an item whose payload was left out, or a session the feed does not list)."
3910
3910
  },
3911
3911
  "TDeviceInboxItem": {
3912
3912
  "anyOf": [
@@ -467,7 +467,8 @@ export type TDeviceInboxWhere =
467
467
 
468
468
  /**
469
469
  * How a device answers an item: `session` with `device.permission.reply`, `device.question.reply` or
470
- * `device.elicitation.reply` for the session; `child` with the same replies and the child's `childSessionId`; `ticket`
470
+ * `device.elicitation.reply` for the session; `child`, only ever a permission or a question, with
471
+ * `device.permission.reply` or `device.question.reply` for the session and the child's `childSessionId`; `ticket`
471
472
  * with `device.ticket.answer`; `none` not on a device (the driver's turn, the driver's own prompts, a native wait, an
472
473
  * item whose payload was left out, or a session the feed does not list).
473
474
  */
@@ -176,6 +176,11 @@ interface IControllerInboxItemBase<TKind extends TControllerInboxKind, TWhere ex
176
176
  }
177
177
 
178
178
  type TSessionWhere = Extract<TControllerInboxWhere, { kind: 'conversation' | 'child' | 'native' | 'driver' }>;
179
+ /**
180
+ * Where an MCP form lives: never a direct child, whose harness (OpenCode) hands AGL no MCP forms, so no child reply
181
+ * answers one (AGL-1701).
182
+ */
183
+ type TElicitationWhere = Extract<TControllerInboxWhere, { kind: 'conversation' | 'native' | 'driver' }>;
179
184
 
180
185
  export interface IControllerInboxPermissionItem extends IControllerInboxItemBase<'permission', TSessionWhere> {
181
186
  permission?: IControllerPermission;
@@ -183,7 +188,9 @@ export interface IControllerInboxPermissionItem extends IControllerInboxItemBase
183
188
  export interface IControllerInboxQuestionItem extends IControllerInboxItemBase<'question', TSessionWhere> {
184
189
  question?: IControllerQuestion;
185
190
  }
186
- export interface IControllerInboxElicitationItem extends IControllerInboxItemBase<'elicitation', TSessionWhere> {
191
+ export interface IControllerInboxElicitationItem extends IControllerInboxItemBase<'elicitation', TElicitationWhere> {
192
+ /** Never `child`: no child holds an MCP form. */
193
+ answer: Exclude<TControllerInboxAnswer, 'child'>;
187
194
  elicitation?: TControllerElicitation;
188
195
  }
189
196
  /** A wait the harness shows in its own client: AGL holds no request for it, so it is answered there (`answer: 'none'`). */
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '43.3.2',
6
+ version: '43.4.0',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }
@@ -12,15 +12,22 @@ export interface IDeploymentsSender {
12
12
  fire<TRequest extends interfaces.TControllerRequest>(
13
13
  methodArg: TRequest['method'],
14
14
  requestArg: TRequest['request'],
15
- optionsArg?: { abortSignal?: AbortSignal },
15
+ optionsArg?: { abortSignal?: AbortSignal; timeoutMs?: number; maxRetries?: number },
16
16
  ): Promise<TRequest['response']>;
17
17
  }
18
18
 
19
19
  const deploy = <TOperation extends interfaces.TFleetDeployOperation>(senderArg: IDeploymentsSender, operationArg: TOperation,
20
- requestArg: interfaces.IFleetDeployOperations[TOperation]['request']): Promise<interfaces.IFleetDeployOperations[TOperation]['response']> => (
21
- senderArg.fire<interfaces.TControllerDeployTypedRequest>(`controller.deploy.${operationArg}`, requestArg as never) as Promise<
20
+ requestArg: interfaces.IFleetDeployOperations[TOperation]['request'], optionsArg?: { timeoutMs?: number; maxRetries?: number },
21
+ ): Promise<interfaces.IFleetDeployOperations[TOperation]['response']> => (
22
+ senderArg.fire<interfaces.TControllerDeployTypedRequest>(`controller.deploy.${operationArg}`, requestArg as never, optionsArg) as Promise<
22
23
  interfaces.IFleetDeployOperations[TOperation]['response']>
23
24
  );
25
+ /** A full check now (`controller.deploy.refresh`): the controller answers within `fleetDeployRefreshWaitMs`, so the request waits longer, and it is never resent. */
26
+ const refreshDeployments = (senderArg: IDeploymentsSender): Promise<interfaces.IFleetDeployRefreshResult> => (
27
+ deploy(senderArg, 'refresh', {}, {
28
+ timeoutMs: interfaces.fleetDeployRefreshWaitMs + interfaces.fleetDeployRefreshClientMarginMs, maxRetries: 0,
29
+ })
30
+ );
24
31
  const ticket = <TMethod extends interfaces.TTicketOperation>(senderArg: IDeploymentsSender, operationArg: TMethod,
25
32
  requestArg: interfaces.TTicketRequest<TMethod>): Promise<interfaces.TTicketResponse<TMethod>> => (
26
33
  senderArg.fire<interfaces.TControllerTicketTypedRequest>(`controller.ticket.${operationArg}`, requestArg as never) as Promise<interfaces.TTicketResponse<TMethod>>
@@ -124,9 +131,15 @@ export class AglDeployments extends plugins.deesElement.DeesElement {
124
131
  `,
125
132
  ];
126
133
 
134
+ /**
135
+ * Opening the view shows the stored status at once and asks the controller for a full check in the background
136
+ * (AGL-1704); its end comes back as `deployments.changed`, which reads again. A failed check shows as the status's
137
+ * failure, so the request's own answer is not waited for.
138
+ */
127
139
  public async connectedCallback(): Promise<void> {
128
140
  await super.connectedCallback();
129
141
  void this.refresh();
142
+ if (this.sender) void refreshDeployments(this.sender).catch(() => undefined);
130
143
  }
131
144
 
132
145
  public async disconnectedCallback(): Promise<void> {
@@ -184,6 +197,8 @@ export class AglDeployments extends plugins.deesElement.DeesElement {
184
197
  </div>
185
198
  </div>
186
199
  ${this.error ? html`<p class="error" role="alert">${this.error}</p>` : ''}
200
+ ${status?.failure ? html`<p class="checkFailed error" role="status">The last check failed at ${deployClock(status.failure.at)}: ${status.failure.message}
201
+ What is shown is from ${deployClock(status.checkedAt)}. (ref ${status.failure.reference})</p>` : ''}
187
202
  <dees-statsgrid density="compact" .minTileWidth=${220} .tiles=${summary ? this.tiles(summary) : []}></dees-statsgrid>
188
203
  ${this.renderTargets(summary)}
189
204
  <div class="lower">
@@ -372,12 +387,13 @@ export class AglDeployments extends plugins.deesElement.DeesElement {
372
387
  this.dispatchEvent(new CustomEvent('deploy-open-ticket', { detail: { key: keyArg }, bubbles: true, composed: true }));
373
388
  }
374
389
 
390
+ /** "Probe all": one full check (`refresh`), waited for as long as the controller waits; then the view reads again. */
375
391
  private async probeAll(): Promise<void> {
376
392
  const sender = this.sender;
377
393
  if (!sender || !this.status) return;
378
394
  this.probing = true;
379
395
  try {
380
- for (const target of this.status.targets) await deploy(sender, 'probe', { targetId: target.target.id });
396
+ await refreshDeployments(sender);
381
397
  } catch (errorArg) {
382
398
  this.error = errorArg instanceof Error ? errorArg.message : String(errorArg);
383
399
  } finally {
@@ -1308,6 +1308,13 @@ const concatBytes = (chunksArg: readonly Uint8Array[]): Uint8Array => {
1308
1308
  const isElicitationRefusal = (errorArg: unknown): boolean => errorArg instanceof plugins.typedrequest.TypedResponseError
1309
1309
  && (errorArg.errorData?.code === 'invalid_request' || errorArg.errorData?.code === 'not_found');
1310
1310
 
1311
+ /**
1312
+ * The controller refused an answer because the permission or question was answered or changed meanwhile: nothing was
1313
+ * sent, and the conversation is read again.
1314
+ */
1315
+ const isConcurrentChange = (errorArg: unknown): boolean => errorArg instanceof plugins.typedrequest.TypedResponseError
1316
+ && errorArg.errorData?.code === 'concurrent_change';
1317
+
1311
1318
  const errorMessage = (errorArg: unknown): string => {
1312
1319
  if (errorArg instanceof Error && errorArg.message) {
1313
1320
  return errorArg.message;
@@ -5178,10 +5185,24 @@ export class HarnessControllerApp extends plugins.deesElement.DeesElement {
5178
5185
  }
5179
5186
  }
5180
5187
 
5188
+ /**
5189
+ * Loads the workspace after sign-in. Only the projects gate the conversations, terminals and
5190
+ * resources, which read the selected project; every other read runs beside them and holds
5191
+ * nothing back. It resolves once every read has settled.
5192
+ */
5181
5193
  private async loadWorkspaceData(): Promise<void> {
5182
5194
  this.scheduleSystemMetricsRefresh(0);
5183
5195
  await Promise.all([
5184
- this.refreshProjects(),
5196
+ this.refreshProjects().then(async () => {
5197
+ void this.retryStaleDraftSessionCleanup();
5198
+ void this.refreshModelCatalog();
5199
+ await this.refreshSessions();
5200
+ // A link to the Deployments view, as the board's "Open in Deployments" opens in a new tab, shows it once.
5201
+ if (globalThis.location?.hash === deploymentsHref) {
5202
+ globalThis.history.replaceState(globalThis.history.state, '', `${globalThis.location.pathname}${globalThis.location.search}`);
5203
+ await this.openDeployments();
5204
+ }
5205
+ }),
5185
5206
  this.refreshProviderManagement(),
5186
5207
  this.reconcileControllerStatus(),
5187
5208
  this.refreshDriverStatus(),
@@ -5190,14 +5211,6 @@ export class HarnessControllerApp extends plugins.deesElement.DeesElement {
5190
5211
  this.refreshSessionFeed(),
5191
5212
  this.inboxFeed.refresh(),
5192
5213
  ]);
5193
- void this.retryStaleDraftSessionCleanup();
5194
- void this.refreshModelCatalog();
5195
- await this.refreshSessions();
5196
- // A link to the Deployments view, as the board's "Open in Deployments" opens in a new tab, shows it once.
5197
- if (globalThis.location?.hash === deploymentsHref) {
5198
- globalThis.history.replaceState(globalThis.history.state, '', `${globalThis.location.pathname}${globalThis.location.search}`);
5199
- await this.openDeployments();
5200
- }
5201
5214
  }
5202
5215
 
5203
5216
  private scheduleSystemMetricsRefresh(delayMsArg: number): void {
@@ -13779,7 +13792,14 @@ ${entry.detail.stack}`}</pre>`}
13779
13792
  }
13780
13793
  } catch (error) {
13781
13794
  if (this.isCurrentMutation(mutationId, generation, sessionId)) {
13782
- this.reportWorkspaceError('Answer the permission request', error);
13795
+ if (isConcurrentChange(error) && sessionId) {
13796
+ // Nothing was sent: the card drops the answer it showed and the conversation is read again.
13797
+ this.answeredPermissionCards.delete(controllerRuntimeIdToUiKey(requestIdArg));
13798
+ this.noteComposer(errorMessage(error));
13799
+ await this.loadSessionDetail(sessionId);
13800
+ } else {
13801
+ this.reportWorkspaceError('Answer the permission request', error);
13802
+ }
13783
13803
  }
13784
13804
  } finally {
13785
13805
  this.finishMutation(mutationId);
@@ -14720,7 +14740,17 @@ ${entry.detail.stack}`}</pre>`}
14720
14740
  }
14721
14741
  } catch (error) {
14722
14742
  if (this.isCurrentMutation(mutationId, generation, sessionId)) {
14723
- this.reportWorkspaceError('Answer the question', error);
14743
+ if (isConcurrentChange(error) && sessionId) {
14744
+ // Nothing was sent: the cards drop the answers they showed and the conversation is read again.
14745
+ const requestKey = controllerRuntimeIdToUiKey(requestIdArg);
14746
+ answersArg.forEach((_answersArg, indexArg) => {
14747
+ this.answeredQuestionCards.delete(questionCardId(requestKey, answersArg.length, indexArg));
14748
+ });
14749
+ this.noteComposer(errorMessage(error));
14750
+ await this.loadSessionDetail(sessionId);
14751
+ } else {
14752
+ this.reportWorkspaceError('Answer the question', error);
14753
+ }
14724
14754
  }
14725
14755
  } finally {
14726
14756
  this.finishMutation(mutationId);
@@ -16992,10 +17022,10 @@ ${entry.detail.stack}`}</pre>`}
16992
17022
  }
16993
17023
  return;
16994
17024
  }
16995
- // Tickets change only an open board and the open questions of the direct reports the driver lists.
17025
+ // Tickets change only an open board and the open questions of the direct reports the driver lists. What a board
17026
+ // change does to the Deployments view the controller computes, and tells with `deployments.changed` (AGL-1704).
16996
17027
  if (eventArg.type === 'tickets.changed') {
16997
17028
  void this.ticketBoard()?.refresh();
16998
- void this.deploymentsView()?.refresh();
16999
17029
  if (this.driverShown()) void this.refreshDirectReports();
17000
17030
  return;
17001
17031
  }