aegisone 1.0.34 → 1.0.35

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 (226) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -1
  3. package/SOURCE-OFFER.txt +9 -0
  4. package/bin/aegis.js +1 -322
  5. package/package.json +4 -5
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -976
  9. package/src/child.js +1 -285
  10. package/src/dispatch.js +1 -269
  11. package/src/doctor.js +1 -639
  12. package/src/host.js +1 -111
  13. package/src/permissions.js +1 -383
  14. package/src/probes.js +1 -159
  15. package/src/release.js +1 -409
  16. package/vendor/cli/package.json +3 -7
  17. package/vendor/cli/scripts/check.mjs +1 -52
  18. package/vendor/cli/scripts/demo.mjs +1 -94
  19. package/vendor/cli/scripts/predist.mjs +1 -75
  20. package/vendor/cli/scripts/runtests.mjs +1 -56
  21. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  22. package/vendor/cli/src/agents.js +1 -139
  23. package/vendor/cli/src/app.js +1 -2957
  24. package/vendor/cli/src/art.js +1 -289
  25. package/vendor/cli/src/chatflow.js +1 -3023
  26. package/vendor/cli/src/checkpoint.js +1 -90
  27. package/vendor/cli/src/clipboard.js +1 -424
  28. package/vendor/cli/src/cloudsync.js +1 -528
  29. package/vendor/cli/src/commands.js +1 -4089
  30. package/vendor/cli/src/config.js +1 -581
  31. package/vendor/cli/src/connect.js +1 -349
  32. package/vendor/cli/src/credentials.js +1 -33
  33. package/vendor/cli/src/deps.js +1 -232
  34. package/vendor/cli/src/devrun.js +1 -187
  35. package/vendor/cli/src/diff.js +1 -333
  36. package/vendor/cli/src/diffview.js +1 -296
  37. package/vendor/cli/src/engine.js +1 -297
  38. package/vendor/cli/src/entitlement.js +1 -355
  39. package/vendor/cli/src/events.js +1 -707
  40. package/vendor/cli/src/export.js +1 -67
  41. package/vendor/cli/src/filepreview.js +1 -153
  42. package/vendor/cli/src/fingerprint.js +1 -592
  43. package/vendor/cli/src/format.js +1 -259
  44. package/vendor/cli/src/fuzzy.js +1 -119
  45. package/vendor/cli/src/history.js +1 -423
  46. package/vendor/cli/src/init.js +1 -175
  47. package/vendor/cli/src/input.js +1 -139
  48. package/vendor/cli/src/keys.js +1 -183
  49. package/vendor/cli/src/markdown.js +1 -306
  50. package/vendor/cli/src/models.js +1 -507
  51. package/vendor/cli/src/naming.js +1 -57
  52. package/vendor/cli/src/overlays.js +1 -462
  53. package/vendor/cli/src/panels.js +1 -1418
  54. package/vendor/cli/src/ping.js +1 -226
  55. package/vendor/cli/src/presence.js +1 -238
  56. package/vendor/cli/src/render.js +1 -516
  57. package/vendor/cli/src/screen.js +1 -518
  58. package/vendor/cli/src/screens.js +1 -896
  59. package/vendor/cli/src/secret.js +1 -59
  60. package/vendor/cli/src/securefs.js +1 -359
  61. package/vendor/cli/src/settings.js +1 -155
  62. package/vendor/cli/src/shared.js +1 -52
  63. package/vendor/cli/src/sharedpaths.js +1 -53
  64. package/vendor/cli/src/signup.js +1 -156
  65. package/vendor/cli/src/summarize.js +1 -95
  66. package/vendor/cli/src/sysdiag.js +1 -585
  67. package/vendor/cli/src/system.js +1 -40
  68. package/vendor/cli/src/theme.js +1 -570
  69. package/vendor/cli/src/title.js +1 -220
  70. package/vendor/cli/src/todos.js +1 -115
  71. package/vendor/cli/src/tokens.js +1 -263
  72. package/vendor/cli/src/topup.js +1 -210
  73. package/vendor/cli/src/update.js +1 -191
  74. package/vendor/cli/vendor/client/aegis.js +1 -2441
  75. package/vendor/cli/vendor/client/attest.js +1 -518
  76. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  77. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  78. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  79. package/vendor/cli/vendor/client/byok-catalog.js +1 -199
  80. package/vendor/cli/vendor/client/catalog-client.js +1 -487
  81. package/vendor/cli/vendor/client/conversation-export.js +1 -177
  82. package/vendor/cli/vendor/client/credentials.js +1 -494
  83. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  84. package/vendor/cli/vendor/client/drive-connect.js +1 -110
  85. package/vendor/cli/vendor/client/drive-upload.js +1 -234
  86. package/vendor/cli/vendor/client/env-file.js +1 -1273
  87. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  88. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  89. package/vendor/cli/vendor/client/google-signin.js +1 -133
  90. package/vendor/cli/vendor/client/hooks.js +1 -430
  91. package/vendor/cli/vendor/client/model-discovery.js +1 -373
  92. package/vendor/cli/vendor/client/naming.js +1 -283
  93. package/vendor/cli/vendor/client/platform.js +1 -937
  94. package/vendor/cli/vendor/client/prefs.js +1 -351
  95. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  96. package/vendor/cli/vendor/client/presence.js +1 -438
  97. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  98. package/vendor/cli/vendor/client/session-store.js +1 -575
  99. package/vendor/cli/vendor/client/topup.js +1 -297
  100. package/vendor/cli/vendor/client/touch.js +1 -458
  101. package/vendor/cli/vendor/client/update.js +1 -763
  102. package/vendor/cli/vendor/client/user-models.js +1 -381
  103. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  104. package/vendor/cli/vendor/desktop/lib/local/attachments.js +1 -276
  105. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  106. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -1028
  107. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -125
  108. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3666
  109. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
  110. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  111. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2145
  112. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -280
  113. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  114. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -238
  115. package/vendor/cli/vendor/desktop/lib/local/spill.js +1 -75
  116. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  117. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  118. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  119. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  120. package/vendor/cli/vendor/hosts/install.js +1 -638
  121. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  122. package/vendor/cli/vendor/hosts/spec.js +1 -164
  123. package/vendor/cli/vendor/hosts/targets.js +1 -346
  124. package/vendor/cli/vendor/mcp/server.js +1 -221
  125. package/vendor/cli/vendor/mcp/tools.js +1 -408
  126. package/vendor/cli/vendor/one/src/child.js +1 -285
  127. package/vendor/cli/vendor/one/src/permissions.js +1 -383
  128. package/vendor/desktop/bin/aegis.js +1 -32
  129. package/vendor/desktop/lib/account-key.js +1 -56
  130. package/vendor/desktop/lib/auto.js +1 -461
  131. package/vendor/desktop/lib/avatar/companion.js +1 -698
  132. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  133. package/vendor/desktop/lib/avatar/events.js +1 -344
  134. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  135. package/vendor/desktop/lib/avatar/holders.js +1 -612
  136. package/vendor/desktop/lib/avatar/identity.js +1 -641
  137. package/vendor/desktop/lib/avatar/level.js +1 -368
  138. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  139. package/vendor/desktop/lib/avatar/persona.js +1 -388
  140. package/vendor/desktop/lib/avatar/profile.js +1 -977
  141. package/vendor/desktop/lib/avatar/register.js +1 -307
  142. package/vendor/desktop/lib/avatar/store.js +1 -472
  143. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  144. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  145. package/vendor/desktop/lib/avatar/turn.js +1 -216
  146. package/vendor/desktop/lib/avatar/voice.js +1 -328
  147. package/vendor/desktop/lib/avatar/xp.js +1 -404
  148. package/vendor/desktop/lib/deep-link.js +1 -120
  149. package/vendor/desktop/lib/fingerprint.js +2 -347
  150. package/vendor/desktop/lib/google-connect.js +1 -323
  151. package/vendor/desktop/lib/local/agents.js +1 -105
  152. package/vendor/desktop/lib/local/attachments.js +1 -276
  153. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  154. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  155. package/vendor/desktop/lib/local/context.js +1 -125
  156. package/vendor/desktop/lib/local/engine.js +1 -3666
  157. package/vendor/desktop/lib/local/entitlement.js +1 -660
  158. package/vendor/desktop/lib/local/git-scope.js +1 -228
  159. package/vendor/desktop/lib/local/local.js +1 -2145
  160. package/vendor/desktop/lib/local/prompt.js +1 -280
  161. package/vendor/desktop/lib/local/queue.js +1 -560
  162. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  163. package/vendor/desktop/lib/local/spill.js +1 -75
  164. package/vendor/desktop/lib/local/telemetry.js +1 -470
  165. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  166. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  167. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  168. package/vendor/desktop/lib/quick-launcher.js +1 -84
  169. package/vendor/desktop/lib/settings.js +1 -890
  170. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  171. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  172. package/vendor/desktop/lib/sync/sessions.js +1 -106
  173. package/vendor/desktop/lib/window-state.js +1 -66
  174. package/vendor/desktop/package.json +2 -4
  175. package/vendor/desktop/preload.js +1 -679
  176. package/vendor/desktop/renderer/app.js +1 -7250
  177. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  178. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  179. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  180. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  181. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  182. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  183. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  184. package/vendor/desktop/renderer/budget.js +1 -172
  185. package/vendor/desktop/renderer/companion.js +1 -223
  186. package/vendor/desktop/renderer/diff.js +1 -359
  187. package/vendor/desktop/renderer/diffview.js +1 -336
  188. package/vendor/desktop/renderer/filepreview.js +1 -211
  189. package/vendor/desktop/renderer/fingerprint.js +3 -789
  190. package/vendor/desktop/renderer/markdown.js +1 -168
  191. package/vendor/desktop/renderer/provider-mark.js +1 -311
  192. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  193. package/vendor/desktop/renderer/providers.js +1 -259
  194. package/vendor/desktop/renderer/quick.js +1 -285
  195. package/vendor/desktop/renderer/stream-policy.js +1 -387
  196. package/vendor/desktop/renderer/transcript-view.js +1 -323
  197. package/vendor/desktop/renderer/usage.js +1 -1239
  198. package/vendor/desktop/vendor/aegis.js +1 -2441
  199. package/vendor/desktop/vendor/attest.js +1 -518
  200. package/vendor/desktop/vendor/authorship-key.js +1 -410
  201. package/vendor/desktop/vendor/auto-provision.js +1 -134
  202. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  203. package/vendor/desktop/vendor/byok-catalog.js +1 -199
  204. package/vendor/desktop/vendor/catalog-client.js +1 -487
  205. package/vendor/desktop/vendor/conversation-export.js +1 -177
  206. package/vendor/desktop/vendor/credentials.js +1 -494
  207. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  208. package/vendor/desktop/vendor/drive-connect.js +1 -110
  209. package/vendor/desktop/vendor/drive-upload.js +1 -234
  210. package/vendor/desktop/vendor/env-file.js +1 -1273
  211. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  212. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  213. package/vendor/desktop/vendor/google-signin.js +1 -133
  214. package/vendor/desktop/vendor/hooks.js +1 -430
  215. package/vendor/desktop/vendor/model-discovery.js +1 -373
  216. package/vendor/desktop/vendor/naming.js +1 -283
  217. package/vendor/desktop/vendor/platform.js +1 -937
  218. package/vendor/desktop/vendor/prefs.js +1 -351
  219. package/vendor/desktop/vendor/presence-constants.js +1 -107
  220. package/vendor/desktop/vendor/presence.js +1 -438
  221. package/vendor/desktop/vendor/record-vault.js +3 -1055
  222. package/vendor/desktop/vendor/session-store.js +1 -575
  223. package/vendor/desktop/vendor/topup.js +1 -297
  224. package/vendor/desktop/vendor/touch.js +1 -458
  225. package/vendor/desktop/vendor/update.js +1 -763
  226. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -1,518 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * The CLI's renderers — the start-up banner, transcript turns, the per-turn
