@code-yeongyu/senpi 2026.8.1 → 2026.8.3

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 (988) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +1 -0
  3. package/dist/cli/args.d.ts +2 -0
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +27 -0
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/credential-print.d.ts +23 -0
  8. package/dist/cli/credential-print.d.ts.map +1 -0
  9. package/dist/cli/credential-print.js +116 -0
  10. package/dist/cli/credential-print.js.map +1 -0
  11. package/dist/client/index.d.ts +3 -0
  12. package/dist/client/index.d.ts.map +1 -0
  13. package/dist/client/index.js +3 -0
  14. package/dist/client/index.js.map +1 -0
  15. package/dist/client/remote-session.d.ts +53 -0
  16. package/dist/client/remote-session.d.ts.map +1 -0
  17. package/dist/client/remote-session.js +340 -0
  18. package/dist/client/remote-session.js.map +1 -0
  19. package/dist/client/transcript.d.ts +12 -0
  20. package/dist/client/transcript.d.ts.map +1 -0
  21. package/dist/client/transcript.js +98 -0
  22. package/dist/client/transcript.js.map +1 -0
  23. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  24. package/dist/core/agent-session-runtime.js +3 -0
  25. package/dist/core/agent-session-runtime.js.map +1 -1
  26. package/dist/core/agent-session.d.ts +36 -1
  27. package/dist/core/agent-session.d.ts.map +1 -1
  28. package/dist/core/agent-session.js +325 -41
  29. package/dist/core/agent-session.js.map +1 -1
  30. package/dist/core/auth-storage.d.ts +5 -0
  31. package/dist/core/auth-storage.d.ts.map +1 -1
  32. package/dist/core/auth-storage.js +72 -11
  33. package/dist/core/auth-storage.js.map +1 -1
  34. package/dist/core/dynamic-prompt/verification.d.ts +2 -2
  35. package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
  36. package/dist/core/dynamic-prompt/verification.js +2 -2
  37. package/dist/core/dynamic-prompt/verification.js.map +1 -1
  38. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts +17 -0
  39. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts.map +1 -0
  40. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.js +56 -0
  41. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.js.map +1 -0
  42. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts +1 -0
  43. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts.map +1 -1
  44. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.js.map +1 -1
  45. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts +32 -0
  46. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts.map +1 -0
  47. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js +43 -0
  48. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js.map +1 -0
  49. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts +18 -0
  50. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -0
  51. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js +46 -0
  52. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js.map +1 -0
  53. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts +81 -0
  54. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts.map +1 -0
  55. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js +127 -0
  56. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js.map +1 -0
  57. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.d.ts +10 -0
  58. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.d.ts.map +1 -0
  59. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.js +34 -0
  60. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.js.map +1 -0
  61. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.d.ts +56 -0
  62. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.d.ts.map +1 -0
  63. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.js +174 -0
  64. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.js.map +1 -0
  65. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts +24 -0
  66. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts.map +1 -0
  67. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.js +34 -0
  68. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.js.map +1 -0
  69. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.d.ts +34 -0
  70. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.d.ts.map +1 -0
  71. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.js +85 -0
  72. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.js.map +1 -0
  73. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts +2 -13
  74. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts.map +1 -1
  75. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js +34 -55
  76. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js.map +1 -1
  77. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.d.ts.map +1 -1
  78. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js +35 -93
  79. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js.map +1 -1
  80. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts +13 -11
  81. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -1
  82. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js +44 -55
  83. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js.map +1 -1
  84. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts +3 -1
  85. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -1
  86. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +101 -126
  87. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
  88. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts +2 -31
  89. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -1
  90. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +26 -98
  91. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
  92. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.d.ts +14 -0
  93. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.d.ts.map +1 -0
  94. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.js +42 -0
  95. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.js.map +1 -0
  96. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts +32 -0
  97. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts.map +1 -0
  98. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.js +8 -0
  99. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.js.map +1 -0
  100. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.d.ts +16 -0
  101. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.d.ts.map +1 -0
  102. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.js +92 -0
  103. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.js.map +1 -0
  104. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -1
  105. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +48 -88
  106. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -1
  107. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts +1 -0
  108. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js +1 -0
  110. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js.map +1 -1
  111. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts +18 -1
  112. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts.map +1 -1
  113. package/dist/core/extensions/builtin/compaction/checkpoint-state.js +32 -0
  114. package/dist/core/extensions/builtin/compaction/checkpoint-state.js.map +1 -1
  115. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +1 -1
  116. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +4 -0
  118. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
  119. package/dist/core/extensions/builtin/compaction/idle-retry.d.ts +21 -0
  120. package/dist/core/extensions/builtin/compaction/idle-retry.d.ts.map +1 -0
  121. package/dist/core/extensions/builtin/compaction/idle-retry.js +24 -0
  122. package/dist/core/extensions/builtin/compaction/idle-retry.js.map +1 -0
  123. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/compaction/index.js +91 -13
  125. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  126. package/dist/core/extensions/builtin/compaction/lane-policy.d.ts +71 -0
  127. package/dist/core/extensions/builtin/compaction/lane-policy.d.ts.map +1 -0
  128. package/dist/core/extensions/builtin/compaction/lane-policy.js +94 -0
  129. package/dist/core/extensions/builtin/compaction/lane-policy.js.map +1 -0
  130. package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/compaction/log.js +1 -0
  132. package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
  133. package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts +59 -0
  134. package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts.map +1 -0
  135. package/dist/core/extensions/builtin/compaction/overflow-retry.js +155 -0
  136. package/dist/core/extensions/builtin/compaction/overflow-retry.js.map +1 -0
  137. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  138. package/dist/core/extensions/builtin/compaction/speculative.js +17 -98
  139. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  140. package/dist/core/extensions/builtin/compaction/transient-failure.d.ts.map +1 -1
  141. package/dist/core/extensions/builtin/compaction/transient-failure.js +3 -0
  142. package/dist/core/extensions/builtin/compaction/transient-failure.js.map +1 -1
  143. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts +1 -0
  144. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts.map +1 -1
  145. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js +13 -1
  146. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -1
  147. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts +1 -1
  148. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
  149. package/dist/core/extensions/builtin/gpt-apply-patch/index.js +1 -1
  150. package/dist/core/extensions/builtin/gpt-apply-patch/index.js.map +1 -1
  151. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts +1 -0
  152. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  153. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +23 -5
  154. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  155. package/dist/core/extensions/builtin/loop-guard/detectors.d.ts.map +1 -1
  156. package/dist/core/extensions/builtin/loop-guard/detectors.js +42 -1
  157. package/dist/core/extensions/builtin/loop-guard/detectors.js.map +1 -1
  158. package/dist/core/extensions/builtin/mcp/health.d.ts.map +1 -1
  159. package/dist/core/extensions/builtin/mcp/health.js +2 -1
  160. package/dist/core/extensions/builtin/mcp/health.js.map +1 -1
  161. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +1 -1
  162. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
  163. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +5 -3
  164. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  165. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
  166. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +8 -1
  167. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
  168. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +1 -1
  169. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  170. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  171. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
  172. package/dist/core/extensions/builtin/terminal/tools/monitor.js +1 -0
  173. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  174. package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -1
  175. package/dist/core/extensions/builtin/tool-pair-guard/index.js +1 -1
  176. package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -1
  177. package/dist/core/extensions/index.d.ts +1 -1
  178. package/dist/core/extensions/index.d.ts.map +1 -1
  179. package/dist/core/extensions/index.js.map +1 -1
  180. package/dist/core/extensions/loader.d.ts.map +1 -1
  181. package/dist/core/extensions/loader.js +14 -18
  182. package/dist/core/extensions/loader.js.map +1 -1
  183. package/dist/core/extensions/runner.d.ts +4 -1
  184. package/dist/core/extensions/runner.d.ts.map +1 -1
  185. package/dist/core/extensions/runner.js +18 -0
  186. package/dist/core/extensions/runner.js.map +1 -1
  187. package/dist/core/extensions/types.d.ts +16 -1
  188. package/dist/core/extensions/types.d.ts.map +1 -1
  189. package/dist/core/extensions/types.js.map +1 -1
  190. package/dist/core/footer-data-provider.d.ts +10 -0
  191. package/dist/core/footer-data-provider.d.ts.map +1 -1
  192. package/dist/core/footer-data-provider.js +1 -1
  193. package/dist/core/footer-data-provider.js.map +1 -1
  194. package/dist/core/keybindings.d.ts +24 -0
  195. package/dist/core/keybindings.d.ts.map +1 -1
  196. package/dist/core/model-registry.d.ts +2 -1
  197. package/dist/core/model-registry.d.ts.map +1 -1
  198. package/dist/core/model-registry.js +3 -0
  199. package/dist/core/model-registry.js.map +1 -1
  200. package/dist/core/model-runtime.d.ts +2 -0
  201. package/dist/core/model-runtime.d.ts.map +1 -1
  202. package/dist/core/model-runtime.js.map +1 -1
  203. package/dist/core/package-manager.d.ts +0 -1
  204. package/dist/core/package-manager.d.ts.map +1 -1
  205. package/dist/core/package-manager.js +18 -34
  206. package/dist/core/package-manager.js.map +1 -1
  207. package/dist/core/pi-manifest.d.ts +9 -0
  208. package/dist/core/pi-manifest.d.ts.map +1 -0
  209. package/dist/core/pi-manifest.js +25 -0
  210. package/dist/core/pi-manifest.js.map +1 -0
  211. package/dist/core/resource-loader.d.ts +15 -0
  212. package/dist/core/resource-loader.d.ts.map +1 -1
  213. package/dist/core/resource-loader.js +55 -6
  214. package/dist/core/resource-loader.js.map +1 -1
  215. package/dist/core/retry-fallback/hint-policy.d.ts +29 -0
  216. package/dist/core/retry-fallback/hint-policy.d.ts.map +1 -0
  217. package/dist/core/retry-fallback/hint-policy.js +54 -0
  218. package/dist/core/retry-fallback/hint-policy.js.map +1 -0
  219. package/dist/core/retry-fallback/probe-scheduler.d.ts +60 -0
  220. package/dist/core/retry-fallback/probe-scheduler.d.ts.map +1 -0
  221. package/dist/core/retry-fallback/probe-scheduler.js +206 -0
  222. package/dist/core/retry-fallback/probe-scheduler.js.map +1 -0
  223. package/dist/core/retry-fallback/settings.d.ts +9 -0
  224. package/dist/core/retry-fallback/settings.d.ts.map +1 -1
  225. package/dist/core/retry-fallback/settings.js +14 -0
  226. package/dist/core/retry-fallback/settings.js.map +1 -1
  227. package/dist/core/settings-manager.d.ts +10 -1
  228. package/dist/core/settings-manager.d.ts.map +1 -1
  229. package/dist/core/settings-manager.js +21 -1
  230. package/dist/core/settings-manager.js.map +1 -1
  231. package/dist/extensions/llama/provider.js +1 -1
  232. package/dist/extensions/llama/provider.js.map +1 -1
  233. package/dist/index.d.ts +2 -2
  234. package/dist/index.d.ts.map +1 -1
  235. package/dist/index.js.map +1 -1
  236. package/dist/main.d.ts.map +1 -1
  237. package/dist/main.js +44 -0
  238. package/dist/main.js.map +1 -1
  239. package/dist/modes/interactive/components/assistant-message.d.ts +5 -2
  240. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  241. package/dist/modes/interactive/components/assistant-message.js +16 -4
  242. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  243. package/dist/modes/interactive/components/continuity-notice.d.ts +21 -0
  244. package/dist/modes/interactive/components/continuity-notice.d.ts.map +1 -0
  245. package/dist/modes/interactive/components/continuity-notice.js +58 -0
  246. package/dist/modes/interactive/components/continuity-notice.js.map +1 -0
  247. package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
  248. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  249. package/dist/modes/interactive/components/markdown-transform.js +19 -0
  250. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  251. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  252. package/dist/modes/interactive/components/model-selector.js +4 -1
  253. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  254. package/dist/modes/interactive/components/settings-selector.d.ts +6 -2
  255. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/settings-selector.js +20 -0
  257. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  258. package/dist/modes/interactive/components/user-message.d.ts +3 -1
  259. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  260. package/dist/modes/interactive/components/user-message.js +8 -2
  261. package/dist/modes/interactive/components/user-message.js.map +1 -1
  262. package/dist/modes/interactive/help-content.d.ts.map +1 -1
  263. package/dist/modes/interactive/help-content.js +1 -0
  264. package/dist/modes/interactive/help-content.js.map +1 -1
  265. package/dist/modes/interactive/interactive-mode.d.ts +21 -0
  266. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  267. package/dist/modes/interactive/interactive-mode.js +151 -50
  268. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  269. package/dist/modes/interactive/theme/dark.json +1 -0
  270. package/dist/modes/interactive/theme/grok-day.json +1 -0
  271. package/dist/modes/interactive/theme/grok-night.json +1 -0
  272. package/dist/modes/interactive/theme/light.json +1 -0
  273. package/dist/modes/interactive/theme/theme-schema.json +5 -1
  274. package/dist/modes/interactive/theme/theme.d.ts +2 -2
  275. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  276. package/dist/modes/interactive/theme/theme.js +13 -3
  277. package/dist/modes/interactive/theme/theme.js.map +1 -1
  278. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  279. package/dist/modes/rpc/connection-handler.js +13 -0
  280. package/dist/modes/rpc/connection-handler.js.map +1 -1
  281. package/dist/utils/clipboard.d.ts +1 -1
  282. package/dist/utils/clipboard.d.ts.map +1 -1
  283. package/dist/utils/clipboard.js +22 -2
  284. package/dist/utils/clipboard.js.map +1 -1
  285. package/docs/AGENTS.md +1 -6
  286. package/docs/custom-provider.md +10 -3
  287. package/docs/development.md +1 -2
  288. package/docs/extensions.md +24 -1
  289. package/docs/keybindings.md +13 -0
  290. package/docs/mcp.md +63 -4
  291. package/docs/models.md +1 -0
  292. package/docs/providers.md +20 -0
  293. package/docs/release-guide.md +5 -3
  294. package/docs/session-format.md +2 -0
  295. package/docs/settings.md +2 -0
  296. package/docs/skills.md +29 -0
  297. package/docs/themes.md +5 -3
  298. package/docs/usage.md +5 -0
  299. package/examples/extensions/custom-compaction.ts +1 -2
  300. package/examples/extensions/custom-provider-anthropic/index.ts +8 -2
  301. package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
  302. package/examples/extensions/handoff.ts +2 -3
  303. package/examples/extensions/qna.ts +2 -2
  304. package/examples/rpc-extension-ui.ts +11 -2
  305. package/examples/sdk/02-custom-model.ts +1 -2
  306. package/examples/sdk/12-full-control.ts +2 -0
  307. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
  308. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  309. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +14 -3
  310. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  311. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +156 -67
  312. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  313. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.d.ts +3 -0
  314. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.d.ts.map +1 -0
  315. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.js +70 -0
  316. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.js.map +1 -0
  317. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts +4 -0
  318. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts.map +1 -0
  319. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js +22 -0
  320. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js.map +1 -0
  321. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.d.ts +13 -0
  322. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.d.ts.map +1 -0
  323. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.js +304 -0
  324. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.js.map +1 -0
  325. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts +17 -0
  326. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts.map +1 -0
  327. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js +60 -0
  328. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js.map +1 -0
  329. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.d.ts +6 -0
  330. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.d.ts.map +1 -0
  331. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.js +107 -0
  332. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.js.map +1 -0
  333. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.d.ts +28 -0
  334. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.d.ts.map +1 -0
  335. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.js +61 -0
  336. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.js.map +1 -0
  337. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.d.ts +8 -0
  338. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.d.ts.map +1 -0
  339. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.js +22 -0
  340. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.js.map +1 -0
  341. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -10
  342. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  343. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +154 -77
  344. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  345. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +49 -23
  346. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  347. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  348. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +6 -6
  349. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  350. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +6 -6
  351. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  352. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +1 -1
  353. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  354. package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  355. package/node_modules/@earendil-works/pi-ai/README.md +2 -1
  356. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  357. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +46 -10
  358. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  359. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts +3 -0
  360. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts.map +1 -0
  361. package/{dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js → node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js} +3 -3
  362. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js.map +1 -0
  363. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  364. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +5 -1
  365. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  366. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  367. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +64 -4
  368. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  369. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
  370. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +12 -2
  371. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  372. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  373. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +13 -6
  374. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  375. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
  376. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +12 -2
  377. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  378. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  379. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +19 -10
  380. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  381. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  382. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +84 -47
  383. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  384. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  385. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +17 -8
  386. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  387. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  388. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +11 -1
  389. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  390. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  391. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +7 -3
  392. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  393. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +3 -2
  394. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js.map +1 -1
  395. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -2
  396. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  397. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
  398. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -0
  399. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
  400. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts +3 -1
  401. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts.map +1 -1
  402. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +81 -26
  403. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js.map +1 -1
  404. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +2 -0
  405. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
  406. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +16 -8
  407. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  408. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
  409. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  410. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  411. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  412. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  413. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  414. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  415. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  416. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  417. package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  418. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  419. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  420. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  421. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  422. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  423. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  424. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  425. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  426. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  427. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  428. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  429. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +4 -1
  430. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  431. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +1 -1
  432. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js.map +1 -1
  433. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +13 -1
  434. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  435. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  436. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.d.ts.map +1 -1
  437. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +23 -4
  438. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js.map +1 -1
  439. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  440. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +10 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
  442. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +3 -0
  443. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -1
  444. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +13 -12
  445. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
  446. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.d.ts +24 -0
  447. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.d.ts.map +1 -0
  448. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.js +233 -0
  449. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.js.map +1 -0
  450. package/node_modules/@earendil-works/pi-ai/package.json +10 -6
  451. package/node_modules/@earendil-works/pi-client/CHANGELOG.md +7 -0
  452. package/node_modules/@earendil-works/pi-client/README.md +64 -0
  453. package/node_modules/@earendil-works/pi-client/dist/client.d.ts +25 -0
  454. package/node_modules/@earendil-works/pi-client/dist/client.d.ts.map +1 -0
  455. package/node_modules/@earendil-works/pi-client/dist/client.js +386 -0
  456. package/node_modules/@earendil-works/pi-client/dist/client.js.map +1 -0
  457. package/node_modules/@earendil-works/pi-client/dist/connection.d.ts +25 -0
  458. package/node_modules/@earendil-works/pi-client/dist/connection.d.ts.map +1 -0
  459. package/node_modules/@earendil-works/pi-client/dist/connection.js +204 -0
  460. package/node_modules/@earendil-works/pi-client/dist/connection.js.map +1 -0
  461. package/node_modules/@earendil-works/pi-client/dist/errors.d.ts +23 -0
  462. package/node_modules/@earendil-works/pi-client/dist/errors.d.ts.map +1 -0
  463. package/node_modules/@earendil-works/pi-client/dist/errors.js +42 -0
  464. package/node_modules/@earendil-works/pi-client/dist/errors.js.map +1 -0
  465. package/node_modules/@earendil-works/pi-client/dist/index.d.ts +6 -0
  466. package/node_modules/@earendil-works/pi-client/dist/index.d.ts.map +1 -0
  467. package/node_modules/@earendil-works/pi-client/dist/index.js +3 -0
  468. package/node_modules/@earendil-works/pi-client/dist/index.js.map +1 -0
  469. package/node_modules/@earendil-works/pi-client/dist/promise.d.ts +8 -0
  470. package/node_modules/@earendil-works/pi-client/dist/promise.d.ts.map +1 -0
  471. package/node_modules/@earendil-works/pi-client/dist/promise.js +11 -0
  472. package/node_modules/@earendil-works/pi-client/dist/promise.js.map +1 -0
  473. package/node_modules/@earendil-works/pi-client/dist/session-handle.d.ts +54 -0
  474. package/node_modules/@earendil-works/pi-client/dist/session-handle.d.ts.map +1 -0
  475. package/node_modules/@earendil-works/pi-client/dist/session-handle.js +50 -0
  476. package/node_modules/@earendil-works/pi-client/dist/session-handle.js.map +1 -0
  477. package/node_modules/@earendil-works/pi-client/dist/state.d.ts +22 -0
  478. package/node_modules/@earendil-works/pi-client/dist/state.d.ts.map +1 -0
  479. package/node_modules/@earendil-works/pi-client/dist/state.js +149 -0
  480. package/node_modules/@earendil-works/pi-client/dist/state.js.map +1 -0
  481. package/node_modules/@earendil-works/pi-client/dist/transport.d.ts +17 -0
  482. package/node_modules/@earendil-works/pi-client/dist/transport.d.ts.map +1 -0
  483. package/node_modules/@earendil-works/pi-client/dist/transport.js +2 -0
  484. package/node_modules/@earendil-works/pi-client/dist/transport.js.map +1 -0
  485. package/node_modules/@earendil-works/pi-client/dist/types.d.ts +23 -0
  486. package/node_modules/@earendil-works/pi-client/dist/types.d.ts.map +1 -0
  487. package/node_modules/@earendil-works/pi-client/dist/types.js +2 -0
  488. package/node_modules/@earendil-works/pi-client/dist/types.js.map +1 -0
  489. package/node_modules/@earendil-works/pi-client/dist/unix.d.ts +8 -0
  490. package/node_modules/@earendil-works/pi-client/dist/unix.d.ts.map +1 -0
  491. package/node_modules/@earendil-works/pi-client/dist/unix.js +151 -0
  492. package/node_modules/@earendil-works/pi-client/dist/unix.js.map +1 -0
  493. package/node_modules/@earendil-works/pi-client/package.json +56 -0
  494. package/node_modules/@earendil-works/pi-protocol/README.md +68 -0
  495. package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.d.ts +4 -0
  496. package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.d.ts.map +1 -0
  497. package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js +163 -0
  498. package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js.map +1 -0
  499. package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.d.ts +4 -0
  500. package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.d.ts.map +1 -0
  501. package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js +199 -0
  502. package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js.map +1 -0
  503. package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.d.ts +4 -0
  504. package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.d.ts.map +1 -0
  505. package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js +4 -0
  506. package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js.map +1 -0
  507. package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.d.ts +26 -0
  508. package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.d.ts.map +1 -0
  509. package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js +29 -0
  510. package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js.map +1 -0
  511. package/node_modules/@earendil-works/pi-protocol/dist/codec.d.ts +29 -0
  512. package/node_modules/@earendil-works/pi-protocol/dist/codec.d.ts.map +1 -0
  513. package/node_modules/@earendil-works/pi-protocol/dist/codec.js +140 -0
  514. package/node_modules/@earendil-works/pi-protocol/dist/codec.js.map +1 -0
  515. package/node_modules/@earendil-works/pi-protocol/dist/framing.d.ts +29 -0
  516. package/node_modules/@earendil-works/pi-protocol/dist/framing.d.ts.map +1 -0
  517. package/node_modules/@earendil-works/pi-protocol/dist/framing.js +152 -0
  518. package/node_modules/@earendil-works/pi-protocol/dist/framing.js.map +1 -0
  519. package/node_modules/@earendil-works/pi-protocol/dist/index.d.ts +5 -0
  520. package/node_modules/@earendil-works/pi-protocol/dist/index.d.ts.map +1 -0
  521. package/node_modules/@earendil-works/pi-protocol/dist/index.js +5 -0
  522. package/node_modules/@earendil-works/pi-protocol/dist/index.js.map +1 -0
  523. package/node_modules/@earendil-works/pi-protocol/dist/schemas.d.ts +13818 -0
  524. package/node_modules/@earendil-works/pi-protocol/dist/schemas.d.ts.map +1 -0
  525. package/node_modules/@earendil-works/pi-protocol/dist/schemas.js +382 -0
  526. package/node_modules/@earendil-works/pi-protocol/dist/schemas.js.map +1 -0
  527. package/node_modules/@earendil-works/pi-protocol/package.json +48 -0
  528. package/node_modules/@earendil-works/pi-pty/package.json +2 -2
  529. package/node_modules/@earendil-works/pi-tui/README.md +77 -14
  530. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.d.ts +83 -0
  531. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.d.ts.map +1 -0
  532. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.js +687 -0
  533. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.js.map +1 -0
  534. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.d.ts +5 -0
  535. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.d.ts.map +1 -0
  536. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.js +5 -0
  537. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.js.map +1 -0
  538. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts +13 -0
  539. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts.map +1 -0
  540. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.js +36 -0
  541. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.js.map +1 -0
  542. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts +7 -0
  543. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts.map +1 -0
  544. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js +43 -0
  545. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js.map +1 -0
  546. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  547. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +4 -4
  548. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  549. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +2 -0
  550. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
  551. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +3 -2
  552. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
  553. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +51 -0
  554. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts.map +1 -0
  555. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js +163 -0
  556. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js.map +1 -0
  557. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
  558. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +3 -6
  559. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
  560. package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts +32 -0
  561. package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts.map +1 -0
  562. package/node_modules/@earendil-works/pi-tui/dist/components/stack.js +109 -0
  563. package/node_modules/@earendil-works/pi-tui/dist/components/stack.js.map +1 -0
  564. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts +8 -0
  565. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts.map +1 -0
  566. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js +21 -0
  567. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js.map +1 -0
  568. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +10 -4
  569. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  570. package/node_modules/@earendil-works/pi-tui/dist/index.js +10 -4
  571. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  572. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +30 -0
  573. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  574. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +18 -0
  575. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  576. package/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts +40 -0
  577. package/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts.map +1 -0
  578. package/node_modules/@earendil-works/pi-tui/dist/layout-node.js +6 -0
  579. package/node_modules/@earendil-works/pi-tui/dist/layout-node.js.map +1 -0
  580. package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts +40 -0
  581. package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts.map +1 -0
  582. package/node_modules/@earendil-works/pi-tui/dist/layout.js +315 -0
  583. package/node_modules/@earendil-works/pi-tui/dist/layout.js.map +1 -0
  584. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +10 -0
  585. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  586. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +61 -3
  587. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  588. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts +1 -0
  589. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts.map +1 -1
  590. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js +12 -2
  591. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js.map +1 -1
  592. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +36 -16
  593. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  594. package/node_modules/@earendil-works/pi-tui/dist/tui.js +72 -18
  595. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  596. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +10 -0
  597. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  598. package/node_modules/@earendil-works/pi-tui/dist/utils.js +95 -4
  599. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  600. package/node_modules/@earendil-works/pi-tui/package.json +2 -2
  601. package/node_modules/typebox/build/compile/validator.d.mts +3 -11
  602. package/node_modules/typebox/build/compile/validator.mjs +6 -36
  603. package/node_modules/typebox/build/error/errors.d.mts +1 -7
  604. package/node_modules/typebox/build/format/_idna.mjs +36 -6
  605. package/node_modules/typebox/build/format/_puny.mjs +4 -1
  606. package/node_modules/typebox/build/format/uuid.d.mts +2 -2
  607. package/node_modules/typebox/build/format/uuid.mjs +3 -3
  608. package/node_modules/typebox/build/guard/emit.d.mts +0 -4
  609. package/node_modules/typebox/build/guard/emit.mjs +0 -8
  610. package/node_modules/typebox/build/guard/guard.d.mts +5 -9
  611. package/node_modules/typebox/build/guard/guard.mjs +10 -15
  612. package/node_modules/typebox/build/guard/string.mjs +16 -4
  613. package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
  614. package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  615. package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  616. package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  617. package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  618. package/node_modules/typebox/build/schema/engine/schema.mjs +6 -11
  619. package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  620. package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  621. package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  622. package/node_modules/typebox/build/schema/types/index.mjs +0 -1
  623. package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  624. package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  625. package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  626. package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  627. package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  628. package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  629. package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  630. package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  631. package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  632. package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  633. package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  634. package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  635. package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  636. package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  637. package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  638. package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  639. package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  640. package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  641. package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  642. package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  643. package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  644. package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  645. package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  646. package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  647. package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  648. package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  649. package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  650. package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  651. package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  652. package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  653. package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  654. package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  655. package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  656. package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  657. package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  658. package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  659. package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  660. package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  661. package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  662. package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  663. package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  664. package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  665. package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  666. package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  667. package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  668. package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  669. package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  670. package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  671. package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  672. package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  673. package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  674. package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  675. package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  676. package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  677. package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  678. package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  679. package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  680. package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  681. package/node_modules/typebox/build/type/action/index.d.mts +7 -4
  682. package/node_modules/typebox/build/type/action/index.mjs +7 -4
  683. package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  684. package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  685. package/node_modules/typebox/build/type/action/module.d.mts +8 -7
  686. package/node_modules/typebox/build/type/action/module.mjs +7 -6
  687. package/node_modules/typebox/build/type/action/readonly_object.mjs +3 -0
  688. package/node_modules/typebox/build/type/action/with.d.mts +11 -0
  689. package/node_modules/typebox/build/type/action/with.mjs +11 -0
  690. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  691. package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  692. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  693. package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  694. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  695. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  696. package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  697. package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  698. package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  699. package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  700. package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  701. package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  702. package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  703. package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  704. package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  705. package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  706. package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  707. package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  708. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  709. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  710. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  711. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  712. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  713. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  714. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  715. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  716. package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  717. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  718. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  719. package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  720. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  721. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  722. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  723. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  724. package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  725. package/node_modules/typebox/build/type/engine/index.mjs +2 -2
  726. package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  727. package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  728. package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  729. package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  730. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  731. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  732. package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  733. package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  734. package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  735. package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  736. package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  737. package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  738. package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  739. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  740. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  741. package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  742. package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  743. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  744. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  745. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  746. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  747. package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  748. package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  749. package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  750. package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  751. package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  752. package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  753. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  754. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  755. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  756. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  757. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  758. package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  759. package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  760. package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  761. package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  762. package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  763. package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  764. package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  765. package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  766. package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  767. package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  768. package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  769. package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  770. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  771. package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  772. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  773. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  774. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  775. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  776. package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  777. package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  778. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  779. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  780. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  781. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  782. package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  783. package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  784. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  785. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  786. package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  787. package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  788. package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  789. package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  790. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  791. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  792. package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  793. package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  794. package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  795. package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  796. package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  797. package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  798. package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  799. package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  800. package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  801. package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  802. package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  803. package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  804. package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  805. package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  806. package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  807. package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  808. package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  809. package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  810. package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
  811. package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  812. package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  813. package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  814. package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  815. package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  816. package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  817. package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  818. package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  819. package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  820. package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  821. package/node_modules/typebox/build/type/extends/object.mjs +25 -3
  822. package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  823. package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  824. package/node_modules/typebox/build/type/extends/record.mjs +23 -0
  825. package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  826. package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  827. package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  828. package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  829. package/node_modules/typebox/build/type/extends/union.mjs +2 -2
  830. package/node_modules/typebox/build/type/script/mapping.d.mts +86 -98
  831. package/node_modules/typebox/build/type/script/mapping.mjs +95 -92
  832. package/node_modules/typebox/build/type/script/parser.d.mts +42 -40
  833. package/node_modules/typebox/build/type/script/parser.mjs +23 -22
  834. package/node_modules/typebox/build/type/script/script.d.mts +3 -4
  835. package/node_modules/typebox/build/type/script/script.mjs +3 -2
  836. package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  837. package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  838. package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  839. package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  840. package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  841. package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  842. package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  843. package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  844. package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  845. package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  846. package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  847. package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  848. package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  849. package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  850. package/node_modules/typebox/build/type/types/call.d.mts +3 -3
  851. package/node_modules/typebox/build/type/types/call.mjs +3 -2
  852. package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  853. package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  854. package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  855. package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  856. package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  857. package/node_modules/typebox/build/type/types/enum.mjs +5 -0
  858. package/node_modules/typebox/build/type/types/index.d.mts +1 -4
  859. package/node_modules/typebox/build/type/types/index.mjs +1 -4
  860. package/node_modules/typebox/build/type/types/number.d.mts +1 -1
  861. package/node_modules/typebox/build/type/types/number.mjs +1 -1
  862. package/node_modules/typebox/build/type/types/record.d.mts +13 -7
  863. package/node_modules/typebox/build/type/types/record.mjs +15 -9
  864. package/node_modules/typebox/build/type/types/static.d.mts +2 -5
  865. package/node_modules/typebox/build/typebox.d.mts +3 -7
  866. package/node_modules/typebox/build/typebox.mjs +3 -7
  867. package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  868. package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  869. package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  870. package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  871. package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  872. package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  873. package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  874. package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  875. package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  876. package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  877. package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  878. package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  879. package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  880. package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  881. package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  882. package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  883. package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  884. package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  885. package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  886. package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  887. package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  888. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  889. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  890. package/node_modules/typebox/build/value/index.d.mts +0 -1
  891. package/node_modules/typebox/build/value/index.mjs +0 -1
  892. package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  893. package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  894. package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  895. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  896. package/node_modules/typebox/build/value/value.d.mts +0 -1
  897. package/node_modules/typebox/build/value/value.mjs +0 -1
  898. package/node_modules/typebox/package.json +33 -33
  899. package/node_modules/typebox/readme.md +117 -103
  900. package/package.json +20 -10
  901. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts +0 -3
  902. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +0 -1
  903. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +0 -1
  904. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts +0 -26
  905. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +0 -1
  906. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -100
  907. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +0 -1
  908. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +0 -42
  909. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +0 -1
  910. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -286
  911. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +0 -1
  912. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts +0 -18
  913. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +0 -1
  914. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -44
  915. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +0 -1
  916. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +0 -33
  917. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +0 -1
  918. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -163
  919. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +0 -1
  920. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts +0 -11
  921. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +0 -1
  922. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -39
  923. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +0 -1
  924. package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  925. package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  926. package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  927. package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  928. package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  929. package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  930. package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  931. package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  932. package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  933. package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  934. package/node_modules/typebox/build/type/action/options.d.mts +0 -11
  935. package/node_modules/typebox/build/type/action/options.mjs +0 -11
  936. package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  937. package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  938. package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  939. package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  940. package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
  941. package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
  942. package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  943. package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  944. package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  945. package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  946. package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  947. package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  948. package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  949. package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  950. package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  951. package/node_modules/typebox/build/type/types/base.d.mts +0 -50
  952. package/node_modules/typebox/build/type/types/base.mjs +0 -84
  953. package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  954. package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  955. package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  956. package/node_modules/typebox/build/type/types/promise.mjs +0 -29
  957. package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  958. package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  959. package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  960. package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  961. package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  962. package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  963. package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  964. package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  965. package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  966. package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  967. package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  968. package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  969. package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  970. package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  971. package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  972. package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  973. package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  974. package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  975. package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  976. package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  977. package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  978. package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  979. package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  980. package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  981. package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  982. package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  983. package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  984. package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  985. package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  986. package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  987. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
  988. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
