@timurproko/a1 0.2.7-dev.1252 → 0.2.7-dev.1264

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 (296) hide show
  1. package/bin/ui.js +3 -3
  2. package/dist/app/session-shell/clipboard-diagnostics.d.ts +2 -2
  3. package/dist/app/session-shell/clipboard-image.d.ts +0 -1
  4. package/dist/app/session-shell/clipboard-image.js +1 -1
  5. package/dist/app/session-shell/dialog-coordinator.d.ts +6 -5
  6. package/dist/app/session-shell/dialog-coordinator.js +3 -4
  7. package/dist/app/session-shell/dock-chrome.d.ts +11 -6
  8. package/dist/app/session-shell/dock-chrome.js +5 -8
  9. package/dist/app/session-shell/editor-hyperlink-budget.d.ts +0 -2
  10. package/dist/app/session-shell/editor-hyperlink-budget.js +1 -1
  11. package/dist/app/session-shell/exit-notice.d.ts +2 -2
  12. package/dist/app/session-shell/exit-notice.js +1 -1
  13. package/dist/app/session-shell/extension-surface.d.ts +8 -7
  14. package/dist/app/session-shell/helper-pool.d.ts +3 -4
  15. package/dist/app/session-shell/helper-pool.js +1 -1
  16. package/dist/app/session-shell/image-preparation-client.d.ts +4 -3
  17. package/dist/app/session-shell/image-preparation.d.ts +0 -2
  18. package/dist/app/session-shell/image-preparation.js +2 -2
  19. package/dist/app/session-shell/image-source.d.ts +2 -3
  20. package/dist/app/session-shell/image-source.js +2 -2
  21. package/dist/app/session-shell/input-surface-switch.d.ts +9 -7
  22. package/dist/app/session-shell/input-surface-switch.js +1 -2
  23. package/dist/app/session-shell/login-interaction.d.ts +5 -4
  24. package/dist/app/session-shell/login-interaction.js +2 -3
  25. package/dist/app/session-shell/paste-executor.d.ts +4 -8
  26. package/dist/app/session-shell/paste-executor.js +2 -2
  27. package/dist/app/session-shell/paste-protocol.d.ts +2 -2
  28. package/dist/app/session-shell/path-chip-presentation.d.ts +0 -5
  29. package/dist/app/session-shell/path-chip-presentation.js +3 -3
  30. package/dist/app/session-shell/prompt-chips.d.ts +8 -7
  31. package/dist/app/session-shell/prompt-history-controller.d.ts +3 -3
  32. package/dist/app/session-shell/prompt-submission.d.ts +5 -2
  33. package/dist/app/session-shell/prompt-submission.js +13 -14
  34. package/dist/app/session-shell/quit-outro-effects.d.ts +3 -3
  35. package/dist/app/session-shell/quit-outro-effects.js +1 -4
  36. package/dist/app/session-shell/quit-outro.d.ts +9 -12
  37. package/dist/app/session-shell/quit-outro.js +11 -11
  38. package/dist/app/session-shell/resource-labels.d.ts +2 -0
  39. package/dist/app/session-shell/resource-labels.js +158 -0
  40. package/dist/app/session-shell/response-copy-protocol.d.ts +3 -2
  41. package/dist/app/session-shell/response-copy-transport.d.ts +2 -14
  42. package/dist/app/session-shell/response-copy-transport.js +1 -1
  43. package/dist/app/session-shell/session-lifecycle.d.ts +2 -1
  44. package/dist/app/session-shell/session-prompt-history.d.ts +29 -0
  45. package/dist/app/session-shell/session-prompt-history.js +80 -0
  46. package/dist/app/session-shell/session-selectors.d.ts +46 -0
  47. package/dist/app/session-shell/session-selectors.js +269 -0
  48. package/dist/app/session-shell/session-shell-root.d.ts +76 -113
  49. package/dist/app/session-shell/session-shell-root.js +103 -329
  50. package/dist/app/session-shell/session-shell.d.ts +14 -37
  51. package/dist/app/session-shell/session-shell.js +177 -612
  52. package/dist/app/session-shell/session-viewport-controller.d.ts +9 -16
  53. package/dist/app/session-shell/session-viewport-controller.js +42 -320
  54. package/dist/app/session-shell/settings-bindings.d.ts +25 -3
  55. package/dist/app/session-shell/settings-bindings.js +26 -2
  56. package/dist/app/session-shell/share-operation.d.ts +3 -3
  57. package/dist/app/session-shell/share-operation.js +4 -6
  58. package/dist/app/session-shell/shell-clipboard.d.ts +59 -0
  59. package/dist/app/session-shell/shell-clipboard.js +119 -0
  60. package/dist/app/session-shell/shell-editor-factory.d.ts +8 -4
  61. package/dist/app/session-shell/shell-editor-factory.js +13 -15
  62. package/dist/app/session-shell/shell-host.d.ts +16 -17
  63. package/dist/app/session-shell/shell-host.js +18 -19
  64. package/dist/app/session-shell/shell-layout.d.ts +2 -2
  65. package/dist/app/session-shell/shell-prompt-suggestions.d.ts +26 -0
  66. package/dist/app/session-shell/shell-prompt-suggestions.js +48 -0
  67. package/dist/app/session-shell/suggestion-surface.d.ts +1 -6
  68. package/dist/app/session-shell/suggestion-surface.js +1 -1
  69. package/dist/app/session-shell/system-clipboard.d.ts +2 -14
  70. package/dist/app/session-shell/system-clipboard.js +2 -7
  71. package/dist/app/session-shell/transcript-document.d.ts +11 -8
  72. package/dist/app/session-shell/transcript-document.js +13 -14
  73. package/dist/app/session-shell/viewport-layout.d.ts +2 -2
  74. package/dist/app/session-shell/viewport-pointer.d.ts +83 -0
  75. package/dist/app/session-shell/viewport-pointer.js +361 -0
  76. package/dist/app/session-shell/workflow-output.d.ts +5 -3
  77. package/dist/app/session-shell/workflow-output.js +13 -15
  78. package/dist/cli/package-messages.d.ts +0 -1
  79. package/dist/cli/package-messages.js +1 -1
  80. package/dist/cli/session-context.d.ts +1 -1
  81. package/dist/cli/uninstall.d.ts +3 -2
  82. package/dist/composition/owned-settings.d.ts +2 -1
  83. package/dist/composition/owned-settings.js +0 -3
  84. package/dist/composition/owned-ui.d.ts +1 -1
  85. package/dist/composition/owned-ui.js +77 -73
  86. package/dist/composition/reference-selection-options.d.ts +1 -1
  87. package/dist/composition/reference-selection-options.js +1 -1
  88. package/dist/composition/session-runtime-registry.d.ts +2 -1
  89. package/dist/composition/settings-route-host.js +3 -10
  90. package/dist/composition/settings-search-input.d.ts +2 -1
  91. package/dist/composition/startup-route.d.ts +2 -2
  92. package/dist/composition/startup-route.js +2 -2
  93. package/dist/contracts/owned-ui/extension-ui.d.ts +2 -1
  94. package/dist/contracts/owned-ui/index.d.ts +2 -1
  95. package/dist/contracts/owned-ui/index.js +1 -1
  96. package/dist/contracts/owned-ui/session-presenters.d.ts +3 -0
  97. package/dist/contracts/owned-ui/shell-components.d.ts +543 -0
  98. package/dist/contracts/owned-ui/validation.d.ts +1 -11
  99. package/dist/contracts/owned-ui/validation.js +8 -104
  100. package/dist/contracts/presentation/component.d.ts +17 -0
  101. package/dist/contracts/presentation/component.js +8 -0
  102. package/dist/contracts/presentation/index.d.ts +6 -15
  103. package/dist/contracts/presentation/index.js +2 -0
  104. package/dist/contracts/presentation/terminal.d.ts +284 -0
  105. package/dist/contracts/presentation/terminal.js +1 -0
  106. package/dist/contracts/presentation/theme.d.ts +46 -0
  107. package/dist/contracts/presentation/theme.js +1 -0
  108. package/dist/features/launch/development-launch.js +1 -1
  109. package/dist/features/launch/runtime-selection.d.ts +2 -2
  110. package/dist/features/launch/runtime-selection.js +2 -2
  111. package/dist/features/owned-ui/project-trust-prompt.d.ts +2 -2
  112. package/dist/features/owned-ui/project-trust-prompt.js +1 -1
  113. package/dist/features/owned-ui/release-note-state.d.ts +2 -1
  114. package/dist/features/owned-ui/settings-app.js +49 -425
  115. package/dist/features/owned-ui/settings-edits.d.ts +31 -0
  116. package/dist/features/owned-ui/settings-edits.js +139 -0
  117. package/dist/features/owned-ui/settings-model-dialog.d.ts +41 -0
  118. package/dist/features/owned-ui/settings-model-dialog.js +194 -0
  119. package/dist/features/owned-ui/settings-scroll-rail.d.ts +29 -0
  120. package/dist/features/owned-ui/settings-scroll-rail.js +79 -0
  121. package/dist/features/owned-ui/settings-search-input.d.ts +2 -1
  122. package/dist/features/prompt-history/service.d.ts +3 -2
  123. package/dist/foundation/lifecycle/claim-gate.d.ts +2 -1
  124. package/dist/foundation/release/automatic-update.d.ts +5 -14
  125. package/dist/foundation/release/automatic-update.js +15 -22
  126. package/dist/foundation/release/bootstrap.js +4 -4
  127. package/dist/foundation/release/dependency-certification.d.ts +0 -1
  128. package/dist/foundation/release/dependency-certification.js +1 -1
  129. package/dist/foundation/release/dependency-layer.js +3 -3
  130. package/dist/foundation/release/early-accent.d.ts +2 -2
  131. package/dist/foundation/release/early-accent.js +1 -1
  132. package/dist/foundation/release/index.d.ts +2 -2
  133. package/dist/foundation/release/index.js +1 -1
  134. package/dist/foundation/release/latest-release.d.ts +3 -18
  135. package/dist/foundation/release/latest-release.js +11 -11
  136. package/dist/foundation/release/managed-path.d.ts +10 -0
  137. package/dist/foundation/release/managed-path.js +26 -0
  138. package/dist/foundation/release/ordinary-launch-selection.d.ts +1 -1
  139. package/dist/foundation/release/ordinary-launch-selection.js +1 -1
  140. package/dist/foundation/release/release-gc.d.ts +3 -3
  141. package/dist/foundation/release/release-gc.js +10 -12
  142. package/dist/foundation/release/{cohort-state.d.ts → release-state.d.ts} +23 -23
  143. package/dist/foundation/release/{cohort-state.js → release-state.js} +8 -8
  144. package/dist/foundation/release/restart-certification.js +3 -4
  145. package/dist/foundation/release/update-activation.js +3 -3
  146. package/dist/foundation/release/update-execution-lease.d.ts +2 -3
  147. package/dist/foundation/release/update-execution-lease.js +2 -8
  148. package/dist/foundation/release/update-installer.d.ts +45 -0
  149. package/dist/foundation/release/update-installer.js +57 -0
  150. package/dist/foundation/release/update-launch.d.ts +2 -2
  151. package/dist/foundation/release/update-recovery.js +2 -9
  152. package/dist/foundation/release/update.d.ts +4 -25
  153. package/dist/foundation/release/update.js +164 -183
  154. package/dist/foundation/startup/startup-budget.d.ts +5 -5
  155. package/dist/foundation/startup/startup-budget.js +2 -2
  156. package/dist/integrations/pi/components/bracketed-paste.d.ts +33 -0
  157. package/dist/integrations/pi/components/bracketed-paste.js +123 -0
  158. package/dist/integrations/pi/components/editor-interaction.d.ts +4 -12
  159. package/dist/integrations/pi/components/index.d.ts +15 -9
  160. package/dist/integrations/pi/components/index.js +9 -5
  161. package/dist/integrations/pi/components/lazy-selectors.d.ts +2 -10
  162. package/dist/integrations/pi/components/lazy-selectors.js +1 -1
  163. package/dist/integrations/pi/components/modal-frame.d.ts +5 -22
  164. package/dist/integrations/pi/components/modal-frame.js +3 -23
  165. package/dist/integrations/pi/components/owned-editor-ux.d.ts +4 -3
  166. package/dist/integrations/pi/components/owned-editor-ux.js +46 -140
  167. package/dist/integrations/pi/components/prompt-input-port.d.ts +2 -19
  168. package/dist/integrations/pi/components/resources/builtin-themes.d.ts +2 -1
  169. package/dist/integrations/pi/components/shell-editor-autocomplete.d.ts +3 -2
  170. package/dist/integrations/pi/components/shell-footer-status.d.ts +2 -2
  171. package/dist/integrations/pi/components/shell-footer-status.js +3 -2
  172. package/dist/integrations/pi/components/shell-presenters-info.d.ts +6 -5
  173. package/dist/integrations/pi/components/shell-presenters-info.js +2 -1
  174. package/dist/integrations/pi/components/shell-session-info-reference.d.ts +2 -1
  175. package/dist/integrations/pi/components/shell-shared-facade.d.ts +33 -227
  176. package/dist/integrations/pi/components/shell-shared-facade.js +8 -1
  177. package/dist/integrations/pi/components/skills-command.d.ts +1 -9
  178. package/dist/integrations/pi/components/skills-command.js +5 -5
  179. package/dist/integrations/pi/components/theme.d.ts +9 -2
  180. package/dist/integrations/pi/components/theme.js +17 -2
  181. package/dist/integrations/pi/components/thinking-selector-dialog.d.ts +2 -1
  182. package/dist/integrations/pi/components/upstream/adjacent/core/keybindings.d.ts +2 -2
  183. package/dist/integrations/pi/engine/adapter.d.ts +4 -13
  184. package/dist/integrations/pi/engine/adapter.js +9 -61
  185. package/dist/integrations/pi/engine/changelog.d.ts +2 -2
  186. package/dist/integrations/pi/engine/changelog.js +3 -3
  187. package/dist/integrations/pi/engine/compaction-progress.d.ts +2 -3
  188. package/dist/integrations/pi/engine/compaction-progress.js +1 -1
  189. package/dist/integrations/pi/engine/conformance.d.ts +2 -1
  190. package/dist/integrations/pi/engine/default-model-setting.d.ts +0 -2
  191. package/dist/integrations/pi/engine/default-model-setting.js +1 -2
  192. package/dist/integrations/pi/engine/event-delivery.d.ts +2 -1
  193. package/dist/integrations/pi/engine/extension-ui-binding.d.ts +2 -1
  194. package/dist/integrations/pi/engine/host.js +3 -3
  195. package/dist/integrations/pi/engine/message-values.d.ts +0 -1
  196. package/dist/integrations/pi/engine/message-values.js +1 -1
  197. package/dist/integrations/pi/engine/pending-delivery.d.ts +0 -4
  198. package/dist/integrations/pi/engine/pending-delivery.js +3 -3
  199. package/dist/integrations/pi/engine/ports.d.ts +7 -1
  200. package/dist/integrations/pi/engine/ports.js +4 -0
  201. package/dist/integrations/pi/engine/project-trust-preflight.d.ts +2 -1
  202. package/dist/integrations/pi/engine/prompt-suggestions.d.ts +3 -2
  203. package/dist/integrations/pi/engine/provider-authentication.d.ts +1 -1
  204. package/dist/integrations/pi/engine/public-main-entry.d.ts +1 -5
  205. package/dist/integrations/pi/engine/public-main-entry.js +1 -1
  206. package/dist/integrations/pi/engine/repository-metadata.d.ts +49 -0
  207. package/dist/integrations/pi/engine/repository-metadata.js +189 -0
  208. package/dist/integrations/pi/engine/repository-pr-rest.d.ts +1 -9
  209. package/dist/integrations/pi/engine/repository-pr-rest.js +2 -2
  210. package/dist/integrations/pi/engine/repository-pr.d.ts +1 -3
  211. package/dist/integrations/pi/engine/repository-pr.js +1 -1
  212. package/dist/integrations/pi/engine/resource-catalog.d.ts +2 -1
  213. package/dist/integrations/pi/engine/session-integration.d.ts +1 -1
  214. package/dist/integrations/pi/engine/session-runtime.d.ts +7 -12
  215. package/dist/integrations/pi/engine/session-runtime.js +21 -178
  216. package/dist/integrations/pi/engine/settings-bridge.d.ts +0 -2
  217. package/dist/integrations/pi/engine/settings-bridge.js +1 -1
  218. package/dist/integrations/pi/engine/settings-port.d.ts +3 -2
  219. package/dist/integrations/pi/engine/transcript-projection.d.ts +2 -1
  220. package/dist/integrations/pi/engine/view-state.d.ts +21 -2
  221. package/dist/integrations/pi/engine/view-state.js +129 -1
  222. package/dist/integrations/pi/engine/workflow-contexts.d.ts +1 -1
  223. package/dist/integrations/pi/engine/workflow-runner.d.ts +1 -2
  224. package/dist/integrations/pi/engine/workflow-runner.js +254 -365
  225. package/dist/integrations/pi/engine/workflow-share.d.ts +9 -0
  226. package/dist/integrations/pi/engine/workflow-share.js +168 -0
  227. package/dist/integrations/pi/engine/workflow-support.d.ts +0 -20
  228. package/dist/integrations/pi/engine/workflow-support.js +4 -65
  229. package/dist/integrations/pi/engine/workflows.d.ts +5 -5
  230. package/dist/integrations/pi/session-presenters/components.d.ts +3 -0
  231. package/dist/integrations/pi/session-presenters/components.js +75 -0
  232. package/dist/integrations/pi/session-presenters/index.d.ts +1 -0
  233. package/dist/integrations/pi/session-presenters/index.js +1 -0
  234. package/dist/integrations/pi/session-presenters/presentation.d.ts +3 -0
  235. package/dist/integrations/pi/session-presenters/presentation.js +10 -0
  236. package/dist/integrations/pi/session-presenters/presenters.d.ts +2 -1
  237. package/dist/integrations/pi/session-presenters/presenters.js +3 -1
  238. package/dist/integrations/pi/tui-runtime/adapter.d.ts +9 -19
  239. package/dist/integrations/pi/tui-runtime/adapter.js +56 -174
  240. package/dist/integrations/pi/tui-runtime/damage-aware-terminal.d.ts +9 -44
  241. package/dist/integrations/pi/tui-runtime/index.d.ts +1 -1
  242. package/dist/integrations/pi/tui-runtime/index.js +1 -0
  243. package/dist/integrations/pi/tui-runtime/input-presentation-coordinator.d.ts +4 -6
  244. package/dist/integrations/pi/tui-runtime/overlay-geometry.d.ts +4 -10
  245. package/dist/integrations/pi/tui-runtime/overlay-geometry.js +3 -9
  246. package/dist/integrations/pi/tui-runtime/presentation-adapter.d.ts +2 -2
  247. package/dist/integrations/pi/tui-runtime/runtime-factory.d.ts +3 -0
  248. package/dist/integrations/pi/tui-runtime/runtime-factory.js +11 -0
  249. package/dist/ui/components/index.d.ts +2 -2
  250. package/dist/ui/components/index.js +1 -1
  251. package/dist/ui/components/selection-copy.d.ts +0 -1
  252. package/dist/ui/components/selection-copy.js +0 -12
  253. package/dist/ui/components/theme.d.ts +4 -19
  254. package/dist/ui/components/theme.js +6 -0
  255. package/dist/ui/components/transcript-viewport-frame.d.ts +120 -0
  256. package/dist/ui/components/transcript-viewport-frame.js +314 -0
  257. package/dist/ui/components/transcript-viewport-types.d.ts +147 -0
  258. package/dist/ui/components/transcript-viewport-types.js +1 -0
  259. package/dist/ui/components/transcript-viewport.d.ts +2 -147
  260. package/dist/ui/components/transcript-viewport.js +87 -315
  261. package/dist/ui/settings/declarations.d.ts +2 -3
  262. package/dist/ui/settings/declarations.js +2 -3
  263. package/dist/ui/settings/early-accent.js +1 -1
  264. package/dist/ui/settings/index.d.ts +3 -5
  265. package/dist/ui/settings/index.js +2 -3
  266. package/dist/ui/settings/manager.d.ts +0 -4
  267. package/dist/ui/settings/manager.js +6 -62
  268. package/dist/ui/settings/resolution.d.ts +6 -18
  269. package/dist/ui/settings/resolution.js +4 -103
  270. package/dist/ui/settings/sections.d.ts +0 -4
  271. package/dist/ui/settings/sections.js +1 -1
  272. package/docs/architecture/boundaries.md +2 -2
  273. package/docs/architecture/internal-naming.md +2 -0
  274. package/docs/architecture/project-structure.md +4 -2
  275. package/docs/validation.md +1 -1
  276. package/package.json +3 -4
  277. package/dist/integrations/pi/components/components.d.ts +0 -4
  278. package/dist/integrations/pi/components/components.js +0 -48
  279. package/dist/integrations/pi/components/conformance.d.ts +0 -18
  280. package/dist/integrations/pi/components/conformance.js +0 -70
  281. package/dist/integrations/pi/components/shell-components.d.ts +0 -7
  282. package/dist/integrations/pi/components/shell-components.js +0 -7
  283. package/dist/integrations/pi/components/upstream/theme/theme-controller.d.ts +0 -33
  284. package/dist/integrations/pi/components/upstream/theme/theme-controller.js +0 -114
  285. package/dist/integrations/pi/engine/diagnostics-state.d.ts +0 -9
  286. package/dist/integrations/pi/engine/diagnostics-state.js +0 -34
  287. package/dist/integrations/pi/engine/usage-view.d.ts +0 -4
  288. package/dist/integrations/pi/engine/usage-view.js +0 -56
  289. package/dist/integrations/pi/tui-runtime/contracts.d.ts +0 -166
  290. package/dist/ui/settings/migrations.d.ts +0 -19
  291. package/dist/ui/settings/migrations.js +0 -225
  292. package/dist/ui/settings/progress-palette.generated.d.ts +0 -139
  293. package/dist/ui/settings/progress-palette.generated.js +0 -139
  294. /package/dist/{integrations/pi/tui-runtime/contracts.js → contracts/owned-ui/shell-components.js} +0 -0
  295. /package/dist/{foundation/release → contracts/presentation}/progress-palette.generated.d.ts +0 -0
  296. /package/dist/{foundation/release → contracts/presentation}/progress-palette.generated.js +0 -0
