@timurproko/a1 0.1.8-dev.49ff83a → 0.1.8-dev.508

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 (865) hide show
  1. package/README.md +168 -65
  2. package/bin/cli.js +33 -11
  3. package/bin/guardian.js +16 -6
  4. package/bin/module-identity.js +76 -69
  5. package/bin/module-resolver.js +138 -0
  6. package/bin/pinned-pi-public.d.ts +3 -0
  7. package/bin/pinned-pi-public.js +93 -0
  8. package/bin/release-cleanup.js +8 -0
  9. package/bin/supervisor.js +2 -2
  10. package/bin/ui.js +67 -22
  11. package/bin/update-recovery.js +343 -0
  12. package/bin/warmup.js +28 -0
  13. package/dist/app/session-shell/clipboard-diagnostics.d.ts +16 -0
  14. package/dist/app/session-shell/clipboard-diagnostics.js +65 -0
  15. package/dist/app/session-shell/clipboard-image.d.ts +11 -0
  16. package/dist/app/session-shell/clipboard-image.js +38 -0
  17. package/dist/app/session-shell/editor-hyperlink-budget.d.ts +9 -0
  18. package/dist/app/session-shell/editor-hyperlink-budget.js +23 -0
  19. package/dist/app/session-shell/helper-pool.d.ts +33 -0
  20. package/dist/app/session-shell/helper-pool.js +98 -0
  21. package/dist/app/session-shell/image-preparation-client.d.ts +20 -0
  22. package/dist/app/session-shell/image-preparation-client.js +145 -0
  23. package/dist/app/session-shell/image-preparation.d.ts +18 -0
  24. package/dist/app/session-shell/image-preparation.js +126 -0
  25. package/dist/app/session-shell/image-source.d.ts +13 -0
  26. package/dist/app/session-shell/image-source.js +171 -0
  27. package/dist/app/session-shell/image-worker.d.ts +17 -0
  28. package/dist/app/session-shell/image-worker.js +23 -0
  29. package/dist/app/session-shell/index.d.ts +7 -0
  30. package/dist/app/session-shell/index.js +4 -0
  31. package/dist/app/session-shell/paste-executor.d.ts +18 -0
  32. package/dist/app/session-shell/paste-executor.js +253 -0
  33. package/dist/app/session-shell/paste-helper.js +173 -0
  34. package/dist/app/session-shell/paste-preparation-client.d.ts +31 -0
  35. package/dist/app/session-shell/paste-preparation-client.js +170 -0
  36. package/dist/app/session-shell/paste-protocol.d.ts +78 -0
  37. package/dist/app/session-shell/paste-protocol.js +18 -0
  38. package/dist/app/session-shell/paste-text-preparation.d.ts +6 -0
  39. package/dist/app/session-shell/paste-text-preparation.js +134 -0
  40. package/dist/app/session-shell/paste-text-worker.js +12 -0
  41. package/dist/app/session-shell/paste-types.d.ts +17 -0
  42. package/dist/app/session-shell/path-chip-presentation.d.ts +7 -0
  43. package/dist/app/session-shell/path-chip-presentation.js +24 -0
  44. package/dist/app/session-shell/prompt-chips.d.ts +76 -0
  45. package/dist/app/session-shell/prompt-chips.js +507 -0
  46. package/dist/app/session-shell/prompt-history-controller.d.ts +36 -0
  47. package/dist/app/session-shell/prompt-history-controller.js +170 -0
  48. package/dist/app/session-shell/prompt-suggestion-controller.d.ts +35 -0
  49. package/dist/app/session-shell/prompt-suggestion-controller.js +207 -0
  50. package/dist/app/session-shell/quit-outro-effects.d.ts +29 -0
  51. package/dist/app/session-shell/quit-outro-effects.js +242 -0
  52. package/dist/app/session-shell/quit-outro.d.ts +38 -0
  53. package/dist/app/session-shell/quit-outro.js +98 -0
  54. package/dist/app/session-shell/response-copy-coordinator.d.ts +27 -0
  55. package/dist/app/session-shell/response-copy-coordinator.js +187 -0
  56. package/dist/app/session-shell/response-copy-helper.js +122 -0
  57. package/dist/app/session-shell/response-copy-protocol.d.ts +56 -0
  58. package/dist/app/session-shell/response-copy-protocol.js +5 -0
  59. package/dist/app/session-shell/response-copy-transport.d.ts +39 -0
  60. package/dist/app/session-shell/response-copy-transport.js +217 -0
  61. package/dist/app/session-shell/session-shell-root.d.ts +265 -0
  62. package/dist/app/session-shell/session-shell-root.js +1366 -0
  63. package/dist/app/session-shell/session-shell.d.ts +59 -0
  64. package/dist/app/session-shell/session-shell.js +1917 -0
  65. package/dist/app/session-shell/session-viewport-controller.d.ts +61 -0
  66. package/dist/app/session-shell/session-viewport-controller.js +597 -0
  67. package/dist/app/session-shell/stream-presentation-coalescer.d.ts +29 -0
  68. package/dist/app/session-shell/stream-presentation-coalescer.js +79 -0
  69. package/dist/app/session-shell/system-clipboard.d.ts +20 -0
  70. package/dist/app/session-shell/system-clipboard.js +159 -0
  71. package/dist/app/session-shell/text-paste.d.ts +5 -0
  72. package/dist/app/session-shell/text-paste.js +16 -0
  73. package/dist/cli/capabilities.d.ts +6 -0
  74. package/dist/cli/capabilities.js +7 -0
  75. package/dist/cli/dispatch.d.ts +46 -0
  76. package/dist/cli/dispatch.js +261 -0
  77. package/dist/cli/index.d.ts +8 -0
  78. package/dist/cli/index.js +4 -0
  79. package/dist/cli/package-messages.d.ts +26 -0
  80. package/dist/cli/package-messages.js +71 -0
  81. package/dist/cli/packages.d.ts +32 -0
  82. package/dist/cli/packages.js +81 -0
  83. package/dist/cli/version-stats.d.ts +22 -0
  84. package/dist/cli/version-stats.js +112 -0
  85. package/dist/composition/index.d.ts +2 -0
  86. package/dist/composition/index.js +2 -0
  87. package/dist/composition/owned-ui.d.ts +37 -0
  88. package/dist/composition/owned-ui.js +136 -0
  89. package/dist/composition/settings-route-host.d.ts +7 -0
  90. package/dist/composition/settings-route-host.js +110 -0
  91. package/dist/contracts/agent-engine/capability-ports.d.ts +95 -0
  92. package/dist/contracts/agent-engine/domain-validation.js +107 -0
  93. package/dist/contracts/agent-engine/domain.d.ts +138 -0
  94. package/dist/contracts/agent-engine/index.d.ts +11 -0
  95. package/dist/contracts/agent-engine/index.js +6 -0
  96. package/dist/contracts/agent-engine/package-ports.d.ts +60 -0
  97. package/dist/contracts/agent-engine/ports.js +1 -0
  98. package/dist/contracts/owned-ui/extension-ui.d.ts +310 -0
  99. package/dist/contracts/owned-ui/image-attachments.d.ts +36 -0
  100. package/dist/contracts/owned-ui/image-attachments.js +67 -0
  101. package/dist/contracts/owned-ui/index.d.ts +12 -0
  102. package/dist/contracts/owned-ui/index.js +8 -0
  103. package/dist/contracts/owned-ui/model.d.ts +378 -0
  104. package/dist/contracts/owned-ui/prompt-history.d.ts +55 -0
  105. package/dist/contracts/owned-ui/prompt-history.js +23 -0
  106. package/dist/contracts/owned-ui/prompt-suggestions.d.ts +3 -0
  107. package/dist/contracts/owned-ui/prompt-suggestions.js +44 -0
  108. package/dist/contracts/owned-ui/suggestion-diagnostics.d.ts +22 -0
  109. package/dist/contracts/owned-ui/suggestion-diagnostics.js +9 -0
  110. package/dist/contracts/owned-ui/transcript-lifecycle.d.ts +5 -0
  111. package/dist/contracts/owned-ui/transcript-lifecycle.js +33 -0
  112. package/dist/contracts/owned-ui/validation.d.ts +15 -0
  113. package/dist/contracts/owned-ui/validation.js +523 -0
  114. package/dist/contracts/presentation/index.d.ts +104 -0
  115. package/dist/features/launch/development-launch.js +36 -0
  116. package/dist/features/launch/index.d.ts +12 -0
  117. package/dist/features/launch/index.js +6 -0
  118. package/dist/features/launch/intent.d.ts +12 -0
  119. package/dist/features/launch/intent.js +8 -0
  120. package/dist/features/launch/prepare-launch.d.ts +11 -0
  121. package/dist/features/launch/prepare-launch.js +14 -0
  122. package/dist/features/launch/profile-paths.d.ts +16 -0
  123. package/dist/features/launch/profile-paths.js +36 -0
  124. package/dist/features/launch/runtime-selection.d.ts +16 -0
  125. package/dist/features/launch/runtime-selection.js +13 -0
  126. package/dist/features/owned-ui/index.d.ts +6 -0
  127. package/dist/features/owned-ui/index.js +4 -0
  128. package/dist/features/owned-ui/project-trust-prompt.d.ts +25 -0
  129. package/dist/features/owned-ui/project-trust-prompt.js +149 -0
  130. package/dist/features/owned-ui/run.d.ts +17 -0
  131. package/dist/features/owned-ui/run.js +64 -0
  132. package/dist/features/owned-ui/session-fork-prompt.d.ts +8 -0
  133. package/dist/features/owned-ui/session-fork-prompt.js +34 -0
  134. package/dist/features/owned-ui/settings-app.d.ts +21 -0
  135. package/dist/features/owned-ui/settings-app.js +807 -0
  136. package/dist/features/owned-ui/settings-route.d.ts +2 -0
  137. package/dist/features/owned-ui/settings-route.js +2 -0
  138. package/dist/features/prompt-history/image-sidecar.d.ts +32 -0
  139. package/dist/features/prompt-history/image-sidecar.js +130 -0
  140. package/dist/features/prompt-history/index.d.ts +4 -0
  141. package/dist/features/prompt-history/index.js +3 -0
  142. package/dist/features/prompt-history/paths.d.ts +5 -0
  143. package/dist/features/prompt-history/paths.js +17 -0
  144. package/dist/features/prompt-history/service.d.ts +54 -0
  145. package/dist/features/prompt-history/service.js +425 -0
  146. package/dist/features/prompt-history/store.d.ts +16 -0
  147. package/dist/features/prompt-history/store.js +219 -0
  148. package/dist/features/prompt-history/worker.d.ts +9 -0
  149. package/dist/features/prompt-history/worker.js +45 -0
  150. package/dist/features/prompt-suggestions/diagnostics.d.ts +18 -0
  151. package/dist/features/prompt-suggestions/diagnostics.js +82 -0
  152. package/dist/features/prompt-suggestions/index.d.ts +2 -0
  153. package/dist/features/prompt-suggestions/index.js +1 -0
  154. package/dist/foundation/launch-context/index.d.ts +59 -0
  155. package/dist/foundation/launch-context/index.js +136 -0
  156. package/dist/foundation/launch-guardian/index.d.ts +2 -0
  157. package/dist/foundation/launch-guardian/index.js +1 -0
  158. package/dist/foundation/launch-guardian/main.d.ts +33 -0
  159. package/dist/foundation/launch-guardian/main.js +180 -0
  160. package/dist/foundation/lifecycle/commands.js +1 -0
  161. package/dist/foundation/lifecycle/index.d.ts +11 -0
  162. package/dist/foundation/lifecycle/index.js +5 -0
  163. package/dist/foundation/lifecycle/model.d.ts +64 -0
  164. package/dist/foundation/lifecycle/model.js +40 -0
  165. package/dist/foundation/lifecycle/paths.d.ts +30 -0
  166. package/dist/foundation/lifecycle/paths.js +70 -0
  167. package/dist/foundation/lifecycle/session-selection.d.ts +9 -0
  168. package/dist/foundation/lifecycle/session-selection.js +39 -0
  169. package/dist/foundation/lifecycle/supervisor-startup.d.ts +30 -0
  170. package/dist/foundation/lifecycle/supervisor-startup.js +106 -0
  171. package/dist/foundation/process-containment/darwin-process-inspector.d.ts +5 -0
  172. package/dist/foundation/process-containment/darwin-process-inspector.js +7 -0
  173. package/dist/foundation/process-containment/index.d.ts +8 -0
  174. package/dist/foundation/process-containment/index.js +6 -0
  175. package/dist/foundation/process-containment/linux-process-inspector.d.ts +7 -0
  176. package/dist/foundation/process-containment/linux-process-inspector.js +27 -0
  177. package/dist/foundation/process-containment/native-guardian-containment.d.ts +17 -0
  178. package/dist/foundation/process-containment/native-guardian-containment.js +140 -0
  179. package/dist/foundation/process-containment/windows-process-inspector.d.ts +19 -0
  180. package/dist/foundation/process-containment/windows-process-inspector.js +56 -0
  181. package/dist/foundation/protocol/client.d.ts +18 -0
  182. package/dist/foundation/protocol/client.js +130 -0
  183. package/dist/foundation/protocol/index.d.ts +3 -0
  184. package/dist/foundation/protocol/index.js +2 -0
  185. package/dist/foundation/protocol/messages.d.ts +90 -0
  186. package/dist/foundation/protocol/messages.js +100 -0
  187. package/dist/foundation/release/bootstrap.d.ts +51 -0
  188. package/dist/foundation/release/bootstrap.js +427 -0
  189. package/dist/foundation/release/cohort-state.d.ts +157 -0
  190. package/dist/foundation/release/cohort-state.js +472 -0
  191. package/dist/foundation/release/dependency-certification-retention.d.ts +7 -0
  192. package/dist/foundation/release/dependency-certification-retention.js +88 -0
  193. package/dist/foundation/release/dependency-certification.d.ts +24 -0
  194. package/dist/foundation/release/dependency-certification.js +266 -0
  195. package/dist/foundation/release/dependency-layer.d.ts +78 -0
  196. package/dist/foundation/release/dependency-layer.js +466 -0
  197. package/dist/foundation/release/endpoints.d.ts +24 -0
  198. package/dist/foundation/release/endpoints.js +134 -0
  199. package/dist/foundation/release/immutable-platform.d.ts +6 -0
  200. package/dist/foundation/release/immutable-platform.js +13 -0
  201. package/dist/foundation/release/index.d.ts +30 -0
  202. package/dist/foundation/release/index.js +16 -0
  203. package/dist/foundation/release/release-gc.d.ts +71 -0
  204. package/dist/foundation/release/release-gc.js +764 -0
  205. package/dist/foundation/release/release-store.d.ts +49 -0
  206. package/dist/foundation/release/release-store.js +235 -0
  207. package/dist/foundation/release/release.d.ts +43 -0
  208. package/dist/foundation/release/release.js +215 -0
  209. package/dist/foundation/release/restart-certification.d.ts +68 -0
  210. package/dist/foundation/release/restart-certification.js +227 -0
  211. package/dist/foundation/release/types.d.ts +11 -0
  212. package/dist/foundation/release/types.js +1 -0
  213. package/dist/foundation/release/update-launch.d.ts +6 -0
  214. package/dist/foundation/release/update-launch.js +17 -0
  215. package/dist/foundation/release/update-recovery.d.ts +76 -0
  216. package/dist/foundation/release/update-recovery.js +356 -0
  217. package/dist/foundation/release/update-transaction.d.ts +42 -0
  218. package/dist/foundation/release/update-transaction.js +101 -0
  219. package/dist/foundation/release/update.d.ts +119 -0
  220. package/dist/foundation/release/update.js +632 -0
  221. package/dist/foundation/release/warmup.d.ts +3 -0
  222. package/dist/foundation/release/warmup.js +47 -0
  223. package/dist/foundation/startup/index.d.ts +4 -0
  224. package/dist/foundation/startup/index.js +2 -0
  225. package/dist/foundation/startup/startup-budget.d.ts +46 -0
  226. package/dist/foundation/startup/startup-budget.js +42 -0
  227. package/dist/foundation/startup/startup-descriptor.js +34 -0
  228. package/dist/foundation/startup/startup-runtime.d.ts +27 -0
  229. package/dist/foundation/startup/startup-runtime.js +128 -0
  230. package/dist/foundation/storage/control-store.d.ts +18 -0
  231. package/dist/foundation/storage/control-store.js +342 -0
  232. package/dist/foundation/storage/index.d.ts +1 -0
  233. package/dist/foundation/storage/index.js +1 -0
  234. package/dist/foundation/supervision/index.d.ts +3 -0
  235. package/dist/foundation/supervision/index.js +3 -0
  236. package/dist/foundation/supervision/main.d.ts +1 -0
  237. package/dist/foundation/supervision/main.js +84 -0
  238. package/dist/foundation/supervision/paths.d.ts +1 -0
  239. package/dist/foundation/supervision/paths.js +1 -0
  240. package/dist/foundation/supervision/server.d.ts +46 -0
  241. package/dist/foundation/supervision/server.js +573 -0
  242. package/dist/foundation/terminal-cleanup/fatal-exit.d.ts +12 -0
  243. package/dist/foundation/terminal-cleanup/fatal-exit.js +87 -0
  244. package/dist/foundation/terminal-cleanup/index.d.ts +3 -0
  245. package/dist/foundation/terminal-cleanup/index.js +2 -0
  246. package/dist/foundation/terminal-cleanup/terminal-reset.d.ts +4 -0
  247. package/dist/foundation/terminal-cleanup/terminal-reset.js +40 -0
  248. package/dist/integrations/pi/components/components.d.ts +4 -0
  249. package/dist/integrations/pi/components/components.js +64 -0
  250. package/dist/integrations/pi/components/conformance.d.ts +18 -0
  251. package/dist/integrations/pi/components/conformance.js +70 -0
  252. package/dist/integrations/pi/components/editor-interaction.d.ts +38 -0
  253. package/dist/integrations/pi/components/editor-interaction.js +1 -0
  254. package/dist/integrations/pi/components/history-editor-loader.d.ts +5 -0
  255. package/dist/integrations/pi/components/history-editor-loader.js +5 -0
  256. package/dist/integrations/pi/components/index.d.ts +21 -0
  257. package/dist/integrations/pi/components/index.js +13 -0
  258. package/dist/integrations/pi/components/owned-editor-ux.d.ts +74 -0
  259. package/dist/integrations/pi/components/owned-editor-ux.js +1094 -0
  260. package/dist/integrations/pi/components/path-word-ranges.d.ts +2 -0
  261. package/dist/integrations/pi/components/path-word-ranges.js +37 -0
  262. package/dist/integrations/pi/components/prompt-input-port.d.ts +18 -0
  263. package/dist/integrations/pi/components/prompt-input-port.js +1 -0
  264. package/dist/integrations/pi/components/resources/builtin-themes.d.ts +167 -0
  265. package/dist/integrations/pi/components/resources/builtin-themes.js +168 -0
  266. package/dist/integrations/pi/components/shell-components.d.ts +7 -0
  267. package/dist/integrations/pi/components/shell-components.js +7 -0
  268. package/dist/integrations/pi/components/shell-editor-autocomplete.js +298 -0
  269. package/dist/integrations/pi/components/shell-extension-ui.d.ts +35 -0
  270. package/dist/integrations/pi/components/shell-extension-ui.js +280 -0
  271. package/dist/integrations/pi/components/shell-footer-status.d.ts +7 -0
  272. package/dist/integrations/pi/components/shell-footer-status.js +248 -0
  273. package/dist/integrations/pi/components/shell-presenters-info.d.ts +43 -0
  274. package/dist/integrations/pi/components/shell-presenters-info.js +114 -0
  275. package/dist/integrations/pi/components/shell-presenters-transcript.d.ts +29 -0
  276. package/dist/integrations/pi/components/shell-presenters-transcript.js +433 -0
  277. package/dist/integrations/pi/components/shell-selectors-dialogs.d.ts +123 -0
  278. package/dist/integrations/pi/components/shell-selectors-dialogs.js +242 -0
  279. package/dist/integrations/pi/components/shell-shared-facade.d.ts +217 -0
  280. package/dist/integrations/pi/components/shell-shared-facade.js +92 -0
  281. package/dist/integrations/pi/components/submitted-prompt-adapter.d.ts +17 -0
  282. package/dist/integrations/pi/components/submitted-prompt-adapter.js +49 -0
  283. package/dist/integrations/pi/components/tool-image-presentation.d.ts +21 -0
  284. package/dist/integrations/pi/components/tool-image-presentation.js +83 -0
  285. package/dist/integrations/pi/components/tool-result-adapter.d.ts +6 -0
  286. package/dist/integrations/pi/components/tool-result-adapter.js +27 -0
  287. package/dist/integrations/pi/components/transcript-image-resolver.d.ts +7 -0
  288. package/dist/integrations/pi/components/transcript-image-resolver.js +19 -0
  289. package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.d.ts +445 -0
  290. package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.js +370 -0
  291. package/dist/integrations/pi/components/upstream/assets/earendil-image.json +12 -0
  292. package/dist/integrations/pi/components/upstream/components/countdown-timer.d.ts +13 -0
  293. package/dist/integrations/pi/components/upstream/components/daxnuts.d.ts +29 -0
  294. package/dist/integrations/pi/components/upstream/components/daxnuts.js +146 -0
  295. package/dist/integrations/pi/components/upstream/components/earendil-announcement.d.ts +4 -0
  296. package/dist/integrations/pi/components/upstream/components/earendil-announcement.js +48 -0
  297. package/dist/integrations/pi/components/upstream/components/extension-editor.d.ts +20 -0
  298. package/dist/integrations/pi/components/upstream/components/extension-editor.js +84 -0
  299. package/dist/integrations/pi/components/upstream/components/mermaid.js +81 -0
  300. package/dist/integrations/pi/components/upstream/components/owned-editor.d.ts +46 -0
  301. package/dist/integrations/pi/components/upstream/components/owned-editor.js +187 -0
  302. package/dist/integrations/pi/components/upstream/components/scoped-models-selector.d.ts +59 -0
  303. package/dist/integrations/pi/components/upstream/components/scoped-models-selector.js +346 -0
  304. package/dist/integrations/pi/components/upstream/components/session-footer.d.ts +11 -0
  305. package/dist/integrations/pi/components/upstream/components/session-footer.js +123 -0
  306. package/dist/integrations/pi/components/upstream/components/session-selector-search.js +161 -0
  307. package/dist/integrations/pi/components/upstream/components/session-selector.d.ts +95 -0
  308. package/dist/integrations/pi/components/upstream/components/session-selector.js +893 -0
  309. package/dist/integrations/pi/components/upstream/components/skill-invocation-message.d.ts +21 -0
  310. package/dist/integrations/pi/components/upstream/components/skill-invocation-message.js +46 -0
  311. package/dist/integrations/pi/components/upstream/components/status-indicator.d.ts +35 -0
  312. package/dist/integrations/pi/components/upstream/components/status-indicator.js +69 -0
  313. package/dist/integrations/pi/components/upstream/components/tool-execution.d.ts +67 -0
  314. package/dist/integrations/pi/components/upstream/components/tool-execution.js +365 -0
  315. package/dist/integrations/pi/components/upstream/components/tree-selector.d.ts +101 -0
  316. package/dist/integrations/pi/components/upstream/components/tree-selector.js +1275 -0
  317. package/dist/integrations/pi/components/upstream/components/trust-selector.d.ts +33 -0
  318. package/dist/integrations/pi/components/upstream/components/trust-selector.js +81 -0
  319. package/dist/integrations/pi/components/upstream/external-editor.js +43 -0
  320. package/dist/integrations/pi/components/upstream/history/editor-core.d.ts +289 -0
  321. package/dist/integrations/pi/components/upstream/history/editor-core.js +2144 -0
  322. package/dist/integrations/pi/components/upstream/history/kill-ring.d.ts +35 -0
  323. package/dist/integrations/pi/components/upstream/history/kill-ring.js +51 -0
  324. package/dist/integrations/pi/components/upstream/history/printable-key.d.ts +1 -0
  325. package/dist/integrations/pi/components/upstream/history/printable-key.js +43 -0
  326. package/dist/integrations/pi/components/upstream/history/text-helpers.d.ts +14 -0
  327. package/dist/integrations/pi/components/upstream/history/text-helpers.js +31 -0
  328. package/dist/integrations/pi/components/upstream/history/undo-stack.d.ts +25 -0
  329. package/dist/integrations/pi/components/upstream/history/undo-stack.js +39 -0
  330. package/dist/integrations/pi/components/upstream/history/word-navigation.d.ts +24 -0
  331. package/dist/integrations/pi/components/upstream/history/word-navigation.js +103 -0
  332. package/dist/integrations/pi/components/upstream/model-search.d.ts +18 -0
  333. package/dist/integrations/pi/components/upstream/theme/theme-controller.d.ts +33 -0
  334. package/dist/integrations/pi/components/upstream/theme/theme-controller.js +114 -0
  335. package/dist/integrations/pi/components/upstream/theme/theme.d.ts +61 -0
  336. package/dist/integrations/pi/components/upstream/theme/theme.js +337 -0
  337. package/dist/integrations/pi/engine/adapter.d.ts +135 -0
  338. package/dist/integrations/pi/engine/adapter.js +648 -0
  339. package/dist/integrations/pi/engine/changelog.d.ts +2 -0
  340. package/dist/integrations/pi/engine/changelog.js +63 -0
  341. package/dist/integrations/pi/engine/command-dispatch.d.ts +41 -0
  342. package/dist/integrations/pi/engine/command-dispatch.js +125 -0
  343. package/dist/integrations/pi/engine/compaction-progress.d.ts +28 -0
  344. package/dist/integrations/pi/engine/compaction-progress.js +96 -0
  345. package/dist/integrations/pi/engine/conformance.d.ts +39 -0
  346. package/dist/integrations/pi/engine/conformance.js +140 -0
  347. package/dist/integrations/pi/engine/event-delivery.d.ts +100 -0
  348. package/dist/integrations/pi/engine/event-delivery.js +184 -0
  349. package/dist/integrations/pi/engine/extension-ui-binding.d.ts +35 -0
  350. package/dist/integrations/pi/engine/extension-ui-binding.js +81 -0
  351. package/dist/integrations/pi/engine/http-dispatcher.d.ts +4 -0
  352. package/dist/integrations/pi/engine/http-dispatcher.js +25 -0
  353. package/dist/integrations/pi/engine/index.d.ts +18 -0
  354. package/dist/integrations/pi/engine/index.js +10 -0
  355. package/dist/integrations/pi/engine/message-values.d.ts +29 -0
  356. package/dist/integrations/pi/engine/message-values.js +168 -0
  357. package/dist/integrations/pi/engine/package-integration.d.ts +13 -0
  358. package/dist/integrations/pi/engine/package-integration.js +118 -0
  359. package/dist/integrations/pi/engine/pending-delivery.d.ts +30 -0
  360. package/dist/integrations/pi/engine/pending-delivery.js +156 -0
  361. package/dist/integrations/pi/engine/pi-settings-metadata.json +385 -0
  362. package/dist/integrations/pi/engine/project-trust-preflight.d.ts +22 -0
  363. package/dist/integrations/pi/engine/project-trust-preflight.js +50 -0
  364. package/dist/integrations/pi/engine/prompt-suggestions.d.ts +30 -0
  365. package/dist/integrations/pi/engine/prompt-suggestions.js +102 -0
  366. package/dist/integrations/pi/engine/provider-authentication.d.ts +34 -0
  367. package/dist/integrations/pi/engine/provider-authentication.js +209 -0
  368. package/dist/integrations/pi/engine/resource-catalog.d.ts +49 -0
  369. package/dist/integrations/pi/engine/resource-catalog.js +289 -0
  370. package/dist/integrations/pi/engine/resources/changelog.json +12 -0
  371. package/dist/integrations/pi/engine/runtime-integration.d.ts +53 -0
  372. package/dist/integrations/pi/engine/runtime-integration.js +118 -0
  373. package/dist/integrations/pi/engine/session-events.d.ts +48 -0
  374. package/dist/integrations/pi/engine/session-events.js +223 -0
  375. package/dist/integrations/pi/engine/session-integration.d.ts +67 -0
  376. package/dist/integrations/pi/engine/session-integration.js +195 -0
  377. package/dist/integrations/pi/engine/session-runtime.d.ts +84 -0
  378. package/dist/integrations/pi/engine/session-runtime.js +249 -0
  379. package/dist/integrations/pi/engine/session-selection.d.ts +28 -0
  380. package/dist/integrations/pi/engine/session-selection.js +90 -0
  381. package/dist/integrations/pi/engine/settings-bridge.d.ts +121 -0
  382. package/dist/integrations/pi/engine/settings-bridge.js +514 -0
  383. package/dist/integrations/pi/engine/settings-metadata.d.ts +31 -0
  384. package/dist/integrations/pi/engine/settings-metadata.js +67 -0
  385. package/dist/integrations/pi/engine/settings-port.d.ts +42 -0
  386. package/dist/integrations/pi/engine/settings-port.js +353 -0
  387. package/dist/integrations/pi/engine/tool-rendering.d.ts +13 -0
  388. package/dist/integrations/pi/engine/tool-rendering.js +145 -0
  389. package/dist/integrations/pi/engine/transcript-image-assets.d.ts +11 -0
  390. package/dist/integrations/pi/engine/transcript-image-assets.js +86 -0
  391. package/dist/integrations/pi/engine/transcript-projection.d.ts +39 -0
  392. package/dist/integrations/pi/engine/transcript-projection.js +405 -0
  393. package/dist/integrations/pi/engine/usage-view.d.ts +4 -0
  394. package/dist/integrations/pi/engine/usage-view.js +56 -0
  395. package/dist/integrations/pi/engine/windows-filesystem-hygiene.d.ts +21 -0
  396. package/dist/integrations/pi/engine/windows-filesystem-hygiene.js +55 -0
  397. package/dist/integrations/pi/engine/workflow-contexts.d.ts +59 -0
  398. package/dist/integrations/pi/engine/workflow-contexts.js +316 -0
  399. package/dist/integrations/pi/engine/workflow-runner.d.ts +60 -0
  400. package/dist/integrations/pi/engine/workflow-runner.js +509 -0
  401. package/dist/integrations/pi/engine/workflow-support.d.ts +33 -0
  402. package/dist/integrations/pi/engine/workflow-support.js +352 -0
  403. package/dist/integrations/pi/engine/workflows.d.ts +251 -0
  404. package/dist/integrations/pi/engine/workflows.js +63 -0
  405. package/dist/integrations/pi/startup-public.d.ts +2 -0
  406. package/dist/integrations/pi/startup-public.js +2223 -0
  407. package/dist/integrations/pi/startup-public.manifest.json +12502 -0
  408. package/dist/integrations/pi/tui-runtime/adapter.d.ts +56 -0
  409. package/dist/integrations/pi/tui-runtime/adapter.js +783 -0
  410. package/dist/integrations/pi/tui-runtime/contracts.d.ts +156 -0
  411. package/dist/integrations/pi/tui-runtime/contracts.js +1 -0
  412. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +88 -0
  413. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +433 -0
  414. package/dist/integrations/pi/tui-runtime/index.d.ts +9 -0
  415. package/dist/integrations/pi/tui-runtime/index.js +5 -0
  416. package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.d.ts +39 -0
  417. package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.js +139 -0
  418. package/dist/integrations/pi/tui-runtime/mouse-report-input.d.ts +13 -0
  419. package/dist/integrations/pi/tui-runtime/mouse-report-input.js +57 -0
  420. package/dist/integrations/pi/tui-runtime/overlay-geometry.d.ts +32 -0
  421. package/dist/integrations/pi/tui-runtime/overlay-geometry.js +158 -0
  422. package/dist/integrations/pi/tui-runtime/presentation-adapter.d.ts +4 -0
  423. package/dist/integrations/pi/tui-runtime/presentation-adapter.js +48 -0
  424. package/dist/native/darwin-arm64/manifest.json +4 -4
  425. package/dist/native/darwin-arm64/process-guardian +0 -0
  426. package/dist/native/linux-x64/manifest.json +3 -3
  427. package/dist/native/linux-x64/process-guardian +0 -0
  428. package/dist/native/win32-x64/manifest.json +3 -3
  429. package/dist/native/win32-x64/process-guardian.exe +0 -0
  430. package/dist/product-identity.d.ts +37 -0
  431. package/dist/product-identity.js +119 -0
  432. package/dist/product-identity.json +85 -0
  433. package/dist/runtime-payload-inventory.json +127147 -0
  434. package/dist/ui/apps/contracts.d.ts +64 -0
  435. package/dist/ui/apps/host.d.ts +42 -0
  436. package/dist/ui/apps/host.js +156 -0
  437. package/dist/ui/apps/index.d.ts +5 -0
  438. package/dist/ui/apps/index.js +3 -0
  439. package/dist/ui/apps/registry.d.ts +12 -0
  440. package/dist/ui/apps/registry.js +33 -0
  441. package/dist/ui/components/dialog-panel.js +49 -0
  442. package/dist/ui/components/frame.d.ts +22 -0
  443. package/dist/ui/components/frame.js +55 -0
  444. package/dist/ui/components/index.d.ts +47 -0
  445. package/dist/ui/components/index.js +25 -0
  446. package/dist/ui/components/line-input.d.ts +68 -0
  447. package/dist/ui/components/line-input.js +224 -0
  448. package/dist/ui/components/list-view.d.ts +60 -0
  449. package/dist/ui/components/list-view.js +82 -0
  450. package/dist/ui/components/mouse.d.ts +25 -0
  451. package/dist/ui/components/mouse.js +70 -0
  452. package/dist/ui/components/progress-status.d.ts +2 -0
  453. package/dist/ui/components/progress-status.js +4 -0
  454. package/dist/ui/components/prompt-input.d.ts +32 -0
  455. package/dist/ui/components/prompt-input.js +51 -0
  456. package/dist/ui/components/scrollbar.d.ts +88 -0
  457. package/dist/ui/components/scrollbar.js +137 -0
  458. package/dist/ui/components/selection-copy.d.ts +24 -0
  459. package/dist/ui/components/selection-copy.js +39 -0
  460. package/dist/ui/components/shortcuts.d.ts +58 -0
  461. package/dist/ui/components/shortcuts.js +82 -0
  462. package/dist/ui/components/spans.d.ts +28 -0
  463. package/dist/ui/components/spans.js +266 -0
  464. package/dist/ui/components/submitted-prompt.d.ts +23 -0
  465. package/dist/ui/components/submitted-prompt.js +50 -0
  466. package/dist/ui/components/surface.d.ts +20 -0
  467. package/dist/ui/components/surface.js +44 -0
  468. package/dist/ui/components/text-selection.d.ts +62 -0
  469. package/dist/ui/components/text-selection.js +210 -0
  470. package/dist/ui/components/text.d.ts +38 -0
  471. package/dist/ui/components/text.js +185 -0
  472. package/dist/ui/components/transcript-viewport.d.ts +173 -0
  473. package/dist/ui/components/transcript-viewport.js +753 -0
  474. package/dist/ui/components/visible-hyperlinks.d.ts +26 -0
  475. package/dist/ui/components/visible-hyperlinks.js +97 -0
  476. package/dist/ui/settings/declarations.d.ts +141 -0
  477. package/dist/ui/settings/declarations.js +135 -0
  478. package/dist/ui/settings/index.d.ts +10 -0
  479. package/dist/ui/settings/index.js +5 -0
  480. package/dist/ui/settings/manager.d.ts +54 -0
  481. package/dist/ui/settings/manager.js +256 -0
  482. package/dist/ui/settings/migrations.d.ts +13 -0
  483. package/dist/ui/settings/migrations.js +74 -0
  484. package/dist/ui/settings/sections.d.ts +52 -0
  485. package/dist/ui/settings/sections.js +112 -0
  486. package/docs/architecture/boundaries.md +17 -13
  487. package/docs/architecture/code-documentation.md +77 -0
  488. package/docs/architecture/history-editor-provenance.md +100 -0
  489. package/docs/architecture/internal-naming.md +91 -0
  490. package/docs/architecture/process-guardian-provenance.md +3 -1
  491. package/docs/architecture/project-structure.md +69 -30
  492. package/docs/architecture/prompt-suggestions.md +68 -0
  493. package/docs/architecture/resource-and-data-policy.md +28 -2
  494. package/docs/architecture/response-copy-delivery.md +85 -0
  495. package/docs/architecture/terminal-host-proof-gate.md +1 -1
  496. package/docs/architecture/terminal-host-spike-evidence.md +1 -1
  497. package/docs/architecture/tool-image-presentation.md +62 -0
  498. package/docs/architecture/toolchain.md +32 -10
  499. package/docs/architecture/ui-reference-provenance.md +60 -6
  500. package/docs/ci-release-runbook.md +256 -79
  501. package/docs/features/launch-profiles.md +24 -17
  502. package/docs/features/modal-content-interaction.md +37 -0
  503. package/docs/features/prompt-history.md +149 -0
  504. package/docs/local-worktree-cleanup.md +212 -0
  505. package/docs/manual-code-streaming-cleanup.md +88 -0
  506. package/docs/manual-ghost-link-baseline.md +89 -0
  507. package/docs/manual-launch-instance-acceptance.md +12 -35
  508. package/docs/manual-owned-ui-checkpoint.md +79 -0
  509. package/docs/manual-pi-boundary-candidate.md +4 -5
  510. package/docs/manual-terminal-colour-check.md +4 -3
  511. package/docs/openspec-archive-automation.md +259 -0
  512. package/docs/repository-governance-live-acceptance.md +77 -0
  513. package/docs/validation.md +100 -0
  514. package/package.json +49 -34
  515. package/dist/src/cli/capabilities.d.ts +0 -15
  516. package/dist/src/cli/capabilities.js +0 -7
  517. package/dist/src/cli/dispatch.d.ts +0 -32
  518. package/dist/src/cli/dispatch.js +0 -142
  519. package/dist/src/cli/index.d.ts +0 -5
  520. package/dist/src/cli/index.js +0 -5
  521. package/dist/src/cli/packages.d.ts +0 -23
  522. package/dist/src/cli/packages.js +0 -84
  523. package/dist/src/cli/version-stats.d.ts +0 -16
  524. package/dist/src/cli/version-stats.js +0 -72
  525. package/dist/src/cli/version.d.ts +0 -2
  526. package/dist/src/cli/version.js +0 -23
  527. package/dist/src/composition/index.d.ts +0 -48
  528. package/dist/src/composition/index.js +0 -258
  529. package/dist/src/features/launch/development-launch.js +0 -28
  530. package/dist/src/features/launch/index.d.ts +0 -7
  531. package/dist/src/features/launch/index.js +0 -7
  532. package/dist/src/features/launch/intent.d.ts +0 -7
  533. package/dist/src/features/launch/intent.js +0 -4
  534. package/dist/src/features/launch/prepare-launch.d.ts +0 -13
  535. package/dist/src/features/launch/prepare-launch.js +0 -21
  536. package/dist/src/features/launch/profile-paths.d.ts +0 -15
  537. package/dist/src/features/launch/profile-paths.js +0 -31
  538. package/dist/src/features/launch/profiles.d.ts +0 -12
  539. package/dist/src/features/launch/profiles.js +0 -26
  540. package/dist/src/features/launch/runtime-selection.d.ts +0 -19
  541. package/dist/src/features/launch/runtime-selection.js +0 -13
  542. package/dist/src/features/owned-ui/customization.d.ts +0 -38
  543. package/dist/src/features/owned-ui/customization.js +0 -108
  544. package/dist/src/features/owned-ui/diagnostics.d.ts +0 -33
  545. package/dist/src/features/owned-ui/diagnostics.js +0 -94
  546. package/dist/src/features/owned-ui/index.d.ts +0 -4
  547. package/dist/src/features/owned-ui/index.js +0 -4
  548. package/dist/src/features/owned-ui/run.d.ts +0 -11
  549. package/dist/src/features/owned-ui/run.js +0 -15
  550. package/dist/src/features/owned-ui/settings-app.d.ts +0 -22
  551. package/dist/src/features/owned-ui/settings-app.js +0 -633
  552. package/dist/src/features/workspace/capabilities.d.ts +0 -31
  553. package/dist/src/features/workspace/capabilities.js +0 -75
  554. package/dist/src/features/workspace/index.d.ts +0 -6
  555. package/dist/src/features/workspace/index.js +0 -6
  556. package/dist/src/features/workspace/presentation.d.ts +0 -30
  557. package/dist/src/features/workspace/presentation.js +0 -70
  558. package/dist/src/features/workspace/reconciliation.d.ts +0 -15
  559. package/dist/src/features/workspace/reconciliation.js +0 -82
  560. package/dist/src/features/workspace/reducer.d.ts +0 -42
  561. package/dist/src/features/workspace/reducer.js +0 -213
  562. package/dist/src/features/workspace/router.d.ts +0 -31
  563. package/dist/src/features/workspace/router.js +0 -124
  564. package/dist/src/features/workspace/store.d.ts +0 -17
  565. package/dist/src/features/workspace/store.js +0 -54
  566. package/dist/src/foundation/agent-engine-contracts/capability-ports.d.ts +0 -95
  567. package/dist/src/foundation/agent-engine-contracts/domain-validation.js +0 -89
  568. package/dist/src/foundation/agent-engine-contracts/domain.d.ts +0 -116
  569. package/dist/src/foundation/agent-engine-contracts/index.d.ts +0 -8
  570. package/dist/src/foundation/agent-engine-contracts/index.js +0 -8
  571. package/dist/src/foundation/agent-engine-contracts/package-ports.d.ts +0 -54
  572. package/dist/src/foundation/launch-guardian/index.d.ts +0 -1
  573. package/dist/src/foundation/launch-guardian/index.js +0 -1
  574. package/dist/src/foundation/launch-guardian/main.d.ts +0 -31
  575. package/dist/src/foundation/launch-guardian/main.js +0 -165
  576. package/dist/src/foundation/lifecycle/index.d.ts +0 -4
  577. package/dist/src/foundation/lifecycle/index.js +0 -4
  578. package/dist/src/foundation/lifecycle/model.d.ts +0 -64
  579. package/dist/src/foundation/lifecycle/model.js +0 -40
  580. package/dist/src/foundation/lifecycle/paths.d.ts +0 -10
  581. package/dist/src/foundation/lifecycle/paths.js +0 -42
  582. package/dist/src/foundation/native-host-protocol/codec.d.ts +0 -11
  583. package/dist/src/foundation/native-host-protocol/codec.js +0 -56
  584. package/dist/src/foundation/native-host-protocol/evidence.d.ts +0 -67
  585. package/dist/src/foundation/native-host-protocol/evidence.js +0 -141
  586. package/dist/src/foundation/native-host-protocol/index.d.ts +0 -4
  587. package/dist/src/foundation/native-host-protocol/index.js +0 -4
  588. package/dist/src/foundation/native-host-protocol/messages.d.ts +0 -56
  589. package/dist/src/foundation/native-host-protocol/messages.js +0 -149
  590. package/dist/src/foundation/native-host-protocol/proof-gate.d.ts +0 -13
  591. package/dist/src/foundation/native-host-protocol/proof-gate.js +0 -33
  592. package/dist/src/foundation/owned-ui-contracts/extension-ui.d.ts +0 -302
  593. package/dist/src/foundation/owned-ui-contracts/index.d.ts +0 -3
  594. package/dist/src/foundation/owned-ui-contracts/index.js +0 -3
  595. package/dist/src/foundation/owned-ui-contracts/model.d.ts +0 -241
  596. package/dist/src/foundation/owned-ui-contracts/validation.d.ts +0 -11
  597. package/dist/src/foundation/owned-ui-contracts/validation.js +0 -395
  598. package/dist/src/foundation/owned-ui-settings/declarations.d.ts +0 -13
  599. package/dist/src/foundation/owned-ui-settings/declarations.js +0 -39
  600. package/dist/src/foundation/owned-ui-settings/index.d.ts +0 -6
  601. package/dist/src/foundation/owned-ui-settings/index.js +0 -6
  602. package/dist/src/foundation/owned-ui-settings/migrations.d.ts +0 -13
  603. package/dist/src/foundation/owned-ui-settings/migrations.js +0 -28
  604. package/dist/src/foundation/owned-ui-settings/sections.d.ts +0 -70
  605. package/dist/src/foundation/owned-ui-settings/sections.js +0 -93
  606. package/dist/src/foundation/owned-ui-settings/session.d.ts +0 -44
  607. package/dist/src/foundation/owned-ui-settings/session.js +0 -145
  608. package/dist/src/foundation/owned-ui-settings/store.d.ts +0 -28
  609. package/dist/src/foundation/owned-ui-settings/store.js +0 -90
  610. package/dist/src/foundation/pi-component-adapter/components.d.ts +0 -4
  611. package/dist/src/foundation/pi-component-adapter/components.js +0 -64
  612. package/dist/src/foundation/pi-component-adapter/conformance.d.ts +0 -17
  613. package/dist/src/foundation/pi-component-adapter/conformance.js +0 -69
  614. package/dist/src/foundation/pi-component-adapter/index.d.ts +0 -13
  615. package/dist/src/foundation/pi-component-adapter/index.js +0 -13
  616. package/dist/src/foundation/pi-component-adapter/resources/builtin-themes.d.ts +0 -165
  617. package/dist/src/foundation/pi-component-adapter/resources/builtin-themes.js +0 -166
  618. package/dist/src/foundation/pi-component-adapter/shell-components.d.ts +0 -6
  619. package/dist/src/foundation/pi-component-adapter/shell-components.js +0 -6
  620. package/dist/src/foundation/pi-component-adapter/shell-editor-autocomplete.js +0 -162
  621. package/dist/src/foundation/pi-component-adapter/shell-extension-ui.d.ts +0 -35
  622. package/dist/src/foundation/pi-component-adapter/shell-extension-ui.js +0 -279
  623. package/dist/src/foundation/pi-component-adapter/shell-footer-status.d.ts +0 -7
  624. package/dist/src/foundation/pi-component-adapter/shell-footer-status.js +0 -189
  625. package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.d.ts +0 -57
  626. package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.js +0 -429
  627. package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.d.ts +0 -113
  628. package/dist/src/foundation/pi-component-adapter/shell-selectors-dialogs.js +0 -235
  629. package/dist/src/foundation/pi-component-adapter/shell-shared-facade.d.ts +0 -116
  630. package/dist/src/foundation/pi-component-adapter/shell-shared-facade.js +0 -87
  631. package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.d.ts +0 -422
  632. package/dist/src/foundation/pi-component-adapter/upstream/adjacent/core/keybindings.js +0 -296
  633. package/dist/src/foundation/pi-component-adapter/upstream/components/countdown-timer.d.ts +0 -10
  634. package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.d.ts +0 -17
  635. package/dist/src/foundation/pi-component-adapter/upstream/components/custom-entry.js +0 -51
  636. package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.d.ts +0 -22
  637. package/dist/src/foundation/pi-component-adapter/upstream/components/daxnuts.js +0 -142
  638. package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.d.ts +0 -4
  639. package/dist/src/foundation/pi-component-adapter/upstream/components/earendil-announcement.js +0 -19
  640. package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.d.ts +0 -17
  641. package/dist/src/foundation/pi-component-adapter/upstream/components/extension-editor.js +0 -81
  642. package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.d.ts +0 -24
  643. package/dist/src/foundation/pi-component-adapter/upstream/components/first-time-setup.js +0 -105
  644. package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.d.ts +0 -2
  645. package/dist/src/foundation/pi-component-adapter/upstream/components/markdown-transform.js +0 -18
  646. package/dist/src/foundation/pi-component-adapter/upstream/components/mermaid.js +0 -77
  647. package/dist/src/foundation/pi-component-adapter/upstream/components/owned-editor.d.ts +0 -18
  648. package/dist/src/foundation/pi-component-adapter/upstream/components/owned-editor.js +0 -55
  649. package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.d.ts +0 -55
  650. package/dist/src/foundation/pi-component-adapter/upstream/components/scoped-models-selector.js +0 -342
  651. package/dist/src/foundation/pi-component-adapter/upstream/components/session-footer.d.ts +0 -10
  652. package/dist/src/foundation/pi-component-adapter/upstream/components/session-footer.js +0 -120
  653. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector-search.js +0 -159
  654. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.d.ts +0 -95
  655. package/dist/src/foundation/pi-component-adapter/upstream/components/session-selector.js +0 -889
  656. package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.d.ts +0 -19
  657. package/dist/src/foundation/pi-component-adapter/upstream/components/skill-invocation-message.js +0 -44
  658. package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.d.ts +0 -30
  659. package/dist/src/foundation/pi-component-adapter/upstream/components/status-indicator.js +0 -59
  660. package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.d.ts +0 -98
  661. package/dist/src/foundation/pi-component-adapter/upstream/components/tree-selector.js +0 -1272
  662. package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.d.ts +0 -33
  663. package/dist/src/foundation/pi-component-adapter/upstream/components/trust-selector.js +0 -76
  664. package/dist/src/foundation/pi-component-adapter/upstream/external-editor.js +0 -39
  665. package/dist/src/foundation/pi-component-adapter/upstream/model-search.d.ts +0 -15
  666. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.d.ts +0 -25
  667. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme-controller.js +0 -117
  668. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.d.ts +0 -61
  669. package/dist/src/foundation/pi-component-adapter/upstream/theme/theme.js +0 -326
  670. package/dist/src/foundation/pi-engine-adapter/adapter.d.ts +0 -164
  671. package/dist/src/foundation/pi-engine-adapter/adapter.js +0 -2367
  672. package/dist/src/foundation/pi-engine-adapter/conformance.d.ts +0 -37
  673. package/dist/src/foundation/pi-engine-adapter/conformance.js +0 -130
  674. package/dist/src/foundation/pi-engine-adapter/index.d.ts +0 -10
  675. package/dist/src/foundation/pi-engine-adapter/index.js +0 -10
  676. package/dist/src/foundation/pi-engine-adapter/model-auth-integration.d.ts +0 -30
  677. package/dist/src/foundation/pi-engine-adapter/model-auth-integration.js +0 -61
  678. package/dist/src/foundation/pi-engine-adapter/package-integration.d.ts +0 -13
  679. package/dist/src/foundation/pi-engine-adapter/package-integration.js +0 -112
  680. package/dist/src/foundation/pi-engine-adapter/pi-settings-metadata.json +0 -374
  681. package/dist/src/foundation/pi-engine-adapter/resource-extension-integration.d.ts +0 -31
  682. package/dist/src/foundation/pi-engine-adapter/resource-extension-integration.js +0 -80
  683. package/dist/src/foundation/pi-engine-adapter/runtime-integration.d.ts +0 -35
  684. package/dist/src/foundation/pi-engine-adapter/runtime-integration.js +0 -67
  685. package/dist/src/foundation/pi-engine-adapter/session-integration.d.ts +0 -43
  686. package/dist/src/foundation/pi-engine-adapter/session-integration.js +0 -97
  687. package/dist/src/foundation/pi-engine-adapter/settings-integration.d.ts +0 -55
  688. package/dist/src/foundation/pi-engine-adapter/settings-integration.js +0 -233
  689. package/dist/src/foundation/pi-engine-adapter/workflow-controllers.d.ts +0 -20
  690. package/dist/src/foundation/pi-engine-adapter/workflow-controllers.js +0 -48
  691. package/dist/src/foundation/pi-engine-adapter/workflows.d.ts +0 -173
  692. package/dist/src/foundation/pi-engine-adapter/workflows.js +0 -60
  693. package/dist/src/foundation/pi-owned-ui-integration/index.d.ts +0 -2
  694. package/dist/src/foundation/pi-owned-ui-integration/index.js +0 -2
  695. package/dist/src/foundation/pi-owned-ui-integration/route-host.d.ts +0 -29
  696. package/dist/src/foundation/pi-owned-ui-integration/session-shell.d.ts +0 -106
  697. package/dist/src/foundation/pi-owned-ui-integration/session-shell.js +0 -1518
  698. package/dist/src/foundation/pi-tui-runtime-adapter/adapter.d.ts +0 -39
  699. package/dist/src/foundation/pi-tui-runtime-adapter/adapter.js +0 -493
  700. package/dist/src/foundation/pi-tui-runtime-adapter/conformance.d.ts +0 -18
  701. package/dist/src/foundation/pi-tui-runtime-adapter/conformance.js +0 -145
  702. package/dist/src/foundation/pi-tui-runtime-adapter/contracts.d.ts +0 -120
  703. package/dist/src/foundation/pi-tui-runtime-adapter/index.d.ts +0 -4
  704. package/dist/src/foundation/pi-tui-runtime-adapter/index.js +0 -4
  705. package/dist/src/foundation/pi-tui-runtime-adapter/presentation-adapter.d.ts +0 -4
  706. package/dist/src/foundation/pi-tui-runtime-adapter/presentation-adapter.js +0 -48
  707. package/dist/src/foundation/presentation-contracts/index.d.ts +0 -96
  708. package/dist/src/foundation/process-containment/index.d.ts +0 -5
  709. package/dist/src/foundation/process-containment/index.js +0 -5
  710. package/dist/src/foundation/process-containment/linux-process-inspector.d.ts +0 -6
  711. package/dist/src/foundation/process-containment/linux-process-inspector.js +0 -26
  712. package/dist/src/foundation/process-containment/native-guardian-containment.d.ts +0 -16
  713. package/dist/src/foundation/process-containment/native-guardian-containment.js +0 -139
  714. package/dist/src/foundation/process-containment/windows-process-inspector.d.ts +0 -17
  715. package/dist/src/foundation/process-containment/windows-process-inspector.js +0 -53
  716. package/dist/src/foundation/protocol/client.d.ts +0 -17
  717. package/dist/src/foundation/protocol/client.js +0 -129
  718. package/dist/src/foundation/protocol/index.d.ts +0 -2
  719. package/dist/src/foundation/protocol/index.js +0 -2
  720. package/dist/src/foundation/protocol/messages.d.ts +0 -89
  721. package/dist/src/foundation/protocol/messages.js +0 -99
  722. package/dist/src/foundation/release/bootstrap.d.ts +0 -29
  723. package/dist/src/foundation/release/bootstrap.js +0 -335
  724. package/dist/src/foundation/release/cohort-state.d.ts +0 -70
  725. package/dist/src/foundation/release/cohort-state.js +0 -202
  726. package/dist/src/foundation/release/index.d.ts +0 -10
  727. package/dist/src/foundation/release/index.js +0 -10
  728. package/dist/src/foundation/release/release-gc.d.ts +0 -5
  729. package/dist/src/foundation/release/release-gc.js +0 -16
  730. package/dist/src/foundation/release/release-store.d.ts +0 -43
  731. package/dist/src/foundation/release/release-store.js +0 -175
  732. package/dist/src/foundation/release/release.d.ts +0 -38
  733. package/dist/src/foundation/release/release.js +0 -204
  734. package/dist/src/foundation/release/update-transaction.d.ts +0 -31
  735. package/dist/src/foundation/release/update-transaction.js +0 -89
  736. package/dist/src/foundation/release/update.d.ts +0 -82
  737. package/dist/src/foundation/release/update.js +0 -529
  738. package/dist/src/foundation/storage/control-store.d.ts +0 -61
  739. package/dist/src/foundation/storage/control-store.js +0 -530
  740. package/dist/src/foundation/storage/index.d.ts +0 -1
  741. package/dist/src/foundation/storage/index.js +0 -1
  742. package/dist/src/foundation/structured-agent-runtime/backpressure.d.ts +0 -46
  743. package/dist/src/foundation/structured-agent-runtime/backpressure.js +0 -118
  744. package/dist/src/foundation/structured-agent-runtime/commands.d.ts +0 -52
  745. package/dist/src/foundation/structured-agent-runtime/commands.js +0 -164
  746. package/dist/src/foundation/structured-agent-runtime/handshake.d.ts +0 -41
  747. package/dist/src/foundation/structured-agent-runtime/handshake.js +0 -151
  748. package/dist/src/foundation/structured-agent-runtime/index.d.ts +0 -5
  749. package/dist/src/foundation/structured-agent-runtime/index.js +0 -5
  750. package/dist/src/foundation/structured-agent-runtime/reconnection.d.ts +0 -37
  751. package/dist/src/foundation/structured-agent-runtime/reconnection.js +0 -129
  752. package/dist/src/foundation/structured-agent-runtime/state.d.ts +0 -56
  753. package/dist/src/foundation/structured-agent-runtime/state.js +0 -118
  754. package/dist/src/foundation/supervision/index.d.ts +0 -3
  755. package/dist/src/foundation/supervision/index.js +0 -3
  756. package/dist/src/foundation/supervision/main.d.ts +0 -1
  757. package/dist/src/foundation/supervision/main.js +0 -41
  758. package/dist/src/foundation/supervision/paths.d.ts +0 -1
  759. package/dist/src/foundation/supervision/paths.js +0 -1
  760. package/dist/src/foundation/supervision/server.d.ts +0 -22
  761. package/dist/src/foundation/supervision/server.js +0 -451
  762. package/dist/src/foundation/ui-apps/contracts.d.ts +0 -42
  763. package/dist/src/foundation/ui-apps/host.d.ts +0 -42
  764. package/dist/src/foundation/ui-apps/host.js +0 -152
  765. package/dist/src/foundation/ui-apps/index.d.ts +0 -3
  766. package/dist/src/foundation/ui-apps/index.js +0 -3
  767. package/dist/src/foundation/ui-apps/registry.d.ts +0 -11
  768. package/dist/src/foundation/ui-apps/registry.js +0 -32
  769. package/dist/src/foundation/ui-components/dialog-panel.js +0 -47
  770. package/dist/src/foundation/ui-components/frame.d.ts +0 -21
  771. package/dist/src/foundation/ui-components/frame.js +0 -54
  772. package/dist/src/foundation/ui-components/index.d.ts +0 -18
  773. package/dist/src/foundation/ui-components/index.js +0 -18
  774. package/dist/src/foundation/ui-components/line-input.d.ts +0 -74
  775. package/dist/src/foundation/ui-components/line-input.js +0 -245
  776. package/dist/src/foundation/ui-components/list-view.d.ts +0 -66
  777. package/dist/src/foundation/ui-components/list-view.js +0 -76
  778. package/dist/src/foundation/ui-components/mouse.d.ts +0 -15
  779. package/dist/src/foundation/ui-components/mouse.js +0 -46
  780. package/dist/src/foundation/ui-components/scrollbar.d.ts +0 -62
  781. package/dist/src/foundation/ui-components/scrollbar.js +0 -102
  782. package/dist/src/foundation/ui-components/shortcuts.d.ts +0 -57
  783. package/dist/src/foundation/ui-components/shortcuts.js +0 -81
  784. package/dist/src/foundation/ui-components/spans.d.ts +0 -7
  785. package/dist/src/foundation/ui-components/spans.js +0 -59
  786. package/dist/src/foundation/ui-components/surface.d.ts +0 -20
  787. package/dist/src/foundation/ui-components/surface.js +0 -38
  788. package/dist/src/foundation/ui-components/text.d.ts +0 -24
  789. package/dist/src/foundation/ui-components/text.js +0 -123
  790. package/dist/src/foundation/workspace-contracts/index.d.ts +0 -2
  791. package/dist/src/foundation/workspace-contracts/index.js +0 -2
  792. package/dist/src/foundation/workspace-contracts/model.d.ts +0 -248
  793. package/dist/src/foundation/workspace-contracts/model.js +0 -2
  794. package/dist/src/foundation/workspace-contracts/validation.d.ts +0 -13
  795. package/dist/src/foundation/workspace-contracts/validation.js +0 -335
  796. package/dist/src/product-identity.d.ts +0 -37
  797. package/dist/src/product-identity.js +0 -150
  798. package/dist/src/product-identity.json +0 -99
  799. package/docs/manual-transparent-checkpoint.md +0 -53
  800. /package/dist/{src/foundation/agent-engine-contracts/domain.js → app/session-shell/paste-helper.d.ts} +0 -0
  801. /package/dist/{src/foundation/agent-engine-contracts/ports.js → app/session-shell/paste-text-worker.d.ts} +0 -0
  802. /package/dist/{src/foundation/lifecycle/commands.js → app/session-shell/paste-types.js} +0 -0
  803. /package/dist/{src/foundation/pi-owned-ui-integration/route-host.js → app/session-shell/response-copy-helper.d.ts} +0 -0
  804. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/capability-ports.js +0 -0
  805. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain-validation.d.ts +0 -0
  806. /package/dist/{src/foundation/pi-tui-runtime-adapter/contracts.js → contracts/agent-engine/domain.js} +0 -0
  807. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/model.d.ts +0 -0
  808. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/model.js +0 -0
  809. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/package-ports.js +0 -0
  810. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/ports.d.ts +0 -0
  811. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/serialization.d.ts +0 -0
  812. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/serialization.js +0 -0
  813. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/validation.d.ts +0 -0
  814. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/validation.js +0 -0
  815. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/extension-ui.js +0 -0
  816. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/model.js +0 -0
  817. /package/dist/{src/foundation/presentation-contracts → contracts/presentation}/index.js +0 -0
  818. /package/dist/{src/features → features}/launch/development-launch.d.ts +0 -0
  819. /package/dist/{src/features → features}/launch/initialize-profile.d.ts +0 -0
  820. /package/dist/{src/features → features}/launch/initialize-profile.js +0 -0
  821. /package/dist/{src/foundation → foundation}/lifecycle/commands.d.ts +0 -0
  822. /package/dist/{src/foundation → foundation}/lifecycle/launch-instance.d.ts +0 -0
  823. /package/dist/{src/foundation → foundation}/lifecycle/launch-instance.js +0 -0
  824. /package/dist/{src/foundation → foundation}/process-containment/artifact.d.ts +0 -0
  825. /package/dist/{src/foundation → foundation}/process-containment/artifact.js +0 -0
  826. /package/dist/{src/foundation → foundation}/process-containment/contracts.d.ts +0 -0
  827. /package/dist/{src/foundation → foundation}/process-containment/contracts.js +0 -0
  828. /package/dist/{src/foundation → foundation}/release/cohort-selection.d.ts +0 -0
  829. /package/dist/{src/foundation → foundation}/release/cohort-selection.js +0 -0
  830. /package/dist/{src/foundation → foundation}/release/concurrency.d.ts +0 -0
  831. /package/dist/{src/foundation → foundation}/release/concurrency.js +0 -0
  832. /package/dist/{src/foundation → foundation}/release/process-cleanup.d.ts +0 -0
  833. /package/dist/{src/foundation → foundation}/release/process-cleanup.js +0 -0
  834. /package/dist/{src/foundation → foundation}/release/stable-release.d.ts +0 -0
  835. /package/dist/{src/foundation → foundation}/release/stable-release.js +0 -0
  836. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-editor-autocomplete.d.ts +0 -0
  837. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/theme.d.ts +0 -0
  838. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/theme.js +0 -0
  839. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/countdown-timer.js +0 -0
  840. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/mermaid.d.ts +0 -0
  841. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector-search.d.ts +0 -0
  842. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/external-editor.d.ts +0 -0
  843. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/model-search.js +0 -0
  844. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/public-main-entry.d.ts +0 -0
  845. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/public-main-entry.js +0 -0
  846. /package/dist/{src/foundation/ui-apps → ui/apps}/contracts.js +0 -0
  847. /package/dist/{src/foundation/ui-components → ui/components}/dialog-panel.d.ts +0 -0
  848. /package/dist/{src/foundation/ui-components → ui/components}/label.d.ts +0 -0
  849. /package/dist/{src/foundation/ui-components → ui/components}/label.js +0 -0
  850. /package/dist/{src/foundation/ui-components → ui/components}/list-block.d.ts +0 -0
  851. /package/dist/{src/foundation/ui-components → ui/components}/list-block.js +0 -0
  852. /package/dist/{src/foundation/ui-components → ui/components}/pane.d.ts +0 -0
  853. /package/dist/{src/foundation/ui-components → ui/components}/pane.js +0 -0
  854. /package/dist/{src/foundation/ui-components → ui/components}/revision.d.ts +0 -0
  855. /package/dist/{src/foundation/ui-components → ui/components}/revision.js +0 -0
  856. /package/dist/{src/foundation/ui-components → ui/components}/status-line.d.ts +0 -0
  857. /package/dist/{src/foundation/ui-components → ui/components}/status-line.js +0 -0
  858. /package/dist/{src/foundation/ui-components → ui/components}/stepper.d.ts +0 -0
  859. /package/dist/{src/foundation/ui-components → ui/components}/stepper.js +0 -0
  860. /package/dist/{src/foundation/ui-components → ui/components}/theme.d.ts +0 -0
  861. /package/dist/{src/foundation/ui-components → ui/components}/theme.js +0 -0
  862. /package/dist/{src/foundation/ui-components → ui/components}/value-menu.d.ts +0 -0
  863. /package/dist/{src/foundation/ui-components → ui/components}/value-menu.js +0 -0
  864. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/resolution.d.ts +0 -0
  865. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/resolution.js +0 -0
