agl 43.0.2 → 43.0.3

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 (45) hide show
  1. package/changelog.md +6 -0
  2. package/dist_serve/bundle.js +749 -749
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_ts/00_commitinfo_data.js +1 -1
  5. package/dist_ts/aglapi/aglapisurface.document.js +37 -2
  6. package/dist_ts/classes.claudeharness.js +19 -6
  7. package/dist_ts/classes.codexclientadapter.d.ts +2 -1
  8. package/dist_ts/classes.codexclientadapter.js +11 -6
  9. package/dist_ts/classes.codexprojection.d.ts +8 -1
  10. package/dist_ts/classes.codexprojection.js +22 -2
  11. package/dist_ts/classes.sessionfeed.d.ts +20 -2
  12. package/dist_ts/classes.sessionfeed.js +63 -24
  13. package/dist_ts/fleet/classes.claudeworkers.d.ts +4 -1
  14. package/dist_ts/fleet/classes.claudeworkers.js +52 -6
  15. package/dist_ts/fleet/classes.codexworkers.d.ts +2 -1
  16. package/dist_ts/fleet/classes.codexworkers.js +34 -9
  17. package/dist_ts/fleet/classes.workers.js +9 -5
  18. package/dist_ts/fleet/functions.workervalidation.js +4 -2
  19. package/dist_ts/fleet/interfaces.workers.d.ts +27 -2
  20. package/dist_ts/fleet/interfaces.workers.js +7 -1
  21. package/dist_ts_interfaces/fleetworkers.d.ts +17 -1
  22. package/dist_ts_interfaces/interfaces.d.ts +20 -0
  23. package/dist_ts_interfaces/interfaces.js +2 -1
  24. package/dist_ts_interfaces/requests.fleetworkers.d.ts +11 -2
  25. package/dist_ts_interfaces/sessionfeed.d.ts +12 -2
  26. package/dist_ts_interfaces/sessionfeed.js +1 -1
  27. package/package.json +2 -2
  28. package/readme.md +1 -1
  29. package/ts/00_commitinfo_data.ts +1 -1
  30. package/ts/aglapi/aglapisurface.document.ts +36 -1
  31. package/ts/classes.claudeharness.ts +19 -3
  32. package/ts/classes.codexclientadapter.ts +9 -6
  33. package/ts/classes.codexprojection.ts +23 -2
  34. package/ts/classes.sessionfeed.ts +77 -29
  35. package/ts/fleet/classes.claudeworkers.ts +57 -9
  36. package/ts/fleet/classes.codexworkers.ts +35 -11
  37. package/ts/fleet/classes.workers.ts +8 -4
  38. package/ts/fleet/functions.workervalidation.ts +3 -1
  39. package/ts/fleet/interfaces.workers.ts +25 -2
  40. package/ts_interfaces/fleetworkers.ts +17 -1
  41. package/ts_interfaces/interfaces.ts +22 -0
  42. package/ts_interfaces/requests.fleetworkers.ts +11 -2
  43. package/ts_interfaces/sessionfeed.ts +12 -2
  44. package/ts_web/00_commitinfo_data.ts +1 -1
  45. package/ts_web/classes.controllersocketclient.ts +10 -2
@@ -1,12 +1,13 @@
1
1
  import * as plugins from './plugins.js';
2
2
  import { resolveControllerTerminalAgentTranscript } from './functions.terminalagents.js';
3
3
  import { codexQualifiedIdentity } from './functions.codexidentity.js';
