@bastani/atomic 0.9.89-alpha.1 → 0.9.89-alpha.2

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 (152) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +8 -0
  3. package/dist/builtin/intercom/broker/broker-instance.ts +15 -1
  4. package/dist/builtin/intercom/broker/broker.ts +25 -8
  5. package/dist/builtin/intercom/broker/client.ts +29 -14
  6. package/dist/builtin/intercom/broker/multinode-router.ts +193 -52
  7. package/dist/builtin/intercom/broker/multinode-state-store.ts +6 -2
  8. package/dist/builtin/intercom/broker/restoring-recipients.ts +5 -0
  9. package/dist/builtin/intercom/broker/sql-outbox-store.ts +3 -2
  10. package/dist/builtin/intercom/index.bundle.mjs +19 -12
  11. package/dist/builtin/intercom/package.json +1 -1
  12. package/dist/builtin/intercom/types.ts +6 -2
  13. package/dist/builtin/mcp/package.json +1 -1
  14. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  15. package/dist/builtin/subagents/package.json +1 -1
  16. package/dist/builtin/subagents/src/extension/index.bundle.mjs +17 -6
  17. package/dist/builtin/web-access/package.json +1 -1
  18. package/dist/builtin/workflows/CHANGELOG.md +12 -0
  19. package/dist/builtin/workflows/package.json +1 -1
  20. package/dist/builtin/workflows/src/extension/index.bundle.mjs +310 -344
  21. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +99 -17
  22. package/dist/builtin/workflows/src/index.js +99 -17
  23. package/dist/builtin/workflows/src/local-worker-entry.mjs +99 -17
  24. package/dist/cli/storage-command.js +8 -0
  25. package/dist/cli/storage-command.js.map +1 -1
  26. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  27. package/dist/core/auth-storage-backends.js +1 -0
  28. package/dist/core/auth-storage-backends.js.map +1 -1
  29. package/dist/core/keybindings.d.ts +8 -0
  30. package/dist/core/keybindings.d.ts.map +1 -1
  31. package/dist/core/keybindings.js +4 -0
  32. package/dist/core/keybindings.js.map +1 -1
  33. package/dist/core/process-start-token.d.ts.map +1 -1
  34. package/dist/core/process-start-token.js +8 -1
  35. package/dist/core/process-start-token.js.map +1 -1
  36. package/dist/core/resume/blueprint/build-lock.d.ts.map +1 -1
  37. package/dist/core/resume/blueprint/build-lock.js +2 -1
  38. package/dist/core/resume/blueprint/build-lock.js.map +1 -1
  39. package/dist/core/storage/errors.d.ts +4 -2
  40. package/dist/core/storage/errors.d.ts.map +1 -1
  41. package/dist/core/storage/errors.js +6 -1
  42. package/dist/core/storage/errors.js.map +1 -1
  43. package/dist/core/tasks/completion.d.ts +5 -0
  44. package/dist/core/tasks/completion.d.ts.map +1 -1
  45. package/dist/core/tasks/completion.js +13 -0
  46. package/dist/core/tasks/completion.js.map +1 -1
  47. package/dist/core/tools/shell-task-render.d.ts +1 -2
  48. package/dist/core/tools/shell-task-render.d.ts.map +1 -1
  49. package/dist/core/tools/shell-task-render.js +3 -7
  50. package/dist/core/tools/shell-task-render.js.map +1 -1
  51. package/dist/core/tools/windows-directory-security.d.ts.map +1 -1
  52. package/dist/core/tools/windows-directory-security.js +3 -11
  53. package/dist/core/tools/windows-directory-security.js.map +1 -1
  54. package/dist/core/worktree-snapshot/capture.d.ts.map +1 -1
  55. package/dist/core/worktree-snapshot/capture.js +25 -1
  56. package/dist/core/worktree-snapshot/capture.js.map +1 -1
  57. package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
  58. package/dist/core/worktree-snapshot/restore.js +38 -9
  59. package/dist/core/worktree-snapshot/restore.js.map +1 -1
  60. package/dist/index.d.ts +2 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +2 -1
  63. package/dist/index.js.map +1 -1
  64. package/dist/modes/interactive/components/agent-panel.d.ts +5 -0
  65. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  66. package/dist/modes/interactive/components/agent-panel.js +13 -0
  67. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  68. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  69. package/dist/modes/interactive/components/chat-transcript.js +5 -2
  70. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  71. package/dist/modes/interactive/components/custom-message.js +1 -1
  72. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  73. package/dist/modes/interactive/components/heartbeat-block.d.ts +34 -0
  74. package/dist/modes/interactive/components/heartbeat-block.d.ts.map +1 -0
  75. package/dist/modes/interactive/components/heartbeat-block.js +50 -0
  76. package/dist/modes/interactive/components/heartbeat-block.js.map +1 -0
  77. package/dist/modes/interactive/components/input-label.d.ts.map +1 -1
  78. package/dist/modes/interactive/components/input-label.js +8 -3
  79. package/dist/modes/interactive/components/input-label.js.map +1 -1
  80. package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
  81. package/dist/modes/interactive/components/main-composer-keys.js +3 -7
  82. package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
  83. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  84. package/dist/modes/interactive/components/mermaid.js +13 -7
  85. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  86. package/dist/modes/interactive/components/notice-line.d.ts +10 -2
  87. package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
  88. package/dist/modes/interactive/components/notice-line.js +13 -3
  89. package/dist/modes/interactive/components/notice-line.js.map +1 -1
  90. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -1
  91. package/dist/modes/interactive/components/provider-brand.js +3 -0
  92. package/dist/modes/interactive/components/provider-brand.js.map +1 -1
  93. package/dist/modes/interactive/components/task-heartbeat-message.d.ts +9 -4
  94. package/dist/modes/interactive/components/task-heartbeat-message.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/task-heartbeat-message.js +33 -27
  96. package/dist/modes/interactive/components/task-heartbeat-message.js.map +1 -1
  97. package/dist/modes/interactive/components/task-inspector.d.ts +16 -0
  98. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/task-inspector.js +95 -4
  100. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  101. package/dist/modes/interactive/components/task-list.d.ts +5 -1
  102. package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/task-list.js +20 -3
  104. package/dist/modes/interactive/components/task-list.js.map +1 -1
  105. package/dist/modes/interactive/components/task-transcript-page.d.ts +1 -1
  106. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/task-transcript-page.js +10 -7
  108. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  109. package/dist/modes/interactive/interactive-startup.js +1 -2
  110. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  111. package/dist/modes/interactive/theme/color-utils.d.ts +29 -1
  112. package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
  113. package/dist/modes/interactive/theme/color-utils.js +81 -7
  114. package/dist/modes/interactive/theme/color-utils.js.map +1 -1
  115. package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
  116. package/dist/modes/interactive/theme/global-theme.js +3 -0
  117. package/dist/modes/interactive/theme/global-theme.js.map +1 -1
  118. package/dist/modes/interactive/theme/theme-class.d.ts +22 -2
  119. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  120. package/dist/modes/interactive/theme/theme-class.js +64 -18
  121. package/dist/modes/interactive/theme/theme-class.js.map +1 -1
  122. package/dist/modes/interactive/theme/theme.d.ts +1 -0
  123. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  124. package/dist/modes/interactive/theme/theme.js +1 -0
  125. package/dist/modes/interactive/theme/theme.js.map +1 -1
  126. package/dist/utils/clipboard-image.d.ts.map +1 -1
  127. package/dist/utils/clipboard-image.js +2 -0
  128. package/dist/utils/clipboard-image.js.map +1 -1
  129. package/dist/utils/clipboard.d.ts.map +1 -1
  130. package/dist/utils/clipboard.js +2 -1
  131. package/dist/utils/clipboard.js.map +1 -1
  132. package/dist/utils/tools-manager.d.ts +6 -0
  133. package/dist/utils/tools-manager.d.ts.map +1 -1
  134. package/dist/utils/tools-manager.js +170 -15
  135. package/dist/utils/tools-manager.js.map +1 -1
  136. package/dist/utils/windows-powershell.d.ts +9 -0
  137. package/dist/utils/windows-powershell.d.ts.map +1 -0
  138. package/dist/utils/windows-powershell.js +16 -0
  139. package/dist/utils/windows-powershell.js.map +1 -0
  140. package/docs/background-tasks.md +6 -6
  141. package/docs/getting-started/installation.md +4 -2
  142. package/docs/keybindings.md +3 -0
  143. package/docs/storage.md +24 -5
  144. package/docs/subagents.md +1 -1
  145. package/docs/themes/reference.md +7 -0
  146. package/docs/tui/reference.md +1 -1
  147. package/docs/windows.md +1 -1
  148. package/docs/workflows/api-reference.md +9 -1
  149. package/docs/workflows/operations.md +1 -1
  150. package/npm-shrinkwrap.json +49 -49
  151. package/package.json +6 -6
  152. package/schemas/keybindings.schema.json +4 -0
@@ -0,0 +1,50 @@
1
+ import { Text, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@bastani/atomic-tui";
2
+ import { theme } from "../theme/theme.js";
3
+ import { keyHintIfBound } from "./keybinding-hints.js";
4
+ import { ToolBlock, ToolBlockRecords } from "./tool-block.js";
5
+ class HeartbeatRecord {
6
+ rows;
7
+ constructor(rows) {
8
+ this.rows = rows;
9
+ }
10
+ invalidate() { }
11
+ render(width) {
12
+ return this.rows.flatMap((row) => typeof row === "string" ? [truncateToWidth(row, width, "…")] : wrapTextWithAnsi(row.text, Math.max(1, width)));
13
+ }
14
+ }
15
+ /**
16
+ * A heartbeat notice: the shared notice anatomy, with `♥` as its mark. One header row, a `⎿` connector row per record
17
+ * with its continuation rows, and the inspect hint as the last continuation row.
18
+ */
19
+ export class HeartbeatBlock {
20
+ spec;
21
+ constructor(spec) {
22
+ this.spec = spec;
23
+ }
24
+ invalidate() { }
25
+ render(width) {
26
+ const expand = this.spec.expandable && !this.spec.expanded ? keyHintIfBound("app.tools.expand", "to expand") : "";
27
+ const hint = theme.fg("dim", [this.spec.hint, expand].filter(Boolean).join(" · "));
28
+ const records = this.spec.records.length === 0 ? [[hint]] : this.spec.records.map((rows) => [...rows]);
29
+ if (this.spec.records.length > 0)
30
+ records[records.length - 1]?.push(hint);
31
+ // The title and subject stay whole while they can: facts are dropped from the right first, as a notice's are,
32
+ // and only then is the subject shortened.
33
+ const pad = Math.max(0, Math.min(Math.floor(this.spec.outputPad ?? 1), Math.floor(width) - 1));
34
+ const subject = this.spec.subject;
35
+ const subjectWidth = subject === undefined ? 0 : 3 + visibleWidth(subject);
36
+ const room = Math.floor(width) - pad - 2 - visibleWidth(this.spec.title);
37
+ const meta = [...(this.spec.meta ?? [])];
38
+ while (meta.length > 0 && subjectWidth + meta.reduce((sum, part) => sum + 3 + visibleWidth(part), 0) > room)
39
+ meta.pop();
40
+ const shown = subject === undefined ? "" : room - 3 >= 2 ? ` · ${truncateToWidth(subject, room - 3, "…")}` : "";
41
+ return new ToolBlock({
42
+ status: "heartbeat",
43
+ title: new Text(`${this.spec.title}${shown}`, 0, 0),
44
+ meta,
45
+ details: new ToolBlockRecords(records.map((rows) => new HeartbeatRecord(rows))),
46
+ outputPad: this.spec.outputPad,
47
+ }).render(width);
48
+ }
49
+ }
50
+ //# sourceMappingURL=heartbeat-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heartbeat-block.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/heartbeat-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5G,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAuB9D,MAAM,eAAe;IACH,IAAI,CAA0B;IAC/C,YAAY,IAA6B;QACxC,IAAI,CAAC,IAAI,GAAG,IAA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AAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChH,OAAO,IAAI,SAAS,CAAC;YACpB,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YACnD,IAAI;YACJ,OAAO,EAAE,IAAI,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/E,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;SAC9B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;CACD","sourcesContent":["import { type Component, Text, truncateToWidth, visibleWidth, wrapTextWithAnsi } from \"@bastani/atomic-tui\";\nimport { theme } from \"../theme/theme.js\";\nimport { keyHintIfBound } from \"./keybinding-hints.js\";\nimport { ToolBlock, ToolBlockRecords } from \"./tool-block.ts\";\n\n/** One row of a heartbeat record: shortened to the width, or wrapped onto further rows when `wrap` is set. */\nexport type HeartbeatRow = string | { readonly text: string; readonly wrap: true };\n\n/** A heartbeat in the transcript: what is still running, the rows under it, and where to inspect it. */\nexport interface HeartbeatBlockSpec {\n\t/** `Task heartbeat`, `Workflow heartbeat`. */\n\treadonly title: string;\n\t/** What is still running, after the title as ` · <subject>`; shortened with `…` only once every fact is dropped. */\n\treadonly subject?: string;\n\t/** Dim facts after the title, joined with ` · `: what is still running and for how long. */\n\treadonly meta?: readonly string[];\n\t/** Each record is its connector row and its continuation rows, already styled. */\n\treadonly records: readonly (readonly HeartbeatRow[])[];\n\t/** Where to inspect it, such as `/tasks to inspect`; shown dim under the last record. */\n\treadonly hint: string;\n\t/** Whether expanding it (ctrl+o) shows more, so the hint names the key while it is collapsed. */\n\treadonly expandable: boolean;\n\treadonly expanded: boolean;\n\treadonly outputPad?: number;\n}\n\nclass HeartbeatRecord implements Component {\n\tprivate readonly rows: readonly HeartbeatRow[];\n\tconstructor(rows: readonly HeartbeatRow[]) {\n\t\tthis.rows = rows;\n\t}\n\tinvalidate(): void {}\n\trender(width: number): string[] {\n\t\treturn this.rows.flatMap((row) =>\n\t\t\ttypeof row === \"string\" ? [truncateToWidth(row, width, \"…\")] : wrapTextWithAnsi(row.text, Math.max(1, width)),\n\t\t);\n\t}\n}\n\n/**\n * A heartbeat notice: the shared notice anatomy, with `♥` as its mark. One header row, a `⎿` connector row per record\n * with its continuation rows, and the inspect hint as the last continuation row.\n */\nexport class HeartbeatBlock implements Component {\n\tprivate readonly spec: HeartbeatBlockSpec;\n\tconstructor(spec: HeartbeatBlockSpec) {\n\t\tthis.spec = spec;\n\t}\n\tinvalidate(): void {}\n\trender(width: number): string[] {\n\t\tconst expand = this.spec.expandable && !this.spec.expanded ? keyHintIfBound(\"app.tools.expand\", \"to expand\") : \"\";\n\t\tconst hint = theme.fg(\"dim\", [this.spec.hint, expand].filter(Boolean).join(\" · \"));\n\t\tconst records = this.spec.records.length === 0 ? [[hint]] : this.spec.records.map((rows) => [...rows]);\n\t\tif (this.spec.records.length > 0) records[records.length - 1]?.push(hint);\n\t\t// The title and subject stay whole while they can: facts are dropped from the right first, as a notice's are,\n\t\t// and only then is the subject shortened.\n\t\tconst pad = Math.max(0, Math.min(Math.floor(this.spec.outputPad ?? 1), Math.floor(width) - 1));\n\t\tconst subject = this.spec.subject;\n\t\tconst subjectWidth = subject === undefined ? 0 : 3 + visibleWidth(subject);\n\t\tconst room = Math.floor(width) - pad - 2 - visibleWidth(this.spec.title);\n\t\tconst meta = [...(this.spec.meta ?? [])];\n\t\twhile (meta.length > 0 && subjectWidth + meta.reduce((sum, part) => sum + 3 + visibleWidth(part), 0) > room)\n\t\t\tmeta.pop();\n\t\tconst shown = subject === undefined ? \"\" : room - 3 >= 2 ? ` · ${truncateToWidth(subject, room - 3, \"…\")}` : \"\";\n\t\treturn new ToolBlock({\n\t\t\tstatus: \"heartbeat\",\n\t\t\ttitle: new Text(`${this.spec.title}${shown}`, 0, 0),\n\t\t\tmeta,\n\t\t\tdetails: new ToolBlockRecords(records.map((rows) => new HeartbeatRecord(rows))),\n\t\t\toutputPad: this.spec.outputPad,\n\t\t}).render(width);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"input-label.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/input-label.ts"],"names":[],"mappings":"AAKA,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,6FAA6F;AAC7F,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,UAAU,CAAC;AAElD,gGAAgG;AAChG,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAQD,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAE7D;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAgBD,yHAAyH;AACzH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACZ,UAAU,GAAG,SAAS,CAExB;AAkCD;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC7C,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC5B,MAAM,EAAE,CAUV;AAED,MAAM,WAAW,qBAAqB;IACrC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAyCD,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,WAAW,EAAE,SAAS,MAAM,EAAE,GAC5B,MAAM,EAAE,CA0DV"}
1
+ {"version":3,"file":"input-label.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/input-label.ts"],"names":[],"mappings":"AAMA,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,6FAA6F;AAC7F,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,UAAU,CAAC;AAElD,gGAAgG;AAChG,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAaD,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAE7D;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAgBD,yHAAyH;AACzH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACZ,UAAU,GAAG,SAAS,CAExB;AAkCD;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC7C,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC5B,MAAM,EAAE,CAUV;AAED,MAAM,WAAW,qBAAqB;IACrC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAyCD,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,WAAW,EAAE,SAAS,MAAM,EAAE,GAC5B,MAAM,EAAE,CA0DV"}
@@ -1,5 +1,6 @@
1
1
  import { truncateToWidth, visibleWidth } from "@bastani/atomic-tui";