@@ -0,0 +1,315 @@
1
+ import { allocateStackSizes, visibleStackEntries } from "./components/stack.js";
2
+ import { getLayoutNode } from "./layout-node.js";
3
+ import { cropKittyImageLine, getKittyImageMetadata, isImageLine } from "./terminal-image.js";
4
+ import { CURSOR_MARKER, compositeTuiLine } from "./tui.js";
5
+ import { extractAnsiCode, getGraphemeCellRange, sliceByColumn, visibleWidth } from "./utils.js";
6
+ const OSC133_ZONE_PREFIX = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
7
+ function intersect(a, b) {
8
+ const x = Math.max(a.x, b.x);
9
+ const y = Math.max(a.y, b.y);
10
+ const right = Math.min(a.x + a.width, b.x + b.width);
11
+ const bottom = Math.min(a.y + a.height, b.y + b.height);
12
+ return { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };
13
+ }
14
+ function renderCached(context, component, width) {
15
+ const safeWidth = Math.max(1, Math.floor(width));
16
+ let widths = context.renderCache.get(component);
17
+ if (!widths) {
18
+ widths = new Map();
19
+ context.renderCache.set(component, widths);
20
+ }
21
+ let lines = widths.get(safeWidth);
22
+ if (!lines) {
23
+ lines = component.render(safeWidth);
24
+ widths.set(safeWidth, lines);
25
+ }
26
+ return lines;
27
+ }
28
+ function measureHeight(context, component, width) {
29
+ return renderCached(context, component, width).length;
30
+ }
31
+ function measureWidth(context, component, width) {
32
+ return renderCached(context, component, width).reduce((max, line) => Math.max(max, visibleWidth(line)), 0);
33
+ }
34
+ function withParent(box, parent) {
35
+ box.parent = parent;
36
+ return box;
37
+ }
38
+ function translateBox(box, deltaY) {
39
+ box.rect.y += deltaY;
40
+ for (const child of box.children)
41
+ translateBox(child, deltaY);
42
+ }
43
+ function updateClips(box, parentClip) {
44
+ box.clip = intersect(parentClip, box.rect);
45
+ for (const child of box.children)
46
+ updateClips(child, box.clip);
47
+ }
48
+ function layoutComponent(context, component, x, y, width, height, clip) {
49
+ const safeWidth = Math.max(1, Math.floor(width));
50
+ const node = getLayoutNode(component);
51
+ if (!node) {
52
+ const lines = renderCached(context, component, safeWidth);
53
+ const allocatedHeight = height === undefined ? lines.length : Math.max(0, Math.floor(height));
54
+ let lineOffset = 0;
55
+ if (lines.length > allocatedHeight && allocatedHeight > 0) {
56
+ const cursorLine = lines.findIndex((line) => line.includes(CURSOR_MARKER));
57
+ if (cursorLine >= allocatedHeight)
58
+ lineOffset = cursorLine - allocatedHeight + 1;
59
+ }
60
+ return {
61
+ component,
62
+ rect: { x, y, width: safeWidth, height: allocatedHeight },
63
+ clip: intersect(clip, { x, y, width: safeWidth, height: allocatedHeight }),
64
+ children: [],
65
+ lines,
66
+ lineOffset,
67
+ layer: 0,
68
+ };
69
+ }
70
+ if (node.type === "scroll") {
71
+ const previousScrollTop = node.state.scrollTop;
72
+ const contentWidth = node.state.getContentWidth(safeWidth);
73
+ const childBox = layoutComponent(context, node.component, x, y - previousScrollTop, contentWidth, undefined, clip);
74
+ const contentHeight = childBox.rect.height;
75
+ const viewportHeight = height === undefined ? contentHeight : Math.max(0, Math.floor(height));
76
+ node.state.updateLayout(contentHeight, viewportHeight, context.requestRender);
77
+ translateBox(childBox, previousScrollTop - node.state.scrollTop);
78
+ const scrollView = node.state;
79
+ if (node.state.primary || !context.primaryScrollView)
80
+ context.primaryScrollView = scrollView;
81
+ const rect = { x, y, width: safeWidth, height: viewportHeight };
82
+ const childClip = intersect(clip, rect);
83
+ const box = {
84
+ component,
85
+ rect,
86
+ clip: childClip,
87
+ children: [childBox],
88
+ scrollView,
89
+ scrollContentLines: renderCached(context, node.component, contentWidth),
90
+ layer: 0,
91
+ };
92
+ childBox.parent = box;
93
+ updateClips(childBox, childClip);
94
+ return box;
95
+ }
96
+ const entries = visibleStackEntries(node.entries, context.viewport);
97
+ const gapTotal = Math.max(0, entries.length - 1) * node.gap;
98
+ if (node.type === "vstack") {
99
+ const intrinsicHeights = entries.map((entry) => measureHeight(context, entry.component, safeWidth));
100
+ const sizes = allocateStackSizes(entries, intrinsicHeights, height, node.gap);
101
+ const naturalHeight = sizes.reduce((sum, size) => sum + size, 0) + gapTotal;
102
+ const allocatedHeight = height === undefined ? naturalHeight : Math.max(0, Math.floor(height));
103
+ const rect = { x, y, width: safeWidth, height: allocatedHeight };
104
+ const box = {
105
+ component,
106
+ rect,
107
+ clip: intersect(clip, rect),
108
+ children: [],
109
+ layer: 0,
110
+ };
111
+ let childY = y;
112
+ for (let index = 0; index < entries.length; index++) {
113
+ box.children.push(withParent(layoutComponent(context, entries[index].component, x, childY, safeWidth, sizes[index], box.clip), box));
114
+ childY += sizes[index] + node.gap;
115
+ }
116
+ return box;
117
+ }
118
+ const intrinsicWidths = entries.map((entry) => measureWidth(context, entry.component, safeWidth));
119
+ const widths = allocateStackSizes(entries, intrinsicWidths, safeWidth, node.gap);
120
+ const intrinsicHeights = entries.map((entry, index) => measureHeight(context, entry.component, Math.max(1, widths[index])));
121
+ const allocatedHeight = height === undefined
122
+ ? intrinsicHeights.reduce((max, childHeight) => Math.max(max, childHeight), 0)
123
+ : Math.max(0, height);
124
+ const rect = { x, y, width: safeWidth, height: allocatedHeight };
125
+ const box = {
126
+ component,
127
+ rect,
128
+ clip: intersect(clip, rect),
129
+ children: [],
130
+ layer: 0,
131
+ };
132
+ let childX = x;
133
+ for (let index = 0; index < entries.length; index++) {
134
+ const naturalChildHeight = intrinsicHeights[index];
135
+ const childHeight = node.align === "stretch" ? allocatedHeight : Math.min(allocatedHeight, naturalChildHeight);
136
+ let childY = y;
137
+ if (node.align === "center")
138
+ childY += Math.floor((allocatedHeight - childHeight) / 2);
139
+ else if (node.align === "end")
140
+ childY += allocatedHeight - childHeight;
141
+ const childWidth = widths[index];
142
+ if (childWidth === 0) {
143
+ box.children.push({
144
+ component: entries[index].component,
145
+ rect: { x: childX, y: childY, width: 0, height: childHeight },
146
+ clip: { x: childX, y: childY, width: 0, height: 0 },
147
+ children: [],
148
+ parent: box,
149
+ layer: 0,
150
+ });
151
+ }
152
+ else {
153
+ box.children.push(withParent(layoutComponent(context, entries[index].component, childX, childY, childWidth, childHeight, box.clip), box));
154
+ }
155
+ childX += childWidth + node.gap;
156
+ }
157
+ return box;
158
+ }
159
+ function styleScrollbarCell(line, column, totalWidth, style) {
160
+ if (isImageLine(line))
161
+ return line;
162
+ const graphemeRange = getGraphemeCellRange(line, column);
163
+ const start = graphemeRange?.start ?? column;
164
+ const end = graphemeRange?.end ?? column + 1;
165
+ const before = sliceByColumn(line, 0, start, true);
166
+ const target = sliceByColumn(line, start, end - start, true);
167
+ const after = sliceByColumn(line, end, Math.max(0, totalWidth - end), true);
168
+ let targetPrefix = "";
169
+ let targetIndex = 0;
170
+ while (targetIndex < target.length) {
171
+ const ansi = extractAnsiCode(target, targetIndex);
172
+ if (!ansi)
173
+ break;
174
+ targetPrefix += ansi.code;
175
+ targetIndex += ansi.length;
176
+ }
177
+ const targetText = target.slice(targetIndex) || " ".repeat(end - start);
178
+ const beforePadding = " ".repeat(Math.max(0, start - visibleWidth(before)));
179
+ return `${before}${beforePadding}${targetPrefix}${style(targetText)}${after}`;
180
+ }
181
+ export function getScrollbarGeometry(box) {
182
+ if (!box.scrollView?.isScrollbarVisible || box.rect.width <= 0 || box.rect.height <= 0)
183
+ return undefined;
184
+ const contentHeight = box.children[0]?.rect.height ?? box.scrollContentLines?.length ?? 0;
185
+ const trackHeight = box.rect.height;
186
+ const minThumbHeight = Math.min(2, trackHeight);
187
+ const thumbHeight = Math.max(minThumbHeight, Math.min(trackHeight, Math.round((trackHeight * trackHeight) / contentHeight)));
188
+ const maxScrollTop = Math.max(0, contentHeight - trackHeight);
189
+ const maxThumbTop = trackHeight - thumbHeight;
190
+ const thumbOffset = maxScrollTop === 0 ? 0 : Math.round((box.scrollView.scrollTop / maxScrollTop) * maxThumbTop);
191
+ const column = box.rect.x + box.rect.width - 1;
192
+ if (column < box.clip.x || column >= box.clip.x + box.clip.width)
193
+ return undefined;
194
+ return {
195
+ column,
196
+ trackTop: box.rect.y,
197
+ trackHeight,
198
+ thumbTop: box.rect.y + thumbOffset,
199
+ thumbHeight,
200
+ maxScrollTop,
201
+ };
202
+ }
203
+ function paintScrollbar(box, screen, totalWidth) {
204
+ const geometry = getScrollbarGeometry(box);
205
+ if (!geometry || !box.scrollView)
206
+ return;
207
+ for (let offset = 0; offset < geometry.thumbHeight; offset++) {
208
+ const row = geometry.thumbTop + offset;
209
+ if (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length)
210
+ continue;
211
+ screen[row] = styleScrollbarCell(screen[row] ?? "", geometry.column, totalWidth, box.scrollView.scrollbarStyle);
212
+ }
213
+ }
214
+ function paintBox(box, screen, totalWidth) {
215
+ if (box.lines) {
216
+ const offset = box.lineOffset ?? 0;
217
+ for (let localRow = 0; localRow < box.rect.height; localRow++) {
218
+ const row = box.rect.y + localRow;
219
+ if (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length)
220
+ continue;
221
+ const sourceLine = box.lines[offset + localRow];
222
+ if (sourceLine === undefined)
223
+ continue;
224
+ let line = sourceLine.replace(OSC133_ZONE_PREFIX, "");
225
+ const imageMetadata = getKittyImageMetadata(line);
226
+ if (imageMetadata) {
227
+ const clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);
228
+ const visibleRows = Math.min(imageMetadata.rows, clipBottom - row);
229
+ if (visibleRows < imageMetadata.rows)
230
+ line = cropKittyImageLine(line, 0, visibleRows);
231
+ }
232
+ if (isImageLine(line) && box.rect.x === 0 && box.rect.width >= totalWidth)
233
+ screen[row] = line;
234
+ else
235
+ screen[row] = compositeTuiLine(screen[row] ?? "", line, box.rect.x, box.rect.width, totalWidth);
236
+ }
237
+ }
238
+ for (const child of box.children)
239
+ paintBox(child, screen, totalWidth);
240
+ if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {
241
+ for (let imageRow = box.scrollView.scrollTop - 1; imageRow >= 0; imageRow--) {
242
+ const imageLine = box.scrollContentLines[imageRow] ?? "";
243
+ const metadata = getKittyImageMetadata(imageLine);
244
+ if (metadata) {
245
+ const hiddenRows = box.scrollView.scrollTop - imageRow;
246
+ if (hiddenRows < metadata.rows) {
247
+ const visibleRows = Math.min(box.rect.height, metadata.rows - hiddenRows);
248
+ const cropped = cropKittyImageLine(imageLine, hiddenRows, visibleRows);
249
+ if (box.rect.x === 0 && box.rect.width >= totalWidth)
250
+ screen[box.rect.y] = cropped;
251
+ }
252
+ break;
253
+ }
254
+ if (imageLine !== "")
255
+ break;
256
+ }
257
+ }
258
+ paintScrollbar(box, screen, totalWidth);
259
+ }
260
+ export function renderLayoutFrame(root, width, height, requestRender) {
261
+ const safeWidth = Math.max(1, Math.floor(width));
262
+ const safeHeight = Math.max(1, Math.floor(height));
263
+ const context = {
264
+ viewport: { width: safeWidth, height: safeHeight },
265
+ renderCache: new Map(),
266
+ requestRender,
267
+ primaryScrollView: undefined,
268
+ };
269
+ const rootBox = layoutComponent(context, root, 0, 0, safeWidth, safeHeight, {
270
+ x: 0,
271
+ y: 0,
272
+ width: safeWidth,
273
+ height: safeHeight,
274
+ });
275
+ const lines = Array.from({ length: safeHeight }, () => "");
276
+ paintBox(rootBox, lines, safeWidth);
277
+ return {
278
+ root: rootBox,
279
+ width: safeWidth,
280
+ height: safeHeight,
281
+ lines,
282
+ ...(context.primaryScrollView === undefined ? {} : { primaryScrollView: context.primaryScrollView }),
283
+ };
284
+ }
285
+ function containsPoint(rect, x, y) {
286
+ return x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height;
287
+ }
288
+ export function getScrollViewBox(frame, scrollView) {
289
+ const visit = (box) => {
290
+ if (box.scrollView === scrollView)
291
+ return box;
292
+ for (const child of box.children) {
293
+ const match = visit(child);
294
+ if (match)
295
+ return match;
296
+ }
297
+ return undefined;
298
+ };
299
+ return visit(frame.root);
300
+ }
301
+ export function getScrollViewsAt(frame, x, y) {
302
+ const result = [];
303
+ const visit = (box, depth) => {
304
+ if (!containsPoint(box.clip, x, y))
305
+ return;
306
+ if (box.scrollView && containsPoint(box.rect, x, y))
307
+ result.push({ scrollView: box.scrollView, depth });
308
+ for (const child of box.children)
309
+ visit(child, depth + 1);
310
+ };
311
+ visit(frame.root, 0);
312
+ result.sort((a, b) => b.depth - a.depth);
313
+ return result.map((entry) => entry.scrollView);
314
+ }
315
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAkB,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEhG,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AA8ClE,SAAS,SAAS,CAAC,CAAa,EAAE,CAAa;IAC9C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KA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AC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAkB,EAAE,CAAS,EAAE,CAAS;IACxE,MAAM,MAAM,GAAqD,EAAE,CAAC;IACpE,MAAM,KAAK,GAAG,CAAC,GAAc,EAAE,KAAa,EAAQ,EAAE;QACrD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YAAE,OAAO;QAC3C,IAAI,GAAG,CAAC,UAAU,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACxG,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,QAAQ;YAAE,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC;IACF,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { ScrollView } from \"./components/scroll-view.ts\";\nimport { allocateStackSizes, visibleStackEntries } from \"./components/stack.ts\";\nimport { getLayoutNode } from \"./layout-node.ts\";\nimport { cropKittyImageLine, getKittyImageMetadata, isImageLine } from \"./terminal-image.ts\";\nimport { type Component, CURSOR_MARKER, compositeTuiLine } from \"./tui.ts\";\nimport { extractAnsiCode, getGraphemeCellRange, sliceByColumn, visibleWidth } from \"./utils.ts\";\n\nconst OSC133_ZONE_PREFIX = /^(?:\\x1b\\]133;[ABC](?:\\x07|\\x1b\\\\))+/;\n\nexport interface LayoutRect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\nexport interface LayoutBox {\n\tcomponent: Component;\n\trect: LayoutRect;\n\tclip: LayoutRect;\n\tchildren: LayoutBox[];\n\tparent?: LayoutBox;\n\tlines?: readonly string[];\n\tlineOffset?: number;\n\tscrollView?: ScrollView;\n\tscrollContentLines?: readonly string[];\n\tlayer: number;\n}\n\nexport interface LayoutFrame {\n\troot: LayoutBox;\n\twidth: number;\n\theight: number;\n\tlines: string[];\n\tprimaryScrollView?: ScrollView;\n}\n\nexport interface ScrollbarGeometry {\n\tcolumn: number;\n\ttrackTop: number;\n\ttrackHeight: number;\n\tthumbTop: number;\n\tthumbHeight: number;\n\tmaxScrollTop: number;\n}\n\ninterface LayoutContext {\n\tviewport: { width: number; height: number };\n\trenderCache: Map<Component, Map<number, string[]>>;\n\trequestRender: () => void;\n\tprimaryScrollView: ScrollView | undefined;\n}\n\nfunction intersect(a: LayoutRect, b: LayoutRect): LayoutRect {\n\tconst x = Math.max(a.x, b.x);\n\tconst y = Math.max(a.y, b.y);\n\tconst right = Math.min(a.x + a.width, b.x + b.width);\n\tconst bottom = Math.min(a.y + a.height, b.y + b.height);\n\treturn { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };\n}\n\nfunction renderCached(context: LayoutContext, component: Component, width: number): string[] {\n\tconst safeWidth = Math.max(1, Math.floor(width));\n\tlet widths = context.renderCache.get(component);\n\tif (!widths) {\n\t\twidths = new Map<number, string[]>();\n\t\tcontext.renderCache.set(component, widths);\n\t}\n\tlet lines = widths.get(safeWidth);\n\tif (!lines) {\n\t\tlines = component.render(safeWidth);\n\t\twidths.set(safeWidth, lines);\n\t}\n\treturn lines;\n}\n\nfunction measureHeight(context: LayoutContext, component: Component, width: number): number {\n\treturn renderCached(context, component, width).length;\n}\n\nfunction measureWidth(context: LayoutContext, component: Component, width: number): number {\n\treturn renderCached(context, component, width).reduce((max, line) => Math.max(max, visibleWidth(line)), 0);\n}\n\nfunction withParent(box: LayoutBox, parent: LayoutBox): LayoutBox {\n\tbox.parent = parent;\n\treturn box;\n}\n\nfunction translateBox(box: LayoutBox, deltaY: number): void {\n\tbox.rect.y += deltaY;\n\tfor (const child of box.children) translateBox(child, deltaY);\n}\n\nfunction updateClips(box: LayoutBox, parentClip: LayoutRect): void {\n\tbox.clip = intersect(parentClip, box.rect);\n\tfor (const child of box.children) updateClips(child, box.clip);\n}\n\nfunction layoutComponent(\n\tcontext: LayoutContext,\n\tcomponent: Component,\n\tx: number,\n\ty: number,\n\twidth: number,\n\theight: number | undefined,\n\tclip: LayoutRect,\n): LayoutBox {\n\tconst safeWidth = Math.max(1, Math.floor(width));\n\tconst node = getLayoutNode(component);\n\tif (!node) {\n\t\tconst lines = renderCached(context, component, safeWidth);\n\t\tconst allocatedHeight = height === undefined ? lines.length : Math.max(0, Math.floor(height));\n\t\tlet lineOffset = 0;\n\t\tif (lines.length > allocatedHeight && allocatedHeight > 0) {\n\t\t\tconst cursorLine = lines.findIndex((line) => line.includes(CURSOR_MARKER));\n\t\t\tif (cursorLine >= allocatedHeight) lineOffset = cursorLine - allocatedHeight + 1;\n\t\t}\n\t\treturn {\n\t\t\tcomponent,\n\t\t\trect: { x, y, width: safeWidth, height: allocatedHeight },\n\t\t\tclip: intersect(clip, { x, y, width: safeWidth, height: allocatedHeight }),\n\t\t\tchildren: [],\n\t\t\tlines,\n\t\t\tlineOffset,\n\t\t\tlayer: 0,\n\t\t};\n\t}\n\n\tif (node.type === \"scroll\") {\n\t\tconst previousScrollTop = node.state.scrollTop;\n\t\tconst contentWidth = node.state.getContentWidth(safeWidth);\n\t\tconst childBox = layoutComponent(\n\t\t\tcontext,\n\t\t\tnode.component,\n\t\t\tx,\n\t\t\ty - previousScrollTop,\n\t\t\tcontentWidth,\n\t\t\tundefined,\n\t\t\tclip,\n\t\t);\n\t\tconst contentHeight = childBox.rect.height;\n\t\tconst viewportHeight = height === undefined ? contentHeight : Math.max(0, Math.floor(height));\n\t\tnode.state.updateLayout(contentHeight, viewportHeight, context.requestRender);\n\t\ttranslateBox(childBox, previousScrollTop - node.state.scrollTop);\n\t\tconst scrollView = node.state as ScrollView;\n\t\tif (node.state.primary || !context.primaryScrollView) context.primaryScrollView = scrollView;\n\t\tconst rect = { x, y, width: safeWidth, height: viewportHeight };\n\t\tconst childClip = intersect(clip, rect);\n\t\tconst box: LayoutBox = {\n\t\t\tcomponent,\n\t\t\trect,\n\t\t\tclip: childClip,\n\t\t\tchildren: [childBox],\n\t\t\tscrollView,\n\t\t\tscrollContentLines: renderCached(context, node.component, contentWidth),\n\t\t\tlayer: 0,\n\t\t};\n\t\tchildBox.parent = box;\n\t\tupdateClips(childBox, childClip);\n\t\treturn box;\n\t}\n\n\tconst entries = visibleStackEntries(node.entries, context.viewport);\n\tconst gapTotal = Math.max(0, entries.length - 1) * node.gap;\n\tif (node.type === \"vstack\") {\n\t\tconst intrinsicHeights = entries.map((entry) => measureHeight(context, entry.component, safeWidth));\n\t\tconst sizes = allocateStackSizes(entries, intrinsicHeights, height, node.gap);\n\t\tconst naturalHeight = sizes.reduce((sum, size) => sum + size, 0) + gapTotal;\n\t\tconst allocatedHeight = height === undefined ? naturalHeight : Math.max(0, Math.floor(height));\n\t\tconst rect = { x, y, width: safeWidth, height: allocatedHeight };\n\t\tconst box: LayoutBox = {\n\t\t\tcomponent,\n\t\t\trect,\n\t\t\tclip: intersect(clip, rect),\n\t\t\tchildren: [],\n\t\t\tlayer: 0,\n\t\t};\n\t\tlet childY = y;\n\t\tfor (let index = 0; index < entries.length; index++) {\n\t\t\tbox.children.push(\n\t\t\t\twithParent(\n\t\t\t\t\tlayoutComponent(context, entries[index]!.component, x, childY, safeWidth, sizes[index]!, box.clip),\n\t\t\t\t\tbox,\n\t\t\t\t),\n\t\t\t);\n\t\t\tchildY += sizes[index]! + node.gap;\n\t\t}\n\t\treturn box;\n\t}\n\n\tconst intrinsicWidths = entries.map((entry) => measureWidth(context, entry.component, safeWidth));\n\tconst widths = allocateStackSizes(entries, intrinsicWidths, safeWidth, node.gap);\n\tconst intrinsicHeights = entries.map((entry, index) =>\n\t\tmeasureHeight(context, entry.component, Math.max(1, widths[index]!)),\n\t);\n\tconst allocatedHeight =\n\t\theight === undefined\n\t\t\t? intrinsicHeights.reduce((max, childHeight) => Math.max(max, childHeight), 0)\n\t\t\t: Math.max(0, height);\n\tconst rect = { x, y, width: safeWidth, height: allocatedHeight };\n\tconst box: LayoutBox = {\n\t\tcomponent,\n\t\trect,\n\t\tclip: intersect(clip, rect),\n\t\tchildren: [],\n\t\tlayer: 0,\n\t};\n\tlet childX = x;\n\tfor (let index = 0; index < entries.length; index++) {\n\t\tconst naturalChildHeight = intrinsicHeights[index]!;\n\t\tconst childHeight = node.align === \"stretch\" ? allocatedHeight : Math.min(allocatedHeight, naturalChildHeight);\n\t\tlet childY = y;\n\t\tif (node.align === \"center\") childY += Math.floor((allocatedHeight - childHeight) / 2);\n\t\telse if (node.align === \"end\") childY += allocatedHeight - childHeight;\n\t\tconst childWidth = widths[index]!;\n\t\tif (childWidth === 0) {\n\t\t\tbox.children.push({\n\t\t\t\tcomponent: entries[index]!.component,\n\t\t\t\trect: { x: childX, y: childY, width: 0, height: childHeight },\n\t\t\t\tclip: { x: childX, y: childY, width: 0, height: 0 },\n\t\t\t\tchildren: [],\n\t\t\t\tparent: box,\n\t\t\t\tlayer: 0,\n\t\t\t});\n\t\t} else {\n\t\t\tbox.children.push(\n\t\t\t\twithParent(\n\t\t\t\t\tlayoutComponent(context, entries[index]!.component, childX, childY, childWidth, childHeight, box.clip),\n\t\t\t\t\tbox,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tchildX += childWidth + node.gap;\n\t}\n\treturn box;\n}\n\nfunction styleScrollbarCell(line: string, column: number, totalWidth: number, style: (text: string) => string): string {\n\tif (isImageLine(line)) return line;\n\n\tconst graphemeRange = getGraphemeCellRange(line, column);\n\tconst start = graphemeRange?.start ?? column;\n\tconst end = graphemeRange?.end ?? column + 1;\n\tconst before = sliceByColumn(line, 0, start, true);\n\tconst target = sliceByColumn(line, start, end - start, true);\n\tconst after = sliceByColumn(line, end, Math.max(0, totalWidth - end), true);\n\n\tlet targetPrefix = \"\";\n\tlet targetIndex = 0;\n\twhile (targetIndex < target.length) {\n\t\tconst ansi = extractAnsiCode(target, targetIndex);\n\t\tif (!ansi) break;\n\t\ttargetPrefix += ansi.code;\n\t\ttargetIndex += ansi.length;\n\t}\n\tconst targetText = target.slice(targetIndex) || \" \".repeat(end - start);\n\tconst beforePadding = \" \".repeat(Math.max(0, start - visibleWidth(before)));\n\treturn `${before}${beforePadding}${targetPrefix}${style(targetText)}${after}`;\n}\n\nexport function getScrollbarGeometry(box: LayoutBox): ScrollbarGeometry | undefined {\n\tif (!box.scrollView?.isScrollbarVisible || box.rect.width <= 0 || box.rect.height <= 0) return undefined;\n\n\tconst contentHeight = box.children[0]?.rect.height ?? box.scrollContentLines?.length ?? 0;\n\tconst trackHeight = box.rect.height;\n\n\tconst minThumbHeight = Math.min(2, trackHeight);\n\tconst thumbHeight = Math.max(\n\t\tminThumbHeight,\n\t\tMath.min(trackHeight, Math.round((trackHeight * trackHeight) / contentHeight)),\n\t);\n\tconst maxScrollTop = Math.max(0, contentHeight - trackHeight);\n\tconst maxThumbTop = trackHeight - thumbHeight;\n\tconst thumbOffset = maxScrollTop === 0 ? 0 : Math.round((box.scrollView.scrollTop / maxScrollTop) * maxThumbTop);\n\tconst column = box.rect.x + box.rect.width - 1;\n\tif (column < box.clip.x || column >= box.clip.x + box.clip.width) return undefined;\n\n\treturn {\n\t\tcolumn,\n\t\ttrackTop: box.rect.y,\n\t\ttrackHeight,\n\t\tthumbTop: box.rect.y + thumbOffset,\n\t\tthumbHeight,\n\t\tmaxScrollTop,\n\t};\n}\n\nfunction paintScrollbar(box: LayoutBox, screen: string[], totalWidth: number): void {\n\tconst geometry = getScrollbarGeometry(box);\n\tif (!geometry || !box.scrollView) return;\n\n\tfor (let offset = 0; offset < geometry.thumbHeight; offset++) {\n\t\tconst row = geometry.thumbTop + offset;\n\t\tif (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length) continue;\n\t\tscreen[row] = styleScrollbarCell(screen[row] ?? \"\", geometry.column, totalWidth, box.scrollView.scrollbarStyle);\n\t}\n}\n\nfunction paintBox(box: LayoutBox, screen: string[], totalWidth: number): void {\n\tif (box.lines) {\n\t\tconst offset = box.lineOffset ?? 0;\n\t\tfor (let localRow = 0; localRow < box.rect.height; localRow++) {\n\t\t\tconst row = box.rect.y + localRow;\n\t\t\tif (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length) continue;\n\t\t\tconst sourceLine = box.lines[offset + localRow];\n\t\t\tif (sourceLine === undefined) continue;\n\t\t\tlet line = sourceLine.replace(OSC133_ZONE_PREFIX, \"\");\n\t\t\tconst imageMetadata = getKittyImageMetadata(line);\n\t\t\tif (imageMetadata) {\n\t\t\t\tconst clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);\n\t\t\t\tconst visibleRows = Math.min(imageMetadata.rows, clipBottom - row);\n\t\t\t\tif (visibleRows < imageMetadata.rows) line = cropKittyImageLine(line, 0, visibleRows);\n\t\t\t}\n\t\t\tif (isImageLine(line) && box.rect.x === 0 && box.rect.width >= totalWidth) screen[row] = line;\n\t\t\telse screen[row] = compositeTuiLine(screen[row] ?? \"\", line, box.rect.x, box.rect.width, totalWidth);\n\t\t}\n\t}\n\tfor (const child of box.children) paintBox(child, screen, totalWidth);\n\n\tif (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {\n\t\tfor (let imageRow = box.scrollView.scrollTop - 1; imageRow >= 0; imageRow--) {\n\t\t\tconst imageLine = box.scrollContentLines[imageRow] ?? \"\";\n\t\t\tconst metadata = getKittyImageMetadata(imageLine);\n\t\t\tif (metadata) {\n\t\t\t\tconst hiddenRows = box.scrollView.scrollTop - imageRow;\n\t\t\t\tif (hiddenRows < metadata.rows) {\n\t\t\t\t\tconst visibleRows = Math.min(box.rect.height, metadata.rows - hiddenRows);\n\t\t\t\t\tconst cropped = cropKittyImageLine(imageLine, hiddenRows, visibleRows);\n\t\t\t\t\tif (box.rect.x === 0 && box.rect.width >= totalWidth) screen[box.rect.y] = cropped;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (imageLine !== \"\") break;\n\t\t}\n\t}\n\n\tpaintScrollbar(box, screen, totalWidth);\n}\n\nexport function renderLayoutFrame(\n\troot: Component,\n\twidth: number,\n\theight: number,\n\trequestRender: () => void,\n): LayoutFrame {\n\tconst safeWidth = Math.max(1, Math.floor(width));\n\tconst safeHeight = Math.max(1, Math.floor(height));\n\tconst context: LayoutContext = {\n\t\tviewport: { width: safeWidth, height: safeHeight },\n\t\trenderCache: new Map(),\n\t\trequestRender,\n\t\tprimaryScrollView: undefined,\n\t};\n\tconst rootBox = layoutComponent(context, root, 0, 0, safeWidth, safeHeight, {\n\t\tx: 0,\n\t\ty: 0,\n\t\twidth: safeWidth,\n\t\theight: safeHeight,\n\t});\n\tconst lines = Array.from({ length: safeHeight }, () => \"\");\n\tpaintBox(rootBox, lines, safeWidth);\n\treturn {\n\t\troot: rootBox,\n\t\twidth: safeWidth,\n\t\theight: safeHeight,\n\t\tlines,\n\t\t...(context.primaryScrollView === undefined ? {} : { primaryScrollView: context.primaryScrollView }),\n\t};\n}\n\nfunction containsPoint(rect: LayoutRect, x: number, y: number): boolean {\n\treturn x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height;\n}\n\nexport function getScrollViewBox(frame: LayoutFrame, scrollView: ScrollView): LayoutBox | undefined {\n\tconst visit = (box: LayoutBox): LayoutBox | undefined => {\n\t\tif (box.scrollView === scrollView) return box;\n\t\tfor (const child of box.children) {\n\t\t\tconst match = visit(child);\n\t\t\tif (match) return match;\n\t\t}\n\t\treturn undefined;\n\t};\n\treturn visit(frame.root);\n}\n\nexport function getScrollViewsAt(frame: LayoutFrame, x: number, y: number): ScrollView[] {\n\tconst result: Array<{ scrollView: ScrollView; depth: number }> = [];\n\tconst visit = (box: LayoutBox, depth: number): void => {\n\t\tif (!containsPoint(box.clip, x, y)) return;\n\t\tif (box.scrollView && containsPoint(box.rect, x, y)) result.push({ scrollView: box.scrollView, depth });\n\t\tfor (const child of box.children) visit(child, depth + 1);\n\t};\n\tvisit(frame.root, 0);\n\tresult.sort((a, b) => b.depth - a.depth);\n\treturn result.map((entry) => entry.scrollView);\n}\n"]}
@@ -87,6 +87,14 @@ export interface ImageCellSize {
87
87
  columns: number;
88
88
  rows: number;
89
89
  }
