@timurproko/a1 0.1.8-dev.21b95d6 → 0.1.8-dev.224

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 (461) hide show
  1. package/README.md +107 -67
  2. package/bin/cli.js +28 -10
  3. package/bin/guardian.js +4 -1
  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 +1 -1
  9. package/bin/sync-pi-tui-proxy.js +97 -0
  10. package/bin/ui.js +25 -6
  11. package/bin/warmup.js +18 -0
  12. package/dist/cli/capabilities.d.ts +6 -0
  13. package/dist/{src/cli → cli}/capabilities.js +1 -1
  14. package/dist/{src/cli → cli}/dispatch.d.ts +6 -0
  15. package/dist/cli/dispatch.js +202 -0
  16. package/dist/{src/cli → cli}/packages.d.ts +10 -2
  17. package/dist/{src/cli → cli}/packages.js +24 -20
  18. package/dist/{src/cli → cli}/version-stats.d.ts +6 -0
  19. package/dist/cli/version-stats.js +112 -0
  20. package/dist/composition/agent-engine-bridge.d.ts +3 -0
  21. package/dist/composition/agent-engine-bridge.js +108 -0
  22. package/dist/composition/index.d.ts +3 -0
  23. package/dist/composition/index.js +3 -0
  24. package/dist/composition/owned-ui.d.ts +28 -0
  25. package/dist/composition/owned-ui.js +64 -0
  26. package/dist/composition/process.d.ts +16 -0
  27. package/dist/composition/process.js +45 -0
  28. package/dist/composition/settings-route-host.d.ts +8 -0
  29. package/dist/composition/settings-route-host.js +75 -0
  30. package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/capability-ports.d.ts +2 -2
  31. package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain-validation.js +22 -4
  32. package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain.d.ts +17 -0
  33. package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/model.d.ts +36 -0
  34. package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/validation.js +25 -0
  35. package/dist/{src/features → features}/launch/development-launch.js +11 -3
  36. package/dist/{src/features → features}/launch/index.d.ts +0 -1
  37. package/dist/{src/features → features}/launch/index.js +0 -1
  38. package/dist/{src/features → features}/launch/intent.d.ts +3 -2
  39. package/dist/features/launch/intent.js +3 -0
  40. package/dist/{src/features → features}/launch/prepare-launch.d.ts +0 -2
  41. package/dist/{src/features → features}/launch/prepare-launch.js +2 -9
  42. package/dist/{src/features → features}/launch/profile-paths.d.ts +1 -2
  43. package/dist/{src/features → features}/launch/profile-paths.js +2 -8
  44. package/dist/{src/features → features}/launch/runtime-selection.d.ts +2 -5
  45. package/dist/{src/features → features}/owned-ui/customization.d.ts +3 -1
  46. package/dist/{src/features → features}/owned-ui/customization.js +3 -1
  47. package/dist/{src/features → features}/owned-ui/diagnostics.d.ts +2 -1
  48. package/dist/{src/features → features}/owned-ui/diagnostics.js +1 -0
  49. package/dist/{src/features → features}/owned-ui/index.d.ts +1 -0
  50. package/dist/{src/features → features}/owned-ui/index.js +1 -0
  51. package/dist/features/owned-ui/project-trust-prompt.d.ts +25 -0
  52. package/dist/features/owned-ui/project-trust-prompt.js +149 -0
  53. package/dist/{src/features → features}/owned-ui/run.d.ts +2 -2
  54. package/dist/{src/features → features}/owned-ui/run.js +2 -0
  55. package/dist/{src/features → features}/owned-ui/settings-app.d.ts +3 -3
  56. package/dist/{src/features → features}/owned-ui/settings-app.js +103 -54
  57. package/dist/{src/features → features}/workspace/capabilities.d.ts +1 -1
  58. package/dist/{src/features → features}/workspace/reducer.d.ts +2 -1
  59. package/dist/{src/features → features}/workspace/reducer.js +2 -1
  60. package/dist/{src/features → features}/workspace/router.d.ts +2 -1
  61. package/dist/{src/features → features}/workspace/router.js +1 -0
  62. package/dist/{src/features → features}/workspace/store.d.ts +2 -1
  63. package/dist/{src/features → features}/workspace/store.js +1 -0
  64. package/dist/{src/foundation → foundation}/launch-guardian/main.js +10 -2
  65. package/dist/{src/foundation → foundation}/lifecycle/model.d.ts +1 -1
  66. package/dist/{src/foundation → foundation}/lifecycle/model.js +1 -1
  67. package/dist/foundation/lifecycle/paths.d.ts +28 -0
  68. package/dist/{src/foundation → foundation}/lifecycle/paths.js +21 -0
  69. package/dist/{src/foundation → foundation}/native-host-protocol/codec.d.ts +2 -0
  70. package/dist/{src/foundation → foundation}/native-host-protocol/codec.js +2 -0
  71. package/dist/{src/foundation → foundation}/native-host-protocol/messages.d.ts +1 -1
  72. package/dist/{src/foundation → foundation}/native-host-protocol/messages.js +1 -1
  73. package/dist/{src/foundation → foundation}/process-containment/linux-process-inspector.d.ts +1 -0
  74. package/dist/{src/foundation → foundation}/process-containment/linux-process-inspector.js +1 -0
  75. package/dist/{src/foundation → foundation}/process-containment/native-guardian-containment.d.ts +1 -0
  76. package/dist/{src/foundation → foundation}/process-containment/native-guardian-containment.js +1 -0
  77. package/dist/{src/foundation → foundation}/process-containment/windows-process-inspector.d.ts +1 -0
  78. package/dist/{src/foundation → foundation}/process-containment/windows-process-inspector.js +1 -0
  79. package/dist/{src/foundation → foundation}/protocol/client.d.ts +1 -0
  80. package/dist/{src/foundation → foundation}/protocol/client.js +1 -0
  81. package/dist/{src/foundation → foundation}/protocol/messages.d.ts +1 -0
  82. package/dist/{src/foundation → foundation}/protocol/messages.js +1 -0
  83. package/dist/{src/foundation → foundation}/release/bootstrap.d.ts +14 -4
  84. package/dist/{src/foundation → foundation}/release/bootstrap.js +66 -13
  85. package/dist/foundation/release/cohort-state.d.ts +131 -0
  86. package/dist/foundation/release/cohort-state.js +384 -0
  87. package/dist/foundation/release/dependency-layer.d.ts +78 -0
  88. package/dist/foundation/release/dependency-layer.js +487 -0
  89. package/dist/foundation/release/endpoints.d.ts +20 -0
  90. package/dist/foundation/release/endpoints.js +50 -0
  91. package/dist/{src/foundation → foundation}/release/index.d.ts +3 -0
  92. package/dist/{src/foundation → foundation}/release/index.js +3 -0
  93. package/dist/foundation/release/release-gc.d.ts +60 -0
  94. package/dist/foundation/release/release-gc.js +538 -0
  95. package/dist/{src/foundation → foundation}/release/release-store.d.ts +3 -1
  96. package/dist/{src/foundation → foundation}/release/release-store.js +60 -10
  97. package/dist/{src/foundation → foundation}/release/release.d.ts +4 -1
  98. package/dist/{src/foundation → foundation}/release/release.js +10 -3
  99. package/dist/{src/foundation → foundation}/release/update-transaction.d.ts +1 -0
  100. package/dist/{src/foundation → foundation}/release/update-transaction.js +1 -0
  101. package/dist/{src/foundation → foundation}/release/update.d.ts +19 -3
  102. package/dist/{src/foundation → foundation}/release/update.js +114 -54
  103. package/dist/foundation/release/warmup.d.ts +3 -0
  104. package/dist/foundation/release/warmup.js +35 -0
  105. package/dist/foundation/startup/index.d.ts +1 -0
  106. package/dist/foundation/startup/index.js +1 -0
  107. package/dist/foundation/startup/startup-runtime.d.ts +36 -0
  108. package/dist/foundation/startup/startup-runtime.js +140 -0
  109. package/dist/{src/foundation → foundation}/storage/control-store.d.ts +2 -1
  110. package/dist/{src/foundation → foundation}/storage/control-store.js +39 -4
  111. package/dist/{src/foundation → foundation}/structured-agent-runtime/backpressure.d.ts +2 -1
  112. package/dist/{src/foundation → foundation}/structured-agent-runtime/backpressure.js +2 -1
  113. package/dist/{src/foundation → foundation}/structured-agent-runtime/commands.d.ts +2 -1
  114. package/dist/{src/foundation → foundation}/structured-agent-runtime/commands.js +2 -1
  115. package/dist/{src/foundation → foundation}/structured-agent-runtime/handshake.d.ts +1 -1
  116. package/dist/{src/foundation → foundation}/structured-agent-runtime/handshake.js +1 -1
  117. package/dist/{src/foundation → foundation}/structured-agent-runtime/reconnection.d.ts +2 -1
  118. package/dist/{src/foundation → foundation}/structured-agent-runtime/reconnection.js +2 -1
  119. package/dist/{src/foundation → foundation}/structured-agent-runtime/state.d.ts +2 -1
  120. package/dist/{src/foundation → foundation}/structured-agent-runtime/state.js +2 -1
  121. package/dist/foundation/supervision/index.d.ts +3 -0
  122. package/dist/foundation/supervision/index.js +3 -0
  123. package/dist/{src/foundation → foundation}/supervision/main.js +11 -5
  124. package/dist/foundation/supervision/paths.d.ts +1 -0
  125. package/dist/foundation/supervision/paths.js +1 -0
  126. package/dist/{src/foundation → foundation}/supervision/server.d.ts +19 -1
  127. package/dist/{src/foundation → foundation}/supervision/server.js +51 -2
  128. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/components.d.ts +1 -1
  129. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/conformance.d.ts +1 -0
  130. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/conformance.js +3 -2
  131. package/dist/integrations/pi/components/owned-editor-ux.d.ts +55 -0
  132. package/dist/integrations/pi/components/owned-editor-ux.js +778 -0
  133. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-components.d.ts +1 -0
  134. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-components.js +1 -0
  135. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-editor-autocomplete.js +54 -6
  136. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-extension-ui.d.ts +1 -1
  137. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-footer-status.d.ts +3 -3
  138. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-footer-status.js +32 -17
  139. package/dist/integrations/pi/components/shell-presenters-info.d.ts +36 -0
  140. package/dist/integrations/pi/components/shell-presenters-info.js +78 -0
  141. package/dist/integrations/pi/components/shell-presenters-transcript.d.ts +25 -0
  142. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-presenters-transcript.js +92 -131
  143. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-selectors-dialogs.d.ts +1 -1
  144. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-shared-facade.d.ts +52 -8
  145. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-shared-facade.js +4 -2
  146. package/dist/integrations/pi/components/submitted-prompt-adapter.d.ts +13 -0
  147. package/dist/integrations/pi/components/submitted-prompt-adapter.js +27 -0
  148. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/adjacent/core/keybindings.d.ts +10 -2
  149. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/adjacent/core/keybindings.js +36 -3
  150. package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-footer.d.ts +1 -1
  151. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/adapter.d.ts +22 -4
  152. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/adapter.js +289 -68
  153. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/conformance.d.ts +2 -0
  154. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/conformance.js +4 -2
  155. package/dist/integrations/pi/engine/http-dispatcher.d.ts +4 -0
  156. package/dist/integrations/pi/engine/http-dispatcher.js +25 -0
  157. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/index.d.ts +3 -0
  158. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/index.js +3 -0
  159. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/model-auth-integration.d.ts +2 -1
  160. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/model-auth-integration.js +1 -0
  161. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/package-integration.d.ts +1 -1
  162. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/package-integration.js +2 -2
  163. package/dist/integrations/pi/engine/project-trust-preflight.d.ts +22 -0
  164. package/dist/integrations/pi/engine/project-trust-preflight.js +50 -0
  165. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/resource-extension-integration.d.ts +2 -1
  166. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/resource-extension-integration.js +1 -0
  167. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/runtime-integration.d.ts +16 -1
  168. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/runtime-integration.js +39 -4
  169. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/session-integration.d.ts +4 -2
  170. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/session-integration.js +19 -4
  171. package/dist/integrations/pi/engine/settings-effects.d.ts +66 -0
  172. package/dist/integrations/pi/engine/settings-effects.js +249 -0
  173. package/dist/integrations/pi/engine/settings-integration.d.ts +43 -0
  174. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/settings-integration.js +102 -108
  175. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/workflow-controllers.d.ts +3 -2
  176. package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/workflow-controllers.js +1 -0
  177. package/dist/integrations/pi/session-ui/clipboard-image.d.ts +11 -0
  178. package/dist/integrations/pi/session-ui/clipboard-image.js +29 -0
  179. package/dist/{src/foundation/pi-owned-ui-integration → integrations/pi/session-ui}/index.d.ts +1 -0
  180. package/dist/{src/foundation/pi-owned-ui-integration → integrations/pi/session-ui}/index.js +1 -0
  181. package/dist/integrations/pi/session-ui/prompt-chips.d.ts +23 -0
  182. package/dist/integrations/pi/session-ui/prompt-chips.js +246 -0
  183. package/dist/integrations/pi/session-ui/route-host.d.ts +5 -0
  184. package/dist/integrations/pi/session-ui/session-shell-root.d.ts +137 -0
  185. package/dist/integrations/pi/session-ui/session-shell-root.js +1106 -0
  186. package/dist/integrations/pi/session-ui/session-shell.d.ts +55 -0
  187. package/dist/{src/foundation/pi-owned-ui-integration → integrations/pi/session-ui}/session-shell.js +415 -775
  188. package/dist/integrations/pi/session-ui/session-viewport-controller.d.ts +44 -0
  189. package/dist/integrations/pi/session-ui/session-viewport-controller.js +434 -0
  190. package/dist/integrations/pi/session-ui/stream-presentation-coalescer.d.ts +29 -0
  191. package/dist/integrations/pi/session-ui/stream-presentation-coalescer.js +79 -0
  192. package/dist/integrations/pi/session-ui/system-clipboard.d.ts +20 -0
  193. package/dist/integrations/pi/session-ui/system-clipboard.js +130 -0
  194. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/adapter.d.ts +8 -1
  195. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/adapter.js +216 -9
  196. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/contracts.d.ts +29 -6
  197. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +63 -0
  198. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +240 -0
  199. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/index.d.ts +2 -0
  200. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/index.js +2 -0
  201. package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.d.ts +39 -0
  202. package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.js +139 -0
  203. package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/presentation-adapter.d.ts +1 -1
  204. package/dist/native/darwin-arm64/manifest.json +1 -1
  205. package/dist/native/linux-x64/manifest.json +3 -3
  206. package/dist/native/linux-x64/process-guardian +0 -0
  207. package/dist/native/win32-x64/manifest.json +3 -3
  208. package/dist/native/win32-x64/process-guardian.exe +0 -0
  209. package/dist/{src/product-identity.d.ts → product-identity.d.ts} +3 -3
  210. package/dist/{src/product-identity.js → product-identity.js} +7 -5
  211. package/dist/{src/product-identity.json → product-identity.json} +11 -6
  212. package/dist/runtime-payload-inventory.json +122328 -0
  213. package/dist/{src/foundation/ui-apps → ui/apps}/contracts.d.ts +23 -1
  214. package/dist/{src/foundation/ui-apps → ui/apps}/host.d.ts +1 -1
  215. package/dist/{src/foundation/ui-apps → ui/apps}/host.js +14 -10
  216. package/dist/{src/foundation/ui-apps → ui/apps}/registry.d.ts +1 -0
  217. package/dist/{src/foundation/ui-apps → ui/apps}/registry.js +1 -0
  218. package/dist/{src/foundation/ui-components → ui/components}/dialog-panel.js +5 -3
  219. package/dist/{src/foundation/ui-components → ui/components}/frame.d.ts +1 -0
  220. package/dist/{src/foundation/ui-components → ui/components}/frame.js +1 -0
  221. package/dist/{src/foundation/ui-components → ui/components}/index.d.ts +4 -0
  222. package/dist/{src/foundation/ui-components → ui/components}/index.js +4 -0
  223. package/dist/{src/foundation/ui-components → ui/components}/line-input.d.ts +1 -6
  224. package/dist/{src/foundation/ui-components → ui/components}/line-input.js +4 -9
  225. package/dist/{src/foundation/ui-components → ui/components}/list-view.d.ts +0 -6
  226. package/dist/{src/foundation/ui-components → ui/components}/list-view.js +14 -7
  227. package/dist/{src/foundation/ui-components → ui/components}/mouse.d.ts +10 -0
  228. package/dist/{src/foundation/ui-components → ui/components}/mouse.js +23 -0
  229. package/dist/ui/components/progress-status.d.ts +2 -0
  230. package/dist/ui/components/progress-status.js +4 -0
  231. package/dist/ui/components/prompt-row.d.ts +14 -0
  232. package/dist/ui/components/prompt-row.js +20 -0
  233. package/dist/{src/foundation/ui-components → ui/components}/scrollbar.d.ts +26 -0
  234. package/dist/{src/foundation/ui-components → ui/components}/scrollbar.js +35 -0
  235. package/dist/{src/foundation/ui-components → ui/components}/shortcuts.d.ts +1 -0
  236. package/dist/{src/foundation/ui-components → ui/components}/shortcuts.js +1 -0
  237. package/dist/ui/components/spans.d.ts +25 -0
  238. package/dist/ui/components/spans.js +257 -0
  239. package/dist/ui/components/submitted-prompt.d.ts +23 -0
  240. package/dist/ui/components/submitted-prompt.js +50 -0
  241. package/dist/{src/foundation/ui-components → ui/components}/surface.d.ts +0 -5
  242. package/dist/{src/foundation/ui-components → ui/components}/surface.js +1 -5
  243. package/dist/ui/components/text-selection.d.ts +62 -0
  244. package/dist/ui/components/text-selection.js +235 -0
  245. package/dist/{src/foundation/ui-components → ui/components}/text.d.ts +14 -0
  246. package/dist/{src/foundation/ui-components → ui/components}/text.js +66 -4
  247. package/dist/ui/components/transcript-viewport.d.ts +146 -0
  248. package/dist/ui/components/transcript-viewport.js +629 -0
  249. package/dist/{src/foundation/owned-ui-settings → ui/settings}/declarations.d.ts +8 -1
  250. package/dist/{src/foundation/owned-ui-settings → ui/settings}/declarations.js +33 -5
  251. package/dist/{src/foundation/owned-ui-settings → ui/settings}/migrations.d.ts +1 -1
  252. package/dist/{src/foundation/owned-ui-settings → ui/settings}/migrations.js +21 -2
  253. package/dist/{src/foundation/owned-ui-settings → ui/settings}/sections.d.ts +6 -19
  254. package/dist/{src/foundation/owned-ui-settings → ui/settings}/sections.js +32 -23
  255. package/dist/{src/foundation/owned-ui-settings → ui/settings}/session.d.ts +9 -17
  256. package/dist/{src/foundation/owned-ui-settings → ui/settings}/session.js +65 -55
  257. package/dist/{src/foundation/owned-ui-settings → ui/settings}/store.d.ts +1 -0
  258. package/dist/{src/foundation/owned-ui-settings → ui/settings}/store.js +2 -1
  259. package/docs/architecture/boundaries.md +9 -9
  260. package/docs/architecture/code-documentation.md +77 -0
  261. package/docs/architecture/project-structure.md +67 -30
  262. package/docs/architecture/resource-and-data-policy.md +1 -1
  263. package/docs/architecture/toolchain.md +10 -10
  264. package/docs/architecture/ui-reference-provenance.md +34 -5
  265. package/docs/ci-release-runbook.md +186 -79
  266. package/docs/features/launch-profiles.md +10 -19
  267. package/docs/manual-launch-instance-acceptance.md +12 -35
  268. package/docs/manual-owned-ui-checkpoint.md +78 -0
  269. package/docs/manual-pi-boundary-candidate.md +4 -5
  270. package/docs/manual-terminal-colour-check.md +4 -3
  271. package/docs/repository-governance-live-acceptance.md +77 -0
  272. package/package.json +37 -27
  273. package/dist/src/cli/capabilities.d.ts +0 -15
  274. package/dist/src/cli/dispatch.js +0 -177
  275. package/dist/src/cli/version-stats.js +0 -72
  276. package/dist/src/composition/index.d.ts +0 -48
  277. package/dist/src/composition/index.js +0 -258
  278. package/dist/src/features/launch/intent.js +0 -4
  279. package/dist/src/features/launch/profiles.d.ts +0 -12
  280. package/dist/src/features/launch/profiles.js +0 -26
  281. package/dist/src/foundation/lifecycle/paths.d.ts +0 -10
  282. package/dist/src/foundation/pi-component-adapter/shell-presenters-transcript.d.ts +0 -57
  283. package/dist/src/foundation/pi-engine-adapter/settings-integration.d.ts +0 -55
  284. package/dist/src/foundation/pi-owned-ui-integration/route-host.d.ts +0 -29
  285. package/dist/src/foundation/pi-owned-ui-integration/session-shell.d.ts +0 -112
  286. package/dist/src/foundation/release/cohort-state.d.ts +0 -70
  287. package/dist/src/foundation/release/cohort-state.js +0 -202
  288. package/dist/src/foundation/release/release-gc.d.ts +0 -5
  289. package/dist/src/foundation/release/release-gc.js +0 -16
  290. package/dist/src/foundation/supervision/index.d.ts +0 -3
  291. package/dist/src/foundation/supervision/index.js +0 -3
  292. package/dist/src/foundation/supervision/paths.d.ts +0 -1
  293. package/dist/src/foundation/supervision/paths.js +0 -1
  294. package/dist/src/foundation/ui-components/spans.d.ts +0 -7
  295. package/dist/src/foundation/ui-components/spans.js +0 -59
  296. package/docs/manual-transparent-checkpoint.md +0 -53
  297. /package/dist/{src/cli → cli}/index.d.ts +0 -0
  298. /package/dist/{src/cli → cli}/index.js +0 -0
  299. /package/dist/{src/cli → cli}/version.d.ts +0 -0
  300. /package/dist/{src/cli → cli}/version.js +0 -0
  301. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/capability-ports.js +0 -0
  302. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain-validation.d.ts +0 -0
  303. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/domain.js +0 -0
  304. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/index.d.ts +0 -0
  305. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/index.js +0 -0
  306. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/model.d.ts +0 -0
  307. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/model.js +0 -0
  308. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/package-ports.d.ts +0 -0
  309. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/package-ports.js +0 -0
  310. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/ports.d.ts +0 -0
  311. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/ports.js +0 -0
  312. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/serialization.d.ts +0 -0
  313. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/serialization.js +0 -0
  314. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/validation.d.ts +0 -0
  315. /package/dist/{src/foundation/agent-engine-contracts → contracts/agent-engine}/validation.js +0 -0
  316. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/extension-ui.d.ts +0 -0
  317. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/extension-ui.js +0 -0
  318. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/index.d.ts +0 -0
  319. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/index.js +0 -0
  320. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/model.js +0 -0
  321. /package/dist/{src/foundation/owned-ui-contracts → contracts/owned-ui}/validation.d.ts +0 -0
  322. /package/dist/{src/foundation/presentation-contracts → contracts/presentation}/index.d.ts +0 -0
  323. /package/dist/{src/foundation/presentation-contracts → contracts/presentation}/index.js +0 -0
  324. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/index.d.ts +0 -0
  325. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/index.js +0 -0
  326. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/model.d.ts +0 -0
  327. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/model.js +0 -0
  328. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/validation.d.ts +0 -0
  329. /package/dist/{src/foundation/workspace-contracts → contracts/workspace}/validation.js +0 -0
  330. /package/dist/{src/features → features}/launch/development-launch.d.ts +0 -0
  331. /package/dist/{src/features → features}/launch/initialize-profile.d.ts +0 -0
  332. /package/dist/{src/features → features}/launch/initialize-profile.js +0 -0
  333. /package/dist/{src/features → features}/launch/runtime-selection.js +0 -0
  334. /package/dist/{src/features → features}/workspace/capabilities.js +0 -0
  335. /package/dist/{src/features → features}/workspace/index.d.ts +0 -0
  336. /package/dist/{src/features → features}/workspace/index.js +0 -0
  337. /package/dist/{src/features → features}/workspace/presentation.d.ts +0 -0
  338. /package/dist/{src/features → features}/workspace/presentation.js +0 -0
  339. /package/dist/{src/features → features}/workspace/reconciliation.d.ts +0 -0
  340. /package/dist/{src/features → features}/workspace/reconciliation.js +0 -0
  341. /package/dist/{src/foundation → foundation}/launch-guardian/index.d.ts +0 -0
  342. /package/dist/{src/foundation → foundation}/launch-guardian/index.js +0 -0
  343. /package/dist/{src/foundation → foundation}/launch-guardian/main.d.ts +0 -0
  344. /package/dist/{src/foundation → foundation}/lifecycle/commands.d.ts +0 -0
  345. /package/dist/{src/foundation → foundation}/lifecycle/commands.js +0 -0
  346. /package/dist/{src/foundation → foundation}/lifecycle/index.d.ts +0 -0
  347. /package/dist/{src/foundation → foundation}/lifecycle/index.js +0 -0
  348. /package/dist/{src/foundation → foundation}/lifecycle/launch-instance.d.ts +0 -0
  349. /package/dist/{src/foundation → foundation}/lifecycle/launch-instance.js +0 -0
  350. /package/dist/{src/foundation → foundation}/native-host-protocol/evidence.d.ts +0 -0
  351. /package/dist/{src/foundation → foundation}/native-host-protocol/evidence.js +0 -0
  352. /package/dist/{src/foundation → foundation}/native-host-protocol/index.d.ts +0 -0
  353. /package/dist/{src/foundation → foundation}/native-host-protocol/index.js +0 -0
  354. /package/dist/{src/foundation → foundation}/native-host-protocol/proof-gate.d.ts +0 -0
  355. /package/dist/{src/foundation → foundation}/native-host-protocol/proof-gate.js +0 -0
  356. /package/dist/{src/foundation → foundation}/process-containment/artifact.d.ts +0 -0
  357. /package/dist/{src/foundation → foundation}/process-containment/artifact.js +0 -0
  358. /package/dist/{src/foundation → foundation}/process-containment/contracts.d.ts +0 -0
  359. /package/dist/{src/foundation → foundation}/process-containment/contracts.js +0 -0
  360. /package/dist/{src/foundation → foundation}/process-containment/index.d.ts +0 -0
  361. /package/dist/{src/foundation → foundation}/process-containment/index.js +0 -0
  362. /package/dist/{src/foundation → foundation}/protocol/index.d.ts +0 -0
  363. /package/dist/{src/foundation → foundation}/protocol/index.js +0 -0
  364. /package/dist/{src/foundation → foundation}/release/cohort-selection.d.ts +0 -0
  365. /package/dist/{src/foundation → foundation}/release/cohort-selection.js +0 -0
  366. /package/dist/{src/foundation → foundation}/release/concurrency.d.ts +0 -0
  367. /package/dist/{src/foundation → foundation}/release/concurrency.js +0 -0
  368. /package/dist/{src/foundation → foundation}/release/process-cleanup.d.ts +0 -0
  369. /package/dist/{src/foundation → foundation}/release/process-cleanup.js +0 -0
  370. /package/dist/{src/foundation → foundation}/release/stable-release.d.ts +0 -0
  371. /package/dist/{src/foundation → foundation}/release/stable-release.js +0 -0
  372. /package/dist/{src/foundation → foundation}/storage/index.d.ts +0 -0
  373. /package/dist/{src/foundation → foundation}/storage/index.js +0 -0
  374. /package/dist/{src/foundation → foundation}/structured-agent-runtime/index.d.ts +0 -0
  375. /package/dist/{src/foundation → foundation}/structured-agent-runtime/index.js +0 -0
  376. /package/dist/{src/foundation → foundation}/supervision/main.d.ts +0 -0
  377. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/components.js +0 -0
  378. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/index.d.ts +0 -0
  379. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/index.js +0 -0
  380. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/resources/builtin-themes.d.ts +0 -0
  381. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/resources/builtin-themes.js +0 -0
  382. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-editor-autocomplete.d.ts +0 -0
  383. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-extension-ui.js +0 -0
  384. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/shell-selectors-dialogs.js +0 -0
  385. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/theme.d.ts +0 -0
  386. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/theme.js +0 -0
  387. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/countdown-timer.d.ts +0 -0
  388. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/countdown-timer.js +0 -0
  389. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/custom-entry.d.ts +0 -0
  390. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/custom-entry.js +0 -0
  391. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/daxnuts.d.ts +0 -0
  392. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/daxnuts.js +0 -0
  393. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/earendil-announcement.d.ts +0 -0
  394. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/earendil-announcement.js +0 -0
  395. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/extension-editor.d.ts +0 -0
  396. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/extension-editor.js +0 -0
  397. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/first-time-setup.d.ts +0 -0
  398. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/first-time-setup.js +0 -0
  399. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/markdown-transform.d.ts +0 -0
  400. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/markdown-transform.js +0 -0
  401. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/mermaid.d.ts +0 -0
  402. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/mermaid.js +0 -0
  403. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/owned-editor.d.ts +0 -0
  404. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/owned-editor.js +0 -0
  405. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/scoped-models-selector.d.ts +0 -0
  406. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/scoped-models-selector.js +0 -0
  407. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-footer.js +0 -0
  408. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector-search.d.ts +0 -0
  409. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector-search.js +0 -0
  410. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector.d.ts +0 -0
  411. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/session-selector.js +0 -0
  412. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/skill-invocation-message.d.ts +0 -0
  413. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/skill-invocation-message.js +0 -0
  414. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/status-indicator.d.ts +0 -0
  415. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/status-indicator.js +0 -0
  416. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/tree-selector.d.ts +0 -0
  417. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/tree-selector.js +0 -0
  418. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/trust-selector.d.ts +0 -0
  419. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/components/trust-selector.js +0 -0
  420. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/external-editor.d.ts +0 -0
  421. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/external-editor.js +0 -0
  422. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/model-search.d.ts +0 -0
  423. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/model-search.js +0 -0
  424. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/theme/theme-controller.d.ts +0 -0
  425. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/theme/theme-controller.js +0 -0
  426. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/theme/theme.d.ts +0 -0
  427. /package/dist/{src/foundation/pi-component-adapter → integrations/pi/components}/upstream/theme/theme.js +0 -0
  428. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/pi-settings-metadata.json +0 -0
  429. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/public-main-entry.d.ts +0 -0
  430. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/public-main-entry.js +0 -0
  431. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/workflows.d.ts +0 -0
  432. /package/dist/{src/foundation/pi-engine-adapter → integrations/pi/engine}/workflows.js +0 -0
  433. /package/dist/{src/foundation/pi-owned-ui-integration → integrations/pi/session-ui}/route-host.js +0 -0
  434. /package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/conformance.d.ts +0 -0
  435. /package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/conformance.js +0 -0
  436. /package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/contracts.js +0 -0
  437. /package/dist/{src/foundation/pi-tui-runtime-adapter → integrations/pi/tui-runtime}/presentation-adapter.js +0 -0
  438. /package/dist/{src/foundation/ui-apps → ui/apps}/contracts.js +0 -0
  439. /package/dist/{src/foundation/ui-apps → ui/apps}/index.d.ts +0 -0
  440. /package/dist/{src/foundation/ui-apps → ui/apps}/index.js +0 -0
  441. /package/dist/{src/foundation/ui-components → ui/components}/dialog-panel.d.ts +0 -0
  442. /package/dist/{src/foundation/ui-components → ui/components}/label.d.ts +0 -0
  443. /package/dist/{src/foundation/ui-components → ui/components}/label.js +0 -0
  444. /package/dist/{src/foundation/ui-components → ui/components}/list-block.d.ts +0 -0
  445. /package/dist/{src/foundation/ui-components → ui/components}/list-block.js +0 -0
  446. /package/dist/{src/foundation/ui-components → ui/components}/pane.d.ts +0 -0
  447. /package/dist/{src/foundation/ui-components → ui/components}/pane.js +0 -0
  448. /package/dist/{src/foundation/ui-components → ui/components}/revision.d.ts +0 -0
  449. /package/dist/{src/foundation/ui-components → ui/components}/revision.js +0 -0
  450. /package/dist/{src/foundation/ui-components → ui/components}/status-line.d.ts +0 -0
  451. /package/dist/{src/foundation/ui-components → ui/components}/status-line.js +0 -0
  452. /package/dist/{src/foundation/ui-components → ui/components}/stepper.d.ts +0 -0
  453. /package/dist/{src/foundation/ui-components → ui/components}/stepper.js +0 -0
  454. /package/dist/{src/foundation/ui-components → ui/components}/theme.d.ts +0 -0
  455. /package/dist/{src/foundation/ui-components → ui/components}/theme.js +0 -0
  456. /package/dist/{src/foundation/ui-components → ui/components}/value-menu.d.ts +0 -0
  457. /package/dist/{src/foundation/ui-components → ui/components}/value-menu.js +0 -0
  458. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/index.d.ts +0 -0
  459. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/index.js +0 -0
  460. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/resolution.d.ts +0 -0
  461. /package/dist/{src/foundation/owned-ui-settings → ui/settings}/resolution.js +0 -0
