@timurproko/a1 0.1.8-dev.472 → 0.1.8-dev.508

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/bin/cli.js +4 -5
  2. package/bin/guardian.js +5 -1
  3. package/bin/module-identity.js +53 -98
  4. package/bin/module-resolver.js +138 -0
  5. package/bin/pinned-pi-public.js +25 -6
  6. package/bin/ui.js +7 -2
  7. package/bin/update-recovery.js +76 -7
  8. package/bin/warmup.js +3 -0
  9. package/dist/{integrations/pi/session-ui → app/session-shell}/clipboard-diagnostics.d.ts +1 -1
  10. package/dist/{integrations/pi/session-ui → app/session-shell}/clipboard-image.js +1 -1
  11. package/dist/app/session-shell/helper-pool.d.ts +33 -0
  12. package/dist/app/session-shell/helper-pool.js +98 -0
  13. package/dist/{integrations/pi/session-ui → app/session-shell}/image-preparation-client.d.ts +1 -1
  14. package/dist/{integrations/pi/session-ui → app/session-shell}/image-preparation-client.js +1 -1
  15. package/dist/{integrations/pi/session-ui → app/session-shell}/image-preparation.js +1 -1
  16. package/dist/{integrations/pi/session-ui → app/session-shell}/image-source.js +1 -1
  17. package/dist/{integrations/pi/session-ui → app/session-shell}/image-worker.js +1 -1
  18. package/dist/app/session-shell/index.d.ts +7 -0
  19. package/dist/app/session-shell/index.js +4 -0
  20. package/dist/app/session-shell/paste-executor.d.ts +18 -0
  21. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-executor.js +50 -29
  22. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-helper.js +1 -1
  23. package/dist/app/session-shell/paste-preparation-client.d.ts +31 -0
  24. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-preparation-client.js +19 -8
  25. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-protocol.d.ts +1 -1
  26. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-protocol.js +1 -1
  27. package/dist/app/session-shell/paste-text-preparation.d.ts +6 -0
  28. package/dist/{integrations/pi/session-ui/paste-text-preparation.d.ts → app/session-shell/paste-types.d.ts} +1 -4
  29. package/dist/{integrations/pi/session-ui → app/session-shell}/path-chip-presentation.d.ts +1 -1
  30. package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-chips.d.ts +5 -1
  31. package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-chips.js +6 -2
  32. package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-history-controller.d.ts +2 -2
  33. package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-history-controller.js +2 -2
  34. package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-suggestion-controller.d.ts +1 -1
  35. package/dist/{integrations/pi/session-ui → app/session-shell}/prompt-suggestion-controller.js +2 -2
  36. package/dist/{integrations/pi/session-ui → app/session-shell}/quit-outro.js +1 -1
  37. package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-coordinator.d.ts +1 -1
  38. package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-coordinator.js +3 -5
  39. package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-helper.js +1 -1
  40. package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-protocol.d.ts +1 -1
  41. package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-transport.d.ts +10 -2
  42. package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-transport.js +45 -19
  43. package/dist/{integrations/pi/session-ui → app/session-shell}/session-shell-root.d.ts +75 -53
  44. package/dist/{integrations/pi/session-ui → app/session-shell}/session-shell-root.js +30 -20
  45. package/dist/{integrations/pi/session-ui → app/session-shell}/session-shell.d.ts +9 -8
  46. package/dist/{integrations/pi/session-ui → app/session-shell}/session-shell.js +108 -67
  47. package/dist/{integrations/pi/session-ui → app/session-shell}/session-viewport-controller.d.ts +5 -5
  48. package/dist/{integrations/pi/session-ui → app/session-shell}/session-viewport-controller.js +5 -5
  49. package/dist/{integrations/pi/session-ui → app/session-shell}/system-clipboard.d.ts +1 -1
  50. package/dist/{integrations/pi/session-ui → app/session-shell}/system-clipboard.js +1 -1
  51. package/dist/cli/index.d.ts +8 -5
  52. package/dist/cli/index.js +4 -5
  53. package/dist/composition/index.d.ts +0 -1
  54. package/dist/composition/index.js +0 -1
  55. package/dist/composition/owned-ui.d.ts +2 -2
  56. package/dist/composition/owned-ui.js +35 -36
  57. package/dist/composition/settings-route-host.d.ts +2 -2
  58. package/dist/contracts/agent-engine/domain.d.ts +6 -1
  59. package/dist/contracts/agent-engine/index.d.ts +11 -8
  60. package/dist/contracts/agent-engine/index.js +6 -8
  61. package/dist/contracts/owned-ui/extension-ui.d.ts +8 -0
  62. package/dist/contracts/owned-ui/index.d.ts +12 -8
  63. package/dist/contracts/owned-ui/index.js +8 -8
  64. package/dist/features/launch/index.d.ts +12 -6
  65. package/dist/features/launch/index.js +6 -6
  66. package/dist/features/launch/intent.d.ts +5 -5
  67. package/dist/features/launch/intent.js +2 -2
  68. package/dist/features/owned-ui/index.d.ts +6 -6
  69. package/dist/features/owned-ui/index.js +4 -6
  70. package/dist/features/owned-ui/run.d.ts +2 -2
  71. package/dist/features/owned-ui/settings-app.d.ts +2 -2
  72. package/dist/features/owned-ui/settings-app.js +18 -5
  73. package/dist/features/prompt-history/service.d.ts +1 -1
  74. package/dist/features/prompt-history/service.js +1 -1
  75. package/dist/features/prompt-history/store.js +3 -7
  76. package/dist/features/prompt-suggestions/diagnostics.js +1 -1
  77. package/dist/features/prompt-suggestions/index.d.ts +2 -1
  78. package/dist/features/prompt-suggestions/index.js +1 -1
  79. package/dist/foundation/launch-guardian/index.d.ts +2 -1
  80. package/dist/foundation/launch-guardian/index.js +1 -1
  81. package/dist/foundation/lifecycle/index.d.ts +11 -6
  82. package/dist/foundation/lifecycle/index.js +5 -6
  83. package/dist/foundation/process-containment/index.d.ts +8 -6
  84. package/dist/foundation/process-containment/index.js +6 -6
  85. package/dist/foundation/process-containment/native-guardian-containment.js +3 -3
  86. package/dist/foundation/protocol/index.d.ts +3 -2
  87. package/dist/foundation/protocol/index.js +2 -2
  88. package/dist/foundation/release/bootstrap.d.ts +0 -4
  89. package/dist/foundation/release/bootstrap.js +1 -82
  90. package/dist/foundation/release/dependency-layer.d.ts +2 -5
  91. package/dist/foundation/release/endpoints.d.ts +4 -0
  92. package/dist/foundation/release/endpoints.js +86 -2
  93. package/dist/foundation/release/index.d.ts +30 -16
  94. package/dist/foundation/release/index.js +16 -16
  95. package/dist/foundation/release/release.d.ts +1 -1
  96. package/dist/foundation/release/types.d.ts +11 -0
  97. package/dist/foundation/release/types.js +1 -0
  98. package/dist/foundation/release/update-transaction.d.ts +1 -1
  99. package/dist/foundation/release/update.d.ts +2 -1
  100. package/dist/foundation/release/update.js +3 -18
  101. package/dist/foundation/startup/index.d.ts +4 -2
  102. package/dist/foundation/startup/index.js +2 -2
  103. package/dist/foundation/startup/startup-descriptor.js +2 -2
  104. package/dist/foundation/storage/control-store.d.ts +1 -45
  105. package/dist/foundation/storage/control-store.js +54 -277
  106. package/dist/foundation/storage/index.d.ts +1 -1
  107. package/dist/foundation/storage/index.js +1 -1
  108. package/dist/foundation/supervision/index.d.ts +2 -2
  109. package/dist/foundation/supervision/index.js +2 -2
  110. package/dist/foundation/supervision/server.d.ts +5 -10
  111. package/dist/foundation/supervision/server.js +7 -7
  112. package/dist/foundation/terminal-cleanup/index.d.ts +3 -2
  113. package/dist/foundation/terminal-cleanup/index.js +2 -2
  114. package/dist/integrations/pi/components/editor-interaction.d.ts +1 -1
  115. package/dist/integrations/pi/components/history-editor-loader.d.ts +1 -1
  116. package/dist/integrations/pi/components/index.d.ts +20 -13
  117. package/dist/integrations/pi/components/index.js +12 -13
  118. package/dist/integrations/pi/components/owned-editor-ux.js +5 -8
  119. package/dist/integrations/pi/components/resources/builtin-themes.d.ts +7 -5
  120. package/dist/integrations/pi/components/resources/builtin-themes.js +7 -5
  121. package/dist/integrations/pi/components/shell-editor-autocomplete.js +1 -1
  122. package/dist/integrations/pi/components/shell-extension-ui.js +2 -1
  123. package/dist/integrations/pi/components/shell-footer-status.js +1 -1
  124. package/dist/integrations/pi/components/shell-presenters-info.d.ts +1 -1
  125. package/dist/integrations/pi/components/shell-presenters-info.js +1 -1
  126. package/dist/integrations/pi/components/shell-presenters-transcript.js +1 -1
  127. package/dist/integrations/pi/components/shell-selectors-dialogs.d.ts +9 -3
  128. package/dist/integrations/pi/components/shell-selectors-dialogs.js +9 -6
  129. package/dist/integrations/pi/components/shell-shared-facade.d.ts +3 -1
  130. package/dist/integrations/pi/components/shell-shared-facade.js +4 -2
  131. package/dist/integrations/pi/components/submitted-prompt-adapter.d.ts +1 -1
  132. package/dist/integrations/pi/components/submitted-prompt-adapter.js +1 -1
  133. package/dist/integrations/pi/components/tool-image-presentation.d.ts +1 -1
  134. package/dist/integrations/pi/components/tool-image-presentation.js +4 -7
  135. package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.d.ts +36 -22
  136. package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.js +43 -7
  137. package/dist/integrations/pi/components/upstream/assets/earendil-image.json +2 -2
  138. package/dist/integrations/pi/components/upstream/components/countdown-timer.d.ts +6 -3
  139. package/dist/integrations/pi/components/upstream/components/daxnuts.d.ts +8 -1
  140. package/dist/integrations/pi/components/upstream/components/daxnuts.js +7 -3
  141. package/dist/integrations/pi/components/upstream/components/earendil-announcement.d.ts +1 -1
  142. package/dist/integrations/pi/components/upstream/components/earendil-announcement.js +10 -4
  143. package/dist/integrations/pi/components/upstream/components/extension-editor.d.ts +7 -4
  144. package/dist/integrations/pi/components/upstream/components/extension-editor.js +7 -4
  145. package/dist/integrations/pi/components/upstream/components/mermaid.js +8 -4
  146. package/dist/integrations/pi/components/upstream/components/owned-editor.d.ts +9 -5
  147. package/dist/integrations/pi/components/upstream/components/owned-editor.js +10 -6
  148. package/dist/integrations/pi/components/upstream/components/scoped-models-selector.d.ts +8 -4
  149. package/dist/integrations/pi/components/upstream/components/scoped-models-selector.js +27 -25
  150. package/dist/integrations/pi/components/upstream/components/session-footer.d.ts +1 -1
  151. package/dist/integrations/pi/components/upstream/components/session-footer.js +8 -10
  152. package/dist/integrations/pi/components/upstream/components/session-selector-search.js +6 -4
  153. package/dist/integrations/pi/components/upstream/components/session-selector.d.ts +1 -1
  154. package/dist/integrations/pi/components/upstream/components/session-selector.js +8 -4
  155. package/dist/integrations/pi/components/upstream/components/skill-invocation-message.d.ts +7 -5
  156. package/dist/integrations/pi/components/upstream/components/skill-invocation-message.js +8 -6
  157. package/dist/integrations/pi/components/upstream/components/status-indicator.d.ts +9 -4
  158. package/dist/integrations/pi/components/upstream/components/status-indicator.js +15 -5
  159. package/dist/integrations/pi/components/upstream/components/tool-execution.d.ts +8 -2
  160. package/dist/integrations/pi/components/upstream/components/tool-execution.js +58 -37
  161. package/dist/integrations/pi/components/upstream/components/tree-selector.d.ts +7 -4
  162. package/dist/integrations/pi/components/upstream/components/tree-selector.js +7 -4
  163. package/dist/integrations/pi/components/upstream/components/trust-selector.d.ts +1 -1
  164. package/dist/integrations/pi/components/upstream/components/trust-selector.js +10 -5
  165. package/dist/integrations/pi/components/upstream/external-editor.js +8 -4
  166. package/dist/integrations/pi/components/upstream/history/editor-core.d.ts +13 -4
  167. package/dist/integrations/pi/components/upstream/history/editor-core.js +112 -30
  168. package/dist/integrations/pi/components/upstream/history/kill-ring.d.ts +6 -3
  169. package/dist/integrations/pi/components/upstream/history/kill-ring.js +6 -3
  170. package/dist/integrations/pi/components/upstream/history/printable-key.js +7 -4
  171. package/dist/integrations/pi/components/upstream/history/text-helpers.js +6 -3
  172. package/dist/integrations/pi/components/upstream/history/undo-stack.d.ts +6 -3
  173. package/dist/integrations/pi/components/upstream/history/undo-stack.js +6 -3
  174. package/dist/integrations/pi/components/upstream/history/word-navigation.js +6 -3
  175. package/dist/integrations/pi/components/upstream/model-search.d.ts +5 -2
  176. package/dist/integrations/pi/components/upstream/theme/theme-controller.d.ts +8 -0
  177. package/dist/integrations/pi/components/upstream/theme/theme-controller.js +0 -3
  178. package/dist/integrations/pi/components/upstream/theme/theme.d.ts +2 -2
  179. package/dist/integrations/pi/components/upstream/theme/theme.js +17 -6
  180. package/dist/integrations/pi/engine/adapter.d.ts +39 -138
  181. package/dist/integrations/pi/engine/adapter.js +338 -3226
  182. package/dist/integrations/pi/engine/command-dispatch.d.ts +41 -0
  183. package/dist/integrations/pi/engine/command-dispatch.js +125 -0
  184. package/dist/integrations/pi/engine/event-delivery.d.ts +100 -0
  185. package/dist/integrations/pi/engine/event-delivery.js +184 -0
  186. package/dist/integrations/pi/engine/extension-ui-binding.d.ts +35 -0
  187. package/dist/integrations/pi/engine/extension-ui-binding.js +81 -0
  188. package/dist/integrations/pi/engine/index.d.ts +18 -14
  189. package/dist/integrations/pi/engine/index.js +10 -14
  190. package/dist/integrations/pi/engine/message-values.d.ts +29 -0
  191. package/dist/integrations/pi/engine/message-values.js +168 -0
  192. package/dist/integrations/pi/engine/pending-delivery.d.ts +2 -2
  193. package/dist/integrations/pi/engine/pending-delivery.js +2 -4
  194. package/dist/integrations/pi/engine/pi-settings-metadata.json +382 -371
  195. package/dist/integrations/pi/engine/prompt-suggestions.d.ts +30 -0
  196. package/dist/integrations/pi/engine/prompt-suggestions.js +102 -0
  197. package/dist/integrations/pi/engine/provider-authentication.d.ts +34 -0
  198. package/dist/integrations/pi/engine/provider-authentication.js +209 -0
  199. package/dist/integrations/pi/engine/resource-catalog.d.ts +49 -0
  200. package/dist/integrations/pi/engine/resource-catalog.js +289 -0
  201. package/dist/integrations/pi/engine/resources/changelog.json +4 -4
  202. package/dist/integrations/pi/engine/session-events.d.ts +48 -0
  203. package/dist/integrations/pi/engine/session-events.js +223 -0
  204. package/dist/integrations/pi/engine/session-integration.js +2 -4
  205. package/dist/integrations/pi/engine/session-runtime.d.ts +84 -0
  206. package/dist/integrations/pi/engine/session-runtime.js +249 -0
  207. package/dist/integrations/pi/engine/{settings-effects.d.ts → settings-bridge.d.ts} +57 -2
  208. package/dist/integrations/pi/engine/settings-bridge.js +514 -0
  209. package/dist/integrations/pi/engine/settings-metadata.d.ts +31 -0
  210. package/dist/integrations/pi/engine/settings-metadata.js +67 -0
  211. package/dist/integrations/pi/engine/settings-port.d.ts +42 -0
  212. package/dist/integrations/pi/engine/settings-port.js +353 -0
  213. package/dist/integrations/pi/engine/transcript-projection.d.ts +39 -0
  214. package/dist/integrations/pi/engine/transcript-projection.js +405 -0
  215. package/dist/integrations/pi/engine/usage-view.d.ts +4 -0
  216. package/dist/integrations/pi/engine/usage-view.js +56 -0
  217. package/dist/integrations/pi/engine/workflow-contexts.d.ts +59 -0
  218. package/dist/integrations/pi/engine/workflow-contexts.js +316 -0
  219. package/dist/integrations/pi/engine/workflow-runner.d.ts +60 -0
  220. package/dist/integrations/pi/engine/workflow-runner.js +509 -0
  221. package/dist/integrations/pi/engine/workflow-support.d.ts +33 -0
  222. package/dist/integrations/pi/engine/workflow-support.js +352 -0
  223. package/dist/integrations/pi/engine/workflows.d.ts +63 -2
  224. package/dist/integrations/pi/engine/workflows.js +5 -2
  225. package/dist/integrations/pi/startup-public.js +576 -554
  226. package/dist/integrations/pi/startup-public.manifest.json +1730 -984
  227. package/dist/integrations/pi/tui-runtime/adapter.js +10 -13
  228. package/dist/integrations/pi/tui-runtime/contracts.d.ts +11 -1
  229. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +1 -1
  230. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.js +4 -7
  231. package/dist/integrations/pi/tui-runtime/index.d.ts +8 -6
  232. package/dist/integrations/pi/tui-runtime/index.js +4 -6
  233. package/dist/integrations/pi/tui-runtime/mouse-report-input.js +2 -4
  234. package/dist/integrations/pi/tui-runtime/overlay-geometry.d.ts +2 -2
  235. package/dist/integrations/pi/tui-runtime/overlay-geometry.js +4 -5
  236. package/dist/integrations/pi/tui-runtime/presentation-adapter.js +1 -1
  237. package/dist/native/darwin-arm64/manifest.json +1 -1
  238. package/dist/native/linux-x64/manifest.json +1 -1
  239. package/dist/native/win32-x64/manifest.json +2 -2
  240. package/dist/native/win32-x64/process-guardian.exe +0 -0
  241. package/dist/runtime-payload-inventory.json +51320 -46509
  242. package/dist/ui/apps/index.d.ts +5 -3
  243. package/dist/ui/apps/index.js +3 -3
  244. package/dist/ui/components/index.d.ts +47 -25
  245. package/dist/ui/components/index.js +25 -25
  246. package/dist/ui/components/prompt-input.js +1 -4
  247. package/dist/ui/settings/declarations.d.ts +119 -0
  248. package/dist/ui/settings/declarations.js +20 -11
  249. package/dist/ui/settings/index.d.ts +10 -6
  250. package/dist/ui/settings/index.js +5 -6
  251. package/dist/ui/settings/manager.d.ts +54 -0
  252. package/dist/ui/settings/{session.js → manager.js} +101 -9
  253. package/dist/ui/settings/sections.d.ts +2 -7
  254. package/docs/architecture/boundaries.md +4 -4
  255. package/docs/architecture/history-editor-provenance.md +1 -1
  256. package/docs/architecture/project-structure.md +6 -6
  257. package/docs/architecture/prompt-suggestions.md +1 -1
  258. package/docs/architecture/terminal-host-proof-gate.md +1 -1
  259. package/docs/architecture/terminal-host-spike-evidence.md +1 -1
  260. package/docs/architecture/toolchain.md +8 -0
  261. package/docs/architecture/ui-reference-provenance.md +4 -4
  262. package/docs/ci-release-runbook.md +7 -1
  263. package/docs/features/modal-content-interaction.md +2 -2
  264. package/docs/local-worktree-cleanup.md +4 -2
  265. package/docs/validation.md +6 -4
  266. package/package.json +7 -11
  267. package/bin/pi-tui.d.ts +0 -6
  268. package/bin/pi-tui.js +0 -28
  269. package/bin/sync-pi-tui-proxy.js +0 -97
  270. package/dist/cli/version.d.ts +0 -2
  271. package/dist/cli/version.js +0 -23
  272. package/dist/composition/agent-engine-bridge.d.ts +0 -3
  273. package/dist/composition/agent-engine-bridge.js +0 -108
  274. package/dist/composition/process.d.ts +0 -16
  275. package/dist/composition/process.js +0 -45
  276. package/dist/contracts/workspace/index.d.ts +0 -2
  277. package/dist/contracts/workspace/index.js +0 -2
  278. package/dist/contracts/workspace/model.d.ts +0 -248
  279. package/dist/contracts/workspace/model.js +0 -2
  280. package/dist/contracts/workspace/validation.d.ts +0 -13
  281. package/dist/contracts/workspace/validation.js +0 -335
  282. package/dist/features/owned-ui/customization.d.ts +0 -40
  283. package/dist/features/owned-ui/customization.js +0 -110
  284. package/dist/features/owned-ui/diagnostics.d.ts +0 -34
  285. package/dist/features/owned-ui/diagnostics.js +0 -95
  286. package/dist/features/workspace/capabilities.d.ts +0 -31
  287. package/dist/features/workspace/capabilities.js +0 -75
  288. package/dist/features/workspace/index.d.ts +0 -6
  289. package/dist/features/workspace/index.js +0 -6
  290. package/dist/features/workspace/presentation.d.ts +0 -30
  291. package/dist/features/workspace/presentation.js +0 -70
  292. package/dist/features/workspace/reconciliation.d.ts +0 -15
  293. package/dist/features/workspace/reconciliation.js +0 -82
  294. package/dist/features/workspace/reducer.d.ts +0 -43
  295. package/dist/features/workspace/reducer.js +0 -214
  296. package/dist/features/workspace/router.d.ts +0 -32
  297. package/dist/features/workspace/router.js +0 -125
  298. package/dist/features/workspace/store.d.ts +0 -18
  299. package/dist/features/workspace/store.js +0 -55
  300. package/dist/foundation/native-host-protocol/codec.d.ts +0 -13
  301. package/dist/foundation/native-host-protocol/codec.js +0 -58
  302. package/dist/foundation/native-host-protocol/evidence.d.ts +0 -67
  303. package/dist/foundation/native-host-protocol/evidence.js +0 -141
  304. package/dist/foundation/native-host-protocol/index.d.ts +0 -4
  305. package/dist/foundation/native-host-protocol/index.js +0 -4
  306. package/dist/foundation/native-host-protocol/messages.d.ts +0 -56
  307. package/dist/foundation/native-host-protocol/messages.js +0 -149
  308. package/dist/foundation/native-host-protocol/proof-gate.d.ts +0 -13
  309. package/dist/foundation/native-host-protocol/proof-gate.js +0 -33
  310. package/dist/foundation/structured-agent-runtime/backpressure.d.ts +0 -47
  311. package/dist/foundation/structured-agent-runtime/backpressure.js +0 -119
  312. package/dist/foundation/structured-agent-runtime/commands.d.ts +0 -53
  313. package/dist/foundation/structured-agent-runtime/commands.js +0 -165
  314. package/dist/foundation/structured-agent-runtime/handshake.d.ts +0 -41
  315. package/dist/foundation/structured-agent-runtime/handshake.js +0 -151
  316. package/dist/foundation/structured-agent-runtime/index.d.ts +0 -5
  317. package/dist/foundation/structured-agent-runtime/index.js +0 -5
  318. package/dist/foundation/structured-agent-runtime/reconnection.d.ts +0 -38
  319. package/dist/foundation/structured-agent-runtime/reconnection.js +0 -130
  320. package/dist/foundation/structured-agent-runtime/state.d.ts +0 -57
  321. package/dist/foundation/structured-agent-runtime/state.js +0 -119
  322. package/dist/integrations/pi/components/upstream/components/custom-entry.d.ts +0 -17
  323. package/dist/integrations/pi/components/upstream/components/custom-entry.js +0 -51
  324. package/dist/integrations/pi/components/upstream/components/first-time-setup.d.ts +0 -24
  325. package/dist/integrations/pi/components/upstream/components/first-time-setup.js +0 -105
  326. package/dist/integrations/pi/components/upstream/components/markdown-transform.d.ts +0 -2
  327. package/dist/integrations/pi/components/upstream/components/markdown-transform.js +0 -18
  328. package/dist/integrations/pi/engine/model-auth-integration.d.ts +0 -31
  329. package/dist/integrations/pi/engine/model-auth-integration.js +0 -62
  330. package/dist/integrations/pi/engine/resource-extension-integration.d.ts +0 -32
  331. package/dist/integrations/pi/engine/resource-extension-integration.js +0 -81
  332. package/dist/integrations/pi/engine/settings-effects.js +0 -249
  333. package/dist/integrations/pi/engine/settings-integration.d.ts +0 -43
  334. package/dist/integrations/pi/engine/settings-integration.js +0 -227
  335. package/dist/integrations/pi/engine/workflow-controllers.d.ts +0 -21
  336. package/dist/integrations/pi/engine/workflow-controllers.js +0 -49
  337. package/dist/integrations/pi/session-ui/index.d.ts +0 -5
  338. package/dist/integrations/pi/session-ui/index.js +0 -5
  339. package/dist/integrations/pi/session-ui/paste-executor.d.ts +0 -10
  340. package/dist/integrations/pi/session-ui/paste-preparation-client.d.ts +0 -16
  341. package/dist/integrations/pi/session-ui/route-host.d.ts +0 -5
  342. package/dist/integrations/pi/tui-runtime/conformance.d.ts +0 -18
  343. package/dist/integrations/pi/tui-runtime/conformance.js +0 -145
  344. package/dist/ui/components/prompt-row.d.ts +0 -14
  345. package/dist/ui/components/prompt-row.js +0 -20
  346. package/dist/ui/settings/session.d.ts +0 -36
  347. package/dist/ui/settings/store.d.ts +0 -29
  348. package/dist/ui/settings/store.js +0 -91
  349. package/dist/{integrations/pi/session-ui → app/session-shell}/clipboard-diagnostics.js +2 -2
  350. package/dist/{integrations/pi/session-ui → app/session-shell}/clipboard-image.d.ts +0 -0
  351. package/dist/{integrations/pi/session-ui → app/session-shell}/editor-hyperlink-budget.d.ts +0 -0
  352. package/dist/{integrations/pi/session-ui → app/session-shell}/editor-hyperlink-budget.js +0 -0
  353. package/dist/{integrations/pi/session-ui → app/session-shell}/image-preparation.d.ts +0 -0
  354. package/dist/{integrations/pi/session-ui → app/session-shell}/image-source.d.ts +0 -0
  355. package/dist/{integrations/pi/session-ui → app/session-shell}/image-worker.d.ts +0 -0
  356. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-helper.d.ts +0 -0
  357. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-text-preparation.js +0 -0
  358. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-text-worker.d.ts +0 -0
  359. package/dist/{integrations/pi/session-ui → app/session-shell}/paste-text-worker.js +0 -0
  360. package/dist/{integrations/pi/session-ui/response-copy-helper.d.ts → app/session-shell/paste-types.js} +0 -0
  361. package/dist/{integrations/pi/session-ui → app/session-shell}/path-chip-presentation.js +0 -0
  362. package/dist/{integrations/pi/session-ui → app/session-shell}/quit-outro-effects.d.ts +0 -0
  363. package/dist/{integrations/pi/session-ui → app/session-shell}/quit-outro-effects.js +0 -0
  364. package/dist/{integrations/pi/session-ui → app/session-shell}/quit-outro.d.ts +0 -0
  365. package/dist/{integrations/pi/session-ui/route-host.js → app/session-shell/response-copy-helper.d.ts} +0 -0
  366. package/dist/{integrations/pi/session-ui → app/session-shell}/response-copy-protocol.js +0 -0
  367. package/dist/{integrations/pi/session-ui → app/session-shell}/stream-presentation-coalescer.d.ts +0 -0
  368. package/dist/{integrations/pi/session-ui → app/session-shell}/stream-presentation-coalescer.js +3 -3
  369. /package/dist/{integrations/pi/session-ui → app/session-shell}/text-paste.d.ts +0 -0
  370. /package/dist/{integrations/pi/session-ui → app/session-shell}/text-paste.js +0 -0
