pantheon-opencode 1.6.0-beta.9 → 1.6.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 (131) hide show
  1. package/AGENTS.global.md +118 -0
  2. package/AGENTS.md +18 -168
  3. package/CHANGELOG.md +126 -376
  4. package/README.md +83 -610
  5. package/README.pt-BR.md +120 -345
  6. package/bin/pantheon-init.mjs +366 -132
  7. package/commands/pantheon-deepwork.md +14 -3
  8. package/commands/pantheon-vision.md +61 -12
  9. package/package.json +19 -11
  10. package/plugin.json +1 -1
  11. package/pyproject.toml +6 -2
  12. package/scripts/_pantheon_paths.py +24 -0
  13. package/scripts/build-agents-md.mjs +368 -69
  14. package/scripts/changelog-merge.mjs +161 -0
  15. package/scripts/check-plugin-v2-coverage.mjs +11 -8
  16. package/scripts/docs-check-changelog.mjs +204 -0
  17. package/scripts/docs-link-check.mjs +314 -0
  18. package/scripts/docs-media.mjs +157 -0
  19. package/scripts/doctor.mjs +828 -40
  20. package/scripts/install/agents-md.mjs +2 -2
  21. package/scripts/install/backup.mjs +648 -0
  22. package/scripts/install/cli-ui.mjs +303 -72
  23. package/scripts/install/component-selection.mjs +61 -0
  24. package/scripts/install/config-migration.mjs +583 -27
  25. package/scripts/install/exit-codes.mjs +26 -0
  26. package/scripts/install/file-inventory.mjs +555 -0
  27. package/scripts/install/health-check.mjs +31 -25
  28. package/scripts/install/interactive.mjs +78 -383
  29. package/scripts/install/migrate.mjs +49 -25
  30. package/scripts/install/model-picker.mjs +218 -250
  31. package/scripts/install/opencode-version.mjs +83 -21
  32. package/scripts/install/opencode.mjs +1413 -154
  33. package/scripts/install/plan-artifact.mjs +517 -0
  34. package/scripts/install/plan.mjs +475 -0
  35. package/scripts/install/plugin.mjs +214 -27
  36. package/scripts/install/prompt-result.mjs +2 -0
  37. package/scripts/install/shared.mjs +256 -99
  38. package/scripts/install/state.mjs +63 -8
  39. package/scripts/install/strings.mjs +60 -4
  40. package/scripts/install/venv.mjs +90 -47
  41. package/scripts/install/verify.mjs +128 -0
  42. package/scripts/install/vision-prompt.mjs +173 -0
  43. package/scripts/install-mcp.mjs +2 -2
  44. package/scripts/manifest-inventory.mjs +49 -3
  45. package/scripts/mcp_persistence.py +1535 -1050
  46. package/scripts/memory_mcp.py +12 -843
  47. package/scripts/node-engine-policy.mjs +85 -0
  48. package/scripts/package-evidence.mjs +10 -2
  49. package/scripts/postinstall.mjs +26 -26
  50. package/scripts/probe-pantheon-cost.mjs +118 -19
  51. package/scripts/prune.mjs +9 -3
  52. package/scripts/reconcile.mjs +325 -0
  53. package/scripts/release-gates.mjs +682 -0
  54. package/scripts/restore.mjs +222 -0
  55. package/scripts/run-node-tests.mjs +24 -8
  56. package/scripts/sync-artifacts.mjs +19 -7
  57. package/scripts/sync-tui.mjs +5 -1
  58. package/scripts/test-opencode-v2-sandbox.sh +36 -123
  59. package/scripts/uninstall.mjs +369 -34
  60. package/scripts/update.mjs +164 -0
  61. package/scripts/validate-node-engine-policy.mjs +13 -0
  62. package/scripts/version-check.mjs +34 -1
  63. package/scripts/versioning.mjs +23 -3
  64. package/scripts/vision-status.mjs +682 -0
  65. package/skills-lock.json +8 -8
  66. package/src/agents/aphrodite.md +13 -10
  67. package/src/agents/apollo.md +4 -5
  68. package/src/agents/athena.md +74 -46
  69. package/src/agents/demeter.md +10 -7
  70. package/src/agents/gaia.md +0 -1
  71. package/src/agents/hephaestus.md +4 -3
  72. package/src/agents/hermes.md +10 -9
  73. package/src/agents/iris.md +6 -1
  74. package/src/agents/mnemosyne.md +10 -4
  75. package/src/agents/nyx.md +4 -4
  76. package/src/agents/prometheus.md +12 -11
  77. package/src/agents/talos.md +6 -0
  78. package/src/agents/zeus.md +84 -56
  79. package/src/instructions/agent-return-format.instructions.md +12 -41
  80. package/src/instructions/memory-protocol.instructions.md +5 -11
  81. package/src/instructions/test-economy.instructions.md +12 -0
  82. package/src/instructions/yagni.instructions.md +6 -15
  83. package/src/instructions/zeus-anti-stall.instructions.md +6 -6
  84. package/src/instructions/zeus-communication-rules.instructions.md +6 -6
  85. package/src/instructions/zeus-council-synthesis.instructions.md +11 -12
  86. package/src/instructions/zeus-memory-operations.instructions.md +13 -7
  87. package/src/instructions/zeus-timeout-retry.instructions.md +36 -10
  88. package/src/mcp/_pantheon_paths.py +24 -0
  89. package/src/mcp/mcp_codemap_module.py +86 -18
  90. package/src/mcp/mcp_persistence.py +1535 -1050
  91. package/src/mcp/memory_mcp.py +444 -94
  92. package/src/mcp/pantheon_vision.py +285 -41
  93. package/src/mcp/requirements-mcp.txt +5 -0
  94. package/src/pantheon/context-pruner.ts +541 -0
  95. package/src/pantheon/cost-command.ts +814 -60
  96. package/src/pantheon/goal-loop.ts +11 -8
  97. package/src/pantheon/memory-context.ts +1017 -0
  98. package/src/pantheon/model-agents.ts +19 -0
  99. package/src/pantheon/model-command.ts +218 -56
  100. package/src/pantheon/model-pricing.ts +536 -0
  101. package/src/pantheon/presets.mjs +2 -0
  102. package/src/pantheon/task-result-guard.ts +50 -14
  103. package/src/pantheon/v2-bounded-read.ts +640 -0
  104. package/src/pantheon/v2-delegation-enforce.ts +133 -6
  105. package/src/pantheon/v2-execute-after.ts +135 -24
  106. package/src/pantheon/v2-model-overrides.ts +275 -0
  107. package/src/pantheon/v2-tools.ts +89 -35
  108. package/src/pantheon/v2-unsupported.mjs +2 -3
  109. package/src/pantheon/v2-vision.ts +622 -0
  110. package/src/pantheon/vision-local.ts +531 -0
  111. package/src/pantheon/vision.ts +1160 -115
  112. package/src/plugin-v2.ts +654 -162
  113. package/src/plugin.ts +15 -11
  114. package/src/plugins/tui/dist/tui-v2.d.ts +1029 -2
  115. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  116. package/src/plugins/tui/dist/tui-v2.js +3742 -85
  117. package/src/plugins/tui/dist/tui.js +1 -1
  118. package/src/plugins/tui/package-lock.json +6 -6
  119. package/src/plugins/tui/package.json +5 -4
  120. package/src/plugins/tui/src/index-v2.tsx +4314 -50
  121. package/src/plugins/tui/tsconfig.typecheck.json +5 -0
  122. package/src/routing.yml +50 -5
  123. package/src/skills/agent-coordination/SKILL.md +7 -2
  124. package/src/skills/artifact-management/SKILL.md +5 -1
  125. package/src/skills/auto-continue/SKILL.md +14 -6
  126. package/src/skills/codemap/SKILL.md +1 -1
  127. package/src/skills/memory-bank/SKILL.md +21 -13
  128. package/src/skills/session-goal/SKILL.md +12 -22
  129. package/src/skills/spec-driven-development/SKILL.md +3 -1
  130. package/src/skills/worktrees/SKILL.md +30 -11
  131. package/scripts/probe-context-rehydrate.mjs +0 -263
@@ -1,8 +1,1035 @@
1
+ import { Accessor } from "solid-js";
2
+ import { Context, KeymapLayer, PanelInput } from "@opencode/plugin/tui/context";
1
3
  //#region src/index-v2.d.ts
