@timurproko/a1 0.2.7-dev.1252 → 0.2.7-dev.1264

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 (296) hide show
  1. package/bin/ui.js +3 -3
  2. package/dist/app/session-shell/clipboard-diagnostics.d.ts +2 -2
  3. package/dist/app/session-shell/clipboard-image.d.ts +0 -1
  4. package/dist/app/session-shell/clipboard-image.js +1 -1
  5. package/dist/app/session-shell/dialog-coordinator.d.ts +6 -5
  6. package/dist/app/session-shell/dialog-coordinator.js +3 -4
  7. package/dist/app/session-shell/dock-chrome.d.ts +11 -6
  8. package/dist/app/session-shell/dock-chrome.js +5 -8
  9. package/dist/app/session-shell/editor-hyperlink-budget.d.ts +0 -2
  10. package/dist/app/session-shell/editor-hyperlink-budget.js +1 -1
  11. package/dist/app/session-shell/exit-notice.d.ts +2 -2
  12. package/dist/app/session-shell/exit-notice.js +1 -1
  13. package/dist/app/session-shell/extension-surface.d.ts +8 -7
  14. package/dist/app/session-shell/helper-pool.d.ts +3 -4
  15. package/dist/app/session-shell/helper-pool.js +1 -1
  16. package/dist/app/session-shell/image-preparation-client.d.ts +4 -3
  17. package/dist/app/session-shell/image-preparation.d.ts +0 -2
  18. package/dist/app/session-shell/image-preparation.js +2 -2
  19. package/dist/app/session-shell/image-source.d.ts +2 -3
  20. package/dist/app/session-shell/image-source.js +2 -2
  21. package/dist/app/session-shell/input-surface-switch.d.ts +9 -7
  22. package/dist/app/session-shell/input-surface-switch.js +1 -2
  23. package/dist/app/session-shell/login-interaction.d.ts +5 -4
  24. package/dist/app/session-shell/login-interaction.js +2 -3
  25. package/dist/app/session-shell/paste-executor.d.ts +4 -8
  26. package/dist/app/session-shell/paste-executor.js +2 -2
  27. package/dist/app/session-shell/paste-protocol.d.ts +2 -2
  28. package/dist/app/session-shell/path-chip-presentation.d.ts +0 -5
  29. package/dist/app/session-shell/path-chip-presentation.js +3 -3
  30. package/dist/app/session-shell/prompt-chips.d.ts +8 -7
  31. package/dist/app/session-shell/prompt-history-controller.d.ts +3 -3
  32. package/dist/app/session-shell/prompt-submission.d.ts +5 -2
  33. package/dist/app/session-shell/prompt-submission.js +13 -14
  34. package/dist/app/session-shell/quit-outro-effects.d.ts +3 -3
  35. package/dist/app/session-shell/quit-outro-effects.js +1 -4
  36. package/dist/app/session-shell/quit-outro.d.ts +9 -12
  37. package/dist/app/session-shell/quit-outro.js +11 -11
  38. package/dist/app/session-shell/resource-labels.d.ts +2 -0
  39. package/dist/app/session-shell/resource-labels.js +158 -0
  40. package/dist/app/session-shell/response-copy-protocol.d.ts +3 -2
  41. package/dist/app/session-shell/response-copy-transport.d.ts +2 -14
  42. package/dist/app/session-shell/response-copy-transport.js +1 -1
  43. package/dist/app/session-shell/session-lifecycle.d.ts +2 -1
  44. package/dist/app/session-shell/session-prompt-history.d.ts +29 -0
  45. package/dist/app/session-shell/session-prompt-history.js +80 -0
  46. package/dist/app/session-shell/session-selectors.d.ts +46 -0
  47. package/dist/app/session-shell/session-selectors.js +269 -0
  48. package/dist/app/session-shell/session-shell-root.d.ts +76 -113
  49. package/dist/app/session-shell/session-shell-root.js +103 -329
  50. package/dist/app/session-shell/session-shell.d.ts +14 -37
  51. package/dist/app/session-shell/session-shell.js +177 -612
  52. package/dist/app/session-shell/session-viewport-controller.d.ts +9 -16
  53. package/dist/app/session-shell/session-viewport-controller.js +42 -320
  54. package/dist/app/session-shell/settings-bindings.d.ts +25 -3
  55. package/dist/app/session-shell/settings-bindings.js +26 -2
  56. package/dist/app/session-shell/share-operation.d.ts +3 -3
  57. package/dist/app/session-shell/share-operation.js +4 -6
  58. package/dist/app/session-shell/shell-clipboard.d.ts +59 -0
  59. package/dist/app/session-shell/shell-clipboard.js +119 -0
  60. package/dist/app/session-shell/shell-editor-factory.d.ts +8 -4
  61. package/dist/app/session-shell/shell-editor-factory.js +13 -15
  62. package/dist/app/session-shell/shell-host.d.ts +16 -17
  63. package/dist/app/session-shell/shell-host.js +18 -19
  64. package/dist/app/session-shell/shell-layout.d.ts +2 -2
  65. package/dist/app/session-shell/shell-prompt-suggestions.d.ts +26 -0
  66. package/dist/app/session-shell/shell-prompt-suggestions.js +48 -0
  67. package/dist/app/session-shell/suggestion-surface.d.ts +1 -6
  68. package/dist/app/session-shell/suggestion-surface.js +1 -1
  69. package/dist/app/session-shell/system-clipboard.d.ts +2 -14
  70. package/dist/app/session-shell/system-clipboard.js +2 -7
  71. package/dist/app/session-shell/transcript-document.d.ts +11 -8
  72. package/dist/app/session-shell/transcript-document.js +13 -14
  73. package/dist/app/session-shell/viewport-layout.d.ts +2 -2
  74. package/dist/app/session-shell/viewport-pointer.d.ts +83 -0
  75. package/dist/app/session-shell/viewport-pointer.js +361 -0
  76. package/dist/app/session-shell/workflow-output.d.ts +5 -3
  77. package/dist/app/session-shell/workflow-output.js +13 -15
  78. package/dist/cli/package-messages.d.ts +0 -1
  79. package/dist/cli/package-messages.js +1 -1
  80. package/dist/cli/session-context.d.ts +1 -1
  81. package/dist/cli/uninstall.d.ts +3 -2
  82. package/dist/composition/owned-settings.d.ts +2 -1
  83. package/dist/composition/owned-settings.js +0 -3
  84. package/dist/composition/owned-ui.d.ts +1 -1
  85. package/dist/composition/owned-ui.js +77 -73
  86. package/dist/composition/reference-selection-options.d.ts +1 -1
  87. package/dist/composition/reference-selection-options.js +1 -1
  88. package/dist/composition/session-runtime-registry.d.ts +2 -1
  89. package/dist/composition/settings-route-host.js +3 -10
  90. package/dist/composition/settings-search-input.d.ts +2 -1
  91. package/dist/composition/startup-route.d.ts +2 -2
  92. package/dist/composition/startup-route.js +2 -2
  93. package/dist/contracts/owned-ui/extension-ui.d.ts +2 -1
  94. package/dist/contracts/owned-ui/index.d.ts +2 -1
  95. package/dist/contracts/owned-ui/index.js +1 -1
  96. package/dist/contracts/owned-ui/session-presenters.d.ts +3 -0
  97. package/dist/contracts/owned-ui/shell-components.d.ts +543 -0
  98. package/dist/contracts/owned-ui/validation.d.ts +1 -11
  99. package/dist/contracts/owned-ui/validation.js +8 -104
  100. package/dist/contracts/presentation/component.d.ts +17 -0
  101. package/dist/contracts/presentation/component.js +8 -0
  102. package/dist/contracts/presentation/index.d.ts +6 -15
  103. package/dist/contracts/presentation/index.js +2 -0
  104. package/dist/contracts/presentation/terminal.d.ts +284 -0
  105. package/dist/contracts/presentation/terminal.js +1 -0
  106. package/dist/contracts/presentation/theme.d.ts +46 -0
  107. package/dist/contracts/presentation/theme.js +1 -0
  108. package/dist/features/launch/development-launch.js +1 -1
  109. package/dist/features/launch/runtime-selection.d.ts +2 -2
  110. package/dist/features/launch/runtime-selection.js +2 -2
  111. package/dist/features/owned-ui/project-trust-prompt.d.ts +2 -2
  112. package/dist/features/owned-ui/project-trust-prompt.js +1 -1
  113. package/dist/features/owned-ui/release-note-state.d.ts +2 -1
  114. package/dist/features/owned-ui/settings-app.js +49 -425
  115. package/dist/features/owned-ui/settings-edits.d.ts +31 -0
  116. package/dist/features/owned-ui/settings-edits.js +139 -0
  117. package/dist/features/owned-ui/settings-model-dialog.d.ts +41 -0
  118. package/dist/features/owned-ui/settings-model-dialog.js +194 -0
  119. package/dist/features/owned-ui/settings-scroll-rail.d.ts +29 -0
  120. package/dist/features/owned-ui/settings-scroll-rail.js +79 -0
  121. package/dist/features/owned-ui/settings-search-input.d.ts +2 -1
  122. package/dist/features/prompt-history/service.d.ts +3 -2
  123. package/dist/foundation/lifecycle/claim-gate.d.ts +2 -1
  124. package/dist/foundation/release/automatic-update.d.ts +5 -14
  125. package/dist/foundation/release/automatic-update.js +15 -22
  126. package/dist/foundation/release/bootstrap.js +4 -4
  127. package/dist/foundation/release/dependency-certification.d.ts +0 -1
  128. package/dist/foundation/release/dependency-certification.js +1 -1
  129. package/dist/foundation/release/dependency-layer.js +3 -3
  130. package/dist/foundation/release/early-accent.d.ts +2 -2
  131. package/dist/foundation/release/early-accent.js +1 -1
  132. package/dist/foundation/release/index.d.ts +2 -2
  133. package/dist/foundation/release/index.js +1 -1
  134. package/dist/foundation/release/latest-release.d.ts +3 -18
  135. package/dist/foundation/release/latest-release.js +11 -11
  136. package/dist/foundation/release/managed-path.d.ts +10 -0
  137. package/dist/foundation/release/managed-path.js +26 -0
  138. package/dist/foundation/release/ordinary-launch-selection.d.ts +1 -1
  139. package/dist/foundation/release/ordinary-launch-selection.js +1 -1
  140. package/dist/foundation/release/release-gc.d.ts +3 -3
  141. package/dist/foundation/release/release-gc.js +10 -12
  142. package/dist/foundation/release/{cohort-state.d.ts → release-state.d.ts} +23 -23
  143. package/dist/foundation/release/{cohort-state.js → release-state.js} +8 -8
  144. package/dist/foundation/release/restart-certification.js +3 -4
  145. package/dist/foundation/release/update-activation.js +3 -3
  146. package/dist/foundation/release/update-execution-lease.d.ts +2 -3
  147. package/dist/foundation/release/update-execution-lease.js +2 -8
  148. package/dist/foundation/release/update-installer.d.ts +45 -0
  149. package/dist/foundation/release/update-installer.js +57 -0
  150. package/dist/foundation/release/update-launch.d.ts +2 -2
  151. package/dist/foundation/release/update-recovery.js +2 -9
  152. package/dist/foundation/release/update.d.ts +4 -25
  153. package/dist/foundation/release/update.js +164 -183
  154. package/dist/foundation/startup/startup-budget.d.ts +5 -5
  155. package/dist/foundation/startup/startup-budget.js +2 -2
  156. package/dist/integrations/pi/components/bracketed-paste.d.ts +33 -0
  157. package/dist/integrations/pi/components/bracketed-paste.js +123 -0
  158. package/dist/integrations/pi/components/editor-interaction.d.ts +4 -12
  159. package/dist/integrations/pi/components/index.d.ts +15 -9
  160. package/dist/integrations/pi/components/index.js +9 -5
  161. package/dist/integrations/pi/components/lazy-selectors.d.ts +2 -10
  162. package/dist/integrations/pi/components/lazy-selectors.js +1 -1
  163. package/dist/integrations/pi/components/modal-frame.d.ts +5 -22
  164. package/dist/integrations/pi/components/modal-frame.js +3 -23
  165. package/dist/integrations/pi/components/owned-editor-ux.d.ts +4 -3
  166. package/dist/integrations/pi/components/owned-editor-ux.js +46 -140
  167. package/dist/integrations/pi/components/prompt-input-port.d.ts +2 -19
  168. package/dist/integrations/pi/components/resources/builtin-themes.d.ts +2 -1
  169. package/dist/integrations/pi/components/shell-editor-autocomplete.d.ts +3 -2
  170. package/dist/integrations/pi/components/shell-footer-status.d.ts +2 -2
  171. package/dist/integrations/pi/components/shell-footer-status.js +3 -2
  172. package/dist/integrations/pi/components/shell-presenters-info.d.ts +6 -5
  173. package/dist/integrations/pi/components/shell-presenters-info.js +2 -1
  174. package/dist/integrations/pi/components/shell-session-info-reference.d.ts +2 -1
  175. package/dist/integrations/pi/components/shell-shared-facade.d.ts +33 -227
  176. package/dist/integrations/pi/components/shell-shared-facade.js +8 -1
  177. package/dist/integrations/pi/components/skills-command.d.ts +1 -9
  178. package/dist/integrations/pi/components/skills-command.js +5 -5
  179. package/dist/integrations/pi/components/theme.d.ts +9 -2
  180. package/dist/integrations/pi/components/theme.js +17 -2
  181. package/dist/integrations/pi/components/thinking-selector-dialog.d.ts +2 -1
  182. package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.d.ts +2 -2
  183. package/dist/integrations/pi/engine/adapter.d.ts +4 -13
  184. package/dist/integrations/pi/engine/adapter.js +9 -61
  185. package/dist/integrations/pi/engine/changelog.d.ts +2 -2
  186. package/dist/integrations/pi/engine/changelog.js +3 -3
  187. package/dist/integrations/pi/engine/compaction-progress.d.ts +2 -3
  188. package/dist/integrations/pi/engine/compaction-progress.js +1 -1
  189. package/dist/integrations/pi/engine/conformance.d.ts +2 -1
  190. package/dist/integrations/pi/engine/default-model-setting.d.ts +0 -2
  191. package/dist/integrations/pi/engine/default-model-setting.js +1 -2
  192. package/dist/integrations/pi/engine/event-delivery.d.ts +2 -1
  193. package/dist/integrations/pi/engine/extension-ui-binding.d.ts +2 -1
  194. package/dist/integrations/pi/engine/host.js +3 -3
  195. package/dist/integrations/pi/engine/message-values.d.ts +0 -1
  196. package/dist/integrations/pi/engine/message-values.js +1 -1
  197. package/dist/integrations/pi/engine/pending-delivery.d.ts +0 -4
  198. package/dist/integrations/pi/engine/pending-delivery.js +3 -3
  199. package/dist/integrations/pi/engine/ports.d.ts +7 -1
  200. package/dist/integrations/pi/engine/ports.js +4 -0
  201. package/dist/integrations/pi/engine/project-trust-preflight.d.ts +2 -1
  202. package/dist/integrations/pi/engine/prompt-suggestions.d.ts +3 -2
  203. package/dist/integrations/pi/engine/provider-authentication.d.ts +1 -1
  204. package/dist/integrations/pi/engine/public-main-entry.d.ts +1 -5
  205. package/dist/integrations/pi/engine/public-main-entry.js +1 -1
  206. package/dist/integrations/pi/engine/repository-metadata.d.ts +49 -0
  207. package/dist/integrations/pi/engine/repository-metadata.js +189 -0
  208. package/dist/integrations/pi/engine/repository-pr-rest.d.ts +1 -9
  209. package/dist/integrations/pi/engine/repository-pr-rest.js +2 -2
  210. package/dist/integrations/pi/engine/repository-pr.d.ts +1 -3
  211. package/dist/integrations/pi/engine/repository-pr.js +1 -1
  212. package/dist/integrations/pi/engine/resource-catalog.d.ts +2 -1
  213. package/dist/integrations/pi/engine/session-integration.d.ts +1 -1
  214. package/dist/integrations/pi/engine/session-runtime.d.ts +7 -12
  215. package/dist/integrations/pi/engine/session-runtime.js +21 -178
  216. package/dist/integrations/pi/engine/settings-bridge.d.ts +0 -2
  217. package/dist/integrations/pi/engine/settings-bridge.js +1 -1
  218. package/dist/integrations/pi/engine/settings-port.d.ts +3 -2
  219. package/dist/integrations/pi/engine/transcript-projection.d.ts +2 -1
  220. package/dist/integrations/pi/engine/view-state.d.ts +21 -2
  221. package/dist/integrations/pi/engine/view-state.js +129 -1
  222. package/dist/integrations/pi/engine/workflow-contexts.d.ts +1 -1
  223. package/dist/integrations/pi/engine/workflow-runner.d.ts +1 -2
  224. package/dist/integrations/pi/engine/workflow-runner.js +254 -365
  225. package/dist/integrations/pi/engine/workflow-share.d.ts +9 -0
  226. package/dist/integrations/pi/engine/workflow-share.js +168 -0
  227. package/dist/integrations/pi/engine/workflow-support.d.ts +0 -20
  228. package/dist/integrations/pi/engine/workflow-support.js +4 -65
  229. package/dist/integrations/pi/engine/workflows.d.ts +5 -5
  230. package/dist/integrations/pi/session-presenters/components.d.ts +3 -0
  231. package/dist/integrations/pi/session-presenters/components.js +75 -0
  232. package/dist/integrations/pi/session-presenters/index.d.ts +1 -0
  233. package/dist/integrations/pi/session-presenters/index.js +1 -0
  234. package/dist/integrations/pi/session-presenters/presentation.d.ts +3 -0
  235. package/dist/integrations/pi/session-presenters/presentation.js +10 -0
  236. package/dist/integrations/pi/session-presenters/presenters.d.ts +2 -1
  237. package/dist/integrations/pi/session-presenters/presenters.js +3 -1
  238. package/dist/integrations/pi/tui-runtime/adapter.d.ts +9 -19
  239. package/dist/integrations/pi/tui-runtime/adapter.js +56 -174
  240. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +9 -44
  241. package/dist/integrations/pi/tui-runtime/index.d.ts +1 -1
  242. package/dist/integrations/pi/tui-runtime/index.js +1 -0
  243. package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.d.ts +4 -6
  244. package/dist/integrations/pi/tui-runtime/overlay-geometry.d.ts +4 -10
  245. package/dist/integrations/pi/tui-runtime/overlay-geometry.js +3 -9
  246. package/dist/integrations/pi/tui-runtime/presentation-adapter.d.ts +2 -2
  247. package/dist/integrations/pi/tui-runtime/runtime-factory.d.ts +3 -0
  248. package/dist/integrations/pi/tui-runtime/runtime-factory.js +11 -0
  249. package/dist/ui/components/index.d.ts +2 -2
  250. package/dist/ui/components/index.js +1 -1
  251. package/dist/ui/components/selection-copy.d.ts +0 -1
  252. package/dist/ui/components/selection-copy.js +0 -12
  253. package/dist/ui/components/theme.d.ts +4 -19
  254. package/dist/ui/components/theme.js +6 -0
  255. package/dist/ui/components/transcript-viewport-frame.d.ts +120 -0
  256. package/dist/ui/components/transcript-viewport-frame.js +314 -0
  257. package/dist/ui/components/transcript-viewport-types.d.ts +147 -0
  258. package/dist/ui/components/transcript-viewport-types.js +1 -0
  259. package/dist/ui/components/transcript-viewport.d.ts +2 -147
  260. package/dist/ui/components/transcript-viewport.js +87 -315
  261. package/dist/ui/settings/declarations.d.ts +2 -3
  262. package/dist/ui/settings/declarations.js +2 -3
  263. package/dist/ui/settings/early-accent.js +1 -1
  264. package/dist/ui/settings/index.d.ts +3 -5
  265. package/dist/ui/settings/index.js +2 -3
  266. package/dist/ui/settings/manager.d.ts +0 -4
  267. package/dist/ui/settings/manager.js +6 -62
  268. package/dist/ui/settings/resolution.d.ts +6 -18
  269. package/dist/ui/settings/resolution.js +4 -103
  270. package/dist/ui/settings/sections.d.ts +0 -4
  271. package/dist/ui/settings/sections.js +1 -1
  272. package/docs/architecture/boundaries.md +2 -2
  273. package/docs/architecture/internal-naming.md +2 -0
  274. package/docs/architecture/project-structure.md +4 -2
  275. package/docs/validation.md +1 -1
  276. package/package.json +3 -4
  277. package/dist/integrations/pi/components/components.d.ts +0 -4
  278. package/dist/integrations/pi/components/components.js +0 -48
  279. package/dist/integrations/pi/components/conformance.d.ts +0 -18
  280. package/dist/integrations/pi/components/conformance.js +0 -70
  281. package/dist/integrations/pi/components/shell-components.d.ts +0 -7
  282. package/dist/integrations/pi/components/shell-components.js +0 -7
  283. package/dist/integrations/pi/components/upstream/theme/theme-controller.d.ts +0 -33
  284. package/dist/integrations/pi/components/upstream/theme/theme-controller.js +0 -114
  285. package/dist/integrations/pi/engine/diagnostics-state.d.ts +0 -9
  286. package/dist/integrations/pi/engine/diagnostics-state.js +0 -34
  287. package/dist/integrations/pi/engine/usage-view.d.ts +0 -4
  288. package/dist/integrations/pi/engine/usage-view.js +0 -56
  289. package/dist/integrations/pi/tui-runtime/contracts.d.ts +0 -166
  290. package/dist/ui/settings/migrations.d.ts +0 -19
  291. package/dist/ui/settings/migrations.js +0 -225
  292. package/dist/ui/settings/progress-palette.generated.d.ts +0 -139
  293. package/dist/ui/settings/progress-palette.generated.js +0 -139
  294. /package/dist/{integrations/pi/tui-runtime/contracts.js → contracts/owned-ui/shell-components.js} +0 -0
  295. /package/dist/{foundation/release → contracts/presentation}/progress-palette.generated.d.ts +0 -0
  296. /package/dist/{foundation/release → contracts/presentation}/progress-palette.generated.js +0 -0