@@ -2,20 +2,12 @@ interface PiPullRequestIdentity {
2
2
  readonly number: number;
3
3
  readonly url: string;
4
4
  }
5
- export interface PiGitHubRepositoryIdentity {
6
- readonly owner: string;
7
- readonly repository: string;
8
- }
9
5
  type PiGitHubFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
10
6
  type PiCommandReader = (cwd: string, signal: AbortSignal) => Promise<string | null>;
11
- export interface PiPullRequestRestDependencies {
7
+ interface PiPullRequestRestDependencies {
12
8
  readonly readOriginUrl?: PiCommandReader;
13
9
  readonly fetch?: PiGitHubFetch;
14
10
  }
15
11
  /** Discover one exact branch pull request through GitHub's read-only REST API. */
16
12
  export declare function readPullRequestFromGitHub(cwd: string, branch: string, signal: AbortSignal, environment?: NodeJS.ProcessEnv, dependencies?: PiPullRequestRestDependencies): Promise<PiPullRequestIdentity | null>;
17
- /** Parse a supported GitHub origin URL without accepting credentials or non-GitHub hosts. */
18
- export declare function parseGitHubRepositoryRemote(remote: string): PiGitHubRepositoryIdentity | null;
19
- /** Validate a GitHub REST pull list as one exact branch association. */
20
- export declare function parseGitHubPullRequests(value: unknown, expectedRepository: PiGitHubRepositoryIdentity, branch: string): PiPullRequestIdentity | null;
21
13
  export {};
@@ -50,7 +50,7 @@ export async function readPullRequestFromGitHub(cwd, branch, signal, environment
50
50
  }
51
51
  }
