omp-fabric 1.27.1 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +1 -1
  3. package/dist/chunks/{chunk-KIH3KLZU.js → chunk-C2YMZNT5.js} +5 -5
  4. package/dist/chunks/chunk-C2YMZNT5.js.map +7 -0
  5. package/dist/chunks/{chunk-OJZNMROB.js → chunk-DKXNUCM2.js} +36 -50
  6. package/dist/chunks/chunk-DKXNUCM2.js.map +7 -0
  7. package/dist/chunks/chunk-K3OSK6AX.js +132 -0
  8. package/dist/chunks/chunk-K3OSK6AX.js.map +7 -0
  9. package/dist/chunks/{chunk-2BOZMRT5.js → chunk-LK66YHVL.js} +32 -49
  10. package/dist/chunks/chunk-LK66YHVL.js.map +7 -0
  11. package/dist/chunks/chunk-MIGBZN2K.js +81 -0
  12. package/dist/chunks/chunk-MIGBZN2K.js.map +7 -0
  13. package/dist/chunks/chunk-O337ZL5J.js +277 -0
  14. package/dist/chunks/chunk-O337ZL5J.js.map +7 -0
  15. package/dist/chunks/chunk-T76MXSP4.js +32 -0
  16. package/dist/chunks/chunk-T76MXSP4.js.map +7 -0
  17. package/dist/chunks/{chunk-NOZBB266.js → chunk-XZIQGFF7.js} +9 -13
  18. package/dist/chunks/chunk-XZIQGFF7.js.map +7 -0
  19. package/dist/chunks/{chunk-4XLJPEI4.js → chunk-ZJ7HHWW4.js} +20 -41
  20. package/dist/chunks/chunk-ZJ7HHWW4.js.map +7 -0
  21. package/dist/core/approval-controller.d.ts.map +1 -1
  22. package/dist/fabric-exec-tool.d.ts.map +1 -1
  23. package/dist/fabric-runtime-state.js +12 -5
  24. package/dist/fabric-runtime-state.js.map +2 -2
  25. package/dist/host-compatibility.d.ts +1 -1
  26. package/dist/index.js +169 -164
  27. package/dist/index.js.map +3 -3
  28. package/dist/providers/omp-tools-provider.d.ts.map +1 -1
  29. package/dist/ui/arc-group.d.ts +1 -1
  30. package/dist/ui/arc-group.d.ts.map +1 -1
  31. package/dist/ui/code-preview-shell.d.ts +2 -2
  32. package/dist/ui/code-preview-shell.d.ts.map +1 -1
  33. package/dist/ui/controller.d.ts.map +1 -1
  34. package/dist/ui/conversation-chrome.d.ts +1 -5
  35. package/dist/ui/conversation-chrome.d.ts.map +1 -1
  36. package/dist/ui/conversation-chrome.js +2 -2
  37. package/dist/ui/conversation-queue.d.ts +3 -2
  38. package/dist/ui/conversation-queue.d.ts.map +1 -1
  39. package/dist/ui/conversation-render.d.ts +19 -23
  40. package/dist/ui/conversation-render.d.ts.map +1 -1
  41. package/dist/ui/conversation.d.ts +7 -17
  42. package/dist/ui/conversation.d.ts.map +1 -1
  43. package/dist/ui/conversation.js +317 -318
  44. package/dist/ui/conversation.js.map +3 -3
  45. package/dist/ui/core-tool-render.d.ts +1 -1
  46. package/dist/ui/core-tool-render.d.ts.map +1 -1
  47. package/dist/ui/dashboard-detail.d.ts +4 -4
  48. package/dist/ui/dashboard-detail.d.ts.map +1 -1
  49. package/dist/ui/dashboard-fabric-graph.d.ts +1 -1
  50. package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -1
  51. package/dist/ui/dashboard-presentation.d.ts +1 -1
  52. package/dist/ui/dashboard-presentation.d.ts.map +1 -1
  53. package/dist/ui/dashboard.d.ts +8 -8
  54. package/dist/ui/dashboard.d.ts.map +1 -1
  55. package/dist/ui/dashboard.js +207 -343
  56. package/dist/ui/dashboard.js.map +3 -3
  57. package/dist/ui/diff-background.d.ts +1 -1
  58. package/dist/ui/diff-background.d.ts.map +1 -1
  59. package/dist/ui/fabric-actor-delivery-selector.d.ts +4 -4
  60. package/dist/ui/fabric-actor-delivery-selector.d.ts.map +1 -1
  61. package/dist/ui/fabric-actor-tool-selector.d.ts +5 -6
  62. package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -1
  63. package/dist/ui/fabric-host-event-selector.d.ts +4 -4
  64. package/dist/ui/fabric-host-event-selector.d.ts.map +1 -1
  65. package/dist/ui/fabric-model-selector.d.ts +4 -6
  66. package/dist/ui/fabric-model-selector.d.ts.map +1 -1
  67. package/dist/ui/fabric-render.d.ts +6 -6
  68. package/dist/ui/fabric-render.d.ts.map +1 -1
  69. package/dist/ui/fabric-thinking-selector.d.ts +4 -7
  70. package/dist/ui/fabric-thinking-selector.d.ts.map +1 -1
  71. package/dist/ui/highlight.d.ts +2 -13
  72. package/dist/ui/highlight.d.ts.map +1 -1
  73. package/dist/ui/row-balance.d.ts +6 -6
  74. package/dist/ui/row-balance.d.ts.map +1 -1
  75. package/dist/ui/settings.d.ts +6 -3
  76. package/dist/ui/settings.d.ts.map +1 -1
  77. package/dist/ui/settings.js +234 -112
  78. package/dist/ui/settings.js.map +3 -3
  79. package/dist/ui/state-file-preview.d.ts +1 -1
  80. package/dist/ui/state-file-preview.d.ts.map +1 -1
  81. package/dist/ui/tui/input.d.ts +16 -0
  82. package/dist/ui/tui/input.d.ts.map +1 -0
  83. package/dist/ui/tui/rows.d.ts +24 -0
  84. package/dist/ui/tui/rows.d.ts.map +1 -0
  85. package/dist/ui/tui/select-list.d.ts +28 -0
  86. package/dist/ui/tui/select-list.d.ts.map +1 -0
  87. package/dist/ui/tui/settings-list.d.ts +38 -0
  88. package/dist/ui/tui/settings-list.d.ts.map +1 -0
  89. package/dist/ui/tui/text-field.d.ts +40 -0
  90. package/dist/ui/tui/text-field.d.ts.map +1 -0
  91. package/dist/ui/tui/view.d.ts +26 -0
  92. package/dist/ui/tui/view.d.ts.map +1 -0
  93. package/dist/ui/widget.d.ts +3 -3
  94. package/dist/ui/widget.d.ts.map +1 -1
  95. package/dist/worker.js +9 -0
  96. package/dist/worker.js.map +2 -2
  97. package/docs/interface.md +3 -3
  98. package/package.json +11 -11
  99. package/dist/chunks/chunk-2BOZMRT5.js.map +0 -7
  100. package/dist/chunks/chunk-4XLJPEI4.js.map +0 -7
  101. package/dist/chunks/chunk-G2IBGGBM.js +0 -42
  102. package/dist/chunks/chunk-G2IBGGBM.js.map +0 -7
  103. package/dist/chunks/chunk-KIH3KLZU.js.map +0 -7
  104. package/dist/chunks/chunk-NOZBB266.js.map +0 -7
  105. package/dist/chunks/chunk-OJZNMROB.js.map +0 -7
  106. package/dist/ui/symbol-theme.d.ts +0 -3
  107. package/dist/ui/symbol-theme.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.28.0