@@ -1,15 +1,25 @@
1
- import { ImageAttachmentError } from "../../../contracts/owned-ui/index.js";
2
- import { startPasteExecutor } from "./paste-executor.js";
1
+ import { ImageAttachmentError } from "../../contracts/owned-ui/index.js";
2
+ import { createPasteHelperPool, startPasteExecutor } from "./paste-executor.js";
3
3
  import { PASTE_READ_MS, PASTE_REQUESTS, PASTE_STOP_MS, PASTE_TOTAL_MS } from "./paste-protocol.js";
4
4
  /** Keeps eight distinct paste transactions alive through insertion; canceled executors retain capacity until fenced. */
5
5
  export class PastePreparationClient {
6
- onEvent;
7
6
  #active = new Set();
7
+ #onEvent;
8
+ #execute;
9
+ #helper;
10
+ #pool;
8
11
  #sequence = 0;
9
12
  #disposed = false;
10
- constructor(onEvent) {
11
- this.onEvent = onEvent;
13
+ constructor(options = {}) {
14
+ this.#onEvent = options.onEvent;
15
+ this.#execute = options.execute ?? startPasteExecutor;
16
+ this.#helper = options.helper;
17
+ this.#pool = options.execute === undefined ? createPasteHelperPool(options.helper, options.spareIdleMs) : undefined;
12
18
  }
19
+ /** Forks the spare helper now so the first paste takes a live child; later pastes rewarm it themselves. */
20
+ warm() { this.#pool?.warm(); }
21
+ /** Whether a spare helper is held; diagnostics and tests only. */
22
+ get warmed() { return this.#pool?.warmed ?? false; }
13
23
  start(source, adopt, onImage, onText = () => { }) {
14
24
  const controller = new AbortController();
15
25
  const id = ++this.#sequence;
@@ -22,7 +32,7 @@ export class PastePreparationClient {
22
32
  const emit = (phase, bytes, outcome) => {
23
33
  const atMs = performance.now();
24
34
  try {
25
- this.onEvent?.({ request: id, phase, atMs, elapsedMs: atMs - admitted, pending: this.#active.size, transport: source.kind === "text" ? "terminal" : source.kind,
35
+ this.#onEvent?.({ request: id, phase, atMs, elapsedMs: atMs - admitted, pending: this.#active.size, transport: source.kind === "text" ? "terminal" : source.kind,
26
36
  ...(bytes === undefined ? {} : { bytes }), ...(outcome === undefined ? {} : { outcome }) });
27
37
  }
28
38
  catch { /* Invariant: observations never affect input. */ }
@@ -100,7 +110,7 @@ export class PastePreparationClient {
100
110
  }
101
111
  content = read;
102
112
  }
103
- executor = startPasteExecutor(content, controller.signal, (phase, bytes) => {
113
+ executor = this.#execute(content, controller.signal, (phase, bytes) => {
104
114
  // Protocol: helper exit precedes adoption; only the request's finally block reports complete cleanup.
105
115
  if (phase === "cleanup")
106
116
  return;
@@ -113,7 +123,7 @@ export class PastePreparationClient {
113
123
  if (phase === "acquired-text")
114
124
  onText();
115
125
  emit(phase, bytes);
116
- });
126
+ }, this.#helper, this.#pool);
117
127
  const value = await executor.result;
118
128
  if (controller.signal.aborted)
119
129
  return;
@@ -150,6 +160,7 @@ export class PastePreparationClient {
150
160
  async dispose() {
151
161
  this.#disposed = true;
152
162
  this.reset();
163
+ this.#pool?.dispose();
153
164
  let timer;
154
165
  await Promise.race([Promise.all([...this.#active].map(active => active.stopped)),
155
166
  new Promise(resolve => { timer = setTimeout(resolve, PASTE_STOP_MS); timer.unref(); })]);
@@ -1,4 +1,4 @@
1
- import type { PiShellClipboardContent } from "../components/index.js";
1
+ import type { PiShellClipboardContent } from "../../integrations/pi/components/index.js";
2
2
  import type { PreparedPasteText, ClipboardPath } from "./paste-text-preparation.js";
3
3
  import type { PreparedImage } from "./image-preparation.js";
4
4
  export declare const PASTE_READ_MS = 5000;
@@ -1,4 +1,4 @@
1
- import { MAX_CLIPBOARD_TEXT_BYTES } from "../../../contracts/owned-ui/index.js";
1
+ import { MAX_CLIPBOARD_TEXT_BYTES } from "../../contracts/owned-ui/index.js";
2
2
  export const PASTE_READ_MS = 5_000;
3
3
  export const PASTE_TOTAL_MS = 15_000;
4
4
  export const PASTE_STOP_MS = 250;
@@ -0,0 +1,6 @@
1
+ import type { PreparedPasteText } from "./paste-types.js";
2
+ export type { ClipboardPath, PreparedPasteText } from "./paste-types.js";
3
+ /** Small non-path text has a fixed CPU bound and cannot enter filesystem probing. */
4
+ export declare function canPreparePasteInline(text: string): boolean;
5
+ /** The shared chip classifier; interactive callers run path/filesystem probing in an isolated executor. */
6
+ export declare function preparePasteText(text: string, skipPaths?: boolean, compactPaths?: boolean): PreparedPasteText;
@@ -1,3 +1,4 @@
1
+ /** Paste classification results shared by text preparation and path chip presentation. */
1
2
  export interface ClipboardPath {
2
3
  readonly fullPath: string;
3
4
  readonly kind: "folder" | "file";
@@ -14,7 +15,3 @@ export type PreparedPasteText = {
14
15
  readonly kind: "paths";
15
16
  readonly paths: readonly ClipboardPath[];
16
17
  };
17
- /** Small non-path text has a fixed CPU bound and cannot enter filesystem probing. */
18
- export declare function canPreparePasteInline(text: string): boolean;
19
- /** The shared chip classifier; interactive callers run path/filesystem probing in an isolated executor. */
20
- export declare function preparePasteText(text: string, skipPaths?: boolean, compactPaths?: boolean): PreparedPasteText;
@@ -1,4 +1,4 @@
1
- import type { ClipboardPath, PreparedPasteText } from "./paste-text-preparation.js";
1
+ import type { ClipboardPath, PreparedPasteText } from "./paste-types.js";
2
2
  export declare const PATH_CHIP_PRESENTATION_UNITS = 4096;
3
3
  export declare const PATH_CHIP_SUFFIX_UNITS = 20;
4
4
  /** Shared base tag for presentation budgeting and actual chip adoption, including image-file spacing. */
@@ -1,4 +1,5 @@
1
- import type { PiShellClipboardContent, PiShellEditorTextRange } from "../components/shell-shared-facade.js";
1
+ import type { PiShellClipboardContent, PiShellEditorTextRange } from "../../integrations/pi/components/shell-shared-facade.js";
2
+ import { type PastePreparationClientOptions } from "./paste-preparation-client.js";
2
3
  import type { PasteEvent, PasteSource } from "./paste-protocol.js";
3
4
  export interface PromptImageAttachment {
4
5
  readonly type: "image";
@@ -15,7 +16,10 @@ export declare class PromptChipStore {
15
16
  constructor(options?: {
16
17
  readonly isolated?: boolean;
17
18
  readonly onEvent?: (event: PasteEvent) => void;
19
+ readonly preparation?: Omit<PastePreparationClientOptions, "onEvent">;
18
20
  });
21
+ /** Forks the spare paste helper so the session's first paste does not pay for helper startup. */
22
+ warm(): void;
19
23
  beginPaste(currentText: string, read: ((signal: AbortSignal) => Promise<PiShellClipboardContent | null>) | PasteSource, onError: (error: unknown) => void, onImage?: () => void): {
20
24
  marker: string;
21
25
  result: Promise<string>;
@@ -1,7 +1,7 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import path from "node:path";
3
3
  import { canonicalizeClipboardImage } from "./clipboard-image.js";
4
- import { assertImageEncodedSize, assertPromptImages, ImageAttachmentError } from "../../../contracts/owned-ui/image-attachments.js";
4
+ import { assertImageEncodedSize, assertPromptImages, ImageAttachmentError } from "../../contracts/owned-ui/index.js";
5
5
  import { ImagePreparationClient } from "./image-preparation-client.js";
6
6
  import { preparePasteText } from "./paste-text-preparation.js";
7
7
  import { pathChipTag } from "./path-chip-presentation.js";
@@ -26,8 +26,12 @@ export class PromptChipStore {
26
26
  #provisionalOwners = new Map();
27
27
  #ownedChipTags = new Map();
28
28
  constructor(options = {}) {
29
- this.#isolated = options.isolated ? new PastePreparationClient(options.onEvent) : undefined;
29
+ this.#isolated = options.isolated
30
+ ? new PastePreparationClient({ ...options.preparation, ...(options.onEvent === undefined ? {} : { onEvent: options.onEvent }) })
31
+ : undefined;
30
32
  }
33
+ /** Forks the spare paste helper so the session's first paste does not pay for helper startup. */
34
+ warm() { this.#isolated?.warm(); }
31
35
  beginPaste(currentText, read, onError, onImage = () => { }) {
32
36
  if (this.#isolated)
33
37
  return this.#beginIsolatedPaste(currentText, typeof read === "function" ? { kind: "provided", read } : read, onError, onImage);
@@ -1,5 +1,5 @@
1
- import { type PromptHistoryKind, type PromptHistoryPort } from "../../../contracts/owned-ui/index.js";
2
- import type { PiShellEditorPort } from "../components/index.js";
1
+ import { type PromptHistoryKind, type PromptHistoryPort } from "../../contracts/owned-ui/index.js";
2
+ import type { PiShellEditorPort } from "../../integrations/pi/components/index.js";
3
3
  /** Merges bounded recall snapshots; the editor alone owns browsing, draft, cursor, and undo state. */
4
4
  export declare class PromptHistoryController {
5
5
  #private;
@@ -1,8 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { PROMPT_HISTORY_MAX_TEXT_BYTES } from "../../../contracts/owned-ui/index.js";
2
+ import { PROMPT_HISTORY_MAX_TEXT_BYTES } from "../../contracts/owned-ui/index.js";
3
3
  /** Merges bounded recall snapshots; the editor alone owns browsing, draft, cursor, and undo state. */
4
4
  export class PromptHistoryController {
5
- options;
6
5
  #local = new Map();
7
6
  #unsubscribe;
8
7
  #snapshot;
@@ -14,6 +13,7 @@ export class PromptHistoryController {
14
13
  #unsubscribeFailure;
15
14
  #closeFailed = false;
16
15
  #closePromise;
16
+ options;
17
17
  constructor(options) {
18
18
  this.options = options;
19
19
  if (options.editor.recall === undefined)
@@ -1,4 +1,4 @@
1
- import { type OwnedUiPromptSuggestionGeneratorPort, type OwnedUiPromptSuggestionIdentity, type OwnedUiPromptSuggestionState, type SuggestionDecision, type SuggestionDecisionReason, type SuggestionDiagnosticObserver } from "../../../contracts/owned-ui/index.js";
1
+ import { type OwnedUiPromptSuggestionGeneratorPort, type OwnedUiPromptSuggestionIdentity, type OwnedUiPromptSuggestionState, type SuggestionDecision, type SuggestionDecisionReason, type SuggestionDiagnosticObserver } from "../../contracts/owned-ui/index.js";
2
2
  export interface ContextualPromptSuggestionSurface {
3
3
  canPresent(identity: OwnedUiPromptSuggestionIdentity): boolean;
4
4
  presentationBlockReason?(identity: OwnedUiPromptSuggestionIdentity): SuggestionDecision;
@@ -1,7 +1,6 @@
1
- import { assertOwnedUiPromptSuggestionResult, normalizePromptSuggestionCandidate, } from "../../../contracts/owned-ui/index.js";
1
+ import { assertOwnedUiPromptSuggestionResult, normalizePromptSuggestionCandidate, } from "../../contracts/owned-ui/index.js";
2
2
  /** Prefetches one inert candidate; owns retirement even when a provider ignores abort. */
3
3
  export class ContextualPromptSuggestionController {
4
- options;
5
4
  #state = { status: "idle" };
6
5
  #request = null;
7
6
  #lastConsidered = "";
@@ -12,6 +11,7 @@ export class ContextualPromptSuggestionController {
12
11
  #requestSequence = 0;
13
12
  #timeoutMs;
14
13
  #now;
14
+ options;
15
15
  constructor(options) {
16
16
  this.options = options;
17
17
  this.#enabled = options.enabled;
@@ -5,7 +5,7 @@
5
5
  * terminal never shows a half-painted step, and playback is bounded so a slow
6
6
  * terminal cannot delay restoration past the configured clamp.
7
7
  */
8
- import { displayWidth, truncateToWidth } from "../../../ui/components/index.js";
8
+ import { displayWidth, truncateToWidth } from "../../ui/components/index.js";
9
9
  import { createQuitOutroPlan } from "./quit-outro-effects.js";
10
10
  export const QUIT_OUTRO_MIN_MS = 300;
11
11
  export const QUIT_OUTRO_MAX_MS = 2000;
@@ -1,4 +1,4 @@
1
- import { type SelectionCopySnapshot } from "../../../ui/components/selection-copy.js";
1
+ import { type SelectionCopySnapshot } from "../../ui/components/selection-copy.js";
2
2
  import { type CopyResult, type ResponseCopyEvent } from "./response-copy-protocol.js";
3
3
  import type { ResponseCopyExecutor } from "./response-copy-transport.js";
4
4
  /** Owns one delivery and one newest pending copy, including expiry and side-effect fencing. */
@@ -1,8 +1,7 @@
1
- import { MAX_COPY_SOURCE_UNITS } from "../../../ui/components/selection-copy.js";
1
+ import { MAX_COPY_SOURCE_UNITS } from "../../ui/components/selection-copy.js";
2
2
  import { COPY_CLEANUP_MS, COPY_DEADLINE_MS } from "./response-copy-protocol.js";
3
3
  /** Owns one delivery and one newest pending copy, including expiry and side-effect fencing. */
4
4
  export class ResponseCopyCoordinator {
5
- options;
6
5
  #sequence = 0;
7
6
  #epoch = 0;
8
7
  #active;
@@ -11,9 +10,8 @@ export class ResponseCopyCoordinator {
11
10
  #latestPending = false;
12
11
  #disposed = false;
13
12
  #quarantined = false;
14
- constructor(options) {
15
- this.options = options;
16
- }
13
+ options;
14
+ constructor(options) { this.options = options; }
17
15
  get busy() { return this.#active !== undefined || this.#pending !== undefined; }
18
16
  get latest() { return this.#latest; }
19
17
  /** Exact prompt copy/cut shares the write lifetime without transcript text transformations. */
@@ -1,4 +1,4 @@
1
- import { MAX_COPY_ROWS, MAX_COPY_SOURCE_UNITS, selectionCopyRowText } from "../../../ui/components/index.js";
1
+ import { MAX_COPY_ROWS, MAX_COPY_SOURCE_UNITS, selectionCopyRowText } from "../../ui/components/index.js";
2
2
  import { COPY_CHUNK_UNITS, MAX_COPY_BYTES, MAX_COPY_CONTROL_BYTES } from "./response-copy-protocol.js";
3
3
  // Security: this isolated executor never inherits the UI terminal and never logs clipboard contents.
4
4
  let header;
@@ -1,4 +1,4 @@
1
- import type { OrderedTextSelection, SelectionCopyPrompt } from "../../../ui/components/index.js";
1
+ import type { OrderedTextSelection, SelectionCopyPrompt } from "../../ui/components/index.js";
2
2
  export declare const COPY_DEADLINE_MS = 5000;
3
3
  export declare const COPY_CLEANUP_MS = 250;
4
4
  export declare const MAX_COPY_BYTES: number;
@@ -1,4 +1,4 @@
1
- import type { SelectionCopySnapshot } from "../../../ui/components/selection-copy.js";
1
+ import type { SelectionCopySnapshot } from "../../ui/components/selection-copy.js";
2
2
  import { type CopyResult } from "./response-copy-protocol.js";
3
3
  export interface ResponseCopyJob {
4
4
  readonly result: Promise<CopyResult>;
@@ -8,6 +8,12 @@ export interface ResponseCopyJob {
8
8
  }
9
9
  export type CopyPhaseObserver = (phase: "extracted" | "encoded" | "submitting", bytes: number, transport: "native" | "terminal" | "injected") => void;
10
10
  export type ResponseCopyExecutor = (snapshot: SelectionCopySnapshot, phase: CopyPhaseObserver) => ResponseCopyJob;
11
+ /** The production executor also owns a spare helper; the owner warms it at start and disposes it at shutdown. */
12
+ export interface OwnedResponseCopyExecutor extends ResponseCopyExecutor {
13
+ warm(): void;
14
+ dispose(): void;
15
+ readonly warmed: boolean;
16
+ }
11
17
  export interface ResponseCopyTerminal {
12
18
  readonly maxBytes?: number;
13
19
  /** A supported non-blocking submission boundary, not clipboard acknowledgment. */
@@ -28,4 +34,6 @@ export declare function createResponseCopyExecutor(options?: {
28
34
  readonly writeText?: (text: string, signal: AbortSignal) => Promise<void>;
29
35
  /** Package/fault-test seam: the production helper is always an emitted sibling. */
30
36
  readonly helper?: URL;
31
- }): ResponseCopyExecutor;
37
+ /** Idle bound for the spare helper; production keeps the default. */
38
+ readonly spareIdleMs?: number;
39
+ }): OwnedResponseCopyExecutor;
@@ -1,5 +1,6 @@
1
1
  import { fork } from "node:child_process";
2
2
  import { fstatSync } from "node:fs";
3
+ import { HelperPool } from "./helper-pool.js";
3
4
  import { COPY_CHUNK_UNITS, COPY_CLEANUP_MS, MAX_COPY_BYTES, MAX_COPY_CONTROL_BYTES } from "./response-copy-protocol.js";
4
5
  /** Never substitute a remote host's native clipboard for the terminal user's clipboard. */
5
6
  export function responseCopyDestination(env) {
@@ -22,7 +23,8 @@ export function hasAsyncClipboardOutput(platform = process.platform, stdout = pr
22
23
  }
23
24
  /** Isolates preparation and native clipboard access; only the owner may submit terminal controls. */
24
25
  export function createResponseCopyExecutor(options = {}) {
25
- return (snapshot, phase) => {
26
+ const pool = new HelperPool({ fork: () => forkCopyHelper(options.helper), stop: stopCopyHelper, ...(options.spareIdleMs === undefined ? {} : { idleMs: options.spareIdleMs }) });
27
+ const execute = (snapshot, phase) => {
26
28
  const controller = new AbortController();
27
29
  let active;
28
30
  const run = async () => {
@@ -33,7 +35,7 @@ export function createResponseCopyExecutor(options = {}) {
33
35
  if (mode === "terminal" && options.terminal === undefined) {
34
36
  return { kind: "result", result: { outcome: "failed", failure: "unsafe" } };
35
37
  }
36
- active = startHelper(snapshot, mode, options.terminal?.maxBytes ?? MAX_COPY_CONTROL_BYTES, phase, options.helper);
38
+ active = startHelper(snapshot, mode, options.terminal?.maxBytes ?? MAX_COPY_CONTROL_BYTES, phase, options.helper, pool);
37
39
  if (controller.signal.aborted)
38
40
  active.cancel();
39
41
  return active.result;
@@ -65,6 +67,28 @@ export function createResponseCopyExecutor(options = {}) {
65
67
  const result = run().catch(() => ({ outcome: controller.signal.aborted ? "canceled" : "failed", failure: "transport" }));
66
68
  return { result, stopped: result.then(() => { }), cancel: () => { controller.abort(); active?.cancel(); } };
67
69
  };
70
+ // Rationale: `Object.assign` would copy the getter's value once; the accessor must read the pool each time.
71
+ return Object.defineProperties(execute, {
72
+ warm: { value: () => pool.warm() },
73
+ dispose: { value: () => pool.dispose() },
74
+ warmed: { get: () => pool.warmed },
75
+ });
76
+ }
77
+ /** Forks one copy helper: bounded IPC only, no clipboard payload in argv or temp files, no inherited terminal descriptors. */
78
+ function forkCopyHelper(helper) {
79
+ const source = new URL(import.meta.url).pathname.endsWith(".ts");
80
+ const entry = helper ?? new URL(source ? "./response-copy-helper.ts" : "./response-copy-helper.js", import.meta.url);
81
+ const forkOptions = {
82
+ execArgv: entry.pathname.endsWith(".ts") ? ["--import", "tsx"] : [],
83
+ stdio: ["ignore", "ignore", "ignore", "ipc"], windowsHide: true,
84
+ serialization: "json",
85
+ };
86
+ return fork(entry, [], forkOptions);
87
+ }
88
+ function stopCopyHelper(child) {
89
+ child.kill("SIGKILL");
90
+ child.unref();
91
+ child.channel?.unref();
68
92
  }
69
93
  function* sourceMessages(snapshot, mode, controlLimit) {
70
94
  yield { kind: "begin", selection: snapshot.selection, rows: snapshot.rows.length, mode, controlLimit,
@@ -77,16 +101,10 @@ function* sourceMessages(snapshot, mode, controlLimit) {
77
101
  }
78
102
  yield { kind: "finish" };
79
103
  }
80
- function startHelper(snapshot, mode, controlLimit, phase, helper) {
81
- const source = new URL(import.meta.url).pathname.endsWith(".ts");
82
- const entry = helper ?? new URL(source ? "./response-copy-helper.ts" : "./response-copy-helper.js", import.meta.url);
83
- // Security: bounded IPC only, no clipboard payload in argv/temp files, and no inherited terminal descriptors.
84
- const forkOptions = {
85
- execArgv: entry.pathname.endsWith(".ts") ? ["--import", "tsx"] : [],
86
- stdio: ["ignore", "ignore", "ignore", "ipc"], windowsHide: true,
87
- serialization: "json",
88
- };
89
- const child = fork(entry, [], forkOptions);
104
+ function startHelper(snapshot, mode, controlLimit, phase, helper, pool) {
105
+ // Performance: a warm spare skips fork and module load on the copy's own critical path.
106
+ const spare = pool.take();
107
+ const child = spare?.child ?? forkCopyHelper(helper);
90
108
  let iterator = sourceMessages(snapshot, mode, controlLimit);
91
109
  let outcome;
92
110
  let stopping = false;
@@ -123,18 +141,21 @@ function startHelper(snapshot, mode, controlLimit, phase, helper) {
123
141
  resolve(value);
124
142
  prepared = [];
125
143
  };
144
+ const advance = () => {
145
+ const next = iterator?.next();
146
+ if (next === undefined || next.done) {
147
+ cancel();
148
+ return;
149
+ }
150
+ child.send(next.value, error => { if (error)
151
+ cancel(); });
152
+ };
126
153
  child.on("message", value => {
127
154
  const message = value;
128
155
  if (stopping)
129
156
  return;
130
157
  if (message?.kind === "ready") {
131
- const next = iterator?.next();
132
- if (next === undefined || next.done) {
133
- cancel();
134
- return;
135
- }
136
- child.send(next.value, error => { if (error)
137
- cancel(); });
158
+ advance();
138
159
  }
139
160
  else if (message?.kind === "data") {
140
161
  if (mode !== "prepare" || expectedBytes === undefined || typeof message.text !== "string" || message.text.length > COPY_CHUNK_UNITS) {
@@ -178,6 +199,8 @@ function startHelper(snapshot, mode, controlLimit, phase, helper) {
178
199
  clearTimeout(cleanup);
179
200
  child.removeAllListeners("message");
180
201
  settle();
202
+ // Performance: the next copy finds a spare that was forked while nothing waited on it.
203
+ pool.replenish();
181
204
  });
182
205
  // Platform: spawn failure has no exit event, but has a close event and no live executor to fence.
183
206
  child.once("close", () => {
@@ -186,6 +209,9 @@ function startHelper(snapshot, mode, controlLimit, phase, helper) {
186
209
  clearTimeout(cleanup);
187
210
  settle();
188
211
  });
212
+ // Protocol: a spare already announced itself while pooled, so its first request is sent now rather than on "ready".
213
+ if (spare?.ready)
214
+ advance();
189
215
  });
190
216
  return { result, cancel };
191
217
  }
@@ -1,13 +1,14 @@
1
- import type { OwnedUiPromptSuggestionGeneratorPort, OwnedUiSessionViewModel, OwnedUiViewportSettings, OwnedUiViewportSettingsPort, OwnedUiQuitOutroSettingsPort, SuggestionDecision, SuggestionDiagnosticObserver } from "../../../contracts/owned-ui/index.js";
2
- import type { PiTuiPointerSurface } from "../tui-runtime/contracts.js";
3
- import type { UiRouteHost } from "../../../ui/apps/contracts.js";
4
- import type { TranscriptViewportFrame, TranscriptViewportFrameDescriptor } from "../../../ui/components/transcript-viewport.js";
5
- import type { PiEngineAdapter } from "../engine/adapter.js";
6
- import type { PiWorkflowMessage, PiWorkflowResult } from "../engine/workflows.js";
7
- import { type PiShellClipboardContent, type PiShellComponentPort, type PiShellEditorPort, type PiShellExtensionRendererResolver, type PiShellHeaderOptions, type PiShellHeaderPort, type PiShellImageAssetResolver, type PiShellLoadedResourcesPort, type PiShellResourceEntry, type PiShellTranscriptComponentPort } from "../components/shell-shared-facade.js";
8
- import { type PiTuiInputCoordinationScheduler, type PiTuiInputSurfaceKind } from "../tui-runtime/input-presentation-coordinator.js";
9
- import type { PiTuiComponentPort, PiTuiInputDiagnosticsEvent, PiTuiLayoutNode, PiTuiTerminalPort } from "../tui-runtime/contracts.js";
1
+ import type { OwnedUiPromptSuggestionGeneratorPort, OwnedUiSessionViewModel, OwnedUiViewportSettings, OwnedUiViewportSettingsPort, OwnedUiQuitOutroSettingsPort, SuggestionDecision, SuggestionDiagnosticObserver } from "../../contracts/owned-ui/index.js";
2
+ import type { PiTuiPointerSurface } from "../../integrations/pi/tui-runtime/contracts.js";
3
+ import type { UiRouteHost } from "../../ui/apps/contracts.js";
4
+ import type { TranscriptViewportFrame, TranscriptViewportFrameDescriptor } from "../../ui/components/transcript-viewport.js";
5
+ import type { PiEngineAdapter } from "../../integrations/pi/engine/adapter.js";
6
+ import type { PiWorkflowMessage, PiWorkflowResult } from "../../integrations/pi/engine/workflows.js";
7
+ import { type PiShellClipboardContent, type PiShellComponentPort, type PiShellEditorPort, type PiShellExtensionRendererResolver, type PiShellHeaderOptions, type PiShellHeaderPort, type PiShellImageAssetResolver, type PiShellLoadedResourcesPort, type PiShellResourceEntry, type PiShellTranscriptComponentPort } from "../../integrations/pi/components/shell-shared-facade.js";
8
+ import { type PiTuiInputCoordinationScheduler, type PiTuiInputSurfaceKind } from "../../integrations/pi/tui-runtime/input-presentation-coordinator.js";
9
+ import type { PiTuiComponentPort, PiTuiInputDiagnosticsEvent, PiTuiLayoutNode, PiTuiTerminalPort } from "../../integrations/pi/tui-runtime/contracts.js";
10
10
  import { type PreparedPrompt } from "./prompt-chips.js";
11
+ import type { PastePreparationClientOptions } from "./paste-preparation-client.js";
11
12
  import { type SessionViewportInputResult } from "./session-viewport-controller.js";
12
13
  import type { ResponseCopyExecutor } from "./response-copy-transport.js";
13
14
  import type { ResponseCopyEvent } from "./response-copy-protocol.js";
@@ -24,20 +25,10 @@ export interface OwnedUiClipboardPort {
24
25
  } | null>;
25
26
  writeText?(text: string, signal?: AbortSignal): Promise<void>;
26
27
  }
27
- export interface OwnedUiSessionShellOptions {
28
- readonly promptHistory?: {
29
- readonly store: import("../../../contracts/owned-ui/index.js").PromptHistoryPort;
30
- readonly limit: number;
31
- readonly editor: import("../components/index.js").HistoryEditorConstructor;
32
- /** Optional per-profile filesystem sidecar for image chip payloads. When present, submit
33
- * writes each referenced attachment and recall reads them back to rehydrate live chips.
34
- * When absent, image chips silently strip on recall, matching the missing-sidecar path. */
35
- readonly imageSidecar?: import("../../../contracts/owned-ui/index.js").PromptHistoryImageSidecarPort;
36
- };
28
+ /** The engine session the shell presents and the composition's decisions about it. */
29
+ export interface OwnedUiShellEngineOptions {
37
30
  readonly backend: OwnedUiBackendPort;
38
31
  readonly cwd: string;
39
- readonly terminal?: OwnedUiTerminalPort;
40
- readonly startup?: OwnedUiStartupOptions;
41
32
  /**
42
33
  * Declared A1-owned routes. A route this host claims resolves to its app;
43
34
  * every other route continues to the pinned workflow table unchanged.
@@ -45,30 +36,15 @@ export interface OwnedUiSessionShellOptions {
45
36
  readonly routeHost?: UiRouteHost;
46
37
  /** Bare A1 selects the owned bounded viewport; comparison profiles stay pinned. */
47
38
  readonly sessionLayout?: "pinned" | "custom-viewport";
39
+ }
40
+ /** Terminal, startup, viewport, and presentation-cadence seams; production leaves most at their defaults. */
41
+ export interface OwnedUiShellPresentationOptions {
42
+ readonly terminal?: OwnedUiTerminalPort;
43
+ readonly startup?: OwnedUiStartupOptions;
48
44
  /** Live profile-local settings, supplied only to the bare-A1 composition. */
49
45
  readonly viewportSettings?: OwnedUiViewportSettingsPort;
50
- /**
51
- * Quit outro settings and seams, supplied only to the bare-A1 composition.
52
- * `interactive` states whether the terminal can show the animation; production
53
- * passes stdout's TTY state, tests opt in explicitly.
54
- */
55
- readonly quitOutro?: OwnedUiQuitOutroSettingsPort & {
56
- readonly interactive: boolean;
57
- readonly now?: () => number;
58
- readonly sleep?: (ms: number) => Promise<void>;
59
- readonly seed?: number;
60
- };
61
- /** Optional platform seam; production uses A1's system clipboard adapter. */
62
- readonly clipboard?: OwnedUiClipboardPort;
63
- /** Owned response-copy transport and payload-free diagnostic seams. Comparison profiles ignore them. */
64
- readonly responseCopy?: {
65
- readonly execute?: ResponseCopyExecutor;
66
- readonly onEvent?: (event: ResponseCopyEvent) => void;
67
- };
68
- /** Bounded, payload-free clipboard acquisition/preparation observations. */
69
- readonly pasteDiagnostics?: (event: PasteEvent) => void;
70
46
  /** Deterministic scheduling seam for presentation-cadence tests. */
71
- readonly streamPresentation?: {
47
+ readonly stream?: {
72
48
  readonly intervalMs?: number;
73
49
  readonly scheduler?: StreamPresentationScheduler;
74
50
  };
@@ -76,19 +52,23 @@ export interface OwnedUiSessionShellOptions {
76
52
  * Minimum time the reload box stays visible so a fast reload still reads as one.
77
53
  * Production uses the default hold; tests inject `now`/`sleep` for determinism.
78
54
  */
79
- readonly reloadPresentation?: {
55
+ readonly reload?: {
80
56
  readonly minVisibleMs?: number;
81
57
  readonly now?: () => number;
82
58
  readonly sleep?: (ms: number) => Promise<void>;
83
59
  };
84
- /** Optional deterministic seam for keyboard scheduling and phase evidence. */
85
- readonly promptSuggestions?: {
86
- readonly diagnostics?: SuggestionDiagnosticObserver;
87
- readonly generator: OwnedUiPromptSuggestionGeneratorPort;
88
- readonly enabled: () => boolean;
89
- readonly onChange: (listener: (enabled: boolean) => void) => () => void;
60
+ /**
61
+ * Quit outro settings and seams, supplied only to the bare-A1 composition.
62
+ * `interactive` states whether the terminal can show the animation; production
63
+ * passes stdout's TTY state, tests opt in explicitly.
64
+ */
65
+ readonly quitOutro?: OwnedUiQuitOutroSettingsPort & {
66
+ readonly interactive: boolean;
67
+ readonly now?: () => number;
68
+ readonly sleep?: (ms: number) => Promise<void>;
69
+ readonly seed?: number;
90
70
  };
91
- readonly inputPresentation?: {
71
+ readonly input?: {
92
72
  readonly scheduler?: PiTuiInputCoordinationScheduler;
93
73
  readonly onEvent?: (event: PiTuiInputDiagnosticsEvent) => void;
94
74
  readonly now?: () => number;
@@ -98,6 +78,45 @@ export interface OwnedUiSessionShellOptions {
98
78
  readonly viewportReuse?: boolean;
99
79
  };
100
80
  }
81
+ /** Persistent prompt history: its store, its bound, the editor that recalls it, and the image sidecar. */
82
+ export interface OwnedUiShellHistoryOptions {
83
+ readonly store: import("../../contracts/owned-ui/index.js").PromptHistoryPort;
84
+ readonly limit: number;
85
+ readonly editor: import("../../integrations/pi/components/index.js").HistoryEditorConstructor;
86
+ /** Optional per-profile filesystem sidecar for image chip payloads. When present, submit
87
+ * writes each referenced attachment and recall reads them back to rehydrate live chips.
88
+ * When absent, image chips silently strip on recall, matching the missing-sidecar path. */
89
+ readonly imageSidecar?: import("../../contracts/owned-ui/index.js").PromptHistoryImageSidecarPort;
90
+ }
91
+ /** Contextual prompt suggestions: the generator, the enablement setting, and an optional evidence seam. */
92
+ export interface OwnedUiShellSuggestionOptions {
93
+ readonly diagnostics?: SuggestionDiagnosticObserver;
94
+ readonly generator: OwnedUiPromptSuggestionGeneratorPort;
95
+ readonly enabled: () => boolean;
96
+ readonly onChange: (listener: (enabled: boolean) => void) => () => void;
97
+ }
98
+ /** Clipboard seams and payload-free diagnostics; comparison profiles ignore the diagnostics. */
99
+ export interface OwnedUiShellDiagnosticOptions {
100
+ /** Optional platform seam; production uses A1's system clipboard adapter. */
101
+ readonly clipboard?: OwnedUiClipboardPort;
102
+ /** Owned response-copy transport and payload-free diagnostic seams. */
103
+ readonly responseCopy?: {
104
+ readonly execute?: ResponseCopyExecutor;
105
+ readonly onEvent?: (event: ResponseCopyEvent) => void;
106
+ };
107
+ /** Bounded, payload-free clipboard acquisition/preparation observations. */
108
+ readonly paste?: (event: PasteEvent) => void;
109
+ /** Test seams for isolated paste preparation: an in-process starter, or the forked helper's entry. */
110
+ readonly pastePreparation?: Omit<PastePreparationClientOptions, "onEvent" | "spareIdleMs">;
111
+ }
112
+ /** What composes an owned session shell, grouped by the collaborator that provides each part. */
113
+ export interface OwnedUiSessionShellOptions {
114
+ readonly engine: OwnedUiShellEngineOptions;
115
+ readonly presentation?: OwnedUiShellPresentationOptions;
116
+ readonly history?: OwnedUiShellHistoryOptions;
117
+ readonly suggestions?: OwnedUiShellSuggestionOptions;
118
+ readonly diagnostics?: OwnedUiShellDiagnosticOptions;
119
+ }
101
120
  /** Composes backend session state into the owned transcript, viewport, editor, and dock presentation. */
102
121
  export declare class OwnedUiSessionShellRoot implements PiTuiComponentPort {
103
122
  #private;
@@ -112,7 +131,7 @@ export declare class OwnedUiSessionShellRoot implements PiTuiComponentPort {
112
131
  readonly requestHyperlinkCleanup?: (rows?: readonly number[]) => void;
113
132
  readonly enableDockInputReuse?: boolean;
114
133
  readonly persistentHistory?: boolean;
115
- readonly historyEditor?: import("../components/index.js").HistoryEditorConstructor;
134
+ readonly historyEditor?: import("../../integrations/pi/components/index.js").HistoryEditorConstructor;
116
135
  readonly onSubmit: (text: string) => void;
117
136
  readonly onPasteRejected?: (error: unknown) => void;
118
137
  readonly onInterrupt: () => void;
@@ -132,6 +151,7 @@ export declare class OwnedUiSessionShellRoot implements PiTuiComponentPort {
132
151
  readonly readClipboardContent?: (signal?: AbortSignal) => Promise<PiShellClipboardContent | null>;
133
152
  readonly captureClipboardPaste?: () => PasteSource;
134
153
  readonly pasteDiagnostics?: (event: PasteEvent) => void;
154
+ readonly pastePreparation?: Omit<PastePreparationClientOptions, "onEvent">;
135
155
  }, startup?: PiShellHeaderOptions, agentDir?: string, extensionRenderers?: PiShellExtensionRendererResolver, sessionLayout?: "pinned" | "custom-viewport", imageAssets?: PiShellImageAssetResolver);
136
156
  setEditorPaddingX(padding: number): void;
137
157
  setAutocompleteMaxVisible(maxVisible: number): void;
@@ -140,7 +160,7 @@ export declare class OwnedUiSessionShellRoot implements PiTuiComponentPort {
140
160
  setMermaidRenderingMode(mode: "off" | "final" | "streaming"): void;
141
161
  setImagePresentation(showImages: boolean, imageWidthCells: number): void;
142
162
  prepareHistoryText(text: string): string;
143
- rehydrateHistoryText(text: string, resolveImage: (id: string) => import("../../../contracts/owned-ui/index.js").PromptHistoryImageSidecarAttachment | null): string;
163
+ rehydrateHistoryText(text: string, resolveImage: (id: string) => import("../../contracts/owned-ui/index.js").PromptHistoryImageSidecarAttachment | null): string;
144
164
  imageChipAttachmentsFromEditor(text: string): {
145
165
  readonly id: string;
146
166
  readonly tag: string;
@@ -154,6 +174,8 @@ export declare class OwnedUiSessionShellRoot implements PiTuiComponentPort {
154
174
  hasPendingPastes(text: string): boolean;
155
175
  waitForPromptPastes(text: string, signal: AbortSignal): Promise<PreparedPrompt>;
156
176
  resetPendingPastes(): void;
177
+ /** Forks the spare paste helper so the first paste of the session takes a live child. */
178
+ warmPastePreparation(): void;
157
179
  disposePendingPastes(): Promise<void>;
158
180
  promptSuggestionPrepareBlockReason(): SuggestionDecision;
159
181
  canPreparePromptSuggestion(): boolean;
@@ -192,7 +214,7 @@ export declare class OwnedUiSessionShellRoot implements PiTuiComponentPort {
192
214
  followingEnd: boolean;
193
215
  scrollTop: number;
194
216
  maxScroll: number;
195
- cause: "detached" | "initial" | "steady" | "dock-input" | "follow-shift" | "geometry-change" | null;
217
+ cause: "initial" | "steady" | "dock-input" | "follow-shift" | "detached" | "geometry-change" | null;
196
218
  };
197
219
  /** Visible non-selectable Steering, alignment, and Working rows, for rendering evidence. */
198
220
  viewportTransientTailRowCount(): number;