pantheon-opencode 1.4.2 → 1.4.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.
- package/README.md +27 -115
- package/package.json +1 -1
- package/src/agents/zeus.md +14 -25
- package/src/pantheon/cost-command.ts +7 -7
- package/src/pantheon/delegation-enforce.ts +12 -13
- package/src/pantheon/goal-loop.ts +2 -2
- package/src/pantheon/goal-store.ts +1 -1
- package/src/pantheon/hashline/tool.ts +2 -2
- package/src/pantheon/model-command.ts +87 -34
- package/src/pantheon/tool-context.ts +41 -0
- package/src/plugin.ts +41 -193
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/index.tsx +8 -6
- package/src/pantheon/delegation-classifier.ts +0 -307
- package/src/pantheon/delegation-finalize.ts +0 -374
- package/src/pantheon/delegation-notify.ts +0 -197
- package/src/pantheon/delegation-toast.ts +0 -73
- package/src/pantheon/delegation.ts +0 -1120
- package/src/pantheon/permission-eval.ts +0 -284
- package/src/pantheon/step-cap.ts +0 -110
- package/src/pantheon/zeus-delegate-with-retry.ts +0 -406
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pantheon-tui",
|
|
9
|
-
"version": "1.4.
|
|
9
|
+
"version": "1.4.3",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@opencode-ai/plugin": ">=1.14.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.3",
|
|
5
5
|
"description": "Pantheon TUI plugin — sidebar (version, preset, sessions, real-time delegations) + AI subscription usage gauges incl. OpenCode Go/Zen dollar limits (vendored, MIT)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -905,9 +905,10 @@ async function setupUsageBar(api: TuiPluginApi) {
|
|
|
905
905
|
* board row for the same child (a child WITH a report keeps the md
|
|
906
906
|
* entry, source 'md').
|
|
907
907
|
*
|
|
908
|
-
* 2. ENRICHMENT + HISTORY — markdown reports
|
|
909
|
-
* `.pantheon/delegations/<sessionID>/<alias>.md
|
|
910
|
-
* src/pantheon/delegation-finalize.ts
|
|
908
|
+
* 2. ENRICHMENT + HISTORY — markdown reports under
|
|
909
|
+
* `.pantheon/delegations/<sessionID>/<alias>.md`. These are LEGACY files
|
|
910
|
+
* (the writer, src/pantheon/delegation-finalize.ts, was removed); the
|
|
911
|
+
* panel still reads them for history. Each child
|
|
911
912
|
* is matched to its report by the `Task ID` header (== child session
|
|
912
913
|
* id == board task id), which supplies the alias (apo-N), agent,
|
|
913
914
|
* description and terminal duration/timedOut. No report → the child
|
|
@@ -1151,7 +1152,8 @@ export async function readDelegationEntries(dir: string): Promise<DelegationEntr
|
|
|
1151
1152
|
|
|
1152
1153
|
/** Read delegation reports from EVERY session under
|
|
1153
1154
|
* `<root>/.pantheon/delegations/<sessionID>/<alias>.md` — the panel's
|
|
1154
|
-
* HISTORY channel
|
|
1155
|
+
* HISTORY channel (reads legacy files; the writer, delegation-finalize.ts,
|
|
1156
|
+
* was removed). Unlike the children/live channels it does NOT depend on a
|
|
1155
1157
|
* resolved sessionID: with no focused session (null/placeholder), the panel
|
|
1156
1158
|
* still shows the reports from all past sessions (running first, Finalized
|
|
1157
1159
|
* desc — the sort applied by readDelegationEntries). Fail-open: a
|
|
@@ -1160,8 +1162,8 @@ export async function readAllDelegationEntries(root: string): Promise<Delegation
|
|
|
1160
1162
|
return readDelegationEntries(join(root, '.pantheon', 'delegations'))
|
|
1161
1163
|
}
|
|
1162
1164
|
|
|
1163
|
-
/** Resolve the directory
|
|
1164
|
-
* The
|
|
1165
|
+
/** Resolve the directory holding delegation md reports.
|
|
1166
|
+
* The reports live under `.pantheon/delegations` RELATIVE to the server cwd,
|
|
1165
1167
|
* which the TUI exposes as `TuiState.path.directory`. `project` does NOT
|
|
1166
1168
|
* exist on `TuiState.path` (the old `state?.project ?? state?.worktree`
|
|
1167
1169
|
* resolution was always undefined for the first term) and `worktree` is
|
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delegation Classifier — stuck-agent detection for delegation results.
|
|
3
|
-
*
|
|
4
|
-
* Classifies delegation results into actionable statuses:
|
|
5
|
-
* - `content` / `success` — agent returned usable output
|
|
6
|
-
* - `empty` (empty-mode1 / empty-mode2) — no or near-no output; retryable
|
|
7
|
-
* - `budget-exhausted` — agent hit max_steps; partial result available
|
|
8
|
-
* - `timeout` (timeout-with-partial / timeout-empty / timeout-exhausted)
|
|
9
|
-
* - `error` — provider or infrastructure failure
|
|
10
|
-
*
|
|
11
|
-
* Integrates with the existing `dispatch-guard.ts` classification for
|
|
12
|
-
* empty-response detection and provides a structured `DelegationResult`
|
|
13
|
-
* that replaces raw-text returns.
|
|
14
|
-
*
|
|
15
|
-
* @module delegation-classifier
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
// ─── Types ─────────────────────────────────────────────────────────────
|
|
19
|
-
|
|
20
|
-
/** Empty-response mode classification (matches dispatch-guard). */
|
|
21
|
-
export type EmptyMode = 'empty-mode1' | 'empty-mode2'
|
|
22
|
-
|
|
23
|
-
/** Timeout sub-type based on partial output and retry history. */
|
|
24
|
-
export type TimeoutSubType = 'timeout-with-partial' | 'timeout-empty' | 'timeout-exhausted'
|
|
25
|
-
|
|
26
|
-
/** Structured delegation result replacing raw-text returns. */
|
|
27
|
-
export interface DelegationResult {
|
|
28
|
-
status:
|
|
29
|
-
| 'success'
|
|
30
|
-
| 'empty'
|
|
31
|
-
| 'budget-exhausted'
|
|
32
|
-
| 'timeout'
|
|
33
|
-
| 'error'
|
|
34
|
-
| 'startup_failed'
|
|
35
|
-
| 'bootstrap_unknown'
|
|
36
|
-
content: string
|
|
37
|
-
retryCount: number
|
|
38
|
-
/** When status is 'empty', which empty mode was detected. */
|
|
39
|
-
classification?: EmptyMode | undefined
|
|
40
|
-
/** When status is 'timeout', the timeout sub-type. */
|
|
41
|
-
subType?: TimeoutSubType | undefined
|
|
42
|
-
/** Available when budget-exhausted or timeout-with-partial. */
|
|
43
|
-
partialResult?: string | undefined
|
|
44
|
-
/** Actionable recommendation for the orchestrator. */
|
|
45
|
-
recommendation?: string | undefined
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** Result of empty-response classification. */
|
|
49
|
-
export interface EmptyClassification {
|
|
50
|
-
mode: EmptyMode | 'content'
|
|
51
|
-
hasContent: boolean
|
|
52
|
-
hasTokens: boolean
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Timeout classification input. */
|
|
56
|
-
export interface TimeoutClassifyInput {
|
|
57
|
-
/** Report markdown (undefined if no report was written). */
|
|
58
|
-
report: string | undefined
|
|
59
|
-
/** Whether the child session had any messages at all. */
|
|
60
|
-
hasMessages: boolean
|
|
61
|
-
/** How many retries have already been attempted (0 or 1). */
|
|
62
|
-
retryCount: number
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Result of stuck-agent classification. */
|
|
66
|
-
export interface StuckClassification {
|
|
67
|
-
status: 'success' | 'budget-exhausted' | 'empty'
|
|
68
|
-
partialResult?: string | undefined
|
|
69
|
-
recommendation?: string | undefined
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// ─── Patterns ──────────────────────────────────────────────────────────
|
|
73
|
-
|
|
74
|
-
/** Matches budget-exhausted messages from the agent or step-cap system. */
|
|
75
|
-
const BUDGET_EXHAUSTED_RE =
|
|
76
|
-
/maximum\s+(?:steps?|step\s*budget)\s+(?:for\s+this\s+agent\s+)?(?:has|have)\s+been\s+reached|step\s*budget\s+(?:was\s+)?exhausted/i
|
|
77
|
-
|
|
78
|
-
/** Output-captured marker in delegation reports. */
|
|
79
|
-
const NO_OUTPUT_RE = /_No output captured\._/i
|
|
80
|
-
|
|
81
|
-
// ─── Empty-Response Classification ────────────────────────────────────
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Classify whether a response is empty, empty-with-tokens, or has content.
|
|
85
|
-
* Matches the dispatch-guard classification (empty-mode1, empty-mode2).
|
|
86
|
-
*
|
|
87
|
-
* @param text The response text (may be null/undefined).
|
|
88
|
-
* @param tokens Optional token counts for mode2 detection.
|
|
89
|
-
*/
|
|
90
|
-
export function classifyEmptyResponse(
|
|
91
|
-
text: string | null | undefined,
|
|
92
|
-
tokens?: { tokensInput?: number; tokensOutput?: number },
|
|
93
|
-
): EmptyClassification {
|
|
94
|
-
const hasContent = typeof text === 'string' && text.trim() !== ''
|
|
95
|
-
if (hasContent) {
|
|
96
|
-
return { mode: 'content', hasContent: true, hasTokens: hasTokens(tokens) }
|
|
97
|
-
}
|
|
98
|
-
const hasT = hasTokens(tokens)
|
|
99
|
-
return {
|
|
100
|
-
mode: hasT ? 'empty-mode2' : 'empty-mode1',
|
|
101
|
-
hasContent: false,
|
|
102
|
-
hasTokens: hasT,
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** Whether token counts indicate the model actually ran. */
|
|
107
|
-
function hasTokens(tokens?: { tokensInput?: number; tokensOutput?: number }): boolean {
|
|
108
|
-
if (tokens === undefined) return false
|
|
109
|
-
return (tokens.tokensInput ?? 0) > 0 || (tokens.tokensOutput ?? 0) > 0
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// ─── Stuck-Agent Detection ────────────────────────────────────────────
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Classify a report as success, budget-exhausted, or empty.
|
|
116
|
-
* Detects max-steps patterns in the report text.
|
|
117
|
-
*
|
|
118
|
-
* @param report The delegation report markdown.
|
|
119
|
-
*/
|
|
120
|
-
export function classifyStuckAgent(report: string): StuckClassification {
|
|
121
|
-
const trimmed = report.trim()
|
|
122
|
-
|
|
123
|
-
// Empty output
|
|
124
|
-
if (NO_OUTPUT_RE.test(trimmed) || trimmed === '') {
|
|
125
|
-
return { status: 'empty' }
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Budget-exhausted: extract content before the marker as partialResult
|
|
129
|
-
if (BUDGET_EXHAUSTED_RE.test(trimmed)) {
|
|
130
|
-
const outputSection = extractOutputSection(trimmed)
|
|
131
|
-
const partialResult =
|
|
132
|
-
outputSection !== undefined && !NO_OUTPUT_RE.test(outputSection) ? outputSection : undefined
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
status: 'budget-exhausted',
|
|
136
|
-
partialResult,
|
|
137
|
-
recommendation:
|
|
138
|
-
'Agent hit step budget; partial result available. ' +
|
|
139
|
-
'Consider resuming with task_id or dispatching with larger budget.',
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return { status: 'success' }
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/** Extract the text after "## Output" in a delegation report, or undefined. */
|
|
147
|
-
function extractOutputSection(report: string): string | undefined {
|
|
148
|
-
const marker = '## Output'
|
|
149
|
-
const idx = report.indexOf(marker)
|
|
150
|
-
if (idx === -1) return undefined
|
|
151
|
-
const afterMarker = report.slice(idx + marker.length)
|
|
152
|
-
// Skip the newline after "## Output"
|
|
153
|
-
const content = afterMarker.replace(/^\n+/, '')
|
|
154
|
-
// Stop at the next section (## or **Error**)
|
|
155
|
-
const endIdx = content.search(/\n(?:##|\*\*Error\*\*|\[TIMEOUT)/)
|
|
156
|
-
return endIdx === -1 ? content.trim() : content.slice(0, endIdx).trim()
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// ─── Timeout Classification ───────────────────────────────────────────
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Classify a timeout based on available output and retry history.
|
|
163
|
-
*
|
|
164
|
-
* - timeout-empty: no report, no messages, not yet retried → retryable
|
|
165
|
-
* - timeout-with-partial: has report or messages → return partial
|
|
166
|
-
* - timeout-exhausted: already retried → escalate
|
|
167
|
-
*
|
|
168
|
-
* @param input Report availability, message presence, and retry count.
|
|
169
|
-
*/
|
|
170
|
-
export function classifyTimeout(input: TimeoutClassifyInput): DelegationResult {
|
|
171
|
-
const { report, hasMessages, retryCount } = input
|
|
172
|
-
const hasPartial =
|
|
173
|
-
(report !== undefined && report.trim() !== '' && !NO_OUTPUT_RE.test(report)) || hasMessages
|
|
174
|
-
|
|
175
|
-
// Already retried → exhausted, no more retries
|
|
176
|
-
if (retryCount >= 1) {
|
|
177
|
-
return {
|
|
178
|
-
status: 'timeout',
|
|
179
|
-
content: report ?? '',
|
|
180
|
-
retryCount,
|
|
181
|
-
subType: 'timeout-exhausted',
|
|
182
|
-
partialResult: hasPartial ? (report ?? '') : undefined,
|
|
183
|
-
recommendation:
|
|
184
|
-
'Agent timed out after retry. Options: ' +
|
|
185
|
-
'(a) try different agent, (b) simplify scope, (c) manual intervention.',
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Has partial output → return it
|
|
190
|
-
if (hasPartial) {
|
|
191
|
-
return {
|
|
192
|
-
status: 'timeout',
|
|
193
|
-
content: report ?? '',
|
|
194
|
-
retryCount,
|
|
195
|
-
subType: 'timeout-with-partial',
|
|
196
|
-
partialResult: report ?? '',
|
|
197
|
-
recommendation:
|
|
198
|
-
'Agent timed out but partial work exists. ' + 'Partial result is available above.',
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// No output at all → retryable
|
|
203
|
-
return {
|
|
204
|
-
status: 'timeout',
|
|
205
|
-
content: report ?? '',
|
|
206
|
-
retryCount,
|
|
207
|
-
subType: 'timeout-empty',
|
|
208
|
-
recommendation: 'Agent timed out with no output. Will retry once with rephrased prompt.',
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// ─── Result Helpers ───────────────────────────────────────────────────
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Whether a delegation result is retryable (empty + retryCount < 1,
|
|
216
|
-
* or timeout-empty + retryCount < 1).
|
|
217
|
-
*/
|
|
218
|
-
export function isRetryableResult(result: DelegationResult): boolean {
|
|
219
|
-
if (result.retryCount >= 1) return false
|
|
220
|
-
if (result.status === 'empty') return true
|
|
221
|
-
if (result.status === 'timeout' && result.subType === 'timeout-empty') return true
|
|
222
|
-
return false
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Format a DelegationResult into a human-readable string for the orchestrator.
|
|
227
|
-
* Success results are returned as-is (the raw content). Non-success results
|
|
228
|
-
* get a structured status message.
|
|
229
|
-
*/
|
|
230
|
-
export function formatDelegationResult(result: DelegationResult): string {
|
|
231
|
-
if (result.status === 'success') {
|
|
232
|
-
return result.content
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const parts: string[] = []
|
|
236
|
-
|
|
237
|
-
// Status header
|
|
238
|
-
switch (result.status) {
|
|
239
|
-
case 'empty': {
|
|
240
|
-
const modeLabel =
|
|
241
|
-
result.classification === 'empty-mode2'
|
|
242
|
-
? 'empty-mode2 (reasoning tokens present but no text output)'
|
|
243
|
-
: 'empty-mode1 (no tokens generated)'
|
|
244
|
-
parts.push(`[EMPTY RESULT — ${modeLabel}]`)
|
|
245
|
-
if (result.retryCount === 0) {
|
|
246
|
-
parts.push(
|
|
247
|
-
'The agent returned an empty response. ' +
|
|
248
|
-
'A retry with a rephrased prompt has been triggered automatically.',
|
|
249
|
-
)
|
|
250
|
-
} else {
|
|
251
|
-
parts.push(
|
|
252
|
-
'The agent returned an empty response even after retry. ' +
|
|
253
|
-
'Options: (a) try different agent, (b) simplify scope, (c) manual intervention.',
|
|
254
|
-
)
|
|
255
|
-
}
|
|
256
|
-
break
|
|
257
|
-
}
|
|
258
|
-
case 'budget-exhausted':
|
|
259
|
-
parts.push('[BUDGET EXHAUSTED]')
|
|
260
|
-
if (result.partialResult) {
|
|
261
|
-
parts.push('Partial result:')
|
|
262
|
-
parts.push(result.partialResult)
|
|
263
|
-
}
|
|
264
|
-
parts.push(result.recommendation ?? '')
|
|
265
|
-
break
|
|
266
|
-
case 'timeout': {
|
|
267
|
-
const subLabel =
|
|
268
|
-
result.subType === 'timeout-with-partial'
|
|
269
|
-
? 'with partial output'
|
|
270
|
-
: result.subType === 'timeout-exhausted'
|
|
271
|
-
? 'exhausted after retry'
|
|
272
|
-
: 'no output'
|
|
273
|
-
parts.push(`[TIMEOUT — ${subLabel}]`)
|
|
274
|
-
if (result.partialResult) {
|
|
275
|
-
parts.push('Partial result:')
|
|
276
|
-
parts.push(result.partialResult)
|
|
277
|
-
}
|
|
278
|
-
parts.push(result.recommendation ?? '')
|
|
279
|
-
break
|
|
280
|
-
}
|
|
281
|
-
case 'error':
|
|
282
|
-
parts.push('[ERROR]')
|
|
283
|
-
parts.push(result.content)
|
|
284
|
-
break
|
|
285
|
-
case 'startup_failed':
|
|
286
|
-
parts.push('[STARTUP FAILED]')
|
|
287
|
-
parts.push(result.content)
|
|
288
|
-
parts.push(
|
|
289
|
-
result.recommendation ??
|
|
290
|
-
'Retry once or inspect the child session before dispatching again.',
|
|
291
|
-
)
|
|
292
|
-
break
|
|
293
|
-
case 'bootstrap_unknown':
|
|
294
|
-
parts.push('[BOOTSTRAP UNKNOWN]')
|
|
295
|
-
parts.push(result.content)
|
|
296
|
-
parts.push(
|
|
297
|
-
result.recommendation ?? 'The host did not expose enough session state to verify startup.',
|
|
298
|
-
)
|
|
299
|
-
break
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Structured fields for non-success results
|
|
303
|
-
parts.push(`status: ${result.status}`)
|
|
304
|
-
parts.push(`retryCount: ${result.retryCount}`)
|
|
305
|
-
|
|
306
|
-
return parts.filter((p) => p !== '').join('\n')
|
|
307
|
-
}
|