@@ -1,11 +1,13 @@
1
1
  import { execFile } from "node:child_process";
2
+ import { createHash } from "node:crypto";
2
3
  import { mkdir, rm, writeFile } from "node:fs/promises";
3
4
  import { tmpdir } from "node:os";
4
5
  import { dirname, join, resolve } from "node:path";
5
6
  import { promisify } from "node:util";
6
- import { PRODUCT_IDENTITY } from "../../product-identity.js";
7
- import { copyToClipboard, DefaultPackageManager, getAgentDir, ProjectTrustStore, SessionManager, } from "@earendil-works/pi-coding-agent";
8
- import { OWNED_UI_EXTENSION_CONTRACT_VERSION, OWNED_UI_EXTENSION_RENDER_CALLBACKS, OWNED_UI_EXTENSION_UI_CALLBACKS, OWNED_UI_EXTENSION_UI_PROPERTIES, assertOwnedUiCommand, assertOwnedUiExtensionUiPort, assertOwnedUiSnapshot, } from "../owned-ui-contracts/index.js";
7
+ import { PRODUCT_IDENTITY } from "../../../product-identity.js";
8
+ import { configureOwnedHttpDispatcher } from "./http-dispatcher.js";
9
+ import { copyToClipboard, DefaultPackageManager, getAgentDir, ProjectTrustStore, SessionManager, VERSION, } from "@earendil-works/pi-coding-agent";
10
+ import { OWNED_UI_EXTENSION_CONTRACT_VERSION, OWNED_UI_EXTENSION_RENDER_CALLBACKS, OWNED_UI_EXTENSION_UI_CALLBACKS, OWNED_UI_EXTENSION_UI_PROPERTIES, assertOwnedUiCommand, assertOwnedUiExtensionUiPort, assertOwnedUiSnapshot, } from "../../../contracts/owned-ui/index.js";
9
11
  import { PINNED_PI_SETTINGS_CALLBACKS, PINNED_PI_WORKFLOW_COMMAND_NAMES, } from "./workflows.js";