4
- import type { IFleetNativeAgent, IFleetNativeThread } from './fleet/interfaces.workers.js';
4
+ import { fleetClaudeNativeWait, type IFleetNativeAgent, type IFleetNativeThread } from './fleet/interfaces.workers.js';
5
5
  import {
6
6
  controllerSessionFeedExcerpt,
7
7
  controllerSessionFeedLimits,
8
8
  type IControllerEvent,
9
9
  type IControllerFleetWorkerView,
10
+ type IControllerNativeWait,
10
11
  type IControllerSession,
11
12
  type IControllerSessionFeedRow,
12
13
  type IControllerSessionFeedTicket,
@@ -15,7 +16,6 @@ import {
15
16
  type TControllerSessionFeedDelta,
16
17
  type TControllerSessionFeedHarness,
17
18
  type TControllerSessionFeedOpen,
18
- type TControllerSessionFeedState,
19
19
  } from '../ts_interfaces/index.js';
20
20
  import type { ITicket, ITicketActor } from '../ts_interfaces/tickets.js';
21
21
 
@@ -116,19 +116,53 @@ const defaultMaxAgeMs: Record<TSessionFeedSource, number> = {
116
116
  };
117
117
 
118
118
  const harnessLabels: Record<TControllerSessionFeedHarness, string> = { claude: 'Claude Code', codex: 'Codex', flex: 'Flex', opencode: 'OpenCode' };
119
- const conversationState = (sessionArg: IControllerSession): TControllerSessionFeedState => (
120
- sessionArg.attention ? 'needs_input'
121
- : sessionArg.status === 'busy' || sessionArg.status === 'retry' ? 'working'
122
- : sessionArg.status === 'error' ? 'failed' : 'completed'
123
- );
124
- const agentState = (agentArg: IFleetNativeAgent): TControllerSessionFeedState => (
125
- agentArg.state === 'failed' ? 'failed'
126
- : agentArg.state === 'blocked' || agentArg.status === 'waiting' ? 'needs_input'
127
- : agentArg.state === 'working' || agentArg.status === 'busy' ? 'working' : 'completed'
128
- );
129
- const threadState = (threadArg: IFleetNativeThread): TControllerSessionFeedState => (
130
- threadArg.status === 'waiting' ? 'needs_input' : threadArg.status === 'busy' ? 'working' : threadArg.status === 'error' ? 'failed' : 'completed'
119
+
120
+ /** What one source tells of a session, for `sessionFeedState` to group. */
121
+ export interface ISessionFeedFacts {
122
+ /** AGL holds a question or permission for the session that the owner answers in AGL. */
123
+ request?: boolean;
124
+ /** The harness signals a wait in its own client. */
125
+ nativeWait?: IControllerNativeWait;
126
+ busy?: boolean;
127
+ /** The session reports an error, its newest turn failed, or it is gone. */
128
+ failed?: boolean;
129
+ interrupted?: boolean;
130
+ }
131
+ export type TSessionFeedStateResult = Pick<IControllerSessionFeedRow, 'state' | 'nativeWait' | 'interrupted'>;
132
+
133
+ /**
134
+ * The one decision of a row's group, in this order: a request AGL holds or a native wait needs input, a session at
135
+ * work works, a failure fails, anything else completed; an interrupted turn is labelled so. A native wait shows on the
136
+ * row only while AGL holds no request it could answer instead.
137
+ */
138
+ export const sessionFeedState = (factsArg: ISessionFeedFacts): TSessionFeedStateResult => (
139
+ factsArg.request ? { state: 'needs_input' }
140
+ : factsArg.nativeWait ? { state: 'needs_input', nativeWait: { reason: factsArg.nativeWait.reason } }
141
+ : factsArg.busy ? { state: 'working' }
142
+ : factsArg.failed ? { state: 'failed' }
143
+ : factsArg.interrupted ? { state: 'completed', interrupted: true } : { state: 'completed' }
131
144
  );
145
+ const conversationFacts = (sessionArg: IControllerSession): ISessionFeedFacts => ({
146
+ request: sessionArg.attention === true, ...(sessionArg.nativeWait ? { nativeWait: sessionArg.nativeWait } : {}),
147
+ busy: sessionArg.status === 'busy' || sessionArg.status === 'retry', failed: sessionArg.status === 'error',
148
+ });
149
+ /**
150
+ * A Claude Code job its inventory lists waits in Claude Code itself only while its process reports waiting and the job
151
+ * has not failed (`fleetClaudeNativeWait`); a job listed `blocked` whose process is idle ended its turn. A failed job
152
+ * is a failure, never at work, whatever its process reports.
153
+ */
154
+ const agentFacts = (agentArg: IFleetNativeAgent): ISessionFeedFacts => {
155
+ const nativeWait = fleetClaudeNativeWait(agentArg);
156
+ return {
157
+ ...(nativeWait ? { nativeWait } : {}), busy: agentArg.state !== 'failed' && (agentArg.state === 'working' || agentArg.status === 'busy'),
158
+ failed: agentArg.state === 'failed',
159
+ };
160
+ };
161
+ /** A waiting thread of the shared Codex app-server is an active one that says why it waits. */
162
+ const threadFacts = (threadArg: IFleetNativeThread): ISessionFeedFacts => ({
163
+ ...(threadArg.nativeWait ? { nativeWait: threadArg.nativeWait } : {}),
164
+ busy: threadArg.status === 'busy' || threadArg.status === 'waiting', failed: threadArg.status === 'error',
165
+ });
132
166
  /** A thread title is its name or its first prompt; the row shows its first line. */
133
167
  const threadName = (titleArg: string): string => {
134
168
  const line = titleArg.trim().split('\n', 1)[0]!.trim();
@@ -141,14 +175,21 @@ const threadName = (titleArg: string): string => {
141
175
  export const sessionFeedRowId = (harnessArg: TControllerSessionFeedHarness, nativeIdArg: string): string => (
142
176
  `${harnessArg}:${harnessArg === 'codex' ? codexQualifiedIdentity(nativeIdArg)?.rawThreadId ?? nativeIdArg : nativeIdArg}`
143
177
  );
144
- const workerState = (viewArg: IControllerFleetWorkerView): TControllerSessionFeedState => {
145
- if (viewArg.status) {
146
- return viewArg.status === 'blocked' ? 'needs_input'
147
- : viewArg.status === 'busy' ? 'working'
148
- : viewArg.status === 'gone' ? 'failed' : 'completed';
178
+ /**
179
+ * A worker as its view shows it. A Codex worker is `blocked` on requests the fleet's own connection holds for AGL to
180
+ * answer. A Claude Code worker waits only on the wait its job's inventory showed (`nativeWait`): the fleet reads more
181
+ * than a wait as `blocked` (a failed job, a job without a live process, one listed `working` among them, which
182
+ * therefore groups completed), and the view's outcome names a failure.
183
+ */
184
+ const workerFacts = (viewArg: IControllerFleetWorkerView): ISessionFeedFacts => {
185
+ const failed = viewArg.outcome?.state === 'failed', interrupted = viewArg.outcome?.state === 'interrupted';
186
+ if (!viewArg.status) {
187
+ return { busy: viewArg.worker.state === 'starting', failed: failed || viewArg.worker.state === 'unknown' || Boolean(viewArg.worker.error), interrupted };
149
188
  }
150
- return viewArg.worker.state === 'starting' ? 'working'
151
- : viewArg.worker.state === 'unknown' || viewArg.worker.error ? 'failed' : 'completed';
189
+ return {
190
+ request: viewArg.status === 'blocked' && viewArg.worker.harness === 'codex', ...(viewArg.nativeWait ? { nativeWait: viewArg.nativeWait } : {}),
191
+ busy: viewArg.status === 'busy', failed: failed || viewArg.status === 'gone', interrupted,
192
+ };
152
193
  };
153
194
 
154
195
  interface IRowDraft {
@@ -357,7 +398,9 @@ export class SessionFeed {
357
398
  if (statusArg.projectId !== undefined && statusArg.projectId !== conversation.projectId) return conversation;
358
399
  if (conversation.session.status === statusArg.status) return conversation;
359
400
  changesArg.count += 1;
360
- return { ...conversation, session: { ...conversation.session, status: statusArg.status } };
401
+ // A harness signals a wait only while the session is busy: a status that ends the work ends the wait.
402
+ const { nativeWait: _wait, ...settled } = conversation.session;
403
+ return { ...conversation, session: { ...(statusArg.status === 'busy' || statusArg.status === 'retry' ? conversation.session : settled), status: statusArg.status } };
361
404
  });
362
405
  }
363
406
 
@@ -536,7 +579,7 @@ export class SessionFeed {
536
579
  .filter((conversation) => {
537
580
  const known = this.excerpts.get(this.conversationRowId(conversation));
538
581
  // A working session's text still streams; its excerpt is read when the turn ends.
539
- return (!known || known.updatedAt !== conversation.session.updatedAt) && conversationState(conversation.session) !== 'working';
582
+ return (!known || known.updatedAt !== conversation.session.updatedAt) && sessionFeedState(conversationFacts(conversation.session)).state !== 'working';
540
583
  })
541
584
  .sort((left, right) => right.session.updatedAt - left.session.updatedAt);
542
585
  if (due.length === 0) return;
@@ -641,12 +684,13 @@ export class SessionFeed {
641
684
  const { worker, agent, transcript, thread, terminal } = entryArg;
642
685
  // An untracked project conversation stands in for a tracked one; it opens the same way.
643
686
  const conversation = entryArg.conversation ?? (entryArg.archived ? undefined : entryArg.project);
644
- const state: TControllerSessionFeedState | undefined = conversation ? conversationState(conversation.session)
645
- : agent ? agentState(agent)
646
- : worker ? workerState(worker)
647
- : thread ? threadState(thread)
648
- : terminal ? terminal.failed ? 'failed' : 'completed' : undefined;
649
- if (!state) return undefined;
687
+ const facts: ISessionFeedFacts | undefined = conversation ? conversationFacts(conversation.session)
688
+ : agent ? agentFacts(agent)
689
+ : worker ? workerFacts(worker)
690
+ : thread ? threadFacts(thread)
691
+ : terminal ? { failed: terminal.failed } : undefined;
692
+ if (!facts) return undefined;
693
+ const { state, nativeWait, interrupted } = sessionFeedState(facts);
650
694
  const cwd = terminal?.cwd ?? worker?.worker.cwd ?? agent?.cwd ?? thread?.cwd ?? '';
651
695
  const name = conversation?.session.title.trim() || worker?.worker.name || terminal?.title.trim() || agent?.name?.trim()
652
696
  || (thread ? threadName(thread.title) : '')
@@ -656,6 +700,8 @@ export class SessionFeed {
656
700
  conversation?.session.updatedAt ?? 0,
657
701
  thread?.updatedAt ?? 0,
658
702
  worker ? Date.parse(worker.worker.updatedAt) || 0 : 0,
703
+ // A worker's newer turn moves its row, so a failure the owner acknowledged does not hide the next one.
704
+ worker?.turnStartedAt ? Date.parse(worker.turnStartedAt) || 0 : 0,
659
705
  transcript?.updatedAt ?? agent?.startedAt ?? 0,
660
706
  terminal?.updatedAt ?? 0,
661
707
  );
@@ -680,6 +726,8 @@ export class SessionFeed {
680
726
  ...(tickets.length ? { tickets } : {}),
681
727
  updatedAt,
682
728
  open,
729
+ ...(nativeWait ? { nativeWait } : {}),
730
+ ...(interrupted ? { interrupted } : {}),
683
731
  };
684
732
  }
685
733
 
@@ -1,10 +1,10 @@
1
1
  import * as plugins from '../plugins.js';
2
2
  import { resolveControllerTerminalAgentTranscript } from '../functions.terminalagents.js';
3
3
  import { fleetWorkerPath, resolveClaudeWorkerExecutable } from '../functions.workerprocessproof.js';
4
- import type { IFleetWorker, IFleetWorkerProfile, IFleetWorkerReport, IFleetRelaunchBlocker, IFleetWorkerAbsenceProof, IFleetWorkerSessionProof, IFleetWorkerRebindProof } from '../../ts_interfaces/fleetworkers.js';
5
- import { controllerSessionFeedExcerpt, type IControllerMessageBundle } from '../../ts_interfaces/index.js';
4
+ import type { IFleetWorker, IFleetWorkerProfile, IFleetWorkerReport, IFleetWorkerTurnOutcome, IFleetRelaunchBlocker, IFleetWorkerAbsenceProof, IFleetWorkerSessionProof, IFleetWorkerRebindProof } from '../../ts_interfaces/fleetworkers.js';
5
+ import { controllerSessionFeedExcerpt, type IControllerMessageBundle, type IControllerNativeWait } from '../../ts_interfaces/index.js';
6
6
  import { claudePage, claudeTranscript } from '../classes.claudeprojection.js';
7
- import { FleetDispatchError, FleetNativeTurnError, boundedFleetReport, fleetMessageDigest, fleetReportMarker, type IFleetWorkerBackend, type IFleetNativeEvent, type IFleetNativeAgent, type IFleetNativeSession, type IFleetNativePage, type IFleetNativeSendTurn, type IFleetNativeSendReceipt } from './interfaces.workers.js';
7
+ import { FleetDispatchError, FleetNativeTurnError, boundedFleetReport, fleetClaudeNativeWait, fleetMessageDigest, fleetReportMarker, type IFleetWorkerBackend, type IFleetWorkerObservedTurn, type IFleetNativeEvent, type IFleetNativeAgent, type IFleetNativeSession, type IFleetNativePage, type IFleetNativeSendTurn, type IFleetNativeSendReceipt } from './interfaces.workers.js';
8
8
  import { runFleetWorkerCommand, type IFleetWorkerCommand, type TFleetWorkerRunner } from './classes.workercommand.js';
9
9
  import { sanitizeFailureText } from '../functions.failuredescription.js';
10
10
  import type { FleetWorkerLaunches } from './classes.workerlaunches.js';
@@ -64,6 +64,41 @@ const resumable = (agent: TClaudeAgent): boolean => reaped(agent) || !live(agent
64
64
  const status = (agent?: TClaudeAgent): IFleetWorkerReport['status'] => !agent ? 'gone' : reaped(agent) ? 'reaped'
65
65
  : agent.state === 'stopped' ? 'stopped' : agent.state === 'failed' || agent.state === 'blocked' || agent.status === 'waiting' ? 'blocked'
66
66
  : agent.status === 'busy' ? 'busy' : live(agent) ? 'idle' : 'blocked';
67
+ /**
68
+ * The turn the newest prompt among Claude Code transcript records opened: a `user` record outside a sidechain that
69
+ * Claude Code does not mark as its own (`isMeta`) and that holds text, not only tool results; named by its uuid, as
70
+ * turn endings are.
71
+ */
72
+ const claudePrompt = (records: Record<string, unknown>[]): { id: string; startedAt?: string } | undefined => {
73
+ for (let index = records.length - 1; index >= 0; index -= 1) {
74
+ const entry = records[index]!, id = entry.uuid ?? entry.timestamp;
75
+ if (entry.type !== 'user' || entry.isSidechain === true || entry.isMeta === true || typeof id !== 'string' || !id) continue;
76
+ const content = record.safeParse(entry.message).data?.content;
77
+ if (typeof content !== 'string' && !(Array.isArray(content) && content.some((part) => {
78
+ const type = record.safeParse(part).data?.type;
79
+ return typeof type === 'string' && type !== 'tool_result';
80
+ }))) continue;
81
+ const at = typeof entry.timestamp === 'string' ? Date.parse(entry.timestamp) : Number.NaN;
82
+ return { id, ...(Number.isFinite(at) ? { startedAt: new Date(at).toISOString() } : {}) };
83
+ }
84
+ return undefined;
85
+ };
86
+ /** How a Claude Code job's turn ended, as its inventory lists the job: failed, or done. */
87
+ const claudeOutcome = (agent: TClaudeAgent | undefined, turnId: string): IFleetWorkerTurnOutcome | undefined => (
88
+ agent?.state === 'failed' ? { turnId, state: 'failed' } : agent?.state === 'done' ? { turnId, state: 'completed' } : undefined);
89
+ /**
90
+ * A worker job's newest turn: the one the newest prompt in `records` opened, else the turn observed before, else the
91
+ * session itself while AGL sees none of its prompts. Its outcome is the inventory's: a state there is the job's, not a
92
+ * turn's, and may lag behind the transcript, so the job's state now (`working`, `blocked`, `done`, `failed`) always
93
+ * replaces what was observed for the turn. A failure observed for that turn stays only while the inventory is quiet: it
94
+ * lists no state, `stopped`, or not the job at all.
95
+ */
96
+ const claudeObservedTurn = (nativeId: string, agent: TClaudeAgent | undefined, records: Record<string, unknown>[], previous?: IFleetWorkerObservedTurn): IFleetWorkerObservedTurn => {
97
+ const turn = claudePrompt(records) ?? (previous ? { id: previous.id, ...(previous.startedAt ? { startedAt: previous.startedAt } : {}) } : { id: nativeId });
98
+ const quiet = agent?.state === undefined || agent.state === 'stopped';
99
+ const outcome = quiet && previous?.outcome?.state === 'failed' && previous.id === turn.id ? previous.outcome : claudeOutcome(agent, turn.id);
100
+ return { ...turn, ...(outcome ? { outcome } : {}) };
101
+ };
67
102
  /**
68
103
  * The permission modes a Claude Code transcript records and `--permission-mode` takes: Claude Code 2.1.282 and 2.1.306
69
104
  * know `acceptEdits`, `auto`, `bypassPermissions`, `default`, `dontAsk` and `plan`, and read `manual` as `default`
@@ -203,8 +238,11 @@ export const fleetClaudeRelayFailure = (result: IFleetWorkerCommand): FleetDispa
203
238
  return new FleetDispatchError(`Claude -p failed (exit ${result.code})${unsent ? ' before it sent any message' : ''}${output ? `: ${output}` : '.'}`, !unsent);
204
239
  };
205
240
 
206
- /** `offset` is absent once the poll baseline was forgotten: the next poll reads afresh but keeps the observed state. */
207
- interface IClaudeObservation { offset?: number; state?: IFleetWorkerReport['status']; turnState?: string; path?: string; excerpt?: string }
241
+ /** `offset` is absent once the poll baseline was forgotten: the next poll reads afresh but keeps the observed state, turn and wait. */
242
+ interface IClaudeObservation {
243
+ offset?: number; state?: IFleetWorkerReport['status']; turnState?: string; path?: string; excerpt?: string; turn?: IFleetWorkerObservedTurn;
244
+ nativeWait?: IControllerNativeWait;
245
+ }
208
246
  /** The SDK's transcript chain reader, which builds a conversation from transcript records. */
209
247
  export type TFleetClaudeTranscriptReader = Pick<typeof plugins.claudeAgentSdk, 'getSessionMessages'>;
210
248
  export class FleetClaudeWorkers implements IFleetWorkerBackend {
@@ -636,8 +674,9 @@ export class FleetClaudeWorkers implements IFleetWorkerBackend {
636
674
  const agent = await this.findAgent(worker, profile), transcript = await this.transcript(worker, profile);
637
675
  // A turn may continue past its report; the newest report outranks later chatter.
638
676
  const texts = fleetClaudeAssistantTexts(transcript.records), latest = texts.findLast((item) => fleetReportMarker.test(item.text)) ?? texts.at(-1);
677
+ const outcome = claudeObservedTurn(worker.nativeId!, agent, transcript.records, this.observations.get(worker.nativeId!)?.turn).outcome;
639
678
  return { worker, status: status(agent), ...boundedFleetReport(latest?.text ?? ''), ...(latest ? { reportId: latest.id } : {}),
640
- ...(agent ? { turnStatus: agent.state ?? agent.status } : {}) };
679
+ ...(agent ? { turnStatus: agent.state ?? agent.status } : {}), ...(outcome ? { outcome } : {}) };
641
680
  }
642
681
  public async poll(worker: IFleetWorker, profile: IFleetWorkerProfile): Promise<IFleetNativeEvent[]> {
643
682
  const agent = await this.findAgent(worker, profile), observation = this.observations.get(worker.nativeId!);
@@ -647,7 +686,9 @@ export class FleetClaudeWorkers implements IFleetWorkerBackend {
647
686
  if (previous?.path && tail.path !== previous.path) throw new Error('Claude transcript moved; re-baseline with a report before watching.');
648
687
  const texts = fleetClaudeAssistantTexts(tail.records);
649
688
  const excerpt = controllerSessionFeedExcerpt(texts.at(-1)?.text) ?? observation?.excerpt;
650
- this.observations.set(worker.nativeId!, { offset: tail.end, state: current, turnState: agent.state, path: tail.path, ...(excerpt ? { excerpt } : {}) });
689
+ const turn = claudeObservedTurn(worker.nativeId!, agent, tail.records, observation?.turn), nativeWait = fleetClaudeNativeWait(agent);
690
+ this.observations.set(worker.nativeId!, { offset: tail.end, state: current, turnState: agent.state, path: tail.path, ...(excerpt ? { excerpt } : {}), turn,
691
+ ...(nativeWait ? { nativeWait } : {}) });
651
692
  const events: IFleetNativeEvent[] = current === 'reaped' && observation?.state !== 'reaped'
652
693
  ? [{ nativeId: worker.nativeId!, kind: 'worker.reaped', status: 'reaped' }] : [];
653
694
  if (!previous) return events;
@@ -670,7 +711,7 @@ export class FleetClaudeWorkers implements IFleetWorkerBackend {
670
711
  await this.callers?.bindClaude(worker, worker.nativeId!, agent);
671
712
  const previous = this.observations.get(worker.nativeId!);
672
713
  this.observations.set(worker.nativeId!, { offset: previous?.offset ?? baseline.end, path: previous?.path ?? baseline.path, state: 'busy', turnState: 'working',
673
- ...(previous?.excerpt ? { excerpt: previous.excerpt } : {}) });
714
+ ...(previous?.excerpt ? { excerpt: previous.excerpt } : {}), ...(previous?.turn ? { turn: previous.turn } : {}) });
674
715
  } catch (error) {
675
716
  await this.callers?.revoke(worker, 'failure');
676
717
  throw new FleetDispatchError(`Claude revival was acknowledged but reconciliation failed: ${error instanceof Error ? error.message : 'unknown failure.'} Inspect before retrying.`, true, { cause: error });
@@ -855,11 +896,18 @@ export class FleetClaudeWorkers implements IFleetWorkerBackend {
855
896
  }
856
897
  public forget(worker: IFleetWorker): void {
857
898
  const observation = worker.nativeId ? this.observations.get(worker.nativeId) : undefined;
858
- if (observation) this.observations.set(worker.nativeId!, { state: observation.state, turnState: observation.turnState, ...(observation.excerpt ? { excerpt: observation.excerpt } : {}) });
899
+ if (observation) this.observations.set(worker.nativeId!, { state: observation.state, turnState: observation.turnState, ...(observation.excerpt ? { excerpt: observation.excerpt } : {}),
900
+ ...(observation.turn ? { turn: observation.turn } : {}), ...(observation.nativeWait ? { nativeWait: observation.nativeWait } : {}) });
859
901
  }
860
902
  public observed(worker: IFleetWorker): IFleetWorkerReport['status'] | undefined {
861
903
  return worker.nativeId ? this.observations.get(worker.nativeId)?.state : undefined;
862
904
  }
905
+ public observedTurn(worker: IFleetWorker): IFleetWorkerObservedTurn | undefined {
906
+ return worker.nativeId ? this.observations.get(worker.nativeId)?.turn : undefined;
907
+ }
908
+ public observedNativeWait(worker: IFleetWorker): IControllerNativeWait | undefined {
909
+ return worker.nativeId ? this.observations.get(worker.nativeId)?.nativeWait : undefined;
910
+ }
863
911
  public observedExcerpt(worker: IFleetWorker): string | undefined {
864
912
  return worker.nativeId ? this.observations.get(worker.nativeId)?.excerpt : undefined;
865
913
  }
@@ -1,14 +1,28 @@
1
1
  import * as plugins from '../plugins.js';
2
2
  import { CodexSupervisor } from '../classes.codexsupervisor.js';
3
3
  import { CodexClientAdapter } from '../classes.codexclientadapter.js';
4
- import { codexRecord, codexArray, codexString, codexSession } from '../classes.codexprojection.js';
5
- import type { IFleetWorker, IFleetWorkerProfile, IFleetWorkerReport } from '../../ts_interfaces/fleetworkers.js';
4
+ import { codexRecord, codexArray, codexString, codexSession, codexTimestamp, codexTurnError } from '../classes.codexprojection.js';
5
+ import { isCodexThreadId } from '../functions.codexidentity.js';
6
+ import type { IFleetWorker, IFleetWorkerProfile, IFleetWorkerReport, IFleetWorkerTurnOutcome } from '../../ts_interfaces/fleetworkers.js';
6
7
  import { controllerSessionFeedExcerpt } from '../../ts_interfaces/sessionfeed.js';
7
8
  import type { IControllerMessageBundle, IControllerPermission, IControllerQuestion, TControllerPermissionReply } from '../../ts_interfaces/index.js';
8
9
  import type { FleetWorkerLaunches, IFleetCodexCallerRuntime } from './classes.workerlaunches.js';
9
- import { FleetDispatchError, FleetNativeTurnError, fleetReportMarker, boundedFleetReport, type IFleetWorkerBackend, type IFleetNativeEvent, type IFleetNativeThread, type IFleetNativeSession, type IFleetNativePage, type IFleetNativeSendTurn, type IFleetNativeSendReceipt } from './interfaces.workers.js';
10
+ import { FleetDispatchError, FleetNativeTurnError, fleetReportMarker, boundedFleetReport, type IFleetWorkerBackend, type IFleetWorkerObservedTurn, type IFleetNativeEvent, type IFleetNativeThread, type IFleetNativeSession, type IFleetNativePage, type IFleetNativeSendTurn, type IFleetNativeSendReceipt } from './interfaces.workers.js';
10
11
 
11
- interface ICodexObservation { turns: Set<string>; items: Map<string, string>; status?: IFleetWorkerReport['status']; excerpt?: string }
12
+ /** `turns` and `items` are the poll baseline; `turn` stays when the baseline is forgotten, so a failure stays observed. */
13
+ interface ICodexObservation { turns?: Set<string>; items?: Map<string, string>; status?: IFleetWorkerReport['status']; excerpt?: string; turn?: IFleetWorkerObservedTurn }
14
+ const terminalTurnStates: ReadonlySet<unknown> = new Set<IFleetWorkerTurnOutcome['state']>(['completed', 'interrupted', 'failed']);
15
+ /**
16
+ * What a listed Codex turn tells: when it started (Codex's `startedAt`, else its UUIDv7 id) and, once it ended, how;
17
+ * the limit kind of a failure Codex named as a provider limit (`codexTurnError`).
18
+ */
19
+ const codexObservedTurn = (turn: Record<string, unknown>): IFleetWorkerObservedTurn => {
20
+ const turnId = codexString(turn.id), started = Number.isSafeInteger(turn.startedAt) ? codexTimestamp(turn.startedAt)
21
+ : isCodexThreadId(turnId) ? Number.parseInt(turnId.replaceAll('-', '').slice(0, 12), 16) : undefined;
22
+ const limit = turn.status === 'failed' ? codexTurnError(turn.error)?.limit?.kind : undefined;
23
+ return { id: turnId, ...(started === undefined ? {} : { startedAt: new Date(started).toISOString() }),
24
+ ...(terminalTurnStates.has(turn.status) ? { outcome: { turnId, state: turn.status as IFleetWorkerTurnOutcome['state'], ...(limit ? { limit } : {}) } } : {}) };
25
+ };
12
26
  export interface IFleetCodexConnection { supervisor: CodexSupervisor; adapter: CodexClientAdapter }
13
27
  export type TFleetCodexConnectionFactory = (cwd: string) => IFleetCodexConnection;
14
28
  const connection: TFleetCodexConnectionFactory = (directory) => {
@@ -125,10 +139,10 @@ export class FleetCodexWorkers implements IFleetWorkerBackend {
125
139
  const latest = turns[0], items = await this.items(adapter, worker.nativeId!, undefined, true);
126
140
  const message = items.find((entry) => codexRecord(entry.item).type === 'agentMessage');
127
141
  const item = message ? codexRecord(message.item) : undefined;
128
- const attention = adapter.attention(worker.nativeId!);
142
+ const attention = adapter.attention(worker.nativeId!), outcome = (latest ? codexObservedTurn(latest) : this.observations.get(worker.nativeId!)?.turn)?.outcome;
129
143
  return { worker, status: worker.state === 'archived' ? 'archived' : latest?.status === 'inProgress' ? attention.permissions.length || attention.questions.length ? 'blocked' : 'busy' : 'idle',
130
144
  ...boundedFleetReport(typeof item?.text === 'string' ? item.text : ''), ...(item ? { reportId: codexString(item.id) } : {}),
131
- ...(latest ? { turnId: codexString(latest.id), turnStatus: codexString(latest.status) } : {}) };
145
+ ...(latest ? { turnId: codexString(latest.id), turnStatus: codexString(latest.status) } : {}), ...(outcome ? { outcome } : {}) };
132
146
  }
133
147
  public async poll(worker: IFleetWorker, _profile: IFleetWorkerProfile): Promise<IFleetNativeEvent[]> {
134
148
  const adapter = await this.scoped(worker), id = worker.nativeId!, previous = this.observations.get(id);
@@ -137,9 +151,11 @@ export class FleetCodexWorkers implements IFleetWorkerBackend {
137
151
  const status = turns[0]?.status === 'inProgress' ? attention.permissions.length || attention.questions.length ? 'blocked' : 'busy' : 'idle';
138
152
  const message = items.map((entry) => codexRecord(entry.item)).find((item) => item.type === 'agentMessage' && typeof item.text === 'string' && item.text.trim());
139
153
  const excerpt = controllerSessionFeedExcerpt(message?.text as string | undefined) ?? previous?.excerpt;
154
+ // The newest listed turn replaces the observed one; a thread listing none leaves it.
155
+ const turn = turns[0] ? codexObservedTurn(turns[0]) : previous?.turn;
140
156
  this.observations.set(id, { turns: new Set(terminal.map((turn) => codexString(turn.id))), items: new Map(items.map((entry) => { const item = codexRecord(entry.item); return [codexString(item.id), typeof item.text === 'string' ? item.text : '']; })),
141
- status, ...(excerpt ? { excerpt } : {}) });
142
- if (!previous) return [];
157
+ status, ...(excerpt ? { excerpt } : {}), ...(turn ? { turn } : {}) });
158
+ if (!previous?.turns || !previous.items) return [];
143
159
  const events: IFleetNativeEvent[] = [];
144
160
  for (const entry of [...items].reverse()) {
145
161
  const item = codexRecord(entry.item), itemId = codexString(item.id);
@@ -150,7 +166,11 @@ export class FleetCodexWorkers implements IFleetWorkerBackend {
150
166
  return events;
151
167
  }
152
168
  public forget(worker: IFleetWorker): void {
153
- if (worker.nativeId) this.observations.delete(worker.nativeId);
169
+ if (!worker.nativeId) return;
170
+ // A failure clears only on a newer turn: the observed turn outlives the forgotten baseline.
171
+ const turn = this.observations.get(worker.nativeId)?.turn;
172
+ if (turn) this.observations.set(worker.nativeId, { turn });
173
+ else this.observations.delete(worker.nativeId);
154
174
  }
155
175
  public async send(messages: Array<{ worker: IFleetWorker; profile: IFleetWorkerProfile; text: string }>): Promise<void> {
156
176
  let admitted = false;
@@ -244,6 +264,9 @@ export class FleetCodexWorkers implements IFleetWorkerBackend {
244
264
  public observed(worker: IFleetWorker): IFleetWorkerReport['status'] | undefined {
245
265
  return worker.nativeId ? this.observations.get(worker.nativeId)?.status : undefined;
246
266
  }
267
+ public observedTurn(worker: IFleetWorker): IFleetWorkerObservedTurn | undefined {
268
+ return worker.nativeId ? this.observations.get(worker.nativeId)?.turn : undefined;
269
+ }
247
270
  public observedExcerpt(worker: IFleetWorker): string | undefined {
248
271
  return worker.nativeId ? this.observations.get(worker.nativeId)?.excerpt : undefined;
249
272
  }
@@ -270,9 +293,10 @@ export class FleetCodexWorkers implements IFleetWorkerBackend {
270
293
  if (thread.ephemeral === true) continue;
271
294
  const session = codexSession(thread, codexString(thread.cwd));
272
295
  if (session.parentId) continue;
273
- const flags = codexRecord(thread.status).activeFlags;
296
+ // A wait (`codexNativeWait`) comes only with an active thread: the thread waits, and says why.
297
+ const nativeWait = session.status === 'busy' ? session.nativeWait : undefined;
274
298
  threads.push({ sessionId: session.id.nativeId, cwd: codexString(thread.cwd), title: session.title, updatedAt: session.updatedAt,
275
- status: session.status === 'busy' ? Array.isArray(flags) && flags.length > 0 ? 'waiting' : 'busy' : session.status === 'error' ? 'error' : 'idle' });
299
+ status: nativeWait ? 'waiting' : session.status === 'busy' ? 'busy' : session.status === 'error' ? 'error' : 'idle', ...(nativeWait ? { nativeWait } : {}) });
276
300
  }
277
301
  if (result.nextCursor === null || result.nextCursor === undefined) break;
278
302
  cursor = codexString(result.nextCursor, 8192); if (cursors.has(cursor)) throw new Error('Codex thread pagination did not advance.'); cursors.add(cursor);
@@ -114,6 +114,7 @@ export class FleetWorkers {
114
114
  for (const { owner, worker } of observable) {
115
115
  try {
116
116
  const backend = this.backends[worker.harness], observed = backend.observed?.(worker), excerpt = backend.observedExcerpt?.(worker);
117
+ const turnAndWait = JSON.stringify([backend.observedTurn?.(worker) ?? null, backend.observedNativeWait?.(worker) ?? null]);
117
118
  const events = await this.backends[worker.harness].poll(worker, worker.profile);
118
119
  const ticketed = this.options.ticketEffects && worker.ticketKey && worker.ticketActor;
119
120
  for (const { nativeId: _nativeId, ...event } of events) {
@@ -141,8 +142,9 @@ export class FleetWorkers {
141
142
  this.reportBaselines.add(baseline);
142
143
  }
143
144
  }
144
- // A newly observed status or excerpt publishes no fleet event, yet the Driver view and the session feed show it.
145
- if (backend.observed?.(worker) !== observed || backend.observedExcerpt?.(worker) !== excerpt) for (const listener of this.viewListeners) listener();
145
+ // A newly observed status, excerpt, turn or wait publishes no fleet event, yet the Driver view and the session feed show it.
146
+ if (backend.observed?.(worker) !== observed || backend.observedExcerpt?.(worker) !== excerpt
147
+ || JSON.stringify([backend.observedTurn?.(worker) ?? null, backend.observedNativeWait?.(worker) ?? null]) !== turnAndWait) for (const listener of this.viewListeners) listener();
146
148
  this.observationFailures.delete(worker.id);
147
149
  } catch (error) { await this.observationFailed(owner, worker, error); }
148
150
  if (this.abort.signal.aborted) return;
@@ -322,8 +324,10 @@ export class FleetWorkers {
322
324
  }
323
325
  private view(worker: IFleetWorker): IControllerFleetWorkerView {
324
326
  if (worker.lostDispatch) return { worker: this.publicWorker(worker), status: worker.state === 'archived' ? 'archived' : 'gone' };
325
- const status = this.backends[worker.harness].observed?.(worker), excerpt = this.backends[worker.harness].observedExcerpt?.(worker);
326
- return { worker: this.publicWorker(worker), ...(status ? { status } : {}), ...(excerpt ? { excerpt } : {}) };
327
+ const backend = this.backends[worker.harness], status = backend.observed?.(worker), excerpt = backend.observedExcerpt?.(worker), turn = backend.observedTurn?.(worker);
328
+ const nativeWait = backend.observedNativeWait?.(worker);
329
+ return { worker: this.publicWorker(worker), ...(status ? { status } : {}), ...(turn?.outcome ? { outcome: structuredClone(turn.outcome) } : {}),
330
+ ...(turn?.startedAt ? { turnStartedAt: turn.startedAt } : {}), ...(nativeWait ? { nativeWait: structuredClone(nativeWait) } : {}), ...(excerpt ? { excerpt } : {}) };
327
331
  }
328
332
  /** The host's Claude Code sessions of the profile home `home` (the default home when absent), read at most `maxAgeMs` ago. */
329
333
  public async nativeAgents(home: string | undefined, maxAgeMs: number): Promise<IFleetNativeAgent[]> {
@@ -99,8 +99,10 @@ export const fleetWorkerSchema = plugins.z.object({
99
99
  context.addIssue({ code: 'custom', message: 'Re-bind proof does not match the worker binding.' });
100
100
  }
101
101
  });
102
+ const outcome = plugins.z.object({ turnId: text, state: plugins.z.enum(['completed', 'interrupted', 'failed']),
103
+ limit: plugins.z.enum(['usage_limit', 'usage_reserve', 'rate_limit']).optional() }).strict();
102
104
  const report = plugins.z.object({ worker: fleetWorkerSchema, status: plugins.z.enum(['busy', 'idle', 'blocked', 'stopped', 'archived', 'reaped', 'gone']),
103
- turnId: text.optional(), turnStatus: text.optional(), reportId: text.optional(), text: plugins.z.string().max(64 * 1024),
105
+ turnId: text.optional(), turnStatus: text.optional(), outcome: outcome.optional(), reportId: text.optional(), text: plugins.z.string().max(64 * 1024),
104
106
  truncated: plugins.z.boolean(), error: plugins.z.string().max(4096).optional() }).strict();
105
107
  const nativeMessage = plugins.z.object({ delivery: plugins.z.literal('native-wake'), nativeId: plugins.z.string().uuid(), jobId: text, cwd,
106
108
  profileId: name.optional(), note: plugins.z.string().min(1).max(4096), adopt: plugins.z.string().min(1).max(8192) }).strict();
@@ -1,6 +1,6 @@
1
1
  import * as plugins from '../plugins.js';
2
- import type { IFleetWorker, IFleetWorkerProfile, IFleetWorkerReport, IFleetRelaunchBlocker, IFleetWorkerAbsenceProof, IFleetWorkerSessionProof, IFleetWorkerRebindProof } from '../../ts_interfaces/fleetworkers.js';
3
- import type { IControllerMessageBundle, IControllerPermission, IControllerQuestion, TControllerPermissionReply } from '../../ts_interfaces/index.js';
2
+ import type { IFleetWorker, IFleetWorkerProfile, IFleetWorkerReport, IFleetWorkerTurnOutcome, IFleetRelaunchBlocker, IFleetWorkerAbsenceProof, IFleetWorkerSessionProof, IFleetWorkerRebindProof } from '../../ts_interfaces/fleetworkers.js';
3
+ import type { IControllerMessageBundle, IControllerNativeWait, IControllerPermission, IControllerQuestion, TControllerPermissionReply } from '../../ts_interfaces/index.js';
4
4
 
5
5
  export class FleetDispatchError extends Error {
6
6
  constructor(message: string, public readonly dispatched: boolean, options?: ErrorOptions) { super(message, options); this.name = 'FleetDispatchError'; }
@@ -24,14 +24,30 @@ export interface IFleetNativeEvent {
24
24
  nativeId: string; kind: 'worker.turn.ended' | 'worker.report.mid_turn' | 'worker.reaped' | 'worker.credential.failed'; turnId?: string; status?: string;
25
25
  text?: string; reportId?: string; truncated?: boolean; error?: string;
26
26
  }
27
+ /**
28
+ * The newest turn the polls observed: its id, when it started (ISO 8601) where the harness states it, and how it ended
29
+ * once it did. A failed outcome stays until a turn of another id is observed or, for a Claude Code job, its inventory
30
+ * lists the job `working`, `blocked` or `done`.
31
+ */
32
+ export interface IFleetWorkerObservedTurn { id: string; startedAt?: string; outcome?: IFleetWorkerTurnOutcome }
27
33
  /** A native session in a harness's own inventory, live or settled. */
28
34
  export interface IFleetNativeAgent {
29
35
  sessionId: string; cwd: string; kind: 'interactive' | 'background'; id?: string; name?: string; pid?: number;
30
36
  state?: 'working' | 'blocked' | 'done' | 'failed' | 'stopped'; status?: 'busy' | 'waiting' | 'idle'; startedAt?: number;
31
37
  }
38
+ /**
39
+ * Whether a Claude Code job its inventory lists waits for a person in Claude Code itself: its process reports
40
+ * `waiting` while the job has not failed. A failed job is a failure, never a wait, and a `blocked` state alone is no
41
+ * wait: a live job whose turn ended shows status `idle` with state `done` or `blocked`, and counts as idle.
42
+ */
43
+ export const fleetClaudeNativeWait = (agentArg: Pick<IFleetNativeAgent, 'state' | 'status'>): IControllerNativeWait | undefined => (
44
+ agentArg.status === 'waiting' && agentArg.state !== 'failed' ? { reason: 'native_prompt' } : undefined
45
+ );
32
46
  /** A root thread on a harness's shared server, live or settled. */
33
47
  export interface IFleetNativeThread {
34
48
  sessionId: string; cwd: string; title: string; status: 'busy' | 'waiting' | 'idle' | 'error'; updatedAt: number;
49
+ /** Why the thread waits for a person in the harness's own client: set exactly when `status` is `waiting`. */
50
+ nativeWait?: IControllerNativeWait;
35
51
  }
36
52
  /**
37
53
  * A native session the fleet lists but does not bind: `cwd` is the directory its own source lists, `home` the profile
@@ -91,6 +107,13 @@ export interface IFleetWorkerBackend {
91
107
  forget?(worker: IFleetWorker): void;
92
108
  /** The native status the last poll observed, without reading native state again. */
93
109
  observed?(worker: IFleetWorker): IFleetWorkerReport['status'] | undefined;
110
+ /** The newest turn the polls observed, without reading native state again; it outlives `forget`. */
111
+ observedTurn?(worker: IFleetWorker): IFleetWorkerObservedTurn | undefined;
112
+ /**
113
+ * The wait for a person in the harness's own client that the last poll observed, without reading native state again:
114
+ * a Claude Code job whose process its inventory lists as waiting without the job having failed (`fleetClaudeNativeWait`).
115
+ */
116
+ observedNativeWait?(worker: IFleetWorker): IControllerNativeWait | undefined;
94
117
  /** The newest assistant text the last poll observed, as a session feed excerpt, without reading native state again. */
95
118
  observedExcerpt?(worker: IFleetWorker): string | undefined;
96
119
  /**
@@ -1,4 +1,4 @@
1
- import type { IControllerSystemMetrics } from './interfaces.js';
1
+ import type { IControllerSystemMetrics, TControllerModelLimitKind } from './interfaces.js';
2
2
  import type { ITicketActor } from './tickets.js';
3
3
  import type { IFleetTicketSync } from './fleet.js';
4
4
 
@@ -134,11 +134,27 @@ export interface IFleetWorker {
134
134
  /** `error` is a session binding that stayed on this worker; the next repair that leaves none on it clears the error. */
135
135
  errorSource?: 'binding';
136
136
  }
137
+ /**
138
+ * How the worker's newest native turn ended, as its harness recorded it: a Codex turn's status, with the limit kind of
139
+ * a failure Codex named as a provider limit; a Claude Code job its inventory lists as failed or done. `turnId` names
140
+ * the turn: a Codex turn id, or a Claude Code prompt's transcript uuid (the session id while AGL sees no prompt). A
141
+ * Codex failure stays until a turn with another id is observed. A Claude Code inventory lists the job's state, not a
142
+ * turn's: listing the job `working`, `blocked` or `done` replaces a failure, which stays only while the inventory lists
143
+ * the job with no state, `stopped`, or not at all.
144
+ */
145
+ export interface IFleetWorkerTurnOutcome {
146
+ turnId: string;
147
+ state: 'completed' | 'interrupted' | 'failed';
148
+ limit?: TControllerModelLimitKind;
149
+ }
137
150
  export interface IFleetWorkerReport {
138
151
  worker: IFleetWorker;
152
+ /** The native status, whatever `outcome` says: refresh's settled check, adopt, the board pump and direct reports read this. */
139
153
  status: 'busy' | 'idle' | 'blocked' | 'stopped' | 'archived' | 'reaped' | 'gone';
140
154
  turnId?: string;
141
155
  turnStatus?: string;
156
+ /** Absent while the newest turn runs, and when the harness states no outcome. */
157
+ outcome?: IFleetWorkerTurnOutcome;
142
158
  reportId?: string;
143
159
  text: string;
144
160
  truncated: boolean;
@@ -966,6 +966,23 @@ export interface IControllerPromptQueueHold {
966
966
  resumeAt?: number;
967
967
  }
968
968
 
969
+ /**
970
+ * Why a harness says its session waits for a person in the harness's own client: `approval` and `user_input`, Codex's
971
+ * thread flags `waitingOnApproval` and `waitingOnUserInput`; `native_prompt`, Claude Code's `requires_action`, or a
972
+ * Claude Code job whose process its inventory lists as waiting without the job having failed; `unrecognized`, a wait
973
+ * signal AGL does not know.
974
+ */
975
+ export type TControllerNativeWaitReason = 'approval' | 'user_input' | 'native_prompt' | 'unrecognized';
976
+ export const controllerNativeWaitReasons: readonly TControllerNativeWaitReason[] = ['approval', 'user_input', 'native_prompt', 'unrecognized'];
977
+
978
+ /**
979
+ * A wait the harness signals, projected only: it carries no request id, so nothing in AGL can answer it. Whether AGL
980
+ * holds a request it can answer is `attention`.
981
+ */
982
+ export interface IControllerNativeWait {
983
+ reason: TControllerNativeWaitReason;
984
+ }
985
+
969
986
  export interface IControllerSession {
970
987
  id: IControllerRuntimeId;
971
988
  title: string;
@@ -979,6 +996,11 @@ export interface IControllerSession {
979
996
  codexActivity?: import('./codex.js').IControllerCodexActivitySummary;
980
997
  /** True while OpenCode has a pending permission or question for this session. */
981
998
  attention?: boolean;
999
+ /**
1000
+ * Set while the harness signals that the session waits for a person in its own client (Codex, Claude Code), which
1001
+ * it does only while the session is busy. Absent is no proof that nothing waits: a harness does not signal every wait.
1002
+ */
1003
+ nativeWait?: IControllerNativeWait;
982
1004
  /** Why the last run failed, while the session reports that failure (Flex). */
983
1005
  error?: IControllerSessionError;
984
1006
  /** Set while the running prompt waits to call the model again (Flex). */
@@ -1,6 +1,6 @@
1
1
  import type * as plugins from './plugins.js';
2
- import type { IFleetWorker, IFleetWorkerJob, IFleetWorkerReport, TFleetWorkerAction, TFleetWorkerRequest, TFleetWorkerResponse } from './fleetworkers.js';
3
- import type { IControllerDraftAttachment, IControllerMessageBundle } from './interfaces.js';
2
+ import type { IFleetWorker, IFleetWorkerJob, IFleetWorkerReport, IFleetWorkerTurnOutcome, TFleetWorkerAction, TFleetWorkerRequest, TFleetWorkerResponse } from './fleetworkers.js';
3
+ import type { IControllerDraftAttachment, IControllerMessageBundle, IControllerNativeWait } from './interfaces.js';
4
4
  export const controllerMcpFleetWorkerMethods = ['start', 'adopt', 'resolve-lost', 'reconfirm', 'steer', 'report', 'stop', 'archive', 'refresh', 'move', 'list', 'status', 'watch', 'native-message'].map(
5
5
  (action) => `agl.mcp.fleet.worker.${action}`,
6
6
  ) as Array<`agl.mcp.fleet.worker.${TFleetWorkerAction}`>;
@@ -16,6 +16,15 @@ export interface IControllerFleetWorkerView {
16
16
  worker: IFleetWorker;
17
17
  /** Absent until the controller observed the worker. */
18
18
  status?: IFleetWorkerReport['status'];
19
+ /** How the newest turn the controller observed ended; see `IFleetWorkerReport.outcome`. */
20
+ outcome?: IFleetWorkerTurnOutcome;
21
+ /** When the newest turn the controller observed started (ISO 8601), where the harness states it. */
22
+ turnStartedAt?: string;
23
+ /**
24
+ * The wait for a person in the harness's own client that the controller last observed: a Claude Code job whose
25
+ * process its inventory lists as waiting without the job having failed. Absent is no proof that nothing waits.
26
+ */
27
+ nativeWait?: IControllerNativeWait;
19
28
  /** The tail of the newest assistant text the controller last observed, for harnesses whose poll records it. */
20
29
  excerpt?: string;
21
30
  }