@toddzheng024/dscode-bundle 0.7.11 → 0.7.13

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 (154) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -3
  2. package/cordis.patch.yml +1 -1
  3. package/package.json +5 -4
  4. package/plugins/i18n/messages.mjs +6 -6
  5. package/plugins/session-metrics/view.mjs +16 -5
  6. package/plugins/tui-tools/index.mjs +14 -1
  7. package/vendor/tui/lib/app.mjs +6674 -0
  8. package/vendor/tui/lib/approval.mjs +122 -0
  9. package/vendor/tui/lib/attachments.mjs +218 -0
  10. package/vendor/tui/lib/authorization-panel.mjs +242 -0
  11. package/vendor/tui/lib/authorization.mjs +111 -0
  12. package/vendor/tui/lib/commands.mjs +123 -0
  13. package/vendor/tui/lib/dscode/chat.mjs +64 -0
  14. package/vendor/tui/lib/dscode/flags.mjs +32 -0
  15. package/vendor/tui/lib/dscode/model-search.mjs +68 -0
  16. package/vendor/tui/lib/dscode/paste.mjs +87 -0
  17. package/vendor/tui/lib/dscode/telemetry.mjs +82 -0
  18. package/vendor/tui/lib/dscode/welcome.mjs +100 -0
  19. package/vendor/tui/lib/editor-keys.mjs +346 -0
  20. package/vendor/tui/lib/editor.mjs +50 -0
  21. package/vendor/tui/lib/fork.mjs +24 -0
  22. package/vendor/tui/lib/git-workflow.mjs +278 -0
  23. package/vendor/tui/{types/history.d.ts → lib/history.mjs} +69 -26
  24. package/vendor/tui/{types/i18n.d.ts → lib/i18n.mjs} +23 -15
  25. package/vendor/tui/lib/index.mjs +2198 -0
  26. package/vendor/tui/lib/input-split.mjs +170 -0
  27. package/vendor/tui/lib/internals.mjs +90 -0
  28. package/vendor/tui/lib/invariant.mjs +22 -0
  29. package/vendor/tui/lib/kernel-panels.mjs +1265 -0
  30. package/vendor/tui/lib/keyboard.mjs +283 -0
  31. package/vendor/tui/lib/language-panel.mjs +41 -0
  32. package/vendor/tui/lib/locales/en.mjs +495 -0
  33. package/vendor/tui/lib/locales/zh.mjs +495 -0
  34. package/vendor/tui/lib/mentions.mjs +150 -0
  35. package/vendor/tui/lib/model-capabilities.mjs +245 -0
  36. package/vendor/tui/lib/models.mjs +215 -0
  37. package/vendor/tui/{types/panel-accent.d.ts → lib/panel-accent.mjs} +11 -7
  38. package/vendor/tui/lib/permissions.mjs +45 -0
  39. package/vendor/tui/lib/plugin-inventory.mjs +27 -0
  40. package/vendor/tui/lib/presets.mjs +46 -0
  41. package/vendor/tui/lib/provider-settings.mjs +600 -0
  42. package/vendor/tui/lib/questions.mjs +116 -0
  43. package/vendor/tui/lib/rainbow.mjs +181 -0
  44. package/vendor/tui/lib/render/animations.mjs +665 -0
  45. package/vendor/tui/lib/render/editor.mjs +437 -0
  46. package/vendor/tui/lib/render/export.mjs +119 -0
  47. package/vendor/tui/lib/render/fuzzy.mjs +79 -0
  48. package/vendor/tui/lib/render/ime-cursor.mjs +135 -0
  49. package/vendor/tui/lib/render/inspector.mjs +93 -0
  50. package/vendor/tui/lib/render/lines.mjs +538 -0
  51. package/vendor/tui/lib/render/markdown.mjs +592 -0
  52. package/vendor/tui/lib/render/projection.mjs +1862 -0
  53. package/vendor/tui/lib/render/status.mjs +591 -0
  54. package/vendor/tui/lib/render/text.mjs +157 -0
  55. package/vendor/tui/lib/render/tool-detail.mjs +187 -0
  56. package/vendor/tui/lib/render/tool-preview.mjs +79 -0
  57. package/vendor/tui/lib/render/usage.mjs +336 -0
  58. package/vendor/tui/lib/render/width.mjs +191 -0
  59. package/vendor/tui/lib/session-directory.mjs +329 -0
  60. package/vendor/tui/lib/session-query.mjs +184 -0
  61. package/vendor/tui/lib/session-switch.mjs +51 -0
  62. package/vendor/tui/lib/settings-file.mjs +75 -0
  63. package/vendor/tui/lib/skills.mjs +119 -0
  64. package/vendor/tui/lib/startup.mjs +111 -0
  65. package/vendor/tui/lib/store.mjs +129 -0
  66. package/vendor/tui/lib/subagents.mjs +200 -0
  67. package/vendor/tui/lib/terminal-title.mjs +186 -0
  68. package/vendor/tui/lib/theme-panel.mjs +60 -0
  69. package/vendor/tui/lib/theme.mjs +379 -0
  70. package/vendor/tui/lib/update-panel.mjs +239 -0
  71. package/vendor/tui/lib/update.mjs +101 -0
  72. package/vendor/tui/lib/version.mjs +105 -0
  73. package/vendor/tui/lib/whale-glyph.mjs +20 -0
  74. package/vendor/tui/LICENSE +0 -21
  75. package/vendor/tui/devtools-CdTl3MNy.mjs +0 -3643
  76. package/vendor/tui/dscode-email/cli.mjs +0 -32
  77. package/vendor/tui/dscode-email/contacts.mjs +0 -36
  78. package/vendor/tui/dscode-email/gmail-oauth.mjs +0 -69
  79. package/vendor/tui/dscode-email/gmail-store.mjs +0 -2
  80. package/vendor/tui/dscode-email/gmail.mjs +0 -194
  81. package/vendor/tui/dscode-email/imap.mjs +0 -136
  82. package/vendor/tui/dscode-email/inbox.d.mts +0 -25
  83. package/vendor/tui/dscode-email/inbox.mjs +0 -76
  84. package/vendor/tui/dscode-email/smtp.mjs +0 -69
  85. package/vendor/tui/dscode-email/store.mjs +0 -32
  86. package/vendor/tui/dscode-providers/catalog.mjs +0 -136
  87. package/vendor/tui/dscode-providers/effort.mjs +0 -35
  88. package/vendor/tui/dscode-providers/openrouter-account.mjs +0 -171
  89. package/vendor/tui/index.mjs +0 -44483
  90. package/vendor/tui/invariant.mjs +0 -21
  91. package/vendor/tui/rolldown-runtime-CMFfr-1z.mjs +0 -26
  92. package/vendor/tui/session-query.mjs +0 -150
  93. package/vendor/tui/startup.mjs +0 -109
  94. package/vendor/tui/theme-7u5Qo3dF.mjs +0 -1265
  95. package/vendor/tui/types/app.d.ts +0 -348
  96. package/vendor/tui/types/approval.d.ts +0 -59
  97. package/vendor/tui/types/attachments.d.ts +0 -52
  98. package/vendor/tui/types/authorization-panel.d.ts +0 -22
  99. package/vendor/tui/types/authorization.d.ts +0 -36
  100. package/vendor/tui/types/commands.d.ts +0 -52
  101. package/vendor/tui/types/editor-keys.d.ts +0 -105
  102. package/vendor/tui/types/editor.d.ts +0 -6
  103. package/vendor/tui/types/fork.d.ts +0 -8
  104. package/vendor/tui/types/git-workflow.d.ts +0 -121
  105. package/vendor/tui/types/index.d.ts +0 -223
  106. package/vendor/tui/types/input-split.d.ts +0 -54
  107. package/vendor/tui/types/internals.d.ts +0 -26
  108. package/vendor/tui/types/invariant.d.ts +0 -15
  109. package/vendor/tui/types/kernel-panels.d.ts +0 -245
  110. package/vendor/tui/types/keyboard.d.ts +0 -80
  111. package/vendor/tui/types/language-panel.d.ts +0 -12
  112. package/vendor/tui/types/locales/en.d.ts +0 -450
  113. package/vendor/tui/types/locales/zh.d.ts +0 -9
  114. package/vendor/tui/types/mentions.d.ts +0 -85
  115. package/vendor/tui/types/model-capabilities.d.ts +0 -82
  116. package/vendor/tui/types/models.d.ts +0 -133
  117. package/vendor/tui/types/permissions.d.ts +0 -27
  118. package/vendor/tui/types/plugin-inventory.d.ts +0 -11
  119. package/vendor/tui/types/presets.d.ts +0 -22
  120. package/vendor/tui/types/provider-settings.d.ts +0 -239
  121. package/vendor/tui/types/questions.d.ts +0 -54
  122. package/vendor/tui/types/rainbow.d.ts +0 -69
  123. package/vendor/tui/types/render/animations.d.ts +0 -307
  124. package/vendor/tui/types/render/editor.d.ts +0 -163
  125. package/vendor/tui/types/render/export.d.ts +0 -9
  126. package/vendor/tui/types/render/fuzzy.d.ts +0 -21
  127. package/vendor/tui/types/render/ime-cursor.d.ts +0 -60
  128. package/vendor/tui/types/render/inspector.d.ts +0 -62
  129. package/vendor/tui/types/render/lines.d.ts +0 -86
  130. package/vendor/tui/types/render/markdown.d.ts +0 -29
  131. package/vendor/tui/types/render/projection.d.ts +0 -587
  132. package/vendor/tui/types/render/status.d.ts +0 -196
  133. package/vendor/tui/types/render/text.d.ts +0 -64
  134. package/vendor/tui/types/render/tool-detail.d.ts +0 -94
  135. package/vendor/tui/types/render/tool-preview.d.ts +0 -28
  136. package/vendor/tui/types/render/usage.d.ts +0 -113
  137. package/vendor/tui/types/render/width.d.ts +0 -29
  138. package/vendor/tui/types/session-directory.d.ts +0 -190
  139. package/vendor/tui/types/session-query.d.ts +0 -92
  140. package/vendor/tui/types/session-switch.d.ts +0 -17
  141. package/vendor/tui/types/settings-file.d.ts +0 -41
  142. package/vendor/tui/types/skills.d.ts +0 -47
  143. package/vendor/tui/types/startup.d.ts +0 -65
  144. package/vendor/tui/types/store.d.ts +0 -58
  145. package/vendor/tui/types/subagents.d.ts +0 -70
  146. package/vendor/tui/types/terminal-title.d.ts +0 -66
  147. package/vendor/tui/types/theme-panel.d.ts +0 -24
  148. package/vendor/tui/types/theme.d.ts +0 -434
  149. package/vendor/tui/types/update-panel.d.ts +0 -49
  150. package/vendor/tui/types/update.d.ts +0 -75
  151. package/vendor/tui/types/version.d.ts +0 -19
  152. package/vendor/tui/types/whale-glyph.d.ts +0 -6
  153. /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/clipboard-image.swift +0 -0
  154. /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/index.mjs +0 -0