52
52
  /** Parse a supported GitHub origin URL without accepting credentials or non-GitHub hosts. */
53
- export function parseGitHubRepositoryRemote(remote) {
53
+ function parseGitHubRepositoryRemote(remote) {
54
54
  const value = remote.trim();
55
55
  if (value.length === 0 || /[\r\n]/u.test(value))
56
56
  return null;
@@ -76,7 +76,7 @@ export function parseGitHubRepositoryRemote(remote) {
76
76
  }
77
77
  }
78
78
  /** Validate a GitHub REST pull list as one exact branch association. */
79
- export function parseGitHubPullRequests(value, expectedRepository, branch) {
79
+ function parseGitHubPullRequests(value, expectedRepository, branch) {
80
80
  if (!Array.isArray(value))
81
81
  return null;
82
82
  const fullName = `${expectedRepository.owner}/${expectedRepository.repository}`;
@@ -5,12 +5,10 @@ export interface PiPullRequestIdentity {
5
5
  export type PiPullRequestProbe = (cwd: string, branch: string, signal: AbortSignal) => Promise<PiPullRequestIdentity | null>;
6
6
  type PiCommandReader = (cwd: string, signal: AbortSignal) => Promise<string | null>;
7
7
  type PiPullRequestRestProbe = (cwd: string, branch: string, signal: AbortSignal, environment: NodeJS.ProcessEnv) => Promise<PiPullRequestIdentity | null>;
8
- export interface PiPullRequestDiscoveryDependencies {
8
+ interface PiPullRequestDiscoveryDependencies {
9
9
  readonly executeGh?: PiCommandReader;
10
10
  readonly restProbe?: PiPullRequestRestProbe;
11
11
  }
12
12
  /** Read an exact branch's open or merged PR, preferring GitHub CLI before the REST fallback. */
13
13
  export declare function readPullRequest(cwd: string, branch: string, signal: AbortSignal, environment?: NodeJS.ProcessEnv, dependencies?: PiPullRequestDiscoveryDependencies): Promise<PiPullRequestIdentity | null>;
14
- /** Parse and validate the normalized payload emitted by `gh pr view`. */
15
- export declare function parsePullRequest(stdout: string, branch: string): PiPullRequestIdentity | null;
16
14
  export {};
@@ -20,7 +20,7 @@ export async function readPullRequest(cwd, branch, signal, environment = process
20
20
  return (dependencies.restProbe ?? readPullRequestFromRest)(cwd, branch, signal, environment);
21
21
  }
22
22
  /** Parse and validate the normalized payload emitted by `gh pr view`. */
23
- export function parsePullRequest(stdout, branch) {
23
+ function parsePullRequest(stdout, branch) {
24
24
  let value;
25
25
  try {
26
26
  value = JSON.parse(stdout);
@@ -5,7 +5,7 @@ import { type PiProductMode, type PiWorkflowAutocompleteCommand } from "./workfl
5
5
  export type OwnedPiResourceSummary = OwnedUiResourceSummary;
6
6
  export type OwnedPiExtensionSourceSummary = OwnedUiExtensionSourceSummary;
7
7
  export type OwnedPiExtensionResourceSummary = OwnedUiExtensionResourceSummary;
8
- export interface PiResourceCatalogPorts {
8
+ interface PiResourceCatalogPorts {
9
9
  session(): AgentSession | undefined;
10
10
  runtime(): AgentSessionRuntime | undefined;
11
11
  }
@@ -29,3 +29,4 @@ export declare function collectionResult(value: unknown, key: string): {
29
29
  values: readonly unknown[];
30
30
  diagnostics: readonly string[];
31
31
  };
32
+ export {};
@@ -35,7 +35,7 @@ export type PiSessionCommand = {
35
35
  readonly excludeFromContext: boolean;
36
36
  readonly onChunk?: (chunk: string) => void;
37
37
  };
38
- export type PiSessionCommandOutcome = "completed" | "rejected" | "failed" | "cancelled";
38
+ type PiSessionCommandOutcome = "completed" | "rejected" | "failed" | "cancelled";
39
39
  export interface PiSessionCommandResult {
40
40
  readonly outcome: PiSessionCommandOutcome;
41
41
  readonly value?: unknown;
@@ -5,7 +5,8 @@ import type { PiProjectTrustPreflightPrompt } from "./project-trust-preflight.js
5
5
  import type { PiSessionForkPrompt, PiSessionSelection } from "./session-selection.js";
6
6
  import type { OwnedUiDiagnostics } from "../../../contracts/owned-ui/index.js";
7
7
  import type { PiSessionResumeMetadata, PiWorkflowHost } from "./workflows.js";
8
- import { type PiPullRequestIdentity, type PiPullRequestProbe } from "./repository-pr.js";
8
+ import type { PiPullRequestProbe } from "./repository-pr.js";
9
+ import { RepositoryMetadataPoller, type PiRepositoryContextReader } from "./repository-metadata.js";
9
10
  export interface PiEngineRuntimeFactoryInput {
10
11
  readonly cwd: string;
11
12
  readonly agentDir: string;
@@ -20,13 +21,8 @@ export interface PiEngineRuntimeFactoryInput {
20
21
  }
21
22
  export type PiEngineRuntimeFactory = (input: PiEngineRuntimeFactoryInput) => Promise<AgentSessionRuntime>;
22
23
  export type PiEnginePackageUpdateProbe = (settingsManager: AgentSessionServices["settingsManager"]) => Promise<readonly string[]>;
23
- export interface PiRepositoryContextSelection {
24
- readonly cwd: string;
25
- readonly branch: string;
26
- }
27
- export type PiRepositoryContextReader = (sessionId: string, sessionFile: string, signal: AbortSignal) => Promise<PiRepositoryContextSelection | null>;
28
- export type PiGitBranchReader = (cwd: string, signal: AbortSignal) => Promise<string | null>;
29
- export interface PiEngineRuntimeOptions {
24
+ export type { PiRepositoryContextReader } from "./repository-metadata.js";
25
+ interface PiEngineRuntimeOptions {
30
26
  readonly cwd: string;
31
27
  readonly agentDir: string;
32
28
  readonly sessionId: string;
@@ -43,7 +39,7 @@ export interface PiEngineRuntimeOptions {
43
39
  readonly pullRequestRefreshMs?: number;
44
40
  readonly repositoryContextPollMs?: number;
45
41
  readonly repositoryContextReader?: PiRepositoryContextReader;
46
- readonly gitBranchReader?: PiGitBranchReader;
42
+ readonly gitBranchReader?: (cwd: string, signal: AbortSignal) => Promise<string | null>;
47
43
  readonly host: PiWorkflowHost;
48
44
  }
49
45
  export interface PiEngineRuntimePorts {
@@ -74,9 +70,8 @@ export declare class PiEngineRuntime {
74
70
  /** Actual session replacements, excluding delivery-only invalidation of callbacks. */
75
71
  get bindingGeneration(): number;
76
72
  get cwd(): string;
77
- get repositoryCwd(): string;
78
- get gitBranch(): string | null;
79
- get pullRequest(): PiPullRequestIdentity | null;
73
+ /** The branch and pull request polled for the bound session. */
74
+ get repository(): RepositoryMetadataPoller;
80
75
  get sessionCommands(): PiSessionCommandIntegration | undefined;
81
76
  get started(): boolean;
82
77
  /** Create the runtime and bind its first session; startup failures propagate. */
@@ -1,17 +1,10 @@
1
- import { execFile } from "node:child_process";
2
1
  import { existsSync } from "node:fs";
3
- import { promisify } from "node:util";
4
2
  import { PRODUCT_IDENTITY } from "../../../product-identity.js";
5
3
  import { observeCompactionProgress } from "./compaction-progress.js";
6
4
  import { createPiRuntimeIntegration } from "./runtime-integration.js";
7
5
  import { PiSessionCommandIntegration } from "./session-integration.js";
8
6
  import { DefaultPackageManager, VERSION } from "../startup-public.js";
9
- import { readPullRequest, } from "./repository-pr.js";
10
- const execFileAsync = promisify(execFile);
11
- const PULL_REQUEST_REFRESH_MS = 60_000;
12
- const REPOSITORY_CONTEXT_POLL_MS = 5_000;
13
- const GIT_BRANCH_TIMEOUT_MS = 5_000;
14
- const GIT_BRANCH_MAX_BUFFER_BYTES = 4 * 1024;
7
+ import { RepositoryMetadataPoller } from "./repository-metadata.js";
15
8
  /**
16
9
  * The pinned Pi runtime and the session bound to it: creation through the runtime factory, the
17
10
  * session generation that stamps and invalidates events, the subscription that forwards session
@@ -26,11 +19,6 @@ export class PiEngineRuntime {
26
19
  #ports;
27
20
  #runtimeFactory;
28
21
  #checkPackageUpdates;
29
- #pullRequestProbe;
30
- #pullRequestRefreshMs;
31
- #repositoryContextPollMs;
32
- #repositoryContextReader;
33
- #gitBranchReader;
34
22
  #cwd;
35
23
  #runtime;
36
24
  #session;
@@ -39,31 +27,27 @@ export class PiEngineRuntime {
39
27
  #sessionBindingGeneration = 0;
40
28
  #sessionCommands;
41
29
  #compactionProgress = null;
42
- #repositoryCwd;
43
- #gitBranch = null;
44
- #pullRequest = null;
45
- #repositoryRefreshTimer;
46
- #repositoryRefreshAbort;
47
- #repositoryRefreshTask;
48
- #repositoryRefreshPending = false;
49
- #lastPullRequestProbeAt = null;
50
- #repositoryRefreshEnabled = false;
30
+ #repository;
51
31
  #disposed = false;
52
32
  constructor(options, ports) {
53
33
  this.#options = options;
54
34
  this.#ports = ports;
55
35
  this.#cwd = options.cwd;
56
- this.#repositoryCwd = options.cwd;
57
36
  this.#runtimeFactory = options.createRuntime ?? createDefaultPiRuntime;
58
37
  this.#checkPackageUpdates = options.checkPackageUpdates
59
38
  ?? (options.createRuntime
60
39
  ? async () => []
61
40
  : settingsManager => checkDefaultPiPackageUpdates(this.#cwd, options.agentDir, settingsManager));
62
- this.#pullRequestProbe = options.pullRequestProbe ?? readPullRequest;
63
- this.#pullRequestRefreshMs = options.pullRequestRefreshMs ?? PULL_REQUEST_REFRESH_MS;
64
- this.#repositoryContextPollMs = options.repositoryContextPollMs ?? REPOSITORY_CONTEXT_POLL_MS;
65
- this.#repositoryContextReader = options.repositoryContextReader ?? (async () => null);
66
- this.#gitBranchReader = options.gitBranchReader ?? readGitBranch;
41
+ this.#repository = new RepositoryMetadataPoller(options, {
42
+ bindingGeneration: () => this.#sessionBindingGeneration,
43
+ sessionIdentity: () => {
44
+ const manager = this.#session?.sessionManager;
45
+ return { sessionId: manager?.getSessionId?.(), sessionFile: manager?.getSessionFile?.() };
46
+ },
47
+ fallbackCwd: () => this.#cwd,
48
+ disposed: () => this.#disposed || this.#ports.disposed(),
49
+ changed: () => this.#ports.emitView(),
50
+ });
67
51
  }
68
52
  get runtime() {
69
53
  return this.#runtime;
@@ -82,14 +66,9 @@ export class PiEngineRuntime {
82
66
  get cwd() {
83
67
  return this.#runtime?.cwd ?? this.#cwd;
84
68
  }
85
- get repositoryCwd() {
86
- return this.#repositoryCwd;
87
- }
88
- get gitBranch() {
89
- return this.#gitBranch;
90
- }
91
- get pullRequest() {
92
- return this.#pullRequest;
69
+ /** The branch and pull request polled for the bound session. */
70
+ get repository() {
71
+ return this.#repository;
93
72
  }
94
73
  get sessionCommands() {
95
74
  return this.#sessionCommands;
@@ -112,7 +91,7 @@ export class PiEngineRuntime {
112
91
  });
113
92
  this.#runtime = runtime;
114
93
  this.#cwd = runtime.cwd ?? this.#cwd;
115
- this.#repositoryCwd = this.#cwd;
94
+ this.#repository.reset();
116
95
  this.#ports.started(runtime);
117
96
  runtime.setRebindSession(async (session) => {
118
97
  if (this.#ports.rebindBlocked())
@@ -127,8 +106,7 @@ export class PiEngineRuntime {
127
106
  this.#ports.diagnostic(diagnostic.type === "error" ? "error" : diagnostic.type === "warning" ? "warning" : "info", code, diagnostic.message, diagnostic.type !== "error");
128
107
  }
129
108
  this.bindSession(runtime.session);
130
- this.#repositoryRefreshEnabled = true;
131
- this.#startRepositoryRefresh();
109
+ this.#repository.start();
132
110
  return runtime;
133
111
  }
134
112
  /**
@@ -186,10 +164,9 @@ export class PiEngineRuntime {
186
164
  // Invariant: the subscription is live before the adapter rebuilds its state so the extension
187
165
  // rebind that finishes the rebuild cannot emit an event nobody is listening to.
188
166
  this.#subscribe();
189
- this.#resetRepositoryRefresh();
167
+ this.#repository.reset();
190
168
  this.#ports.sessionReplaced(session);
191
- if (this.#repositoryRefreshEnabled)
192
- this.#startRepositoryRefresh();
169
+ this.#repository.refresh();
193
170
  }
194
171
  /** Stop forwarding the current session's events and open a new generation; overload recovery resumes or abandons it. */
195
172
  suspend() {
@@ -235,127 +212,14 @@ export class PiEngineRuntime {
235
212
  /** Unsubscribe, stop observing compaction, and dispose the runtime; the session reference is kept for final reads. */
236
213
  async dispose() {
237
214
  this.#disposed = true;
238
- this.#repositoryRefreshEnabled = false;
239
- if (this.#repositoryRefreshTimer !== undefined)
240
- clearTimeout(this.#repositoryRefreshTimer);
241
- this.#repositoryRefreshTimer = undefined;
242
- this.#repositoryRefreshPending = false;
243
- this.#repositoryRefreshAbort?.abort();
244
- const repositoryRefreshTask = this.#repositoryRefreshTask;
215
+ const repository = this.#repository.dispose();
245
216
  this.#unsubscribe?.();
246
217
  this.#unsubscribe = undefined;
247
218
  this.#compactionProgress?.dispose();
248
219
  this.#compactionProgress = null;
249
- await repositoryRefreshTask;
220
+ await repository;
250
221
  await this.#runtime?.dispose();
251
222
  }
252
- #startRepositoryRefresh() {
253
- if (!this.#repositoryRefreshEnabled || this.#disposed || this.#ports.disposed())
254
- return;
255
- if (this.#repositoryRefreshTask !== undefined) {
256
- this.#repositoryRefreshPending = true;
257
- return;
258
- }
259
- const task = this.#refreshRepositoryMetadata();
260
- this.#repositoryRefreshTask = task;
261
- const settled = () => {
262
- if (this.#repositoryRefreshTask === task)
263
- this.#repositoryRefreshTask = undefined;
264
- if (!this.#repositoryRefreshPending)
265
- return;
266
- this.#repositoryRefreshPending = false;
267
- this.#startRepositoryRefresh();
268
- };
269
- void task.then(settled, settled);
270
- }
271
- #resetRepositoryRefresh() {
272
- if (this.#repositoryRefreshTimer !== undefined)
273
- clearTimeout(this.#repositoryRefreshTimer);
274
- this.#repositoryRefreshTimer = undefined;
275
- this.#repositoryRefreshAbort?.abort();
276
- this.#repositoryCwd = this.#cwd;
277
- this.#gitBranch = null;
278
- this.#pullRequest = null;
279
- this.#lastPullRequestProbeAt = null;
280
- }
281
- async #refreshRepositoryMetadata() {
282
- if (this.#repositoryRefreshAbort !== undefined || this.#disposed || this.#ports.disposed())
283
- return;
284
- const controller = new AbortController();
285
- const generation = this.#sessionBindingGeneration;
286
- this.#repositoryRefreshAbort = controller;
287
- let associatedContext = null;
288
- const manager = this.#session?.sessionManager;
289
- const sessionId = manager?.getSessionId?.();
290
- const sessionFile = manager?.getSessionFile?.();
291
- try {
292
- if (typeof sessionId === "string" && sessionId.length > 0 && typeof sessionFile === "string" && sessionFile.length > 0) {
293
- try {
294
- associatedContext = await this.#repositoryContextReader(sessionId, sessionFile, controller.signal);
295
- }
296
- catch {
297
- associatedContext = null;
298
- }
299
- }
300
- const nextCwd = associatedContext?.cwd ?? this.#cwd;
301
- let nextBranch = associatedContext?.branch ?? null;
302
- if (associatedContext === null) {
303
- try {
304
- nextBranch = await this.#gitBranchReader(nextCwd, controller.signal);
305
- }
306
- catch {
307
- nextBranch = null;
308
- }
309
- }
310
- const metadataChanged = nextCwd !== this.#repositoryCwd || nextBranch !== this.#gitBranch;
311
- const remoteDue = metadataChanged || this.#lastPullRequestProbeAt === null
312
- || Date.now() - this.#lastPullRequestProbeAt >= this.#pullRequestRefreshMs;
313
- if (remoteDue) {
314
- let nextPullRequest = null;
315
- try {
316
- nextPullRequest = nextBranch === null
317
- ? null
318
- : await this.#pullRequestProbe(nextCwd, nextBranch, controller.signal);
319
- }
320
- catch {
321
- nextPullRequest = null;
322
- }
323
- if (controller.signal.aborted || generation !== this.#sessionBindingGeneration || this.#disposed || this.#ports.disposed())
324
- return;
325
- const changed = nextCwd !== this.#repositoryCwd
326
- || nextBranch !== this.#gitBranch
327
- || !samePullRequest(this.#pullRequest, nextPullRequest);
328
- this.#repositoryCwd = nextCwd;
329
- this.#gitBranch = nextBranch;
330
- this.#pullRequest = nextPullRequest;
331
- this.#lastPullRequestProbeAt = Date.now();
332
- if (changed)
333
- this.#ports.emitView();
334
- }
335
- }
336
- catch {
337
- if (!controller.signal.aborted && generation === this.#sessionBindingGeneration && !this.#disposed && !this.#ports.disposed()) {
338
- const changed = this.#repositoryCwd !== this.#cwd || this.#gitBranch !== null || this.#pullRequest !== null;
339
- this.#repositoryCwd = this.#cwd;
340
- this.#gitBranch = null;
341
- this.#pullRequest = null;
342
- this.#lastPullRequestProbeAt = Date.now();
343
- if (changed)
344
- this.#ports.emitView();
345
- }
346
- }
347
- finally {
348
- if (this.#repositoryRefreshAbort === controller)
349
- this.#repositoryRefreshAbort = undefined;
350
- }
351
- if (controller.signal.aborted || generation !== this.#sessionBindingGeneration || this.#disposed || this.#ports.disposed())
352
- return;
353
- this.#repositoryRefreshTimer = setTimeout(() => {
354
- this.#repositoryRefreshTimer = undefined;
355
- this.#startRepositoryRefresh();
356
- }, this.#repositoryContextPollMs);
357
- this.#repositoryRefreshTimer.unref?.();
358
- }
359
223
  #attachCompactionProgress(session) {
360
224
  this.#compactionProgress?.dispose();
361
225
  this.#compactionProgress = observeCompactionProgress(session, percent => {
@@ -419,24 +283,3 @@ async function checkDefaultPiPackageUpdates(cwd, agentDir, settingsManager) {
419
283
  const updates = await packageManager.checkForAvailableUpdates();
420
284
  return updates.map(update => update.displayName);
421
285
  }
422
- function samePullRequest(left, right) {
423
- return left?.number === right?.number && left?.url === right?.url;
424
- }
425
- async function readGitBranch(cwd, signal) {
426
- if (!existsSync(cwd))
427
- return null;
428
- try {
429
- const { stdout } = await execFileAsync("git", ["branch", "--show-current"], {
430
- cwd,
431
- windowsHide: true,
432
- timeout: GIT_BRANCH_TIMEOUT_MS,
433
- maxBuffer: GIT_BRANCH_MAX_BUFFER_BYTES,
434
- signal,
435
- encoding: "utf8",
436
- });
437
- return stdout.trim() || null;
438
- }
439
- catch {
440
- return null;
441
- }
442
- }
@@ -120,6 +120,4 @@ export declare class PiSettingsBridge implements AgentSettingsPort {
120
120
  writeSettingNow(key: string, value: AgentJsonValue): Promise<AgentSettingChangeOutcome>;
121
121
  flush(): Promise<void>;
122
122
  }
123
- /** The engine keys overrides as `provider/modelId`; the model id may itself contain slashes. */
124
- export declare function splitModelKey(key: string): [provider: string, modelId: string];
125
123
  export {};
@@ -462,7 +462,7 @@ function modelThinkingLevels(settings) {
462
462
  });
463
463
  }
464
464
  /** The engine keys overrides as `provider/modelId`; the model id may itself contain slashes. */
465
- export function splitModelKey(key) {
465
+ function splitModelKey(key) {
466
466
  const at = key.indexOf("/");
467
467
  return [key.slice(0, at), key.slice(at + 1)];
468
468
  }
@@ -4,12 +4,12 @@ import type { AgentSession, AgentSessionRuntime } from "../startup-public.js";
4
4
  import type { OwnedUiThinkingLevel } from "../../../contracts/owned-ui/index.js";
5
5
  import type { AgentSettingOwner } from "../../../contracts/agent-engine/index.js";
6
6
  import { type PiPinnedSettingsCallback, type PiPinnedSettingsSnapshot, type PiWorkflowResult } from "./workflows.js";
7
- export interface PiEngineSettingsOptions {
7
+ interface PiEngineSettingsOptions {
8
8
  /** Themes installed on this machine, when the component adapter that owns the theme unit supplies them. */
9
9
  readonly availableThemes: (() => readonly string[]) | null;
10
10
  readonly productMode: "bare" | "comparison";
11
11
  }
12
- export interface PiEngineSettingsPorts {
12
+ interface PiEngineSettingsPorts {
13
13
  runtime(): AgentSessionRuntime | undefined;
14
14
  /** The bound session, or a thrown "not running" error before one exists. */
15
15
  requireSession(): AgentSession;
@@ -44,3 +44,4 @@ export declare class PiEngineSettings {
44
44
  applyPinnedSettingValue(callback: PiPinnedSettingsCallback, value: unknown): Promise<PiWorkflowResult>;
45
45
  applyPinnedSetting(selection: string, selectedValue?: unknown, hasSelectedValue?: boolean): Promise<PiWorkflowResult>;
46
46
  }
47
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { TranscriptImageAssets } from "./transcript-image-assets.js";
2
2
  import { type OwnedUiTranscriptBlock, type OwnedUiTranscriptImageReference } from "../../../contracts/owned-ui/index.js";
3
- export interface PiTranscriptProjectionPorts {
3
+ interface PiTranscriptProjectionPorts {
4
4
  /** Pinned Pi's current retry attempt, which words an aborted declaration's failure text. */
5
5
  retryAttempt(): number;
6
6
  /** Called once per stored block change, in order, so the adapter can deliver it. */
@@ -37,3 +37,4 @@ export declare class PiTranscriptProjection {
37
37
  upsert(block: OwnedUiTranscriptBlock): void;
38
38
  nextRevision(id: string): number;
39
39
  }
40
+ export {};
@@ -1,5 +1,13 @@
1
- import { EngineDiagnostics } from "./diagnostics-state.js";
2
- import type { OwnedUiDiagnostics, OwnedUiEditorState, OwnedUiModelInfo, OwnedUiSessionViewModel, OwnedUiStatusView, OwnedUiTerminalSurface, OwnedUiThinkingLevel, OwnedUiUsageView } from "../../../contracts/owned-ui/index.js";
1
+ import type { PiEngineRuntime } from "./session-runtime.js";
2
+ import type { OwnedUiDiagnostics, OwnedUiEditorState, OwnedUiModelInfo, OwnedUiSessionViewModel, OwnedUiStatusView, OwnedUiTerminalSurface, OwnedUiThinkingLevel, OwnedUiTranscriptBlock, OwnedUiUsageView } from "../../../contracts/owned-ui/index.js";
3
+ /** Bounded structured notices; acknowledgements never inspect terminal cells or touch Agent work. */
4
+ declare class EngineDiagnostics {
5
+ #private;
6
+ get values(): readonly OwnedUiDiagnostics[];
7
+ get messages(): readonly string[];
8
+ record(severity: OwnedUiDiagnostics["severity"], code: string, message: string, recoverable: boolean): OwnedUiDiagnostics;
9
+ clearCodes(codes: readonly string[]): boolean;
10
+ }
3
11
  /**
4
12
  * The engine adapter's own view-model state: lifecycle, editor, status, terminal surface, active
5
13
  * model, thinking level, the usage cache, diagnostics, and the view revision. Every change that
@@ -41,3 +49,14 @@ export declare class EngineViewState {
41
49
  /** Delivery overload ended the run: ready when it can resume, stopped once disposed, otherwise failed. */
42
50
  settleOverload(canResume: boolean, disposed: boolean): void;
43
51
  }
52
+ /** What the session view is projected from: the adapter's view state, the bound engine, the transcript and the running commands. */
53
+ export interface PiSessionViewSource {
54
+ readonly sessionId: string;
55
+ readonly state: EngineViewState;
56
+ readonly engine: PiEngineRuntime;
57
+ readonly transcript: readonly OwnedUiTranscriptBlock[];
58
+ readonly activeCommandIds: readonly string[];
59
+ }
60
+ /** The owned UI session view model, copied so a published view never aliases adapter state. */
61
+ export declare function projectSessionView({ sessionId, state, engine, transcript, activeCommandIds }: PiSessionViewSource): OwnedUiSessionViewModel;
62
+ export {};
@@ -1,4 +1,38 @@
1
- import { EngineDiagnostics } from "./diagnostics-state.js";
1
+ import { finiteNumber, isRecord, readModel, readThinkingLevel } from "./message-values.js";
2
+ /** Bounded structured notices; acknowledgements never inspect terminal cells or touch Agent work. */
3
+ class EngineDiagnostics {
4
+ #values = [];
5
+ #messages = [];
6
+ #sequence = 0;
7
+ get values() { return this.#values; }
8
+ get messages() { return this.#messages; }
9
+ record(severity, code, message, recoverable) {
10
+ const diagnostic = { sequence: this.#sequence++, code, severity, message, recoverable };
11
+ this.#values.push(diagnostic);
12
+ if (this.#values.length > 100)
13
+ this.#values.shift();
14
+ this.#messages = [...this.#messages, message].slice(-8);
15
+ return diagnostic;
16
+ }
17
+ clearCodes(codes) {
18
+ const selected = new Set(codes);
19
+ return this.#remove(diagnostic => selected.has(diagnostic.code));
20
+ }
21
+ #remove(predicate) {
22
+ const removed = new Set();
23
+ for (let index = this.#values.length - 1; index >= 0; index--) {
24
+ const diagnostic = this.#values[index];
25
+ if (predicate(diagnostic)) {
26
+ removed.add(diagnostic.message);
27
+ this.#values.splice(index, 1);
28
+ }
29
+ }
30
+ if (removed.size === 0)
31
+ return false;
32
+ this.#messages = this.#messages.filter(message => !removed.has(message) || this.#values.some(diagnostic => diagnostic.message === message));
33
+ return true;
34
+ }
35
+ }
2
36
  const DEFAULT_SURFACE = {
3
37
  columns: 100,
4
38
  rows: 32,
@@ -112,3 +146,97 @@ export class EngineViewState {
112
146
  this.#revision += 1;
113
147
  }
114
148
  }
149
+ /** Token, cost, cache, and context usage summed from the session's entries for the status footer. */
150
+ function readUsageView(session, runtime, activeModel) {
151
+ let input = 0;
152
+ let output = 0;
153
+ let cacheRead = 0;
154
+ let cacheWrite = 0;
155
+ let cost = 0;
156
+ let latestCacheHitRate = null;
157
+ let latestPrompt = null;
158
+ const entries = session?.sessionManager?.getEntries?.()
159
+ ?? (session?.messages ?? []).map(message => ({ type: "message", message }));
160
+ for (const entry of entries) {
161
+ if (!isRecord(entry))
162
+ continue;
163
+ const message = entry.type === "message" && isRecord(entry.message) ? entry.message : undefined;
164
+ const usage = message !== undefined && isRecord(message.usage)
165
+ ? message.usage
166
+ : (entry.type === "usage" || entry.type === "branch_summary" || entry.type === "compaction") && isRecord(entry.usage) ? entry.usage : undefined;
167
+ if (usage === undefined)
168
+ continue;
169
+ input += finiteNumber(usage.input);
170
+ output += finiteNumber(usage.output);
171
+ cacheRead += finiteNumber(usage.cacheRead);
172
+ cacheWrite += finiteNumber(usage.cacheWrite);
173
+ cost += isRecord(usage.cost) ? finiteNumber(usage.cost.total) : 0;
174
+ if (message?.role === "assistant") {
175
+ latestPrompt = {
176
+ input: finiteNumber(usage.input),
177
+ cacheRead: finiteNumber(usage.cacheRead),
178
+ cacheWrite: finiteNumber(usage.cacheWrite),
179
+ };
180
+ const promptTokens = latestPrompt.input + latestPrompt.cacheRead + latestPrompt.cacheWrite;
181
+ latestCacheHitRate = promptTokens > 0 ? (latestPrompt.cacheRead / promptTokens) * 100 : null;
182
+ }
183
+ }
184
+ const context = session?.getContextUsage?.();
185
+ const providerId = activeModel?.providerId;
186
+ const usingSubscription = providerId === "kimi-coding"
187
+ || (providerId !== undefined && runtime?.services.modelRuntime.isUsingSubscription?.(providerId) === true);
188
+ return {
189
+ input,
190
+ output,
191
+ cacheRead,
192
+ cacheWrite,
193
+ cost,
194
+ latestCacheHitRate,
195
+ latestPrompt,
196
+ contextAvailable: context !== undefined,
197
+ contextTokens: context?.tokens ?? null,
198
+ contextWindow: context?.contextWindow ?? 0,
199
+ contextPercent: context?.percent ?? null,
200
+ usingSubscription,
201
+ autoCompactEnabled: runtime?.services.settingsManager?.getCompactionEnabled?.() ?? true,
202
+ };
203
+ }
204
+ /** The owned UI session view model, copied so a published view never aliases adapter state. */
205
+ export function projectSessionView({ sessionId, state, engine, transcript, activeCommandIds }) {
206
+ const routed = engine.session?.routedModel;
207
+ const routedModel = routed === undefined ? null : readModel(routed.model);
208
+ return {
209
+ contractVersion: 1,
210
+ sessionId,
211
+ revision: state.revision,
212
+ lifecycle: state.lifecycle,
213
+ transcript,
214
+ editor: { ...state.editor, queuedSubmissions: [...state.editor.queuedSubmissions] },
215
+ status: {
216
+ ...state.status,
217
+ diagnostics: [...state.status.diagnostics],
218
+ badges: [...state.status.badges],
219
+ usage: state.usage(() => readUsageView(engine.session, engine.runtime, state.activeModel)),
220
+ footer: {
221
+ branch: engine.repository.branch,
222
+ repositoryPath: engine.repository.cwd,
223
+ pullRequest: engine.repository.pullRequest,
224
+ sessionName: engine.session?.sessionManager?.getSessionName() ?? null,
225
+ availableProviderCount: new Set(engine.runtime?.services.modelRuntime.getAvailableSnapshot?.().map(model => model.provider).filter(provider => provider !== undefined) ?? []).size,
226
+ extensionStatuses: [],
227
+ },
228
+ },
229
+ terminal: { ...state.terminal },
230
+ activeModel: state.activeModel === null ? null : { ...state.activeModel },
231
+ routedModel: routedModel === null ? null : {
232
+ model: routedModel,
233
+ ...(routed?.thinkingLevel === undefined ? {} : { thinkingLevel: readThinkingLevel(routed.thinkingLevel) }),
234
+ },
235
+ thinkingLevel: state.thinkingLevel,
236
+ activeCommandIds: [...activeCommandIds],
237
+ dialog: null,
238
+ overlay: null,
239
+ customizations: [],
240
+ diagnostics: state.diagnostics.map(diagnostic => ({ ...diagnostic })),
241
+ };
242
+ }
@@ -3,7 +3,7 @@ import type { OwnedUiModelInfo } from "../../../contracts/owned-ui/index.js";
3
3
  import type { PiAuthenticationProviderOption, PiModelsContext, PiModelsRefreshResult, PiProjectTrustContext, PiProjectTrustUpdate, PiScopedModelsContext, PiScopedModelsRefreshResult, PiSessionSelectorContext, PiTreeSelectorContext, PiWorkflowOption } from "./workflows.js";
4
4
  type PiSessionApi = AgentSession;
5
5
  type PiRuntimeApi = AgentSessionRuntime;
6
- export interface PiWorkflowContextPorts {
6
+ interface PiWorkflowContextPorts {
7
7
  /** The working directory the runtime settled on; it can change when a session is resumed elsewhere. */
8
8
  cwd(): string;
9
9
  session(): PiSessionApi | undefined;