2
2
  import { singleLineDisplayText } from "../../../utils/terminal-text.js";
3
+ import { colorEnvironment } from "../theme/color-utils.js";
3
4
  import { stripAnsi } from "./chat-session-host-utils.js";
4
5
  import { renderComposerRule } from "./composer-rule.js";
5
6
  /** Supported terminal floor for naming the session in a chat input's top rule. */
@@ -7,6 +8,10 @@ export const INPUT_LABEL_MIN_COLUMNS = 40;
7
8
  const RESET = "\x1b[0m";
8
9
  const BOLD = "\x1b[1m";
9
10
  const NORMAL_INTENSITY = "\x1b[22m";
11
+ /** `text` in bold, unless NO_COLOR or FORCE_COLOR=0 turned styles off; reads the cached color environment only. */
12
+ function emboldened(text) {
13
+ return colorEnvironment().off ? text : `${BOLD}${text}${NORMAL_INTENSITY}`;
14
+ }
10
15
  const EDITOR_SUFFIX = "] ";
11
16
  const EDITOR_OVERFLOW_RE = /^(─*)( [↑↓] \d+ more )(─*)$/u;
12
17
  /** The text that opens a `kind` label, such as `[stage:`; a line containing it is labeled already. */
@@ -21,7 +26,7 @@ function inputLabel(style, name, maxNameWidth, prefix, suffix) {
21
26
  const shown = truncateToWidth(name, maxNameWidth, "…");
22
27
  return {
23
28
  plain: prefix + shown + suffix,
24
- styled: style.textMuted(prefix) + BOLD + style.text(shown) + NORMAL_INTENSITY + style.textMuted(suffix),
29
+ styled: style.textMuted(prefix) + emboldened(style.text(shown)) + style.textMuted(suffix),
25
30
  };
26
31
  }
27
32
  /** `prefix`, `name` truncated with an ellipsis to `maxNameWidth` columns, then `suffix`; nothing when no column fits. */
@@ -137,7 +142,7 @@ export function applyAttachedComposer(style, label, placeholder, editorLines) {
137
142
  lines[0] = renderComposerRule(width, {
138
143
  ...(cleanLabel === undefined
139
144
  ? {}
140
- : { label: { plain: cleanLabel, styled: `${BOLD}${style.text(cleanLabel)}${NORMAL_INTENSITY}` } }),
145
+ : { label: { plain: cleanLabel, styled: emboldened(style.text(cleanLabel)) } }),
141
146
  color: style.accent,
142
147
  heavy: true,
143
148
  });
@@ -152,7 +157,7 @@ export function applyAttachedComposer(style, label, placeholder, editorLines) {
152
157
  lines[0] =
153
158
  style.accent(HEAVY_RULE.repeat(fill)) +
154
159
  (overflow === undefined ? "" : style.dim(overflow)) +
155
- (shown === undefined ? "" : `${BOLD}${style.text(tail)}${NORMAL_INTENSITY}`) +
160
+ (shown === undefined ? "" : emboldened(style.text(tail))) +
156
161
  style.accent(HEAVY_RULE.repeat(Math.max(0, width - fill - visibleWidth(tail) - (overflow === undefined ? 0 : visibleWidth(overflow)))));
157
162
  }
158
163
  const bottom = lines[bottomIndex];
