@orion-agents/orion-code 0.4.7 → 0.4.9

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 (142) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +8 -9
  3. package/README.zh-CN.md +8 -8
  4. package/dist/acp/session-updates.js +1 -0
  5. package/dist/cli.js +42 -3
  6. package/dist/commands/session-command-handlers.js +8 -3
  7. package/dist/commands/system-commands.js +3 -3
  8. package/dist/commands/types.d.ts +3 -0
  9. package/dist/framework/loop-progress.js +3 -1
  10. package/dist/framework/query.d.ts +6 -8
  11. package/dist/framework/query.js +39 -76
  12. package/dist/framework/tool-serializer.d.ts +12 -0
  13. package/dist/framework/tool-serializer.js +35 -0
  14. package/dist/framework/tool.d.ts +2 -0
  15. package/dist/framework/verification-command.d.ts +21 -0
  16. package/dist/framework/verification-command.js +53 -4
  17. package/dist/harness/context-harness.d.ts +3 -9
  18. package/dist/harness/context-harness.js +43 -163
  19. package/dist/harness/ledger.js +2 -1
  20. package/dist/harness/state.d.ts +3 -0
  21. package/dist/harness/state.js +37 -4
  22. package/dist/harness/task-checklist.d.ts +1 -1
  23. package/dist/harness/task-checklist.js +1 -1
  24. package/dist/harness/types.d.ts +1 -0
  25. package/dist/harness/verification.js +5 -4
  26. package/dist/print-ui/delivery.d.ts +15 -0
  27. package/dist/print-ui/delivery.js +131 -0
  28. package/dist/print-ui/event-stream.d.ts +6 -1
  29. package/dist/print-ui/event-stream.js +56 -10
  30. package/dist/print-ui/launch.d.ts +5 -0
  31. package/dist/print-ui/launch.js +66 -9
  32. package/dist/runtime/agent-loop.d.ts +3 -1
  33. package/dist/runtime/agent-loop.js +26 -41
  34. package/dist/runtime/agent-runtime-controller.d.ts +4 -1
  35. package/dist/runtime/agent-runtime-controller.js +36 -22
  36. package/dist/runtime/agent-runtime-runner.d.ts +4 -0
  37. package/dist/runtime/agent-runtime-runner.js +9 -0
  38. package/dist/runtime/builtin-tool-provider.js +6 -5
  39. package/dist/runtime/composer/layout.d.ts +1 -1
  40. package/dist/runtime/composer/layout.js +5 -5
  41. package/dist/runtime/core-tools/descriptors.d.ts +1 -1
  42. package/dist/runtime/core-tools/descriptors.js +39 -1
  43. package/dist/runtime/first-party-core-provider.js +1 -0
  44. package/dist/runtime/first-party-tool-services.js +10 -0
  45. package/dist/runtime/goal-lifecycle-v2.js +5 -0
  46. package/dist/runtime/goal-runtime-coordinator.js +6 -2
  47. package/dist/runtime/goals/evidence.js +2 -0
  48. package/dist/runtime/legacy-thread-materializer.d.ts +7 -0
  49. package/dist/runtime/legacy-thread-materializer.js +32 -6
  50. package/dist/runtime/orion-runtime-v1.d.ts +2 -1
  51. package/dist/runtime/orion-runtime-v1.js +34 -6
  52. package/dist/runtime/product-bootstrap.d.ts +2 -0
  53. package/dist/runtime/product-bootstrap.js +1 -0
  54. package/dist/runtime/product-orion-runtime.d.ts +2 -1
  55. package/dist/runtime/product-orion-runtime.js +7 -2
  56. package/dist/runtime/rich-text/layout.d.ts +3 -1
  57. package/dist/runtime/rich-text/layout.js +37 -22
  58. package/dist/runtime/shell-process-sessions.d.ts +41 -0
  59. package/dist/runtime/shell-process-sessions.js +258 -0
  60. package/dist/runtime/step-snapshot.js +61 -11
  61. package/dist/runtime/subagents/presets.d.ts +1 -1
  62. package/dist/runtime/subagents/presets.js +1 -0
  63. package/dist/runtime/task-context-recovery.js +14 -3
  64. package/dist/runtime/task-context-service.d.ts +2 -6
  65. package/dist/runtime/task-context-service.js +3 -12
  66. package/dist/runtime/thread-event-store.d.ts +3 -0
  67. package/dist/runtime/thread-event-store.js +35 -22
  68. package/dist/runtime/thread-session-index.d.ts +15 -3
  69. package/dist/runtime/thread-session-index.js +152 -45
  70. package/dist/runtime/thread-session-view.js +1 -1
  71. package/dist/runtime/thread-ui-adapter.d.ts +1 -1
  72. package/dist/runtime/thread-ui-adapter.js +23 -5
  73. package/dist/runtime/tool-gateway.d.ts +1 -0
  74. package/dist/runtime/tool-gateway.js +1 -0
  75. package/dist/runtime/tool-transcript-entry.d.ts +8 -1
  76. package/dist/runtime/tool-transcript-entry.js +35 -7
  77. package/dist/runtime/ui-events.d.ts +10 -0
  78. package/dist/runtime/verification-feedback.d.ts +4 -0
  79. package/dist/runtime/verification-feedback.js +61 -0
  80. package/dist/services/global-config.d.ts +1 -1
  81. package/dist/services/global-config.js +2 -0
  82. package/dist/services/llm.d.ts +3 -0
  83. package/dist/services/llm.js +48 -4
  84. package/dist/terminal-ui/raw-editor.js +2 -1
  85. package/dist/tools/bash_security.d.ts +1 -24
  86. package/dist/tools/bash_security.js +7 -124
  87. package/dist/tools/core/exec-command.js +51 -42
  88. package/dist/tools/core/index.d.ts +2 -1
  89. package/dist/tools/core/index.js +4 -1
  90. package/dist/tools/core/process-session.d.ts +2 -0
  91. package/dist/tools/core/process-session.js +54 -0
  92. package/dist/tools/todo.js +9 -13
  93. package/dist/tui-core/frame.d.ts +2 -0
  94. package/dist/tui-core/frame.js +19 -0
  95. package/dist/tui-core/input-parser.d.ts +4 -1
  96. package/dist/tui-core/input-parser.js +22 -0
  97. package/dist/tui-ui/chrome-view-model.d.ts +0 -2
  98. package/dist/tui-ui/chrome-view-model.js +54 -56
  99. package/dist/tui-ui/launch.js +133 -202
  100. package/dist/tui-ui/layout.d.ts +16 -41
  101. package/dist/tui-ui/layout.js +408 -295
  102. package/dist/tui-ui/render-scheduler.d.ts +2 -5
  103. package/dist/tui-ui/render-scheduler.js +10 -10
  104. package/dist/tui-ui/response-clipboard.d.ts +17 -0
  105. package/dist/tui-ui/response-clipboard.js +201 -0
  106. package/dist/tui-ui/runner.d.ts +65 -80
  107. package/dist/tui-ui/runner.js +545 -738
  108. package/dist/tui-ui/session-picker-preview.d.ts +8 -0
  109. package/dist/tui-ui/session-picker-preview.js +119 -0
  110. package/dist/tui-ui/session-picker.d.ts +20 -0
  111. package/dist/tui-ui/session-picker.js +42 -0
  112. package/dist/tui-ui/state.d.ts +34 -81
  113. package/dist/tui-ui/state.js +155 -288
  114. package/dist/tui-ui/terminal-image.d.ts +3 -7
  115. package/dist/tui-ui/terminal-image.js +18 -47
  116. package/dist/tui-ui/terminal-viewport.d.ts +55 -0
  117. package/dist/tui-ui/terminal-viewport.js +221 -0
  118. package/dist/tui-ui/transcript-layout.d.ts +5 -0
  119. package/dist/tui-ui/transcript-layout.js +43 -28
  120. package/dist/tui-ui/transcript-pager.d.ts +39 -0
  121. package/dist/tui-ui/transcript-pager.js +278 -0
  122. package/dist/tui-ui/transcript-tool-output.d.ts +16 -0
  123. package/dist/tui-ui/transcript-tool-output.js +102 -0
  124. package/dist/utils/bounded-file.d.ts +4 -0
  125. package/dist/utils/bounded-file.js +30 -0
  126. package/dist/utils/command-process.d.ts +4 -0
  127. package/dist/utils/command-process.js +23 -0
  128. package/dist/utils/shell-command.d.ts +29 -0
  129. package/dist/utils/shell-command.js +185 -0
  130. package/docs/cli-guide.md +50 -6
  131. package/npm-shrinkwrap.json +115 -15
  132. package/package.json +4 -1
  133. package/dist/tui-ui/inline-surface.d.ts +0 -191
  134. package/dist/tui-ui/inline-surface.js +0 -644
  135. package/dist/tui-ui/input-ownership.d.ts +0 -46
  136. package/dist/tui-ui/input-ownership.js +0 -74
  137. package/dist/tui-ui/transcript-inspector-layout.d.ts +0 -9
  138. package/dist/tui-ui/transcript-inspector-layout.js +0 -107
  139. package/dist/tui-ui/transcript-inspector-surface.d.ts +0 -18
  140. package/dist/tui-ui/transcript-inspector-surface.js +0 -91
  141. package/dist/tui-ui/transcript-inspector.d.ts +0 -36
  142. package/dist/tui-ui/transcript-inspector.js +0 -129