10
- * accounting line, the status bar, the live working line and the transcript's
11
- * markdown body. The presentation layer is a fidelity port of
12
- * the upstream engine: gold `━`/`─` rules, the one-ink ÆGIS wordmark (box runes,
13
- * in gold), the coral-bold welcome title, the `❯` prompt, the
14
- * `⎿` hook rows, the `●` answer/stream cursor and the `✻` done glyph.
15
- *
16
- * Every function returns lines (strings carrying SGR escapes) rather than
17
- * writing to stdout, so the whole surface is assertable from a plain Node test
18
- * with no TTY and no child process — the same split the desktop uses for its
19
- * pure renderer modules. The markdown body is delegated to `./markdown.js`
20
- * (returning span lines); the require is guarded so this file always loads even
21
- * if that module is absent, falling back to the built-in `mdLines`.
22
- */
23
-
24
- const {
25
- RGB,
26
- BG,
27
- RESET,
28
- BOLD,
29
- DIM,
30
- ITALIC,
31
- UNDER,
32
- RESET_FG,
33
- RESET_BG,
34
- GLYPH,
35
- VERBS,
36
- DONE_VERBS,
37
- themeOf,
38
- } = require('./theme.js');
39
- const { WELCOME_TITLE, WELCOME_BACK, TAGLINE, STAR, stencilGlyph, welcomeArtParts } = require('./art.js');
40
- const { w, pad, padStart, wrapBlock, clip, span } = require('./screen.js');
41
- const { fmtTokens, fmtEur, fmtElapsed, fmtUsageSplit, displayTokens, feeBillable } = require('./format.js');
42
- const { renderDiffBlock } = require('./diffview.js');
43
-
44
- // Guarded: a concurrent workstream owns ./markdown.js.
45
- let markdown = null;
46
- try {
47
- // eslint-disable-next-line global-require
48
- markdown = require('./markdown.js');
49
- } catch {
50
- markdown = null;
51
- }
52
-
53
- // The failed-check `✗` and warning `⚠` marks now come from the shared glyph
54
- // table (`GLYPH.err` / `GLYPH.warn`), which downgrades them to `x` / `!` on a
55
- // terminal with no Unicode claim. They used to be two file-local constants
56
- // here, so a legacy Windows console printed U+2717 and U+26A0 into a font that
57
- // has neither — the notice rows were the last place the ASCII pass could not
58
- // reach. Read them at CALL time: `GLYPH` is mutated in place by `/terminal`, so
59
- // a value captured at require time would survive the switch.
60
- const errMark = () => GLYPH.err;
61
- const warnMark = () => GLYPH.warn;
62
-
63
- const fg = (t, c) => `${c}`;
64
- const bg = (c) => BG(...c);
65
-
66
- /** Flatten a span line back to an ANSI string (what the transcript emits). */
67
- const spansToString = (line) => line.map((sp) => (sp.s || '') + sp.t).join('') + RESET;
68
-
69
- /** Centre plain `text` inside `width`, painted with `style` (never overflows). */
70
- function centerStyled(text, width, style) {
71
- const tt = clip(text, width);
72
- const p = Math.max(0, Math.floor((width - w(tt)) / 2));
73
- return ' '.repeat(p) + style + tt + RESET;
74
- }
75
-
76
- /** The right (moon + whale) half of the mark: ▓ blue, ▒ lavender, ░ dim,
77
- * eye white, stars gold.
78
- *
79
- * The keys are the runes as `art.js` drew them, then run through the stencil:
80
- * `artRow` is handed rows that have *already* been stencilled for this
81
- * platform, so a raw-rune table silently matched nothing on win32/darwin and
82
- * the whole moon/whale half rendered uncoloured there — the mark looked
83
- * different on two of the three platforms it ships to. */
84
- function tintWhale(str, t) {
85
- const byRune = { '▓': t.blue, '▒': t.lavender, '░': t.dim, '█': t.white, [STAR]: t.gold, '·': t.dim };
86
- const map = {};
87
- for (const rune of Object.keys(byRune)) map[stencilGlyph(rune)] = byRune[rune];
88
- const spans = [];
89
- let cur = null;
90
- let style = '';
91
- for (const ch of str) {
92
- const s = map[ch] != null ? map[ch] : '';
93
- if (cur !== null && s === style) {
94
- cur += ch;
95
- } else {
96
- if (cur !== null) spans.push(span(style, cur));
97
- cur = ch;
98
- style = s;
99
- }
100
- }
101
- if (cur !== null) spans.push(span(style, cur));
102
- return spans;
103
- }
104
-
105
- /** One centred welcome-art row: the gold wordmark on the left, and (when a
106
- * two-tone mark returns) the tinted right half. */
107
- function artRow(ctx, row, parts, leftPad) {
108
- const t = themeOf(ctx);
109
- const left = row[0] || '';
110
- const right = row[1] || '';
111
- const spans = [span('', ' '.repeat(leftPad))];
112
- if (left && right) {
113
- spans.push(span(t.gold, left));
114
- spans.push(span('', ' '.repeat(parts.gutter)));
115
- spans.push(...tintWhale(right, t));
116
- } else if (left) {
117
- spans.push(span(t.gold, left));
118
- if (w(left) < parts.width) spans.push(span('', ' '.repeat(parts.width - w(left))));
119
- } else if (right) {
120
- spans.push(...tintWhale(right, t));
121
- if (w(right) < parts.width) spans.push(span('', ' '.repeat(parts.width - w(right))));
122
- } else {
123
- spans.push(span('', ' '.repeat(parts.width)));
124
- }
125
- return spansToString(spans);
126
- }
127
-
128
- /**
129
- * The start-up banner: a gold `━`+`─` rule across the full terminal, the
130
- * centred welcome mark (the ÆGIS wordmark, in gold — the same mark and the same
131
- * ink the desktop app draws), the coral-bold welcome title and a version line,
132
- * then the compact identity block.
133
- */
134
- function renderBanner(ctx, info = {}) {
135
- const t = themeOf(ctx);
136
- const width = Math.max(20, Number(info.width) || 80);
137
- const lines = [];
138
-
139
- // Full-width gold header rule — the heavy/light pair from the shared glyph
140
- // table, so the frame is `━───━` on a Unicode terminal and `=---=` on a
141
- // legacy console instead of printing two box-drawing runes it cannot draw.
142
- lines.push(
143
- `${t.gold}${GLYPH.ruleHeavy}${GLYPH.rule.repeat(Math.max(0, width - 2))}${GLYPH.ruleHeavy}${RESET}`
144
- );
145
- lines.push('');
146
-
147
- const parts = welcomeArtParts();
148
- if (width >= parts.width + 2) {
149
- const leftPad = Math.max(0, Math.floor((width - parts.width) / 2));
150
- for (const row of parts.rows) lines.push(artRow(ctx, row, parts, leftPad));
151
- } else {
152
- // Too narrow for the mark: a compact gold wordmark keeps every row in width.
153
- lines.push(centerStyled('AEGIS CODE', width, t.gold + BOLD));
154
- }
155
- lines.push('');
156
-
157
- const title = info.firstRun === false ? WELCOME_BACK : WELCOME_TITLE;
158
- lines.push(centerStyled(title, width, t.coral + BOLD));
159
- const verLine = [info.version ? `v${info.version}` : null, TAGLINE].filter(Boolean).join(` ${GLYPH.bullet} `);
160
- lines.push(centerStyled(verLine, width, t.gray));
161
- lines.push('');
162
-
163
- lines.push(...renderIdentityBox(ctx, info, width));
164
- return lines;
165
- }
166
-
167
- /** The identity panel: what you are talking to, and as what. Routed through
168
- * renderHeading so it shares the CLI's ruled-section look (no rounded frame). */
169
- function renderIdentityBox(ctx, info = {}, width = 80) {
170
- const t = themeOf(ctx);
171
- const lines = [renderHeading(ctx, 'aegiscode', width)];
172
-
173
- const rows = [
174
- ['version', info.version ? `v${info.version}` : null],
175
- ['model', info.model || 'server default'],
176
- ['base', info.base || ''],
177
- ['key', info.key || 'not set'],
178
- ['render', info.stream === false ? 'buffered' : 'streaming'],
179
- ].filter(([, v]) => v);
180
-
181
- for (const [k, v] of rows) {
182
- const value = clip(String(v), Math.max(0, width - 12));
183
- lines.push(` ${t.gray}${k.padEnd(8)}${RESET}${t.white}${value}${RESET}`);
184
- }
185
- const hint = clip(` type /help for commands ${GLYPH.bullet} /quit to exit`, width);
186
- lines.push('');
187
- lines.push(`${t.dim}${hint}${RESET}`);
188
- return lines;
189
- }
190
-
191
- /** Markdown-lite body (fallback when ./markdown.js is unavailable): fenced
192
- * code, bullets, headings, inline code/bold. */
193
- function mdLines(text, width, ctx) {
194
- const t = themeOf(ctx);
195
- const out = [];
196
- let inFence = false;
197
- const bodyW = Math.max(20, width - 4);
198
-
199
- for (const raw of String(text == null ? '' : text).split('\n')) {
200
- const fence = /^\s*```/.test(raw);
201
- if (fence) {
202
- inFence = !inFence;
203
- continue;
204
- }
205
- if (inFence) {
206
- for (const l of wrapBlock(raw, bodyW)) out.push(`${t.gray} ${l}${RESET}`);
207
- continue;
208
- }
209
- if (raw.trim() === '') {
210
- out.push('');
211
- continue;
212
- }
213
- const bullet = /^(\s*)[-*]\s+(.*)$/.exec(raw);
214
- if (bullet) {
215
- const indent = ' '.repeat(Math.min(6, bullet[1].length));
216
- for (const l of wrapBlock(inline(bullet[2], ctx), bodyW - 2)) {
217
- out.push(`${indent}${t.gray}${GLYPH.bullet}${RESET} ${l}`);
218
- }
219
- continue;
220
- }
221
- const heading = /^(#{1,6})\s+(.*)$/.exec(raw);
222
- if (heading) {
223
- out.push(`${t.gold}${BOLD}${inline(heading[2], ctx)}${RESET}`);
224
- continue;
225
- }
226
- for (const l of wrapBlock(inline(raw, ctx), bodyW, '')) out.push(l);
227
- }
228
- return out;
229
- }
230
-
231
- /** Inline span treatment: `code` in green, **bold** in bold. */
232
- function inline(text, ctx) {
233
- const t = themeOf(ctx);
234
- return String(text == null ? '' : text)
235
- .replace(/`([^`]+)`/g, (_, code) => `${t.green}${code}${RESET}`)
236
- .replace(/\*\*([^*]+)\*\*/g, (_, bold) => `${BOLD}${bold}${RESET}`);
237
- }
238
-
239
- /** Assistant body: ./markdown.js span lines flattened to ANSI strings, else the
240
- * plain mdLines fallback. */
241
- function assistantLines(ctx, text, width) {
242
- if (markdown && typeof markdown.renderMarkdown === 'function') {
243
- return markdown.renderMarkdown(String(text == null ? '' : text), width, ctx).map(spansToString);
244
- }
245
- return mdLines(text, width, ctx);
246
- }
247
-
248
- /**
249
- * One transcript turn: a `❯`-prefixed user line, an assistant answer whose
250
- * first line carries the `●` marker (and, on a multi-line streaming answer, a
251
- * `●` cursor on its last line), a tool line with its `⎿ $ …` hook row, and
252
- * each turn's accounting line beneath.
253
- */
254
- function renderTurn(ctx, turn, width = 80) {
255
- const t = themeOf(ctx);
256
- const role = turn.role || 'assistant';
257
- const text = String(turn.text == null ? '' : turn.text);
258
- const lines = [];
259
-
260
- if (role === 'user') {
261
- const body = wrapBlock(text, Math.max(8, width - 2));
262
- body.forEach((l, i) => {
263
- if (i === 0) lines.push(`${t.gray}${GLYPH.cursor}${RESET} ${t.white}${l}${RESET}`);
264
- else lines.push(` ${t.white}${l}${RESET}`);
265
- });
266
- } else if (role === 'assistant' || role === 'system') {
267
- const body = assistantLines(ctx, text, Math.max(8, width - 2));
268
- if (!body.length) body.push('');
269
- body[0] = `${t.white}${GLYPH.block}${RESET} ` + body[0];
270
- // No trailing cursor, deliberately — the twin of the rule in chatflow.js's
271
- // `rowLines`. Appending one to the last line only when the message ran past
272
- // one row made the glyph count depend on the text's WRAP (`● Working` at one
273
- // line, `● Working●` at two), so the extra dot appeared on exactly the long
274
- // answers a reader is likeliest to look at. The head marker is the answer's
275
- // gutter, not half of a bracket, and it is the same glyph the finished row
276
- // keeps — the live turn is the working line's job to advertise.
277
- lines.push(...body);
278
- } else if (role === 'tool') {
279
- // turn.ok is only known once the call has actually run (the agent loop's
280
- // tool-activity event fires after execution); undefined means "no result
281
- // yet to report" (the plain registry-tool path, which never set it).
282
- const status = turn.ok === undefined ? '' : turn.ok ? ` ${t.green}${GLYPH.check}${RESET}` : ` ${t.red}${errMark()}${RESET}`;
283
- // A tool row is a running command, not a bullet in a list — it carries no
284
- // leading `●` mark. Only the assistant's answer keeps that marker (see the
285
- // role branch above), so the two row kinds no longer look interchangeable.
286
- lines.push(`${t.gray}${turn.label || 'tool'}${RESET}${status}`);
287
- const args =
288
- turn.args == null
289
- ? ''
290
- : typeof turn.args === 'string'
291
- ? turn.args
292
- : JSON.stringify(turn.args);
293
-
294
- // An editFile/writeFile turn carries a diff preview (app.js builds it from
295
- // the tool call's `run` frame). Paint the colored block instead of the gray
296
- // `$ {args}` row, so an edit shows *what* changed, not just that something
297
- // did. The summary row is unconditional; the body follows when the block is
298
- // open, which the click handler toggles. The `$ args` row stays the fallback
299
- // for every non-edit tool and for a turn with no preview.
300
- if (turn.diff) {
301
- lines.push(...renderDiffBlock(turn.diff, ctx, width, { open: !!turn.diffOpen }));
302
- } else if (args) {
303
- lines.push(` ${t.gray}${GLYPH.hook} $ ${clip(args, Math.max(0, width - 6))}${RESET}`);
304
- }
305
- } else if (role === 'error') {
306
- lines.push(`${t.red}${errMark()} ${text}${RESET}`);
307
- } else {
308
- for (const l of wrapBlock(text, Math.max(8, width - 2))) lines.push(`${t.white}${l}${RESET}`);
309
- }
310
-
311
- if (turn.meta) {
312
- const m = renderMeta(ctx, turn.meta, width);
313
- if (m) lines.push(m);
314
- }
315
- return lines;
316
- }
317
-
318
- /**
319
- * The per-turn accounting line — what the turn produced beside what it cost, in
320
- * the `⎿` hook row style, e.g. `⎿ 312 out · €0.0007 · 4.2s`. The figure is
321
- * labelled and is the OUTPUT half alone (see `fmtUsageSplit`).
322
- */
323
- function renderMeta(ctx, meta = {}, width = 80) {
324
- const t = themeOf(ctx);
325
- const bits = [];
326
- if (meta.model) bits.push(`${t.blue}${meta.model}${RESET}`);
327
- // The producer (chatflow.js's accounting row) pushes the pair flat, as
328
- // `input`/`output` — reading it as `meta.usage.input` here meant the pair was
329
- // never printed on this path even though the docstring above promises it.
330
- // Both shapes are accepted: `usage` is what the desktop's renderer hands over.
331
- const split = meta.usage && typeof meta.usage === 'object' ? meta.usage : meta;
332
- // The row's token figure is what the turn PRODUCED, and it is the only one it
333
- // prints: labelled `tokens`, in this theme's strongest token — the figure the row
334
- // exists to report. The input half is gone deliberately, not by omission. It
335
- // is the prompt restated, on a cached turn it is the larger number by an order
336
- // of magnitude, and it is the one figure in the row nobody can act on: you
337
- // change what a turn costs by changing what it PRODUCES. Leading with it made
338
- // the row read as a runaway (`156,189 tok · 151,175 in · 5,014 tokens`) while
339
- // saying nothing about the answer. Its one remaining reader is `/cost`, which
340
- // carries the full miss/hit breakdown — a panel you open, not a line painted
341
- // under every answer.
342
- //
343
- // This is the twin of chatflow.js's accounting row (see `metaBits`): the two
344
- // render the same row through different plumbing, so they state the same
345
- // figure. The total does NOT stand in when no output figure arrived: `tokens`
346
- // is input + output, so the fallback that used to sit here printed a turn's
347
- // prompt back at it under an unlabelled figure — the exact reading this row
348
- // exists to remove, and the one the desktop already refuses in
349
- // `displayTokens` (desktop/renderer/usage.js). An unmeasurable output leaves
350
- // the figure off rather than stating a total, and `0 tokens` is refused for the
351
- // reason `fmtRoll` refuses `0 tokens`: it states a figure the provider never
352
- // reported.
353
- const parts = fmtUsageSplit(split);
354
- if (parts) bits.push(`${t.white}${parts.output}${RESET}`);
355
- else {
356
- const produced = displayTokens(split);
357
- if (produced != null) bits.push(`${t.white}${fmtTokens(produced)} tokens${RESET}`);
358
- }
359
- // No money on a tier AEGIS bills no fee to, and none from a snapshot that has
360
- // not proven a fee is owed — the desktop's rule, and now this host's too
361
- // (`feeBillable`). The token figure above stays either way: what the turn
362
- // produced is not a price, and hiding it would leave an Unlimited account with
363
- // no meter at all.
364
- if (meta.eur != null && feeBillable()) bits.push(`${meta.eur > 0 ? t.coral : t.green}${fmtEur(meta.eur)}${RESET}`);
365
- if (meta.ms != null) bits.push(`${t.gray}${fmtElapsed(meta.ms)}${RESET}`);
366
- if (meta.calls > 1) bits.push(`${t.gray}${meta.calls} calls${RESET}`);
367
- if (!bits.length) return '';
368
- const sep = `${t.dim} ${GLYPH.bullet} ${RESET}`;
369
- return `${t.dim}${GLYPH.hook} ${RESET}${bits.join(sep)}`;
370
- }
371
-
372
- /**
373
- * The bottom bar: segments packed left, the hint right-aligned, always exactly
374
- * `width` cells (clipped, never wrapped, so a narrow terminal degrades instead
375
- * of corrupting the transcript). No background — the CLI stays pipeable.
376
- */
377
- function renderStatus(ctx, state = {}, width = 80) {
378
- const t = themeOf(ctx);
379
- const left = ['aegis'];
380
- if (state.model) left.push(state.model);
381
- if (state.tokens != null) left.push(`${fmtTokens(state.tokens)} tokens`);
382
- if (state.spend != null) left.push(fmtEur(state.spend));
383
- if (state.mode) left.push(state.mode);
384
-
385
- const right = state.hint || 'ctrl+c quit';
386
- const body = ` ${left.join(` ${GLYPH.bullet} `)} `;
387
- const gap = width - w(body) - w(right) - 1;
388
- const content = gap > 0 ? body + ' '.repeat(gap) + right + ' ' : clip(body, width);
389
- return `${t.gray}${pad(content, width)}${RESET}`;
390
- }
391
-
392
- /**
393
- * The working line (drawn in the live region, then replaced by the turn):
394
- * the `✻`-family spinner cycling with a VERBS entry. With `state.done`, the
395
- * completion line `✻ <DoneVerb> for Ns` in gray (Churned after a chat turn,
396
- * Worked after a turn that used tools).
397
- */
398
- function renderWorking(ctx, state = {}) {
399
- const t = themeOf(ctx);
400
- if (state.done) {
401
- const verb = state.verb || DONE_VERBS[state.tools ? 1 : 0] || DONE_VERBS[0];
402
- const secs =
403
- state.secs != null ? state.secs : Math.max(1, Math.round((state.elapsedMs || 0) / 1000));
404
- return `${t.gray}${GLYPH.bloom} ${verb} for ${secs}s${RESET}`;
405
- }
406
- const frame = GLYPH.spin[Math.abs(Math.floor(state.tick || 0)) % GLYPH.spin.length];
407
- const verb = state.verb || VERBS[0];
408
- const tail = [];
409
- if (state.elapsedMs != null) tail.push(fmtElapsed(state.elapsedMs));
410
- // `streamedFloor` marks a figure that has folded in Anthropic's own
411
- // `thinking_delta.estimated_tokens` (desktop/lib/local/claude-pro.js) — a
412
- // running count that measurement showed landing under the real billed
413
- // thinking-token total (1900 vs 1943, 1800 vs 1832, 250 vs 339). Flagged
414
- // with `≥` rather than shown as an exact figure, because the true number
415
- // only arrives with the turn's final `usage`.
416
- if (state.streamed != null) {
417
- tail.push(`↓${state.streamedFloor ? '≥' : ''}${fmtTokens(state.streamed)} tokens`);
418
- }
419
- const tailStr = tail.length ? ` ${t.gray}(${tail.join(` ${GLYPH.bullet} `)})${RESET}` : '';
420
- return (
421
- `${t.coral}${frame}${RESET} ${t.white}${verb}${RESET}${t.white}…${RESET}${tailStr}` +
422
- `${t.dim} esc to interrupt${RESET}`
423
- );
424
- }
425
-
426
- /** A ruled section header used by command output (`/help`, `/cost`). */
427
- function renderHeading(ctx, text, width = 80) {
428
- const t = themeOf(ctx);
429
- const label = ` ${text} `;
430
- const fill = Math.max(0, width - w(label));
431
- const left = Math.floor(fill / 2);
432
- const rule = GLYPH.rule;
433
- return (
434
- `${t.gray}${rule.repeat(left)}${RESET}${t.gold}${BOLD}${label}${RESET}` +
435
- `${t.gray}${rule.repeat(Math.max(0, fill - left))}${RESET}`
436
- );
437
- }
438
-
439
- /** Render a tool result body: heading + indented lines, no role gutter. */
440
- function renderToolResult(ctx, name, text, width = 80) {
441
- const t = themeOf(ctx);
442
- const lines = [renderHeading(ctx, name, width)];
443
- for (const l of wrapBlock(String(text == null ? '' : text), Math.max(8, width - 2))) {
444
- lines.push(l ? ` ${t.white}${l}${RESET}` : '');
445
- }
446
- return lines;
447
- }
448
-
449
- /**
450
- * The tool-approval card: the mutating call the model wants to run (a diff
451
- * for writeFile/editFile, the command for exec) and the three answers. One
452
- * inline question, matching the upstream engine's Bash/edit approval dialog.
453
- */
454
- function renderApproval(ctx, info = {}, width = 80) {
455
- const t = themeOf(ctx);
456
- const lines = [renderHeading(ctx, `confirm ${info.tool || 'tool'}`, width)];
457
- const body = info.diff
458
- ? info.diff
459
- : info.args == null
460
- ? ''
461
- : typeof info.args === 'string'
462
- ? info.args
463
- : JSON.stringify(info.args);
464
- for (const l of wrapBlock(body, Math.max(8, width - 2))) {
465
- lines.push(l ? ` ${t.gray}${l}${RESET}` : '');
466
- }
467
- lines.push('');
468
- lines.push(
469
- ` ${t.coral}${GLYPH.bullet}${RESET} ${t.white}y${RESET}es once` +
470
- ` ${t.dim}${GLYPH.bullet}${RESET} ${t.white}s${RESET}ession` +
471
- ` ${t.dim}${GLYPH.bullet}${RESET} ${t.white}n${RESET}o ${t.dim}(default)${RESET}`
472
- );
473
- return lines;
474
- }
475
-
476
- /** A transient notice. Kinds map gray / coral / red / green with the matching
477
- * glyph: info `·`, warn `⚠`, error `✗`, ok `✔` — all four read from the shared
478
- * table at call time, so `--ascii` swaps them along with the rest of the UI. */
479
- const NOTICE = {
480
- info: ['gray', () => GLYPH.bullet],
481
- warn: ['coral', warnMark],
482
- error: ['red', errMark],
483
- ok: ['green', () => GLYPH.check],
484
- };
485
-
486
- function renderNotice(ctx, kind, text) {
487
- const t = themeOf(ctx);
488
- const [token, mark] = NOTICE[kind] || NOTICE.info;
489
- return `${t[token]}${mark()} ${text}${RESET}`;
490
- }
491
-
492
- module.exports = {
493
- renderBanner,
494
- renderIdentityBox,
495
- renderTurn,
496
- renderMeta,
497
- renderStatus,
498
- renderWorking,
499
- renderHeading,
500
- renderToolResult,
501
- renderApproval,
502
- renderNotice,
503
- mdLines,
504
- inline,
505
- // Welcome-mark pieces, shared with the onboarding screens so there is exactly
506
- // one renderer for the mascot/moon/whale mark rather than two that can drift.
507
- artRow,
508
- tintWhale,
509
- // Style helpers kept for legacy consumers.
510
- fg,
511
- bg,
512
- UNDER,
513
- ITALIC,
514
- RESET_FG,
515
- RESET_BG,
516
- pad,
517
- padStart,
518
- };
3
+ "use strict";const{RGB:RGB,BG:BG,RESET:RESET,BOLD:BOLD,DIM:DIM,ITALIC:ITALIC,UNDER:UNDER,RESET_FG:RESET_FG,RESET_BG:RESET_BG,GLYPH:GLYPH,VERBS:VERBS,DONE_VERBS:DONE_VERBS,themeOf:themeOf}=require("./theme.js"),{WELCOME_TITLE:WELCOME_TITLE,WELCOME_BACK:WELCOME_BACK,TAGLINE:TAGLINE,STAR:STAR,stencilGlyph:stencilGlyph,welcomeArtParts:welcomeArtParts}=require("./art.js"),{w:w,pad:pad,padStart:padStart,wrapBlock:wrapBlock,clip:clip,span:span}=require("./screen.js"),{fmtTokens:fmtTokens,fmtEur:fmtEur,fmtElapsed:fmtElapsed,fmtUsageSplit:fmtUsageSplit,displayTokens:displayTokens,feeBillable:feeBillable}=require("./format.js"),{renderDiffBlock:renderDiffBlock}=require("./diffview.js");let markdown=null;try{markdown=require("./markdown.js")}catch{markdown=null}const errMark=()=>GLYPH.err,warnMark=()=>GLYPH.warn,fg=(e,t)=>`${t}`,bg=e=>BG(...e),spansToString=e=>e.map((e=>(e.s||"")+e.t)).join("")+RESET;function centerStyled(e,t,r){const n=clip(e,t),s=Math.max(0,Math.floor((t-w(n))/2));return" ".repeat(s)+r+n+RESET}function tintWhale(e,t){const r={"▓":t.blue,"▒":t.lavender,"░":t.dim,"█":t.white,[STAR]:t.gold,"·":t.dim},n={};for(const e of Object.keys(r))n[stencilGlyph(e)]=r[e];const s=[];let o=null,a="";for(const t of e){const e=null!=n[t]?n[t]:"";null!==o&&e===a?o+=t:(null!==o&&s.push(span(a,o)),o=t,a=e)}return null!==o&&s.push(span(a,o)),s}function artRow(e,t,r,n){const s=themeOf(e),o=t[0]||"",a=t[1]||"",l=[span(""," ".repeat(n))];return o&&a?(l.push(span(s.gold,o)),l.push(span(""," ".repeat(r.gutter))),l.push(...tintWhale(a,s))):o?(l.push(span(s.gold,o)),w(o)<r.width&&l.push(span(""," ".repeat(r.width-w(o))))):a?(l.push(...tintWhale(a,s)),w(a)<r.width&&l.push(span(""," ".repeat(r.width-w(a))))):l.push(span(""," ".repeat(r.width))),spansToString(l)}function renderBanner(e,t={}){const r=themeOf(e),n=Math.max(20,Number(t.width)||80),s=[];s.push(`${r.gold}${GLYPH.ruleHeavy}${GLYPH.rule.repeat(Math.max(0,n-2))}${GLYPH.ruleHeavy}${RESET}`),s.push("");const o=welcomeArtParts();if(n>=o.width+2){const t=Math.max(0,Math.floor((n-o.width)/2));for(const r of o.rows)s.push(artRow(e,r,o,t))}else s.push(centerStyled("AEGIS CODE",n,r.gold+BOLD));s.push("");const a=!1===t.firstRun?WELCOME_BACK:WELCOME_TITLE;s.push(centerStyled(a,n,r.coral+BOLD));const l=[t.version?`v${t.version}`:null,TAGLINE].filter(Boolean).join(` ${GLYPH.bullet} `);return s.push(centerStyled(l,n,r.gray)),s.push(""),s.push(...renderIdentityBox(e,t,n)),s}function renderIdentityBox(e,t={},r=80){const n=themeOf(e),s=[renderHeading(e,"aegiscode",r)],o=[["version",t.version?`v${t.version}`:null],["model",t.model||"server default"],["base",t.base||""],["key",t.key||"not set"],["render",!1===t.stream?"buffered":"streaming"]].filter((([,e])=>e));for(const[e,t]of o){const o=clip(String(t),Math.max(0,r-12));s.push(` ${n.gray}${e.padEnd(8)}${RESET}${n.white}${o}${RESET}`)}const a=clip(` type /help for commands ${GLYPH.bullet} /quit to exit`,r);return s.push(""),s.push(`${n.dim}${a}${RESET}`),s}function mdLines(e,t,r){const n=themeOf(r),s=[];let o=!1;const a=Math.max(20,t-4);for(const t of String(null==e?"":e).split("\n")){if(/^\s*```/.test(t)){o=!o;continue}if(o){for(const e of wrapBlock(t,a))s.push(`${n.gray} ${e}${RESET}`);continue}if(""===t.trim()){s.push("");continue}const e=/^(\s*)[-*]\s+(.*)$/.exec(t);if(e){const t=" ".repeat(Math.min(6,e[1].length));for(const o of wrapBlock(inline(e[2],r),a-2))s.push(`${t}${n.gray}${GLYPH.bullet}${RESET} ${o}`);continue}const l=/^(#{1,6})\s+(.*)$/.exec(t);if(l)s.push(`${n.gold}${BOLD}${inline(l[2],r)}${RESET}`);else for(const e of wrapBlock(inline(t,r),a,""))s.push(e)}return s}function inline(e,t){const r=themeOf(t);return String(null==e?"":e).replace(/`([^`]+)`/g,((e,t)=>`${r.green}${t}${RESET}`)).replace(/\*\*([^*]+)\*\*/g,((e,t)=>`${BOLD}${t}${RESET}`))}function assistantLines(e,t,r){return markdown&&"function"==typeof markdown.renderMarkdown?markdown.renderMarkdown(String(null==t?"":t),r,e).map(spansToString):mdLines(t,r,e)}function renderTurn(e,t,r=80){const n=themeOf(e),s=t.role||"assistant",o=String(null==t.text?"":t.text),a=[];if("user"===s)wrapBlock(o,Math.max(8,r-2)).forEach(((e,t)=>{0===t?a.push(`${n.gray}${GLYPH.cursor}${RESET} ${n.white}${e}${RESET}`):a.push(` ${n.white}${e}${RESET}`)}));else if("assistant"===s||"system"===s){const t=assistantLines(e,o,Math.max(8,r-2));t.length||t.push(""),t[0]=`${n.white}${GLYPH.block}${RESET} `+t[0],a.push(...t)}else if("tool"===s){const s=void 0===t.ok?"":t.ok?` ${n.green}${GLYPH.check}${RESET}`:` ${n.red}${errMark()}${RESET}`;a.push(`${n.gray}${t.label||"tool"}${RESET}${s}`);const o=null==t.args?"":"string"==typeof t.args?t.args:JSON.stringify(t.args);t.diff?a.push(...renderDiffBlock(t.diff,e,r,{open:!!t.diffOpen})):o&&a.push(` ${n.gray}${GLYPH.hook} $ ${clip(o,Math.max(0,r-6))}${RESET}`)}else if("error"===s)a.push(`${n.red}${errMark()} ${o}${RESET}`);else for(const e of wrapBlock(o,Math.max(8,r-2)))a.push(`${n.white}${e}${RESET}`);if(t.meta){const n=renderMeta(e,t.meta,r);n&&a.push(n)}return a}function renderMeta(e,t={},r=80){const n=themeOf(e),s=[];t.model&&s.push(`${n.blue}${t.model}${RESET}`);const o=t.usage&&"object"==typeof t.usage?t.usage:t,a=fmtUsageSplit(o);if(a)s.push(`${n.white}${a.output}${RESET}`);else{const e=displayTokens(o);null!=e&&s.push(`${n.white}${fmtTokens(e)} tokens${RESET}`)}if(null!=t.eur&&feeBillable()&&s.push(`${t.eur>0?n.coral:n.green}${fmtEur(t.eur)}${RESET}`),null!=t.ms&&s.push(`${n.gray}${fmtElapsed(t.ms)}${RESET}`),t.calls>1&&s.push(`${n.gray}${t.calls} calls${RESET}`),!s.length)return"";const l=`${n.dim} ${GLYPH.bullet} ${RESET}`;return`${n.dim}${GLYPH.hook} ${RESET}${s.join(l)}`}function renderStatus(e,t={},r=80){const n=themeOf(e),s=["aegis"];t.model&&s.push(t.model),null!=t.tokens&&s.push(`${fmtTokens(t.tokens)} tokens`),null!=t.spend&&s.push(fmtEur(t.spend)),t.mode&&s.push(t.mode);const o=t.hint||"ctrl+c quit",a=` ${s.join(` ${GLYPH.bullet} `)} `,l=r-w(a)-w(o)-1,i=l>0?a+" ".repeat(l)+o+" ":clip(a,r);return`${n.gray}${pad(i,r)}${RESET}`}function renderWorking(e,t={}){const r=themeOf(e);if(t.done){const e=t.verb||DONE_VERBS[t.tools?1:0]||DONE_VERBS[0],n=null!=t.secs?t.secs:Math.max(1,Math.round((t.elapsedMs||0)/1e3));return`${r.gray}${GLYPH.bloom} ${e} for ${n}s${RESET}`}const n=GLYPH.spin[Math.abs(Math.floor(t.tick||0))%GLYPH.spin.length],s=t.verb||VERBS[0],o=[];null!=t.elapsedMs&&o.push(fmtElapsed(t.elapsedMs)),null!=t.streamed&&o.push(`↓${t.streamedFloor?"≥":""}${fmtTokens(t.streamed)} tokens`);const a=o.length?` ${r.gray}(${o.join(` ${GLYPH.bullet} `)})${RESET}`:"";return`${r.coral}${n}${RESET} ${r.white}${s}${RESET}${r.white}…${RESET}${a}${r.dim} esc to interrupt${RESET}`}function renderHeading(e,t,r=80){const n=themeOf(e),s=` ${t} `,o=Math.max(0,r-w(s)),a=Math.floor(o/2),l=GLYPH.rule;return`${n.gray}${l.repeat(a)}${RESET}${n.gold}${BOLD}${s}${RESET}${n.gray}${l.repeat(Math.max(0,o-a))}${RESET}`}function renderToolResult(e,t,r,n=80){const s=themeOf(e),o=[renderHeading(e,t,n)];for(const e of wrapBlock(String(null==r?"":r),Math.max(8,n-2)))o.push(e?` ${s.white}${e}${RESET}`:"");return o}function renderApproval(e,t={},r=80){const n=themeOf(e),s=[renderHeading(e,`confirm ${t.tool||"tool"}`,r)],o=t.diff?t.diff:null==t.args?"":"string"==typeof t.args?t.args:JSON.stringify(t.args);for(const e of wrapBlock(o,Math.max(8,r-2)))s.push(e?` ${n.gray}${e}${RESET}`:"");return s.push(""),s.push(` ${n.coral}${GLYPH.bullet}${RESET} ${n.white}y${RESET}es once ${n.dim}${GLYPH.bullet}${RESET} ${n.white}s${RESET}ession ${n.dim}${GLYPH.bullet}${RESET} ${n.white}n${RESET}o ${n.dim}(default)${RESET}`),s}const NOTICE={info:["gray",()=>GLYPH.bullet],warn:["coral",warnMark],error:["red",errMark],ok:["green",()=>GLYPH.check]};function renderNotice(e,t,r){const n=themeOf(e),[s,o]=NOTICE[t]||NOTICE.info;return`${n[s]}${o()} ${r}${RESET}`}module.exports={renderBanner:renderBanner,renderIdentityBox:renderIdentityBox,renderTurn:renderTurn,renderMeta:renderMeta,renderStatus:renderStatus,renderWorking:renderWorking,renderHeading:renderHeading,renderToolResult:renderToolResult,renderApproval:renderApproval,renderNotice:renderNotice,mdLines:mdLines,inline:inline,artRow:artRow,tintWhale:tintWhale,fg:fg,bg:bg,UNDER:UNDER,ITALIC:ITALIC,RESET_FG:RESET_FG,RESET_BG:RESET_BG,pad:pad,padStart:padStart};