@@ -1 +1 @@
1
- {"version":3,"file":"input-label.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/input-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,8BA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IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACvB,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,GAAG,YAAY,GAAG,EAAE,CAAC;YAC5D,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACzC,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;YAChE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACjG,MAAM,IAAI,GAAG,eAAe,CAAC,gBAAgB,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YAC1D,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { truncateToWidth, visibleWidth } from \"@bastani/atomic-tui\";\nimport { singleLineDisplayText } from \"../../../utils/terminal-text.ts\";\nimport { stripAnsi } from \"./chat-session-host-utils.ts\";\nimport { renderComposerRule } from \"./composer-rule.ts\";\n\n/** Supported terminal floor for naming the session in a chat input's top rule. */\nexport const INPUT_LABEL_MIN_COLUMNS = 40;\n\n/** What kind of session a chat input sends to: an attached workflow stage, or a subagent. */\nexport type InputLabelKind = \"stage\" | \"subagent\";\n\n/** Colours of a label: the brackets and kind are muted, the name is bold in the text colour. */\nexport interface InputLabelStyle {\n\ttextMuted(text: string): string;\n\ttext(text: string): string;\n}\n\n/** A label for a rule: its plain text, for measuring, and its styled text. */\nexport interface InputLabel {\n\treadonly plain: string;\n\treadonly styled: string;\n}\n\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst NORMAL_INTENSITY = \"\\x1b[22m\";\nconst EDITOR_SUFFIX = \"] \";\nconst EDITOR_OVERFLOW_RE = /^(─*)( [↑↓] \\d+ more )(─*)$/u;\n\n/** The text that opens a `kind` label, such as `[stage:`; a line containing it is labeled already. */\nexport function inputLabelMarker(kind: InputLabelKind): string {\n\treturn `[${kind}:`;\n}\n\n/** The colour a rendered rule opens with, so a label's fill continues in it. */\nexport function ruleOpenColor(line: string): string {\n\treturn line.match(/^(\\x1b\\[[0-9;]*m)/)?.[1] ?? \"\";\n}\n\nfunction inputLabel(\n\tstyle: InputLabelStyle,\n\tname: string,\n\tmaxNameWidth: number,\n\tprefix: string,\n\tsuffix: string,\n): InputLabel {\n\tconst shown = truncateToWidth(name, maxNameWidth, \"…\");\n\treturn {\n\t\tplain: prefix + shown + suffix,\n\t\tstyled: style.textMuted(prefix) + BOLD + style.text(shown) + NORMAL_INTENSITY + style.textMuted(suffix),\n\t};\n}\n\n/** `prefix`, `name` truncated with an ellipsis to `maxNameWidth` columns, then `suffix`; nothing when no column fits. */\nexport function buildInputLabel(\n\tstyle: InputLabelStyle,\n\tname: string,\n\tmaxNameWidth: number,\n\tprefix: string,\n\tsuffix: string,\n): InputLabel | undefined {\n\treturn maxNameWidth < 1 ? undefined : inputLabel(style, name, maxNameWidth, prefix, suffix);\n}\n\nfunction decorateEditorTopLine(\n\tstyle: InputLabelStyle,\n\tkind: InputLabelKind,\n\tname: string,\n\tline: string,\n\tplain: string,\n\toverflow: string | undefined,\n): string | undefined {\n\tconst width = visibleWidth(plain);\n\tif (width < INPUT_LABEL_MIN_COLUMNS) return undefined;\n\tconst prefix = `${inputLabelMarker(kind)} `;\n\tconst overflowWidth = overflow === undefined ? 0 : visibleWidth(overflow);\n\tconst maxNameWidth = Math.max(1, width - overflowWidth - visibleWidth(prefix) - visibleWidth(EDITOR_SUFFIX) - 2);\n\tconst label = inputLabel(style, name, maxNameWidth, prefix, EDITOR_SUFFIX);\n\tconst labelWidth = visibleWidth(label.plain);\n\tif (labelWidth + overflowWidth >= width) return undefined;\n\tconst fillWidth = width - labelWidth - overflowWidth;\n\tconst openColor = ruleOpenColor(line);\n\tif (overflow === undefined) return openColor + RESET + label.styled + openColor + \"─\".repeat(fillWidth) + RESET;\n\tconst leftFill = Math.floor(fillWidth / 2);\n\treturn (\n\t\topenColor +\n\t\tRESET +\n\t\tlabel.styled +\n\t\topenColor +\n\t\t\"─\".repeat(leftFill) +\n\t\toverflow +\n\t\t\"─\".repeat(fillWidth - leftFill) +\n\t\tRESET\n\t);\n}\n\n/**\n * Names the session a chat input sends to in the editor's top rule, as `[kind: name]`. Call it on the editor's\n * rendered lines: decorating the rule while the editor renders would stop it recognising the rule as a border and\n * put the `❯` prompt on it. Only the first line is decorated, a plain `─` rule or a scrolled `↑ N more` rule, whose\n * indicator stays; later rules never are. A labeled rule is no longer plain, so it is never labeled twice, and draft\n * text that names a label does not count as one. A rule narrower than {@link INPUT_LABEL_MIN_COLUMNS} is left as it is.\n */\nexport function applyInputLabelToEditorTopRule(\n\tstyle: InputLabelStyle,\n\tkind: InputLabelKind,\n\tname: string | undefined,\n\teditorLines: readonly string[],\n): string[] {\n\tconst lines = [...editorLines];\n\tconst topLine = lines[0];\n\tif (!name || topLine === undefined) return lines;\n\tconst plain = stripAnsi(topLine);\n\tconst overflow = EDITOR_OVERFLOW_RE.exec(plain)?.[2];\n\tif (!/^─+$/.test(plain) && overflow === undefined) return lines;\n\tconst decorated = decorateEditorTopLine(style, kind, name, topLine, plain, overflow);\n\tif (decorated !== undefined) lines[0] = decorated;\n\treturn lines;\n}\n\nexport interface AttachedComposerStyle {\n\taccent(text: string): string;\n\ttext(text: string): string;\n\tdim(text: string): string;\n}\n\nconst HEAVY_RULE = \"━\";\nconst PROMPT_GLYPH = \"❯\";\n\nfunction stripApc(text: string): string {\n\tlet start = text.indexOf(\"\\x1b_\");\n\tif (start === -1) return text;\n\tlet out = \"\";\n\tlet cursor = 0;\n\twhile (start !== -1) {\n\t\tconst end = text.indexOf(\"\\x07\", start + 2);\n\t\tif (end === -1) break;\n\t\tout += text.slice(cursor, start);\n\t\tcursor = end + 1;\n\t\tstart = text.indexOf(\"\\x1b_\", cursor);\n\t}\n\treturn cursor === 0 ? text : out + text.slice(cursor);\n}\n\nfunction trimTrailingSpaces(line: string): string {\n\tlet sgrStart = line.length;\n\twhile (sgrStart >= 3 && line.charCodeAt(sgrStart - 1) === 0x6d) {\n\t\tlet index = sgrStart - 2;\n\t\twhile (index >= 0) {\n\t\t\tconst code = line.charCodeAt(index);\n\t\t\tif ((code >= 0x30 && code <= 0x39) || code === 0x3b) index--;\n\t\t\telse break;\n\t\t}\n\t\tif (index >= 1 && line.charCodeAt(index) === 0x5b && line.charCodeAt(index - 1) === 0x1b) {\n\t\t\tsgrStart = index - 1;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tlet spaceStart = sgrStart;\n\twhile (spaceStart > 0 && line.charCodeAt(spaceStart - 1) === 0x20) spaceStart--;\n\tif (spaceStart === sgrStart) return line;\n\treturn line.slice(0, spaceStart) + line.slice(sgrStart);\n}\n\nexport function applyAttachedComposer(\n\tstyle: AttachedComposerStyle,\n\tlabel: string | undefined,\n\tplaceholder: string | undefined,\n\teditorLines: readonly string[],\n): string[] {\n\tconst lines = [...editorLines];\n\tconst cleanLabel = label === undefined ? undefined : singleLineDisplayText(label).trim();\n\tconst cleanPlaceholder = placeholder === undefined ? undefined : singleLineDisplayText(placeholder).trim();\n\tconst top = lines[0];\n\tconst isRule = (line: string) => {\n\t\tconst plain = stripAnsi(line);\n\t\treturn /^─+$/.test(plain) || EDITOR_OVERFLOW_RE.test(plain);\n\t};\n\tlet bottomIndex = lines.length - 1;\n\twhile (bottomIndex > 0 && !isRule(lines[bottomIndex]!)) bottomIndex--;\n\tif (top === undefined || bottomIndex < 1) return lines;\n\tconst width = visibleWidth(stripAnsi(top));\n\tconst overflowNote = isRule(top) ? EDITOR_OVERFLOW_RE.exec(stripAnsi(top))?.[2] : undefined;\n\tif (isRule(top) && overflowNote === undefined) {\n\t\tlines[0] = renderComposerRule(width, {\n\t\t\t...(cleanLabel === undefined\n\t\t\t\t? {}\n\t\t\t\t: { label: { plain: cleanLabel, styled: `${BOLD}${style.text(cleanLabel)}${NORMAL_INTENSITY}` } }),\n\t\t\tcolor: style.accent,\n\t\t\theavy: true,\n\t\t});\n\t} else if (isRule(top)) {\n\t\tconst overflow = overflowNote;\n\t\tconst shown =\n\t\t\tcleanLabel === undefined || width < INPUT_LABEL_MIN_COLUMNS\n\t\t\t\t? undefined\n\t\t\t\t: truncateToWidth(\n\t\t\t\t\t\tcleanLabel,\n\t\t\t\t\t\tMath.max(1, width - (overflow === undefined ? 0 : visibleWidth(overflow)) - 6),\n\t\t\t\t\t\t\"…\",\n\t\t\t\t\t);\n\t\tconst tail = shown === undefined ? \"\" : ` ${shown} `;\n\t\tconst fill = Math.max(0, width - visibleWidth(tail) - 1 - (overflow === undefined ? 0 : visibleWidth(overflow)));\n\t\tlines[0] =\n\t\t\tstyle.accent(HEAVY_RULE.repeat(fill)) +\n\t\t\t(overflow === undefined ? \"\" : style.dim(overflow)) +\n\t\t\t(shown === undefined ? \"\" : `${BOLD}${style.text(tail)}${NORMAL_INTENSITY}`) +\n\t\t\tstyle.accent(\n\t\t\t\tHEAVY_RULE.repeat(\n\t\t\t\t\tMath.max(0, width - fill - visibleWidth(tail) - (overflow === undefined ? 0 : visibleWidth(overflow))),\n\t\t\t\t),\n\t\t\t);\n\t}\n\tconst bottom = lines[bottomIndex]!;\n\tif (isRule(bottom)) lines[bottomIndex] = style.accent(stripAnsi(bottom).replace(/─/gu, HEAVY_RULE));\n\tif (cleanPlaceholder !== undefined && bottomIndex === 2) {\n\t\tconst line = lines[1]!;\n\t\tconst plain = stripAnsi(stripApc(line)).trimEnd();\n\t\tif (plain === PROMPT_GLYPH || plain === `${PROMPT_GLYPH} `) {\n\t\t\tconst trimmed = trimTrailingSpaces(line);\n\t\t\tconst separator = trimmed.includes(\"\\x1b_pi:fc\\x07\") ? \"\" : \" \";\n\t\t\tconst room = Math.max(0, width - visibleWidth(stripAnsi(line).trimEnd()) - separator.length - 1);\n\t\t\tconst text = truncateToWidth(cleanPlaceholder, room, \"…\");\n\t\t\tlines[1] = `${trimmed}${separator}${style.dim(text)}`;\n\t\t}\n\t}\n\treturn lines;\n}\n"]}
1
+ {"version":3,"file":"input-label.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/input-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,kFAAkF;AAClF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAiB1C,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,SAAS,CAAC;AACvB,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC,mHAAmH;AACnH,SAAS,UAAU,CAAC,IAAY;IAC/B,OAAO,gBAAgB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,gBAAgB,EAAE,CAAC;AAC5E,CAAC;AACD,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAE1D,sGAAsG;AACtG,MAAM,UAAU,gBAAgB,CAAC,IAAoB;IACpD,OAAO,IAAI,IAAI,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AK,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACjG,MAAM,IAAI,GAAG,eAAe,CAAC,gBAAgB,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YAC1D,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { truncateToWidth, visibleWidth } from \"@bastani/atomic-tui\";\nimport { singleLineDisplayText } from \"../../../utils/terminal-text.ts\";\nimport { colorEnvironment } from \"../theme/color-utils.ts\";\nimport { stripAnsi } from \"./chat-session-host-utils.ts\";\nimport { renderComposerRule } from \"./composer-rule.ts\";\n\n/** Supported terminal floor for naming the session in a chat input's top rule. */\nexport const INPUT_LABEL_MIN_COLUMNS = 40;\n\n/** What kind of session a chat input sends to: an attached workflow stage, or a subagent. */\nexport type InputLabelKind = \"stage\" | \"subagent\";\n\n/** Colours of a label: the brackets and kind are muted, the name is bold in the text colour. */\nexport interface InputLabelStyle {\n\ttextMuted(text: string): string;\n\ttext(text: string): string;\n}\n\n/** A label for a rule: its plain text, for measuring, and its styled text. */\nexport interface InputLabel {\n\treadonly plain: string;\n\treadonly styled: string;\n}\n\nconst RESET = \"\\x1b[0m\";\nconst BOLD = \"\\x1b[1m\";\nconst NORMAL_INTENSITY = \"\\x1b[22m\";\n\n/** `text` in bold, unless NO_COLOR or FORCE_COLOR=0 turned styles off; reads the cached color environment only. */\nfunction emboldened(text: string): string {\n\treturn colorEnvironment().off ? text : `${BOLD}${text}${NORMAL_INTENSITY}`;\n}\nconst EDITOR_SUFFIX = \"] \";\nconst EDITOR_OVERFLOW_RE = /^(─*)( [↑↓] \\d+ more )(─*)$/u;\n\n/** The text that opens a `kind` label, such as `[stage:`; a line containing it is labeled already. */\nexport function inputLabelMarker(kind: InputLabelKind): string {\n\treturn `[${kind}:`;\n}\n\n/** The colour a rendered rule opens with, so a label's fill continues in it. */\nexport function ruleOpenColor(line: string): string {\n\treturn line.match(/^(\\x1b\\[[0-9;]*m)/)?.[1] ?? \"\";\n}\n\nfunction inputLabel(\n\tstyle: InputLabelStyle,\n\tname: string,\n\tmaxNameWidth: number,\n\tprefix: string,\n\tsuffix: string,\n): InputLabel {\n\tconst shown = truncateToWidth(name, maxNameWidth, \"…\");\n\treturn {\n\t\tplain: prefix + shown + suffix,\n\t\tstyled: style.textMuted(prefix) + emboldened(style.text(shown)) + style.textMuted(suffix),\n\t};\n}\n\n/** `prefix`, `name` truncated with an ellipsis to `maxNameWidth` columns, then `suffix`; nothing when no column fits. */\nexport function buildInputLabel(\n\tstyle: InputLabelStyle,\n\tname: string,\n\tmaxNameWidth: number,\n\tprefix: string,\n\tsuffix: string,\n): InputLabel | undefined {\n\treturn maxNameWidth < 1 ? undefined : inputLabel(style, name, maxNameWidth, prefix, suffix);\n}\n\nfunction decorateEditorTopLine(\n\tstyle: InputLabelStyle,\n\tkind: InputLabelKind,\n\tname: string,\n\tline: string,\n\tplain: string,\n\toverflow: string | undefined,\n): string | undefined {\n\tconst width = visibleWidth(plain);\n\tif (width < INPUT_LABEL_MIN_COLUMNS) return undefined;\n\tconst prefix = `${inputLabelMarker(kind)} `;\n\tconst overflowWidth = overflow === undefined ? 0 : visibleWidth(overflow);\n\tconst maxNameWidth = Math.max(1, width - overflowWidth - visibleWidth(prefix) - visibleWidth(EDITOR_SUFFIX) - 2);\n\tconst label = inputLabel(style, name, maxNameWidth, prefix, EDITOR_SUFFIX);\n\tconst labelWidth = visibleWidth(label.plain);\n\tif (labelWidth + overflowWidth >= width) return undefined;\n\tconst fillWidth = width - labelWidth - overflowWidth;\n\tconst openColor = ruleOpenColor(line);\n\tif (overflow === undefined) return openColor + RESET + label.styled + openColor + \"─\".repeat(fillWidth) + RESET;\n\tconst leftFill = Math.floor(fillWidth / 2);\n\treturn (\n\t\topenColor +\n\t\tRESET +\n\t\tlabel.styled +\n\t\topenColor +\n\t\t\"─\".repeat(leftFill) +\n\t\toverflow +\n\t\t\"─\".repeat(fillWidth - leftFill) +\n\t\tRESET\n\t);\n}\n\n/**\n * Names the session a chat input sends to in the editor's top rule, as `[kind: name]`. Call it on the editor's\n * rendered lines: decorating the rule while the editor renders would stop it recognising the rule as a border and\n * put the `❯` prompt on it. Only the first line is decorated, a plain `─` rule or a scrolled `↑ N more` rule, whose\n * indicator stays; later rules never are. A labeled rule is no longer plain, so it is never labeled twice, and draft\n * text that names a label does not count as one. A rule narrower than {@link INPUT_LABEL_MIN_COLUMNS} is left as it is.\n */\nexport function applyInputLabelToEditorTopRule(\n\tstyle: InputLabelStyle,\n\tkind: InputLabelKind,\n\tname: string | undefined,\n\teditorLines: readonly string[],\n): string[] {\n\tconst lines = [...editorLines];\n\tconst topLine = lines[0];\n\tif (!name || topLine === undefined) return lines;\n\tconst plain = stripAnsi(topLine);\n\tconst overflow = EDITOR_OVERFLOW_RE.exec(plain)?.[2];\n\tif (!/^─+$/.test(plain) && overflow === undefined) return lines;\n\tconst decorated = decorateEditorTopLine(style, kind, name, topLine, plain, overflow);\n\tif (decorated !== undefined) lines[0] = decorated;\n\treturn lines;\n}\n\nexport interface AttachedComposerStyle {\n\taccent(text: string): string;\n\ttext(text: string): string;\n\tdim(text: string): string;\n}\n\nconst HEAVY_RULE = \"━\";\nconst PROMPT_GLYPH = \"❯\";\n\nfunction stripApc(text: string): string {\n\tlet start = text.indexOf(\"\\x1b_\");\n\tif (start === -1) return text;\n\tlet out = \"\";\n\tlet cursor = 0;\n\twhile (start !== -1) {\n\t\tconst end = text.indexOf(\"\\x07\", start + 2);\n\t\tif (end === -1) break;\n\t\tout += text.slice(cursor, start);\n\t\tcursor = end + 1;\n\t\tstart = text.indexOf(\"\\x1b_\", cursor);\n\t}\n\treturn cursor === 0 ? text : out + text.slice(cursor);\n}\n\nfunction trimTrailingSpaces(line: string): string {\n\tlet sgrStart = line.length;\n\twhile (sgrStart >= 3 && line.charCodeAt(sgrStart - 1) === 0x6d) {\n\t\tlet index = sgrStart - 2;\n\t\twhile (index >= 0) {\n\t\t\tconst code = line.charCodeAt(index);\n\t\t\tif ((code >= 0x30 && code <= 0x39) || code === 0x3b) index--;\n\t\t\telse break;\n\t\t}\n\t\tif (index >= 1 && line.charCodeAt(index) === 0x5b && line.charCodeAt(index - 1) === 0x1b) {\n\t\t\tsgrStart = index - 1;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tlet spaceStart = sgrStart;\n\twhile (spaceStart > 0 && line.charCodeAt(spaceStart - 1) === 0x20) spaceStart--;\n\tif (spaceStart === sgrStart) return line;\n\treturn line.slice(0, spaceStart) + line.slice(sgrStart);\n}\n\nexport function applyAttachedComposer(\n\tstyle: AttachedComposerStyle,\n\tlabel: string | undefined,\n\tplaceholder: string | undefined,\n\teditorLines: readonly string[],\n): string[] {\n\tconst lines = [...editorLines];\n\tconst cleanLabel = label === undefined ? undefined : singleLineDisplayText(label).trim();\n\tconst cleanPlaceholder = placeholder === undefined ? undefined : singleLineDisplayText(placeholder).trim();\n\tconst top = lines[0];\n\tconst isRule = (line: string) => {\n\t\tconst plain = stripAnsi(line);\n\t\treturn /^─+$/.test(plain) || EDITOR_OVERFLOW_RE.test(plain);\n\t};\n\tlet bottomIndex = lines.length - 1;\n\twhile (bottomIndex > 0 && !isRule(lines[bottomIndex]!)) bottomIndex--;\n\tif (top === undefined || bottomIndex < 1) return lines;\n\tconst width = visibleWidth(stripAnsi(top));\n\tconst overflowNote = isRule(top) ? EDITOR_OVERFLOW_RE.exec(stripAnsi(top))?.[2] : undefined;\n\tif (isRule(top) && overflowNote === undefined) {\n\t\tlines[0] = renderComposerRule(width, {\n\t\t\t...(cleanLabel === undefined\n\t\t\t\t? {}\n\t\t\t\t: { label: { plain: cleanLabel, styled: emboldened(style.text(cleanLabel)) } }),\n\t\t\tcolor: style.accent,\n\t\t\theavy: true,\n\t\t});\n\t} else if (isRule(top)) {\n\t\tconst overflow = overflowNote;\n\t\tconst shown =\n\t\t\tcleanLabel === undefined || width < INPUT_LABEL_MIN_COLUMNS\n\t\t\t\t? undefined\n\t\t\t\t: truncateToWidth(\n\t\t\t\t\t\tcleanLabel,\n\t\t\t\t\t\tMath.max(1, width - (overflow === undefined ? 0 : visibleWidth(overflow)) - 6),\n\t\t\t\t\t\t\"…\",\n\t\t\t\t\t);\n\t\tconst tail = shown === undefined ? \"\" : ` ${shown} `;\n\t\tconst fill = Math.max(0, width - visibleWidth(tail) - 1 - (overflow === undefined ? 0 : visibleWidth(overflow)));\n\t\tlines[0] =\n\t\t\tstyle.accent(HEAVY_RULE.repeat(fill)) +\n\t\t\t(overflow === undefined ? \"\" : style.dim(overflow)) +\n\t\t\t(shown === undefined ? \"\" : emboldened(style.text(tail))) +\n\t\t\tstyle.accent(\n\t\t\t\tHEAVY_RULE.repeat(\n\t\t\t\t\tMath.max(0, width - fill - visibleWidth(tail) - (overflow === undefined ? 0 : visibleWidth(overflow))),\n\t\t\t\t),\n\t\t\t);\n\t}\n\tconst bottom = lines[bottomIndex]!;\n\tif (isRule(bottom)) lines[bottomIndex] = style.accent(stripAnsi(bottom).replace(/─/gu, HEAVY_RULE));\n\tif (cleanPlaceholder !== undefined && bottomIndex === 2) {\n\t\tconst line = lines[1]!;\n\t\tconst plain = stripAnsi(stripApc(line)).trimEnd();\n\t\tif (plain === PROMPT_GLYPH || plain === `${PROMPT_GLYPH} `) {\n\t\t\tconst trimmed = trimTrailingSpaces(line);\n\t\t\tconst separator = trimmed.includes(\"\\x1b_pi:fc\\x07\") ? \"\" : \" \";\n\t\t\tconst room = Math.max(0, width - visibleWidth(stripAnsi(line).trimEnd()) - separator.length - 1);\n\t\t\tconst text = truncateToWidth(cleanPlaceholder, room, \"…\");\n\t\t\tlines[1] = `${trimmed}${separator}${style.dim(text)}`;\n\t\t}\n\t}\n\treturn lines;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"main-composer-keys.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/main-composer-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,iCAAiC,CAAC;AAE1F,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,cAAc,EAAsC,MAAM,eAAe,CAAC;AAEnH,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,sBAAsB,GAC/B,IAAI,CAAC,oBAAoB,EAAE,WAAW,GAAG,YAAY,GAAG,QAAQ,CAAC,GACjE,CAAC,iBAAiB,GAAG,MAAM,CAAC,GAC5B,CAAC,MAAM,gBAAgB,CAAC,CAAC;AAI5B,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,gBAAgB,GAAG,IAAI,CAE1G;AAoCD,wBAAgB,wBAAwB,CACvC,WAAW,EAAE,cAAc,GAAG,SAAS,EACvC,KAAK,CAAC,EAAE,sBAAsB,GAC5B,MAAM,EAAE,CAkBV;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAgBtE;AAED,qBAAa,sBAAuB,YAAW,SAAS;IACvD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IACzD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;IACnD,OAAO,CAAC,QAAQ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,sBAAsB,GAC5B,MAAM,EAAE,CAcV;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAgBtE;AAED,qBAAa,sBAAuB,YAAW,SAAS;IACvD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IACzD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;IACnD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IAEnC,YAAY,WAAW,EAAE,cAAc,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,EAAE,KAAK,EAAE,MAAM,IAAI,EAIxG;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAmB9B;IAED,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAI9B;IAED,UAAU,IAAI,IAAI,CAAG;CACrB"}
@@ -1,5 +1,6 @@
1
1
  import { agentPanelCounts } from "../../rpc/agent-panel-bridge.js";
2
2
  import { theme } from "../theme/theme.js";
3
+ import { panelShellHintSegments } from "./agent-panel.js";
3
4
  import { isNavHelpKey, navActionText, renderNavKeyOverlay } from "./nav-keys.js";
4
5
  const boundAgentCounts = new WeakMap();
5
6
  export function bindMainComposerAgentRows(keybindings, count) {
@@ -48,13 +49,8 @@ export function mainComposerHintSegments(keybindings, state) {
48
49
  if (counts.needsInput > 0)
49
50
  segments.push(`${counts.needsInput} needs input`);
50
51
  }
51
- const shells = Math.floor(counts.shells ?? 0);
52
- if (Number.isFinite(shells) && shells > 0) {
53
- segments.push(`${shells} ${shells === 1 ? "shell" : "shells"}`);
54
- // Shells are not panel rows; with no panel to focus, say where they are.
55
- if (!agents)
56
- segments.push("/tasks to manage");
57
- }
52
+ // Shells are not panel rows; with no panel to focus, say where they are.
53
+ segments.push(...panelShellHintSegments(counts.shells ?? 0, agents !== undefined));
58
54
  const help = navActionText(promptKeys, "app.keys.help");
59
55
  if (help)
60
56
  segments.push(`${help} keys`);
@@ -1 +1 @@
1
- {"version":3,"file":"main-composer-keys.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/main-composer-keys.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAoC,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAenH,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA0C,CAAC;AAE/E,MAAM,UAAU,yBAAyB,CAAC,WAA2B,EAAE,KAA6B;IACnG,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,kBAAkB,CAC1B,WAAuC,EACvC,MAA+B;IAE/B,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,MAAM,EAAE,CAAC;IAClD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,IAAI,WAAW,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YACnE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACpG,CAAC;QACD,OAAO,gBAAgB,CAAC,MAAoC,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,CAAC,WAAW,IAAI,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;AAC9F,CAAC;AAED,SAAS,iBAAiB,CAAC,WAAuC;IACjE,IAAI,CAAC,WAAW;QAAE,OAAO,SAAS,CAAC;IACnC,OAAO;QACN,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,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AC,KAAK,CAAC,EACvB,KAAK,EACL;YACC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;YACpC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC;YACtC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;YACxC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC;YAC/C,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;SAChC,EACD,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CACnC,CAAC;IACH,CAAC;IAED,WAAW,CAAC,IAAY;QACvB,IAAI,IAAI,KAAK,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE,CAAC;YACjH,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;IACF,CAAC;IAED,UAAU,KAAU,CAAC;CACrB","sourcesContent":["import type { Component } from \"@bastani/atomic-tui\";\nimport type { AgentPanelSession } from \"../../../core/tasks/agent-panel-source.ts\";\nimport { type AgentPanelCounts, agentPanelCounts } from \"../../rpc/agent-panel-bridge.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport { isNavHelpKey, type NavKey, type NavKeybindings, navActionText, renderNavKeyOverlay } from \"./nav-keys.ts\";\n\nexport interface MainComposerKeyState {\n\treadonly agentRows?: number;\n\treadonly needsInput?: number;\n\t/** Running background shells, which /tasks lists. */\n\treadonly shells?: number;\n\treadonly working: boolean;\n}\n\nexport type MainComposerHintSource =\n\t| Pick<MainComposerKeyState, \"agentRows\" | \"needsInput\" | \"shells\">\n\t| (AgentPanelSession & object)\n\t| (() => AgentPanelCounts);\n\nconst boundAgentCounts = new WeakMap<NavKeybindings, () => AgentPanelCounts>();\n\nexport function bindMainComposerAgentRows(keybindings: NavKeybindings, count: () => AgentPanelCounts): void {\n\tboundAgentCounts.set(keybindings, count);\n}\n\nfunction resolveAgentCounts(\n\tkeybindings: NavKeybindings | undefined,\n\tsource?: MainComposerHintSource,\n): AgentPanelCounts {\n\tif (typeof source === \"function\") return source();\n\tif (source !== undefined) {\n\t\tif (\"agentRows\" in source && typeof source.agentRows === \"number\") {\n\t\t\treturn { total: source.agentRows, needsInput: source.needsInput ?? 0, shells: source.shells ?? 0 };\n\t\t}\n\t\treturn agentPanelCounts(source as AgentPanelSession & object);\n\t}\n\treturn (keybindings && boundAgentCounts.get(keybindings)?.()) || { total: 0, needsInput: 0 };\n}\n\nfunction promptKeybindings(keybindings: NavKeybindings | undefined): NavKeybindings | undefined {\n\tif (!keybindings) return undefined;\n\treturn {\n\t\tmatches: (data, action) => keybindings.matches(data, action),\n\t\tgetKeys: (action) => {\n\t\t\tconst keys = keybindings.getKeys?.(action) ?? [];\n\t\t\treturn action === \"app.interrupt\" ? keys : keys.filter((key) => key !== \"esc\" && key !== \"escape\");\n\t\t},\n\t};\n}\n\nfunction agentsSegment(keybindings: NavKeybindings | undefined, rows: number): string | undefined {\n\tif (!Number.isFinite(rows) || rows <= 0) return undefined;\n\tconst count = Math.floor(rows);\n\tif (count <= 0) return undefined;\n\tconst key = navActionText(keybindings, \"app.agents.focus\");\n\tif (!key) return undefined;\n\treturn `${key} ${count} ${count === 1 ? \"agent\" : \"agents\"}`;\n}\n\nexport function mainComposerHintSegments(\n\tkeybindings: NavKeybindings | undefined,\n\tstate?: MainComposerHintSource,\n): string[] {\n\tconst segments: string[] = [];\n\tconst counts = resolveAgentCounts(keybindings, state);\n\tconst promptKeys = promptKeybindings(keybindings);\n\tconst agents = agentsSegment(promptKeys, counts.total);\n\tif (agents) {\n\t\tsegments.push(agents);\n\t\tif (counts.needsInput > 0) segments.push(`${counts.needsInput} needs input`);\n\t}\n\tconst shells = Math.floor(counts.shells ?? 0);\n\tif (Number.isFinite(shells) && shells > 0) {\n\t\tsegments.push(`${shells} ${shells === 1 ? \"shell\" : \"shells\"}`);\n\t\t// Shells are not panel rows; with no panel to focus, say where they are.\n\t\tif (!agents) segments.push(\"/tasks to manage\");\n\t}\n\tconst help = navActionText(promptKeys, \"app.keys.help\");\n\tif (help) segments.push(`${help} keys`);\n\treturn segments;\n}\n\nexport function mainComposerKeys(state: MainComposerKeyState): NavKey[] {\n\tconst agentRows = state.agentRows ?? 0;\n\treturn [\n\t\t{ keys: \"enter\", label: \"send the prompt\" },\n\t\t...(state.working ? [{ action: \"app.interrupt\", label: \"interrupt the agent's turn\" }] : []),\n\t\t...(agentRows > 0 ? [{ action: \"app.agents.focus\", label: \"agents, on an empty prompt\" }] : []),\n\t\t{ keys: \"/\", label: \"commands, at the start of the prompt\" },\n\t\t{ keys: \"@\", label: \"insert a file path\" },\n\t\t{ action: \"app.history.search\", label: \"search past prompts\" },\n\t\t{ keys: \"pgup/pgdn\", label: \"scroll\" },\n\t\t{ action: \"tui.altScreen.bottom\", label: \"jump to the latest message\" },\n\t\t{ action: \"app.tools.expand\", label: \"expand tool output\" },\n\t\t{ action: \"app.thinking.toggle\", label: \"show or hide thinking\" },\n\t\t{ action: \"app.agents.chord\", label: \"then the stop-all key: stop all background work\" },\n\t\t{ action: \"app.keys.help\", label: \"keys, on an empty prompt\" },\n\t];\n}\n\nexport class MainComposerKeyOverlay implements Component {\n\tprivate readonly keybindings: NavKeybindings | undefined;\n\tprivate readonly state: () => MainComposerKeyState;\n\tprivate readonly close: () => void;\n\n\tconstructor(keybindings: NavKeybindings | undefined, state: () => MainComposerKeyState, close: () => void) {\n\t\tthis.keybindings = keybindings;\n\t\tthis.state = state;\n\t\tthis.close = close;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst current = this.state();\n\t\tconst state =\n\t\t\tcurrent.agentRows !== undefined\n\t\t\t\t? current\n\t\t\t\t: { ...current, agentRows: resolveAgentCounts(this.keybindings).total };\n\t\treturn renderNavKeyOverlay(\n\t\t\t\"keys\",\n\t\t\tmainComposerKeys(state),\n\t\t\twidth,\n\t\t\t{\n\t\t\t\tdim: (text) => theme.fg(\"dim\", text),\n\t\t\t\ttext: (text) => theme.fg(\"text\", text),\n\t\t\t\tmuted: (text) => theme.fg(\"muted\", text),\n\t\t\t\tborder: (text) => theme.fg(\"borderMuted\", text),\n\t\t\t\tbold: (text) => theme.bold(text),\n\t\t\t},\n\t\t\tpromptKeybindings(this.keybindings),\n\t\t);\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (data === \"\\x1b\" || isNavHelpKey(this.keybindings, data) || this.keybindings?.matches(data, \"app.interrupt\")) {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\tinvalidate(): void {}\n}\n"]}
1
+ {"version":3,"file":"main-composer-keys.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/main-composer-keys.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAoC,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAenH,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA0C,CAAC;AAE/E,MAAM,UAAU,yBAAyB,CAAC,WAA2B,EAAE,KAA6B;IACnG,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,kBAAkB,CAC1B,WAAuC,EACvC,MAA+B;IAE/B,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,MAAM,EAAE,CAAC;IAClD,IAA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ent":["import type { Component } from \"@bastani/atomic-tui\";\nimport type { AgentPanelSession } from \"../../../core/tasks/agent-panel-source.ts\";\nimport { type AgentPanelCounts, agentPanelCounts } from \"../../rpc/agent-panel-bridge.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport { panelShellHintSegments } from \"./agent-panel.ts\";\nimport { isNavHelpKey, type NavKey, type NavKeybindings, navActionText, renderNavKeyOverlay } from \"./nav-keys.ts\";\n\nexport interface MainComposerKeyState {\n\treadonly agentRows?: number;\n\treadonly needsInput?: number;\n\t/** Running background shells, which /tasks lists. */\n\treadonly shells?: number;\n\treadonly working: boolean;\n}\n\nexport type MainComposerHintSource =\n\t| Pick<MainComposerKeyState, \"agentRows\" | \"needsInput\" | \"shells\">\n\t| (AgentPanelSession & object)\n\t| (() => AgentPanelCounts);\n\nconst boundAgentCounts = new WeakMap<NavKeybindings, () => AgentPanelCounts>();\n\nexport function bindMainComposerAgentRows(keybindings: NavKeybindings, count: () => AgentPanelCounts): void {\n\tboundAgentCounts.set(keybindings, count);\n}\n\nfunction resolveAgentCounts(\n\tkeybindings: NavKeybindings | undefined,\n\tsource?: MainComposerHintSource,\n): AgentPanelCounts {\n\tif (typeof source === \"function\") return source();\n\tif (source !== undefined) {\n\t\tif (\"agentRows\" in source && typeof source.agentRows === \"number\") {\n\t\t\treturn { total: source.agentRows, needsInput: source.needsInput ?? 0, shells: source.shells ?? 0 };\n\t\t}\n\t\treturn agentPanelCounts(source as AgentPanelSession & object);\n\t}\n\treturn (keybindings && boundAgentCounts.get(keybindings)?.()) || { total: 0, needsInput: 0 };\n}\n\nfunction promptKeybindings(keybindings: NavKeybindings | undefined): NavKeybindings | undefined {\n\tif (!keybindings) return undefined;\n\treturn {\n\t\tmatches: (data, action) => keybindings.matches(data, action),\n\t\tgetKeys: (action) => {\n\t\t\tconst keys = keybindings.getKeys?.(action) ?? [];\n\t\t\treturn action === \"app.interrupt\" ? keys : keys.filter((key) => key !== \"esc\" && key !== \"escape\");\n\t\t},\n\t};\n}\n\nfunction agentsSegment(keybindings: NavKeybindings | undefined, rows: number): string | undefined {\n\tif (!Number.isFinite(rows) || rows <= 0) return undefined;\n\tconst count = Math.floor(rows);\n\tif (count <= 0) return undefined;\n\tconst key = navActionText(keybindings, \"app.agents.focus\");\n\tif (!key) return undefined;\n\treturn `${key} ${count} ${count === 1 ? \"agent\" : \"agents\"}`;\n}\n\nexport function mainComposerHintSegments(\n\tkeybindings: NavKeybindings | undefined,\n\tstate?: MainComposerHintSource,\n): string[] {\n\tconst segments: string[] = [];\n\tconst counts = resolveAgentCounts(keybindings, state);\n\tconst promptKeys = promptKeybindings(keybindings);\n\tconst agents = agentsSegment(promptKeys, counts.total);\n\tif (agents) {\n\t\tsegments.push(agents);\n\t\tif (counts.needsInput > 0) segments.push(`${counts.needsInput} needs input`);\n\t}\n\t// Shells are not panel rows; with no panel to focus, say where they are.\n\tsegments.push(...panelShellHintSegments(counts.shells ?? 0, agents !== undefined));\n\tconst help = navActionText(promptKeys, \"app.keys.help\");\n\tif (help) segments.push(`${help} keys`);\n\treturn segments;\n}\n\nexport function mainComposerKeys(state: MainComposerKeyState): NavKey[] {\n\tconst agentRows = state.agentRows ?? 0;\n\treturn [\n\t\t{ keys: \"enter\", label: \"send the prompt\" },\n\t\t...(state.working ? [{ action: \"app.interrupt\", label: \"interrupt the agent's turn\" }] : []),\n\t\t...(agentRows > 0 ? [{ action: \"app.agents.focus\", label: \"agents, on an empty prompt\" }] : []),\n\t\t{ keys: \"/\", label: \"commands, at the start of the prompt\" },\n\t\t{ keys: \"@\", label: \"insert a file path\" },\n\t\t{ action: \"app.history.search\", label: \"search past prompts\" },\n\t\t{ keys: \"pgup/pgdn\", label: \"scroll\" },\n\t\t{ action: \"tui.altScreen.bottom\", label: \"jump to the latest message\" },\n\t\t{ action: \"app.tools.expand\", label: \"expand tool output\" },\n\t\t{ action: \"app.thinking.toggle\", label: \"show or hide thinking\" },\n\t\t{ action: \"app.agents.chord\", label: \"then the stop-all key: stop all background work\" },\n\t\t{ action: \"app.keys.help\", label: \"keys, on an empty prompt\" },\n\t];\n}\n\nexport class MainComposerKeyOverlay implements Component {\n\tprivate readonly keybindings: NavKeybindings | undefined;\n\tprivate readonly state: () => MainComposerKeyState;\n\tprivate readonly close: () => void;\n\n\tconstructor(keybindings: NavKeybindings | undefined, state: () => MainComposerKeyState, close: () => void) {\n\t\tthis.keybindings = keybindings;\n\t\tthis.state = state;\n\t\tthis.close = close;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst current = this.state();\n\t\tconst state =\n\t\t\tcurrent.agentRows !== undefined\n\t\t\t\t? current\n\t\t\t\t: { ...current, agentRows: resolveAgentCounts(this.keybindings).total };\n\t\treturn renderNavKeyOverlay(\n\t\t\t\"keys\",\n\t\t\tmainComposerKeys(state),\n\t\t\twidth,\n\t\t\t{\n\t\t\t\tdim: (text) => theme.fg(\"dim\", text),\n\t\t\t\ttext: (text) => theme.fg(\"text\", text),\n\t\t\t\tmuted: (text) => theme.fg(\"muted\", text),\n\t\t\t\tborder: (text) => theme.fg(\"borderMuted\", text),\n\t\t\t\tbold: (text) => theme.bold(text),\n\t\t\t},\n\t\t\tpromptKeybindings(this.keybindings),\n\t\t);\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (data === \"\\x1b\" || isNavHelpKey(this.keybindings, data) || this.keybindings?.matches(data, \"app.interrupt\")) {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\tinvalidate(): void {}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/mermaid.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AAI3D,KAAK,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC;AAEpD,UAAU,yBAAyB;IAClC,OAAO,EAAE,MAAM,oBAAoB,CAAC;IACpC,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAoDD,uGAAuG;AACvG,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,yBAAyB,GAAG,mBAAmB,CAmCxG"}
1
+ {"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/mermaid.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AAI3D,KAAK,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC;AAEpD,UAAU,yBAAyB;IAClC,OAAO,EAAE,MAAM,oBAAoB,CAAC;IACpC,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AA0DD,uGAAuG;AACvG,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,yBAAyB,GAAG,mBAAmB,CAmCxG"}
@@ -25,16 +25,22 @@ function codeSpan(line) {
25
25
  }
26
26
  function themedLines(art, theme) {
27
27
  const sgrParameters = (color) => Array.from(theme.getFgAnsi(color).matchAll(/\x1b\[([0-9;]*)m/g), (match) => match[1]).join(";");
28
- const ansiTheme = {
29
- border: sgrParameters("borderMuted"),
30
- text: sgrParameters("text"),
31
- edge: sgrParameters("accent"),
32
- edgeLabel: sgrParameters("text"),
33
- title: `1;${sgrParameters("accent")}`,
34
- };
28
+ // With color turned off (NO_COLOR, FORCE_COLOR=0) the theme has no sequences: the diagram, its author classes
29
+ // included, renders unstyled and keeps its links.
30
+ const colored = theme.getFgAnsi("text") !== "";
31
+ const ansiTheme = colored
32
+ ? {
33
+ border: sgrParameters("borderMuted"),
34
+ text: sgrParameters("text"),
35
+ edge: sgrParameters("accent"),
36
+ edgeLabel: sgrParameters("text"),
37
+ title: `1;${sgrParameters("accent")}`,
38
+ }
39
+ : {};
35
40
  const linkLabels = getCapabilities().hyperlinks;
36
41
  const displayArt = {
37
42
  ...art,
43
+ ...(colored ? {} : { classDefs: {} }),
38
44
  // Only OSC 8 the label text, not the whole box.
39
45
  styled: art.styled.map((row) => row.map((span) => {
40
46
  if (span.href === undefined || (linkLabels && span.role === "text"))
@@ -1 +1 @@
1
- {"version":3,"file":"mermaid.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAc,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAmC,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAKjF,MAAM,cAAc,GAAG,IAAI,MAAM,EAAE,CAAC;AASpC,SAAS,SAAS,CAAC,KAAY;IAC9B,OAAO,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,SAAS,CAAC;AACpG,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC7B,yFAAyF;IACzF,6EAA6E;IAC7E,yCAAyC;IACzC,MAAM,OAAO,GAAG,IAAI,IAAI,QAAQ,CAAC;IACjC,wEAAwE;IACxE,mFAAmF;IACnF,wEAAwE;IACxE,4EAA4E;IAC5E,oEAAoE;IACpE,sDAAsD;IACtD,2CAA2C;IAC3C,6CAA6C;IAC7C,2CAA2C;IAC3C,MAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC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AAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrD,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpF,MAAM,OAAO,GAAG,iCAAiC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC;gBAC5E,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gBACrF,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;YACvD,CAAC;YACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;YAC1E,+DAA+D;YAC/D,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAChD,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { getCapabilities, Marked, type Token } from \"@bastani/atomic-tui\";\nimport { type AnsiTheme, type MermaidArt, render, toAnsi } from \"lovely-mermaid\";\nimport type { MarkdownTransformer } from \"../../../core/extensions/types.ts\";\nimport type { MermaidRenderingMode } from \"../../../core/settings-manager.ts\";\nimport type { Theme, ThemeColor } from \"../theme/theme.js\";\n\nconst markdownParser = new Marked();\n\ntype MermaidTheme = Pick<Theme, \"fg\" | \"getFgAnsi\">;\n\ninterface MermaidTransformerOptions {\n\tgetMode: () => MermaidRenderingMode;\n\ttheme?: MermaidTheme;\n}\n\nfunction isMermaid(token: Token): token is Token & { type: \"code\"; text: string; lang?: string } {\n\treturn token.type === \"code\" && token.lang?.trim().split(/\\s+/, 1)[0]?.toLowerCase() === \"mermaid\";\n}\n\nfunction codeSpan(line: string): string {\n\t// Encode each diagram row as inline code (` ... `) so Markdown preserves its spacing and\n\t// box-drawing characters. Use a non-breaking space for blank rows because an\n\t// empty code span has no visible height.\n\tconst content = line || \"\\u00a0\";\n\t// CommonMark code spans use matching backtick delimiters, so choose one\n\t// longer than any backtick run in the content (``hel`lo`` -> <code>hel`lo</code>).\n\t// If the content starts or ends with a backtick, separating it from the\n\t// delimiter with a space keeps that backtick as content; CommonMark removes\n\t// the padding when rendering (`` `edge` `` -> <code>`edge`</code>).\n\t// Mermaid labels can preserve backticks, for example:\n\t// `┌──────────────┐ ┌──────────────┐`\n\t// ```│ plain ` tick ├───▶│ two `` ticks │```\n\t// `└──────────────┘ └──────────────┘`\n\tconst longestBacktickRun = Math.max(0, ...Array.from(content.matchAll(/`+/g), (match) => match[0].length));\n\tconst fence = \"`\".repeat(longestBacktickRun + 1);\n\tconst padding = content.startsWith(\"`\") || content.endsWith(\"`\") ? \" \" : \"\";\n\treturn `${fence}${padding}${content}${padding}${fence}`;\n}\n\nfunction themedLines(art: MermaidArt, theme: MermaidTheme): string[] {\n\tconst sgrParameters = (color: ThemeColor) =>\n\t\tArray.from(theme.getFgAnsi(color).matchAll(/\\x1b\\[([0-9;]*)m/g), (match) => match[1]).join(\";\");\n\tconst ansiTheme: AnsiTheme = {\n\t\tborder: sgrParameters(\"borderMuted\"),\n\t\ttext: sgrParameters(\"text\"),\n\t\tedge: sgrParameters(\"accent\"),\n\t\tedgeLabel: sgrParameters(\"text\"),\n\t\ttitle: `1;${sgrParameters(\"accent\")}`,\n\t};\n\tconst linkLabels = getCapabilities().hyperlinks;\n\tconst displayArt: MermaidArt = {\n\t\t...art,\n\t\t// Only OSC 8 the label text, not the whole box.\n\t\tstyled: art.styled.map((row) =>\n\t\t\trow.map((span) => {\n\t\t\t\tif (span.href === undefined || (linkLabels && span.role === \"text\")) return span;\n\t\t\t\tconst unlinked = { ...span };\n\t\t\t\tdelete unlinked.href;\n\t\t\t\treturn unlinked;\n\t\t\t}),\n\t\t),\n\t};\n\treturn toAnsi(displayArt, ansiTheme);\n}\n\n/** Create a transformer that replaces top-level Mermaid code blocks with Unicode terminal diagrams. */\nexport function createMermaidMarkdownTransformer(options: MermaidTransformerOptions): MarkdownTransformer {\n\treturn (markdown, context) => {\n\t\tconst mode = options.getMode();\n\t\t// Diagrams render in user and assistant text and in model-written summaries, not in thinking or other surfaces.\n\t\tif (\n\t\t\tmode === \"off\" ||\n\t\t\t(context.messageType !== \"user\" && context.messageType !== \"assistant\" && context.messageType !== \"summary\") ||\n\t\t\t(context.isStreaming && mode !== \"streaming\")\n\t\t) {\n\t\t\treturn markdown;\n\t\t}\n\n\t\treturn markdownParser\n\t\t\t.lexer(markdown)\n\t\t\t.map((token) => {\n\t\t\t\tif (!isMermaid(token)) return token.raw;\n\t\t\t\tlet art: MermaidArt | null;\n\t\t\t\ttry {\n\t\t\t\t\tart = render(token.text);\n\t\t\t\t} catch {\n\t\t\t\t\treturn token.raw;\n\t\t\t\t}\n\t\t\t\tif (!art || art.width > context.availableWidth) return token.raw;\n\t\t\t\tif (!context.isStreaming && art.warnings.length > 0) {\n\t\t\t\t\tconst suffix = art.warnings.length > 1 ? ` (+${art.warnings.length - 1} more)` : \"\";\n\t\t\t\t\tconst warning = `Mermaid diagram not rendered: ${art.warnings[0]}${suffix}`;\n\t\t\t\t\tconst styledWarning = options.theme ? options.theme.fg(\"warning\", warning) : warning;\n\t\t\t\t\treturn `${token.raw}\\n${codeSpan(styledWarning)} \\n`;\n\t\t\t\t}\n\t\t\t\tconst lines = options.theme ? themedLines(art, options.theme) : art.plain;\n\t\t\t\t// Markdown hard breaks keep every diagram row on its own line.\n\t\t\t\treturn `${lines.map(codeSpan).join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IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrD,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpF,MAAM,OAAO,GAAG,iCAAiC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC;gBAC5E,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gBACrF,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;YACvD,CAAC;YACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;YAC1E,+DAA+D;YAC/D,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAChD,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC;AACH,CAAC","sourcesContent":["import { getCapabilities, Marked, type Token } from \"@bastani/atomic-tui\";\nimport { type AnsiTheme, type MermaidArt, render, toAnsi } from \"lovely-mermaid\";\nimport type { MarkdownTransformer } from \"../../../core/extensions/types.ts\";\nimport type { MermaidRenderingMode } from \"../../../core/settings-manager.ts\";\nimport type { Theme, ThemeColor } from \"../theme/theme.js\";\n\nconst markdownParser = new Marked();\n\ntype MermaidTheme = Pick<Theme, \"fg\" | \"getFgAnsi\">;\n\ninterface MermaidTransformerOptions {\n\tgetMode: () => MermaidRenderingMode;\n\ttheme?: MermaidTheme;\n}\n\nfunction isMermaid(token: Token): token is Token & { type: \"code\"; text: string; lang?: string } {\n\treturn token.type === \"code\" && token.lang?.trim().split(/\\s+/, 1)[0]?.toLowerCase() === \"mermaid\";\n}\n\nfunction codeSpan(line: string): string {\n\t// Encode each diagram row as inline code (` ... `) so Markdown preserves its spacing and\n\t// box-drawing characters. Use a non-breaking space for blank rows because an\n\t// empty code span has no visible height.\n\tconst content = line || \"\\u00a0\";\n\t// CommonMark code spans use matching backtick delimiters, so choose one\n\t// longer than any backtick run in the content (``hel`lo`` -> <code>hel`lo</code>).\n\t// If the content starts or ends with a backtick, separating it from the\n\t// delimiter with a space keeps that backtick as content; CommonMark removes\n\t// the padding when rendering (`` `edge` `` -> <code>`edge`</code>).\n\t// Mermaid labels can preserve backticks, for example:\n\t// `┌──────────────┐ ┌──────────────┐`\n\t// ```│ plain ` tick ├───▶│ two `` ticks │```\n\t// `└──────────────┘ └──────────────┘`\n\tconst longestBacktickRun = Math.max(0, ...Array.from(content.matchAll(/`+/g), (match) => match[0].length));\n\tconst fence = \"`\".repeat(longestBacktickRun + 1);\n\tconst padding = content.startsWith(\"`\") || content.endsWith(\"`\") ? \" \" : \"\";\n\treturn `${fence}${padding}${content}${padding}${fence}`;\n}\n\nfunction themedLines(art: MermaidArt, theme: MermaidTheme): string[] {\n\tconst sgrParameters = (color: ThemeColor) =>\n\t\tArray.from(theme.getFgAnsi(color).matchAll(/\\x1b\\[([0-9;]*)m/g), (match) => match[1]).join(\";\");\n\t// With color turned off (NO_COLOR, FORCE_COLOR=0) the theme has no sequences: the diagram, its author classes\n\t// included, renders unstyled and keeps its links.\n\tconst colored = theme.getFgAnsi(\"text\") !== \"\";\n\tconst ansiTheme: AnsiTheme = colored\n\t\t? {\n\t\t\t\tborder: sgrParameters(\"borderMuted\"),\n\t\t\t\ttext: sgrParameters(\"text\"),\n\t\t\t\tedge: sgrParameters(\"accent\"),\n\t\t\t\tedgeLabel: sgrParameters(\"text\"),\n\t\t\t\ttitle: `1;${sgrParameters(\"accent\")}`,\n\t\t\t}\n\t\t: {};\n\tconst linkLabels = getCapabilities().hyperlinks;\n\tconst displayArt: MermaidArt = {\n\t\t...art,\n\t\t...(colored ? {} : { classDefs: {} }),\n\t\t// Only OSC 8 the label text, not the whole box.\n\t\tstyled: art.styled.map((row) =>\n\t\t\trow.map((span) => {\n\t\t\t\tif (span.href === undefined || (linkLabels && span.role === \"text\")) return span;\n\t\t\t\tconst unlinked = { ...span };\n\t\t\t\tdelete unlinked.href;\n\t\t\t\treturn unlinked;\n\t\t\t}),\n\t\t),\n\t};\n\treturn toAnsi(displayArt, ansiTheme);\n}\n\n/** Create a transformer that replaces top-level Mermaid code blocks with Unicode terminal diagrams. */\nexport function createMermaidMarkdownTransformer(options: MermaidTransformerOptions): MarkdownTransformer {\n\treturn (markdown, context) => {\n\t\tconst mode = options.getMode();\n\t\t// Diagrams render in user and assistant text and in model-written summaries, not in thinking or other surfaces.\n\t\tif (\n\t\t\tmode === \"off\" ||\n\t\t\t(context.messageType !== \"user\" && context.messageType !== \"assistant\" && context.messageType !== \"summary\") ||\n\t\t\t(context.isStreaming && mode !== \"streaming\")\n\t\t) {\n\t\t\treturn markdown;\n\t\t}\n\n\t\treturn markdownParser\n\t\t\t.lexer(markdown)\n\t\t\t.map((token) => {\n\t\t\t\tif (!isMermaid(token)) return token.raw;\n\t\t\t\tlet art: MermaidArt | null;\n\t\t\t\ttry {\n\t\t\t\t\tart = render(token.text);\n\t\t\t\t} catch {\n\t\t\t\t\treturn token.raw;\n\t\t\t\t}\n\t\t\t\tif (!art || art.width > context.availableWidth) return token.raw;\n\t\t\t\tif (!context.isStreaming && art.warnings.length > 0) {\n\t\t\t\t\tconst suffix = art.warnings.length > 1 ? ` (+${art.warnings.length - 1} more)` : \"\";\n\t\t\t\t\tconst warning = `Mermaid diagram not rendered: ${art.warnings[0]}${suffix}`;\n\t\t\t\t\tconst styledWarning = options.theme ? options.theme.fg(\"warning\", warning) : warning;\n\t\t\t\t\treturn `${token.raw}\\n${codeSpan(styledWarning)} \\n`;\n\t\t\t\t}\n\t\t\t\tconst lines = options.theme ? themedLines(art, options.theme) : art.plain;\n\t\t\t\t// Markdown hard breaks keep every diagram row on its own line.\n\t\t\t\treturn `${lines.map(codeSpan).join(\" \\n\")}\\n`;\n\t\t\t})\n\t\t\t.join(\"\");\n\t};\n}\n"]}
@@ -1,7 +1,11 @@
1
1
  import { type Component } from "@bastani/atomic-tui";
2
2
  import { type ThemeColor } from "../theme/theme.js";
3
- /** How the subject of a notice ended or stands. A started subject reads as `success`. */
4
- export type NoticeStatus = "success" | "failure" | "stopped" | "warning" | "paused" | "running" | "info";
3
+ /**
4
+ * How the subject of a notice ended or stands. A started subject reads as `success`; `waiting` is a subagent released
5
+ * while it waits on a call, which wakes by itself when that call finishes; `heartbeat` marks a periodic check on work
6
+ * that is still running.
7
+ */
8
+ export type NoticeStatus = "success" | "failure" | "stopped" | "warning" | "paused" | "waiting" | "running" | "info" | "heartbeat";
5
9
  /**
6
10
  * One notice line: what finished, how it ended, and a few dim facts. Background commands, subagents, workflow runs
7
11
  * and stopped tasks all report through it, in the main chat, a workflow stage's chat and a subagent's view alike.
@@ -18,6 +22,10 @@ export interface NoticeLineSpec {
18
22
  readonly meta?: readonly string[];
19
23
  /** What expanding the line (ctrl+o) shows under it, one or more lines. */
20
24
  readonly detail?: string;
25
+ /** Columns before the notice, from the outputPad setting; 1 when left out. */
26
+ readonly outputPad?: number;
27
+ /** While collapsed, count the hidden detail lines under the line with the expand key (`… +N lines (ctrl+o to expand)`). */
28
+ readonly countHiddenDetail?: boolean;
21
29
  }
22
30
  /** The marker and colour of each status, so a status reads without colour too. */
23
31
  export declare const STATUS_MARKERS: Readonly<Record<NoticeStatus, {
@@ -1 +1 @@
1
- {"version":3,"file":"notice-line.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/notice-line.ts"],"names":[],"mappings":"AAAA,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AAC3C,eAAO,MAAM,aAAa,UAAU,CAAC;AAwBrC,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAG3D;AAYD,0GAA0G;AAC1G,qBAAa,UAAW,YAAW,SAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IACtC,OAAO,CAAC,QAAQ,CAAU;IAE1B,YAAY,IAAI,EAAE,cAAc,EAAE,QAAQ,UAAQ,EAGjD;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAEnC;IAED,UAAU,IAAI,IAAI,CAAG;IAErB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAsB9B;CACD"}
@@ -1,7 +1,7 @@
1
1
  import { Text, truncateToWidth, visibleWidth } from "@bastani/atomic-tui";
2
2
  import { terminalDisplayText } from "../../../utils/terminal-text.js";
3
3
  import { theme } from "../theme/theme.js";
4
- import { ToolBlock } from "./tool-block.js";
4
+ import { collapseToolBlockLines, ToolBlock } from "./tool-block.js";
5
5
  /** The marker and colour of each status, so a status reads without colour too. */
6
6
  export const STATUS_MARKERS = {
7
7
  success: { glyph: "●", color: "success" },
@@ -9,8 +9,10 @@ export const STATUS_MARKERS = {
9
9
  stopped: { glyph: "◼", color: "muted" },
10
10
  warning: { glyph: "!", color: "warning" },
11
11
  paused: { glyph: "⏸", color: "muted" },
12
+ waiting: { glyph: "◌", color: "dim" },
12
13
  running: { glyph: "∀", color: "accent" },
13
14
  info: { glyph: "›", color: "muted" },
15
+ heartbeat: { glyph: "♥", color: "muted" },
14
16
  };
15
17
  export const DETAIL_FIRST_PREFIX = " ⎿ ";
16
18
  export const DETAIL_PREFIX = " ";
@@ -63,7 +65,8 @@ export class NoticeLine {
63
65
  render(width) {
64
66
  if (width < 1)
65
67
  return [];
66
- const subject = fittedSubject(this.spec, Math.max(1, width - 1));
68
+ const pad = Math.max(0, Math.min(Math.floor(this.spec.outputPad ?? 1), Math.floor(width) - 1));
69
+ const subject = fittedSubject(this.spec, Math.max(1, width - pad));
67
70
  const title = `${oneLine(this.spec.label)}${quoted(subject)}${outcomeText(this.spec.outcome)}`;
68
71
  const detail = this.spec.detail === undefined ? "" : terminalDisplayText(this.spec.detail).replaceAll("\t", " ").trimEnd();
69
72
  const safeDetail = detail.replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, " ");
@@ -71,7 +74,14 @@ export class NoticeLine {
71
74
  status: this.spec.status,
72
75
  title: new Text(title, 0, 0),
73
76
  meta: this.spec.meta?.map(oneLine).filter(Boolean),
74
- details: this.expanded && safeDetail !== "" ? new Text(theme.fg("muted", safeDetail), 0, 0) : undefined,
77
+ details: safeDetail === ""
78
+ ? undefined
79
+ : this.expanded
80
+ ? new Text(theme.fg("muted", safeDetail), 0, 0)
81
+ : this.spec.countHiddenDetail
82
+ ? new Text(collapseToolBlockLines(safeDetail.split("\n"), 0, false).join("\n"), 0, 0)
83
+ : undefined,
84
+ outputPad: this.spec.outputPad,
75
85
  }).render(width);
76
86
  }
77
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notice-line.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/notice-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAmB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAuB5C,kFAAkF;AAClF,MAAM,CAAC,MAAM,cAAc,GAA2F;IACrH,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE;IACzC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;IACvC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EA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AQ,IAAI,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;SACvG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;CACD","sourcesContent":["import { type Component, Text, truncateToWidth, visibleWidth } from \"@bastani/atomic-tui\";\nimport { terminalDisplayText } from \"../../../utils/terminal-text.ts\";\nimport { type ThemeColor, theme } from \"../theme/theme.js\";\nimport { ToolBlock } from \"./tool-block.ts\";\n\n/** How the subject of a notice ended or stands. A started subject reads as `success`. */\nexport type NoticeStatus = \"success\" | \"failure\" | \"stopped\" | \"warning\" | \"paused\" | \"running\" | \"info\";\n\n/**\n * One notice line: what finished, how it ended, and a few dim facts. Background commands, subagents, workflow runs\n * and stopped tasks all report through it, in the main chat, a workflow stage's chat and a subagent's view alike.\n */\nexport interface NoticeLineSpec {\n\treadonly status: NoticeStatus;\n\t/** What it is: `Background command`, `Agent`, `Workflow`, `Task`. */\n\treadonly label: string;\n\t/** Its name, quoted after the label; shortened first when the line is too narrow. */\n\treadonly subject?: string;\n\t/** How it ended: `completed (exit code 0)`, `finished`, `failed (exit code 1)`, `was stopped by the user`. */\n\treadonly outcome: string;\n\t/** Dim facts after the outcome, joined with ` · `: a duration, a stage, a token count. */\n\treadonly meta?: readonly string[];\n\t/** What expanding the line (ctrl+o) shows under it, one or more lines. */\n\treadonly detail?: string;\n}\n\n/** The marker and colour of each status, so a status reads without colour too. */\nexport const STATUS_MARKERS: Readonly<Record<NoticeStatus, { readonly glyph: string; readonly color: ThemeColor }>> = {\n\tsuccess: { glyph: \"●\", color: \"success\" },\n\tfailure: { glyph: \"✗\", color: \"error\" },\n\tstopped: { glyph: \"◼\", color: \"muted\" },\n\twarning: { glyph: \"!\", color: \"warning\" },\n\tpaused: { glyph: \"⏸\", color: \"muted\" },\n\trunning: { glyph: \"∀\", color: \"accent\" },\n\tinfo: { glyph: \"›\", color: \"muted\" },\n};\n\nexport const DETAIL_FIRST_PREFIX = \" ⎿ \";\nexport const DETAIL_PREFIX = \" \";\n\n/** One line of display text: no terminal controls, no line breaks. */\nfunction oneLine(value: string): string {\n\treturn terminalDisplayText(value)\n\t\t.replace(/[\\x00-\\x1f\\x7f-\\x9f]/g, \" \")\n\t\t.replace(/ {2,}/g, \" \")\n\t\t.trim();\n}\n\nfunction quoted(subject: string | undefined): string {\n\treturn subject === undefined || subject === \"\" ? \"\" : ` \"${subject}\"`;\n}\n\nfunction outcomeText(outcome: string): string {\n\tconst text = oneLine(outcome);\n\treturn text === \"\" ? \"\" : ` ${text}`;\n}\n\nfunction metaText(meta: readonly string[] | undefined): string {\n\tconst facts = (meta ?? []).map(oneLine).filter(Boolean);\n\treturn facts.length === 0 ? \"\" : ` · ${facts.join(\" · \")}`;\n}\n\n/** The notice as plain text, one line, as a screen reader or a log reads it. */\nexport function noticeLineText(spec: NoticeLineSpec): string {\n\tconst subject = spec.subject === undefined ? undefined : oneLine(spec.subject);\n\treturn `${STATUS_MARKERS[spec.status].glyph} ${oneLine(spec.label)}${quoted(subject)}${outcomeText(spec.outcome)}${metaText(spec.meta)}`;\n}\n\n/** The subject shortened so the whole line fits `width`, or undefined when even one character of it does not. */\nfunction fittedSubject(spec: NoticeLineSpec, width: number): string | undefined {\n\tconst subject = spec.subject === undefined ? undefined : oneLine(spec.subject);\n\tif (subject === undefined || subject === \"\") return subject;\n\tconst full = noticeLineText(spec);\n\tif (visibleWidth(full) <= width) return subject;\n\tconst room = visibleWidth(subject) - (visibleWidth(full) - width);\n\treturn room >= 2 ? truncateToWidth(subject, room, \"…\") : undefined;\n}\n\n/** A notice in the transcript: exactly one line collapsed; expanded, the line and its detail under it. */\nexport class NoticeLine implements Component {\n\tprivate readonly spec: NoticeLineSpec;\n\tprivate expanded: boolean;\n\n\tconstructor(spec: NoticeLineSpec, expanded = false) {\n\t\tthis.spec = spec;\n\t\tthis.expanded = expanded;\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tif (width < 1) return [];\n\t\tconst subject = fittedSubject(this.spec, Math.max(1, width - 1));\n\t\tconst title = `${oneLine(this.spec.label)}${quoted(subject)}${outcomeText(this.spec.outcome)}`;\n\t\tconst detail =\n\t\t\tthis.spec.detail === undefined ? \"\" : terminalDisplayText(this.spec.detail).replaceAll(\"\\t\", \" \").trimEnd();\n\t\tconst safeDetail = detail.replace(/[\\x00-\\x08\\x0b-\\x1f\\x7f-\\x9f]/g, \" \");\n\t\treturn new ToolBlock({\n\t\t\tstatus: this.spec.status,\n\t\t\ttitle: new Text(title, 0, 0),\n\t\t\tmeta: this.spec.meta?.map(oneLine).filter(Boolean),\n\t\t\tdetails: this.expanded && safeDetail !== \"\" ? new Text(theme.fg(\"muted\", safeDetail), 0, 0) : undefined,\n\t\t}).render(width);\n\t}\n}\n"]}
1
+ {"version":3,"file":"notice-line.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/notice-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAmB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAwCpE,kFAAkF;AAClF,MAAM,CAAC,MAAM,cAAc,GAA2F;IACrH,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE;IACzC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;IACvC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAA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UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;QACzE,OAAO,IAAI,SAAS,CAAC;YACpB,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;YACxB,KAAK,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAC5B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;YAClD,OAAO,EACN,UAAU,KAAK,EAAE;gBAChB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,IAAI,CAAC,QAAQ;oBACd,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;oBAC/C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB;wBAC5B,CAAC,CAAC,IAAI,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;wBACrF,CAAC,CAAC,SAAS;YACf,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS;SAC9B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;CACD","sourcesContent":["import { type Component, Text, truncateToWidth, visibleWidth } from \"@bastani/atomic-tui\";\nimport { terminalDisplayText } from \"../../../utils/terminal-text.ts\";\nimport { type ThemeColor, theme } from \"../theme/theme.js\";\nimport { collapseToolBlockLines, ToolBlock } from \"./tool-block.ts\";\n\n/**\n * How the subject of a notice ended or stands. A started subject reads as `success`; `waiting` is a subagent released\n * while it waits on a call, which wakes by itself when that call finishes; `heartbeat` marks a periodic check on work\n * that is still running.\n */\nexport type NoticeStatus =\n\t| \"success\"\n\t| \"failure\"\n\t| \"stopped\"\n\t| \"warning\"\n\t| \"paused\"\n\t| \"waiting\"\n\t| \"running\"\n\t| \"info\"\n\t| \"heartbeat\";\n\n/**\n * One notice line: what finished, how it ended, and a few dim facts. Background commands, subagents, workflow runs\n * and stopped tasks all report through it, in the main chat, a workflow stage's chat and a subagent's view alike.\n */\nexport interface NoticeLineSpec {\n\treadonly status: NoticeStatus;\n\t/** What it is: `Background command`, `Agent`, `Workflow`, `Task`. */\n\treadonly label: string;\n\t/** Its name, quoted after the label; shortened first when the line is too narrow. */\n\treadonly subject?: string;\n\t/** How it ended: `completed (exit code 0)`, `finished`, `failed (exit code 1)`, `was stopped by the user`. */\n\treadonly outcome: string;\n\t/** Dim facts after the outcome, joined with ` · `: a duration, a stage, a token count. */\n\treadonly meta?: readonly string[];\n\t/** What expanding the line (ctrl+o) shows under it, one or more lines. */\n\treadonly detail?: string;\n\t/** Columns before the notice, from the outputPad setting; 1 when left out. */\n\treadonly outputPad?: number;\n\t/** While collapsed, count the hidden detail lines under the line with the expand key (`… +N lines (ctrl+o to expand)`). */\n\treadonly countHiddenDetail?: boolean;\n}\n\n/** The marker and colour of each status, so a status reads without colour too. */\nexport const STATUS_MARKERS: Readonly<Record<NoticeStatus, { readonly glyph: string; readonly color: ThemeColor }>> = {\n\tsuccess: { glyph: \"●\", color: \"success\" },\n\tfailure: { glyph: \"✗\", color: \"error\" },\n\tstopped: { glyph: \"◼\", color: \"muted\" },\n\twarning: { glyph: \"!\", color: \"warning\" },\n\tpaused: { glyph: \"⏸\", color: \"muted\" },\n\twaiting: { glyph: \"◌\", color: \"dim\" },\n\trunning: { glyph: \"∀\", color: \"accent\" },\n\tinfo: { glyph: \"›\", color: \"muted\" },\n\theartbeat: { glyph: \"♥\", color: \"muted\" },\n};\n\nexport const DETAIL_FIRST_PREFIX = \" ⎿ \";\nexport const DETAIL_PREFIX = \" \";\n\n/** One line of display text: no terminal controls, no line breaks. */\nfunction oneLine(value: string): string {\n\treturn terminalDisplayText(value)\n\t\t.replace(/[\\x00-\\x1f\\x7f-\\x9f]/g, \" \")\n\t\t.replace(/ {2,}/g, \" \")\n\t\t.trim();\n}\n\nfunction quoted(subject: string | undefined): string {\n\treturn subject === undefined || subject === \"\" ? \"\" : ` \"${subject}\"`;\n}\n\nfunction outcomeText(outcome: string): string {\n\tconst text = oneLine(outcome);\n\treturn text === \"\" ? \"\" : ` ${text}`;\n}\n\nfunction metaText(meta: readonly string[] | undefined): string {\n\tconst facts = (meta ?? []).map(oneLine).filter(Boolean);\n\treturn facts.length === 0 ? \"\" : ` · ${facts.join(\" · \")}`;\n}\n\n/** The notice as plain text, one line, as a screen reader or a log reads it. */\nexport function noticeLineText(spec: NoticeLineSpec): string {\n\tconst subject = spec.subject === undefined ? undefined : oneLine(spec.subject);\n\treturn `${STATUS_MARKERS[spec.status].glyph} ${oneLine(spec.label)}${quoted(subject)}${outcomeText(spec.outcome)}${metaText(spec.meta)}`;\n}\n\n/** The subject shortened so the whole line fits `width`, or undefined when even one character of it does not. */\nfunction fittedSubject(spec: NoticeLineSpec, width: number): string | undefined {\n\tconst subject = spec.subject === undefined ? undefined : oneLine(spec.subject);\n\tif (subject === undefined || subject === \"\") return subject;\n\tconst full = noticeLineText(spec);\n\tif (visibleWidth(full) <= width) return subject;\n\tconst room = visibleWidth(subject) - (visibleWidth(full) - width);\n\treturn room >= 2 ? truncateToWidth(subject, room, \"…\") : undefined;\n}\n\n/** A notice in the transcript: exactly one line collapsed; expanded, the line and its detail under it. */\nexport class NoticeLine implements Component {\n\tprivate readonly spec: NoticeLineSpec;\n\tprivate expanded: boolean;\n\n\tconstructor(spec: NoticeLineSpec, expanded = false) {\n\t\tthis.spec = spec;\n\t\tthis.expanded = expanded;\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tif (width < 1) return [];\n\t\tconst pad = Math.max(0, Math.min(Math.floor(this.spec.outputPad ?? 1), Math.floor(width) - 1));\n\t\tconst subject = fittedSubject(this.spec, Math.max(1, width - pad));\n\t\tconst title = `${oneLine(this.spec.label)}${quoted(subject)}${outcomeText(this.spec.outcome)}`;\n\t\tconst detail =\n\t\t\tthis.spec.detail === undefined ? \"\" : terminalDisplayText(this.spec.detail).replaceAll(\"\\t\", \" \").trimEnd();\n\t\tconst safeDetail = detail.replace(/[\\x00-\\x08\\x0b-\\x1f\\x7f-\\x9f]/g, \" \");\n\t\treturn new ToolBlock({\n\t\t\tstatus: this.spec.status,\n\t\t\ttitle: new Text(title, 0, 0),\n\t\t\tmeta: this.spec.meta?.map(oneLine).filter(Boolean),\n\t\t\tdetails:\n\t\t\t\tsafeDetail === \"\"\n\t\t\t\t\t? undefined\n\t\t\t\t\t: this.expanded\n\t\t\t\t\t\t? new Text(theme.fg(\"muted\", safeDetail), 0, 0)\n\t\t\t\t\t\t: this.spec.countHiddenDetail\n\t\t\t\t\t\t\t? new Text(collapseToolBlockLines(safeDetail.split(\"\\n\"), 0, false).join(\"\\n\"), 0, 0)\n\t\t\t\t\t\t\t: undefined,\n\t\t\toutputPad: this.spec.outputPad,\n\t\t}).render(width);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"provider-brand.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/provider-brand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAyC,KAAK,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAItF,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;AAE7E,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAGxF;AAYD,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAItE;AAID,8GAA8G;AAC9G,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,OAAO,GAAG,MAAM,IAAI,CAMpF"}
1
+ {"version":3,"file":"provider-brand.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/provider-brand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAyC,KAAK,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAItF,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;AAE7E,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAGxF;AAYD,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAMtE;AAID,8GAA8G;AAC9G,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,OAAO,GAAG,MAAM,IAAI,CAMpF"}
@@ -22,6 +22,9 @@ const OPENROUTER_GLOW = {
22
22
  const GLOW_PERIOD_MS = 2400;
23
23
  /** Colors `text` in OpenRouter's brand color, slowly brightening and dimming. */
24
24
  export function openRouterGlow(text, elapsedMs) {
25
+ // The theme's style level is 0 when NO_COLOR or FORCE_COLOR=0 turns color off.
26
+ if (theme.getStyleLevel() === 0)
27
+ return text;
25
28
  const { base, peak } = OPENROUTER_GLOW[isLightTheme(getCurrentThemeName()) ? "light" : "dark"];
26
29
  const amount = (1 - Math.cos((2 * Math.PI * elapsedMs) / GLOW_PERIOD_MS)) / 2;
27
30
  return `${foregroundAnsi(mixColors(base, peak, amount, "oklch"), theme.getColorMode())}${text}\x1b[39m`;
@@ -1 +1 @@
1
- {"version":3,"file":"provider-brand.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/provider-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kBAAkB,GAAG,EAAE,CAAC;AAE9B,8GAA8G;AAC9G,MAAM,UAAU,mBAAmB,CAAC,GAAQ,EAAE,WAA0B;IACvE,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,WAAW,EAAE;YAAE,GAAG,CAAC,aAAa,EAAE,CAAC;IACxC,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACvB,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAChB,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC","sourcesContent":["/**\n * Animated brand styles for the names of preferred partner providers in selectors: OpenRouter glows in its brand\n * color. Selectors apply them to the selected row only.\n */\n\nimport { foregroundAnsi, mixColors, parseColor, type TUI } from \"@bastani/atomic-tui\";\nimport { getCurrentThemeName } from \"../theme/global-theme.ts\";\nimport { isLightTheme, theme } from \"../theme/theme.js\";\n\n/** Colors `text` for animation time `elapsedMs`. */\nexport type ProviderBrandStyle = (text: string, elapsedMs: number) => string;\n\n/** The animated style of a provider's name, or `undefined` when the provider has none. */\nexport function getProviderBrandStyle(providerId: string): ProviderBrandStyle | undefined {\n\tif (providerId === \"openrouter\") return openRouterGlow;\n\treturn undefined;\n}\n\n/**\n * OpenRouter's brand colors per theme appearance: lime on dark backgrounds, violet on light ones, where lime would\n * be unreadable. The glow breathes between `base` and the brighter `peak`.\n */\nconst OPENROUTER_GLOW = {\n\tdark: { base: parseColor(\"#c6f243\"), peak: parseColor(\"#efffb0\") },\n\tlight: { base: parseColor(\"#5d32e1\"), peak: parseColor(\"#8f6bff\") },\n} as const;\nconst GLOW_PERIOD_MS = 2400;\n\n/** Colors `text` in OpenRouter's brand color, slowly brightening and dimming. */\nexport function openRouterGlow(text: string, elapsedMs: number): string {\n\tconst { base, peak } = OPENROUTER_GLOW[isLightTheme(getCurrentThemeName()) ? \"light\" : \"dark\"];\n\tconst amount = (1 - Math.cos((2 * Math.PI * elapsedMs) / GLOW_PERIOD_MS)) / 2;\n\treturn `${foregroundAnsi(mixColors(base, peak, amount, \"oklch\"), theme.getColorMode())}${text}\\x1b[39m`;\n}\n\nconst ANIMATION_FRAME_MS = 50;\n\n/** Re-renders `tui` every animation frame while `isAnimating()` holds; returns the function that stops it. */\nexport function startBrandAnimation(tui: TUI, isAnimating: () => boolean): () => void {\n\tconst timer = setInterval(() => {\n\t\tif (isAnimating()) tui.requestRender();\n\t}, ANIMATION_FRAME_MS);\n\ttimer.unref?.();\n\treturn () => clearInterval(timer);\n}\n"]}
1
+ {"version":3,"file":"provider-brand.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/provider-brand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAY,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKxD,0FAA0F;AAC1F,MAAM,UAAU,qBAAqB,CAAC,UAAkB;IACvD,IAAI,UAAU,KAAK,YAAY;QAAE,OAAO,cAAc,CAAC;IACvD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,eAAe,GAAG;IACvB,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE;IAClE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE;CAC1D,CAAC;AACX,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,iFAAiF;AACjF,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,SAAiB;IAC7D,+EAA+E;IAC/E,IAAI,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/F,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC;IAC9E,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,GAAG,IAAI,UAAU,CAAC;AACzG,CAAC;AAED,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,8GAA8G;AAC9G,MAAM,UAAU,mBAAmB,CAAC,GAAQ,EAAE,WAA0B;IACvE,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,WAAW,EAAE;YAAE,GAAG,CAAC,aAAa,EAAE,CAAC;IACxC,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACvB,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAChB,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC","sourcesContent":["/**\n * Animated brand styles for the names of preferred partner providers in selectors: OpenRouter glows in its brand\n * color. Selectors apply them to the selected row only.\n */\n\nimport { foregroundAnsi, mixColors, parseColor, type TUI } from \"@bastani/atomic-tui\";\nimport { getCurrentThemeName } from \"../theme/global-theme.ts\";\nimport { isLightTheme, theme } from \"../theme/theme.js\";\n\n/** Colors `text` for animation time `elapsedMs`. */\nexport type ProviderBrandStyle = (text: string, elapsedMs: number) => string;\n\n/** The animated style of a provider's name, or `undefined` when the provider has none. */\nexport function getProviderBrandStyle(providerId: string): ProviderBrandStyle | undefined {\n\tif (providerId === \"openrouter\") return openRouterGlow;\n\treturn undefined;\n}\n\n/**\n * OpenRouter's brand colors per theme appearance: lime on dark backgrounds, violet on light ones, where lime would\n * be unreadable. The glow breathes between `base` and the brighter `peak`.\n */\nconst OPENROUTER_GLOW = {\n\tdark: { base: parseColor(\"#c6f243\"), peak: parseColor(\"#efffb0\") },\n\tlight: { base: parseColor(\"#5d32e1\"), peak: parseColor(\"#8f6bff\") },\n} as const;\nconst GLOW_PERIOD_MS = 2400;\n\n/** Colors `text` in OpenRouter's brand color, slowly brightening and dimming. */\nexport function openRouterGlow(text: string, elapsedMs: number): string {\n\t// The theme's style level is 0 when NO_COLOR or FORCE_COLOR=0 turns color off.\n\tif (theme.getStyleLevel() === 0) return text;\n\tconst { base, peak } = OPENROUTER_GLOW[isLightTheme(getCurrentThemeName()) ? \"light\" : \"dark\"];\n\tconst amount = (1 - Math.cos((2 * Math.PI * elapsedMs) / GLOW_PERIOD_MS)) / 2;\n\treturn `${foregroundAnsi(mixColors(base, peak, amount, \"oklch\"), theme.getColorMode())}${text}\\x1b[39m`;\n}\n\nconst ANIMATION_FRAME_MS = 50;\n\n/** Re-renders `tui` every animation frame while `isAnimating()` holds; returns the function that stops it. */\nexport function startBrandAnimation(tui: TUI, isAnimating: () => boolean): () => void {\n\tconst timer = setInterval(() => {\n\t\tif (isAnimating()) tui.requestRender();\n\t}, ANIMATION_FRAME_MS);\n\ttimer.unref?.();\n\treturn () => clearInterval(timer);\n}\n"]}
@@ -1,14 +1,19 @@
1
- import { type Component } from "@bastani/atomic-tui";
1
+ import type { Component } from "@bastani/atomic-tui";
2
2
  import { type TaskHeartbeatDetails } from "../../../core/tasks/heartbeat-notice.js";
3
3
  /** The structured heartbeat a card was raised with, or `undefined` when the entry does not carry one. */
4
4
  export declare function heartbeatDetailsFrom(details: unknown): TaskHeartbeatDetails | undefined;
5
- /** Compact heartbeat card in the owning chat: one row per task, status and output lines when expanded. */
5
+ /** Tasks listed while a task heartbeat is collapsed; the rest are counted in one `… +N more` row. */
6
+ export declare const TASK_HEARTBEAT_COLLAPSED_TASKS = 5;
7
+ /**
8
+ * A task heartbeat in its chat, in the shared notice anatomy: `♥ Task heartbeat · N tasks still running`, one
9
+ * connector row per task, and each task's status and last output lines when expanded.
10
+ */
6
11
  export declare class TaskHeartbeatMessage implements Component {
7
12
  private readonly details;
8
13
  private readonly expanded;
9
- constructor(details: TaskHeartbeatDetails, expanded: boolean);
14
+ private readonly outputPad;
15
+ constructor(details: TaskHeartbeatDetails, expanded: boolean, outputPad?: number);
10
16
  invalidate(): void;
11
17
  render(width: number): string[];
12
- private renderContent;
13
18
  }
14
19
  //# sourceMappingURL=task-heartbeat-message.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"task-heartbeat-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/task-heartbeat-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,SAAS,EAAqC,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAGN,KAAK,oBAAoB,EAGzB,MAAM,yCAAyC,CAAC;AAoBjD,yGAAyG;AACzG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAUvF;AAID,0GAA0G;AAC1G,qBAAa,oBAAqB,YAAW,SAAS;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,YAAY,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,OAAO,EAG3D;IACD,UAAU,IAAI,IAAI,CAAG;IACrB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ9B;IACD,OAAO,CAAC,aAAa;CAuBrB"}
1
+ {"version":3,"file":"task-heartbeat-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/task-heartbeat-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAGN,KAAK,oBAAoB,EAGzB,MAAM,yCAAyC,CAAC;AAoBjD,yGAAyG;AACzG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAUvF;AAID,qGAAqG;AACrG,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,SAAS;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,YAAY,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,EAI/E;IACD,UAAU,IAAI,IAAI,CAAG;IACrB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA0B9B;CACD"}