@timurproko/a1 0.1.8-dev.3b54f21 → 0.1.8-dev.407

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