2
- /** @jsxImportSource @opentui/solid */
4
+ /** Sidebar body shown while the host has not published a session yet. */
5
+ export declare const SIDEBAR_WAITING_LABEL = "Aguardando sessão…";
6
+ /** Marker before the preset label (fixed header, home status, prompt footer).
7
+ * `▸` U+25B8 is one cell; the previous bolt (U+26A1) carries
8
+ * Emoji_Presentation and is measured as two cells, which misaligned the line. */
9
+ export declare const PRESET_MARKER = "▸";
10
+ /** Git ahead / behind arrows (U+2191 / U+2193), one cell each — the glyphs the
11
+ * reference sidebars use for `↑ahead ↓behind`. */
12
+ export declare const GIT_ARROW_UP = "↑";
13
+ export declare const GIT_ARROW_DOWN = "↓";
14
+ /** One event name the host publishes on `data.on` — the OpenCode V2 union. */
15
+ export type SidebarDataEvent = Parameters<Context['data']['on']>[0];
16
+ /** V2 events that refresh the sidebar. V1 also listened to `session.updated`,
17
+ * but that name is absent from the OpenCode V2 event union (verified against
18
+ * `@opencode/client`'s `OpenCodeEvent`), so the valid events that carry the
19
+ * same state changes are used instead: `session.renamed` /
20
+ * `session.metadata.updated` / `session.moved` (the mutations `session.updated`
21
+ * used to stand for) and `session.idle` (a child finishing). `satisfies` keeps
22
+ * the literals while making a name outside the union a type error (surfaced by
23
+ * `tsc -p tsconfig.build.json`), and the sidebar test asserts the same names
24
+ * against the installed union at runtime. */
25
+ export declare const SIDEBAR_REFRESH_EVENTS: readonly ["session.created", "session.renamed", "session.metadata.updated", "session.moved", "session.idle", "session.status", "session.deleted"];
26
+ export type PresetInfo = {
27
+ name: string | null;
28
+ source: 'env' | 'file' | null;
29
+ };
30
+ /** One `overrides.agents[<agent>]` entry from active-preset.json. */
31
+ export type AgentModelOverride = {
32
+ model?: string;
33
+ variant?: string;
34
+ };
35
+ /** The override map the CLI wrote into active-preset.json. */
36
+ export type PresetOverrides = {
37
+ agents: Record<string, AgentModelOverride>;
38
+ };
39
+ /** A preset plus the explicit overrides stored next to it. */
40
+ export type ActivePresetDetail = {
41
+ info: PresetInfo;
42
+ overrides: PresetOverrides;
43
+ };
44
+ /** Keep only well-formed per-agent overrides: unknown keys are ignored and a
45
+ * non-string model/variant is dropped instead of leaking into the render. */
46
+ export declare function parsePresetOverrides(value: unknown): PresetOverrides;
47
+ /** Env leg of resolution: PANTHEON_MODEL_PRESET set and !== 'none' wins. */
48
+ export declare function presetFromEnv(env: Record<string, string | undefined>): PresetInfo;
49
+ /** Resolve the active preset plus its per-agent overrides: env > file > default.
50
+ * An env-selected preset has no file overrides by construction. */
51
+ export declare function resolveActivePresetForTui(env: Record<string, string | undefined>, cwd: string): Promise<ActivePresetDetail>;
52
+ /** `SessionInfo.id` is always a `ses…` handle. Guarded so a placeholder or a
53
+ * foreign id never reaches the status/navigate APIs. */
54
+ export declare function isValidSessionID(id: unknown): id is string;
55
+ /** Model reference shapes the host publishes: `ModelRef` objects, bare ids, or
56
+ * `provider/model` strings. Returns the id part, never throws. */
57
+ export declare function modelRefID(ref: unknown): string | null;
58
+ /** Short display id: the segment after the last `/` (`opencode-go/kimi-k3` →
59
+ * `kimi-k3`), truncated so a long id never wraps the sidebar. */
60
+ export declare function shortModelID(ref: unknown, max?: number): string | null;
61
+ /** `providerID` of a model reference, trimmed; null when absent/blank. Derived
62
+ * only from what the host already published — never a lookup table. */
63
+ export declare function providerIDFromRef(ref: unknown): string | null;
64
+ /** Provider for a bare-string model reference: match its id (or bare segment)
65
+ * in the host model list. Null when the list cannot answer. */
66
+ export declare function providerIDFromModels(models: unknown, ref: unknown): string | null;
67
+ /** Resolve `model.limit.context` for a model reference. Match order: the
68
+ * provider-qualified id, then the bare id (the host's `id`/`modelID` fields).
69
+ * Absent/ambiguous models degrade to null so the gauge is simply omitted. */
70
+ export declare function resolveContextLimit(models: readonly any[], ref: unknown): number | null;
71
+ /** Native token total: input + output + reasoning + cache read + cache write. */
72
+ export declare function messageTokensTotal(tokens: any): number;
73
+ export type ContextUsage = {
74
+ tokens: number;
75
+ percent: number;
76
+ limit: number;
77
+ };
78
+ /** The part of a transcript that still counts: everything before the revert
79
+ * boundary (when a revert is active), then after the last compaction. Both
80
+ * derived numbers that read "the last assistant with usage" — the context
81
+ * gauge and the cache hit rate — share this window, so a reverted-away or
82
+ * compacted-away message can never feed either one. Pure. */
83
+ export declare function transcriptWindow(messages: readonly any[], revertMessageID?: string | null): {
84
+ start: number;
85
+ end: number;
86
+ };
87
+ /** Context usage for a message list. Scope: the live window (see
88
+ * `transcriptWindow`). The last assistant message carrying `tokens` in that
89
+ * window wins. Null when there is no limit or no such message — the caller
90
+ * then omits the block. */
91
+ export declare function computeContextUsage(messages: readonly any[], contextLimit: number | null | undefined, revertMessageID?: string | null): ContextUsage | null;
92
+ /** Semantic tone for a context percentage, inclusive at the top of each band:
93
+ * info (blue) up to 25%, success (green) up to 50%, warning (yellow) up to
94
+ * 90%, error (red) above it. Four explicit stages, each backed by a feedback
95
+ * token, so the gauge follows the active theme. Pure. */
96
+ export declare function contextUsageTone(percent: number): ContextProgressTone;
97
+ /** The gauge's four stages, one per theme feedback token. */
98
+ export type ContextProgressTone = 'info' | 'success' | 'warning' | 'error';
99
+ /** Color for one gauge stage. Filled cells and the percent value both come from
100
+ * this one call, so the bar and its number can never disagree. `theme` is the
101
+ * host's resolved theme (loosely typed at runtime); a missing token falls back
102
+ * to the theme's base text instead of an unstyled cell. Pure. */
103
+ export declare function contextProgressColor(stage: ContextProgressTone, theme: any): any;
104
+ /** The muted extra line under the gauge: `cache 92% · 42.3 tok/s`. Either half
105
+ * may be missing (no cache read, no measurable turn); no data at all yields
106
+ * null so no empty line is rendered. The speed keeps the host's own one
107
+ * decimal and `tok/s` label. Pure. */
108
+ export declare function contextPerformanceLine(performance: ContextPerformance | null | undefined): string | null;
109
+ /** Cache hit rate of one message: `cache.read / (input + cache.read)` as a
110
+ * percentage. The denominator must be > 0, otherwise the ratio is meaningless
111
+ * (a message that only wrote to the cache has no input to hit). Null when the
112
+ * numbers are absent. Pure. */
113
+ export declare function cacheHitPercent(tokens: any): number | null;
114
+ /** The message the cache hit rate comes from: the last assistant of the live
115
+ * window (see `transcriptWindow`) that actually carries `tokens`. Later
116
+ * messages without usage — a streaming placeholder that the host publishes
117
+ * before any step completes, a step that reports no usage — are skipped
118
+ * instead of blanking a ratio the previous message already measured. Null
119
+ * when nothing in the window has usage. Pure. */
120
+ export declare function lastAssistantWithTokens(messages: readonly any[] | null | undefined, revertMessageID?: string | null): any | null;
121
+ /** Tokens per second of the current turn. Mirrors the host's
122
+ * `turnTokensPerSecond` (anomalyco/opencode v2.0.30,
123
+ * `packages/tui/src/routes/session/rows.ts`) so the sidebar and the native
124
+ * session footer can never disagree: the numerator is `output + reasoning`
125
+ * summed over every assistant step of the turn and the denominator is the
126
+ * summed active streaming time `max(0, time.streamed - time.created)`, so the
127
+ * division happens once, after aggregating — each step weighs by its own
128
+ * duration instead of each step voting equally. `completed` is never used; a
129
+ * turn with a step that has no `time.streamed` has no measurable speed. The
130
+ * turn starts after the last `user` message; with no user message only the
131
+ * last assistant step counts (degraded: there is no boundary to group by).
132
+ * Pure and fail-open. */
133
+ export declare function turnTokensPerSecond(messages: readonly any[] | null | undefined, position?: number | null): number | null;
134
+ /** Last-message telemetry the Context block renders in muted text. Both halves
135
+ * are optional; the block renders no line when neither is available. */
136
+ export type ContextPerformance = {
137
+ cacheHit: number | null;
138
+ tokensPerSecond: number | null;
139
+ };
140
+ /** Thousands-separated token total: `55320` → `55,320` (en-US, matching the
141
+ * native block this one replaces). Null for a missing/invalid value. Pure. */
142
+ export declare function formatTokenCount(tokens: number | null | undefined): string | null;
143
+ /** Context-window label: `1_000_000` → `1.0M`, `200_000` → `200K`,
144
+ * `128_000` → `128K`, `32_768` → `32K`. Sub-million limits truncate to whole K
145
+ * so the printed window never overstates the model's capacity. Pure. */
146
+ export declare function formatContextWindow(limit: number | null | undefined): string | null;
147
+ /** Cells in the Context gauge: always rendered in full, so the bar never
148
+ * changes width between refreshes. With the space, the percent and the
149
+ * `of <window>` tail (at most 9 columns) the line stays inside 34 columns. */
150
+ export declare const CONTEXT_BAR_CELLS = 12;
151
+ /** Filled cell (U+25B0) and empty cell (U+25B1), both single-width. */
152
+ export declare const CONTEXT_BAR_FILLED_CELL = "▰";
153
+ export declare const CONTEXT_BAR_EMPTY_CELL = "▱";
154
+ /** Filled cells for a percentage: rounded, clamped to `0..cells`, so 0% is an
155
+ * empty bar and anything at or above 100% is a full one. Pure. */
156
+ export declare function contextBarFilled(percent: number, cells?: number): number;
157
+ /** The gauge split into its toned half (filled cells) and its muted half (empty
158
+ * cells), so the caller colors each side. Null when the percentage is missing:
159
+ * the Context block then keeps its tokens + cost rows and renders no bar. Pure. */
160
+ export declare function contextBar(percent: number | null | undefined, cells?: number): {
161
+ filled: string;
162
+ empty: string;
163
+ } | null;
164
+ /** USD spent with two decimals (`$0.18`), the native block's format. Null for
165
+ * a missing/negative value. Pure. */
166
+ export declare function formatSpent(cost: number | null | undefined): string | null;
167
+ /** One rendered context row. `lead` and `tail` carry the gauge bar when the row
168
+ * has one (`lead` is toned with the value, `tail` is muted), so the 12 cells
169
+ * stay contiguous while the empty half still reads as background. */
170
+ export type ContextRow = {
171
+ lead: string | null;
172
+ value: string;
173
+ tail: string | null;
174
+ suffix: string | null;
175
+ tone: ContextProgressTone | null;
176
+ };
177
+ /** The `Context` block's data rows; null rows are not rendered. */
178
+ export type ContextBlockRows = {
179
+ tokens: ContextRow | null;
180
+ percent: ContextRow | null;
181
+ spent: ContextRow | null;
182
+ };
183
+ /** Rows for the `Context` block:
184
+ * `<tokens> tokens` / `▰▰▰▰▰▱▱▱▱▱▱▱ <percent>% of <window>` /
185
+ * `$<spent> spent`. The percentage row carries the only semantic tone, the
186
+ * gauge bar (12 cells) and is omitted entirely when the percentage is
187
+ * unavailable (never `undefined%`). A block with neither tokens nor cost
188
+ * yields null. Pure. */
189
+ export declare function contextBlockRows(usage: ContextUsage | null, cost: number | null | undefined): ContextBlockRows | null;
190
+ /** Models rendered in the Context block before the aggregate `… +N` line. */
191
+ export declare const MODEL_USAGE_VISIBLE_CEILING = 3;
192
+ /** Newest messages read per session — bounds the O(n) walk on long sessions. */
193
+ export declare const MODEL_USAGE_MESSAGE_LIMIT = 400;
194
+ /** Sessions read per family (root + delegations) for the aggregate. */
195
+ export declare const MODEL_USAGE_SESSION_LIMIT = 8;
196
+ /** Column widths for one model row (labels are muted, numbers right-aligned). */
197
+ export declare const MODEL_USAGE_MODEL_WIDTH = 12;
198
+ export declare const MODEL_USAGE_TOKEN_WIDTH = 6;
199
+ export declare const MODEL_USAGE_COST_WIDTH = 8;
200
+ /** Session events arrive in bursts; model rows are recomputed at most once
201
+ * per window (same cadence as the git-count revalidation). */
202
+ export declare const MODEL_USAGE_DEBOUNCE_MS = 400;
203
+ /** Real usage for one model, summed across the assistant messages that used it. */
204
+ export type ModelUsage = {
205
+ model: string;
206
+ tokens: number;
207
+ cost: number;
208
+ };
209
+ /** Totals per model from assistant messages: sums `cost` and `tokens`, drops
210
+ * models whose real cost is 0/absent, and orders by cost (then tokens, then
211
+ * name). `providerID` participates in the key so two providers exposing the
212
+ * same bare id are not merged. Pure. */
213
+ export declare function collectModelUsage(messages: readonly any[]): ModelUsage[];
214
+ /** Visible rows plus the aggregate of the models that did not fit. Pure. */
215
+ export type ModelUsageCeiling = {
216
+ visible: ModelUsage[];
217
+ hidden: number;
218
+ hiddenCost: number;
219
+ hiddenTokens: number;
220
+ };
221
+ /** Cap the model list at `maxVisible`; the rest is aggregated (still real
222
+ * totals) for the `… +N` line. Pure. */
223
+ export declare function ceilingModelUsage(rows: readonly ModelUsage[], maxVisible?: number): ModelUsageCeiling;
224
+ /** Compact tokens for a model row (`80,000` → `80K`); `0` stays explicit. Pure. */
225
+ export declare function formatUsageTokens(tokens: number | null | undefined): string;
226
+ /** Real per-model cost with adaptive precision: cents for `>= $0.01`, up to
227
+ * four decimals below that (a real `$0.0031` must not render as `$0.00`), and
228
+ * an explicit `< $0.0001` for the remainder. Pure. */
229
+ export declare function formatUsageCost(cost: number | null | undefined): string | null;
230
+ /** One formatted model row: truncated label + compact tokens + real cost. */
231
+ export type ModelUsageRow = {
232
+ model: string;
233
+ tokens: string;
234
+ cost: string;
235
+ };
236
+ /** Format the visible model rows for rendering. Labels are already short ids
237
+ * (12 chars); the second truncation only guards host drift. Pure. */
238
+ export declare function modelUsageRows(rows: readonly ModelUsage[]): ModelUsageRow[];
239
+ /** Exact single-line text of a model row, with numbers right-aligned. Pure. */
240
+ export declare function modelUsageRowText(row: ModelUsageRow): string;
241
+ /** Muted aggregate line for the models beyond the cap (`… +2 $0.03`). Null
242
+ * when every model fits. Pure. */
243
+ export declare function hiddenModelUsageText(hidden: number, hiddenCost: number): string | null;
244
+ /** Bucket for a session the host published without an agent id. */
245
+ export declare const UNKNOWN_AGENT = "?";
246
+ /** Agent key of a session or message: the trimmed id when it is a non-empty
247
+ * string, else the `?` bucket — never `undefined`. Pure. */
248
+ export declare function agentKey(value: unknown): string;
249
+ export type TodoStatus = 'in_progress' | 'pending' | 'completed' | 'cancelled';
250
+ /** One rendered todo row. `priority` is carried by the tool but not rendered:
251
+ * the reference block uses a single marker column. */
252
+ export type TodoItem = {
253
+ content: string;
254
+ status: TodoStatus;
255
+ };
256
+ /** Rows rendered before the `… +N` line. */
257
+ export declare const TODO_VISIBLE_CEILING = 6;
258
+ /** Content width before the ellipsis — the block has ~30-34 usable columns. */
259
+ export declare const TODO_TEXT_WIDTH = 28;
260
+ /** Narrow a loose `status` value to the tool's four states. */
261
+ export declare function isTodoStatus(value: unknown): value is TodoStatus;
262
+ /** Items from a `todowrite` `input` payload. A missing/malformed `input`,
263
+ * absent `todos`, an unknown `status` or an empty/missing `content` drops the
264
+ * entry instead of throwing; a list with nothing readable yields `[]`. Pure. */
265
+ export declare function parseTodoItems(input: unknown): TodoItem[];
266
+ /** Newest completed `todowrite` in a transcript. The tool replaces the list
267
+ * wholesale, so the last write wins; a write with `todos: []` returns null
268
+ * (the block disappears rather than showing the previous list) and a
269
+ * not-yet-completed write is ignored. Null when the transcript carries no
270
+ * such part, so the block never renders a guess. Pure. */
271
+ export declare function latestTodoItems(messages: readonly any[] | null | undefined): TodoItem[] | null;
272
+ /** Stable group order (in_progress → pending → completed → cancelled); within a
273
+ * group the transcript order is preserved. Pure. */
274
+ export declare function orderTodoItems(items: readonly TodoItem[]): TodoItem[];
275
+ /** Row color channel: `accent` for live work, `muted` for closed items, base
276
+ * for pending. Kept separate from the theme so it is testable. Pure. */
277
+ export type TodoTone = 'accent' | 'muted' | 'base';
278
+ /** Tone for one status — no rainbow, a single accent. Pure. */
279
+ export declare function todoTone(status: TodoStatus): TodoTone;
280
+ /** Exact rendered text of one row: `[•] <content truncated to 28>`. Pure. */
281
+ export declare function todoRowText(item: TodoItem): string;
282
+ /** Ordered rows capped for the sidebar, plus how many did not fit. Pure. */
283
+ export type TodoCeiling = {
284
+ visible: TodoItem[];
285
+ hidden: number;
286
+ };
287
+ /** Order then cap the list at `maxVisible`. Pure. */
288
+ export declare function ceilingTodoItems(items: readonly TodoItem[], maxVisible?: number): TodoCeiling;
289
+ /** Overflow line (`… +3`); null when every item fits. Pure. */
290
+ export declare function hiddenTodoText(hidden: number): string | null;
291
+ export type GitChangeCounts = {
292
+ added: number;
293
+ modified: number;
294
+ deleted: number;
295
+ };
296
+ /** Files per status from a `VcsFileStatus[]` payload. Unknown statuses and
297
+ * malformed entries are ignored. Pure. */
298
+ export declare function countGitChanges(files: readonly any[] | null | undefined): GitChangeCounts;
299
+ /** `+1 ±2 −3` for the file counts; each zero term is omitted, and an empty
300
+ * change set returns null so the row is not rendered at all. Pure. */
301
+ export declare function formatGitChanges(files: readonly any[] | null | undefined): string | null;
302
+ /** Wall-clock ceiling for one git call. A stuck git (index lock, network
303
+ * filesystem) is killed instead of holding the row forever. */
304
+ export declare const GIT_CLI_TIMEOUT_MS = 2000;
305
+ /** Session events arrive in bursts; a git probe is scheduled at most once per
306
+ * window instead of once per event. */
307
+ export declare const GIT_CLI_DEBOUNCE_MS = 1000;
308
+ /** Minimum spacing between two probe starts. Five seconds keeps a chatty event
309
+ * stream from spawning a git process per step while staying fresh enough to
310
+ * show a file appearing mid-turn. */
311
+ export declare const GIT_CLI_MIN_INTERVAL_MS = 5000;
312
+ /** Stdout ceiling for one git call. `status --porcelain=v1 -uall` lists every
313
+ * untracked file, so a large worktree easily passes the 1 MB `execFile`
314
+ * default — which would reject and silently hand the row back to the
315
+ * `vcs.status` fallback. 4 MB is far above a realistic porcelain listing. */
316
+ export declare const GIT_CLI_MAX_BUFFER: number;
317
+ /** One `execFile` call: `(file, args, options) → { stdout }`. Injectable so the
318
+ * parsing/gating logic is testable without spawning processes. */
319
+ export type GitExec = (file: string, args: readonly string[], options: {
320
+ cwd: string;
321
+ timeout: number;
322
+ windowsHide: boolean;
323
+ maxBuffer: number;
324
+ }) => Promise<{
325
+ stdout: string;
326
+ }>;
327
+ /** Default runner: the promisified `node:child_process.execFile`. A non-zero
328
+ * exit (no repository, no upstream) rejects and the caller decides. */
329
+ export declare const defaultGitExec: GitExec;
330
+ /** Files per status from `git status --porcelain=v1 -uall`, including the two
331
+ * columns the protocol cannot report. Each line starts with `XY` (index and
332
+ * worktree state); a rename prints `R old -> new`, and `??` / `!!` are
333
+ * untracked / ignored. Precedence per file: deleted > added > modified, so
334
+ * `AM` counts once as added and `AD` once as deleted. Renames, copies and
335
+ * unmerged entries count as modified. Pure. */
336
+ export type GitPorcelainCounts = {
337
+ added: number;
338
+ modified: number;
339
+ deleted: number;
340
+ untracked: number;
341
+ };
342
+ /** Parse porcelain v1 output into file counts. Empty/malformed output yields
343
+ * zero counts (a clean tree), never a throw. Pure. */
344
+ export declare function parseGitStatusPorcelain(output: string | null | undefined): GitPorcelainCounts;
345
+ /** `git rev-list --count --left-right @{upstream}...HEAD` prints two numbers:
346
+ * commits only on the upstream (behind) then commits only on HEAD (ahead).
347
+ * Null when the output is not that pair — e.g. the command failed because the
348
+ * branch has no upstream, in which case the arrows are simply omitted. Pure. */
349
+ export declare function parseGitAheadBehind(output: string | null | undefined): {
350
+ ahead: number;
351
+ behind: number;
352
+ } | null;
353
+ /** One git observation: file counts plus the upstream distance (either arrow
354
+ * may be unknown when the branch has no upstream). */
355
+ export type GitCliSnapshot = {
356
+ changes: GitPorcelainCounts;
357
+ ahead: number | null;
358
+ behind: number | null;
359
+ };
360
+ /** One probe: `git status --porcelain=v1 -uall` for the counts, then
361
+ * `git rev-list --count --left-right @{upstream}...HEAD` for the arrows (a
362
+ * failure there only drops the arrows). A status failure rejects — the caller
363
+ * then falls back to `client.vcs.status`. */
364
+ export declare function readGitSnapshot(directory: string, exec?: GitExec): Promise<GitCliSnapshot>;
365
+ /** Rendered git row: `+1 ±2 −1 ?2 ↑3 ↓1`, zero terms omitted. Null when the
366
+ * tree is clean and in sync, so the block keeps only its branch line. Pure. */
367
+ export declare function formatGitSnapshot(snapshot: GitCliSnapshot | null | undefined): string | null;
368
+ /** Whether a new probe may start. An in-flight probe always wins (no queue), and
369
+ * the previous start must be older than the cooldown. Pure. */
370
+ export declare function gitProbeAllowed(state: {
371
+ now: number;
372
+ lastRunAt: number | null;
373
+ inFlight: boolean;
374
+ }, cooldownMs?: number): boolean;
375
+ /** Spend window labels, in render order. */
376
+ export declare const SPEND_TODAY_LABEL = "hoje";
377
+ export declare const SPEND_30D_LABEL = "30d";
378
+ /** Separator between the two windows on the Context footer line. */
379
+ export declare const SPEND_LINE_SEPARATOR = " · ";
380
+ /** `30d` window: 30 × 24 h, measured back from "now". */
381
+ export declare const SPEND_30D_MS: number;
382
+ /** Probe window: one hour, narrow enough that a unit mix-up cannot line up. */
383
+ export declare const SPEND_PROBE_WINDOW_MS: number;
384
+ /** The echoed `range` may be rounded server-side; 120 s absorbs that. */
385
+ export declare const SPEND_PROBE_TOLERANCE_MS = 120000;
386
+ /** Session events arrive in bursts — same 400 ms window as the other blocks. */
387
+ export declare const SPEND_REFRESH_DEBOUNCE_MS = 400;
388
+ /** Spend per window in USD. Either side may be unknown (kept `null`). */
389
+ export type SpendTotals = {
390
+ today: number | null;
391
+ thirtyDays: number | null;
392
+ };
393
+ /** `from`/`to` unit accepted by the route. `SessionStatsInput` declares both as
394
+ * bare `number` and does not say which unit, so it is measured once per
395
+ * process (`ms` unless the server echoes seconds) instead of guessed. */
396
+ type SpendUnit = 'ms' | 's' | 'unavailable';
397
+ /** Test-only: forget the process-wide unit resolution. Never called at runtime. */
398
+ export declare function resetSpendUnit(): void;
399
+ /** Resolved unit (`ms` / `s` / `unavailable`) or null while still unknown. */
400
+ export declare function resolvedSpendUnit(): SpendUnit | null;
401
+ /** Local midnight for `now`: `new Date()` with the clock fields zeroed in the
402
+ * current timezone (DST-safe, unlike subtracting hours). Pure. */
403
+ export declare function startOfLocalDay(now: number): number;
404
+ /** The two windows the block shows: `hoje` (local midnight → now) and `30d`
405
+ * (now − 30 days → now). Pure. */
406
+ export declare function spendWindows(now: number): {
407
+ today: {
408
+ from: number;
409
+ to: number;
410
+ };
411
+ thirtyDays: {
412
+ from: number;
413
+ to: number;
414
+ };
415
+ };
416
+ /** USD with two decimals (`$0.42`), four for a positive sub-cent amount
417
+ * (`$0.0031`), and `<$0.0001` when even four decimals would read `$0.0000`.
418
+ * `0` prints `$0.00`. Null for a missing/negative/non-finite value. Pure. */
419
+ export declare function formatSpendUSD(cost: number | null | undefined): string | null;
420
+ /** `cost` off a `SessionStatsInfo` (`MoneyUSD` = number) or null when the
421
+ * payload is malformed/negative, so a bad value never reaches a row. Pure. */
422
+ export declare function statsCost(result: unknown): number | null;
423
+ /** True when the server echoed the window we sent, within 120 s. `scale` is how
424
+ * many milliseconds one unit of the sent window is worth (`1` for `ms`, `1000`
425
+ * for `s`). The echo is accepted either as the same numbers we sent (the route
426
+ * keeps the caller's unit) or converted to millisecond epoch (`DateTime.Utc`),
427
+ * so the probe pins the unit without assuming which of the two it gets. Pure. */
428
+ export declare function statsRangeMatches(range: unknown, sent: {
429
+ from: number;
430
+ to: number;
431
+ }, scale: number): boolean;
432
+ /** The `Context` block's last line: both spend windows on one muted row
433
+ * (`hoje $0.42 · 30d $9.80`). A window without a usable amount is omitted, and
434
+ * no usable window at all yields null so the line (and not the block) is
435
+ * dropped. Pure. */
436
+ export declare function contextSpendLine(totals: SpendTotals | null): string | null;
437
+ /** Terminal cells `value` occupies — the unit every column in this plugin is
438
+ * measured in. Mirrors the host (that is how `@opentui/core` sizes a text
439
+ * run): emoji count as two cells, East Asian Wide/Fullwidth as two, East
440
+ * Asian Ambiguous as one, combining marks and variation selectors as none.
441
+ * Pure. */
442
+ export declare function cellWidth(value: string): number;
443
+ /** Clamp a free-form label to `max` terminal cells without wrapping. The width
444
+ * is measured in display cells, never in UTF-16 code units: a CJK or emoji
445
+ * label used to overflow the column it was cut for (`計画の移行` is 5 code
446
+ * units but 10 cells, `🚀` is 2 units and 2 cells). Pure. */
447
+ export declare function truncateLabel(value: string, max?: number): string;
448
+ /** Right-pad `value` with spaces to exactly `cells` display columns (a wider
449
+ * value is truncated first). `padEnd` counts code units, so it under-pads a
450
+ * CJK/emoji cell and the next column drifts. Pure. */
451
+ export declare function padCell(value: string, cells: number): string;
452
+ /** Columns the fixed header may use before it would wrap the sidebar. */
453
+ export declare const HEADER_MAX_WIDTH = 34;
454
+ /** Preset row of the fixed header: `▸ <preset> · <provider>`. The provider is
455
+ * cut first when the row overflows, so the preset name is never the casualty;
456
+ * a missing provider leaves the preset alone (no `unknown` placeholder). */
457
+ export declare function presetHeaderLine(presetName: string, providerID: string | null): string;
458
+ export type DispatchKind = 'coun' | 'plan' | 'revw' | 'hot' | 'disc' | 'oth';
459
+ export type DispatchKindOrigin = 'prefix' | 'agent' | 'unavailable';
460
+ /** One classification plus the evidence that produced it. */
461
+ export type DispatchKindLabel = {
462
+ kind: DispatchKind | null;
463
+ origin: DispatchKindOrigin;
464
+ };
465
+ /** Kind declared by a leading `[prefix]` on the description: case-insensitive
466
+ * and tolerant of spaces inside the brackets. Null when none is declared. */
467
+ export declare function dispatchKindFromPrefix(description: unknown): DispatchKind | null;
468
+ /** Kind implied by the child's agent, null for an agent that implies none. */
469
+ export declare function dispatchKindFromAgent(agent: unknown): DispatchKind | null;
470
+ /** Classify one dispatch. The description prefix always wins over the agent;
471
+ * otherwise the agent decides, and anything else is `oth` (a real dispatch we
472
+ * simply cannot name). A missing call is the only `unavailable` outcome. Pure. */
473
+ export declare function classifyDispatchKind(call: {
474
+ description?: unknown;
475
+ agent?: unknown;
476
+ } | null | undefined): DispatchKindLabel;
477
+ /** A `subagent` tool call the parent made, as its own transcript records it. */
478
+ export type SubagentCall = {
479
+ /** Child session id the call created — the correlation key. */
480
+ sessionID: string;
481
+ agent: string;
482
+ description: string;
483
+ background: boolean;
484
+ };
485
+ /** Correlate the parent transcript's `subagent` calls with the children they
486
+ * spawned: child session id → `{ agent, description, background }`. One pass
487
+ * over the list the sidebar already holds — no request, no `message.sync` on
488
+ * the child. `streaming`/`pending` states carry their input as *partial JSON
489
+ * text*, so they are skipped rather than parsed. Fail-open: a malformed part
490
+ * contributes nothing. Pure. */
491
+ export declare function collectSubagentCalls(messages: readonly any[] | null | undefined): Map<string, SubagentCall>;
492
+ export type DelegationState = 'running' | 'completed' | 'failed' | 'interrupted';
493
+ export type DelegationTone = 'warning' | 'error' | 'success';
494
+ /** Grace window for a child that has not started yet. V2's `session.status()`
495
+ * returns `idle` both for "created but not started" and for "finished", so an
496
+ * idle/unknown/absent child whose own last activity (`time.updated`, falling
497
+ * back to `time.created`) is this recent still reads as running — otherwise a
498
+ * just-spawned child renders a premature ✓. Trade-off (V1 parity: it had the
499
+ * same window for its absent statuses): a child that finished within the window
500
+ * and reports no `outcome` reads as running until the window closes, at which
501
+ * point it turns terminal and its completion toast fires. A child that reports
502
+ * a terminal `outcome` is never held back by the window. */
503
+ export declare const DELEGATION_CHILD_STATUS_GRACE_MS: number;
504
+ /** One delegated child job as the sidebar renders it. */
505
+ export type DelegationView = {
506
+ /** Child session id — also the click-through target. */
507
+ id: string;
508
+ /** Alias shown on the row: the child title, else agent, else short id. */
509
+ label: string;
510
+ state: DelegationState;
511
+ /** Epoch ms of the child's `time.created`. */
512
+ startedAt: number | null;
513
+ /** Epoch ms of the child's `time.updated`. */
514
+ updatedAt: number | null;
515
+ /** Child agent id, when the host published one. */
516
+ agent: string | null;
517
+ /** Resolved child model, shortened to its bare id. */
518
+ model: string | null;
519
+ /** Real `SessionInfo.cost` for the child, null when the host published none. */
520
+ cost: number | null;
521
+ /** Why the child exists — see `classifyDispatchKind`. Null when no `subagent`
522
+ * call in the parent transcript could be correlated with this child. */
523
+ kind: DispatchKind | null;
524
+ /** Which evidence produced `kind`. */
525
+ kindOrigin: DispatchKindOrigin;
526
+ /** The parent asked for this child to run in the background. */
527
+ background: boolean;
528
+ };
529
+ /** Map the host's live session status to a display state. V2 exposes only
530
+ * `"idle" | "running"` through the TUI context (the client union adds `retry`
531
+ * and `busy`); `error`/`failed` are handled defensively for host drift.
532
+ * `idle`, `retry` and unknown/absent statuses are terminal only once the
533
+ * child's own activity is older than the grace window — within it the child
534
+ * reads as running (see `DELEGATION_CHILD_STATUS_GRACE_MS`). An interruption is
535
+ * not part of this union: it arrives as a terminal `outcome`. Pure. */
536
+ export declare function delegationStateFromStatus(status: string | undefined, time?: {
537
+ created?: number;
538
+ updated?: number;
539
+ }, now?: number, graceMs?: number): DelegationState;
540
+ /** Map a V2 child `outcome` to a display state. `interrupted` (user abort,
541
+ * shutdown, superseded, inactivity) is distinct from both success and failure,
542
+ * so an aborted child never renders the ✓ of a completed one. Returns null for
543
+ * an absent/unrecognised outcome so the live status decides. Pure. */
544
+ export declare function delegationStateFromOutcome(outcome: unknown): DelegationState | null;
545
+ /** Build a delegation row from a child session + its live status, plus the
546
+ * `subagent` call that spawned it (when the parent transcript had one). A
547
+ * terminal `outcome` wins when present (the only V2 primitive that surfaces a
548
+ * delegation failure/interruption once the status is back to idle); otherwise
549
+ * the live status decides, with the absent/idle grace window applied. The
550
+ * `call` only ever *adds* the purpose and the background flag — an absent one
551
+ * leaves the row fully renderable. Pure. */
552
+ export declare function toDelegationView(child: any, status: string | undefined, now?: number, call?: SubagentCall | null): DelegationView;
553
+ /** Spinner glyph for a frame counter (incremented every ~80ms while any job is
554
+ * running). Pure. */
555
+ export declare function spinnerFrame(frame: number): string;
556
+ /** Token totals published on `SessionInfo.tokens`, one entry per counter. */
557
+ export type DispatchTokens = {
558
+ input: number | null;
559
+ output: number | null;
560
+ reasoning: number | null;
561
+ cacheRead: number | null;
562
+ cacheWrite: number | null;
563
+ };
564
+ /** One child of the dispatch tree: the delegation row plus the fields only the
565
+ * panel's detail view needs (`SessionInfo.title`/`parentID`/`tokens` and the
566
+ * spawning call's description). */
567
+ export type DispatchEntry = {
568
+ view: DelegationView;
569
+ title: string | null;
570
+ description: string | null;
571
+ parentID: string | null;
572
+ tokens: DispatchTokens | null;
573
+ };
574
+ /** Optional inputs of `collectDispatch`: a fixed clock (tests/render ticks) and
575
+ * an already-computed `agent` map, so a caller that walked the parent
576
+ * transcript anyway never pays for a second walk. */
577
+ export type CollectDispatchOptions = {
578
+ now?: number;
579
+ calls?: Map<string, SubagentCall>;
580
+ };
581
+ /** Token counters of a child, null when the host published none of them. Pure. */
582
+ export declare function dispatchTokens(tokens: unknown): DispatchTokens | null;
583
+ /** One child `SessionInfo` + its live status → `DispatchEntry`. The call only
584
+ * ever adds the kind and the description; an absent one leaves the entry fully
585
+ * renderable. Pure. */
586
+ export declare function toDispatchEntry(child: any, status: string | undefined, now?: number, call?: SubagentCall | null): DispatchEntry;
587
+ /** The delegation tree of `sessionID` — every child `session.family` returns,
588
+ * root excluded, each enriched from `session.get`/`session.status` and the
589
+ * parent's `subagent` calls. Empty when the family API is unavailable or the
590
+ * session id is not a real handle (never falls back to the root). Ordered by
591
+ * the shared `compareDelegations`, so callers render the same list in the same
592
+ * order. A family that repeats an id yields one row per child: the id is
593
+ * deduplicated before the walk, so a duplicate can never double a row or its
594
+ * cost. */
595
+ export declare function collectDispatch(context: any, sessionID: string | undefined, options?: CollectDispatchOptions): DispatchEntry[];
596
+ /** Sidebar blocks in render order. Spacing is derived from this list instead of
597
+ * from the view, so a hidden block can never leave an empty gap behind. */
598
+ export type SidebarBlockKey = 'context' | 'git' | 'todo' | 'dispatch';
599
+ /** One rendered block: its key, and whether a blank line precedes it. */
600
+ export type SidebarBlock = {
601
+ key: SidebarBlockKey;
602
+ spacer: boolean;
603
+ };
604
+ /** Header glyph per block — one codepoint each, rendered muted before the bold
605
+ * label. The fixed header (version/preset/session) takes none.
606
+ * Measured as one terminal cell by the host (`@opentui/core` counts
607
+ * `emoji-regex` matches as two): ▤ U+25A4 (EAW=A), ◆ U+25C6 (A), ▾ U+25BE (N),
608
+ * ◈ U+25C8 (A). `☑` U+2611 was rejected for the Todo header because it matches
609
+ * `emoji-regex` and would occupy two cells; `⌁` U+2301 (the old Dispatch glyph)
610
+ * was replaced by the host's own Notice glyph. */
611
+ export declare const BLOCK_ICONS: Record<SidebarBlockKey, string>;
612
+ /** Tag every block that has content with its spacer: never before the first
613
+ * (the view puts a single blank line after the fixed header instead), one
614
+ * blank line before every later block. A repeated key collapses instead of
615
+ * stacking spacers, so an absent optional block can never leave a double gap.
616
+ * Pure. */
617
+ export declare function withBlockSpacers(keys: readonly SidebarBlockKey[]): SidebarBlock[];
618
+ /** Live children rendered one row each; the rest collapse into `… +N rodando`. */
619
+ export declare const DISPATCH_RUNNING_CEILING = 3;
620
+ /** Agent rollup rows rendered before the `… +K $<soma>` line. */
621
+ export declare const DISPATCH_AGENT_CEILING = 3;
622
+ /** Hard cap on the block's rendered rows, header included. The sidebar is
623
+ * short; live work is served first, then the finished rollup. */
624
+ export declare const DISPATCH_MAX_LINES = 8;
625
+ /** Marker of the aggregated "finished" section. */
626
+ export declare const DISPATCH_DONE_MARKER = "✓";
627
+ /** Column width of the agent (or of its title/id fallback). */
628
+ export declare const DISPATCH_AGENT_WIDTH = 12;
629
+ /** Narrowest agent column a row may fall back to before the cost is kept whole
630
+ * and the label truncates further. */
631
+ export declare const DISPATCH_MIN_AGENT_WIDTH = 8;
632
+ /** Column width of the short model id — the model is dropped before the agent
633
+ * or the cost so a row always fits. */
634
+ export declare const DISPATCH_MODEL_WIDTH = 7;
635
+ /** Column width of the per-dispatch cost (`$0.04`; a sub-cent cost widens it). */
636
+ export declare const DISPATCH_COST_WIDTH = 5;
637
+ /** Column width of the duration (`12.7s` / `1m04s` / `820ms`). */
638
+ export declare const DISPATCH_DURATION_WIDTH = 5;
639
+ /** Column width of the `×<count>` cell of an agent rollup row. */
640
+ export declare const DISPATCH_COUNT_WIDTH = 3;
641
+ /** Column width of an agent rollup cost (`$0.0051` still fits). */
642
+ export declare const DISPATCH_GROUP_COST_WIDTH = 7;
643
+ /** Hard column budget for one row — a Dispatch line never wraps:
644
+ * marker(2) + agent(12) + model(7) + cost(5) + duration(5) + 3 spaces = 34.
645
+ * The kind suffix (`·disc`, `·disc~`) is wider evidence than the model, so a
646
+ * classified row spends the model's columns first: marker(2) + agent(≤12) +
647
+ * suffix(≤6) + cost(5) + duration(5) + 2 spaces ≤ 32, still inside 34. */
648
+ export declare const DISPATCH_MAX_WIDTH = 34;
649
+ /** Kind suffix glued to a row's label: `·disc`, `·disc~` for a background run,
650
+ * and empty when the child could not be classified (the row then reads exactly
651
+ * as before). Pure. */
652
+ export declare function dispatchKindSuffix(kind: DispatchKind | null | undefined, background?: boolean): string;
653
+ /** Header summary: `2 rodando · $3.49`. The live count is omitted when nothing
654
+ * runs, and the total spend is always printed (the header only renders while
655
+ * the tree has children, so `$0.00` is a real answer). Pure. */
656
+ export declare function dispatchHeaderSummary(running: number | null | undefined, cost: number | null | undefined): string | null;
657
+ /** Compact duration without an internal space: `820` → `820ms`, `12_400` →
658
+ * `12.4s`, `64_000` → `1m04s`, `3_780_000` → `1h03m`, `172_800_000` → `2d`.
659
+ * An absent or negative value renders an em dash, never `NaN`s. Pure. */
660
+ export declare function formatDispatchDuration(ms: number | null | undefined): string;
661
+ /** Elapsed label for one row: a live child measures `now - created`, a finished
662
+ * one freezes at `updated - created` (em dash when a timestamp is missing).
663
+ * Pure. */
664
+ export declare function dispatchElapsed(view: DelegationView, now?: number): string;
665
+ /** Name column: the agent when the host published one, else the child title,
666
+ * else the short id — never `undefined`. Truncated to the column width. Pure. */
667
+ export declare function dispatchAgentText(view: Pick<DelegationView, 'agent' | 'label' | 'id'>, max?: number): string;
668
+ /** Model column, empty when the host published none. Pure. */
669
+ export declare function dispatchModelText(view: Pick<DelegationView, 'model'>): string;
670
+ /** Cost column: the child's real `SessionInfo.cost` with two decimals (up to
671
+ * four below a cent, so `$0.0031` never collapses to `$0.00`), `$0.00` for a
672
+ * zero cost, and an em dash when the host published no numeric cost. Pure. */
673
+ export declare function formatDispatchCost(cost: number | null | undefined): string;
674
+ /** Total spend of every child (live + finished), `0` when none published a
675
+ * numeric cost. Pure. */
676
+ export declare function dispatchTotalCost(views: readonly DelegationView[]): number;
677
+ /** One live child: `⠸ <agent 12>·<kind> <custo> <duração>`, with the model as a
678
+ * fourth column only when the row still fits and the child is unclassified —
679
+ * the kind is the stronger evidence at this width, so it takes the model's
680
+ * columns. The kind rides glued to the label (never a column of its own) and
681
+ * disappears with the label's truncation; then the agent column shrinks (never
682
+ * below `DISPATCH_MIN_AGENT_WIDTH`); the cost is always present — `$0.00` for a
683
+ * zero cost, an em dash for a missing one. Pure. */
684
+ export declare function runningChildRowText(view: DelegationView, now?: number, frame?: number, max?: number): string;
685
+ /** Sessions and spend attributed to one agent in the finished section. `kind`
686
+ * is only set when every finished session of the group agrees on it — a mixed
687
+ * group carries no single purpose, so the row omits it rather than picking one.
688
+ * `background` follows the same rule (all of them background). */
689
+ export type ChildAgentUsage = {
690
+ agent: string;
691
+ count: number;
692
+ cost: number;
693
+ kind: DispatchKind | null;
694
+ background: boolean;
695
+ };
696
+ /** Rollup of the finished children by agent: `×count` sessions and the summed
697
+ * `SessionInfo.cost`. Failed and interrupted children are included (they are
698
+ * finished); running ones are not. The group's kind survives only when the
699
+ * whole group agrees, so an aggregate row never claims a purpose it cannot
700
+ * prove. Ordered by cost, then count, then name. Pure. */
701
+ export declare function collectChildAgentUsage(views: readonly DelegationView[]): ChildAgentUsage[];
702
+ /** One agent rollup row: `<agent 12> ×<count 3>·<kind> <custo 7>`. The kind is
703
+ * glued to the count (the row's only label) and omitted for a mixed group; the
704
+ * agent column shrinks (never below the minimum) before the cost, which is
705
+ * what the row is for. Pure. */
706
+ export declare function childAgentRowText(row: ChildAgentUsage, max?: number): string;
707
+ /** The `… +K $<soma>` line for agents beyond the rollup cap. Null when every
708
+ * agent fits. Pure. */
709
+ export declare function hiddenChildAgentsText(hidden: number, hiddenCost: number): string | null;
710
+ /** Summary of the finished section: `✓ 70 · $3.40 · 9 agentes`. `· $<soma>` is
711
+ * omitted when nothing was spent and `· 1 agente` when a single agent owns
712
+ * every finished child; `✓ <total>` always prints. Null when nothing finished.
713
+ * Pure. */
714
+ export declare function completedSummaryText(completed: number | null | undefined, cost: number | null | undefined, agents: number | null | undefined): string | null;
715
+ /** The `· <F> falhas` suffix of the finished summary, null when nothing failed.
716
+ * Pure. */
717
+ export declare function failedSuffixText(failures: number | null | undefined): string | null;
718
+ /** One rendered live row: its text plus the session it navigates to. */
719
+ export type DispatchRunningLine = {
720
+ id: string;
721
+ text: string;
722
+ };
723
+ /** Everything the `Dispatch` block renders, already joined and capped. */
724
+ export type DispatchBlockView = {
725
+ runningCount: number;
726
+ completedCount: number;
727
+ agentCount: number;
728
+ failures: number;
729
+ totalCost: number;
730
+ running: DispatchRunningLine[];
731
+ runningHidden: number;
732
+ summary: string | null;
733
+ agents: ChildAgentUsage[];
734
+ agentsHidden: number;
735
+ agentsHiddenCost: number;
736
+ };
737
+ /** Build the whole block from the child set. Null when there is no child, so
738
+ * the block (and its spacer) never renders empty. Live work is capped at
739
+ * `DISPATCH_RUNNING_CEILING` and the finished rollup at
740
+ * `DISPATCH_AGENT_CEILING`, with the rollup giving up rows first to keep the
741
+ * block inside `DISPATCH_MAX_LINES`. Pure. */
742
+ export declare function buildDispatchBlock(views: readonly DelegationView[], now?: number, frame?: number, max?: number): DispatchBlockView | null;
743
+ /** Panel content name, registered by the `session.panel` claim and passed to
744
+ * `ui.panel.open`. */
745
+ export declare const DISPATCH_PANEL_NAME = "pantheon.dispatch";
746
+ /** Toast shown when `ui.panel.open` refuses (no session route is active). The
747
+ * panel only exists inside a session, so there is no alternative route. */
748
+ export declare const DISPATCH_PANEL_TOAST = "Abra uma sessão para ver o Dispatch";
749
+ /** Panel title marker — the same glyph the sidebar block header uses. */
750
+ export declare const DISPATCH_PANEL_HEADER_MARKER = "◈";
751
+ /** Selected-row gutter marker (`▸`, one cell). */
752
+ export declare const DISPATCH_PANEL_SELECTION_MARKER = "▸";
753
+ /** Cells the selection gutter occupies before a row's own text. */
754
+ export declare const DISPATCH_PANEL_SELECTION_GUTTER = 2;
755
+ /** Column of the horizontal rule under the header. */
756
+ export declare const DISPATCH_PANEL_RULE_CHAR = "─";
757
+ /** Em dash for any datum the host did not publish. */
758
+ export declare const DISPATCH_PANEL_DASH = "—";
759
+ /** Body of an empty panel (the claim still renders, the list is just empty). */
760
+ export declare const DISPATCH_PANEL_EMPTY_TEXT = "Nenhuma sessão delegada";
761
+ /** Width at or above which the list and the detail sit side by side. */
762
+ export declare const DISPATCH_PANEL_WIDE_MIN_WIDTH = 72;
763
+ /** Rows the viewport holds; pageup/pagedown move by exactly this many rows. */
764
+ export declare const DISPATCH_PANEL_PAGE_SIZE = 10;
765
+ /** Panel row columns: marker(2) + agent(12) + kind(4) + cost(≥7) + duration(8).
766
+ * The cost column is at least this wide; a sub-cent cost widens it per row. */
767
+ export declare const DISPATCH_PANEL_AGENT_WIDTH = 12;
768
+ export declare const DISPATCH_PANEL_MIN_AGENT_WIDTH = 6;
769
+ export declare const DISPATCH_PANEL_KIND_WIDTH = 4;
770
+ export declare const DISPATCH_PANEL_COST_WIDTH = 7;
771
+ export declare const DISPATCH_PANEL_DURATION_WIDTH = 8;
772
+ /** Title column budget (`◈ Dispatch — <sessão>`). */
773
+ export declare const DISPATCH_PANEL_TITLE_WIDTH = 44;
774
+ /** Badge appended to the title while the host presents the panel full screen. */
775
+ export declare const DISPATCH_PANEL_FULLSCREEN_BADGE = "[fullscreen]";
776
+ /** Human labels of a kind's evidence, as the detail line prints them. */
777
+ export declare const DISPATCH_KIND_ORIGIN_LABELS: Readonly<Record<DispatchKindOrigin, string>>;
778
+ /** Entries in row order: live work first, then most recent activity — the same
779
+ * comparator the sidebar block uses. Pure. */
780
+ export declare function orderDispatchEntries(entries: readonly DispatchEntry[]): DispatchEntry[];
781
+ /** `◈ Dispatch — <sessão>`, with the session title truncated (never wrapped),
782
+ * plus the `[fullscreen]` badge while the host presents the panel full screen.
783
+ * An absent title leaves the marker and the name alone. Pure. */
784
+ export declare function dispatchPanelTitle(sessionTitle: string | null | undefined, max?: number, presentation?: string): string;
785
+ /** Header counters: `2 rodando · 70 concluídos · 1 falha · $3.59`. A zero
786
+ * counter is omitted (never `0 rodando`); the total spend is printed whenever
787
+ * the tree has a child, because `$0.00` is then a real answer. Null for an
788
+ * empty tree, so the header renders no counter line at all. Pure. */
789
+ export declare function dispatchPanelHeader(entries: readonly DispatchEntry[] | null | undefined): string | null;
790
+ /** Horizontal rule under the header, clamped to the panel's own width. Pure. */
791
+ export declare function dispatchPanelRule(width: number, max?: number): string;
792
+ /** Row marker: animated spinner while running, `✓` done, `✗` failed, `○`
793
+ * cancelled/interrupted, `?` for a state the host never publishes. Every glyph
794
+ * is one cell wide and `?` is the only fallback, so an unknown state is visible
795
+ * instead of silently rendering as success. Pure. */
796
+ export declare function dispatchPanelMarker(state: DelegationState | string, frame?: number): string;
797
+ /** One padded, truncated cell: an absent/blank value becomes the em dash, and
798
+ * the value is cut to the cell's own width (never to the line's length, so one
799
+ * long cell cannot squeeze its neighbours out of alignment). Pure. */
800
+ export declare function dispatchPanelCell(value: unknown, width: number): string;
801
+ /** One list row: `⠋ prometheus plan $0.09 14m34s`. The agent cell absorbs
802
+ * the width difference (down to `DISPATCH_PANEL_MIN_AGENT_WIDTH`), so a narrow
803
+ * panel truncates the label rather than the numbers; the cost column grows by
804
+ * itself for a sub-cent value so the row never spends more than its budget.
805
+ * Pure. */
806
+ export declare function dispatchPanelRowText(entry: DispatchEntry, options?: {
807
+ now?: number;
808
+ frame?: number;
809
+ max?: number;
810
+ }): string;
811
+ /** `ses_ab12cd`, short enough for a detail line. Full id when it already fits. */
812
+ export declare function shortSessionID(id: string | null | undefined, max?: number): string;
813
+ /** Token counters of one child on a single line (`in 1.2K · out 430 · r 120 ·
814
+ * cache 8K/1K`), or `tokens —` when the host published none. Pure. */
815
+ export declare function dispatchTokenLine(tokens: DispatchTokens | null | undefined): string;
816
+ /** Detail lines of the selected child: heading (title, else the spawning
817
+ * description, else the row label), short id + model, token counters, and the
818
+ * kind plus its evidence and the parent id. Two to four lines; `expanded:
819
+ * false` keeps only the heading. Every missing datum prints `—`. Pure. */
820
+ export declare function dispatchPanelDetail(entry: DispatchEntry | null | undefined, options?: {
821
+ expanded?: boolean;
822
+ max?: number;
823
+ }): string[];
824
+ /** Panel geometry for its input width: wide (≥72) puts the detail in a second
825
+ * column, narrow stacks it under the list. `rowWidth` is what a list row may
826
+ * spend after the selection gutter. Pure. */
827
+ export type DispatchPanelLayout = {
828
+ mode: 'wide' | 'narrow';
829
+ listWidth: number;
830
+ detailWidth: number;
831
+ rowWidth: number;
832
+ };
833
+ export declare function dispatchPanelLayout(width: number): DispatchPanelLayout;
834
+ /** Viewport of the list: the page holding the selection, scrolled so the
835
+ * selected row stays visible with its predecessors. Bounded, so a 71-child
836
+ * tree renders ten rows, never all of them. Pure. */
837
+ export declare function dispatchPanelWindow(total: number, selectedIndex: number, pageSize?: number): {
838
+ start: number;
839
+ end: number;
840
+ size: number;
841
+ };
842
+ /** `1-10 de 71` while the list is longer than one page; null when everything
843
+ * fits (and for an empty list), so the footer never pads itself. Pure. */
844
+ export declare function dispatchPanelRangeText(start: number, end: number, total: number): string | null;
845
+ /** One rendered list row, selection resolved by the view against the model's
846
+ * selected id. */
847
+ export type DispatchPanelRow = {
848
+ id: string;
849
+ state: DelegationState;
850
+ text: string;
851
+ };
852
+ /** Every entry as a row, ordered by the shared comparator. Pure. */
853
+ export declare function dispatchPanelRows(entries: readonly DispatchEntry[] | null | undefined, options?: {
854
+ now?: number;
855
+ frame?: number;
856
+ max?: number;
857
+ }): DispatchPanelRow[];
858
+ /** Panel action, one per command. */
859
+ export type DispatchPanelAction = 'up' | 'down' | 'home' | 'end' | 'pageup' | 'pagedown' | 'toggle' | 'fullscreen' | 'close';
860
+ /** One namespaced command: stable id, explicit binding, and the action it runs. */
861
+ export type DispatchPanelCommandSpec = {
862
+ action: DispatchPanelAction;
863
+ id: string;
864
+ title: string;
865
+ bind: string;
866
+ };
867
+ /** The panel's whole keymap, in table order. `bind` is explicit for every
868
+ * command (no auto-binding), and every id is namespaced, so a `k`/`q`/`f`
869
+ * binding can never collide with the host's own keys. */
870
+ export declare const DISPATCH_PANEL_COMMANDS: readonly DispatchPanelCommandSpec[];
871
+ /** Run one action against the model and the host-owned panel input. Kept apart
872
+ * from the keymap so the whole command surface is testable without a renderer.
873
+ */
874
+ export declare function performDispatchPanelAction(action: DispatchPanelAction, model: Pick<DispatchPanelModel, 'move' | 'first' | 'last' | 'pageUp' | 'pageDown' | 'toggle'>, panel: Pick<PanelInput, 'close' | 'toggleFullscreen'>): void;
875
+ /** Footer: the keys the host reports for each command (`keymap.shortcuts`) with
876
+ * an em dash whenever a command has no binding, so the hint can never advertise
877
+ * a key that does nothing. Pure. */
878
+ export declare function dispatchPanelFooter(shortcutsOf: (id: string) => readonly string[]): string;
879
+ /** The subset of `PanelInput` the model reads, so tests can drive it with a
880
+ * plain object. */
881
+ export type DispatchPanelInput = {
882
+ readonly name: string;
883
+ readonly sessionID: string;
884
+ readonly width: number;
885
+ readonly presentation?: string;
886
+ };
887
+ /** Open the panel from the command palette / slash command. `ui.panel.open`
888
+ * only accepts a `session` route, so a refusal (no session open) is answered
889
+ * with a toast — never a fallback route, never a silent no-op. Returns whether
890
+ * the panel opened. */
891
+ export declare function openDispatchPanel(context: any): boolean;
892
+ /** Reactive state the panel view renders. Selection is held by session id, so
893
+ * it survives list updates; the index is derived (and falls back to the first
894
+ * row when the selected child disappears). */
895
+ export type DispatchPanelModel = {
896
+ entries: Accessor<DispatchEntry[]>;
897
+ rows: Accessor<DispatchPanelRow[]>;
898
+ title: Accessor<string>;
899
+ header: Accessor<string | null>;
900
+ detail: Accessor<string[]>;
901
+ layout: Accessor<DispatchPanelLayout>;
902
+ visible: Accessor<{
903
+ start: number;
904
+ rows: DispatchPanelRow[];
905
+ }>;
906
+ selectedID: Accessor<string | null>;
907
+ selectedIndex: Accessor<number>;
908
+ expanded: Accessor<boolean>;
909
+ hasRunning: Accessor<boolean>;
910
+ frame: Accessor<number>;
911
+ footer: Accessor<string>;
912
+ move: (delta: number) => void;
913
+ first: () => void;
914
+ last: () => void;
915
+ pageUp: () => void;
916
+ pageDown: () => void;
917
+ toggle: () => void;
918
+ };
919
+ /** Model behind the panel. Mounted only while the panel claim renders (the
920
+ * `Show` in `session.panel`), so the 80 ms tick it arms exists exactly while
921
+ * the panel is open; it also stops on `isOpen()` going false and on dispose.
922
+ * It performs no `message.sync`, writes no `session.metadata` and makes no
923
+ * request: `collectDispatch` reads only host-cached state. */
924
+ export declare function createDispatchPanelModel(context: any, panel: () => DispatchPanelInput): DispatchPanelModel;
925
+ /** Session ids to eagerly sync at load (deduped, bounded). Pure. */
926
+ export declare function collectWarmupTargets(sessions: readonly any[], limit?: number): string[];
927
+ /** Body a sidebar instance renders when the host has not published a real
928
+ * session id yet. OpenCode V2 scopes the `sidebar.content` slot to a session
929
+ * (`SlotMap["sidebar.content"] = { sessionID: string }`), so before the first
930
+ * prompt the slot may not mount at all — see the `home.footer.status`
931
+ * contribution for the pre-prompt degradation. Pure. */
932
+ export declare function sidebarPlaceholder(sessionID: string | undefined): string | null;
933
+ /** Navigate to a session through the V2 router. Fail-open: an absent router or
934
+ * a removed session must never break the sidebar. Returns whether a valid
935
+ * navigation was dispatched. Pure. */
936
+ export declare function navigateToSession(router: {
937
+ navigate?: (destination: any) => void;
938
+ } | undefined, sessionID: string | undefined): boolean;
939
+ export type DelegationCompletion = {
940
+ id: string;
941
+ label: string;
942
+ state: DelegationState;
943
+ };
944
+ /** Diff two delegation observations: entries that were `running` and are no
945
+ * longer running count as completions, fired once per transition. Returns the
946
+ * next snapshot so callers can keep a single tracker. First observation never
947
+ * reports a completion (no toast spam on mount). Pure. */
948
+ export declare function detectDelegationCompletions(previous: ReadonlyMap<string, DelegationState>, current: ReadonlyArray<DelegationCompletion>): {
949
+ completed: DelegationCompletion[];
950
+ snapshot: Map<string, DelegationState>;
951
+ };
952
+ /** Debounce for the git file-count revalidation. `vcs.status` is an HTTP call;
953
+ * session events arrive in bursts, so the row is refreshed at most once per
954
+ * window instead of on every event. */
955
+ export declare const GIT_CHANGES_DEBOUNCE_MS = 400;
956
+ /** Reactive state the sidebar view renders. Accessors keep the view reactive
957
+ * while the model itself stays free of JSX, so its effects are exercisable
958
+ * without a TUI renderer. */
959
+ export type SidebarModel = {
960
+ activeSessionID: Accessor<string>;
961
+ session: Accessor<any>;
962
+ branch: Accessor<string | null>;
963
+ /** `+N ±N −N` file counts from `vcs.status` (fallback only), null when
964
+ * clean/unavailable. */
965
+ gitChanges: Accessor<string | null>;
966
+ /** The rendered git row: CLI counts with `?untracked ↑ahead ↓behind` when git
967
+ * answered, else the `vcs.status` counts, else null. */
968
+ gitLine: Accessor<string | null>;
969
+ /** Last successful git CLI observation (counts + upstream distance), null
970
+ * while git has never answered. */
971
+ gitCli: Accessor<GitCliSnapshot | null>;
972
+ /** Cache hit rate + output speed of the active session's newest messages. */
973
+ performance: Accessor<ContextPerformance | null>;
974
+ /** The rendered `Dispatch` block: live rows, the finished rollup and the
975
+ * spend totals. Null when the session has no child (block hidden). */
976
+ dispatch: Accessor<DispatchBlockView | null>;
977
+ /** Blocks that have content, in render order, each tagged with its spacer. */
978
+ blocks: Accessor<SidebarBlock[]>;
979
+ hasRunning: Accessor<boolean>;
980
+ frame: Accessor<number>;
981
+ preset: Accessor<PresetInfo>;
982
+ /** Provider of the model in use, derived from the session, its transcript or
983
+ * the host location; null when nothing resolves (the header omits it). */
984
+ provider: Accessor<string | null>;
985
+ /** Resolved preset override map (explicit per-agent models). */
986
+ presetOverrides: Accessor<PresetOverrides>;
987
+ /** Family cost in USD (root + delegations), null when the host cannot answer. */
988
+ cost: Accessor<number | null>;
989
+ /** Real per-model totals from assistant messages, capped for the sidebar. */
990
+ modelUsage: Accessor<ModelUsageCeiling>;
991
+ /** Todo rows derived from the newest completed `todowrite`, ordered + capped. */
992
+ todo: Accessor<TodoCeiling>;
993
+ /** Local spend for `hoje` / `30d`, null when stats is unavailable/unknown.
994
+ * Rendered as the Context block's last line, not as its own block. */
995
+ spend: Accessor<SpendTotals | null>;
996
+ /** Context gauge; null when there is no limit or no token-carrying message. */
997
+ contextUsage: Accessor<ContextUsage | null>;
998
+ /** Current agent and its resolved short model id (`*` = explicit override). */
999
+ agentModel: Accessor<{
1000
+ agent: string;
1001
+ model: string;
1002
+ overridden: boolean;
1003
+ } | null>;
1004
+ };
1005
+ /** Reactive wiring behind the sidebar: refresh subscription, warm syncs, the
1006
+ * running-only spinner and the completion-toast effect. `context` stays loosely
1007
+ * typed (the host API only exists at runtime) but the refresh event names are
1008
+ * narrowed to the V2 union at the subscription site. */
1009
+ export declare function createSidebarModel(context: any, sessionID: () => string | undefined, gitExec?: GitExec): SidebarModel;
1010
+ /** One command: runs only while the panel owns the keyboard, and reports
1011
+ * `false` (the host keeps the key) when it cannot act. `undefined` means the
1012
+ * key was consumed. */
1013
+ export declare function runDispatchPanelCommand(action: DispatchPanelAction, panel: Pick<PanelInput, 'focused' | 'close' | 'toggleFullscreen'>, model: Pick<DispatchPanelModel, 'rows' | 'move' | 'first' | 'last' | 'pageUp' | 'pageDown' | 'toggle'>): false | undefined;
1014
+ /** Keymap layer of the panel, as data. It is registered inside the
1015
+ * `session.panel` claim, but the host mounts the effects of *every* panel
1016
+ * contribution, so the layer itself is not proof of focus: without `enabled`
1017
+ * the `j/k/f/q/enter/escape` bindings were consumed while the panel was not
1018
+ * focused and the composer lost its keys. `enabled` (the documented gate) makes
1019
+ * the whole layer inert until `panel.focused` is true. Pure. */
1020
+ export declare function dispatchPanelKeymapLayer(panel: Pick<PanelInput, 'focused' | 'close' | 'toggleFullscreen'>, model: DispatchPanelModel): KeymapLayer;
1021
+ /** Lean footer model: only the preset label and the live delegation count. It
1022
+ * deliberately does not reuse `createSidebarModel` — that model owns the
1023
+ * completion toasts and the spinner, and a second instance would double-toast.
1024
+ * No session id in the slot input is a graceful no-op (count 0). */
1025
+ export type FooterModel = {
1026
+ preset: Accessor<PresetInfo>;
1027
+ running: Accessor<number>;
1028
+ };
1029
+ export declare function createFooterModel(context: any, sessionID: () => string | undefined): FooterModel;
3
1030
  declare const plugin: {
4
1031
  id: string;
5
- setup(context: any): (() => void) | undefined;
1032
+ setup(context: Context): (() => void) | undefined;
6
1033
  };
7
1034
  //#endregion
8
1035
  export { plugin as default };