@@ -128,7 +128,7 @@ export class PiTuiRuntimeAdapter {
128
128
  #rootBridge;
129
129
  #bridges = new WeakMap();
130
130
  #mountedComponents = new Set();
131
- #scrollViews = new Map();
131
+ #scrollIds = new Set();
132
132
  #overlayGeometry;
133
133
  #overlayDisposers = new Set();
134
134
  #overlayInputCoordination = new Map();
@@ -136,8 +136,6 @@ export class PiTuiRuntimeAdapter {
136
136
  #preInputListeners = new Set();
137
137
  #consumeUnhandledMouse;
138
138
  #inputCoordinator;
139
- #inputDiagnostics;
140
- #diagnosticNow;
141
139
  #inputSink;
142
140
  #state = "idle";
143
141
  #stopPromise;
@@ -149,15 +147,14 @@ export class PiTuiRuntimeAdapter {
149
147
  this.#overlayGeometry = options.onOverlayGeometry === undefined ? undefined : new OverlayGeometryTracker(options.onOverlayGeometry);
150
148
  this.#terminal = options.terminal ?? new ProcessTerminal();
151
149
  this.#consumeUnhandledMouse = options.consumeUnhandledMouse ?? false;
152
- this.#inputDiagnostics = options.inputDiagnostics;
153
- this.#diagnosticNow = options.inputDiagnostics?.now ?? (() => performance.now());
150
+ const diagnostics = options.inputDiagnostics;
151
+ const diagnosticNow = diagnostics?.now ?? (() => performance.now());
152
+ const tracePhase = diagnostics === undefined ? undefined : runtimePhaseTracer(diagnostics, diagnosticNow, () => this.#inputCoordinator);
154
153
  // Invariant: the pinned renderer's frames pass through this gate, while writeControl and
155
154
  // the stop sequence reach the terminal directly. Freezing drops frames without touching
156
155
  // the renderer, so a scheduled repaint cannot land on top of the quit outro.
157
156
  const gatedTerminal = frozenGateTerminal(this.#terminal, () => this.#presentationFrozen || this.#presentationHolds.size > 0);
158
- const tracedTerminal = options.inputDiagnostics === undefined
159
- ? gatedTerminal
160
- : diagnosticTerminal(gatedTerminal, phase => this.#traceRuntimePhase(phase));
157
+ const tracedTerminal = tracePhase === undefined ? gatedTerminal : diagnosticTerminal(gatedTerminal, tracePhase);
161
158
  const decoratedTerminal = options.decorateTerminal?.(tracedTerminal) ?? tracedTerminal;
162
159
  const coordination = options.inputCoordination ?? (options.inputDiagnostics === undefined
163
160
  ? undefined
@@ -173,10 +170,8 @@ export class PiTuiRuntimeAdapter {
173
170
  },
174
171
  ...(coordination.onReceipt === undefined ? {} : { onReceipt: coordination.onReceipt }),
175
172
  ...(coordination.scheduler === undefined ? {} : { scheduler: coordination.scheduler }),
176
- now: this.#diagnosticNow,
177
- ...(options.inputDiagnostics === undefined ? {} : {
178
- onTrace: event => this.#traceInputCoordination(event),
179
- }),
173
+ now: diagnosticNow,
174
+ ...(diagnostics === undefined ? {} : { onTrace: event => diagnostics.onEvent(event) }),
180
175
  });
181
176
  this.#tuiTerminal = this.#inputCoordinator === undefined
182
177
  ? preInputTerminal(decoratedTerminal, data => this.#routePreInput(data), this.#overlayGeometry !== undefined)
@@ -187,9 +182,7 @@ export class PiTuiRuntimeAdapter {
187
182
  this.#tuiTerminal.restoreOnExit = (before, after) => exitTerminal.restoreOnExit?.(before, after);
188
183
  this.#layoutRoot = options.layoutRoot;
189
184
  this.#logDirectory = options.logDirectory;
190
- this.#rootBridge = new ComponentBridge(options.root, options.inputDiagnostics === undefined
191
- ? undefined
192
- : phase => this.#traceRuntimePhase(phase));
185
+ this.#rootBridge = new ComponentBridge(options.root, tracePhase);
193
186
  this.#bridges.set(options.root, this.#rootBridge);
194
187
  this.#mountedComponents.add(options.root);
195
188
  try {
@@ -229,53 +222,6 @@ export class PiTuiRuntimeAdapter {
229
222
  rows: Math.max(1, this.#terminal.rows),
230
223
  };
231
224
  }
232
- scrollState(id) {
233
- if (id === undefined) {
234
- if (!(this.#tui instanceof TuiAltScreen)) {
235
- throw new Error("Pi TUI application scrolling is available only in fullscreen mode");
236
- }
237
- return {
238
- scrollTop: this.#tui.viewportTop,
239
- viewportHeight: this.viewport().rows,
240
- followingEnd: this.#tui.isFollowingOutput,
241
- scrollbarVisible: false,
242
- };
243
- }
244
- const scrollView = this.#requireScrollView(id);
245
- return {
246
- scrollTop: scrollView.scrollTop,
247
- viewportHeight: scrollView.viewportHeight,
248
- followingEnd: scrollView.isFollowingEnd,
249
- scrollbarVisible: scrollView.isScrollbarVisible,
250
- };
251
- }
252
- scrollBy(lines, id) {
253
- this.#assertRunning("scroll");
254
- if (id === undefined)
255
- this.#requireFullscreen().scrollBy(lines);
256
- else {
257
- this.#requireScrollView(id).scrollBy(lines);
258
- this.#tui.requestRender();
259
- }
260
- }
261
- scrollToTop(id) {
262
- this.#assertRunning("scroll");
263
- if (id === undefined)
264
- this.#requireFullscreen().scrollToTop();
265
- else {
266
- this.#requireScrollView(id).scrollToStart();
267
- this.#tui.requestRender();
268
- }
269
- }
270
- scrollToBottom(id) {
271
- this.#assertRunning("scroll");
272
- if (id === undefined)
273
- this.#requireFullscreen().scrollToBottom();
274
- else {
275
- this.#requireScrollView(id).scrollToEnd();
276
- this.#tui.requestRender();
277
- }
278
- }
279
225
  start() {
280
226
  if (this.#state === "running")
281
227
  return;
@@ -293,12 +239,6 @@ export class PiTuiRuntimeAdapter {
293
239
  throw new PiTuiRuntimeError("start", error);
294
240
  }
295
241
  }
296
- setFocus(component) {
297
- this.#assertRunning("focus");
298
- if (this.#overlayInputCoordination.size > 0)
299
- this.#overlayGeometry?.invalidate();
300
- this.#tui.setFocus(this.#bridgeFor(component));
301
- }
302
242
  showOverlay(component, options) {
303
243
  this.#assertRunning("overlay");
304
244
  if (this.#bridges.has(component))
@@ -347,9 +287,6 @@ export class PiTuiRuntimeAdapter {
347
287
  this.#assertRunning("presentation freeze");
348
288
  this.#presentationFrozen = true;
349
289
  }
350
- get presentationFrozen() {
351
- return this.#presentationFrozen;
352
- }
353
290
  /**
354
291
  * Keeps asynchronous replacement-surface construction atomic at the terminal. Renderers may
355
292
  * compose while held, but their writes are dropped until the final forced repaint on release.
@@ -401,7 +338,7 @@ export class PiTuiRuntimeAdapter {
401
338
  previous.clear();
402
339
  if (previous instanceof TuiAltScreen)
403
340
  previous.setLayoutRoot(undefined);
404
- this.#scrollViews.clear();
341
+ this.#scrollIds.clear();
405
342
  const next = this.#createTui(mode, hardwareCursor);
406
343
  next.setClearOnShrink(clearOnShrink);
407
344
  this.#mountTui(next);
@@ -424,9 +361,6 @@ export class PiTuiRuntimeAdapter {
424
361
  if (this.active)
425
362
  this.#tui.requestRender();
426
363
  }
427
- getHardwareCursor() {
428
- return this.#tui.getShowHardwareCursor();
429
- }
430
364
  setClearOnShrink(enabled) {
431
365
  this.#tui.setClearOnShrink(enabled);
432
366
  }
@@ -435,9 +369,6 @@ export class PiTuiRuntimeAdapter {
435
369
  if (this.#tui instanceof TuiAltScreen)
436
370
  this.#tui.setWheelScrollLines(lines);
437
371
  }
438
- getClearOnShrink() {
439
- return this.#tui.getClearOnShrink();
440
- }
441
372
  setTerminalProgress(active) {
442
373
  if (this.#terminalProgress === active)
443
374
  return;
@@ -450,11 +381,6 @@ export class PiTuiRuntimeAdapter {
450
381
  setTitle(title) {
451
382
  this.#terminal.setTitle(title);
452
383
  }
453
- /** Shows a bounded fullscreen acknowledgement without changing root layout geometry. */
454
- showFlash(message, durationMs) {
455
- this.#assertRunning("flash");
456
- this.#requireFullscreen().flash(message, durationMs);
457
- }
458
384
  writeAfterStop(text) {
459
385
  if (this.#state !== "stopped")
460
386
  throw new Error("terminal output requires a stopped Pi TUI runtime");
@@ -560,22 +486,6 @@ export class PiTuiRuntimeAdapter {
560
486
  }
561
487
  return undefined;
562
488
  }
563
- #traceInputCoordination(event) {
564
- this.#inputDiagnostics?.onEvent(event);
565
- }
566
- #traceRuntimePhase(phase) {
567
- if (this.#inputDiagnostics === undefined)
568
- return;
569
- const coordinator = this.#inputCoordinator;
570
- this.#inputDiagnostics.onEvent({
571
- phase,
572
- revision: coordinator?.appliedRevision ?? 0,
573
- atMs: this.#diagnosticNow(),
574
- pendingDepth: coordinator?.pendingDepth ?? 0,
575
- pendingPresentationDepth: coordinator?.pendingPresentation === true ? 1 : 0,
576
- appliedRevision: coordinator?.appliedRevision ?? 0,
577
- });
578
- }
579
489
  #mountTui(tui) {
580
490
  tui.addChild(this.#rootBridge);
581
491
  if (tui instanceof TuiAltScreen && this.#layoutRoot !== undefined) {
@@ -603,7 +513,7 @@ export class PiTuiRuntimeAdapter {
603
513
  if (node.type === "component")
604
514
  return this.#mount(node.component);
605
515
  if (node.type === "scroll") {
606
- if (this.#scrollViews.has(node.id))
516
+ if (this.#scrollIds.has(node.id))
607
517
  throw new TypeError(`duplicate Pi TUI scroll layout id: ${node.id}`);
608
518
  const options = {
609
519
  ...(node.follow === undefined ? {} : { follow: node.follow }),
@@ -614,9 +524,8 @@ export class PiTuiRuntimeAdapter {
614
524
  ...(node.scrollbarThumbStyle === undefined ? {} : { scrollbarThumbStyle: node.scrollbarThumbStyle }),
615
525
  ...(node.scrollbarHideDelayMs === undefined ? {} : { scrollbarHideDelayMs: node.scrollbarHideDelayMs }),
616
526
  };
617
- const scrollView = new ScrollView(this.#buildLayout(node.child), options);
618
- this.#scrollViews.set(node.id, scrollView);
619
- return scrollView;
527
+ this.#scrollIds.add(node.id);
528
+ return new ScrollView(this.#buildLayout(node.child), options);
620
529
  }
621
530
  const children = node.children.map(entry => ({
622
531
  component: this.#buildLayout(entry.node),
@@ -633,19 +542,6 @@ export class PiTuiRuntimeAdapter {
633
542
  };
634
543
  return node.direction === "vertical" ? new VStack(children, options) : new HStack(children, options);
635
544
  }
636
- #requireFullscreen() {
637
- if (!(this.#tui instanceof TuiAltScreen)) {
638
- throw new Error("Pi TUI application scrolling is available only in fullscreen mode");
639
- }
640
- return this.#tui;
641
- }
642
- #requireScrollView(id) {
643
- this.#requireFullscreen();
644
- const scrollView = this.#scrollViews.get(id);
645
- if (!scrollView)
646
- throw new TypeError(`unknown Pi TUI scroll layout id: ${id}`);
647
- return scrollView;
648
- }
649
545
  #assertRunning(operation) {
650
546
  if (!this.active)
651
547
  throw new Error(`Pi TUI ${operation} requires a running runtime`);
@@ -706,12 +602,33 @@ export class PiTuiRuntimeAdapter {
706
602
  this.#disposeRoot();
707
603
  }
708
604
  }
709
- function coordinatedInputTerminal(terminal, coordinator, setSink, frameMouse) {
710
- const mouse = frameMouse ? new MouseReportInput(data => coordinator.accept(data)) : undefined;
605
+ /**
606
+ * Forwards every terminal member to `terminal` unless `overrides` replaces it.
607
+ * Invariant: the size and keyboard getters stay live; spreading the inner terminal would freeze them.
608
+ */
609
+ function forwardingTerminal(terminal, overrides = {}) {
711
610
  return {
712
611
  get columns() { return terminal.columns; },
713
612
  get rows() { return terminal.rows; },
714
613
  get kittyProtocolActive() { return terminal.kittyProtocolActive; },
614
+ start: overrides.start ?? ((onInput, onResize) => terminal.start(onInput, onResize)),
615
+ stop: overrides.stop ?? (() => terminal.stop()),
616
+ drainInput: overrides.drainInput ?? ((maxMs, idleMs) => terminal.drainInput(maxMs, idleMs)),
617
+ write: overrides.write ?? (data => terminal.write(data)),
618
+ moveBy: overrides.moveBy ?? (lines => terminal.moveBy(lines)),
619
+ hideCursor: overrides.hideCursor ?? (() => terminal.hideCursor()),
620
+ showCursor: overrides.showCursor ?? (() => terminal.showCursor()),
621
+ clearLine: overrides.clearLine ?? (() => terminal.clearLine()),
622
+ clearFromCursor: overrides.clearFromCursor ?? (() => terminal.clearFromCursor()),
623
+ clearScreen: overrides.clearScreen ?? (() => terminal.clearScreen()),
624
+ setTitle: overrides.setTitle ?? (title => terminal.setTitle(title)),
625
+ setProgress: overrides.setProgress ?? (active => terminal.setProgress(active)),
626
+ setProgramStatus: overrides.setProgramStatus ?? (status => terminal.setProgramStatus?.(status)),
627
+ };
628
+ }
629
+ function coordinatedInputTerminal(terminal, coordinator, setSink, frameMouse) {
630
+ const mouse = frameMouse ? new MouseReportInput(data => coordinator.accept(data)) : undefined;
631
+ return forwardingTerminal(terminal, {
715
632
  start(onInput, onResize) {
716
633
  setSink(onInput);
717
634
  terminal.start(data => mouse === undefined ? coordinator.accept(data) : mouse.accept(data), () => {
@@ -726,27 +643,10 @@ function coordinatedInputTerminal(terminal, coordinator, setSink, frameMouse) {
726
643
  setSink(undefined);
727
644
  terminal.stop();
728
645
  },
729
- drainInput: (maxMs, idleMs) => terminal.drainInput(maxMs, idleMs),
730
- write: data => terminal.write(data),
731
- moveBy: lines => terminal.moveBy(lines),
732
- hideCursor: () => terminal.hideCursor(),
733
- showCursor: () => terminal.showCursor(),
734
- clearLine: () => terminal.clearLine(),
735
- clearFromCursor: () => terminal.clearFromCursor(),
736
- clearScreen: () => terminal.clearScreen(),
737
- setTitle: title => terminal.setTitle(title),
738
- setProgress: active => terminal.setProgress(active),
739
- setProgramStatus: status => terminal.setProgramStatus?.(status),
740
- };
646
+ });
741
647
  }
742
648
  function diagnosticTerminal(terminal, trace) {
743
- return {
744
- get columns() { return terminal.columns; },
745
- get rows() { return terminal.rows; },
746
- get kittyProtocolActive() { return terminal.kittyProtocolActive; },
747
- start: (onInput, onResize) => terminal.start(onInput, onResize),
748
- stop: () => terminal.stop(),
749
- drainInput: (maxMs, idleMs) => terminal.drainInput(maxMs, idleMs),
649
+ return forwardingTerminal(terminal, {
750
650
  write(data) {
751
651
  trace("write-start");
752
652
  try {
@@ -756,25 +656,10 @@ function diagnosticTerminal(terminal, trace) {
756
656
  trace("write-end");
757
657
  }
758
658
  },
759
- moveBy: lines => terminal.moveBy(lines),
760
- hideCursor: () => terminal.hideCursor(),
761
- showCursor: () => terminal.showCursor(),
762
- clearLine: () => terminal.clearLine(),
763
- clearFromCursor: () => terminal.clearFromCursor(),
764
- clearScreen: () => terminal.clearScreen(),
765
- setTitle: title => terminal.setTitle(title),
766
- setProgress: active => terminal.setProgress(active),
767
- setProgramStatus: status => terminal.setProgramStatus?.(status),
768
- };
659
+ });
769
660
  }
770
661
  function frozenGateTerminal(terminal, frozen) {
771
- return {
772
- get columns() { return terminal.columns; },
773
- get rows() { return terminal.rows; },
774
- get kittyProtocolActive() { return terminal.kittyProtocolActive; },
775
- start: (onInput, onResize) => terminal.start(onInput, onResize),
776
- stop: () => terminal.stop(),
777
- drainInput: (maxMs, idleMs) => terminal.drainInput(maxMs, idleMs),
662
+ return forwardingTerminal(terminal, {
778
663
  write: data => { if (!frozen())
779
664
  terminal.write(data); },
780
665
  moveBy: lines => { if (!frozen())
@@ -789,17 +674,11 @@ function frozenGateTerminal(terminal, frozen) {
789
674
  terminal.clearFromCursor(); },
790
675
  clearScreen: () => { if (!frozen())
791
676
  terminal.clearScreen(); },
792
- setTitle: title => terminal.setTitle(title),
793
- setProgress: active => terminal.setProgress(active),
794
- setProgramStatus: status => terminal.setProgramStatus?.(status),
795
- };
677
+ });
796
678
  }
797
679
  function preInputTerminal(terminal, route, frameMouse) {
798
680
  let mouse;
799
- return {
800
- get columns() { return terminal.columns; },
801
- get rows() { return terminal.rows; },
802
- get kittyProtocolActive() { return terminal.kittyProtocolActive; },
681
+ return forwardingTerminal(terminal, {
803
682
  start(onInput, onResize) {
804
683
  const deliver = (data) => {
805
684
  const routed = route(data);
@@ -813,18 +692,7 @@ function preInputTerminal(terminal, route, frameMouse) {
813
692
  });
814
693
  },
815
694
  stop: () => { mouse?.reset(); terminal.stop(); },
816
- drainInput: (maxMs, idleMs) => terminal.drainInput(maxMs, idleMs),
817
- write: data => terminal.write(data),
818
- moveBy: lines => terminal.moveBy(lines),
819
- hideCursor: () => terminal.hideCursor(),
820
- showCursor: () => terminal.showCursor(),
821
- clearLine: () => terminal.clearLine(),
822
- clearFromCursor: () => terminal.clearFromCursor(),
823
- clearScreen: () => terminal.clearScreen(),
824
- setTitle: title => terminal.setTitle(title),
825
- setProgress: active => terminal.setProgress(active),
826
- setProgramStatus: status => terminal.setProgramStatus?.(status),
827
- };
695
+ });
828
696
  }
829
697
  function toOverlayOptions(options) {
830
698
  if (options === undefined)
@@ -854,3 +722,17 @@ function toOverlayOptions(options) {
854
722
  mapped.nonCapturing = options.nonCapturing;
855
723
  return mapped;
856
724
  }
725
+ /** Reports one runtime phase with the input coordinator's depth and revision at that moment. */
726
+ function runtimePhaseTracer(diagnostics, now, coordinator) {
727
+ return phase => {
728
+ const current = coordinator();
729
+ diagnostics.onEvent({
730
+ phase,
731
+ revision: current?.appliedRevision ?? 0,
732
+ atMs: now(),
733
+ pendingDepth: current?.pendingDepth ?? 0,
734
+ pendingPresentationDepth: current?.pendingPresentation === true ? 1 : 0,
735
+ appliedRevision: current?.appliedRevision ?? 0,
736
+ });
737
+ };
738
+ }
@@ -1,45 +1,10 @@
1
- import type { PiTuiTerminalPort } from "./contracts.js";
1
+ import type { TerminalPort } from "../../../contracts/presentation/index.js";
2
2
  export declare const PINNED_PI_TUI_DAMAGE_GRAMMAR = "@earendil-works/pi-tui@1.5.0:tui-alt-screen-one-write-v1";
3
- export interface PiTuiDamageFrameDescriptor {
4
- /**
5
- * Frame ids are compared only within one presentation epoch; absent means the current epoch. A
6
- * presenter switch starts a new epoch, because each presenter numbers its own frames.
7
- */
8
- readonly epoch?: number;
9
- readonly frameId: number;
10
- readonly width: number;
11
- readonly height: number;
12
- readonly transcript: {
13
- readonly rowStart: number;
14
- readonly rowEnd: number;
15
- } | null;
16
- readonly dock: {
17
- readonly rowStart: number;
18
- readonly rowEnd: number;
19
- } | null;
20
- /**
21
- * Visible rows owned by the block that is currently streaming. A live block repaints
22
- * every row it owns when it reflows, so the allowed damage follows the declared tail
23
- * instead of assuming a one-row tail.
24
- */
25
- readonly liveTailRows?: number;
26
- readonly verticalShiftRows: number;
27
- readonly safeVerticalShift: boolean;
28
- readonly cause: string;
29
- }
30
- export interface PiTuiDamageFrameSafety {
31
- readonly overlayActive: boolean;
32
- readonly selectionActive: boolean;
33
- readonly replacementSurfaceActive: boolean;
34
- }
35
- export type PiTuiDamageDecisionReason = "transformed" | "suppressed-redundant-clear" | "hyperlink-cleanup" | "pending-hyperlink-cleanup" | "not-armed" | "unsafe-frame" | "stale-frame" | "unsupported-region-scroll" | "geometry-mismatch" | "grammar-mismatch" | "unsafe-terminal-content" | "incomplete-prior-frame" | "excessive-real-damage";
36
- export interface PiTuiDamageDecision {
37
- readonly frameId: number | null;
38
- readonly transformed: boolean;
39
- readonly reason: PiTuiDamageDecisionReason;
40
- readonly shiftRows: number;
41
- readonly paintedRows: readonly number[];
42
- }
3
+ import type { TerminalDamageDecision, TerminalDamageDecisionReason, TerminalDamageFrameDescriptor, TerminalDamageFrameSafety } from "../../../contracts/presentation/index.js";
4
+ export type PiTuiDamageFrameDescriptor = TerminalDamageFrameDescriptor;
5
+ export type PiTuiDamageFrameSafety = TerminalDamageFrameSafety;
6
+ export type PiTuiDamageDecisionReason = TerminalDamageDecisionReason;
7
+ export type PiTuiDamageDecision = TerminalDamageDecision;
43
8
  export interface DamageAwareTerminalOptions {
44
9
  readonly regionalScroll: boolean;
45
10
  /** The shell supplies visible-row analysis; the terminal layer owns no UI parser. */
@@ -69,11 +34,11 @@ export interface DamageAwareTerminalOptions {
69
34
  * viewport metadata authorizes a shift; bytes are inspected only to validate
70
35
  * and preserve Pi's complete row paint and cursor syntax.
71
36
  */
72
- export declare class DamageAwareTerminalAdapter implements PiTuiTerminalPort {
37
+ export declare class DamageAwareTerminalAdapter implements TerminalPort {
73
38
  #private;
74
- readonly inner: PiTuiTerminalPort;
39
+ readonly inner: TerminalPort;
75
40
  readonly options: DamageAwareTerminalOptions;
76
- constructor(inner: PiTuiTerminalPort, options: DamageAwareTerminalOptions);
41
+ constructor(inner: TerminalPort, options: DamageAwareTerminalOptions);
77
42
  get columns(): number;
78
43
  get rows(): number;
79
44
  get kittyProtocolActive(): boolean;
@@ -1,5 +1,5 @@
1
- export type { PiTuiComponentPort, PiTuiInputDiagnosticsEvent, PiTuiInputDiagnosticsPhase, PiTuiInputListener, PiTuiInputListenerResult, PiTuiLayoutEntry, PiTuiLayoutNode, PiTuiOverlayAnchor, PiTuiOverlayHandle, PiTuiOverlayMargin, PiTuiOverlayOptions, PiTuiOverlayUnfocusOptions, PiTuiPointerSurface, PiTuiPreInputListener, PiTuiRuntimeAdapterOptions, PiTuiRuntimeState, PiTuiScrollState, PiTuiSizeValue, PiTuiStopOptions, PiTuiTerminalPort, PiTuiViewport, } from "./contracts.js";
2
1
  export { samePointerSurfaces } from "./overlay-geometry.js";
2
+ export { PI_TERMINAL_RUNTIME } from "./runtime-factory.js";
3
3
  export { DamageAwareTerminalAdapter, PINNED_PI_TUI_DAMAGE_GRAMMAR, paintTerminalCanvasFrame, rebaseTerminalDefaultBackground, } from "./damage-aware-terminal.js";
4
4
  export type { DamageAwareTerminalOptions, PiTuiDamageDecision, PiTuiDamageDecisionReason, PiTuiDamageFrameDescriptor, PiTuiDamageFrameSafety, } from "./damage-aware-terminal.js";
5
5
  export { InputPresentationCoordinator, classifyPiTuiInput } from "./input-presentation-coordinator.js";
@@ -1,4 +1,5 @@
1
1
  export { samePointerSurfaces } from "./overlay-geometry.js";
2
+ export { PI_TERMINAL_RUNTIME } from "./runtime-factory.js";
2
3
  export { DamageAwareTerminalAdapter, PINNED_PI_TUI_DAMAGE_GRAMMAR, paintTerminalCanvasFrame, rebaseTerminalDefaultBackground, } from "./damage-aware-terminal.js";
3
4
  export { InputPresentationCoordinator, classifyPiTuiInput } from "./input-presentation-coordinator.js";
4
5
  export { PiTuiRuntimeAdapter, PiTuiRuntimeError } from "./adapter.js";
@@ -1,9 +1,7 @@
1
- export type PiTuiInputCoordinationDecision = "safe" | "barrier";
2
- export type PiTuiInputSurfaceKind = "editor" | "owned" | "opaque";
3
- export interface PiTuiInputCoordinationScheduler {
4
- scheduleImmediate(callback: () => void): ReturnType<typeof setImmediate>;
5
- cancelImmediate(handle: ReturnType<typeof setImmediate>): void;
6
- }
1
+ import type { TerminalInputCoordinationDecision, TerminalInputCoordinationScheduler, TerminalInputSurfaceKind } from "../../../contracts/presentation/index.js";
2
+ export type PiTuiInputCoordinationDecision = TerminalInputCoordinationDecision;
3
+ export type PiTuiInputSurfaceKind = TerminalInputSurfaceKind;
4
+ export type PiTuiInputCoordinationScheduler = TerminalInputCoordinationScheduler;
7
5
  export interface PiTuiInputCoordinationTrace {
8
6
  readonly phase: "receipt" | "semantic-start" | "semantic-end";
9
7
  readonly revision: number;
@@ -1,6 +1,7 @@
1
1
  import { TuiAltScreen, type Component, type OverlayHandle, type OverlayOptions } from "@earendil-works/pi-tui";
2
2
  import type { PresentationComponentPort, PresentationPointerSurface } from "../../../contracts/presentation/index.js";
3
- import type { PiTuiOverlayOptions } from "./contracts.js";
3
+ import { samePointerSurfaces } from "../../../contracts/presentation/index.js";
4
+ import type { TerminalOverlayOptions } from "../../../contracts/presentation/index.js";
4
5
  /** Observes public component renders in compositor order, without accessing renderer state. */
5
6
  export declare class OverlayGeometryTracker {
6
7
  #private;
@@ -9,7 +10,7 @@ export declare class OverlayGeometryTracker {
9
10
  constructor(publish: (surfaces: readonly PresentationPointerSurface[] | null) => void);
10
11
  invalidate(): void;
11
12
  begin(columns: number, rows: number): void;
12
- record(component: PresentationComponentPort, options: PiTuiOverlayOptions | undefined, width: number, height: number): void;
13
+ record(component: PresentationComponentPort, options: TerminalOverlayOptions | undefined, width: number, height: number): void;
13
14
  end(): void;
14
15
  }
15
16
  /** The protected composition hook brackets the actual visible, focus-ordered overlay renders. */
@@ -22,11 +23,4 @@ export declare class GeometryObservedAltScreen extends TuiAltScreen {
22
23
  hideOverlay(): void;
23
24
  protected compositeOverlays(lines: string[], width: number, height: number): string[];
24
25
  }
25
- /** Compare only geometry and ownership, never animation content or transcript position. */
26
- export declare function samePointerSurfaces(a: readonly PresentationPointerSurface[], b: readonly PresentationPointerSurface[]): boolean;
27
- /**
28
- * Resolve the pinned public overlay options against the actual render width/height.
29
- * The runtime still owns layout and painting. Independent terminal-cell tests certify
30
- * this option-to-hit-region projection against its compositor, including clipping.
31
- */
32
- export declare function overlayPointerSurface(component: PresentationComponentPort, options: PiTuiOverlayOptions | undefined, width: number, renderedHeight: number, columns: number, rows: number): PresentationPointerSurface | undefined;
26
+ export { samePointerSurfaces };
@@ -1,4 +1,5 @@
1
1
  import { TuiAltScreen, isFocusable } from "@earendil-works/pi-tui";
2
+ import { samePointerSurfaces } from "../../../contracts/presentation/index.js";
2
3
  /** Observes public component renders in compositor order, without accessing renderer state. */
3
4
  export class OverlayGeometryTracker {
4
5
  #frame = [];
@@ -97,20 +98,13 @@ export class GeometryObservedAltScreen extends TuiAltScreen {
97
98
  return result;
98
99
  }
99
100
  }
100
- /** Compare only geometry and ownership, never animation content or transcript position. */
101
- export function samePointerSurfaces(a, b) {
102
- return a.length === b.length && a.every((surface, index) => {
103
- const other = b[index];
104
- return surface.component === other.component && surface.columnStart === other.columnStart
105
- && surface.columnEnd === other.columnEnd && surface.rowStart === other.rowStart && surface.rowEnd === other.rowEnd;
106
- });
107
- }
101
+ export { samePointerSurfaces };
108
102
  /**
109
103
  * Resolve the pinned public overlay options against the actual render width/height.
110
104
  * The runtime still owns layout and painting. Independent terminal-cell tests certify
111
105
  * this option-to-hit-region projection against its compositor, including clipping.
112
106
  */
113
- export function overlayPointerSurface(component, options, width, renderedHeight, columns, rows) {
107
+ function overlayPointerSurface(component, options, width, renderedHeight, columns, rows) {
114
108
  const opt = options ?? {};
115
109
  const margin = typeof opt.margin === "number"
116
110
  ? { top: opt.margin, right: opt.margin, bottom: opt.margin, left: opt.margin }
@@ -1,4 +1,4 @@
1
1
  import type { PresentationComponentPort, PresentationRuntimePort, PresentationTerminalPort } from "../../../contracts/presentation/index.js";
2
- import type { PiTuiTerminalPort } from "./contracts.js";
2
+ import type { TerminalPort } from "../../../contracts/presentation/index.js";
3
3
  export declare function createPiPresentationRuntime(root: PresentationComponentPort, terminal: PresentationTerminalPort): PresentationRuntimePort;
4
- export declare function createPiTerminalBridge(terminal: PresentationTerminalPort): PiTuiTerminalPort;
4
+ export declare function createPiTerminalBridge(terminal: PresentationTerminalPort): TerminalPort;
@@ -0,0 +1,3 @@
1
+ import type { TerminalRuntimeFactory } from "../../../contracts/presentation/index.js";
2
+ /** The Pi TUI runtime behind the neutral terminal runtime factory the shell uses. */
3
+ export declare const PI_TERMINAL_RUNTIME: TerminalRuntimeFactory;
@@ -0,0 +1,11 @@
1
+ import { legacyKeyInput, PiTuiRuntimeAdapter } from "./adapter.js";
2
+ import { DamageAwareTerminalAdapter, rebaseTerminalDefaultBackground } from "./damage-aware-terminal.js";
3
+ import { classifyPiTuiInput } from "./input-presentation-coordinator.js";
4
+ /** The Pi TUI runtime behind the neutral terminal runtime factory the shell uses. */
5
+ export const PI_TERMINAL_RUNTIME = Object.freeze({
6
+ createRuntime: options => new PiTuiRuntimeAdapter(options),
7
+ createDamageTerminal: (terminal, options) => new DamageAwareTerminalAdapter(terminal, options),
8
+ classifyInput: (data, surface) => classifyPiTuiInput(data, surface),
9
+ legacyKeyInput: data => legacyKeyInput(data),
10
+ rebaseDefaultBackground: (content, backgroundAnsi) => rebaseTerminalDefaultBackground(content, backgroundAnsi),
11
+ });
@@ -44,7 +44,7 @@ export { displayColumnSlice, displayWidth, displayWordColumnRange, faint, padToW
44
44
  export type { DisplayColumnRange, DisplayColumnSlice } from "./text.js";
45
45
  export { TEXT_SELECTION_MULTI_CLICK_MS, extendTextSelection, orderedTextSelection, paintTextSelection, plainTextBetweenColumns, pressTextSelection, releaseTextSelection, textSelectionLineExtendColumn, textSelectionPointAt, textSelectionText, usefulTextLineContent, } from "./text-selection.js";
46
46
  export type { OrderedTextSelection, TextSelection, TextSelectionClick, TextSelectionLineContent, TextSelectionPoint, TextSelectionPressInput, } from "./text-selection.js";
47
- export { PLAIN_THEME } from "./theme.js";
48
- export type { UiTheme, UiThemeToken } from "./theme.js";
47
+ export { PLAIN_THEME, PLAIN_THEME_SOURCE } from "./theme.js";
48
+ export type { ThemeSource, UiTheme, UiThemeBackground, UiThemeToken } from "./theme.js";
49
49
  export { menuRowAt, renderValueMenu, valueMenuFrame } from "./value-menu.js";
50
50
  export type { ValueMenuAnchor, ValueMenuFrame, ValueMenuLayout, ValueMenuState } from "./value-menu.js";
@@ -22,5 +22,5 @@ export { TranscriptViewport, assertTranscriptViewportFrameDescriptor } from "./t
22
22
  export { RAIL_COLUMNS, renderEmptyState, withScrollbarRail } from "./surface.js";
23
23
  export { displayColumnSlice, displayWidth, displayWordColumnRange, faint, padToWidth, stripAnsi, truncateToWidth } from "./text.js";
24
24
  export { TEXT_SELECTION_MULTI_CLICK_MS, extendTextSelection, orderedTextSelection, paintTextSelection, plainTextBetweenColumns, pressTextSelection, releaseTextSelection, textSelectionLineExtendColumn, textSelectionPointAt, textSelectionText, usefulTextLineContent, } from "./text-selection.js";
25
- export { PLAIN_THEME } from "./theme.js";
25
+ export { PLAIN_THEME, PLAIN_THEME_SOURCE } from "./theme.js";
26
26
  export { menuRowAt, renderValueMenu, valueMenuFrame } from "./value-menu.js";
@@ -19,6 +19,5 @@ export interface SelectionCopySnapshot {
19
19
  readonly rejected?: "size";
20
20
  }
21
21
  export declare function selectionCopyLineContent(text: string, prompt: SelectionCopyPrompt): TextSelectionLineContent;
22
- export declare function literalSelectionCopySnapshot(text: string, revision?: number): SelectionCopySnapshot | null;
23
22
  /** Extracts one snapshot row with the existing grapheme/newline policy; run expensive rows off-thread. */
24
23
  export declare function selectionCopyRowText(snapshot: Pick<SelectionCopySnapshot, "selection" | "literal">, row: SelectionCopyRow, index: number): string;
@@ -22,18 +22,6 @@ export function selectionCopyLineContent(text, prompt) {
22
22
  return { from, to: from + 1 };
23
23
  return usefulTextLineContent(plain, from);
24
24
  }
25
- export function literalSelectionCopySnapshot(text, revision = 0) {
26
- if (text.trim().length === 0)
27
- return null;
28
- const selection = {
29
- start: { line: 0, column: 0 },
30
- end: { line: 0, column: Number.MAX_SAFE_INTEGER },
31
- };
32
- if (text.length > MAX_COPY_SOURCE_UNITS) {
33
- return { literal: true, selection, revision, rows: [], sourceUnits: 0, rejected: "size" };
34
- }
35
- return { literal: true, selection, revision, rows: [{ text }], sourceUnits: text.length };
36
- }
37
25
  /** Extracts one snapshot row with the existing grapheme/newline policy; run expensive rows off-thread. */
38
26
  export function selectionCopyRowText(snapshot, row, index) {
39
27
  if (snapshot.literal)
@@ -1,21 +1,6 @@
1
- export type UiThemeToken = "accent" | "mdHeading" | "text" | "muted" | "dim" | "border" | "error" | "success";
2
- export interface UiTheme {
3
- fg(token: UiThemeToken, text: string): string;
4
- bold(text: string): string;
5
- /**
6
- * The terminal's own foreground, left unpainted. What a list's own text is:
7
- * a theme built for a light background would otherwise write near-black rows
8
- * into a dark terminal, which is how the engine leaves its lists too.
9
- */
10
- plain(text: string): string;
11
- /** Optional palette preview used by controls that choose the active accent. */
12
- accentPreview?(color: string, text: string): string | null;
13
- /** Selection background for an active list item or floating-surface row. */
14
- highlight(text: string): string;
15
- /** A control that is present but cannot act: quieter than quiet text. */
16
- disabled(text: string): string;
17
- /** Background for a floating surface, so it reads as above the content. */
18
- panel(text: string): string;
19
- }
1
+ import type { ThemeSource, UiTheme, UiThemeBackground, UiThemeToken } from "../../contracts/presentation/index.js";
2
+ export type { ThemeSource, UiTheme, UiThemeBackground, UiThemeToken };
20
3
  /** Renders every token as plain text. What tests assert against. */
21
4
  export declare const PLAIN_THEME: UiTheme;
5
+ /** A theme source that never changes and paints nothing. */
6
+ export declare const PLAIN_THEME_SOURCE: ThemeSource;