@@ -1,587 +0,0 @@
1
- /**
2
- * Pure session-event-to-view projection for the TUI transcript: one reducer
3
- * over {@link SessionEvent}s producing the ordered entries the renderer draws.
4
- * Rendering never reads the session directly — this module owns the view
5
- * model, so tests drive it with plain event arrays.
6
- *
7
- * @module @deepseek-ai/dsh-tui/render/projection
8
- */
9
- import { type ImageBlock, type MessageId, type StreamChunk } from '@deepseek-ai/dsh-llm';
10
- import type { FileAttachmentRef } from '@deepseek-ai/dsh-attachment';
11
- import type { SessionEvent } from '@deepseek-ai/dsh-session';
12
- import type { TodoItem } from '@deepseek-ai/dsh-tool-todo';
13
- import { type ToolDetail } from './tool-detail.ts';
14
- /** One user prompt line. */
15
- export interface UserEntry {
16
- kind: 'user';
17
- /** Joined text blocks of the user message. */
18
- text: string;
19
- /** True for collapsed injected context (plugin/continuation notices), which
20
- * the renderer marks with a dim ↳ instead of the user ❯ prompt. */
21
- notice: boolean;
22
- /** Durable image references carried by this prompt. */
23
- images?: readonly ImageBlock['attachment'][];
24
- /** Durable file references carried by this prompt (0.1.5 file blocks). */
25
- files?: readonly FileAttachmentRef[];
26
- /**
27
- * How the prompt reached the agent, when it did not arrive as an ordinary
28
- * submission: `queued` waited for this turn, `steered` joined it mid-flight.
29
- * Absent for a prompt typed straight into an idle composer.
30
- */
31
- delivery?: 'queued' | 'steered';
32
- }
33
- /** One user message waiting in the agent inbox (the web's queued-message row). */
34
- export interface PendingEntry {
35
- kind: 'pending';
36
- /** Stable message identity shared with the durable `user/message` that retires it. */
37
- messageId: MessageId;
38
- /** Which inbox list holds the message: steering is consumed at the next step boundary. */
39
- target: 'next-turn' | 'next-step';
40
- /** Full message text — Codex PendingSteer renders queued prompts exactly like user rows. */
41
- text: string;
42
- /** Durable image references queued with this prompt. */
43
- images?: readonly ImageBlock['attachment'][];
44
- /** Durable file references queued with this prompt (0.1.5 file blocks). */
45
- files?: readonly FileAttachmentRef[];
46
- }
47
- /** One authoritative assembled assistant reply. */
48
- export interface AssistantEntry {
49
- kind: 'assistant';
50
- /** Joined text blocks of the assistant message. */
51
- text: string;
52
- /** Joined reasoning blocks from the same assembled message. */
53
- reasoning: string;
54
- /** True when a cancelled stream's delivered prefix was finalized as this
55
- * entry (rc.8 `assistant/message.interrupted`) — rendered with a marker. */
56
- interrupted?: true;
57
- }
58
- /** One model-requested tool invocation and its settled state. */
59
- export interface ToolEntry {
60
- kind: 'tool';
61
- /** Correlation id shared with the matching `tool/result`. */
62
- callId: string;
63
- /**
64
- * Global tool-call ordinal across the whole transcript (1, 2, 3…, never
65
- * reset between turns). The tool-card badge and every error line that
66
- * references the failed call share this number, so "call N" in an error
67
- * always names the exact card the badge shows.
68
- */
69
- ordinal: number;
70
- /** Tool name as the model addressed it. */
71
- name: string;
72
- /** Raw arguments JSON string exactly as the model produced it. */
73
- arguments: string;
74
- /** Bounded human-meaningful arguments preview for the tool card. */
75
- preview: string;
76
- /** Bounded delegation prompt (subagent cards' second row), '' when none. */
77
- prompt: string;
78
- /** Execution state; `running` until the paired result lands. */
79
- state: 'running' | 'done' | 'error';
80
- /** Bounded first text block of the result, empty until it lands. */
81
- summary: string;
82
- /**
83
- * Bounded expansion payload for the verbose transcript (Ctrl+O), derived
84
- * from the tool's persisted presentation metadata; undefined until the
85
- * result lands and only when something renderable exists.
86
- */
87
- detail: ToolDetail | undefined;
88
- /**
89
- * Nested PTC sub-dispatches (`run_code`) in start order, bounded to the
90
- * newest {@link MAX_TOOL_SUB_DISPATCHES} rows.
91
- */
92
- subs: readonly ToolSubDispatch[];
93
- /** Sub-dispatches evicted from the bounded window. */
94
- subsDropped: number;
95
- }
96
- /**
97
- * One nested PTC sub-dispatch under a `run_code` parent call: the durable
98
- * `tool/ptc-dispatch-start`/`tool/ptc-dispatch` pair folded to one bounded
99
- * row (upstream contract: pair by `subCallId`, every start settles, and the
100
- * settle carries `tool/result`'s own vocabulary).
101
- */
102
- export interface ToolSubDispatch {
103
- /** Opaque sub-call id pairing the start with its settle. */
104
- subCallId: string;
105
- /** Sub-call tool name. */
106
- name: string;
107
- /** Bounded arguments preview. */
108
- preview: string;
109
- /** Lifecycle; `running` until the paired settle lands. */
110
- state: 'running' | 'done' | 'error';
111
- /** Bounded first text block of the settle content, '' until it lands. */
112
- summary: string;
113
- /** Wall-clock duration (settle − start), 0 while running. */
114
- durationMs: number;
115
- }
116
- /** Bounded sub-dispatch window per tool card (display budget only). */
117
- export declare const MAX_TOOL_SUB_DISPATCHES = 12;
118
- /** Bounded member window per workflow run card (display budget only). */
119
- export declare const MAX_WORKFLOW_MEMBERS = 12;
120
- /** One workflow member (an `agent()` call inside a `workflow` script). */
121
- export interface WorkflowMember {
122
- /** Member sequence within the run (the agent-start/agent-end pairing key). */
123
- seq: number;
124
- /** Display label. */
125
- label: string;
126
- /** Declared phase title, '' when none. */
127
- phase: string;
128
- /** Child session id (cross-links the subagent feed's rows). */
129
- childId: string;
130
- /** Settlement; `running` until the paired `tool-workflow/agent-end`. */
131
- outcome: 'running' | 'completed' | 'failed' | 'cancelled';
132
- }
133
- /**
134
- * One durable workflow run (the `tool-workflow/*` record a `workflow` or
135
- * `ralph` tool appends to the parent session): run identity plus its
136
- * bounded member list, live until `tool-workflow/run-end` settles.
137
- */
138
- export interface WorkflowEntry {
139
- kind: 'workflow';
140
- /** Stable run identity shared by every event of the run. */
141
- runId: string;
142
- /** Display name of the run. */
143
- name: string;
144
- /** Members in sequence order, bounded to the newest window. */
145
- members: readonly WorkflowMember[];
146
- /** Members evicted from the bounded window. */
147
- membersDropped: number;
148
- /** Run settlement; `running` until `tool-workflow/run-end`. */
149
- state: 'running' | 'completed' | 'cancelled' | 'error';
150
- }
151
- /** One slash-command execution dispatched through `ctx.commands`. */
152
- export interface CommandEntry {
153
- kind: 'command';
154
- /** Pairing id shared with the matching `command/done`. */
155
- commandId: string;
156
- /** Lowercase command name without the leading slash. */
157
- name: string;
158
- /** Verbatim text following the command name. */
159
- args: string;
160
- /** Execution state; `running` until the paired lifecycle event lands. */
161
- state: 'running' | 'done' | 'error';
162
- /** Handler outcome text, empty until it lands. */
163
- summary: string;
164
- }
165
- /** One turn-level failure surfaced from `turn/end`. */
166
- export interface ErrorEntry {
167
- kind: 'error';
168
- /** `code: message` of the failure. */
169
- text: string;
170
- }
171
- /** One non-error turn outcome surfaced from `turn/end`. */
172
- export interface TurnMarkerEntry {
173
- kind: 'turn-marker';
174
- /** Human-readable outcome line, dim-rendered. */
175
- text: string;
176
- }
177
- /** One completed compaction lifecycle surfaced from `compaction/end`. */
178
- export interface CompactionEntry {
179
- kind: 'compaction';
180
- /** True when the compaction completed, false when it failed. */
181
- ok: boolean;
182
- /** Heuristic tokens shadowed by the compaction (summary or prune price). */
183
- tokens: number;
184
- /** Failure text when `ok` is false, empty otherwise. */
185
- error: string;
186
- }
187
- /** One provider-routed model-request retry (the `llm/retry` pair). */
188
- export interface RetryEntry {
189
- kind: 'retry';
190
- /** Correlation id shared with the matching `llm/retry-started`. */
191
- retryId: string;
192
- /** Retry policy mode from the event: `always` has no attempt cap. */
193
- mode: 'normal' | 'always';
194
- /** Attempt ordinal and its cap. */
195
- attempt: number;
196
- max: number;
197
- /** Failure code that triggered the retry. */
198
- code: string;
199
- /** Backoff wait before the next attempt, in ms. */
200
- delayMs: number;
201
- /**
202
- * `running` while the backoff waits, `done` once the attempt started — or
203
- * when the turn ended first (the turn-end sweep finalizes orphans so they
204
- * never pin the settled boundary).
205
- */
206
- state: 'running' | 'done';
207
- }
208
- /** Turn-tail deliverables: files mutated by the turn's diff-bearing tools. */
209
- export interface FilesEntry {
210
- kind: 'files';
211
- /** Unique mutated paths in call order, bounded. */
212
- paths: readonly string[];
213
- }
214
- /** Ordered transcript items the renderer draws. */
215
- export type TranscriptEntry = UserEntry | PendingEntry | AssistantEntry | ToolEntry | CommandEntry | ErrorEntry | TurnMarkerEntry | CompactionEntry | RetryEntry | FilesEntry | WorkflowEntry;
216
- /** The live goal the status line badges, folded from `goal/change`. */
217
- export interface GoalFold {
218
- /** Human-requested completion objective. */
219
- objective: string;
220
- /** Durable lifecycle phase. */
221
- phase: 'active' | 'paused' | 'blocked' | 'complete';
222
- /** Highest admitted continuation round and its cap. */
223
- rounds: number;
224
- max: number;
225
- /** Blocked explanation, empty outside the blocked phase. */
226
- blocked: string;
227
- }
228
- /**
229
- * Cumulative token accounting folded from `assistant/message` usage reports.
230
- * The buckets are disjoint and mirror the provider's report, so the prompt
231
- * side is never double counted: reasoning tokens are already inside
232
- * `outputTokens`, and cache reads are never folded into the uncached input.
233
- */
234
- export interface UsageTotals {
235
- /** Prompt-side tokens billed outside the cache. */
236
- uncachedInputTokens: number;
237
- /** Completion-side tokens over the whole log. */
238
- outputTokens: number;
239
- /** Cache-read tokens over the whole log (0 when the adapter reports none). */
240
- cacheReadTokens: number;
241
- /** Cache-write tokens over the whole log (0 when the adapter reports none). */
242
- cacheWriteTokens: number;
243
- }
244
- /**
245
- * Estimated used tokens per context content type, folded from transcript
246
- * events via {@link estimateTokens}. The segmented context bar's composition
247
- * source: proportions across types are meaningful, absolute values are not
248
- * (they never touch billing or the reported `lastPromptTokens`).
249
- */
250
- export interface ContextSegments {
251
- /** Rendered system-prompt text (latest `request/header`) plus injected-context notices. */
252
- system: number;
253
- /** Direct human prompts (durable `user/message` rows). */
254
- prompt: number;
255
- /** Assistant text blocks (visible replies). */
256
- assistant: number;
257
- /** Assistant reasoning blocks (hidden thinking). */
258
- thinking: number;
259
- /** Tool call arguments plus result text. */
260
- tools: number;
261
- }
262
- /** Window-scoped figures the status line shows; timing uses event timestamps. */
263
- export interface TranscriptStats {
264
- /** Durable turns opened (`turn/start` events). */
265
- turns: number;
266
- /** Model requests made (`step/start` events). */
267
- steps: number;
268
- /** Summed model wall time: `step/start` → `assistant/message`, in ms. */
269
- llmMs: number;
270
- /** Summed tool wall time: `tool/call` → `tool/result`, in ms. */
271
- toolMs: number;
272
- /** Cumulative token accounting; input stays 0 until a report lands. */
273
- usage: UsageTotals;
274
- /** Prompt-side size of the most recent reported request (context pressure). */
275
- lastPromptTokens: number;
276
- /** Newest advertised route capacity, 0 when no adapter ever advertised one. */
277
- contextWindow: number;
278
- /** Estimated used tokens per content type (the segmented bar's composition). */
279
- contextSegments: ContextSegments;
280
- /** Summed first-token waits: `step/start` → first non-empty chunk, in ms. */
281
- ttftMs: number;
282
- /** Steps that produced a first chunk (the TTFT average's denominator). */
283
- ttftSteps: number;
284
- /** Summed decode spans: first chunk → `assistant/message`, in ms. */
285
- decodeMs: number;
286
- /** Completion tokens over timed decode spans (the tok/s numerator). */
287
- decodeTokens: number;
288
- /**
289
- * Adapter-owned reasoning effort of the latest `request/header` config —
290
- * the EFFECTIVE effort the session actually uses (a materialized model
291
- * default is included, exactly as the adapter resolved it). Empty when the
292
- * header carried none (provider-default behavior). The status line appends
293
- * it to the model segment as `provider/model@effort`.
294
- */
295
- reasoningEffort: string;
296
- }
297
- /** One active reminder folded from durable `schedule/change` events. */
298
- export interface ScheduleRow {
299
- readonly id: string;
300
- readonly kind: 'after' | 'at' | 'every';
301
- readonly prompt: string;
302
- /** Next due time (epoch ms); the /schedule panel derives overdue/relative labels. */
303
- readonly targetAt: number;
304
- /** Recurrence seconds for 'every' rows, undefined otherwise. */
305
- readonly everySeconds?: number;
306
- }
307
- /**
308
- * The durable `schedule/change` payload shape this fold consumes. Upstream
309
- * strict-decodes the whole transition stream before appending, so unknown
310
- * ids here are corrupt-input edges that degrade to a no-op.
311
- */
312
- export interface ScheduleChangeLike {
313
- readonly operation: 'create' | 'delete' | 'dispatch';
314
- readonly schedule?: {
315
- readonly id: string;
316
- readonly kind: 'after' | 'at' | 'every';
317
- readonly prompt: string;
318
- readonly afterSeconds?: number;
319
- readonly everySeconds?: number;
320
- readonly scheduledAt: string;
321
- };
322
- readonly id?: string;
323
- readonly acceptedAt?: string;
324
- }
325
- /** Fold one `schedule/change` into the active-reminder list (create/delete/dispatch). */
326
- export declare function applyScheduleChange(rows: readonly ScheduleRow[], data: ScheduleChangeLike): readonly ScheduleRow[];
327
- /** First anchor-aligned target after `acceptedAt`, stepping from the previous aligned target. */
328
- export declare function nextEveryTarget(previousTarget: number, acceptedAt: number, everySeconds: number): number;
329
- /** The complete TUI transcript view for one session. */
330
- export interface TranscriptView {
331
- /** Settled entries in log order. */
332
- entries: readonly TranscriptEntry[];
333
- /** Bounded text tail accumulated from live stream frames since the last settlement. */
334
- streaming: string;
335
- /** Bounded thinking tail accumulated from reasoning deltas since the last flush. */
336
- streamingReasoning: string;
337
- /** Latest whole-list todo snapshot from `todo/write`, empty when none. */
338
- todos: readonly TodoItem[];
339
- /**
340
- * Global tool-call ordinal counter: the number the NEXT `tool/call` lands
341
- * with (1-based). Never reset, so the counter and the badges/error lines
342
- * stay consistent across turns and resumed sessions.
343
- */
344
- toolCallOrdinal: number;
345
- /** True while a durable turn is open (`turn/start` … `turn/end`). */
346
- busy: boolean;
347
- /** `turn/start` time of the open turn (0 while idle) — the web TurnStatus clock anchor. */
348
- busySince: number;
349
- /** Figures the status line renders. */
350
- stats: TranscriptStats;
351
- /**
352
- * The `provider/model` pair of the last `request/header` snapshot — the
353
- * session's own model record, which a resumed TUI prefers over the
354
- * deployment default (mirrors the web host's resume selection order).
355
- * Empty before the session's first request.
356
- */
357
- model: string;
358
- /** Plan mode state folded from the last `plan/mode` event. */
359
- plan: boolean;
360
- /** Active permission preset folded from the last `permission/preset` event, empty before one. */
361
- permission: string;
362
- /** Latest session title folded from the last `session/title` event, empty before one. */
363
- title: string;
364
- /**
365
- * Effective system prompt assembled from `system/message` surface nodes
366
- * (v3): the head node's text joined with every later non-empty node, blank
367
- * lines between. Empty before the first system node or when every node is
368
- * empty ("no system prompt").
369
- */
370
- systemPrompt: string;
371
- /** Sandbox-mode override folded from the last `sandbox/mode` event, empty when never switched. */
372
- sandbox: string;
373
- /** Current long-running goal folded from the last `goal/change`, undefined when cleared. */
374
- goal: GoalFold | undefined;
375
- /** Active reminders folded from `schedule/change` events, oldest target first at render. */
376
- schedules: readonly ScheduleRow[];
377
- /**
378
- * Ordered live message ids per inbox target, mirrored from
379
- * `agent/inbox/spliced` exactly like the upstream Inbox projection — the
380
- * coordinates later removals resolve against.
381
- */
382
- pending: {
383
- 'next-turn': readonly string[];
384
- 'next-step': readonly string[];
385
- };
386
- /**
387
- * In-flight inbox messages by the list they were inserted into, kept until
388
- * the durable user message that claims them lands. The claim itself is a
389
- * plain splice that empties the pending row first, so this map — not
390
- * {@link pending} — is what lets a settled prompt say it was queued or
391
- * steered rather than typed into an idle composer.
392
- */
393
- claimOrigin: ReadonlyMap<string, 'next-turn' | 'next-step'>;
394
- /**
395
- * Fold-internal timing anchors, never rendered: open step and tool-call
396
- * start timestamps the next `assistant/message` / `tool/result` resolves
397
- * against. Keyed `turn:step` and by call id. `turnSteps`/`turnTools`
398
- * track which step/tool anchors still belong to the open turn so
399
- * `turn/end` (and a superseding `step/start`) can sweep anchors an
400
- * interruption left behind; `turnFiles` keys mutated paths by turn.
401
- */
402
- readonly anchors: {
403
- stepStart: Map<string, number>;
404
- toolStart: Map<string, number>;
405
- /** Open PTC sub-dispatch starts by `subCallId` (duration anchors). */
406
- subStart: Map<string, number>;
407
- firstChunkAt: Map<string, number>;
408
- compactionTokens: Map<string, number>;
409
- lastPruneTokens: number;
410
- turnFiles: Map<number, Set<string>>;
411
- turnSteps: Map<number, string>;
412
- turnTools: Map<number, Set<string>>;
413
- /** Live `system/message` surface nodes by event seq (empty string = an empty node). */
414
- systemNodes: Map<number, string>;
415
- };
416
- }
417
- /** Human-readable bounded image labels for transcript, inspector, and export surfaces. */
418
- export declare function imageLabels(images: readonly ImageBlock['attachment'][] | undefined): string;
419
- /** Human-readable bounded file labels for the same surfaces (0.1.5 file blocks). */
420
- export declare function fileLabels(files: readonly FileAttachmentRef[] | undefined): string;
421
- /** Prompt text with its durable image and file labels, without exposing local paths or bytes. */
422
- export declare function promptDisplayText(entry: Pick<UserEntry | PendingEntry, 'text' | 'images' | 'files'>): string;
423
- /** A fresh, empty transcript view. */
424
- export declare function createTranscriptView(): TranscriptView;
425
- /**
426
- * Fold one session event into an updated view (copy-on-write).
427
- * @param view - the view before the event.
428
- * @param event - one durable session event from `session/event` or the log.
429
- * @returns the view after the event; the input view is never mutated.
430
- */
431
- export declare function projectEvent(view: TranscriptView, event: SessionEvent): TranscriptView;
432
- /**
433
- * Mutable replay accumulator: folds a persisted log into the identical view
434
- * `projectEvent` would produce, but in near-linear time. Where `projectEvent`
435
- * is copy-on-write — every append/scan rebuilds the whole `entries` array, so
436
- * folding a full log costs O(N²) — the accumulator appends by push, resolves
437
- * id-keyed updates (tool/result, command/done, retry-started) through index
438
- * maps, and tombstones retired pending rows, so the whole log folds in O(N)
439
- * plus one compaction pass when tombstones exist.
440
- *
441
- * Index maps never delete: every appended row registers its index, so an id
442
- * lookup miss provably means no matching row exists and the update is an O(1)
443
- * no-op (a malicious/orphan-heavy log cannot force per-orphan full-array
444
- * scans). Each id maps to ALL of its indices, so a duplicate id updates every
445
- * matching row exactly like the copy-on-write reducer.
446
- *
447
- * @internal Exported only so tests can (a) prove replay ≡ sequential
448
- * `projectEvent` folds and (b) assert the linear complexity deterministically
449
- * via {@link ReplayAccumulator.ops}, which counts entry-level container work
450
- * instead of relying on wall-clock thresholds. No public consumer.
451
- */
452
- export interface ReplayAccumulator {
453
- /** Working entry list; `undefined` marks a retired pending row (tombstone). */
454
- entries: (TranscriptEntry | undefined)[];
455
- /** callId → every index into `entries` holding a `tool` row with that id. */
456
- toolIndex: Map<string, number[]>;
457
- /** commandId → every index into `entries` holding a `command` row with that id. */
458
- commandIndex: Map<string, number[]>;
459
- /** retryId → every index into `entries` holding a `retry` row with that id. */
460
- retryIndex: Map<string, number[]>;
461
- /** messageId → every index into `entries` holding a `pending` row with that id. */
462
- pendingIndex: Map<string, number[]>;
463
- /** runId → every index into `entries` holding a `workflow` row with that id. */
464
- workflowIndex: Map<string, number[]>;
465
- /** Tombstone count; zero means `entries` is already the final array. */
466
- removedCount: number;
467
- /** Mutable inbox id lists, mirroring `view.pending` order per target. */
468
- pendingTurn: string[];
469
- pendingStep: string[];
470
- /** Mutable mirror of `view.claimOrigin` (see the reducer's field doc). */
471
- claimOrigin: Map<string, 'next-turn' | 'next-step'>;
472
- streaming: string;
473
- streamingReasoning: string;
474
- todos: readonly TodoItem[];
475
- /** Global tool-call ordinal counter (see `TranscriptView.toolCallOrdinal`). */
476
- toolCallOrdinal: number;
477
- busy: boolean;
478
- busySince: number;
479
- model: string;
480
- plan: boolean;
481
- permission: string;
482
- title: string;
483
- systemPrompt: string;
484
- sandbox: string;
485
- goal: GoalFold | undefined;
486
- schedules: readonly ScheduleRow[];
487
- stats: TranscriptStats;
488
- stepStart: Map<string, number>;
489
- toolStart: Map<string, number>;
490
- /** Open PTC sub-dispatch starts by `subCallId` (duration anchors). */
491
- subStart: Map<string, number>;
492
- firstChunkAt: Map<string, number>;
493
- compactionTokens: Map<string, number>;
494
- lastPruneTokens: number;
495
- turnFiles: Map<number, Set<string>>;
496
- turnSteps: Map<number, string>;
497
- turnTools: Map<number, Set<string>>;
498
- /** Live `system/message` surface nodes by event seq (empty string = an empty node). */
499
- systemNodes: Map<number, string>;
500
- /** Entry-level container operations performed so far (test instrumentation). */
501
- ops: number;
502
- }
503
- /** @internal A fresh replay accumulator whose state mirrors `createTranscriptView()`. */
504
- export declare function createReplayAccumulator(): ReplayAccumulator;
505
- /**
506
- * Fold one session event into a replay accumulator. This mirrors
507
- * {@link projectEvent} case for case — same stats arithmetic, same anchor
508
- * set/delete behavior, same entry shapes — so the finished view is identical
509
- * to a sequential fold; only the `entries` container operations are mutable.
510
- *
511
- * @internal Test-instrumentation path; `projectEvents` is the public entry.
512
- * @returns whether the event changed the accumulated state — the live store
513
- * stays silent and keeps its snapshot identity for ignored events, exactly
514
- * like the copy-on-write reducer returning its input view unchanged.
515
- */
516
- export declare function replayProjectEvent(acc: ReplayAccumulator, event: SessionEvent): boolean;
517
- /**
518
- * Materialize the accumulated fold as a `TranscriptView`, compacting any
519
- * retired tombstones. The anchors maps are handed through as-is (their
520
- * content is identical to a sequential fold's).
521
- *
522
- * @internal Test-instrumentation path; `projectEvents` is the public entry.
523
- */
524
- export declare function finishReplay(acc: ReplayAccumulator): TranscriptView;
525
- /**
526
- * Materialize the accumulated fold as a fresh immutable snapshot for the
527
- * live store. Unlike {@link finishReplay} — the one-shot replay entry, which
528
- * hands the accumulator's own arrays through because the accumulator is
529
- * discarded — every array a renderer can hold is copied here, so later
530
- * folds never mutate a snapshot already handed out. Same fields, same
531
- * tombstone compaction.
532
- *
533
- * @internal Live-store path; `projectEvents` is the public entry.
534
- */
535
- export declare function snapshotReplayView(acc: ReplayAccumulator): TranscriptView;
536
- /**
537
- * Fold a replayed event history into one view.
538
- *
539
- * Folding is near-linear in the log size: the mutable replay accumulator
540
- * appends in place and resolves id-keyed updates through index maps, so a
541
- * long persisted session replays without the O(N²) copy-on-write rebuilds a
542
- * naive sequential fold would incur. The result is identical to folding
543
- * {@link projectEvent} per event in order.
544
- * @param events - events in `seq` order.
545
- * @returns the folded view.
546
- */
547
- export declare function projectEvents(events: readonly SessionEvent[]): TranscriptView;
548
- /**
549
- * Fold one process-local assistant-stream chunk frame (session-log v2+ keeps
550
- * durable logs settlement-only; live typing rides the `agent/assistant-stream`
551
- * agent event). Same first-token anchoring the durable `assistant/chunk` event
552
- * used to carry: the first non-empty delta anchors the TTFT and empty
553
- * keep-alive deltas do not count. The caller maps the frame's attempt to the
554
- * `turn:step` key (the start frame owns turn/step; chunk frames do not).
555
- * @param acc - the live replay accumulator.
556
- * @param key - the `turn:step` key the attempt's start frame declared.
557
- * @param time - the frame's safe-integer timestamp.
558
- * @param chunk - the model chunk the frame carries.
559
- * @returns whether the accumulator changed (the store stays silent otherwise).
560
- */
561
- export declare function applyAssistantStreamChunk(acc: ReplayAccumulator, key: string, time: number, chunk: StreamChunk): boolean;
562
- /**
563
- * Drop the live streaming tails without a settlement (an `agent/assistant-stream`
564
- * end frame with an `abandoned` outcome, or a session switch). The next start
565
- * frame rebuilds from scratch.
566
- * @param acc - the live replay accumulator.
567
- * @returns whether any tail text was discarded.
568
- */
569
- export declare function clearAssistantStream(acc: ReplayAccumulator): boolean;
570
- /**
571
- * The append-only flush boundary for a transcript view: the count of entries
572
- * no later event can remove. Entries at or beyond this index are mutable and
573
- * must stay in the live tree.
574
- *
575
- * `pending` rows are excluded even though they are not a running tool/retry:
576
- * the inbox claims or cancels them durably (`agent/inbox/spliced` removals,
577
- * `user/message` retirement), and an append-only `<Static>` flush cannot
578
- * erase a row that vanishes from the view — the retired row would ghost on
579
- * screen until the next source-backed replay. Running commands join the
580
- * mutable boundary for the same reason in reverse: `command/done` mutates the
581
- * row's state/summary, so a flushed row would keep its stale running mark
582
- * until a resize-triggered replay. Everything else (including a completed
583
- * tail) is final: later events only APPEND new rows.
584
- * @param entries - the view's transcript entries in order.
585
- * @returns the count of entries safe to flush (0 for an empty transcript).
586
- */
587
- export declare function settledEntryCount(entries: readonly TranscriptEntry[]): number;