@@ -0,0 +1,1366 @@
1
+ import { acceptsTranscriptUpdate } from "../../contracts/owned-ui/index.js";
2
+ import { caretCell } from "../../ui/components/line-input.js";
3
+ import { PromptInput, promptArrow } from "../../ui/components/prompt-input.js";
4
+ import { composeSubmittedPromptRows, formatSubmittedPromptTime, submittedPromptLayout, } from "../../ui/components/submitted-prompt.js";
5
+ import { backgroundSgrSpan, heldNativeHyperlinkStyle, hyperlinkSgrSpan, nativeHyperlinkStyle, overlaySpan, } from "../../ui/components/spans.js";
6
+ import { progressStatusText } from "../../ui/components/progress-status.js";
7
+ import { displayWidth, faint, stripAnsi } from "../../ui/components/text.js";
8
+ import { PINNED_PI_HIDDEN_COMMAND_NAMES, PINNED_PI_WORKFLOW_COMMAND_NAMES } from "../../integrations/pi/engine/workflows.js";
9
+ import { createPiExtensionUiBridge } from "../../integrations/pi/components/shell-extension-ui.js";
10
+ import { createPiShellEditor } from "../../integrations/pi/components/shell-editor-autocomplete.js";
11
+ import { createPiQueuedInputStatus, createPiShellFooter, createPiShellHeader, createPiShellLoadedResources, createPiShellStatus, } from "../../integrations/pi/components/shell-footer-status.js";
12
+ import { createPiShellArmin, createPiShellAuthProviderSelector, createPiShellDaxnuts, createPiShellDialog, createPiShellEarendilAnnouncement, createPiShellExtensionSelector, createPiShellLoginDialog, createPiShellModelSelector, createPiShellOperationLoader, createPiShellReloadBox, createPiShellScopedModelsSelector, createPiShellSelector, createPiShellSessionSelector, createPiShellSettingsSelector, createPiShellTreeSelector, createPiShellTrustSelector, createPiShellUserMessageSelector, } from "../../integrations/pi/components/shell-selectors-dialogs.js";
13
+ import { createPiShellChangelog, createPiShellCollapsedChangelog, createPiShellHotkeys, createPiShellSessionInfo, renderPiShellCommandMessage, renderPiShellStatusText, } from "../../integrations/pi/components/shell-presenters-info.js";
14
+ import { createPiShellTranscriptComponent, isPiPromptStyleCompaction, paintPiSubmittedPromptTimestamp, renderPiShellPackageUpdateNotice, renderPiShellStartupDiagnostic, renderPiShellTranscriptBlock, } from "../../integrations/pi/components/shell-presenters-transcript.js";
15
+ import { onPiThemeChange, PINNED_PI_LAYOUT, piTheme } from "../../integrations/pi/components/upstream/theme/theme.js";
16
+ import { piShellHyperlink, piShellTruncateToWidth, piShellVisibleWidth, } from "../../integrations/pi/components/shell-shared-facade.js";
17
+ import { classifyPiTuiInput, } from "../../integrations/pi/tui-runtime/input-presentation-coordinator.js";
18
+ import { PromptChipStore } from "./prompt-chips.js";
19
+ import { EditorHyperlinkBudget } from "./editor-hyperlink-budget.js";
20
+ import { SessionViewportController } from "./session-viewport-controller.js";
21
+ import { canPreparePasteInline } from "./paste-text-preparation.js";
22
+ /** Composes backend session state into the owned transcript, viewport, editor, and dock presentation. */
23
+ export class OwnedUiSessionShellRoot {
24
+ editor;
25
+ header;
26
+ resources;
27
+ #cwd;
28
+ #transcript = new Map();
29
+ #blocksById = new Map();
30
+ #renderedRows = new Map();
31
+ // Performance: document layouts are shared by wheel, rail, jump, and selection frames.
32
+ #documentLayouts = new Map();
33
+ #themeUnsubscribe;
34
+ #transcriptOrder = [];
35
+ #view;
36
+ #status;
37
+ #footer;
38
+ #queued;
39
+ #extensionRenderers;
40
+ #imageAssets;
41
+ #promptChips;
42
+ #editorHyperlinks = new EditorHyperlinkBudget();
43
+ #pasteDiagnosticId = 0;
44
+ #terminalPasteDiagnosticRequest;
45
+ #customViewport;
46
+ #submittedPromptComposer;
47
+ #viewportController;
48
+ #viewportTheme;
49
+ #onViewportFrame;
50
+ #onInputSurfaceChanged;
51
+ #componentRuntime;
52
+ #toolsExpanded = false;
53
+ #thinkingVisible = true;
54
+ #mermaidRenderingMode = "off";
55
+ #showImages = true;
56
+ #imageWidthCells = 80;
57
+ #outputPad = 1;
58
+ #workflowTranscriptSequence = 0;
59
+ #workflowStatusAnchors = new Map();
60
+ #workflowStatusMessages = new Map();
61
+ #lastWorkflowStatusId;
62
+ // Invariant: the notice is dock chrome, never transcript content; the custom viewport alone uses it.
63
+ #dockNotice;
64
+ #inputSurface;
65
+ #inputSurfaceCoordination = "editor";
66
+ #dockInputReuseEnabled;
67
+ #dockInputCandidate = false;
68
+ // Invariant: receipt-time eligibility is evidence, never authorization for composition-time reuse.
69
+ #dockInputRevision;
70
+ #visibleViewportSnapshot;
71
+ #fullViewportCompositions = 0;
72
+ #dockOnlyViewportCompositions = 0;
73
+ #transcriptBlockRenders = 0;
74
+ #extensionHeader = null;
75
+ #extensionFooter = null;
76
+ #extensionWidgets = new Map();
77
+ #extensionStatuses = new Map();
78
+ #extensionWorkingMessage;
79
+ #extensionWorkingVisible = true;
80
+ constructor(view, cwd, handlers, startup = {}, agentDir, extensionRenderers = {
81
+ getMessageRenderer: () => undefined,
82
+ getToolDefinition: () => undefined,
83
+ }, sessionLayout = "pinned", imageAssets) {
84
+ this.#view = view;
85
+ this.#customViewport = sessionLayout === "custom-viewport";
86
+ this.#promptChips = new PromptChipStore({ isolated: this.#customViewport,
87
+ ...(handlers.pasteDiagnostics === undefined ? {} : { onEvent: handlers.pasteDiagnostics }),
88
+ ...(handlers.pastePreparation === undefined ? {} : { preparation: handlers.pastePreparation }) });
89
+ this.#submittedPromptComposer = this.#customViewport
90
+ ? {
91
+ layout: submittedPromptLayout,
92
+ compose: (rows, width, source, style) => composeSubmittedPromptRows(rows, width, source, { ...style, prefix: text => promptArrow(text, piTheme()) })
93
+ .map(row => nativeHyperlinkStyle(row, nativeTranscriptLinkColor)),
94
+ }
95
+ : undefined;
96
+ this.#cwd = cwd;
97
+ this.#extensionRenderers = extensionRenderers;
98
+ this.#imageAssets = imageAssets;
99
+ this.#componentRuntime = handlers;
100
+ this.#onViewportFrame = handlers.onViewportFrame;
101
+ this.#onInputSurfaceChanged = handlers.onInputSurfaceChanged;
102
+ this.#dockInputReuseEnabled = handlers.enableDockInputReuse ?? true;
103
+ this.header = createPiShellHeader({
104
+ ...startup,
105
+ ...(this.#customViewport ? { getKeybindings: () => this.editor.keybindingConfig() } : {}),
106
+ });
107
+ this.resources = createPiShellLoadedResources(startup.resources ?? [], startup.expanded ?? false);
108
+ this.#status = createPiShellStatus(view, progressStatusText, handlers);
109
+ this.#status.setProgressPresentation(this.#customViewport ? "custom-viewport" : "pinned");
110
+ this.#footer = createPiShellFooter(this.#viewWithExtensionStatuses(view), cwd, this.#customViewport ? "a1" : "pi");
111
+ this.#queued = createPiQueuedInputStatus(view.editor.queuedSubmissions, this.#customViewport ? "custom-viewport" : "pinned");
112
+ this.editor = createPiShellEditor({
113
+ ...handlers,
114
+ keybindingProfile: this.#customViewport ? "a1" : "pi",
115
+ paintEditorSelection: (line, from, to, atomic) => backgroundSgrSpan(line, from, to, atomic ? "\u001b[7m" : "\u001b[27m\u001b[48;2;38;79;120m", atomic ? "\u001b[27m" : "\u001b[49m", piShellVisibleWidth),
116
+ transformPastedContent: content => {
117
+ try {
118
+ return this.#promptChips.transformPastedContent(content, this.editor.getText());
119
+ }
120
+ catch (error) {
121
+ handlers.onPasteRejected?.(error);
122
+ return "";
123
+ }
124
+ },
125
+ ...(this.#customViewport ? {
126
+ beginClipboardPaste: () => this.#promptChips.beginPaste(this.editor.getText(), handlers.captureClipboardPaste?.() ?? { kind: "provided", read: signal => handlers.readClipboardContent?.(signal) ?? Promise.resolve(null) }, error => handlers.onPasteRejected?.(error), () => handlers.requestRender()),
127
+ onPasteInput: (bytes, phase) => {
128
+ try {
129
+ if (phase === "framing")
130
+ this.#terminalPasteDiagnosticRequest = --this.#pasteDiagnosticId;
131
+ const request = this.#terminalPasteDiagnosticRequest ?? --this.#pasteDiagnosticId;
132
+ handlers.pasteDiagnostics?.({ request, phase, bytes, atMs: performance.now(), pending: 0, transport: "terminal",
133
+ ...(phase === "settled" ? { outcome: "ready" } : {}) });
134
+ if (phase === "settled")
135
+ this.#terminalPasteDiagnosticRequest = undefined;
136
+ }
137
+ catch { /* Invariant: payload-free diagnostics cannot interfere with the input path. */ }
138
+ },
139
+ deferTextPaste: text => !canPreparePasteInline(text),
140
+ beginTextPaste: text => this.#promptChips.beginPaste(this.editor.getText(), { kind: "text", text }, error => handlers.onPasteRejected?.(error)),
141
+ } : {}),
142
+ editorAtomicRanges: line => this.#promptChips.atomicRanges(line),
143
+ editorHiddenRanges: line => this.#promptChips.hiddenRanges(line),
144
+ decorateEditorRow: (row, width, rowIndex) => {
145
+ if (rowIndex === 0)
146
+ this.#editorHyperlinks.reset();
147
+ const plain = stripAnsi(row);
148
+ const ranges = this.#promptChips.hyperlinkRanges(plain);
149
+ if (ranges.length === 0 || !this.#editorHyperlinks.takeCleanup())
150
+ return row;
151
+ const linkResetAndTail = `\u001b]8;;\u001b\\\u001b[24m${" ".repeat(Math.max(0, width - piShellVisibleWidth(row)))}`;
152
+ // Platform: VS15 is zero-column and default-ignorable. It breaks Windows Terminal's
153
+ // plain-text URL detector only in the held-button paint; semantic text stays exact.
154
+ const paintRow = this.#viewportController.editorPointerSelecting
155
+ ? row.replaceAll("https://", "https:\uFE0E//").replaceAll("http://", "http:\uFE0E//")
156
+ : row;
157
+ const decorated = this.#viewportController.editorPointerSelecting
158
+ ? ranges.reduce((result, range) => backgroundSgrSpan(result, piShellVisibleWidth(plain.slice(0, range.start)), piShellVisibleWidth(plain.slice(0, range.end)), "\u001b[4:4m", "\u001b[24m", piShellVisibleWidth), paintRow)
159
+ : ranges.filter(range => this.#editorHyperlinks.take(range.target)).reduce((result, range) => hyperlinkSgrSpan(result, piShellVisibleWidth(plain.slice(0, range.start)), piShellVisibleWidth(plain.slice(0, range.end)), range.target, piShellVisibleWidth), row);
160
+ // Platform: Windows Terminal can retain stale native dotted-link cells when a mutable
161
+ // prompt replaces a longer URL. Explicit non-link spaces overwrite that tail.
162
+ return `${decorated}${linkResetAndTail}`;
163
+ },
164
+ expandCopiedEditorText: text => this.#promptChips.expandCopiedText(text),
165
+ cwd,
166
+ ...(agentDir === undefined ? {} : { agentDir }),
167
+ onToolsExpand: () => this.#setToolsExpanded(!this.#toolsExpanded),
168
+ ...(this.#customViewport ? {
169
+ promptPresentation: {
170
+ input: new PromptInput({ fg: (token, text) => piTheme().fg(token, text) }, {
171
+ measure: piShellVisibleWidth,
172
+ truncate: piShellTruncateToWidth,
173
+ }),
174
+ styleSuggestion: faint,
175
+ styleSuggestionCaret: caretCell,
176
+ },
177
+ } : {}),
178
+ onChange: text => {
179
+ handlers.onEditorChange?.(text);
180
+ // Concurrency: Pi clears before onSubmit; capture waiting references before pruning removed chips.
181
+ queueMicrotask(() => this.#promptChips.reconcileDraft(this.editor.getText()));
182
+ },
183
+ ...(handlers.onPromptSuggestionAccepted === undefined ? {} : { onPromptSuggestionAccepted: handlers.onPromptSuggestionAccepted }),
184
+ });
185
+ this.#viewportController = new SessionViewportController({
186
+ enabled: this.#customViewport,
187
+ editor: this.editor,
188
+ requestRender: force => this.#componentRuntime.requestRender(force),
189
+ requestHyperlinkCleanup: rows => handlers.requestHyperlinkCleanup?.(rows),
190
+ hasEditorLinks: () => this.#promptChips.hyperlinkRanges(this.editor.getText()).length > 0,
191
+ ...(handlers.pasteDiagnostics === undefined ? {} : { pasteDiagnostics: handlers.pasteDiagnostics }),
192
+ nextPasteDiagnosticRequest: () => --this.#pasteDiagnosticId,
193
+ });
194
+ // Performance: stable painter identities let the neutral viewport retain row-level
195
+ // selection variants while each callback still resolves the live Pi theme.
196
+ this.#viewportTheme = {
197
+ track: text => `${SCROLLBAR_CELL_RESET}${piTheme().fg("dim", text)}`,
198
+ thumb: text => `${SCROLLBAR_CELL_RESET}${piTheme().fg("accent", text)}`,
199
+ sticky: (text, hovered) => piTheme().bg(hovered ? "selectedBg" : "toolPendingBg", piTheme().fg("text", withoutTerminalBackground(text))),
200
+ quietSticky: text => `\u001b[2m${text.replace(/\u001b\[(?:0|22)m/g, "$&\u001b[2m")}\u001b[22m`,
201
+ bottomControl: (text, hovered) => piTheme().bg(hovered ? "selectedBg" : "toolPendingBg", piTheme().fg("text", text)),
202
+ selection: (line, from, to) => backgroundSgrSpan(line, from, to, "\u001b[48;2;38;79;120m", "\u001b[49m"),
203
+ };
204
+ this.editor.setThinkingLevel(view.thinkingLevel);
205
+ this.#inputSurface = this.editor;
206
+ for (const block of view.transcript) {
207
+ if (block.kind === "user")
208
+ this.editor.addToHistory(block.text);
209
+ }
210
+ this.#syncTranscript(view.transcript);
211
+ // Invariant: colours come from the active theme, so rendered rows outlive their revision only
212
+ // until the theme under them changes.
213
+ this.#themeUnsubscribe = onPiThemeChange(() => {
214
+ this.#renderedRows.clear();
215
+ this.#documentLayouts.clear();
216
+ });
217
+ }
218
+ setEditorPaddingX(padding) {
219
+ this.editor.setPaddingX(padding);
220
+ this.#documentLayouts.clear();
221
+ }
222
+ setAutocompleteMaxVisible(maxVisible) {
223
+ this.editor.setAutocompleteMaxVisible(maxVisible);
224
+ }
225
+ setOutputPad(padding) {
226
+ if (this.#outputPad === padding)
227
+ return;
228
+ this.#outputPad = padding;
229
+ this.#status.setOutputPad(padding);
230
+ for (const component of this.#transcript.values())
231
+ component.setOutputPad(padding);
232
+ this.#invalidateTranscriptPresentation();
233
+ }
234
+ setHideThinkingBlock(hidden) {
235
+ if (this.#thinkingVisible === !hidden)
236
+ return;
237
+ this.#thinkingVisible = !hidden;
238
+ for (const component of this.#transcript.values())
239
+ component.setHideThinkingBlock(hidden);
240
+ this.#invalidateTranscriptPresentation();
241
+ }
242
+ setMermaidRenderingMode(mode) {
243
+ if (this.#mermaidRenderingMode === mode)
244
+ return;
245
+ this.#mermaidRenderingMode = mode;
246
+ for (const component of this.#transcript.values())
247
+ component.setMermaidRenderingMode(mode);
248
+ this.#invalidateTranscriptPresentation();
249
+ }
250
+ setImagePresentation(showImages, imageWidthCells) {
251
+ if (this.#showImages === showImages && this.#imageWidthCells === imageWidthCells)
252
+ return;
253
+ this.#showImages = showImages;
254
+ this.#imageWidthCells = imageWidthCells;
255
+ for (const component of this.#transcript.values())
256
+ component.setImagePresentation(showImages, imageWidthCells);
257
+ this.#invalidateTranscriptPresentation();
258
+ }
259
+ prepareHistoryText(text) {
260
+ return this.#promptChips.prepareHistoryText(text);
261
+ }
262
+ rehydrateHistoryText(text, resolveImage) {
263
+ return this.#promptChips.rehydrateHistoryText(text, resolveImage);
264
+ }
265
+ imageChipAttachmentsFromEditor(text) {
266
+ return this.#promptChips.imageChipAttachments(text);
267
+ }
268
+ preparePromptSubmission(text) {
269
+ return this.#promptChips.prepareSubmission(text);
270
+ }
271
+ hasPendingPastes(text) { return this.#promptChips.hasPending(text); }
272
+ waitForPromptPastes(text, signal) {
273
+ return this.#promptChips.waitForPastes(text, signal, () => this.editor.getText());
274
+ }
275
+ resetPendingPastes() {
276
+ this.editor.cancelPendingPastes?.();
277
+ this.editor.setText(this.#promptChips.resetPastes(this.editor.getText()));
278
+ }
279
+ /** Forks the spare paste helper so the first paste of the session takes a live child. */
280
+ warmPastePreparation() { this.#promptChips.warm(); }
281
+ disposePendingPastes() {
282
+ this.resetPendingPastes();
283
+ return this.#promptChips.dispose();
284
+ }
285
+ promptSuggestionPrepareBlockReason() {
286
+ if (!this.usesDefaultInputSurface())
287
+ return "replacement-input";
288
+ if (this.#view.dialog !== null || this.#view.overlay !== null)
289
+ return "modal";
290
+ if (this.editor.getText().length > 0)
291
+ return "draft";
292
+ return null;
293
+ }
294
+ canPreparePromptSuggestion() { return this.promptSuggestionPrepareBlockReason() === null; }
295
+ promptSuggestionPresentationBlockReason() {
296
+ const reason = this.promptSuggestionPrepareBlockReason();
297
+ if (reason !== null)
298
+ return reason;
299
+ if (this.#view.lifecycle !== "ready")
300
+ return "not-ready";
301
+ return this.editor.promptSuggestionBlockReason?.()
302
+ ?? (this.editor.canPresentPromptSuggestion() ? null : "presentation-unavailable");
303
+ }
304
+ canPresentPromptSuggestion() { return this.promptSuggestionPresentationBlockReason() === null; }
305
+ setPromptSuggestion(text) {
306
+ this.editor.setPromptSuggestion(text);
307
+ }
308
+ update(view) {
309
+ if (view.diagnostics.length !== this.#view.diagnostics.length
310
+ || view.diagnostics.some((diagnostic, index) => diagnostic.sequence !== this.#view.diagnostics[index]?.sequence)) {
311
+ this.#documentLayouts.clear();
312
+ }
313
+ this.#view = view;
314
+ this.#status.update(view);
315
+ this.#footer.update(this.#viewWithExtensionStatuses(view));
316
+ this.#queued.update(view.editor.queuedSubmissions);
317
+ this.#syncTranscript(view.transcript);
318
+ this.editor.setSubmitEnabled(view.lifecycle !== "stopping" && view.lifecycle !== "stopped" && view.lifecycle !== "failed");
319
+ this.editor.setThinkingLevel(view.thinkingLevel);
320
+ // Performance: semantic updates already invalidate affected transcript blocks. Chrome is a separate authority.
321
+ this.#invalidateChrome();
322
+ }
323
+ /**
324
+ * Applies one block: its component is created or updated in place and the order grows
325
+ * only when the block is new. A streamed chunk costs one component update rather than a
326
+ * walk of the whole transcript.
327
+ */
328
+ applyTranscriptBlock(block) {
329
+ const current = this.#blocksById.get(block.id);
330
+ // Invariant: a full-view/final presentation may preempt queued partials. Never revive an older revision.
331
+ if (current !== undefined && !acceptsTranscriptUpdate(current, block))
332
+ return;
333
+ this.#blocksById.set(block.id, block);
334
+ const component = this.#transcript.get(block.id);
335
+ if (component === undefined) {
336
+ const created = this.#mountTranscript(block);
337
+ this.#transcript.set(block.id, created);
338
+ this.#transcriptOrder.push(block.id);
339
+ }
340
+ else if (component.revision !== block.revision) {
341
+ component.update(block);
342
+ }
343
+ // Performance: one chunk touches one block, and the updated component tracks its own dirtiness.
344
+ // Invalidating the whole shell here would re-wrap the entire transcript per chunk.
345
+ this.#renderedRows.delete(block.id);
346
+ this.#documentLayouts.clear();
347
+ }
348
+ #mountTranscript(block) {
349
+ // Invariant: the notice answers the reader's last command, so only their next prompt or
350
+ // shell command retires it; assistant, tool, and compaction blocks streaming in keep it.
351
+ if (block.kind === "user" || block.kind === "bash")
352
+ this.#dismissDockNotice();
353
+ const created = createPiShellTranscriptComponent(block, this.#cwd, this.#extensionRenderers, this.#submittedPromptComposer, this.#outputPad, !this.#thinkingVisible, this.#mermaidRenderingMode, this.#showImages, this.#imageWidthCells, this.#imageAssets, { ...this.#componentRuntime, changed: () => {
354
+ if (this.#transcript.get(block.id) !== created)
355
+ return;
356
+ this.#renderedRows.delete(block.id);
357
+ this.#documentLayouts.clear();
358
+ this.#visibleViewportSnapshot = undefined;
359
+ this.#dockInputCandidate = false;
360
+ this.#dockInputRevision = undefined;
361
+ this.#componentRuntime.requestRender();
362
+ } });
363
+ created.setExpanded(this.#toolsExpanded);
364
+ return created;
365
+ }
366
+ render(width) {
367
+ if (!this.#customViewport) {
368
+ this.#viewportController.setEditorPointerFrame(undefined);
369
+ return [...this.#renderDocument(width), ...this.#renderDock(width)];
370
+ }
371
+ const height = Math.max(0, this.#componentRuntime.getRows());
372
+ const dock = this.#renderDockLayout(width);
373
+ // Invariant: ordinary transcript content uses the full terminal width. The rail is an
374
+ // overlay, not a lost wrapping cell. Submitted prompts alone retain the
375
+ // intentional final gutter after their right-aligned timestamp.
376
+ const documentWidth = width;
377
+ const document = this.#renderDocumentLayout(documentWidth);
378
+ const steeringRows = this.#renderQueued(width);
379
+ const statusRows = this.#renderStatus(width);
380
+ const transientSignature = transientRowsSignature(steeringRows, statusRows);
381
+ const snapshot = this.#visibleViewportSnapshot;
382
+ const dockInputCandidate = this.#dockInputCandidate;
383
+ // Concurrency: input may change after a keyboard receipt but before its paint.
384
+ // Capture only the live inputs this composition will actually represent.
385
+ const inputSurface = this.#inputSurface;
386
+ const dockRows = dock.rows;
387
+ const selectableDocumentRowCount = document.rows.length;
388
+ const dockStartRow = height - dockRows.length + 1;
389
+ const editorOffset = dock.editorOffset;
390
+ this.#viewportController.setInputSurfaceFrame(this.usesDefaultInputSurface() ? undefined : {
391
+ component: this.#inputSurface,
392
+ columnStart: 1,
393
+ columnEnd: width,
394
+ rowStart: Math.max(1, dockStartRow + editorOffset),
395
+ rowEnd: Math.min(height, dockStartRow + editorOffset + dock.inputRows - 1),
396
+ });
397
+ this.#viewportController.setEditorPointerFrame(this.usesDefaultInputSurface()
398
+ ? {
399
+ rowStart: dockStartRow + editorOffset,
400
+ rowEnd: dockStartRow + editorOffset + dock.inputRows - 1,
401
+ }
402
+ : undefined);
403
+ const viewportRevision = this.#viewportController.presentationRevision;
404
+ const selectionRevision = this.#viewportController.selectionRevision;
405
+ const pointerPosition = this.#viewportController.pointerPosition;
406
+ this.#dockInputCandidate = false;
407
+ let frame = dockInputCandidate
408
+ && snapshot !== undefined
409
+ && snapshot.width === width
410
+ && snapshot.height === height
411
+ && snapshot.documentRows === document.rows
412
+ && snapshot.transientSignature === transientSignature
413
+ && snapshot.promptAnchors === document.promptAnchors
414
+ && snapshot.dockLength === dockRows.length
415
+ && snapshot.inputSurface === inputSurface
416
+ && snapshot.viewportRevision === viewportRevision
417
+ && snapshot.selectionRevision === selectionRevision
418
+ ? this.#viewportController.composeDockOnly(dockRows, width, height)
419
+ : null;
420
+ if (frame === null) {
421
+ frame = this.#viewportController.compose({
422
+ // Performance: do not copy the complete document on unchanged dock-only input.
423
+ // Steering and Working retain their one non-selectable viewport-tail ownership.
424
+ documentRows: [...document.rows, ...steeringRows, ...statusRows],
425
+ ...(this.#viewportController.transcriptPointerSelecting
426
+ ? { paintDocumentRow: heldNativeHyperlinkStyle }
427
+ : {}),
428
+ // Invariant: selection and copying stop at the real document tail; Steering,
429
+ // fitting alignment, and live Working remain transient presentation chrome.
430
+ selectableDocumentRowCount,
431
+ ...(document.liveTailStartRow === undefined ? {} : { liveTailStartRow: document.liveTailStartRow }),
432
+ bottomAlignedTailRowCount: statusRows.length,
433
+ dockRows,
434
+ promptAnchors: document.promptAnchors,
435
+ width,
436
+ height,
437
+ // Invariant: the control belongs immediately above the complete dock and
438
+ // floats over transient viewport content rather than consuming a dock row.
439
+ bottomControlRow: Math.max(0, height - Math.min(height, dockRows.length) - 1),
440
+ theme: this.#viewportTheme,
441
+ });
442
+ this.#fullViewportCompositions += 1;
443
+ }
444
+ else
445
+ this.#dockOnlyViewportCompositions += 1;
446
+ this.#visibleViewportSnapshot = {
447
+ width,
448
+ height,
449
+ documentRows: document.rows,
450
+ transientSignature,
451
+ promptAnchors: document.promptAnchors,
452
+ dockLength: dockRows.length,
453
+ inputSurface,
454
+ // Invariant: a callback during composition cannot bless older rows with its
455
+ // newer revision. Its ordinary pending render will publish the newer state.
456
+ viewportRevision,
457
+ selectionRevision: frame.descriptor.selectionRevision,
458
+ pointerPosition,
459
+ };
460
+ this.#onViewportFrame?.(frame);
461
+ return frame.rows;
462
+ }
463
+ viewportFrameDescriptor() {
464
+ return this.#viewportController.frame?.descriptor ?? null;
465
+ }
466
+ /** Read-only, payload-free evidence; observing a pending frame must never render or repair it. */
467
+ viewportPresentationEvidence() {
468
+ const frame = this.#viewportController.frame;
469
+ const snapshot = this.#visibleViewportSnapshot;
470
+ return {
471
+ candidate: this.#dockInputCandidate,
472
+ candidateRevision: this.#dockInputCandidate ? this.#dockInputRevision ?? null : null,
473
+ currentRevision: this.#viewportController.presentationRevision,
474
+ composedRevision: snapshot?.viewportRevision ?? null,
475
+ currentPointer: this.#viewportController.pointerPosition ?? null,
476
+ composedPointer: snapshot?.pointerPosition ?? null,
477
+ frameId: frame?.descriptor.frameId ?? null,
478
+ bottom: frame?.hits.bottom ?? null,
479
+ followingEnd: frame?.followingEnd ?? true,
480
+ scrollTop: frame?.scrollTop ?? 0,
481
+ maxScroll: frame?.maxScroll ?? 0,
482
+ cause: frame?.descriptor.cause ?? null,
483
+ };
484
+ }
485
+ /** Visible non-selectable Steering, alignment, and Working rows, for rendering evidence. */
486
+ viewportTransientTailRowCount() {
487
+ return this.#viewportController.frame?.hits.transientTail.length ?? 0;
488
+ }
489
+ hasActiveSelection() {
490
+ return this.#viewportController.hasSelection || this.editor.hasSelection();
491
+ }
492
+ setViewportConfig(config) {
493
+ if (this.#viewportController.setConfig(config))
494
+ this.#documentLayouts.clear();
495
+ }
496
+ resumeViewportFollowing() {
497
+ this.#viewportController.resumeFollowing();
498
+ }
499
+ noteCompletedAssistantMessage() {
500
+ this.#viewportController.noteCompletedAssistantMessage();
501
+ }
502
+ /** A new session binding owns new mounts even when it reuses semantic invocation ids. */
503
+ resetTranscript() {
504
+ for (const component of this.#transcript.values())
505
+ component.dispose?.();
506
+ this.#transcript.clear();
507
+ this.#blocksById.clear();
508
+ this.#transcriptOrder = [];
509
+ this.#renderedRows.clear();
510
+ this.#documentLayouts.clear();
511
+ }
512
+ resetViewport() {
513
+ this.#viewportController.reset();
514
+ }
515
+ clearViewportPointerState() {
516
+ this.#viewportController.clearPointerState();
517
+ }
518
+ setViewportOverlaySurfaces(surfaces) {
519
+ this.#viewportController.setOverlaySurfaces(surfaces);
520
+ }
521
+ viewportInputGeometryReady(width, height) {
522
+ const frame = this.#viewportController.frame;
523
+ return this.#viewportController.inputGeometryReady && frame?.descriptor.width === width && frame.descriptor.height === height;
524
+ }
525
+ handleViewportPreInput(data, allowWheel = true, now = Date.now(), editorActive = this.usesDefaultInputSurface()) {
526
+ return this.#viewportController.handlePreInput(data, allowWheel, now, editorActive);
527
+ }
528
+ #renderDock(width) {
529
+ return this.#renderDockLayout(width).rows;
530
+ }
531
+ #renderDockLayout(width) {
532
+ const queued = this.#customViewport ? [] : this.#renderQueued(width);
533
+ const statusRows = this.#customViewport ? this.#status.renderDock(width) : this.#renderStatus(width);
534
+ const transientRows = [...queued, ...statusRows, ...this.#renderDockNotice(width)];
535
+ const aboveWidgets = this.#renderWidgets("aboveEditor", width);
536
+ const input = this.#inputSurface.render(width);
537
+ // Invariant: pointer rows describe the body, not the autocomplete block now preceding it.
538
+ const body = this.usesDefaultInputSurface() ? this.editor.bodyGeometry?.() : undefined;
539
+ const belowWidgets = this.#renderWidgets("belowEditor", width);
540
+ const footer = this.#renderFooter(width);
541
+ const rowsWithoutTransient = [...aboveWidgets, ...input, ...belowWidgets, ...footer];
542
+ return {
543
+ rows: [...transientRows, ...rowsWithoutTransient],
544
+ editorOffset: transientRows.length + aboveWidgets.length + (body?.rowOffset ?? 0),
545
+ inputRows: body?.rowCount ?? input.length,
546
+ };
547
+ }
548
+ #renderDockNotice(width) {
549
+ if (this.#dockNotice === undefined)
550
+ return [];
551
+ // Compatibility: Pi pads its status text by one cell regardless of the output pad setting.
552
+ return ["", ...renderPiShellStatusText(this.#dockNotice, width, PINNED_PI_LAYOUT.outputPad)];
553
+ }
554
+ #dismissDockNotice() {
555
+ if (this.#dockNotice === undefined)
556
+ return;
557
+ this.#dockNotice = undefined;
558
+ this.#invalidateChrome();
559
+ }
560
+ #renderQueued(width) {
561
+ return this.#view.editor.queuedSubmissions.length === 0 ? [] : this.#queued.render(width);
562
+ }
563
+ layoutRoot() {
564
+ const document = layoutPort(width => this.#renderDocument(width), () => this.invalidate());
565
+ const queued = layoutPort(width => this.#view.editor.queuedSubmissions.length === 0 ? [] : this.#queued.render(width), () => this.#queued.invalidate());
566
+ const aboveWidgets = layoutPort(width => this.#renderWidgets("aboveEditor", width), () => this.#invalidateExtensions());
567
+ const status = layoutPort(width => this.#renderStatus(width), () => this.#status.invalidate());
568
+ const editor = layoutPort(width => this.#inputSurface.render(width), () => this.#inputSurface.invalidate(), data => this.#inputSurface.handleInput?.(data));
569
+ const belowWidgets = layoutPort(width => this.#renderWidgets("belowEditor", width), () => this.#invalidateExtensions());
570
+ const footer = layoutPort(width => this.#renderFooter(width), () => (this.#extensionFooter ?? this.#footer).invalidate());
571
+ return {
572
+ type: "stack",
573
+ direction: "vertical",
574
+ children: [
575
+ {
576
+ basis: 0,
577
+ grow: 1,
578
+ shrink: 1,
579
+ minSize: 1,
580
+ node: {
581
+ type: "scroll",
582
+ id: "transcript",
583
+ follow: "end",
584
+ primary: true,
585
+ overscroll: "chain",
586
+ scrollbar: "auto",
587
+ scrollbarTrackStyle: text => piTheme().fg("scrollbarTrack", text),
588
+ scrollbarThumbStyle: text => piTheme().fg("scrollbarThumb", text),
589
+ child: { type: "component", component: document },
590
+ },
591
+ },
592
+ {
593
+ basis: "auto",
594
+ grow: 0,
595
+ shrink: 1,
596
+ minSize: 1,
597
+ node: {
598
+ type: "stack",
599
+ direction: "vertical",
600
+ children: [
601
+ { shrink: 1, minSize: 0, node: { type: "component", component: queued } },
602
+ { shrink: 1, minSize: 0, node: { type: "component", component: status } },
603
+ { shrink: 1, minSize: 0, node: { type: "component", component: aboveWidgets } },
604
+ { shrink: 1, minSize: 3, node: { type: "component", component: editor } },
605
+ { shrink: 1, minSize: 0, node: { type: "component", component: belowWidgets } },
606
+ { shrink: 1, minSize: 1, node: { type: "component", component: footer } },
607
+ ],
608
+ },
609
+ },
610
+ ],
611
+ };
612
+ }
613
+ #renderDocument(width) {
614
+ return this.#renderDocumentLayout(width).rows;
615
+ }
616
+ #renderDocumentLayout(width) {
617
+ // Performance: extension headers may animate independently of transcript revisions, so
618
+ // only the stable built-in document participates in this frame cache.
619
+ const cached = this.#extensionHeader === null ? this.#documentLayouts.get(width) : undefined;
620
+ if (cached !== undefined)
621
+ return cached;
622
+ const diagnostics = this.#view.diagnostics;
623
+ const startupRows = diagnostics
624
+ .filter(diagnostic => diagnostic.code === "engine-startup")
625
+ .flatMap(diagnostic => renderPiShellStartupDiagnostic(diagnostic, width));
626
+ const resourceRows = this.#customViewport ? [] : [...this.resources.render(width)];
627
+ if (resourceRows.at(-1) === "")
628
+ resourceRows.pop();
629
+ const headerRows = this.#extensionHeader !== null
630
+ ? this.#extensionHeader.render(width)
631
+ : this.#customViewport ? [] : this.header.render(width);
632
+ const rows = [
633
+ ...startupRows,
634
+ ...headerRows,
635
+ ...resourceRows,
636
+ ];
637
+ const promptAnchors = [];
638
+ // Rationale: a block that is still streaming re-renders every row it owns, so the frame
639
+ // reports where its rows begin. Damage-aware painting uses that to tell a live block's
640
+ // own reflow apart from a repaint that reaches settled rows.
641
+ let liveTailStartRow;
642
+ for (let index = 0; index < this.#transcriptOrder.length; index += 1) {
643
+ const id = this.#transcriptOrder[index];
644
+ const block = this.#blocksById.get(id);
645
+ if (!this.#thinkingVisible && block?.kind === "thinking")
646
+ continue;
647
+ const promptLike = block !== undefined
648
+ && (block.kind === "user" || this.#customViewport && isPiPromptStyleCompaction(block));
649
+ const blockWidth = this.#customViewport
650
+ && promptLike
651
+ && this.#viewportController.config.scrollbarAppearance !== "hidden"
652
+ && width > 1
653
+ ? width - 1
654
+ : width;
655
+ const blockRows = this.#blockRows(id, block, blockWidth);
656
+ if (promptLike) {
657
+ // Compatibility: the first natural prompt gets one breathing row at the document top.
658
+ // Once scrolling advances, the prompt itself reaches row zero and then
659
+ // becomes sticky there, so the spacer is never pinned with it.
660
+ if (this.#customViewport && index === 0)
661
+ rows.push("");
662
+ else if (index > 0)
663
+ rows.push("");
664
+ }
665
+ const firstRow = rows.length;
666
+ if (liveTailStartRow === undefined && block !== undefined && block.status !== "finalized") {
667
+ liveTailStartRow = firstRow;
668
+ }
669
+ rows.push(...blockRows);
670
+ if (promptLike && blockRows[0] !== undefined) {
671
+ promptAnchors.push({
672
+ id: block.id,
673
+ firstRow,
674
+ lastRow: Math.max(firstRow, rows.length - 1),
675
+ sourceRow: pinnedPromptSourceRow(block, blockRows[0], blockWidth),
676
+ prominentSourceRow: blockRows[0],
677
+ });
678
+ }
679
+ }
680
+ rows.push(...diagnostics
681
+ .filter(diagnostic => diagnostic.code === "package-updates")
682
+ .flatMap(diagnostic => renderPiShellPackageUpdateNotice(diagnostic.message.split("\n").filter(line => line.startsWith("- ")).map(line => line.slice(2)), width)));
683
+ rows.push(...diagnostics
684
+ .filter(diagnostic => diagnostic.code === "changelog-collapsed" || diagnostic.code === "changelog-expanded")
685
+ .flatMap(diagnostic => diagnostic.code === "changelog-collapsed"
686
+ ? createPiShellCollapsedChangelog().render(width)
687
+ : createPiShellChangelog(diagnostic.message).render(width)));
688
+ rows.push(...diagnostics
689
+ .filter(diagnostic => diagnostic.code !== "engine-startup" && diagnostic.code !== "package-updates"
690
+ && diagnostic.code !== "changelog-collapsed" && diagnostic.code !== "changelog-expanded")
691
+ .slice(-3)
692
+ .flatMap(diagnostic => renderPiShellTranscriptBlock({
693
+ id: `diagnostic-${diagnostic.sequence}`,
694
+ kind: diagnostic.severity === "error" ? "error" : "system",
695
+ status: "finalized",
696
+ revision: diagnostic.sequence,
697
+ title: diagnostic.code,
698
+ text: diagnostic.message,
699
+ payload: {},
700
+ }, width, this.#cwd)));
701
+ const layout = { rows: Object.freeze(rows), promptAnchors: Object.freeze(promptAnchors), liveTailStartRow };
702
+ if (this.#extensionHeader === null) {
703
+ this.#documentLayouts.set(width, layout);
704
+ // Performance: the custom viewport commonly probes full width and reserved-rail width.
705
+ while (this.#documentLayouts.size > 2)
706
+ this.#documentLayouts.delete(this.#documentLayouts.keys().next().value);
707
+ }
708
+ return layout;
709
+ }
710
+ // Performance: finalized blocks cache by revision and width; live blocks always render.
711
+ #blockRows(id, block, width) {
712
+ const component = this.#transcript.get(id);
713
+ if (component === undefined)
714
+ return [];
715
+ const render = () => {
716
+ this.#transcriptBlockRenders += 1;
717
+ const rows = component.render(width);
718
+ if (!this.#customViewport || block?.kind === "user")
719
+ return rows;
720
+ return rows.map(row => nativeHyperlinkStyle(row, nativeTranscriptLinkColor));
721
+ };
722
+ if (block === undefined || block.status !== "finalized")
723
+ return render();
724
+ let byWidth = this.#renderedRows.get(id);
725
+ const cached = byWidth?.get(width);
726
+ const presentationRevision = component.presentationRevision ?? 0;
727
+ if (cached?.revision === block.revision && cached.presentationRevision === presentationRevision)
728
+ return cached.rows;
729
+ const rows = render();
730
+ if (byWidth === undefined) {
731
+ byWidth = new Map();
732
+ this.#renderedRows.set(id, byWidth);
733
+ }
734
+ byWidth.set(width, { revision: block.revision, presentationRevision, rows });
735
+ // Invariant: bare A1 probes full width before reserving the overflowing rail column;
736
+ // retain both widths without turning resize history into an unbounded cache.
737
+ while (byWidth.size > 2)
738
+ byWidth.delete(byWidth.keys().next().value);
739
+ return rows;
740
+ }
741
+ transcriptComponent(id) {
742
+ return this.#transcript.get(id);
743
+ }
744
+ exitTranscript(width) {
745
+ const rows = [];
746
+ for (const id of this.#transcriptOrder) {
747
+ const block = this.#blocksById.get(id);
748
+ if (block === undefined || (!this.#thinkingVisible && block.kind === "thinking"))
749
+ continue;
750
+ if (rows.length > 0 && (block.kind === "user" || this.#customViewport && isPiPromptStyleCompaction(block)))
751
+ rows.push("");
752
+ rows.push(...this.#blockRows(id, block, width).map(sanitizeExitTranscriptRow));
753
+ }
754
+ while (rows.at(-1) === "")
755
+ rows.pop();
756
+ return rows.join("\n");
757
+ }
758
+ appendWorkflowStatus(message) {
759
+ // Rationale: bare A1 acknowledges commands in one dock notice above the editor, where the
760
+ // reader's eye already is, instead of a transcript row that opens an empty session at the
761
+ // top-left or sinks into a long feed. The pinned route keeps Pi's chat placement.
762
+ if (this.#customViewport) {
763
+ this.#dockNotice = message;
764
+ this.#invalidateChrome();
765
+ return;
766
+ }
767
+ const previousId = this.#lastWorkflowStatusId;
768
+ if (previousId !== undefined
769
+ && this.#transcriptOrder.at(-1) === previousId
770
+ && this.#workflowStatusAnchors.get(previousId) === this.#view.transcript.length) {
771
+ this.#workflowStatusMessages.set(previousId, message);
772
+ this.#documentLayouts.clear();
773
+ this.invalidate();
774
+ return;
775
+ }
776
+ const id = this.#appendAnchoredWorkflowComponent(width => [
777
+ "",
778
+ ...renderPiShellStatusText(this.#workflowStatusMessages.get(id) ?? message, width),
779
+ ]);
780
+ this.#workflowStatusMessages.set(id, message);
781
+ this.#lastWorkflowStatusId = id;
782
+ }
783
+ appendWorkflowMessage(message) {
784
+ if (message.kind === "status") {
785
+ this.appendWorkflowStatus(message.message);
786
+ return;
787
+ }
788
+ this.#lastWorkflowStatusId = undefined;
789
+ const presentation = { kind: message.kind, message: message.message };
790
+ this.#appendAnchoredWorkflowComponent(width => renderPiShellCommandMessage(presentation, width, this.#outputPad));
791
+ }
792
+ appendWorkflowResult(result) {
793
+ if (result.messages !== undefined) {
794
+ for (const message of result.messages)
795
+ this.appendWorkflowMessage(message);
796
+ return;
797
+ }
798
+ if (result.messageKind === "silent" || (result.outcome === "cancelled" && result.messageKind === undefined))
799
+ return;
800
+ if (result.command === "reload" && result.outcome === "completed") {
801
+ this.appendWorkflowStatus(result.message);
802
+ return;
803
+ }
804
+ if (result.command === "session" && result.outcome === "completed" && result.presentation?.kind === "session-info") {
805
+ this.#lastWorkflowStatusId = undefined;
806
+ const sessionInfo = createPiShellSessionInfo(result.presentation);
807
+ this.#appendAnchoredWorkflowComponent(width => sessionInfo.render(width), () => sessionInfo.dispose?.());
808
+ return;
809
+ }
810
+ if (result.command === "hotkeys" && result.outcome === "completed") {
811
+ this.#lastWorkflowStatusId = undefined;
812
+ const hotkeys = createPiShellHotkeys(this.editor.keybindingConfig(), bindings => this.#extensionRenderers.getShortcuts?.(bindings) ?? [], this.#customViewport ? "a1" : "pi");
813
+ this.#appendAnchoredWorkflowComponent(width => hotkeys.render(width), () => hotkeys.dispose?.());
814
+ return;
815
+ }
816
+ if (result.command === "changelog" && result.outcome === "completed") {
817
+ this.#lastWorkflowStatusId = undefined;
818
+ const changelog = createPiShellChangelog(result.detail ?? "No changelog entries found.");
819
+ this.#appendAnchoredWorkflowComponent(width => changelog.render(width), () => changelog.dispose?.());
820
+ return;
821
+ }
822
+ if (result.outcome === "failed") {
823
+ this.appendWorkflowMessage({
824
+ kind: result.messageKind === "warning" ? "warning" : "error",
825
+ message: result.message,
826
+ });
827
+ return;
828
+ }
829
+ if (result.outcome === "completed" && (result.command === "quit" || result.command === "compact"))
830
+ return;
831
+ if (result.outcome === "completed" && (result.command === "new" || result.command === "name" || result.command === "debug")) {
832
+ this.#lastWorkflowStatusId = undefined;
833
+ const presentation = { kind: result.command, message: result.message, ...(result.detail === undefined ? {} : { detail: result.detail }) };
834
+ this.#appendAnchoredWorkflowComponent(width => renderPiShellCommandMessage(presentation, width, this.#outputPad));
835
+ return;
836
+ }
837
+ if (result.command === "arminsayshi" && result.outcome === "completed") {
838
+ this.#lastWorkflowStatusId = undefined;
839
+ const armin = createPiShellArmin(this.#componentRuntime);
840
+ this.#appendAnchoredWorkflowComponent(width => ["", ...armin.render(width)], () => armin.dispose?.());
841
+ return;
842
+ }
843
+ if (result.command === "dementedelves" && result.outcome === "completed") {
844
+ this.#lastWorkflowStatusId = undefined;
845
+ const announcement = createPiShellEarendilAnnouncement();
846
+ this.#appendAnchoredWorkflowComponent(width => ["", ...announcement.render(width)], () => announcement.dispose?.());
847
+ return;
848
+ }
849
+ // Rationale: pinned 0.85.1 links both share URLs; the workflow result carries the plain URLs.
850
+ const message = result.command === "share" && result.detail
851
+ ? `${linkShareUrl(result.message)}\nGist: ${piShellHyperlink(result.detail)}`
852
+ : result.message;
853
+ this.appendWorkflowStatus(message);
854
+ }
855
+ appendDaxnuts() {
856
+ this.#lastWorkflowStatusId = undefined;
857
+ const daxnuts = createPiShellDaxnuts(this.#componentRuntime);
858
+ this.#appendAnchoredWorkflowComponent(width => ["", ...daxnuts.render(width)], () => daxnuts.dispose?.());
859
+ }
860
+ toggleThinkingVisibility() {
861
+ this.setHideThinkingBlock(this.#thinkingVisible);
862
+ }
863
+ get toolsExpanded() {
864
+ return this.#toolsExpanded;
865
+ }
866
+ setToolsExpanded(expanded) {
867
+ this.#setToolsExpanded(expanded);
868
+ }
869
+ setExtensionWidget(key, component, placement) {
870
+ const previous = this.#extensionWidgets.get(key)?.component;
871
+ if (component === null)
872
+ this.#extensionWidgets.delete(key);
873
+ else
874
+ this.#extensionWidgets.set(key, { component, placement });
875
+ if (previous !== undefined && previous !== component)
876
+ previous.dispose?.();
877
+ this.invalidate();
878
+ }
879
+ setExtensionHeader(component) {
880
+ if (this.#extensionHeader !== component)
881
+ this.#extensionHeader?.dispose?.();
882
+ this.#extensionHeader = component;
883
+ this.#documentLayouts.clear();
884
+ this.invalidate();
885
+ }
886
+ setExtensionFooter(component) {
887
+ if (this.#extensionFooter !== component)
888
+ this.#extensionFooter?.dispose?.();
889
+ this.#extensionFooter = component;
890
+ this.invalidate();
891
+ }
892
+ setExtensionStatus(key, text) {
893
+ if (text === undefined)
894
+ this.#extensionStatuses.delete(key);
895
+ else
896
+ this.#extensionStatuses.set(key, text);
897
+ this.#footer.update(this.#viewWithExtensionStatuses(this.#view));
898
+ this.invalidate();
899
+ }
900
+ setExtensionWorking(message, visible = this.#extensionWorkingVisible) {
901
+ this.#extensionWorkingMessage = message;
902
+ this.#extensionWorkingVisible = visible;
903
+ this.#status.setWorkingOverride(visible ? message : undefined);
904
+ this.invalidate();
905
+ }
906
+ resetWorkflowPresentation() {
907
+ this.#dockNotice = undefined;
908
+ for (const id of this.#workflowStatusAnchors.keys()) {
909
+ this.#transcript.get(id)?.dispose?.();
910
+ this.#transcript.delete(id);
911
+ }
912
+ this.#workflowStatusAnchors.clear();
913
+ this.#workflowStatusMessages.clear();
914
+ this.#transcriptOrder = this.#transcriptOrder.filter(id => !id.startsWith("workflow-status-"));
915
+ this.#lastWorkflowStatusId = undefined;
916
+ this.#documentLayouts.clear();
917
+ this.invalidate();
918
+ }
919
+ resetExtensionUi() {
920
+ this.#extensionHeader?.dispose?.();
921
+ this.#extensionFooter?.dispose?.();
922
+ for (const { component } of this.#extensionWidgets.values())
923
+ component.dispose?.();
924
+ this.#extensionHeader = null;
925
+ this.#extensionFooter = null;
926
+ this.#extensionWidgets.clear();
927
+ this.#extensionStatuses.clear();
928
+ this.#extensionWorkingMessage = undefined;
929
+ this.#status.setWorkingOverride(undefined);
930
+ this.#footer.update(this.#viewWithExtensionStatuses(this.#view));
931
+ // Invariant: an extension renderer may have drawn transcript blocks that are now unrendered by it.
932
+ this.#renderedRows.clear();
933
+ this.#documentLayouts.clear();
934
+ this.invalidate();
935
+ }
936
+ addExtensionNotification(message, type) {
937
+ if (type === "info") {
938
+ this.appendWorkflowStatus(message);
939
+ return;
940
+ }
941
+ this.appendWorkflowMessage({ kind: type, message });
942
+ }
943
+ extensionFooterData() {
944
+ return {
945
+ getGitBranch: () => this.#view.status.footer?.branch ?? null,
946
+ getExtensionStatuses: () => new Map(this.#extensionStatuses),
947
+ getAvailableProviderCount: () => this.#view.status.footer?.availableProviderCount ?? 1,
948
+ onBranchChange: () => () => { },
949
+ };
950
+ }
951
+ usesDefaultInputSurface() {
952
+ return this.#inputSurface === this.editor;
953
+ }
954
+ inputCoordinationSurface() {
955
+ return this.#inputSurfaceCoordination;
956
+ }
957
+ viewportCompositionEvidence() {
958
+ return { full: this.#fullViewportCompositions, dockOnly: this.#dockOnlyViewportCompositions };
959
+ }
960
+ transcriptRenderCount() {
961
+ return this.#transcriptBlockRenders;
962
+ }
963
+ setInputSurface(component, disposePrevious = true, coordination = "owned") {
964
+ const next = component ?? this.editor;
965
+ const nextCoordination = next === this.editor ? "editor" : coordination;
966
+ if (next === this.#inputSurface) {
967
+ this.#inputSurfaceCoordination = nextCoordination;
968
+ return;
969
+ }
970
+ this.#dockInputCandidate = false;
971
+ this.#viewportController.invalidateInputSurface();
972
+ this.#inputSurface.setFocused?.(false);
973
+ if (disposePrevious && this.#inputSurface !== this.editor)
974
+ this.#inputSurface.dispose?.();
975
+ this.#inputSurface = next;
976
+ this.#inputSurfaceCoordination = nextCoordination;
977
+ this.#onInputSurfaceChanged?.();
978
+ this.#inputSurface.setFocused?.(true);
979
+ this.invalidate();
980
+ }
981
+ handleInput(data) {
982
+ this.#dockInputCandidate = this.#customViewport && this.#dockInputReuseEnabled
983
+ && classifyPiTuiInput(data, this.#inputSurfaceCoordination) === "safe";
984
+ this.#dockInputRevision = this.#dockInputCandidate ? this.#viewportController.presentationRevision : undefined;
985
+ try {
986
+ this.#inputSurface.handleInput?.(data);
987
+ }
988
+ catch (error) {
989
+ this.#dockInputCandidate = false;
990
+ throw error;
991
+ }
992
+ }
993
+ invalidate() {
994
+ this.#renderedRows.clear();
995
+ this.#documentLayouts.clear();
996
+ for (const component of this.#transcript.values())
997
+ component.invalidate();
998
+ this.#invalidateChrome();
999
+ }
1000
+ #invalidateChrome() {
1001
+ this.header.invalidate();
1002
+ this.resources.invalidate();
1003
+ this.editor.invalidate();
1004
+ if (this.#inputSurface !== this.editor)
1005
+ this.#inputSurface.invalidate();
1006
+ this.#invalidateExtensions();
1007
+ this.#status.invalidate();
1008
+ this.#footer.invalidate();
1009
+ this.#queued.invalidate();
1010
+ }
1011
+ setFocused(focused) {
1012
+ this.#inputSurface.setFocused?.(focused);
1013
+ }
1014
+ dispose() {
1015
+ this.clearViewportPointerState();
1016
+ this.#themeUnsubscribe();
1017
+ this.header.dispose?.();
1018
+ this.resources.dispose?.();
1019
+ for (const component of this.#transcript.values())
1020
+ component.dispose?.();
1021
+ this.#transcript.clear();
1022
+ this.#renderedRows.clear();
1023
+ this.#documentLayouts.clear();
1024
+ this.#visibleViewportSnapshot = undefined;
1025
+ this.#dockInputCandidate = false;
1026
+ this.#dockInputRevision = undefined;
1027
+ if (this.#inputSurface !== this.editor)
1028
+ this.#inputSurface.dispose?.();
1029
+ this.#extensionHeader?.dispose?.();
1030
+ this.#extensionFooter?.dispose?.();
1031
+ for (const { component } of this.#extensionWidgets.values())
1032
+ component.dispose?.();
1033
+ this.#extensionWidgets.clear();
1034
+ this.editor.dispose?.();
1035
+ this.#status.dispose?.();
1036
+ this.#footer.dispose?.();
1037
+ this.#queued.dispose?.();
1038
+ }
1039
+ #invalidateTranscriptPresentation() {
1040
+ this.#renderedRows.clear();
1041
+ this.#documentLayouts.clear();
1042
+ this.invalidate();
1043
+ }
1044
+ #syncTranscript(blocks) {
1045
+ const previousIds = this.#transcriptOrder.filter(id => !id.startsWith("workflow-status-"));
1046
+ const transcriptChanged = previousIds.length !== blocks.length || blocks.some((block, index) => {
1047
+ const previous = this.#blocksById.get(block.id);
1048
+ return previousIds[index] !== block.id || previous?.revision !== block.revision;
1049
+ });
1050
+ if (transcriptChanged)
1051
+ this.#documentLayouts.clear();
1052
+ this.#blocksById.clear();
1053
+ for (const block of blocks)
1054
+ this.#blocksById.set(block.id, block);
1055
+ const nextIds = new Set(blocks.map(block => block.id));
1056
+ for (const [id, component] of this.#transcript) {
1057
+ if (id.startsWith("workflow-status-") || nextIds.has(id))
1058
+ continue;
1059
+ component.dispose?.();
1060
+ this.#transcript.delete(id);
1061
+ this.#renderedRows.delete(id);
1062
+ }
1063
+ for (const block of blocks) {
1064
+ const component = this.#transcript.get(block.id);
1065
+ if (component === undefined) {
1066
+ const created = this.#mountTranscript(block);
1067
+ this.#transcript.set(block.id, created);
1068
+ }
1069
+ else if (component.revision !== block.revision) {
1070
+ component.update(block);
1071
+ }
1072
+ }
1073
+ const statusIds = [...this.#workflowStatusAnchors.keys()];
1074
+ const order = [];
1075
+ for (let index = 0; index <= blocks.length; index += 1) {
1076
+ for (const statusId of statusIds) {
1077
+ if (this.#workflowStatusAnchors.get(statusId) === index)
1078
+ order.push(statusId);
1079
+ }
1080
+ const block = blocks[index];
1081
+ if (block !== undefined)
1082
+ order.push(block.id);
1083
+ }
1084
+ const placed = new Set(order);
1085
+ for (const statusId of statusIds) {
1086
+ if (!placed.has(statusId))
1087
+ order.push(statusId);
1088
+ }
1089
+ this.#transcriptOrder = order;
1090
+ }
1091
+ #appendAnchoredWorkflowComponent(render, dispose) {
1092
+ // Invariant: transcript-bound workflow output supersedes a pending acknowledgement.
1093
+ this.#dismissDockNotice();
1094
+ this.#workflowTranscriptSequence += 1;
1095
+ const id = `workflow-status-${this.#workflowTranscriptSequence}`;
1096
+ const component = {
1097
+ id,
1098
+ revision: 1,
1099
+ render,
1100
+ handleInput() { },
1101
+ invalidate() { },
1102
+ update() { },
1103
+ setExpanded() { },
1104
+ setOutputPad() { },
1105
+ setHideThinkingBlock() { },
1106
+ setMermaidRenderingMode() { },
1107
+ setImagePresentation() { },
1108
+ ...(dispose === undefined ? {} : { dispose }),
1109
+ };
1110
+ this.#transcript.set(id, component);
1111
+ this.#workflowStatusAnchors.set(id, this.#view.transcript.length);
1112
+ this.#transcriptOrder.push(id);
1113
+ this.#documentLayouts.clear();
1114
+ this.invalidate();
1115
+ return id;
1116
+ }
1117
+ #renderWidgets(placement, width) {
1118
+ const rows = [...this.#extensionWidgets.values()]
1119
+ .filter(widget => widget.placement === placement)
1120
+ .flatMap(widget => widget.component.render(width));
1121
+ return placement === "aboveEditor" ? ["", ...rows] : rows;
1122
+ }
1123
+ #renderStatus(width) {
1124
+ return this.#customViewport ? this.#status.renderLive(width) : this.#status.render(width);
1125
+ }
1126
+ #renderFooter(width) {
1127
+ return (this.#extensionFooter ?? this.#footer).render(width);
1128
+ }
1129
+ #viewWithExtensionStatuses(view) {
1130
+ const footer = view.status.footer;
1131
+ const statuses = new Map(footer?.extensionStatuses ?? []);
1132
+ for (const [key, text] of this.#extensionStatuses)
1133
+ statuses.set(key, text);
1134
+ return {
1135
+ ...view,
1136
+ status: {
1137
+ ...view.status,
1138
+ footer: {
1139
+ branch: footer?.branch ?? null,
1140
+ sessionName: footer?.sessionName ?? null,
1141
+ availableProviderCount: footer?.availableProviderCount ?? 1,
1142
+ extensionStatuses: [...statuses],
1143
+ },
1144
+ },
1145
+ };
1146
+ }
1147
+ #invalidateExtensions() {
1148
+ this.#extensionHeader?.invalidate();
1149
+ this.#extensionFooter?.invalidate();
1150
+ for (const { component } of this.#extensionWidgets.values())
1151
+ component.invalidate();
1152
+ }
1153
+ #setToolsExpanded(expanded) {
1154
+ this.#toolsExpanded = expanded;
1155
+ this.header.setExpanded(expanded);
1156
+ this.resources.setExpanded(expanded);
1157
+ for (const component of this.#transcript.values())
1158
+ component.setExpanded(expanded);
1159
+ // Invariant: expansion changes what a block draws without changing its revision.
1160
+ this.#renderedRows.clear();
1161
+ this.#documentLayouts.clear();
1162
+ this.invalidate();
1163
+ }
1164
+ }
1165
+ const SCROLLBAR_CELL_RESET = "\u001b[22;23;24;25;27;28;29;39;54;55m";
1166
+ const KITTY_IMAGE_CONTROL = /\u001b_G[\s\S]*?\u001b\\/g;
1167
+ const ITERM_IMAGE_CONTROL = /\u001b]1337;File=[^\u0007]*(?:\u0007|\u001b\\)/g;
1168
+ /** Keep semantic SGR/OSC styling while excluding non-replayable image payloads. */
1169
+ function sanitizeExitTranscriptRow(row) {
1170
+ return row.replace(KITTY_IMAGE_CONTROL, "").replace(ITERM_IMAGE_CONTROL, "");
1171
+ }
1172
+ const TERMINAL_BACKGROUND = /\u001b\[(?:4[0-9]|10[0-7]|48(?:[;:][0-9;:]*)?)m/g;
1173
+ /** Web URLs use link blue; file targets retain A1's cyan interactive accent. */
1174
+ function nativeTranscriptLinkColor(text, target) {
1175
+ return piTheme().fg(/^file:/iu.test(target) ? "accent" : "mdLink", text);
1176
+ }
1177
+ /** Repaint a source prompt with viewport chrome while preserving text, links, and foreground roles. */
1178
+ function withoutTerminalBackground(text) {
1179
+ return text.replace(TERMINAL_BACKGROUND, "");
1180
+ }
1181
+ /** Preserve the stable metadata-grey foreground for every pinned timestamp state. */
1182
+ function pinnedPromptSourceRow(block, sourceRow, width) {
1183
+ if (typeof block.payload !== "object" || block.payload === null)
1184
+ return sourceRow;
1185
+ const value = block.payload.timestamp;
1186
+ if (typeof value !== "number" || !Number.isFinite(value))
1187
+ return sourceRow;
1188
+ const timestamp = formatSubmittedPromptTime(value);
1189
+ if (timestamp === null || submittedPromptLayout(width, value).timestamp === null)
1190
+ return sourceRow;
1191
+ const rowWidth = displayWidth(sourceRow);
1192
+ const timestampWidth = displayWidth(timestamp);
1193
+ if (rowWidth < timestampWidth)
1194
+ return sourceRow;
1195
+ return overlaySpan(sourceRow, rowWidth - timestampWidth, rowWidth, paintPiSubmittedPromptTimestamp(timestamp));
1196
+ }
1197
+ function layoutPort(render, invalidate, handleInput) {
1198
+ return {
1199
+ render,
1200
+ invalidate,
1201
+ ...(handleInput === undefined ? {} : { handleInput }),
1202
+ };
1203
+ }
1204
+ export function shellResourceEntries(backend) {
1205
+ const resources = backend.nonVisualResources().map(resource => ({
1206
+ section: resource.kind === "skill"
1207
+ ? "Skills"
1208
+ : resource.kind === "prompt-template"
1209
+ ? "Prompts"
1210
+ : resource.kind === "theme"
1211
+ ? "Themes"
1212
+ : "Context",
1213
+ label: resource.kind === "prompt-template"
1214
+ ? `/${resource.label}`
1215
+ : resource.kind === "agent-context" || resource.kind === "system-prompt"
1216
+ ? compactResourceLabel(resource.sourcePath ?? resource.label)
1217
+ : resource.label,
1218
+ sourcePath: resource.sourcePath,
1219
+ diagnostic: resource.diagnostic,
1220
+ }));
1221
+ const extensions = backend.extensionResources().filter(extension => !extension.hidden);
1222
+ const loadedExtensions = extensions.filter(extension => extension.diagnostic === null);
1223
+ const extensionLabels = compactExtensionLabels(loadedExtensions);
1224
+ for (const extension of extensions) {
1225
+ const labelIndex = loadedExtensions.indexOf(extension);
1226
+ resources.push({
1227
+ section: "Extensions",
1228
+ label: extensionLabels[labelIndex] ?? compactResourceLabel(extension.sourcePath ?? extension.resolvedPath ?? "extension"),
1229
+ sourcePath: extension.sourcePath ?? extension.resolvedPath,
1230
+ diagnostic: extension.diagnostic,
1231
+ });
1232
+ }
1233
+ return resources;
1234
+ }
1235
+ function compactResourceLabel(path) {
1236
+ const segments = compactPathSegments(path);
1237
+ const leaf = segments.at(-1) ?? path;
1238
+ if ((leaf === "index.ts" || leaf === "index.js") && segments.length > 1)
1239
+ return segments.at(-2) ?? leaf;
1240
+ return leaf;
1241
+ }
1242
+ /**
1243
+ * Pinned from InteractiveMode's compact extension-label helpers at Pi commit
1244
+ * 914cf1472e715297caa30db4b9535d534a9eb718. The source metadata crosses an
1245
+ * A1-owned boundary first; the owned shell never inspects Pi's private root.
1246
+ */
1247
+ function compactExtensionLabels(extensions) {
1248
+ const localExtensions = extensions
1249
+ .filter(extension => !isPackageExtensionSource(extension.sourceInfo))
1250
+ .map(extension => {
1251
+ const path = extension.sourcePath ?? extension.resolvedPath ?? "extension";
1252
+ const segments = compactPathSegments(path);
1253
+ if (segments.length > 1 && (segments.at(-1) === "index.ts" || segments.at(-1) === "index.js"))
1254
+ segments.pop();
1255
+ return { extension, segments };
1256
+ });
1257
+ return extensions.map(extension => {
1258
+ const resourcePath = extension.sourcePath ?? extension.resolvedPath ?? "extension";
1259
+ if (isPackageExtensionSource(extension.sourceInfo)) {
1260
+ return compactPackageExtensionLabel(resourcePath, extension.sourceInfo);
1261
+ }
1262
+ const localIndex = localExtensions.findIndex(item => item.extension === extension);
1263
+ const segments = localExtensions[localIndex]?.segments;
1264
+ if (!segments || segments.length === 0)
1265
+ return compactResourceLabel(resourcePath);
1266
+ for (let count = 1; count <= segments.length; count += 1) {
1267
+ const candidate = segments.slice(-count).join("/");
1268
+ if (localExtensions.every((item, itemIndex) => itemIndex === localIndex || item.segments.slice(-count).join("/") !== candidate)) {
1269
+ return candidate;
1270
+ }
1271
+ }
1272
+ return segments.join("/");
1273
+ });
1274
+ }
1275
+ function compactPackageExtensionLabel(resourcePath, sourceInfo) {
1276
+ const sourceLabel = compactPackageSourceLabel(sourceInfo.source);
1277
+ if (!sourceLabel)
1278
+ return compactResourceLabel(resourcePath);
1279
+ const shortPath = shortPackagePath(resourcePath, sourceInfo).replaceAll("\\", "/");
1280
+ const packagePath = shortPath.startsWith("extensions/") ? shortPath.slice("extensions/".length) : shortPath;
1281
+ const slash = packagePath.lastIndexOf("/");
1282
+ const fileName = slash < 0 ? packagePath : packagePath.slice(slash + 1);
1283
+ const directory = slash < 0 ? "" : packagePath.slice(0, slash);
1284
+ const extension = fileName.lastIndexOf(".");
1285
+ const name = extension <= 0 ? fileName : fileName.slice(0, extension);
1286
+ if (name === "index")
1287
+ return !directory || directory === "." ? sourceLabel : `${sourceLabel}:${directory}`;
1288
+ return `${sourceLabel}:${packagePath}`;
1289
+ }
1290
+ function compactPackageSourceLabel(source) {
1291
+ if (source.startsWith("npm:"))
1292
+ return source.slice("npm:".length) || source;
1293
+ if (!source.startsWith("git:"))
1294
+ return source;
1295
+ const gitSource = source.slice("git:".length).trim();
1296
+ let repositoryPath;
1297
+ const scpLike = gitSource.match(/^git@[^:]+:(.+)$/);
1298
+ if (scpLike?.[1]) {
1299
+ repositoryPath = scpLike[1];
1300
+ }
1301
+ else if (/^[a-z]+:\/\//i.test(gitSource)) {
1302
+ try {
1303
+ repositoryPath = new URL(gitSource).pathname.replace(/^\/+/, "");
1304
+ }
1305
+ catch {
1306
+ return source;
1307
+ }
1308
+ }
1309
+ else {
1310
+ const slash = gitSource.indexOf("/");
1311
+ if (slash >= 0)
1312
+ repositoryPath = gitSource.slice(slash + 1);
1313
+ }
1314
+ if (!repositoryPath)
1315
+ return source;
1316
+ const ref = repositoryPath.indexOf("@");
1317
+ const withoutRef = ref < 0 ? repositoryPath : repositoryPath.slice(0, ref);
1318
+ return withoutRef.replace(/\.git$/, "") || source;
1319
+ }
1320
+ function shortPackagePath(resourcePath, sourceInfo) {
1321
+ const fullPath = normalizeResourcePath(resourcePath);
1322
+ const baseDir = sourceInfo.baseDir === null ? undefined : normalizeResourcePath(sourceInfo.baseDir).replace(/\/$/, "");
1323
+ if (baseDir) {
1324
+ const npmRoot = baseDir.match(/^(.*\/node_modules)\/(@?[^/]+(?:\/[^/]+)?)$/);
1325
+ if (npmRoot?.[1] && fullPath.startsWith(`${npmRoot[1]}/`))
1326
+ return relativeResourcePath(baseDir, fullPath);
1327
+ if (fullPath === baseDir)
1328
+ return ".";
1329
+ if (fullPath.startsWith(`${baseDir}/`))
1330
+ return fullPath.slice(baseDir.length + 1);
1331
+ }
1332
+ const npmMatch = fullPath.match(/node_modules\/(@?[^/]+(?:\/[^/]+)?)\/(.*)/);
1333
+ if (npmMatch?.[2] && sourceInfo.source.startsWith("npm:"))
1334
+ return npmMatch[2];
1335
+ const gitMatch = fullPath.match(/git\/[^/]+\/[^/]+\/(.*)/);
1336
+ if (gitMatch?.[1] && sourceInfo.source.startsWith("git:"))
1337
+ return gitMatch[1];
1338
+ return resourcePath;
1339
+ }
1340
+ function relativeResourcePath(from, to) {
1341
+ const fromSegments = from.split("/").filter(Boolean);
1342
+ const toSegments = to.split("/").filter(Boolean);
1343
+ let common = 0;
1344
+ while (common < fromSegments.length && common < toSegments.length
1345
+ && fromSegments[common]?.toLowerCase() === toSegments[common]?.toLowerCase())
1346
+ common += 1;
1347
+ return [...fromSegments.slice(common).map(() => ".."), ...toSegments.slice(common)].join("/") || ".";
1348
+ }
1349
+ function compactPathSegments(path) {
1350
+ return normalizeResourcePath(path).split("/").filter(segment => segment.length > 0 && segment !== "~");
1351
+ }
1352
+ function normalizeResourcePath(path) {
1353
+ return path.replaceAll("\\", "/");
1354
+ }
1355
+ function isPackageExtensionSource(sourceInfo) {
1356
+ const source = sourceInfo?.source ?? "";
1357
+ return source.startsWith("npm:") || source.startsWith("git:");
1358
+ }
1359
+ function transientRowsSignature(steeringRows, statusRows) {
1360
+ return `${steeringRows.length}\u0000${steeringRows.join("\u0000")}\u0001${statusRows.length}\u0000${statusRows.join("\u0000")}`;
1361
+ }
1362
+ /** "Share URL: <url>" with the URL made clickable; other share wordings pass through unchanged. */
1363
+ function linkShareUrl(message) {
1364
+ const match = /^Share URL: (\S+)$/.exec(message);
1365
+ return match === null ? message : `Share URL: ${piShellHyperlink(match[1])}`;
1366
+ }