@@ -24,6 +24,8 @@ export declare function createTuiFrame(width: number, height: number): TuiFrame;
24
24
  export declare function writeFrameText(frame: TuiFrame, row: number, column: number, text: string, style?: TuiStyle): void;
25
25
  export declare function setFrameCursor(frame: TuiFrame, row: number, column: number, visible?: boolean): void;
26
26
  export declare function renderFrameRows(frame: TuiFrame): string[];
27
+ /** Match printed cells. A uniform background suffix can be painted with erase-to-line-end. */
28
+ export declare function trimFrameRow(row: TuiCell[]): TuiCell[];
27
29
  export declare function diffTuiFrames(previous: TuiFrame | null, next: TuiFrame): TuiFrameDiff;
28
30
  /**
29
31
  * Render a single frame row into styled spans by merging consecutive cells
@@ -7,6 +7,7 @@ exports.createTuiFrame = createTuiFrame;
7
7
  exports.writeFrameText = writeFrameText;
8
8
  exports.setFrameCursor = setFrameCursor;
9
9
  exports.renderFrameRows = renderFrameRows;
10
+ exports.trimFrameRow = trimFrameRow;
10
11
  exports.diffTuiFrames = diffTuiFrames;
11
12
  exports.renderStyledFrameRow = renderStyledFrameRow;
12
13
  const string_width_1 = __importDefault(require("string-width"));
@@ -60,6 +61,24 @@ function setFrameCursor(frame, row, column, visible = true) {
60
61
  function renderFrameRows(frame) {
61
62
  return frame.rows.map(row => row.map(cell => (cell.width === 0 ? '' : cell.char)).join(''));
62
63
  }
64
+ /** Match printed cells. A uniform background suffix can be painted with erase-to-line-end. */
65
+ function trimFrameRow(row) {
66
+ const last = row.at(-1);
67
+ if (!last || last.char !== ' ')
68
+ return row;
69
+ const suffixKey = (0, style_1.styleKey)(last.style);
70
+ const backgroundKey = (0, style_1.styleKey)({ background: last.style.background });
71
+ if (suffixKey !== backgroundKey)
72
+ return row;
73
+ let end = row.length;
74
+ while (end > 0) {
75
+ const cell = row[end - 1];
76
+ if (cell.char !== ' ' || (0, style_1.styleKey)(cell.style) !== suffixKey)
77
+ break;
78
+ end -= 1;
79
+ }
80
+ return row.slice(0, end);
81
+ }
63
82
  function diffTuiFrames(previous, next) {
64
83
  if (!previous || previous.width !== next.width || previous.height !== next.height) {
65
84
  return {
@@ -4,12 +4,15 @@ export type TuiInputEvent = {
4
4
  } | {
5
5
  type: 'paste';
6
6
  value: string;
7
+ } | {
8
+ type: 'wheel';
9
+ direction: -1 | 1;
7
10
  } | {
8
11
  type: 'key';
9
12
  key: TuiKey;
10
13
  raw: string;
11
14
  };
12
- export type TuiKey = 'enter' | 'tab' | 'shift+tab' | 'escape' | 'backspace' | 'delete' | 'ctrl+c' | 'ctrl+u' | 'ctrl+w' | 'ctrl+l' | 'ctrl+o' | 'ctrl+r' | 'ctrl+e' | 'ctrl+d' | 'newline' | 'left' | 'right' | 'up' | 'down' | 'home' | 'end' | 'pageup' | 'pagedown';
15
+ export type TuiKey = 'enter' | 'tab' | 'shift+tab' | 'escape' | 'backspace' | 'delete' | 'ctrl+b' | 'ctrl+c' | 'ctrl+u' | 'ctrl+w' | 'ctrl+l' | 'ctrl+o' | 'ctrl+r' | 'ctrl+t' | 'ctrl+e' | 'ctrl+f' | 'ctrl+d' | 'newline' | 'left' | 'right' | 'up' | 'alt+up' | 'down' | 'home' | 'end' | 'pageup' | 'pagedown';
13
16
  export interface TuiInputParserState {
14
17
  mode: 'normal' | 'paste';
15
18
  incompleteUtf8: Buffer;
@@ -14,6 +14,7 @@ const PASTE_END = '\x1b[201~';
14
14
  const CSI_KEYS = {
15
15
  '\x1b[Z': 'shift+tab',
16
16
  '\x1b[A': 'up',
17
+ '\x1b[1;3A': 'alt+up',
17
18
  '\x1b[B': 'down',
18
19
  '\x1b[C': 'right',
19
20
  '\x1b[D': 'left',
@@ -118,6 +119,18 @@ class TuiInputParser {
118
119
  index += PASTE_END.length;
119
120
  continue;
120
121
  }
122
+ const mouse = /^\x1b\[<(\d{1,5});\d{1,5};\d{1,5}([Mm])/u.exec(slice);
123
+ if (mouse) {
124
+ const button = Number(mouse[1]) & ~28; // Ignore Shift, Alt and Ctrl modifier bits.
125
+ if (this.state.mode === 'paste') {
126
+ this.state.pasteBuffer += mouse[0];
127
+ }
128
+ else if (mouse[2] === 'M' && (button === 64 || button === 65)) {
129
+ events.push({ type: 'wheel', direction: button === 64 ? -1 : 1 });
130
+ }
131
+ index += mouse[0].length;
132
+ continue;
133
+ }
121
134
  const csiKey = readCsiKey(slice);
122
135
  if (csiKey) {
123
136
  if (this.state.mode === 'paste') {
@@ -182,6 +195,9 @@ exports.TuiInputParser = TuiInputParser;
182
195
  function readIncompleteEscapePrefix(value) {
183
196
  if (!value.startsWith('\x1b'))
184
197
  return null;
198
+ // Mouse reports may be split across input chunks, like bracketed paste and CSI keys.
199
+ if (/^\x1b\[<(?:\d{1,5};){0,2}\d{0,5}$/u.test(value))
200
+ return value;
185
201
  const knownSequences = [PASTE_START, PASTE_END, ...Object.keys(CSI_KEYS)];
186
202
  return knownSequences.some(sequence => sequence.startsWith(value)) ? value : null;
187
203
  }
@@ -203,6 +219,10 @@ function controlKeyFromChar(char) {
203
219
  case '\x7f':
204
220
  case '\b':
205
221
  return 'backspace';
222
+ case '\x02':
223
+ return 'ctrl+b';
224
+ case '\x06':
225
+ return 'ctrl+f';
206
226
  case '\x03':
207
227
  return 'ctrl+c';
208
228
  case '\x15':
@@ -215,6 +235,8 @@ function controlKeyFromChar(char) {
215
235
  return 'ctrl+o';
216
236
  case '\x12':
217
237
  return 'ctrl+r';
238
+ case '\x14':
239
+ return 'ctrl+t';
218
240
  case '\x05':
219
241
  return 'ctrl+e';
220
242
  case '\x04':
@@ -11,9 +11,7 @@ export interface TuiChromeSegment {
11
11
  export interface TuiChromeViewModel {
12
12
  phase: 'ready' | 'working' | 'waiting' | 'error' | 'paused';
13
13
  pose: PixelHunterPose;
14
- promptMode: 'normal' | 'plan' | 'auto' | 'goal';
15
14
  segments: TuiChromeSegment[];
16
- hint: string;
17
15
  }
18
16
  export declare function createTuiChromeViewModel(state: TuiUiState, requested?: readonly TuiStatusItem[]): TuiChromeViewModel;
19
17
  //# sourceMappingURL=chrome-view-model.d.ts.map
@@ -11,6 +11,14 @@ const DEFAULT_ITEMS = [
11
11
  'queue',
12
12
  'activity',
13
13
  ];
14
+ const MODE_LABELS = { interactive: 'BUILD', plan: 'PLAN', auto: 'AUTO' };
15
+ // Exact presentation formats from statusSnapshotString and the runtime status emitters.
16
+ // Messages with additional user-facing text stay available as notices.
17
+ const SNAPSHOT_STATUS = /^model=(\S+)(?:\s+(?:ctx=\d+%(?: (?:auto-compact|\/compact))?|session=\S+|tokens=\S+))*$/u;
18
+ const SNAPSHOT_CONTEXT = /(?:^|\s)(ctx=\d+%(?: (?:auto-compact|\/compact))?)(?:\s|$)/u;
19
+ const RUNNER_STATUS = /^(?:Ready|Running(?: · (?:BUILD|PLAN|AUTO|INTERACTIVE))?|Working(?:: (?:thinking|reading tool results|running (?:tool|\d+ tools)))?|Waiting: permission required for \S+)$/u;
20
+ const GOAL_DECISION_NOTICE = /^Goal (?:(?:evidence|audit) (?:passed|failed)|complete)\b/u;
21
+ const GOAL_ACTION_NOTICE = /^Goal (?:paused|blocked|budget_limited|usage_limited)\b/u;
14
22
  function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
15
23
  const waiting = state.overlay?.type === 'permission';
16
24
  const errored = state.statusState.phase === 'error';
@@ -38,14 +46,9 @@ function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
38
46
  ? 'success'
39
47
  : 'ready';
40
48
  const all = new Map();
41
- const baseModeLabel = state.agentMode.baseMode === 'interactive' ? 'BUILD' : state.agentMode.baseMode.toUpperCase();
42
- const pendingModeLabel = state.agentMode.pendingBaseMode
43
- ? state.agentMode.pendingBaseMode === 'interactive'
44
- ? 'BUILD'
45
- : state.agentMode.pendingBaseMode.toUpperCase()
46
- : null;
49
+ const status = state.statusMessage.trim();
50
+ const snapshotStatus = SNAPSHOT_STATUS.exec(status);
47
51
  const goalMode = state.goal?.status === 'active';
48
- const modeLabel = `${goalMode ? `GOAL · ${baseModeLabel}` : baseModeLabel}${pendingModeLabel ? ` → ${pendingModeLabel} NEXT` : ''}`;
49
52
  const baseTone = state.agentMode.baseMode === 'plan'
50
53
  ? 'mode-plan'
51
54
  : state.agentMode.baseMode === 'auto'
@@ -53,7 +56,7 @@ function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
53
56
  : 'mode-build';
54
57
  all.set('mode', {
55
58
  id: 'mode',
56
- label: modeLabel,
59
+ label: MODE_LABELS[state.agentMode.baseMode],
57
60
  priority: Number.MAX_SAFE_INTEGER,
58
61
  tone: goalMode ? 'mode-goal' : baseTone,
59
62
  });
@@ -71,13 +74,18 @@ function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
71
74
  const time = timeLimit === undefined
72
75
  ? ''
73
76
  : ` time:${Math.floor(state.goal.timeUsedMs / 1000)}/${timeLimit / 1000}s`;
74
- const statusShowsAudit = state.statusMessage.startsWith('Goal audit failed (');
77
+ const statusShowsAudit = status.startsWith('Goal audit failed (');
75
78
  const audit = !statusShowsAudit && state.goal.auditRemaining?.[0]
76
79
  ? ` audit:${state.goal.auditRemaining[0]}`
77
80
  : '';
78
- const next = state.goal.nextAction && !state.statusMessage.includes(state.goal.nextAction)
81
+ const next = state.goal.nextAction && !status.includes(state.goal.nextAction)
79
82
  ? ` next:${state.goal.nextAction}`
80
83
  : '';
84
+ const reason = state.goal.status !== 'complete' &&
85
+ state.goal.stopReason &&
86
+ !status.includes(state.goal.stopReason)
87
+ ? ` reason:${state.goal.stopReason}`
88
+ : '';
81
89
  const actions = budgetLimited
82
90
  ? ' /goal budget'
83
91
  : ['paused', 'blocked', 'usage_limited'].includes(state.goal.status)
@@ -89,38 +97,38 @@ function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
89
97
  // Usage is the durable progress signal operators need most. Keep it at
90
98
  // the left edge so objective/plan text can be clipped on narrow frames
91
99
  // without hiding how much this Goal has consumed.
92
- label: `${progressLabel}${objective}${plan}${audit}${next}`,
100
+ label: `${progressLabel}${objective}${plan}${audit}${next}${reason}`,
93
101
  compactLabel: progressLabel,
94
102
  priority: 115,
95
103
  });
96
104
  }
97
105
  const snapshot = state.statusState.snapshot;
98
- const modelStatus = snapshot?.model
99
- ? `model=${snapshot.model}`
100
- : state.statusMessage.match(/\bmodel=[^\s]+/u)
101
- ? state.statusMessage
102
- : undefined;
103
- if (modelStatus) {
106
+ const model = snapshot?.model || snapshotStatus?.[1];
107
+ if (model) {
104
108
  all.set('model', {
105
109
  id: 'model',
106
- label: modelStatus,
110
+ label: model,
107
111
  priority: 105,
108
112
  });
109
113
  }
110
114
  if (state.effort) {
111
- const value = 'effective' in state.effort ? (state.effort.effective ?? 'auto') : 'off';
112
- all.set('effort', { id: 'effort', label: `EFFORT ${value}`, priority: 35 });
115
+ const value = state.effort.type === 'effort_unavailable' ? 'off' : (state.effort.effective ?? 'auto');
116
+ all.set('effort', {
117
+ id: 'effort',
118
+ label: `effort ${value}`,
119
+ compactLabel: value,
120
+ priority: 35,
121
+ });
113
122
  }
114
- const contextMeter = (0, ui_view_model_1.contextUsageStatusText)(snapshot?.context);
123
+ const contextMeter = (0, ui_view_model_1.contextUsageStatusText)(snapshot?.context) ||
124
+ (snapshotStatus ? (SNAPSHOT_CONTEXT.exec(status)?.[1] ?? '') : '');
115
125
  const background = (0, ui_view_model_1.backgroundCompactStatusText)(snapshot?.backgroundCompact);
116
126
  const context = [contextMeter, background].filter(Boolean).join(' ');
117
127
  if (context) {
118
128
  all.set('context', {
119
129
  id: 'context',
120
130
  label: context.toUpperCase(),
121
- compactLabel: (background || contextMeter.split(' ')[0])
122
- .replace(/ history$/u, '')
123
- .toUpperCase(),
131
+ compactLabel: (background || contextMeter.split(' ')[0]).toUpperCase(),
124
132
  priority: background ? 130 : 107,
125
133
  });
126
134
  }
@@ -132,48 +140,38 @@ function createTuiChromeViewModel(state, requested = DEFAULT_ITEMS) {
132
140
  priority: 125,
133
141
  });
134
142
  }
135
- const active = state.statusState.activeTools + state.statusState.activeSubtasks;
136
- const statusDuplicatesGoal = Boolean(state.goal &&
137
- (state.statusMessage.startsWith('Goal restored ') ||
138
- (state.goal.status !== 'complete' &&
139
- state.statusMessage.startsWith(`Goal ${state.goal.status}:`))));
140
- const researchStatus = state.research ? (0, ui_view_model_1.researchProjectionLabel)(state.research) : '';
141
- const working = active > 0 ? `Tools ${active}` : state.processing ? 'Working' : '';
142
- const attention = errored ? 'Error' : waiting ? 'Approval' : working;
143
- const message = !statusDuplicatesGoal && !state.statusMessage.startsWith(modelStatus ?? '\0') && !researchStatus
144
- ? state.statusMessage
145
- : '';
146
- const activityParts = [attention, researchStatus, message].filter(Boolean);
147
- if (activityParts.length > 0) {
148
- const lifecycleDecision = state.statusMessage.startsWith('Goal complete:') ||
149
- /^Goal (?:evidence|audit) (?:passed|failed)/u.test(state.statusMessage);
150
- const compactDecision = /^Goal (?:(?:evidence|audit) (?:passed|failed)|complete)/u.exec(state.statusMessage)?.[0];
143
+ const goal = state.goal;
144
+ const statusDuplicatesGoal = goal &&
145
+ (status === `Goal restored ${goal.status}: ${goal.objective}` ||
146
+ (goal.status === 'active' && status === `Goal active: ${goal.objective}`));
147
+ const message = snapshotStatus || statusDuplicatesGoal || RUNNER_STATUS.test(status) ? '' : status;
148
+ const lastResearchEvent = state.researchEvents.at(-1);
149
+ const research = state.research;
150
+ const notice = research &&
151
+ (!message ||
152
+ (lastResearchEvent && message === (0, ui_view_model_1.formatResearchLifecycleEvent)(lastResearchEvent, 'tui')))
153
+ ? (0, ui_view_model_1.researchProjectionLabel)(research)
154
+ : message;
155
+ const pendingMode = state.agentMode.pendingBaseMode;
156
+ const pendingModeNotice = pendingMode ? `${MODE_LABELS[pendingMode]} next` : '';
157
+ if (notice || pendingModeNotice) {
158
+ const decision = GOAL_DECISION_NOTICE.exec(notice)?.[0];
159
+ const action = GOAL_ACTION_NOTICE.exec(notice)?.[0];
151
160
  all.set('activity', {
152
161
  id: 'activity',
153
- label: activityParts.join(' · '),
154
- compactLabel: compactDecision ?? (attention || undefined),
155
- // Evidence/audit decisions are state transitions, not decorative activity.
156
- // Keep them visible ahead of the model and Goal summary so operators and
157
- // PTY automation can observe the transition before the next tool prompt.
158
- priority: errored || waiting ? 140 : lifecycleDecision ? 120 : working ? 110 : 70,
162
+ label: [notice, pendingModeNotice].filter(Boolean).join(' · '),
163
+ compactLabel: decision ?? action ?? (pendingModeNotice || undefined),
164
+ // Keep evidence and audit decisions visible before the next tool prompt.
165
+ // Recovery actions in the Goal segment take priority over the stop reason.
166
+ priority: errored || waiting ? 140 : decision ? 120 : action || pendingMode ? 110 : 70,
159
167
  });
160
168
  }
161
169
  return {
162
170
  phase,
163
171
  pose,
164
- promptMode: state.goal
165
- ? 'goal'
166
- : state.agentMode.baseMode === 'plan'
167
- ? 'plan'
168
- : state.agentMode.baseMode === 'auto'
169
- ? 'auto'
170
- : 'normal',
171
172
  segments: ['mode', ...requested.filter(id => id !== 'mode')]
172
173
  .map(id => all.get(id))
173
174
  .filter((item) => Boolean(item)),
174
- hint: state.processing
175
- ? 'Enter steer · Tab queue · Shift+Tab mode · Esc stop · ? help'
176
- : 'Enter send · Shift+Tab mode · / commands · @ files · ? help',
177
175
  };
178
176
  }
179
177
  function formatGoalTokenUsage(tokens) {