10
12
  import { createPiRuntimeIntegration } from "./runtime-integration.js";
11
13
  import { PiSessionCommandIntegration } from "./session-integration.js";
@@ -16,19 +18,25 @@ const execFileAsync = promisify(execFile);
16
18
  * that a streaming burst never holds input, large enough that an ordinary turn is one
17
19
  * batch.
18
20
  */
19
- const EVENT_DELIVERY_BATCH = 16;
21
+ // Performance: deliver at most one engine event per event-loop turn. Transcript updates can
22
+ // be expensive in long sessions; a larger synchronous batch starves terminal
23
+ // input and makes an in-progress mouse selection appear frozen.
24
+ const EVENT_DELIVERY_BATCH = 1;
25
+ const TOOL_UPDATE_COALESCE_MS = 50;
20
26
  const DEFAULT_SURFACE = {
21
27
  columns: 100,
22
28
  rows: 32,
23
29
  focusedRegion: "editor",
24
30
  hardwareCursor: false,
25
31
  };
32
+ /** Owns the pinned Pi session lifecycle and translates its events into the neutral agent-engine contract. */
26
33
  export class PiEngineAdapter {
27
34
  #runtimeFactory;
28
35
  #checkPackageUpdates;
29
36
  #cwd;
30
37
  #agentDir;
31
38
  #sessionId;
39
+ #sessionPath;
32
40
  #workflowHost;
33
41
  #workflowInteraction;
34
42
  #listeners = new Set();
@@ -64,6 +72,10 @@ export class PiEngineAdapter {
64
72
  #messageBlockIds = new WeakMap();
65
73
  #messageFallbackIds = new Map();
66
74
  #toolBlockIds = new Map();
75
+ #transcriptImageAssets = new Map();
76
+ #pendingToolUpdates = new Map();
77
+ #toolUpdateFlush = null;
78
+ #usageCache;
67
79
  #nextBlockSequence = 0;
68
80
  #diagnostics = [];
69
81
  #eventQueue = [];
@@ -77,12 +89,16 @@ export class PiEngineAdapter {
77
89
  #extensionShutdown;
78
90
  #extensionBound = false;
79
91
  #disposed = false;
80
- /** Lists the themes installed on this machine, when the caller supplies one. */
92
+ #settingsProductMode;
93
+ #projectTrustPrompt;
94
+ #settingsIntegration;
95
+ #settingsIntegrationManager;
81
96
  #availableThemes;
82
97
  constructor(options = {}) {
83
98
  this.#cwd = options.cwd ?? process.cwd();
84
99
  this.#agentDir = options.agentDir ?? getAgentDir();
85
100
  this.#sessionId = options.sessionId ?? "owned-session-1";
101
+ this.#sessionPath = options.sessionPath;
86
102
  this.#runtimeFactory = options.createRuntime ?? createDefaultPiRuntime;
87
103
  this.#checkPackageUpdates = options.checkPackageUpdates
88
104
  ?? (options.createRuntime
@@ -90,6 +106,8 @@ export class PiEngineAdapter {
90
106
  : settingsManager => checkDefaultPiPackageUpdates(this.#cwd, this.#agentDir, settingsManager));
91
107
  this.#workflowHost = options.workflowHost ?? defaultWorkflowHost();
92
108
  this.#availableThemes = options.availableThemes ?? null;
109
+ this.#settingsProductMode = options.settingsProductMode ?? "bare";
110
+ this.#projectTrustPrompt = options.projectTrustPrompt;
93
111
  this.#workflowInteraction = { prompt: async () => null, notify() { } };
94
112
  }
95
113
  setWorkflowInteractionHost(interaction) {
@@ -104,6 +122,29 @@ export class PiEngineAdapter {
104
122
  get agentDir() {
105
123
  return this.#agentDir;
106
124
  }
125
+ resolveTranscriptImage(assetId) {
126
+ return this.#transcriptImageAssets.get(assetId) ?? null;
127
+ }
128
+ currentSessionFile() {
129
+ const value = this.#session?.sessionManager?.getSessionFile?.();
130
+ return typeof value === "string" && value.length > 0 ? value : null;
131
+ }
132
+ currentSessionResumeMetadata() {
133
+ const manager = this.#session?.sessionManager;
134
+ if (manager === undefined
135
+ || typeof manager.isPersisted !== "function"
136
+ || typeof manager.getSessionId !== "function"
137
+ || typeof manager.getSessionDir !== "function"
138
+ || typeof manager.usesDefaultSessionDir !== "function"
139
+ || manager.isPersisted() !== true
140
+ || this.currentSessionFile() === null)
141
+ return null;
142
+ const sessionId = manager.getSessionId();
143
+ const sessionDir = manager.getSessionDir();
144
+ if (!sessionId || !sessionDir)
145
+ return null;
146
+ return { sessionId, sessionDir, usesDefaultSessionDir: manager.usesDefaultSessionDir() };
147
+ }
107
148
  get disposed() {
108
149
  return this.#disposed;
109
150
  }
@@ -114,6 +155,8 @@ export class PiEngineAdapter {
114
155
  cwd: this.#cwd,
115
156
  agentDir: this.#agentDir,
116
157
  sessionId: this.#sessionId,
158
+ ...(this.#sessionPath === undefined ? {} : { sessionPath: this.#sessionPath }),
159
+ ...(this.#projectTrustPrompt === undefined ? {} : { projectTrustPrompt: this.#projectTrustPrompt }),
117
160
  }).catch(error => {
118
161
  this.#lifecycle = "failed";
119
162
  this.#addDiagnostic("error", "engine-startup", error instanceof Error ? error.message : String(error), false);
@@ -133,6 +176,7 @@ export class PiEngineAdapter {
133
176
  this.#addDiagnostic(diagnostic.type === "error" ? "error" : diagnostic.type === "warning" ? "warning" : "info", "engine-startup", diagnostic.message, diagnostic.type !== "error");
134
177
  }
135
178
  this.#bindSession(runtime.session);
179
+ await this.#announceChangelog(runtime.services.settingsManager);
136
180
  this.#lifecycle = "ready";
137
181
  this.#editor = { ...this.#editor, submitEnabled: true };
138
182
  this.#emitEvent({ type: "session-lifecycle", lifecycle: "ready", reason: null });
@@ -140,6 +184,19 @@ export class PiEngineAdapter {
140
184
  void this.#announcePackageUpdates(runtime.services.settingsManager);
141
185
  return this.view();
142
186
  }
187
+ async #announceChangelog(settingsManager) {
188
+ if (!settingsManager || typeof settingsManager.getLastChangelogVersion !== "function"
189
+ || typeof settingsManager.setLastChangelogVersion !== "function")
190
+ return;
191
+ if (settingsManager.getLastChangelogVersion() === VERSION)
192
+ return;
193
+ const markdown = await this.#workflowHost.readChangelog().catch(() => "");
194
+ if (markdown.trim().length > 0) {
195
+ this.#addDiagnostic("info", settingsManager.getCollapseChangelog() ? "changelog-collapsed" : "changelog-expanded", markdown, true);
196
+ }
197
+ settingsManager.setLastChangelogVersion(VERSION);
198
+ await settingsManager.flush();
199
+ }
143
200
  async #announcePackageUpdates(settingsManager) {
144
201
  if (process.env.PI_OFFLINE)
145
202
  return;
@@ -162,6 +219,7 @@ export class PiEngineAdapter {
162
219
  return () => this.#listeners.delete(listener);
163
220
  }
164
221
  async flushEvents() {
222
+ this.#flushPendingToolUpdates();
165
223
  while (this.#eventQueueProcessing)
166
224
  await this.#eventQueueProcessing;
167
225
  }
@@ -424,16 +482,107 @@ export class PiEngineAdapter {
424
482
  /** Settings port for the live runtime, or null before the runtime is available. */
425
483
  settingsPort() {
426
484
  const settings = this.#runtime?.services.settingsManager;
427
- if (!settings)
485
+ if (!settings || typeof settings.getCompactionEnabled !== "function")
428
486
  return null;
429
- const session = this.#runtime?.session;
430
- return new PiSettingsIntegration(settings, {
431
- ...(this.#availableThemes === null ? {} : { themes: this.#availableThemes }),
432
- thinkingLevels: () => {
433
- const levels = session?.getAvailableThinkingLevels?.();
434
- return Array.isArray(levels) ? levels.map(level => String(level)) : [];
435
- },
436
- });
487
+ if (this.#settingsIntegration === undefined || this.#settingsIntegrationManager !== settings) {
488
+ this.#settingsIntegrationManager = settings;
489
+ configureOwnedHttpDispatcher(settings.getHttpIdleTimeoutMs());
490
+ this.#settingsIntegration = new PiSettingsIntegration(settings, {
491
+ ...(this.#availableThemes === null ? {} : { themes: this.#availableThemes }),
492
+ thinkingLevels: () => {
493
+ const levels = this.#runtime?.session?.getAvailableThinkingLevels?.();
494
+ return Array.isArray(levels) ? levels.map(level => String(level)) : [];
495
+ },
496
+ productMode: this.#settingsProductMode,
497
+ });
498
+ this.#settingsIntegration.bindOwner("shell", {
499
+ enableSkillCommands: { apply: value => {
500
+ if (typeof value !== "boolean")
501
+ throw new TypeError("Skill commands value is invalid");
502
+ settings.setEnableSkillCommands(value);
503
+ } },
504
+ doubleEscapeAction: { apply: value => {
505
+ if (value !== "tree" && value !== "fork" && value !== "none")
506
+ throw new TypeError("Double-Escape action is invalid");
507
+ settings.setDoubleEscapeAction(value);
508
+ } },
509
+ treeFilterMode: { apply: value => {
510
+ if (value !== "default" && value !== "no-tools" && value !== "user-only" && value !== "labeled-only" && value !== "all")
511
+ throw new TypeError("Tree filter mode is invalid");
512
+ settings.setTreeFilterMode(value);
513
+ } },
514
+ showCacheMissNotices: { apply: value => {
515
+ if (typeof value !== "boolean")
516
+ throw new TypeError("Cache-miss notice setting is invalid");
517
+ settings.setShowCacheMissNotices(value);
518
+ } },
519
+ });
520
+ this.#settingsIntegration.bindOwner("startup", {
521
+ // Invariant: deferred application is the owner operation: the next preflight reads
522
+ // the persisted default before constructing project-backed services.
523
+ defaultProjectTrust: { apply() { } },
524
+ collapseChangelog: { apply() { } },
525
+ });
526
+ this.#settingsIntegration.bindOwner("agent", {
527
+ autoCompact: { apply: value => {
528
+ if (typeof value !== "boolean")
529
+ throw new TypeError("Auto compact value is invalid");
530
+ this.#requireWorkflowSession().setAutoCompactionEnabled(value);
531
+ } },
532
+ autoResizeImages: { apply: value => {
533
+ if (typeof value !== "boolean")
534
+ throw new TypeError("Auto-resize images value is invalid");
535
+ settings.setImageAutoResize(value);
536
+ } },
537
+ blockImages: { apply: value => {
538
+ if (typeof value !== "boolean")
539
+ throw new TypeError("Block images value is invalid");
540
+ settings.setBlockImages(value);
541
+ } },
542
+ steeringMode: { apply: value => {
543
+ if (value !== "all" && value !== "one-at-a-time")
544
+ throw new TypeError("Steering mode is invalid");
545
+ this.#requireWorkflowSession().setSteeringMode(value);
546
+ } },
547
+ followUpMode: { apply: value => {
548
+ if (value !== "all" && value !== "one-at-a-time")
549
+ throw new TypeError("Follow-up mode is invalid");
550
+ this.#requireWorkflowSession().setFollowUpMode(value);
551
+ } },
552
+ transport: { apply: value => {
553
+ if (value !== "sse" && value !== "websocket" && value !== "websocket-cached" && value !== "auto")
554
+ throw new TypeError("Transport is invalid");
555
+ this.#requireWorkflowSession().agent.transport = value;
556
+ } },
557
+ httpIdleTimeoutMs: { apply: value => {
558
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
559
+ throw new TypeError("HTTP idle timeout is invalid");
560
+ // Invariant: provider streaming reads the manager per request; global fetch uses
561
+ // the matching owned dispatcher and zero maps to disabled semantics.
562
+ configureOwnedHttpDispatcher(value);
563
+ settings.setHttpIdleTimeoutMs(value);
564
+ } },
565
+ thinkingLevel: { apply: value => {
566
+ if (!isThinkingLevel(value))
567
+ throw new TypeError("Thinking level is invalid");
568
+ this.#requireWorkflowSession().setThinkingLevel(value);
569
+ this.#thinkingLevel = readThinkingLevel(this.#requireWorkflowSession().thinkingLevel);
570
+ this.#emitView();
571
+ } },
572
+ warnings: { apply: value => {
573
+ if (!isRecord(value) || Object.values(value).some(flag => typeof flag !== "boolean"))
574
+ throw new TypeError("Warnings setting is invalid");
575
+ settings.setWarnings(value);
576
+ } },
577
+ });
578
+ }
579
+ return this.#settingsIntegration;
580
+ }
581
+ bindSettingsOwner(owner, handlers) {
582
+ const settings = this.settingsPort();
583
+ if (settings === null)
584
+ return () => { };
585
+ return settings.bindOwner(owner, handlers);
437
586
  }
438
587
  pinnedModelSelectorContext() {
439
588
  const session = this.#requireWorkflowSession();
@@ -710,9 +859,9 @@ export class PiEngineAdapter {
710
859
  excludeFromContext,
711
860
  };
712
861
  }
713
- applyPinnedSettingValue(callback, value) {
862
+ async applyPinnedSettingValue(callback, value) {
714
863
  try {
715
- return this.#applyPinnedSetting(callback, value, true);
864
+ return await this.#applyPinnedSetting(callback, value, true);
716
865
  }
717
866
  catch (error) {
718
867
  return workflowResult("settings", "failed", error instanceof Error ? error.message : String(error));
@@ -742,7 +891,7 @@ export class PiEngineAdapter {
742
891
  ...this.#status,
743
892
  diagnostics: [...this.#status.diagnostics],
744
893
  badges: [...this.#status.badges],
745
- usage: this.#readUsage(),
894
+ usage: this.#usageCache ??= this.#readUsage(),
746
895
  footer: {
747
896
  branch: this.#gitBranch,
748
897
  sessionName: this.#session?.sessionManager?.getSessionName() ?? null,
@@ -808,6 +957,12 @@ export class PiEngineAdapter {
808
957
  if (this.#disposed)
809
958
  return;
810
959
  this.#disposed = true;
960
+ if (this.#toolUpdateFlush !== null) {
961
+ clearTimeout(this.#toolUpdateFlush);
962
+ this.#toolUpdateFlush = null;
963
+ }
964
+ this.#pendingToolUpdates.clear();
965
+ this.#transcriptImageAssets.clear();
811
966
  this.#extensionBound = false;
812
967
  this.#extensionUi = undefined;
813
968
  this.#extensionShutdown = undefined;
@@ -833,7 +988,7 @@ export class PiEngineAdapter {
833
988
  case "settings": {
834
989
  if (!selection)
835
990
  return workflowResult(request.command, "failed", "Settings requires the owned settings controller");
836
- return this.#applyPinnedSetting(selection);
991
+ return await this.#applyPinnedSetting(selection);
837
992
  }
838
993
  case "model": {
839
994
  const reference = selection ?? argument;
@@ -1223,7 +1378,7 @@ export class PiEngineAdapter {
1223
1378
  return [];
1224
1379
  return sessionInfoOptions(await SessionManager.list(cwd, typeof sessionDir === "string" ? sessionDir : undefined));
1225
1380
  }
1226
- #applyPinnedSetting(selection, selectedValue, hasSelectedValue = false) {
1381
+ async #applyPinnedSetting(selection, selectedValue, hasSelectedValue = false) {
1227
1382
  if (!PINNED_PI_SETTINGS_CALLBACKS.includes(selection)) {
1228
1383
  return workflowResult("settings", "failed", `Unknown setting callback: ${selection}`);
1229
1384
  }
@@ -1270,29 +1425,19 @@ export class PiEngineAdapter {
1270
1425
  selectedValue = currentValues[callback];
1271
1426
  hasSelectedValue = true;
1272
1427
  }
1273
- const settings = this.#runtime?.services.settingsManager;
1274
- if (!settings)
1428
+ const port = this.settingsPort();
1429
+ if (port === null)
1275
1430
  return workflowResult("settings", "failed", "Settings are unavailable");
1276
- const session = this.#requireWorkflowSession();
1277
- if (callback === "onThinkingLevelChange") {
1278
- if (!isThinkingLevel(selectedValue))
1279
- return workflowResult("settings", "failed", "Thinking level is invalid");
1280
- session.setThinkingLevel(selectedValue);
1281
- }
1282
- else {
1283
- const key = settingKeyForCallback(callback);
1284
- if (key === null)
1285
- return workflowResult("settings", "failed", `${settingLabel(callback)} is unavailable in this runtime`);
1286
- const value = agentJsonValue(selectedValue);
1287
- if (callback === "onAutoCompactChange") {
1288
- if (typeof value !== "boolean")
1289
- return workflowResult("settings", "failed", "Auto compact value is invalid");
1290
- session.setAutoCompactionEnabled?.(value);
1291
- }
1292
- new PiSettingsIntegration(settings).writeSettingNow(key, value);
1431
+ const key = settingKeyForCallback(callback);
1432
+ if (key === null)
1433
+ return workflowResult("settings", "failed", `${settingLabel(callback)} is unavailable in this runtime`);
1434
+ const result = await port.writeSetting(key, agentJsonValue(selectedValue));
1435
+ if (result.status === "failed" || result.status === "unavailable") {
1436
+ return workflowResult("settings", "failed", result.failure ?? result.limitationReason ?? `${settingLabel(callback)} is unavailable`);
1293
1437
  }
1294
1438
  this.#emitView();
1295
- return workflowResult("settings", "completed", `${settingLabel(callback)}: ${String(selectedValue)}`);
1439
+ const suffix = result.status === "deferred" ? ` (${result.application})` : "";
1440
+ return workflowResult("settings", "completed", `${settingLabel(callback)}: ${String(selectedValue)}${suffix}`);
1296
1441
  }
1297
1442
  async #perform(command) {
1298
1443
  const runtime = this.#runtime;
@@ -1307,7 +1452,11 @@ export class PiEngineAdapter {
1307
1452
  case "retry":
1308
1453
  case "compact": {
1309
1454
  const result = await this.#sessionCommands?.execute(command.type === "prompt" || command.type === "steer" || command.type === "follow-up"
1310
- ? { type: command.type, text: command.text }
1455
+ ? {
1456
+ type: command.type,
1457
+ text: command.text,
1458
+ ...(command.images === undefined ? {} : { images: [...command.images] }),
1459
+ }
1311
1460
  : { type: command.type });
1312
1461
  if (!result || result.outcome === "rejected" || result.outcome === "failed") {
1313
1462
  throw new Error(command.type === "retry" ? "no previous prompt is available to retry" : `Pi session command failed: ${command.type}`);
@@ -1367,6 +1516,7 @@ export class PiEngineAdapter {
1367
1516
  this.#activeModel = readModel(session.model);
1368
1517
  this.#reconcileActiveModelAvailability();
1369
1518
  this.#thinkingLevel = readThinkingLevel(session.thinkingLevel);
1519
+ this.#transcriptImageAssets.clear();
1370
1520
  this.#rebuildTranscript(session.messages, "finalized");
1371
1521
  this.#unsubscribe = session.subscribe(event => this.#handlePiEvent(event));
1372
1522
  if (this.#extensionUi !== undefined)
@@ -1416,23 +1566,24 @@ export class PiEngineAdapter {
1416
1566
  this.#emitView();
1417
1567
  }
1418
1568
  }
1419
- /**
1420
- * Replaces the transcript and the index that finds a block by its identifier. Every
1421
- * lookup goes through the index, so streaming a chunk costs the same in a long session
1422
- * as in a new one.
1423
- */
1569
+ // Performance: replacing the transcript rebuilds its index so block lookup stays constant-time.
1424
1570
  #setTranscript(blocks) {
1425
1571
  this.#transcript = blocks;
1426
1572
  this.#transcriptIndex.clear();
1427
1573
  for (const [index, block] of blocks.entries())
1428
1574
  this.#transcriptIndex.set(block.id, index);
1575
+ const retainedAssets = new Set(blocks.flatMap(block => block.imageReferences?.map(reference => reference.assetId) ?? []));
1576
+ for (const assetId of this.#transcriptImageAssets.keys()) {
1577
+ if (!retainedAssets.has(assetId))
1578
+ this.#transcriptImageAssets.delete(assetId);
1579
+ }
1429
1580
  this.#transcriptSnapshot = undefined;
1430
1581
  }
1431
1582
  #transcriptBlock(id) {
1432
1583
  const index = this.#transcriptIndex.get(id);
1433
1584
  return index === undefined ? undefined : this.#transcript[index];
1434
1585
  }
1435
- /** Shows the state named by `kind`, which becomes the state a later end can clear. */
1586
+ // Invariant: the named work state is the only state a matching end may clear.
1436
1587
  #enterWorkState(kind, message) {
1437
1588
  const wasBusy = this.#lifecycle === "busy";
1438
1589
  this.#statusKind = kind;
@@ -1442,21 +1593,16 @@ export class PiEngineAdapter {
1442
1593
  this.#emitEvent({ type: "session-lifecycle", lifecycle: "busy", reason: null });
1443
1594
  this.#emitEvent({ type: "status", status: this.#status });
1444
1595
  }
1445
- /**
1446
- * Ends one named state. A state the shell is not in is left alone, so a finished
1447
- * compaction or retry cannot clear the working state it never replaced. While the run
1448
- * continues, ending either of those returns to working rather than to idle.
1449
- */
1596
+ // Invariant: ending retry or compaction cannot clear a different active work state.
1450
1597
  #endWorkState(kind) {
1451
1598
  if (this.#statusKind !== kind)
1452
1599
  return;
1453
1600
  if (this.#agentRunActive) {
1454
- this.#enterWorkState("working", "Working...");
1601
+ this.#enterWorkState("working", "Working");
1455
1602
  return;
1456
1603
  }
1457
1604
  this.#leaveWorkStates();
1458
1605
  }
1459
- /** Leaves every work state and reports the session idle. */
1460
1606
  #leaveWorkStates() {
1461
1607
  this.#statusKind = null;
1462
1608
  this.#lifecycle = "ready";
@@ -1467,10 +1613,15 @@ export class PiEngineAdapter {
1467
1613
  #handlePiEvent(event) {
1468
1614
  if (!isRecord(event) || typeof event.type !== "string")
1469
1615
  return;
1616
+ // Invariant: usage moves at message and lifecycle boundaries, not with stream chunks, so the
1617
+ // two streaming event kinds keep the memo and everything else drops it.
1618
+ if (event.type !== "message_update" && event.type !== "tool_execution_update")
1619
+ this.#usageCache = undefined;
1470
1620
  switch (event.type) {
1471
1621
  case "agent_start":
1472
1622
  this.#agentRunActive = true;
1473
- this.#enterWorkState("working", "Working...");
1623
+ this.#emitEvent({ type: "agent-run-started" });
1624
+ this.#enterWorkState("working", "Working");
1474
1625
  return;
1475
1626
  case "message_start":
1476
1627
  this.#upsertMessageBlock(event.message, "live");
@@ -1479,7 +1630,7 @@ export class PiEngineAdapter {
1479
1630
  const delta = isRecord(event.assistantMessageEvent) && typeof event.assistantMessageEvent.delta === "string"
1480
1631
  ? event.assistantMessageEvent.delta
1481
1632
  : undefined;
1482
- // The delta is folded in before the block is stored, so a chunk is one update to
1633
+ // Invariant: the delta is folded in before the block is stored, so a chunk is one update to
1483
1634
  // one block rather than a store without the delta followed by a store with it.
1484
1635
  const blocks = this.#messageBlocks(event.message, "live", this.#transcript.length);
1485
1636
  for (const [index, block] of blocks.entries()) {
@@ -1491,6 +1642,12 @@ export class PiEngineAdapter {
1491
1642
  }
1492
1643
  case "message_end":
1493
1644
  this.#upsertMessageBlock(event.message, "finalized");
1645
+ // Compatibility: preserve the same semantic boundary v2 counted. Transcript block
1646
+ // finalization is intentionally not a substitute: rebuilds, retries,
1647
+ // thinking parts, and tool rows can all finalize independently.
1648
+ if (isRecord(event.message) && event.message.role === "assistant") {
1649
+ this.#emitEvent({ type: "assistant-message-completed" });
1650
+ }
1494
1651
  return;
1495
1652
  case "turn_end":
1496
1653
  this.#upsertMessageBlock(event.message, "finalized");
@@ -1500,10 +1657,17 @@ export class PiEngineAdapter {
1500
1657
  }
1501
1658
  return;
1502
1659
  case "tool_execution_start":
1503
- case "tool_execution_update":
1504
- case "tool_execution_end":
1660
+ case "tool_execution_end": {
1661
+ // Concurrency: the end supersedes any update still waiting on the coalescing timer.
1662
+ const toolCallId = stringValue(event.toolCallId);
1663
+ if (toolCallId !== undefined)
1664
+ this.#pendingToolUpdates.delete(toolCallId);
1505
1665
  this.#upsertToolExecutionBlock(event);
1506
1666
  return;
1667
+ }
1668
+ case "tool_execution_update":
1669
+ this.#coalesceToolExecutionUpdate(event);
1670
+ return;
1507
1671
  case "agent_settled":
1508
1672
  case "agent_end": {
1509
1673
  if (event.type === "agent_end" && event.willRetry === true)
@@ -1515,7 +1679,7 @@ export class PiEngineAdapter {
1515
1679
  this.#rebuildTranscript(finalMessages, "finalized");
1516
1680
  else
1517
1681
  this.#setTranscript(this.#transcript.map(block => block.status === "live" ? { ...block, status: "finalized" } : block));
1518
- // Ending a turn leaves the working state, as the recorded pinned baseline does, but
1682
+ // Compatibility: ending a turn leaves the working state, as the recorded pinned baseline does, but
1519
1683
  // it leaves only that state: a compaction or retry being shown outlives the turn
1520
1684
  // that ended under it. Settlement ends the run, and with it every state — the
1521
1685
  // engine ends a turn for each continuation it makes and settles once.
@@ -1541,13 +1705,13 @@ export class PiEngineAdapter {
1541
1705
  return;
1542
1706
  }
1543
1707
  case "auto_retry_start":
1544
- this.#enterWorkState("retry", "Retrying");
1708
+ this.#enterWorkState("retry", "Retrying");
1545
1709
  return;
1546
1710
  case "auto_retry_end":
1547
1711
  this.#endWorkState("retry");
1548
1712
  return;
1549
1713
  case "compaction_start":
1550
- this.#enterWorkState("compaction", "Compacting");
1714
+ this.#enterWorkState("compaction", "Compacting");
1551
1715
  return;
1552
1716
  case "compaction_end":
1553
1717
  this.#endWorkState("compaction");
@@ -1640,7 +1804,7 @@ export class PiEngineAdapter {
1640
1804
  }
1641
1805
  }
1642
1806
  }
1643
- // An authoritative rebuild restates most of what is already there. Reusing the block
1807
+ // Performance: an authoritative rebuild restates most of what is already there. Reusing the block
1644
1808
  // that already says it keeps its revision, and with it the rows the shell rendered for
1645
1809
  // it — otherwise every turn that ends re-renders the whole session.
1646
1810
  this.#setTranscript(blocks.map(block => {
@@ -1667,7 +1831,12 @@ export class PiEngineAdapter {
1667
1831
  revision: this.#nextBlockRevision(baseId),
1668
1832
  title: "User",
1669
1833
  text: textFromContent(message.content),
1670
- payload: { role: "user", imageCount: contentImageCount(message.content) },
1834
+ imageReferences: this.#imageReferences(message.content, "user"),
1835
+ payload: {
1836
+ role: "user",
1837
+ imageCount: contentImageCount(message.content),
1838
+ timestamp: typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : null,
1839
+ },
1671
1840
  }];
1672
1841
  }
1673
1842
  if (message.role === "bashExecution") {
@@ -1740,6 +1909,7 @@ export class PiEngineAdapter {
1740
1909
  revision: this.#nextBlockRevision(blockId),
1741
1910
  title: stringValue(message.toolName) ?? existing?.title ?? "Tool result",
1742
1911
  text: textFromContent(message.content),
1912
+ imageReferences: this.#imageReferences(message.content, "tool-result"),
1743
1913
  payload: {
1744
1914
  ...(existingPayload ?? {}),
1745
1915
  role: "toolResult",
@@ -1795,6 +1965,48 @@ export class PiEngineAdapter {
1795
1965
  }
1796
1966
  return blocks;
1797
1967
  }
1968
+ #imageReferences(content, source) {
1969
+ if (!Array.isArray(content))
1970
+ return [];
1971
+ const references = [];
1972
+ for (const item of content) {
1973
+ if (references.length >= 16 || !isRecord(item) || item.type !== "image"
1974
+ || typeof item.data !== "string" || item.data.length === 0
1975
+ || typeof item.mimeType !== "string" || !/^image\/[a-z0-9.+-]+$/i.test(item.mimeType))
1976
+ continue;
1977
+ const byteLength = Buffer.from(item.data, "base64").byteLength;
1978
+ if (byteLength < 1 || byteLength > 20 * 1024 * 1024)
1979
+ continue;
1980
+ const assetId = `image-${createHash("sha256").update(item.mimeType).update("\0").update(item.data).digest("hex").slice(0, 24)}`;
1981
+ this.#transcriptImageAssets.set(assetId, { type: "image", data: item.data, mimeType: item.mimeType });
1982
+ references.push({ assetId, mimeType: item.mimeType, byteLength, source });
1983
+ }
1984
+ return references;
1985
+ }
1986
+ // Performance: coalescing each tool to its newest chunk bounds work by frames, not stream events.
1987
+ #coalesceToolExecutionUpdate(event) {
1988
+ const toolCallId = stringValue(event.toolCallId);
1989
+ if (!toolCallId)
1990
+ return;
1991
+ this.#pendingToolUpdates.set(toolCallId, event);
1992
+ this.#toolUpdateFlush ??= setTimeout(() => {
1993
+ this.#toolUpdateFlush = null;
1994
+ if (!this.#disposed)
1995
+ this.#flushPendingToolUpdates();
1996
+ }, TOOL_UPDATE_COALESCE_MS);
1997
+ }
1998
+ #flushPendingToolUpdates() {
1999
+ if (this.#toolUpdateFlush !== null) {
2000
+ clearTimeout(this.#toolUpdateFlush);
2001
+ this.#toolUpdateFlush = null;
2002
+ }
2003
+ if (this.#pendingToolUpdates.size === 0)
2004
+ return;
2005
+ const pending = [...this.#pendingToolUpdates.values()];
2006
+ this.#pendingToolUpdates.clear();
2007
+ for (const update of pending)
2008
+ this.#upsertToolExecutionBlock(update);
2009
+ }
1798
2010
  #upsertToolExecutionBlock(event) {
1799
2011
  const toolCallId = stringValue(event.toolCallId);
1800
2012
  if (!toolCallId)
@@ -1814,7 +2026,9 @@ export class PiEngineAdapter {
1814
2026
  toolCallId,
1815
2027
  toolName: stringValue(event.toolName) ?? "unknown",
1816
2028
  arguments: jsonSummary(event.args),
1817
- result: jsonSummary(source),
2029
+ // Performance: a partial result repeats the whole accumulated output on every chunk;
2030
+ // summarizing it each time would cost quadratic work over the stream.
2031
+ result: ended ? jsonSummary(source) : { summary: "", json: null },
1818
2032
  partialResult: event.type === "tool_execution_update",
1819
2033
  argsComplete: ended,
1820
2034
  isError: event.isError === true,
@@ -1825,7 +2039,7 @@ export class PiEngineAdapter {
1825
2039
  const index = this.#transcriptIndex.get(block.id);
1826
2040
  if (index !== undefined) {
1827
2041
  const existing = this.#transcript[index];
1828
- // Nothing to tell the shell about a block that repeats itself, and keeping the
2042
+ // Performance: nothing is emitted for a block that repeats itself, and keeping the
1829
2043
  // revision keeps the rows it already rendered.
1830
2044
  if (existing !== undefined && sameBlockContent(existing, block))
1831
2045
  return;
@@ -1897,6 +2111,7 @@ export class PiEngineAdapter {
1897
2111
  this.#emitEvent({ type: "diagnostic", diagnostic });
1898
2112
  }
1899
2113
  #emitView() {
2114
+ this.#usageCache = undefined;
1900
2115
  this.#viewRevision += 1;
1901
2116
  this.#emitEvent({ type: "session-view", view: this.view() });
1902
2117
  }
@@ -1941,7 +2156,7 @@ export class PiEngineAdapter {
1941
2156
  }
1942
2157
  }
1943
2158
  deliveredSinceYield += 1;
1944
- // A microtask chain runs to exhaustion before the loop turns, so a streaming
2159
+ // Concurrency: a microtask chain runs to exhaustion before the loop turns, so a streaming
1945
2160
  // burst would hold typed input, pointer reports, and timed indicators until it
1946
2161
  // drained. Yielding on a macrotask hands those their turn between batches.
1947
2162
  if (deliveredSinceYield >= EVENT_DELIVERY_BATCH && this.#eventQueue.length > 0) {
@@ -1985,7 +2200,12 @@ export async function createPiEngineAdapter(options = {}) {
1985
2200
  return adapter;
1986
2201
  }
1987
2202
  async function createDefaultPiRuntime(input) {
1988
- return createPiRuntimeIntegration({ cwd: input.cwd, agentDir: input.agentDir });
2203
+ return createPiRuntimeIntegration({
2204
+ cwd: input.cwd,
2205
+ agentDir: input.agentDir,
2206
+ ...(input.sessionPath === undefined ? {} : { sessionPath: input.sessionPath }),
2207
+ ...(input.projectTrustPrompt === undefined ? {} : { projectTrustPrompt: input.projectTrustPrompt }),
2208
+ });
1989
2209
  }
1990
2210
  async function checkDefaultPiPackageUpdates(cwd, agentDir, settingsManager) {
1991
2211
  const packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });
@@ -2211,7 +2431,7 @@ function settingKeyForCallback(callback) {
2211
2431
  onAutoCompactChange: "autoCompact", onShowImagesChange: "showImages", onImageWidthCellsChange: "imageWidthCells",
2212
2432
  onAutoResizeImagesChange: "autoResizeImages", onBlockImagesChange: "blockImages", onEnableSkillCommandsChange: "enableSkillCommands",
2213
2433
  onSteeringModeChange: "steeringMode", onFollowUpModeChange: "followUpMode", onTransportChange: "transport",
2214
- onHttpIdleTimeoutMsChange: "httpIdleTimeoutMs", onThemeChange: "theme", onThemePreview: "theme",
2434
+ onHttpIdleTimeoutMsChange: "httpIdleTimeoutMs", onThinkingLevelChange: "thinkingLevel", onThemeChange: "theme", onThemePreview: "theme",
2215
2435
  onHideThinkingBlockChange: "hideThinkingBlock", onMermaidRenderingModeChange: "mermaidRenderingMode",
2216
2436
  onShowCacheMissNoticesChange: "showCacheMissNotices", onCollapseChangelogChange: "collapseChangelog",
2217
2437
  onEnableInstallTelemetryChange: "enableInstallTelemetry", onQuietStartupChange: "quietStartup",
@@ -2412,7 +2632,8 @@ function sameBlockContent(left, right) {
2412
2632
  && left.status === right.status
2413
2633
  && left.title === right.title
2414
2634
  && left.text === right.text
2415
- && sameValue(left.payload, right.payload);
2635
+ && sameValue(left.payload, right.payload)
2636
+ && sameValue(left.imageReferences ?? [], right.imageReferences ?? []);
2416
2637
  }
2417
2638
  function sameValue(left, right) {
2418
2639
  if (left === right)