90
+ export interface KittyImageMetadata extends ImageCellSize {
91
+ imageId: number;
92
+ widthPx: number;
93
+ heightPx: number;
94
+ }
95
+ export declare function registerKittyImageMetadata(metadata: KittyImageMetadata): void;
96
+ export declare function getKittyImageMetadata(line: string): KittyImageMetadata | undefined;
97
+ export declare function cropKittyImageLine(line: string, hiddenRows: number, visibleRows: number): string;
90
98
  export declare function calculateImageCellSize(imageDimensions: ImageDimensions, maxWidthCells: number, maxHeightCells?: number, cellDimensions?: CellDimensions): ImageCellSize;
91
99
  export declare function getPngDimensions(base64Data: string): ImageDimensions | null;
92
100
  export declare function getJpegDimensions(base64Data: string): ImageDimensions | null;
@@ -95,6 +103,7 @@ export declare function getWebpDimensions(base64Data: string): ImageDimensions |
95
103
  export declare function getImageDimensions(base64Data: string, mimeType: string): ImageDimensions | null;
96
104
  export declare function renderImage(base64Data: string, imageDimensions: ImageDimensions, options?: ImageRenderOptions): {
97
105
  sequence: string;
106
+ columns: number;
98
107
  rows: number;
99
108
  imageId?: number;
100
109
  lines?: string[];
@@ -110,4 +119,5 @@ export declare function renderImage(base64Data: string, imageDimensions: ImageDi
110
119
  * @param url - The URL to link to
111
120
  */
112
121
  export declare function hyperlink(text: string, url: string): string;
122
+ export declare function imageFallback(mimeType: string, dimensions?: ImageDimensions, filename?: string): string;
113
123
  //# sourceMappingURL=terminal-image.d.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AM,CAcvG"}
@@ -1,4 +1,7 @@
1
+ import { isAbsolute } from "node:path";
2
+ import { pathToFileURL } from "node:url";
1
3
  import { detectTerminalCapabilities, } from "./terminal-capabilities.js";
4
+ import { sanitizeTerminalLabel, shortenImagePath } from "./terminal-text.js";
2
5
  export { outerKittyGraphicsMode } from "./terminal-capabilities.js";
3
6
  let cachedCapabilities = null;
4
7
  // Default cell dimensions - updated by TUI when terminal responds to query
@@ -203,6 +206,38 @@ export function encodeITerm2(base64Data, options = {}) {
203
206
  }
204
207
  return `\x1b]1337;File=${params.join(";")}:${base64Data}\x07`;
205
208
  }
209
+ const kittyImageMetadata = new Map();
210
+ export function registerKittyImageMetadata(metadata) {
211
+ kittyImageMetadata.delete(metadata.imageId);
212
+ kittyImageMetadata.set(metadata.imageId, metadata);
213
+ if (kittyImageMetadata.size > 1000) {
214
+ const oldestImageId = kittyImageMetadata.keys().next().value;
215
+ if (oldestImageId !== undefined)
216
+ kittyImageMetadata.delete(oldestImageId);
217
+ }
218
+ }
219
+ export function getKittyImageMetadata(line) {
220
+ const controls = /\x1b_G([^;]*);/.exec(line)?.[1];
221
+ if (!controls)
222
+ return undefined;
223
+ const imageId = /(?:^|,)i=(\d+)(?:,|$)/.exec(controls)?.[1];
224
+ return imageId === undefined ? undefined : kittyImageMetadata.get(Number.parseInt(imageId, 10));
225
+ }
226
+ export function cropKittyImageLine(line, hiddenRows, visibleRows) {
227
+ const metadata = getKittyImageMetadata(line);
228
+ const match = /\x1b_G([^;]*);/.exec(line);
229
+ if (!metadata || !match || hiddenRows < 0 || hiddenRows >= metadata.rows || visibleRows <= 0)
230
+ return line;
231
+ const croppedRows = Math.min(visibleRows, metadata.rows - hiddenRows);
232
+ if (hiddenRows === 0 && croppedRows === metadata.rows)
233
+ return line;
234
+ const sourceY = Math.floor((metadata.heightPx * hiddenRows) / metadata.rows);
235
+ const sourceEnd = Math.ceil((metadata.heightPx * (hiddenRows + croppedRows)) / metadata.rows);
236
+ const sourceHeight = Math.max(1, Math.min(metadata.heightPx, sourceEnd) - sourceY);
237
+ const controls = match[1].split(",").filter((control) => !/^[yhr]=/.test(control));
238
+ controls.push(`y=${sourceY}`, `h=${sourceHeight}`, `r=${croppedRows}`);
239
+ return `${line.slice(0, match.index)}\x1b_G${controls.join(",")};${line.slice(match.index + match[0].length)}`;
240
+ }
206
241
  export function calculateImageCellSize(imageDimensions, maxWidthCells, maxHeightCells, cellDimensions = { widthPx: 9, heightPx: 18 }) {
207
242
  const maxWidth = Math.max(1, Math.floor(maxWidthCells));
208
243
  const maxHeight = maxHeightCells === undefined ? undefined : Math.max(1, Math.floor(maxHeightCells));
@@ -366,16 +401,25 @@ export function renderImage(base64Data, imageDimensions, options = {}) {
366
401
  const placeholderRow = buildKittyPlaceholderRow(imageId, row, columns);
367
402
  lines.push(row === 0 ? sequence + placeholderRow : placeholderRow);
368
403
  }
369
- return { sequence, rows, imageId, lines };
404
+ return { sequence, columns, rows, imageId, lines };
370
405
  }
371
406
  if (caps.images === "kitty") {
407
+ if (options.imageId !== undefined) {
408
+ registerKittyImageMetadata({
409
+ imageId: options.imageId,
410
+ columns: size.columns,
411
+ rows: size.rows,
412
+ widthPx: imageDimensions.widthPx,
413
+ heightPx: imageDimensions.heightPx,
414
+ });
415
+ }
372
416
  const sequence = encodeKitty(base64Data, {
373
417
  columns: size.columns,
374
418
  rows: size.rows,
375
419
  imageId: options.imageId,
376
420
  moveCursor: options.moveCursor,
377
421
  });
378
- return { sequence, rows: size.rows, imageId: options.imageId };
422
+ return { sequence, columns: size.columns, rows: size.rows, imageId: options.imageId };
379
423
  }
380
424
  if (caps.images === "iterm2") {
381
425
  const sequence = encodeITerm2(base64Data, {
@@ -383,7 +427,7 @@ export function renderImage(base64Data, imageDimensions, options = {}) {
383
427
  height: "auto",
384
428
  preserveAspectRatio: options.preserveAspectRatio ?? true,
385
429
  });
386
- return { sequence, rows: size.rows };
430
+ return { sequence, columns: size.columns, rows: size.rows };
387
431
  }
388
432
  return null;
389
433
  }
@@ -400,4 +444,18 @@ export function renderImage(base64Data, imageDimensions, options = {}) {
400
444
  export function hyperlink(text, url) {
401
445
  return `\x1b]8;;${url}\x1b\\${text}\x1b]8;;\x1b\\`;
402
446
  }
447
+ export function imageFallback(mimeType, dimensions, filename) {
448
+ const parts = [];
449
+ if (filename) {
450
+ const sanitized = sanitizeTerminalLabel(filename);
451
+ const display = shortenImagePath(sanitized);
452
+ parts.push(getCapabilities().hyperlinks && isAbsolute(sanitized)
453
+ ? hyperlink(display, pathToFileURL(sanitized).href)
454
+ : display);
455
+ }
456
+ parts.push(`[${sanitizeTerminalLabel(mimeType)}]`);
457
+ if (dimensions)
458
+ parts.push(`${dimensions.widthPx}x${dimensions.heightPx}`);
459
+ return `[Image: ${parts.join(" ")}]`;
460
+ }
403
461
  //# sourceMappingURL=terminal-image.js.map