4
+
5
+ ### Changed (breaking)
6
+
7
+ - OMP 19.2.0 is the minimum host. OMP 19.2 replaced `@oh-my-pi/pi-tui` with a node-based TUI library and stopped re-exporting the old components from the `@oh-my-pi/pi-coding-agent` root, so 1.27.x fails to load there (`Export named 'truncateToWidth' not found`). The peer floor of pi-coding-agent, pi-natives and pi-tui moves from `>=18.4.4` to `>=19.2.0`, `MINIMUM_OMP_HOST_VERSION` from 18.4.4 to 19.2.0, and the host pins from 19.1.1 to 19.2.1. Hosts from 18.4.4 to 19.1.x stay on 1.27.x.
8
+ - The dashboard (`/fabric`) and the focused conversation (`/fabric chat`) open as full-screen overlays (`{ overlay: true, fullscreen: true }`). The old pi-tui positioning options (94% by 90% centered for the dashboard) no longer exist on the host.
9
+ - The conversation transcript is drawn by Fabric: the host no longer exposes its message, tool and summary components to extensions (none of the 1881 module ids in the 19.2.1 binary is under `pi-coding-agent/ui`). User prompts sit on the user message background, assistant text and thinking go through pi-tui Markdown, a tool with its own `renderCall` or `renderResult` (such as `fabric_exec`) draws itself, and other tools show a compact card with arguments and a result that the tool-expand key unfolds. Images inside tool results are no longer shown there, and `terminal.showImages` is no longer read.
10
+ - Mouse wheel scrolling in the conversation reaches Fabric through the host when OMP mouse reporting (`tui.mouse`) is on. Fabric no longer switches the terminal into mouse mode itself; with `tui.mouse` off, a terminal that turns the wheel into arrow keys on the alternate screen scrolls through the line keys.
11
+
12
+ ### Added
13
+
14
+ - `src/ui/tui/`: Fabric's own row primitives (`TextBlock`, `Stack`, `BlankRows`), a single and multi-line `TextField`, `SelectList` and `SettingsList`. Keys come from the pi-tui widget keymap that OMP keeps in sync with the user's keybindings (`select.*`, `editor.*`), and application actions (`app.tools.expand`, `app.message.followUp`, `tui.editor.pageUp`) from the host `KeybindingsManager`.
15
+ - `mountView` mounts a Fabric view as a pi-tui `canvas` node with a role painter and role widget, so key and paste events reach the view, repaints follow a signal, and wheel events reach `handleWheel` through the node's hit region.
16
+ - A Fabric view that throws while drawing shows one row, `⚠ Fabric view failed to render: <message>`, and reports the error once per failure streak; a throw while handling a key, paste or wheel event is reported the same way. The host only contains errors of the rows objects it mounts, and Fabric mounts its dashboard and conversation itself.
17
+
18
+ ### Removed
19
+
20
+ - `src/ui/symbol-theme.ts`, the copied pi-tui symbol table. Styling goes through the host theme (`theme.style("strong", …)` for bold), and diff backgrounds derive from `theme.hex` of `toolDiffAdded`, `toolDiffRemoved`, `toolSuccessBg` and `toolErrorBg`.
21
+ - `tests/fabric-exec-transcript-block.test.ts`, which tested the host `ToolExecutionComponent` that 19.2 removed.
22
+
23
+ ### Notes
24
+
25
+ - Live smoke on OMP 19.2.1 in tmux (160x45): the `/fabric` dashboard overview, topology and detail views, `/fabric settings` with section submenus and search, the approval dialog for `omp.bash` (Allow once ran the call), and `/fabric chat` on a spawned child agent (transcript, PageUp to older activity, the target picker, typing, Escape to close). Headless `omp -p` with 1.27.2 has no `fabric_exec`; this build runs it.
26
+ - Frame cost, same workload, median ms per frame from main (19.1.1) to this release: widget 0.0089 to 0.0087, dashboard overview 0.1616 to 0.1665, dashboard detail 0.1268 to 0.1329, conversation of 60 messages cold 0.5507 to 0.5772 and warm 0.3488 to 0.0448. Warm conversation frames with 20 tool results of 80 KB and a 2 MB image fell from 7.6032 to under 0.05 after the transcript block cache moved to input identity with eviction.
27
+ - Review: Agent Hendra asked in round 1 for the dashboard view to be disposed on close (its topology animation kept an 80 ms interval alive after closing), for view error containment, and for a cheaper transcript cache; round 2 approved 6a3e1801. Controller seam tests fail without the dispose (13 renders after close) and without the error containment.
28
+ - CI: Test run 45935666376 at 6a3e1801 (#26) and main Test run 45936254716 at the code commit 9b885f78, green on ubuntu and windows.
29
+
30
+ ## 1.27.2
31
+
32
+ ### Fixed
33
+
34
+ - `omp.find` without a `limit`, or with a limit above 200, failed on OMP 19.1.1 with `limit must be a number at most 200 (was 1000)`: the host find shim still defaults to 1000 while `GlobTool` now accepts 1 to 200. Fabric clamps the limit to 1..200 before the host sees it, and the truncation marker reports `resultLimit: 200` when the cap cut results. On 18.x hosts a find without a limit now returns at most 200 entries where the shim default returned up to 1000; 200 is the 19.1.1 host default.
35
+ - Bash output spill files were named `undefined-<id>.log` on OMP 19.1.1, which calls `allocateOutputArtifact` without a tool type. They are now named `output-<id>.log`.
36
+ - The first activation of an OMP actor exited with `Session "<path>" not found.` on OMP 19, which treats `--session <path>` as a resume request (#17). The worker now creates the session file with a version 3 header through an exclusive write before it starts OMP, and later activations resume that file. Contributed by @raiscui in #18.
37
+
38
+ ### Changed
39
+
40
+ - Host pins move from 18.20.2 to 19.1.1 (dependencies pi-agent-core, pi-ai, pi-utils; dev omptype, pi-coding-agent, pi-natives, pi-tui); the declared peer floor stays >=18.4.4. All 35 `@oh-my-pi/*` specifiers in `src`, `scripts` and `tests` resolve against 19.1.1 except the `pi-natives-` platform prefix, which is built at runtime.
41
+ - Four host-facing tests followed 19.1.1: bash lists no `pty` parameter in a session without UI, the artifact root is recreated lazily on the first spill, and a handoff session directory holds a `.<file>.lock.os` next to the `.jsonl`, so `agent-manager.test.ts` and `agents-provider.test.ts` open the `.jsonl` entry. The second of those failed main Test runs 45138005661 and 45138826240 on ubuntu only, where the directory listed the lock file first (#20).
42
+
43
+ ### Notes
44
+
45
+ - Negative controls: without the clamp 2 tests in `tests/omp-tools-provider.test.ts` fail with the host error, without the name fallback 1 fails, and without the actor session write `tests/worker-e2e.test.ts` fails with `ENOENT`. Each source file was restored byte-identical.
46
+ - Host-facing tests on 19.1.1: 14 files, 271 passed, 28 skipped. Live probe on OMP 19.1.1: `omp --mode rpc --session <missing file>` exits with `Session ... not found.`; with the header, `get_state` succeeds and a second spawn resumes the same session id.
47
+ - CI: Test run 45136706531 at 59c1cf53 (#19), 45136860746 at 73335a4d and 45138032475 at 453848a0 (#18), 45138882609 at a5d6ebf3 (#20), all green on ubuntu and windows. Agent Hendra approved #18 and #19; #20 is a one-line test change. Main Test run 45139397107 passed at the code commit 69145fc0.
48
+
3
49
  ## 1.27.1
4
50
 
5
51
  ### Added
package/README.md CHANGED
@@ -62,7 +62,7 @@ Independent calls run in parallel, and the returned object enters the model cont
62
62
 
63
63
  ## Install
64
64
 
65
- Requires Node.js 24+ and OMP 18.4.4+. Fabric also checks a detectable OMP host version at startup and warns when an older host does not match the tool shapes Fabric types against.
65
+ Requires Node.js 24+ and OMP 19.2.0+. OMP 19.2 replaced the pi-tui component library, so hosts from 18.4.4 to 19.1.x stay on omp-fabric 1.27.x. Fabric also checks a detectable OMP host version at startup and warns when an older host does not match the tool shapes Fabric types against.
66
66
 
67
67
  ```bash
68
68
  omp install npm:omp-fabric
@@ -1,5 +1,5 @@
1
1
  // src/ui/format.ts
2
- import { truncateToWidth, visibleWidth } from "@oh-my-pi/pi-tui";
2
+ import { truncate, visibleWidth } from "@oh-my-pi/pi-tui/text/width";
3
3
  var safeText = (value) => String(value ?? "").replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, " ").replace(/[\r\n\t]+/g, " ").replace(/\s+/g, " ").trim();
4
4
  var formatActorDataPreview = (data, maxChars = 200) => {
5
5
  if (data === void 0) return void 0;
@@ -38,7 +38,7 @@ var formatTokens = (tokens) => {
38
38
  var formatCost = (usd) => usd <= 0 ? "$0" : usd < 0.01 ? `$${usd.toFixed(4)}` : usd < 1 ? `$${usd.toFixed(3)}` : `$${usd.toFixed(2)}`;
39
39
  var formatClock = (timestamp) => new Date(timestamp).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
40
40
  var padToWidth = (value, width) => {
41
- const clipped = truncateToWidth(value, Math.max(0, width), "");
41
+ const clipped = truncate(value, Math.max(0, width), "");
42
42
  return clipped + " ".repeat(Math.max(0, width - visibleWidth(clipped)));
43
43
  };
44
44
  var wrapPlainText = (value, width, maxLines = 100) => {
@@ -53,7 +53,7 @@ var wrapPlainText = (value, width, maxLines = 100) => {
53
53
  current = candidate;
54
54
  continue;
55
55
  }
56
- if (current) lines.push(truncateToWidth(current, width));
56
+ if (current) lines.push(truncate(current, width));
57
57
  current = word;
58
58
  while (visibleWidth(current) > width && lines.length < maxLines) {
59
59
  let chunk = "";
@@ -78,7 +78,7 @@ var wrapPlainText = (value, width, maxLines = 100) => {
78
78
  }
79
79
  if (lines.length >= maxLines) break;
80
80
  }
81
- if (current && lines.length < maxLines) lines.push(truncateToWidth(current, width));
81
+ if (current && lines.length < maxLines) lines.push(truncate(current, width));
82
82
  return lines;
83
83
  };
84
84
 
@@ -92,4 +92,4 @@ export {
92
92
  padToWidth,
93
93
  wrapPlainText
94
94
  };
95
- //# sourceMappingURL=chunk-KIH3KLZU.js.map
95
+ //# sourceMappingURL=chunk-C2YMZNT5.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ui/format.ts"],
4
+ "sourcesContent": ["import { truncate, visibleWidth } from \"@oh-my-pi/pi-tui/text/width\";\n\nexport const safeText = (value: unknown): string =>\n String(value ?? \"\")\n .replace(/\\x1b\\[[0-?]*[ -/]*[@-~]/g, \"\")\n .replace(/[\\u0000-\\u0008\\u000b-\\u001f\\u007f-\\u009f]/g, \" \")\n .replace(/[\\r\\n\\t]+/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n\n\nexport const formatActorDataPreview = (data: unknown, maxChars = 200): string | undefined => {\n if (data === undefined) return undefined;\n const clip = (value: string): string => {\n const safe = safeText(value);\n return safe.length > maxChars ? `${safe.slice(0, Math.max(1, maxChars - 1))}\u2026` : safe;\n };\n if (typeof data === \"string\") return clip(data);\n if (\n typeof data === \"object\" &&\n data !== null &&\n !Array.isArray(data) &&\n (data as { fabricTruncated?: unknown }).fabricTruncated === true\n ) {\n const wrapper = data as { preview?: unknown; originalBytes?: unknown };\n const preview = clip(String(wrapper.preview ?? \"\"));\n const suffix =\n typeof wrapper.originalBytes === \"number\"\n ? `[truncated from ${wrapper.originalBytes} bytes]`\n : \"[truncated]\";\n return preview ? `${preview} ${suffix}` : suffix;\n }\n let serialized: string;\n try {\n serialized = JSON.stringify(data) ?? String(data);\n } catch {\n serialized = String(data);\n }\n return clip(serialized);\n};\n\nexport const formatDuration = (milliseconds: number): string => {\n const seconds = Math.max(0, Math.floor(milliseconds / 1_000));\n if (seconds < 60) return `${seconds}s`;\n const minutes = Math.floor(seconds / 60);\n if (minutes < 60) return `${minutes}m${String(seconds % 60).padStart(2, \"0\")}s`;\n const hours = Math.floor(minutes / 60);\n return `${hours}h${String(minutes % 60).padStart(2, \"0\")}m`;\n};\n\nexport const formatTokens = (tokens: number): string => {\n if (tokens < 1_000) return String(Math.max(0, Math.round(tokens)));\n if (tokens < 100_000) return `${(tokens / 1_000).toFixed(tokens < 10_000 ? 1 : 0)}k`;\n return `${(tokens / 1_000).toFixed(0)}k`;\n};\n\nexport const formatCost = (usd: number): string =>\n usd <= 0 ? \"$0\" : usd < 0.01 ? `$${usd.toFixed(4)}` : usd < 1 ? `$${usd.toFixed(3)}` : `$${usd.toFixed(2)}`;\n\nexport const formatClock = (timestamp: number): string =>\n new Date(timestamp).toLocaleTimeString([], { hour: \"2-digit\", minute: \"2-digit\" });\n\nexport const padToWidth = (value: string, width: number): string => {\n const clipped = truncate(value, Math.max(0, width), \"\");\n return clipped + \" \".repeat(Math.max(0, width - visibleWidth(clipped)));\n};\n\nexport const wrapPlainText = (value: string, width: number, maxLines = 100): string[] => {\n const safe = safeText(value);\n if (!safe || width <= 0 || maxLines <= 0) return [];\n const words = safe.split(\" \");\n const lines: string[] = [];\n let current = \"\";\n for (const word of words) {\n const candidate = current ? `${current} ${word}` : word;\n if (visibleWidth(candidate) <= width) {\n current = candidate;\n continue;\n }\n if (current) lines.push(truncate(current, width));\n current = word;\n while (visibleWidth(current) > width && lines.length < maxLines) {\n let chunk = \"\";\n let consumed = 0;\n const segments = [\n ...new Intl.Segmenter(undefined, { granularity: \"grapheme\" }).segment(current),\n ];\n for (const { segment } of segments) {\n const candidate = chunk + segment;\n if (visibleWidth(candidate) > width) {\n if (!chunk) {\n chunk = \"\u2026\";\n consumed += segment.length;\n }\n break;\n }\n chunk = candidate;\n consumed += segment.length;\n }\n if (chunk) lines.push(chunk);\n current = current.slice(consumed);\n }\n if (lines.length >= maxLines) break;\n }\n if (current && lines.length < maxLines) lines.push(truncate(current, width));\n return lines;\n};\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU,oBAAoB;AAEhC,IAAM,WAAW,CAAC,UACvB,OAAO,SAAS,EAAE,EACf,QAAQ,4BAA4B,EAAE,EACtC,QAAQ,8CAA8C,GAAG,EACzD,QAAQ,cAAc,GAAG,EACzB,QAAQ,QAAQ,GAAG,EACnB,KAAK;AAGH,IAAM,yBAAyB,CAAC,MAAe,WAAW,QAA4B;AAC3F,MAAI,SAAS,OAAW,QAAO;AAC/B,QAAM,OAAO,CAAC,UAA0B;AACtC,UAAM,OAAO,SAAS,KAAK;AAC3B,WAAO,KAAK,SAAS,WAAW,GAAG,KAAK,MAAM,GAAG,KAAK,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,WAAM;AAAA,EACnF;AACA,MAAI,OAAO,SAAS,SAAU,QAAO,KAAK,IAAI;AAC9C,MACE,OAAO,SAAS,YAChB,SAAS,QACT,CAAC,MAAM,QAAQ,IAAI,KAClB,KAAuC,oBAAoB,MAC5D;AACA,UAAM,UAAU;AAChB,UAAM,UAAU,KAAK,OAAO,QAAQ,WAAW,EAAE,CAAC;AAClD,UAAM,SACJ,OAAO,QAAQ,kBAAkB,WAC7B,mBAAmB,QAAQ,aAAa,YACxC;AACN,WAAO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
+ }
@@ -1,19 +1,24 @@
1
+ import {
2
+ TextField
3
+ } from "./chunk-O337ZL5J.js";
1
4
  import {
2
5
  INHERIT_VALUE,
3
6
  modelKey,
4
7
  sortByLastUsed
5
8
  } from "./chunk-7BOAOKWH.js";
9
+ import {
10
+ BlankRows,
11
+ Stack,
12
+ TextBlock
13
+ } from "./chunk-K3OSK6AX.js";
14
+ import {
15
+ keyOf
16
+ } from "./chunk-T76MXSP4.js";
6
17
 
7
18
  // src/ui/fabric-model-selector.ts
8
- import {
9
- Container,
10
- fuzzyFilter,
11
- getKeybindings,
12
- Input,
13
- Spacer,
14
- Text
15
- } from "@oh-my-pi/pi-tui";
16
- var FabricModelSelector = class extends Container {
19
+ import { widgetKeyMatches } from "@oh-my-pi/pi-tui/term/keymap";
20
+ import { fuzzyFilter } from "@oh-my-pi/pi-coding-agent/utils/fuzzy";
21
+ var FabricModelSelector = class extends Stack {
17
22
  theme;
18
23
  allEntries;
19
24
  filteredEntries;
@@ -22,13 +27,12 @@ var FabricModelSelector = class extends Container {
22
27
  currentValue;
23
28
  selectedIndex = 0;
24
29
  searchInput;
25
- listContainer = new Container();
30
+ listContainer = new Stack();
26
31
  onSelectCallback;
27
32
  onCancelCallback;
28
33
  headerText;
29
34
  inheritLabel;
30
35
  inheritName;
31
- _focused = false;
32
36
  constructor(options) {
33
37
  super();
34
38
  this.theme = options.theme;
@@ -44,51 +48,37 @@ var FabricModelSelector = class extends Container {
44
48
  this.filteredEntries = this.allEntries;
45
49
  const current = this.allEntries.findIndex((entry) => entry.value === this.currentValue);
46
50
  this.selectedIndex = current >= 0 ? current : 0;
47
- this.addChild(
48
- new Text(
49
- this.theme.fg("muted", this.headerText),
50
- 0,
51
- 0
52
- )
53
- );
54
- this.addChild(new Spacer(1));
55
- this.searchInput = new Input();
56
- this.searchInput.focused = true;
51
+ this.add(new TextBlock(this.theme.fg("muted", this.headerText)));
52
+ this.add(new BlankRows(1));
53
+ this.searchInput = new TextField();
57
54
  this.searchInput.onSubmit = () => {
58
55
  const entry = this.filteredEntries[this.selectedIndex];
59
56
  if (entry) this.handleSelect(entry);
60
57
  };
61
- this.addChild(this.searchInput);
62
- this.addChild(new Spacer(1));
63
- this.addChild(this.listContainer);
64
- this.addChild(new Spacer(1));
58
+ this.add(this.searchInput);
59
+ this.add(new BlankRows(1));
60
+ this.add(this.listContainer);
61
+ this.add(new BlankRows(1));
65
62
  this.updateList();
66
63
  }
67
- get focused() {
68
- return this._focused;
69
- }
70
- set focused(value) {
71
- this._focused = value;
72
- this.searchInput.focused = value;
73
- }
74
64
  handleInput(keyData) {
75
- const kb = getKeybindings();
76
- if (kb.matches(keyData, "tui.select.up")) {
65
+ const key = keyOf(keyData);
66
+ if (key && widgetKeyMatches(key, "select.up")) {
77
67
  if (this.filteredEntries.length === 0) return;
78
68
  this.selectedIndex = this.selectedIndex === 0 ? this.filteredEntries.length - 1 : this.selectedIndex - 1;
79
69
  this.updateList();
80
- } else if (kb.matches(keyData, "tui.select.down")) {
70
+ } else if (key && widgetKeyMatches(key, "select.down")) {
81
71
  if (this.filteredEntries.length === 0) return;
82
72
  this.selectedIndex = this.selectedIndex === this.filteredEntries.length - 1 ? 0 : this.selectedIndex + 1;
83
73
  this.updateList();
84
- } else if (kb.matches(keyData, "tui.select.confirm")) {
74
+ } else if (key && widgetKeyMatches(key, "select.confirm")) {
85
75
  const entry = this.filteredEntries[this.selectedIndex];
86
76
  if (entry) this.handleSelect(entry);
87
- } else if (kb.matches(keyData, "tui.select.cancel")) {
77
+ } else if (key && widgetKeyMatches(key, "select.cancel")) {
88
78
  this.onCancelCallback();
89
79
  } else {
90
80
  this.searchInput.handleInput(keyData);
91
- this.filterModels(this.searchInput.getValue());
81
+ this.filterModels(this.searchInput.getText());
92
82
  }
93
83
  }
94
84
  rpcChoices() {
@@ -166,24 +156,20 @@ var FabricModelSelector = class extends Container {
166
156
  const badge = entry.provider ? ` ${this.theme.fg("muted", `[${entry.provider}]`)}` : "";
167
157
  const check = isCurrent ? this.theme.fg("success", " \u2713") : "";
168
158
  const line = isSelected ? `${this.theme.fg("accent", "\u2192 ")}${this.theme.fg("accent", entry.id)}${badge}${check}` : ` ${entry.id}${badge}${check}`;
169
- this.listContainer.addChild(new Text(line, 0, 0));
159
+ this.listContainer.add(new TextBlock(line));
170
160
  }
171
161
  if (startIndex > 0 || endIndex < total) {
172
- this.listContainer.addChild(
173
- new Text(this.theme.fg("muted", ` (${this.selectedIndex + 1}/${total})`), 0, 0)
162
+ this.listContainer.add(
163
+ new TextBlock(this.theme.fg("muted", ` (${this.selectedIndex + 1}/${total})`))
174
164
  );
175
165
  }
176
166
  if (total === 0) {
177
- this.listContainer.addChild(new Text(this.theme.fg("muted", " No matching models"), 0, 0));
167
+ this.listContainer.add(new TextBlock(this.theme.fg("muted", " No matching models")));
178
168
  } else {
179
169
  const selected = this.filteredEntries[this.selectedIndex];
180
- this.listContainer.addChild(new Spacer(1));
181
- this.listContainer.addChild(
182
- new Text(
183
- this.theme.fg("muted", ` Model Name: ${selected ? selected.name : ""}`),
184
- 0,
185
- 0
186
- )
170
+ this.listContainer.add(new BlankRows(1));
171
+ this.listContainer.add(
172
+ new TextBlock(this.theme.fg("muted", ` Model Name: ${selected ? selected.name : ""}`))
187
173
  );
188
174
  }
189
175
  }
@@ -192,4 +178,4 @@ var FabricModelSelector = class extends Container {
192
178
  export {
193
179
  FabricModelSelector
194
180
  };
195
- //# sourceMappingURL=chunk-OJZNMROB.js.map
181
+ //# sourceMappingURL=chunk-DKXNUCM2.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ui/fabric-model-selector.ts"],
4
+ "sourcesContent": ["import type { Theme } from \"@oh-my-pi/pi-tui/theme/contract\";\nimport { widgetKeyMatches } from \"@oh-my-pi/pi-tui/term/keymap\";\nimport { fuzzyFilter } from \"@oh-my-pi/pi-coding-agent/utils/fuzzy\";\nimport { keyOf } from \"./tui/input.js\";\nimport { BlankRows, Stack, TextBlock } from \"./tui/rows.js\";\nimport { TextField } from \"./tui/text-field.js\";\nimport type { FabricView } from \"./tui/view.js\";\nimport { INHERIT_VALUE, modelKey, sortByLastUsed, type ModelLike, type ModelSource } from \"./model-picker.js\";\n\n/** A single pickable row in the Fabric model selector. */\ninterface ModelEntry {\n /** Value persisted to fabric.json: \"Inherit\" or `provider/id`. */\n value: string;\n /** Main text shown for the row (the model id, or \"Inherit\"). */\n id: string;\n /** Provider badge shown after the id; empty for the Inherit row. */\n provider: string;\n /** Human-readable name shown in the footer line. */\n name: string;\n /** Whether this is a real model (vs. the Inherit sentinel). */\n isModel: boolean;\n}\n\nexport interface FabricModelSelectorChoice {\n value: string;\n label: string;\n description: string;\n current: boolean;\n}\n\nexport interface FabricModelSelectorOptions {\n theme: Theme;\n source: ModelSource;\n /** The currently configured canonical model key or \"Inherit\". */\n currentValue: string;\n onSelect: (value: string) => void;\n onCancel: () => void;\n /** Header line above the search input. Defaults to the global-default wording. */\n headerText?: string;\n /** Label shown for the unset/default row. Defaults to Inherit. */\n inheritLabel?: string;\n /** Description shown for the unset/default row's footer name. */\n inheritName?: string;\n}\n\n/**\n * A /model-style searchable model picker adapted for Fabric: same look\n * (search input, list with `[provider]` badges and a \u2713 on\n * the current row, scroll indicator, and a \"Model Name:\" footer) but it writes\n * the Fabric default-model setting instead of the host's default model, and\n * pins an unset/default row on top. Order respects pi-model-sort (most recently\n * used first); search filters by fuzzy match and re-sorts by recency, matching\n * pi-model-sort's patched /model behavior.\n */\nexport class FabricModelSelector extends Stack implements FabricView {\n private readonly theme: Theme;\n private readonly allEntries: ModelEntry[];\n private filteredEntries: ModelEntry[];\n private readonly lastUsed: Record<string, number>;\n private readonly currentKey: string | null;\n private readonly currentValue: string;\n private selectedIndex = 0;\n private readonly searchInput: TextField;\n private readonly listContainer = new Stack();\n private readonly onSelectCallback: (value: string) => void;\n private readonly onCancelCallback: () => void;\n private readonly headerText: string;\n private readonly inheritLabel: string;\n private readonly inheritName: string;\n\n constructor(options: FabricModelSelectorOptions) {\n super();\n this.theme = options.theme;\n this.lastUsed = options.source.lastUsed;\n this.currentValue = options.currentValue;\n this.currentKey = options.currentValue === INHERIT_VALUE ? null : options.currentValue;\n this.onSelectCallback = options.onSelect;\n this.onCancelCallback = options.onCancel;\n this.headerText =\n options.headerText ??\n \"Default model for Fabric agents and actors. Pick Inherit to use the host session's model.\";\n this.inheritLabel = options.inheritLabel ?? INHERIT_VALUE;\n this.inheritName = options.inheritName ?? \"Use the host session's default model\";\n\n this.allEntries = this.buildEntries(options.source.models);\n this.filteredEntries = this.allEntries;\n const current = this.allEntries.findIndex((entry) => entry.value === this.currentValue);\n this.selectedIndex = current >= 0 ? current : 0;\n\n this.add(new TextBlock(this.theme.fg(\"muted\", this.headerText)));\n this.add(new BlankRows(1));\n this.searchInput = new TextField();\n this.searchInput.onSubmit = () => {\n const entry = this.filteredEntries[this.selectedIndex];\n if (entry) this.handleSelect(entry);\n };\n this.add(this.searchInput);\n this.add(new BlankRows(1));\n this.add(this.listContainer);\n this.add(new BlankRows(1));\n this.updateList();\n }\n\n handleInput(keyData: string): void {\n const key = keyOf(keyData);\n if (key && widgetKeyMatches(key, \"select.up\")) {\n if (this.filteredEntries.length === 0) return;\n this.selectedIndex =\n this.selectedIndex === 0 ? this.filteredEntries.length - 1 : this.selectedIndex - 1;\n this.updateList();\n } else if (key && widgetKeyMatches(key, \"select.down\")) {\n if (this.filteredEntries.length === 0) return;\n this.selectedIndex =\n this.selectedIndex === this.filteredEntries.length - 1 ? 0 : this.selectedIndex + 1;\n this.updateList();\n } else if (key && widgetKeyMatches(key, \"select.confirm\")) {\n const entry = this.filteredEntries[this.selectedIndex];\n if (entry) this.handleSelect(entry);\n } else if (key && widgetKeyMatches(key, \"select.cancel\")) {\n this.onCancelCallback();\n } else {\n this.searchInput.handleInput(keyData);\n this.filterModels(this.searchInput.getText());\n }\n }\n\n rpcChoices(): FabricModelSelectorChoice[] {\n return this.allEntries.map((entry) => ({\n value: entry.value,\n label: entry.id,\n description: entry.isModel ? `${entry.provider} \u00B7 ${entry.name}` : entry.name,\n current: entry.value === this.currentValue,\n }));\n }\n\n selectRpc(value: string): boolean {\n const entry = this.allEntries.find((candidate) => candidate.value === value);\n if (!entry) return false;\n this.handleSelect(entry);\n return true;\n }\n\n private handleSelect(entry: ModelEntry): void {\n this.onSelectCallback(entry.value);\n }\n\n private buildEntries(models: ModelLike[]): ModelEntry[] {\n const sorted = sortByLastUsed(models, this.lastUsed, this.currentKey);\n const inherit: ModelEntry = {\n value: INHERIT_VALUE,\n id: this.inheritLabel,\n provider: \"\",\n name: this.inheritName,\n isModel: false,\n };\n const modelEntries: ModelEntry[] = sorted.map((model) => ({\n value: modelKey(model.provider, model.id),\n id: model.id,\n provider: model.provider,\n name: model.name ?? model.id,\n isModel: true,\n }));\n return [inherit, ...modelEntries];\n }\n\n /** Filter by fuzzy match, then re-sort by recency (mirrors pi-model-sort). */\n private sortEntries(entries: ModelEntry[]): ModelEntry[] {\n const inherit = entries.find((entry) => !entry.isModel);\n const models = entries.filter((entry) => entry.isModel);\n const sorted = sortByLastUsed(\n models.map((entry) => ({ provider: entry.provider, id: entry.id, entry })),\n this.lastUsed,\n this.currentKey,\n ).map((item) => item.entry);\n return inherit ? [inherit, ...sorted] : sorted;\n }\n\n private filterModels(query: string): void {\n const matches = query.trim()\n ? fuzzyFilter(this.allEntries, query, (entry) => this.searchText(entry))\n : this.allEntries;\n this.filteredEntries = this.sortEntries(matches);\n const current = this.filteredEntries.findIndex((entry) => entry.value === this.currentValue);\n this.selectedIndex =\n current >= 0\n ? current\n : Math.min(this.selectedIndex, Math.max(0, this.filteredEntries.length - 1));\n this.updateList();\n }\n\n /** Mirrors getModelSelectorSearchText from OMP's /model selector. */\n private searchText(entry: ModelEntry): string {\n if (!entry.isModel) return `${entry.id} ${entry.name}`;\n return `${entry.provider} ${entry.provider}/${entry.id} ${entry.provider} ${entry.id} ${entry.name}`;\n }\n\n private updateList(): void {\n this.listContainer.clear();\n const maxVisible = 10;\n const total = this.filteredEntries.length;\n const startIndex = Math.max(\n 0,\n Math.min(this.selectedIndex - Math.floor(maxVisible / 2), total - maxVisible),\n );\n const endIndex = Math.min(startIndex + maxVisible, total);\n for (let i = startIndex; i < endIndex; i++) {\n const entry = this.filteredEntries[i];\n if (!entry) continue;\n const isSelected = i === this.selectedIndex;\n const isCurrent = entry.value === this.currentValue;\n const badge = entry.provider ? ` ${this.theme.fg(\"muted\", `[${entry.provider}]`)}` : \"\";\n const check = isCurrent ? this.theme.fg(\"success\", \" \u2713\") : \"\";\n const line = isSelected\n ? `${this.theme.fg(\"accent\", \"\\u2192 \")}${this.theme.fg(\"accent\", entry.id)}${badge}${check}`\n : ` ${entry.id}${badge}${check}`;\n this.listContainer.add(new TextBlock(line));\n }\n if (startIndex > 0 || endIndex < total) {\n this.listContainer.add(\n new TextBlock(this.theme.fg(\"muted\", ` (${this.selectedIndex + 1}/${total})`)),\n );\n }\n if (total === 0) {\n this.listContainer.add(new TextBlock(this.theme.fg(\"muted\", \" No matching models\")));\n } else {\n const selected = this.filteredEntries[this.selectedIndex];\n this.listContainer.add(new BlankRows(1));\n this.listContainer.add(\n new TextBlock(this.theme.fg(\"muted\", ` Model Name: ${selected ? selected.name : \"\"}`)),\n );\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AACA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAoDrB,IAAM,sBAAN,cAAkC,MAA4B;AAAA,EAClD;AAAA,EACA;AAAA,EACT;AAAA,EACS;AAAA,EACA;AAAA,EACA;AAAA,EACT,gBAAgB;AAAA,EACP;AAAA,EACA,gBAAgB,IAAI,MAAM;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,SAAqC;AAC/C,UAAM;AACN,SAAK,QAAQ,QAAQ;AACrB,SAAK,WAAW,QAAQ,OAAO;AAC/B,SAAK,eAAe,QAAQ;AAC5B,SAAK,aAAa,QA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AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,132 @@
1
+ import {
2
+ decodeTerminalInput
3
+ } from "./chunk-T76MXSP4.js";
4
+
5
+ // src/ui/tui/rows.ts
6
+ import { padTo, replaceTabs, wrap } from "@oh-my-pi/pi-tui/text/width";
7
+ var TextBlock = class {
8
+ constructor(text = "", paddingX = 0, paddingY = 0) {
9
+ this.text = text;
10
+ this.paddingX = paddingX;
11
+ this.paddingY = paddingY;
12
+ }
13
+ getText() {
14
+ return this.text;
15
+ }
16
+ setText(text) {
17
+ this.text = text;
18
+ }
19
+ render(width) {
20
+ if (this.text.trim() === "") return [];
21
+ const margin = " ".repeat(this.paddingX);
22
+ const contentWidth = Math.max(1, width - this.paddingX * 2);
23
+ const content = replaceTabs(this.text).split("\n").flatMap((line) => line === "" ? [""] : wrap(line, contentWidth)).map((line) => padTo(`${margin}${line}${margin}`, width));
24
+ const blank = Array.from({ length: this.paddingY }, () => " ".repeat(Math.max(0, width)));
25
+ return [...blank, ...content, ...blank];
26
+ }
27
+ };
28
+ var BlankRows = class {
29
+ constructor(count = 1) {
30
+ this.count = count;
31
+ }
32
+ render() {
33
+ return Array.from({ length: this.count }, () => "");
34
+ }
35
+ };
36
+ var Stack = class {
37
+ children = [];
38
+ add(child) {
39
+ this.children.push(child);
40
+ }
41
+ remove(child) {
42
+ const index = this.children.indexOf(child);
43
+ if (index >= 0) this.children.splice(index, 1);
44
+ }
45
+ clear() {
46
+ this.children.length = 0;
47
+ }
48
+ invalidate() {
49
+ for (const child of this.children) child.invalidate?.();
50
+ }
51
+ render(width) {
52
+ return this.children.flatMap((child) => [...child.render(width)]);
53
+ }
54
+ };
55
+
56
+ // src/ui/tui/select-list.ts
57
+ import { widgetKeyMatches } from "@oh-my-pi/pi-tui/term/keymap";
58
+ import { padTo as padTo2, truncate, visibleWidth } from "@oh-my-pi/pi-tui/text/width";
59
+ var CURSOR = "\u2192 ";
60
+ var SelectList = class {
61
+ constructor(items, maxVisible, theme, layout = {}) {
62
+ this.items = items;
63
+ this.maxVisible = maxVisible;
64
+ this.theme = theme;
65
+ this.layout = layout;
66
+ }
67
+ onSelect;
68
+ onCancel;
69
+ selectedIndex = 0;
70
+ setSelectedIndex(index) {
71
+ this.selectedIndex = Math.max(0, Math.min(index, this.items.length - 1));
72
+ }
73
+ getSelectedItem() {
74
+ return this.items[this.selectedIndex];
75
+ }
76
+ handleInput(data) {
77
+ for (const event of decodeTerminalInput(data)) {
78
+ if (event.type !== "key") continue;
79
+ const key = event.key;
80
+ const count = this.items.length;
81
+ if (widgetKeyMatches(key, "select.cancel")) this.onCancel?.();
82
+ else if (count === 0) continue;
83
+ else if (widgetKeyMatches(key, "select.up")) this.selectedIndex = (this.selectedIndex - 1 + count) % count;
84
+ else if (widgetKeyMatches(key, "select.down")) this.selectedIndex = (this.selectedIndex + 1) % count;
85
+ else if (widgetKeyMatches(key, "select.pageUp")) this.setSelectedIndex(this.selectedIndex - this.pageSize());
86
+ else if (widgetKeyMatches(key, "select.pageDown")) this.setSelectedIndex(this.selectedIndex + this.pageSize());
87
+ else if (widgetKeyMatches(key, "select.confirm")) {
88
+ const item = this.items[this.selectedIndex];
89
+ if (item) this.onSelect?.(item);
90
+ }
91
+ }
92
+ }
93
+ render(width) {
94
+ if (this.items.length === 0) return [this.theme.fg("muted", " No matching items")];
95
+ const visible = this.pageSize();
96
+ const start = Math.max(0, Math.min(this.selectedIndex - Math.floor(visible / 2), this.items.length - visible));
97
+ const end = Math.min(this.items.length, start + visible);
98
+ const labelWidth = this.labelColumnWidth();
99
+ const rows = [];
100
+ for (let index = start; index < end; index++) {
101
+ const item = this.items[index];
102
+ const selected = index === this.selectedIndex;
103
+ const prefix = selected ? this.theme.fg("accent", CURSOR) : " ".repeat(CURSOR.length);
104
+ const label = truncate(item.label, labelWidth);
105
+ const styledLabel = selected ? this.theme.fg("accent", label) : label;
106
+ const room = width - CURSOR.length - labelWidth - 2;
107
+ const description = item.description && room > 4 ? this.theme.fg("muted", ` ${truncate(item.description, room)}`) : "";
108
+ rows.push(truncate(`${prefix}${description ? padTo2(styledLabel, labelWidth) : styledLabel}${description}`, width));
109
+ }
110
+ if (start > 0 || end < this.items.length) {
111
+ rows.push(this.theme.fg("muted", truncate(` (${this.selectedIndex + 1}/${this.items.length})`, width, "")));
112
+ }
113
+ return rows;
114
+ }
115
+ pageSize() {
116
+ return Math.max(1, Math.min(this.maxVisible, this.items.length));
117
+ }
118
+ labelColumnWidth() {
119
+ const widest = Math.max(0, ...this.items.map((item) => visibleWidth(item.label)));
120
+ const min = this.layout.minPrimaryColumnWidth ?? 0;
121
+ const max = this.layout.maxPrimaryColumnWidth ?? 32;
122
+ return Math.max(min, Math.min(max, widest));
123
+ }
124
+ };
125
+
126
+ export {
127
+ TextBlock,
128
+ BlankRows,
129
+ Stack,
130
+ SelectList
131
+ };
132
+ //# sourceMappingURL=chunk-K3OSK6AX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ui/tui/rows.ts", "../../src/ui/tui/select-list.ts"],
4
+ "sourcesContent": ["import { padTo, replaceTabs, wrap } from \"@oh-my-pi/pi-tui/text/width\";\nimport type { Rows } from \"./view.js\";\n\nexport class TextBlock implements Rows {\n constructor(\n private text = \"\",\n private readonly paddingX = 0,\n private readonly paddingY = 0,\n ) {}\n\n getText(): string {\n return this.text;\n }\n\n setText(text: string): void {\n this.text = text;\n }\n\n render(width: number): string[] {\n if (this.text.trim() === \"\") return [];\n const margin = \" \".repeat(this.paddingX);\n const contentWidth = Math.max(1, width - this.paddingX * 2);\n const content = replaceTabs(this.text)\n .split(\"\\n\")\n .flatMap((line) => (line === \"\" ? [\"\"] : wrap(line, contentWidth)))\n .map((line) => padTo(`${margin}${line}${margin}`, width));\n const blank = Array.from({ length: this.paddingY }, () => \" \".repeat(Math.max(0, width)));\n return [...blank, ...content, ...blank];\n }\n}\n\nexport class BlankRows implements Rows {\n constructor(private readonly count = 1) {}\n\n render(): string[] {\n return Array.from({ length: this.count }, () => \"\");\n }\n}\n\nexport class Stack implements Rows {\n readonly children: Rows[] = [];\n\n add(child: Rows): void {\n this.children.push(child);\n }\n\n remove(child: Rows): void {\n const index = this.children.indexOf(child);\n if (index >= 0) this.children.splice(index, 1);\n }\n\n clear(): void {\n this.children.length = 0;\n }\n\n invalidate(): void {\n for (const child of this.children) child.invalidate?.();\n }\n\n render(width: number): string[] {\n return this.children.flatMap((child) => [...child.render(width)]);\n }\n}\n", "import type { Theme } from \"@oh-my-pi/pi-tui/theme/contract\";\nimport { widgetKeyMatches } from \"@oh-my-pi/pi-tui/term/keymap\";\nimport { padTo, truncate, visibleWidth } from \"@oh-my-pi/pi-tui/text/width\";\nimport { decodeTerminalInput } from \"./input.js\";\nimport type { Rows } from \"./view.js\";\n\nexport interface SelectItem {\n value: string;\n label: string;\n description?: string;\n}\n\nexport interface SelectListLayout {\n minPrimaryColumnWidth?: number;\n maxPrimaryColumnWidth?: number;\n}\n\nconst CURSOR = \"\u2192 \";\n\nexport class SelectList implements Rows {\n onSelect: ((item: SelectItem) => void) | undefined;\n onCancel: (() => void) | undefined;\n private selectedIndex = 0;\n\n constructor(\n private readonly items: readonly SelectItem[],\n private readonly maxVisible: number,\n private readonly theme: Theme,\n private readonly layout: SelectListLayout = {},\n ) {}\n\n setSelectedIndex(index: number): void {\n this.selectedIndex = Math.max(0, Math.min(index, this.items.length - 1));\n }\n\n getSelectedItem(): SelectItem | undefined {\n return this.items[this.selectedIndex];\n }\n\n handleInput(data: string): void {\n for (const event of decodeTerminalInput(data)) {\n if (event.type !== \"key\") continue;\n const key = event.key;\n const count = this.items.length;\n if (widgetKeyMatches(key, \"select.cancel\")) this.onCancel?.();\n else if (count === 0) continue;\n else if (widgetKeyMatches(key, \"select.up\")) this.selectedIndex = (this.selectedIndex - 1 + count) % count;\n else if (widgetKeyMatches(key, \"select.down\")) this.selectedIndex = (this.selectedIndex + 1) % count;\n else if (widgetKeyMatches(key, \"select.pageUp\")) this.setSelectedIndex(this.selectedIndex - this.pageSize());\n else if (widgetKeyMatches(key, \"select.pageDown\")) this.setSelectedIndex(this.selectedIndex + this.pageSize());\n else if (widgetKeyMatches(key, \"select.confirm\")) {\n const item = this.items[this.selectedIndex];\n if (item) this.onSelect?.(item);\n }\n }\n }\n\n render(width: number): string[] {\n if (this.items.length === 0) return [this.theme.fg(\"muted\", \" No matching items\")];\n const visible = this.pageSize();\n const start = Math.max(0, Math.min(this.selectedIndex - Math.floor(visible / 2), this.items.length - visible));\n const end = Math.min(this.items.length, start + visible);\n const labelWidth = this.labelColumnWidth();\n const rows: string[] = [];\n for (let index = start; index < end; index++) {\n const item = this.items[index]!;\n const selected = index === this.selectedIndex;\n const prefix = selected ? this.theme.fg(\"accent\", CURSOR) : \" \".repeat(CURSOR.length);\n const label = truncate(item.label, labelWidth);\n const styledLabel = selected ? this.theme.fg(\"accent\", label) : label;\n const room = width - CURSOR.length - labelWidth - 2;\n const description = item.description && room > 4\n ? this.theme.fg(\"muted\", ` ${truncate(item.description, room)}`)\n : \"\";\n rows.push(truncate(`${prefix}${description ? padTo(styledLabel, labelWidth) : styledLabel}${description}`, width));\n }\n if (start > 0 || end < this.items.length) {\n rows.push(this.theme.fg(\"muted\", truncate(` (${this.selectedIndex + 1}/${this.items.length})`, width, \"\")));\n }\n return rows;\n }\n\n private pageSize(): number {\n return Math.max(1, Math.min(this.maxVisible, this.items.length));\n }\n\n private labelColumnWidth(): number {\n const widest = Math.max(0, ...this.items.map((item) => visibleWidth(item.label)));\n const min = this.layout.minPrimaryColumnWidth ?? 0;\n const max = this.layout.maxPrimaryColumnWidth ?? 32;\n return Math.max(min, Math.min(max, widest));\n }\n}\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,OAAO,aAAa,YAAY;AAGlC,IAAM,YAAN,MAAgC;AAAA,EACrC,YACU,OAAO,IACE,WAAW,GACX,WAAW,GAC5B;AAHQ;AACS;AACA;AAAA,EAChB;AAAA,EAEH,UAAkB;A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AAAA,EAEQ,WAAmB;AACzB,WAAO,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,YAAY,KAAK,MAAM,MAAM,CAAC;AAAA,EACjE;AAAA,EAEQ,mBAA2B;AACjC,UAAM,SAAS,KAAK,IAAI,GAAG,GAAG,KAAK,MAAM,IAAI,CAAC,SAAS,aAAa,KAAK,KAAK,CAAC,CAAC;AAChF,UAAM,MAAM,KAAK,OAAO,yBAAyB;AACjD,UAAM,MAAM,KAAK,OAAO,yBAAyB;AACjD,WAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,MAAM,CAAC;AAAA,EAC5C;AACF;",
6
+ "names": ["padTo", "padTo"]
7
+ }
@@ -5,6 +5,12 @@ import {
5
5
  import {
6
6
  DynamicBorder
7
7
  } from "./chunk-7VIQNUPS.js";
8
+ import {
9
+ BlankRows,
10
+ SelectList,
11
+ Stack,
12
+ TextBlock
13
+ } from "./chunk-K3OSK6AX.js";
8
14
  import {
9
15
  THINKING_DIGEST_CUSTOM_TYPE,
10
16
  buildThinkingDigest,
@@ -1037,14 +1043,6 @@ var expandSkillDirMarkersForRead = (content, args, cwd) => {
1037
1043
  return expandSkillDirMarkers(content, path.dirname(requestedPath));
1038
1044
  };
1039
1045
 
1040
- // src/core/approval-controller.ts
1041
- import {
1042
- Container,
1043
- SelectList,
1044
- Spacer,
1045
- Text
1046
- } from "@oh-my-pi/pi-tui";
1047
-
1048
1046
  // src/core/auto-approval-classifier.ts
1049
1047
  import { Type } from "@oh-my-pi/pi-coding-agent/extensibility/legacy-typebox";
1050
1048
  var MAX_TRANSCRIPT_CHARS = 24e3;
@@ -1187,17 +1185,6 @@ var FabricAutoApprovalClassifier = class {
1187
1185
  };
1188
1186
 
1189
1187
  // src/core/approval-controller.ts
1190
- var selectListThemeFor = (theme) => {
1191
- const apply = (name, text) => theme.fg(name, text);
1192
- return {
1193
- symbols: theme.symbols,
1194
- selectedPrefix: (text) => apply("accent", text),
1195
- selectedText: (text) => apply("accent", text),
1196
- description: (text) => apply("muted", text),
1197
- scrollInfo: (text) => apply("muted", text),
1198
- noMatch: (text) => apply("muted", text)
1199
- };
1200
- };
1201
1188
  var inheritedRisks = () => {
1202
1189
  const allowed = /* @__PURE__ */ new Set(["read", "write", "execute", "network", "agent"]);
1203
1190
  return (process.env.OMP_FABRIC_GRANTED_RISKS ?? "").split(",").filter((risk) => allowed.has(risk));
@@ -1316,37 +1303,37 @@ var ApprovalController = class {
1316
1303
  return "deny";
1317
1304
  }
1318
1305
  async #requestTuiApproval(action, escalationReason) {
1319
- const choice = await this.context.ui.custom((tui, theme, _keybindings, done) => {
1320
- const container = new Container();
1321
- container.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
1322
- container.addChild(new Spacer(1));
1323
- container.addChild(
1324
- new Text(theme.fg("warning", theme.bold("\u{1F6E1} OMP Fabric permission request")), 1, 0)
1306
+ const choice = await this.context.ui.custom((_ui, theme, _keybindings, done) => {
1307
+ const container = new Stack();
1308
+ container.add(new DynamicBorder((text) => theme.fg("warning", text)));
1309
+ container.add(new BlankRows(1));
1310
+ container.add(
1311
+ new TextBlock(theme.fg("warning", theme.style("strong", "\u{1F6E1} OMP Fabric permission request")), 1, 0)
1325
1312
  );
1326
- container.addChild(new Spacer(1));
1327
- container.addChild(
1328
- new Text(
1313
+ container.add(new BlankRows(1));
1314
+ container.add(
1315
+ new TextBlock(
1329
1316
  theme.fg("text", `${action.ref} requests ${action.risk} access.`),
1330
1317
  1,
1331
1318
  0
1332
1319
  )
1333
1320
  );
1334
- container.addChild(new Text(theme.fg("muted", action.description), 1, 0));
1321
+ container.add(new TextBlock(theme.fg("muted", action.description), 1, 0));
1335
1322
  if (escalationReason) {
1336
- container.addChild(new Spacer(1));
1337
- container.addChild(
1338
- new Text(theme.fg("warning", escalationReason), 1, 0)
1323
+ container.add(new BlankRows(1));
1324
+ container.add(
1325
+ new TextBlock(theme.fg("warning", escalationReason), 1, 0)
1339
1326
  );
1340
1327
  }
1341
- container.addChild(new Spacer(1));
1342
- container.addChild(
1343
- new Text(
1328
+ container.add(new BlankRows(1));
1329
+ container.add(
1330
+ new TextBlock(
1344
1331
  theme.fg("dim", "Choose whether to allow only this call or this risk class for the session."),
1345
1332
  1,
1346
1333
  0
1347
1334
  )
1348
1335
  );
1349
- container.addChild(new Spacer(1));
1336
+ container.add(new BlankRows(1));
1350
1337
  const items = [
1351
1338
  {
1352
1339
  value: "allow-once",
@@ -1364,23 +1351,19 @@ var ApprovalController = class {
1364
1351
  description: "Block the requested action"
1365
1352
  }
1366
1353
  ];
1367
- const list = new SelectList(items, items.length, selectListThemeFor(theme));
1354
+ const list = new SelectList(items, items.length, theme);
1368
1355
  list.onSelect = (item) => done(item.value);
1369
1356
  list.onCancel = () => done("deny");
1370
- container.addChild(list);
1371
- container.addChild(new Spacer(1));
1372
- container.addChild(
1373
- new Text(theme.fg("dim", "\u2191\u2193 navigate \xB7 enter select \xB7 esc deny"), 1, 0)
1357
+ container.add(list);
1358
+ container.add(new BlankRows(1));
1359
+ container.add(
1360
+ new TextBlock(theme.fg("dim", "\u2191\u2193 navigate \xB7 enter select \xB7 esc deny"), 1, 0)
1374
1361
  );
1375
- container.addChild(new Spacer(1));
1376
- container.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
1362
+ container.add(new BlankRows(1));
1363
+ container.add(new DynamicBorder((text) => theme.fg("warning", text)));
1377
1364
  return {
1378
1365
  render: (width) => container.render(width),
1379
- invalidate: () => container.invalidate(),
1380
- handleInput: (data) => {
1381
- list.handleInput(data);
1382
- tui.requestRender();
1383
- }
1366
+ handleInput: (data) => list.handleInput(data)
1384
1367
  };
1385
1368
  });
1386
1369
  return choice ?? "deny";
@@ -2841,4 +2824,4 @@ export {
2841
2824
  resolveFabricIdentity,
2842
2825
  MainAgentController
2843
2826
  };
2844
- //# sourceMappingURL=chunk-2BOZMRT5.js.map
2827
+ //# sourceMappingURL=chunk-LK66YHVL.js.map