@north-light/cli 0.3.707 → 0.3.708

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 (183) hide show
  1. package/dist/api/client.d.ts +1 -2
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/human.d.ts +9 -6
  6. package/dist/api/dto/inbox.d.ts +2 -0
  7. package/dist/api/dto/review-comments.d.ts +12 -35
  8. package/dist/api/dto/reviews.d.ts +3 -10
  9. package/dist/api/routes.d.ts +0 -1
  10. package/dist/api/routes.js +1 -1
  11. package/dist/builtin-memory/05-kinds/review/companion/00-base.md +2 -2
  12. package/dist/builtin-memory/crouter-sdk/release-notes.md +6 -0
  13. package/dist/clients/attach/chrome/canvas-panels.d.ts +1 -1
  14. package/dist/clients/attach/chrome/canvas-panels.js +1 -1
  15. package/dist/clients/attach/chrome/roster.js +6 -6
  16. package/dist/clients/attach/chrome/status-line.js +1 -1
  17. package/dist/clients/attach/chrome/ticket-panel.js +1 -1
  18. package/dist/clients/attach/input/controller.d.ts +0 -1
  19. package/dist/clients/attach/input/controller.js +3 -3
  20. package/dist/clients/attach/input/overlay-owner.d.ts +0 -1
  21. package/dist/clients/attach/input/overlay-owner.js +1 -1
  22. package/dist/clients/attach/session/keys.d.ts +0 -2
  23. package/dist/clients/attach/session/keys.js +1 -1
  24. package/dist/clients/attach/session/surface-host.d.ts +0 -5
  25. package/dist/clients/attach/session/surface-host.js +1 -1
  26. package/dist/clients/attach/viewer.js +544 -559
  27. package/dist/clients/editor-roundtrip.js +3 -0
  28. package/dist/clients/inbox/controller.d.ts +1 -6
  29. package/dist/clients/inbox/controller.js +1 -1
  30. package/dist/clients/inbox/dto-adapt.js +1 -1
  31. package/dist/clients/inbox/tui/page-body.js +1 -1
  32. package/dist/clients/inbox/tui/render.js +2 -2
  33. package/dist/clients/open-browser.d.ts +2 -0
  34. package/dist/clients/open-browser.js +1 -0
  35. package/dist/clients/surfaces/host.d.ts +0 -6
  36. package/dist/commands/human/review.js +1 -1
  37. package/dist/commands/sys/context/admin/shell.js +1 -1
  38. package/dist/core/canvas/schema-pg/025-review-anchors.sql +19 -0
  39. package/dist/core/canvas/schema-version.d.ts +1 -1
  40. package/dist/core/canvas/schema-version.js +1 -1
  41. package/dist/core/human/page-markdown.js +10 -12
  42. package/dist/core/human/tickets.js +1 -1
  43. package/dist/core/human/types.d.ts +4 -6
  44. package/dist/core/keybindings/attach-control.d.ts +0 -3
  45. package/dist/core/keybindings/attach-control.js +1 -1
  46. package/dist/core/keybindings/catalog.d.ts +1 -1
  47. package/dist/core/keybindings/catalog.js +1 -1
  48. package/dist/core/review/anchors.d.ts +28 -0
  49. package/dist/core/review/anchors.js +6 -0
  50. package/dist/core/review/comments.d.ts +2 -2
  51. package/dist/core/review/comments.js +7 -8
  52. package/dist/core/review/companion.d.ts +2 -1
  53. package/dist/core/review/companion.js +1 -1
  54. package/dist/core/review/document.d.ts +4 -17
  55. package/dist/core/review/document.js +1 -2
  56. package/dist/core/review/fork.js +2 -4
  57. package/dist/core/review/project.d.ts +1 -1
  58. package/dist/core/review/project.js +2 -2
  59. package/dist/core/review/realize.js +1 -1
  60. package/dist/core/review/stage.d.ts +2 -9
  61. package/dist/core/review/stage.js +1 -1
  62. package/dist/core/review/types.d.ts +16 -12
  63. package/dist/core/review/types.js +1 -1
  64. package/dist/core/runtime/broker-cli.js +3 -3
  65. package/dist/core/runtime/broker-extension-render.js +1 -1
  66. package/dist/core/runtime/tmux-bindings.js +3 -3
  67. package/dist/daemon/api/canvas-host.js +1 -1
  68. package/dist/daemon/api/document-page.d.ts +12 -1
  69. package/dist/daemon/api/document-page.js +6 -6
  70. package/dist/daemon/api/handlers/inbox.js +1 -1
  71. package/dist/daemon/api/handlers/review-comments.js +1 -1
  72. package/dist/daemon/api/handlers/reviews.js +1 -1
  73. package/dist/daemon/api/map.js +2 -2
  74. package/dist/daemon/api/review-page.d.ts +3 -0
  75. package/dist/daemon/api/review-page.js +13 -0
  76. package/dist/daemon/broker-memory-cap.d.ts +9 -0
  77. package/dist/daemon/broker-memory-cap.js +2 -0
  78. package/dist/daemon/broker-signals/bus.d.ts +1 -1
  79. package/dist/daemon/broker-signals/bus.js +1 -1
  80. package/dist/daemon/crtrd.js +14 -14
  81. package/dist/daemon/machine-daemon.js +1 -1
  82. package/dist/daemon/review/comment-notify.js +2 -2
  83. package/dist/daemon/review/deliver.d.ts +2 -2
  84. package/dist/daemon/review/deliver.js +6 -2
  85. package/dist/daemon/review/finish.js +1 -1
  86. package/dist/doc-editor/Geist-Variable.woff2 +0 -0
  87. package/dist/doc-editor/GeistMono-Variable.woff2 +0 -0
  88. package/dist/doc-editor/editor.css +1 -1
  89. package/dist/doc-editor/review.css +2 -0
  90. package/dist/doc-editor/review.js +149 -0
  91. package/dist/pi-extensions/canvas-review-boundary.js +3 -3
  92. package/docs/sdk/release-notes.md +6 -0
  93. package/package.json +13 -4
  94. package/packages/crouter-api/dist/api/client.js +0 -3
  95. package/packages/crouter-api/dist/api/contract.js +1 -1
  96. package/packages/crouter-api/dist/api/routes.js +0 -1
  97. package/packages/crouter-api/dist/clients/attach/chrome/canvas-panels.js +3 -3
  98. package/packages/crouter-api/dist/clients/attach/chrome/roster.js +9 -20
  99. package/packages/crouter-api/dist/clients/attach/chrome/status-line.js +1 -6
  100. package/packages/crouter-api/dist/clients/attach/chrome/ticket-panel.js +1 -1
  101. package/packages/crouter-api/dist/clients/attach/input/controller.js +0 -3
  102. package/packages/crouter-api/dist/clients/attach/input/overlay-owner.js +0 -7
  103. package/packages/crouter-api/dist/clients/attach/session/keys.js +0 -1
  104. package/packages/crouter-api/dist/clients/attach/session/surface-host.js +0 -17
  105. package/packages/crouter-api/dist/clients/attach/viewer.js +0 -37
  106. package/packages/crouter-api/dist/clients/{inbox/review/roundtrip.js → editor-roundtrip.js} +1 -1
  107. package/packages/crouter-api/dist/clients/inbox/controller.js +12 -31
  108. package/packages/crouter-api/dist/clients/inbox/dto-adapt.js +1 -0
  109. package/packages/crouter-api/dist/clients/inbox/tui/page-body.js +0 -7
  110. package/packages/crouter-api/dist/clients/inbox/tui/render.js +0 -7
  111. package/packages/crouter-api/dist/clients/open-browser.js +6 -0
  112. package/packages/crouter-api/dist/commands/human/review.js +17 -18
  113. package/packages/crouter-api/dist/commands/sys/context/admin/shell.js +1 -1
  114. package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
  115. package/packages/crouter-api/dist/core/human/page-markdown.js +2 -6
  116. package/packages/crouter-api/dist/core/human/tickets.js +2 -11
  117. package/packages/crouter-api/dist/core/keybindings/attach-control.js +0 -1
  118. package/packages/crouter-api/dist/core/keybindings/catalog.js +1 -3
  119. package/packages/crouter-api/dist/core/review/anchors.js +91 -0
  120. package/packages/crouter-api/dist/core/review/comments.js +27 -46
  121. package/packages/crouter-api/dist/core/review/companion.js +5 -9
  122. package/packages/crouter-api/dist/core/review/document.js +17 -89
  123. package/packages/crouter-api/dist/core/review/project.js +2 -1
  124. package/packages/crouter-api/dist/core/review/types.js +2 -2
  125. package/packages/crouter-api/dist/core/runtime/tmux-bindings.js +0 -5
  126. package/packages/crouter-api/dist/daemon/api/map.js +2 -6
  127. package/packages/crouter-api/dist/daemon/broker-signals/bus.js +1 -1
  128. package/packages/crouter-api/dist/daemon/review/deliver.js +4 -3
  129. package/packages/crouter-api/dist/daemon/review/finish.js +26 -47
  130. package/packages/crouter-api/package.json +1 -1
  131. package/packages/crouter-identity/package.json +1 -1
  132. package/packages/crouter-plugin/package.json +3 -3
  133. package/runtime.lock.json +1740 -505
  134. package/dist/clients/attach/overlays/file-review.d.ts +0 -10
  135. package/dist/clients/attach/overlays/file-review.js +0 -2
  136. package/dist/clients/inbox/review/anchors.d.ts +0 -41
  137. package/dist/clients/inbox/review/anchors.js +0 -1
  138. package/dist/clients/inbox/review/comments-client.d.ts +0 -74
  139. package/dist/clients/inbox/review/comments-client.js +0 -1
  140. package/dist/clients/inbox/review/companion-pane.d.ts +0 -47
  141. package/dist/clients/inbox/review/companion-pane.js +0 -1
  142. package/dist/clients/inbox/review/document-surface.d.ts +0 -212
  143. package/dist/clients/inbox/review/document-surface.js +0 -2
  144. package/dist/clients/inbox/review/frame.d.ts +0 -57
  145. package/dist/clients/inbox/review/frame.js +0 -1
  146. package/dist/clients/inbox/review/keys.d.ts +0 -69
  147. package/dist/clients/inbox/review/keys.js +0 -1
  148. package/dist/clients/inbox/review/launch.d.ts +0 -16
  149. package/dist/clients/inbox/review/launch.js +0 -1
  150. package/dist/clients/inbox/review/live-source.d.ts +0 -24
  151. package/dist/clients/inbox/review/live-source.js +0 -1
  152. package/dist/clients/inbox/review/nvim.d.ts +0 -15
  153. package/dist/clients/inbox/review/nvim.js +0 -1
  154. package/dist/clients/inbox/review/remap.d.ts +0 -51
  155. package/dist/clients/inbox/review/remap.js +0 -1
  156. package/dist/clients/inbox/review/review-client.d.ts +0 -43
  157. package/dist/clients/inbox/review/review-client.js +0 -1
  158. package/dist/clients/inbox/review/roundtrip.js +0 -3
  159. package/dist/clients/inbox/review/state.d.ts +0 -153
  160. package/dist/clients/inbox/review/state.js +0 -4
  161. package/dist/clients/inbox/review-adapter.d.ts +0 -17
  162. package/dist/clients/inbox/review-adapter.js +0 -1
  163. package/dist/core/review/remap.d.ts +0 -24
  164. package/dist/core/review/remap.js +0 -19
  165. package/dist/core/review/signal.d.ts +0 -5
  166. package/dist/core/review/signal.js +0 -1
  167. package/packages/crouter-api/dist/clients/attach/overlays/file-review.js +0 -146
  168. package/packages/crouter-api/dist/clients/inbox/review/anchors.js +0 -89
  169. package/packages/crouter-api/dist/clients/inbox/review/comments-client.js +0 -103
  170. package/packages/crouter-api/dist/clients/inbox/review/companion-pane.js +0 -109
  171. package/packages/crouter-api/dist/clients/inbox/review/document-surface.js +0 -1268
  172. package/packages/crouter-api/dist/clients/inbox/review/frame.js +0 -309
  173. package/packages/crouter-api/dist/clients/inbox/review/keys.js +0 -133
  174. package/packages/crouter-api/dist/clients/inbox/review/launch.js +0 -170
  175. package/packages/crouter-api/dist/clients/inbox/review/live-source.js +0 -160
  176. package/packages/crouter-api/dist/clients/inbox/review/nvim.js +0 -43
  177. package/packages/crouter-api/dist/clients/inbox/review/remap.js +0 -157
  178. package/packages/crouter-api/dist/clients/inbox/review/review-client.js +0 -125
  179. package/packages/crouter-api/dist/clients/inbox/review/state.js +0 -315
  180. package/packages/crouter-api/dist/clients/inbox/review-adapter.js +0 -43
  181. package/packages/crouter-api/dist/core/review/signal.js +0 -12
  182. package/packages/crouter-api/dist/core/termrender/code-doc.js +0 -92
  183. /package/dist/clients/{inbox/review/roundtrip.d.ts → editor-roundtrip.d.ts} +0 -0
@@ -1 +1 @@
1
- var N=Object.defineProperty;var n=(s,t)=>N(s,"name",{value:t,configurable:!0});import{watchInboxActivity as P}from"../../../core/human/root.js";import{resolvePageComponents as q}from"../../../core/config.js";import{fillBar as E,stripSgr as x,truncate as $,REVERSE as A}from"../../../core/canvas/nav-render.js";import{cliClient as g}from"../../../commands/api-client.js";import{visibleWidth as M}from"../../inbox/tui/ansi.js";import{pageViewFromDTO as v,settledStatusOf as w}from"../../inbox/dto-adapt.js";import{PageAdapter as S}from"../../inbox/page-adapter.js";import{decodeInboxKey as K}from"../../inbox/tui/keys.js";import{daemonErrorMessage as p,resolveFailureKind as D,resolveTicketPage as F}from"../../inbox/resolve.js";import{editBufferInEditor as H}from"../../inbox/review/roundtrip.js";function ne(s,t){const{tui:o,pal:y}=s;let c,l=!1,f=0,m=0;const b=n(()=>Math.max(3,o.terminal.rows-10),"capRows"),u=n(()=>{const e=c;e!==void 0&&(c=void 0,e.unwatch(),e.adapter.close(),t.syncCursor(),t.refreshStrip(),o.requestRender())},"closeSession"),I=n(async(e,r)=>{l=!0;try{await F(e.id,r),u(),t.setNotice("Response sent")}catch(a){const i=D(a);if(i==="unreachable"||i==="other"){t.setNotice(p(a));return}u(),t.setNotice(i==="already_settled"?await O(e.ticketId):p(a))}finally{l=!1}},"complete"),h=n(async e=>{if(c!==e||l)return;let r;try{r=await g().getHumanInboxPage(e.ticketId)}catch(a){if(c!==e)return;u(),t.setNotice(`Ticket could not be read: ${p(a)}`);return}if(!(c!==e||l)){if(r.state==="resolved"||r.state==="canceled"){u(),t.setNotice(r.state==="canceled"?"Ticket was canceled by its requester":"Ticket was resolved elsewhere");return}if(r.revision!==e.revision){e.revision=r.revision;try{e.adapter.reload(v(r))}catch{t.setNotice("Page could not be read")}o.requestRender()}}},"onActivity"),R=n(e=>{const r=e.adapter.inputBuffer();if(r===void 0)return;const a=t.suspendForChild();let i={text:r};try{i=H(r)}finally{a(),e.adapter.setInputBuffer(i.text),i.error!==void 0&&t.setNotice(i.error),o.requestRender()}},"editPageInput");return{component:{render(e){const r=c;if(r===void 0)return[];const a=Math.max(20,e-2),i=b();(a!==f||i!==m)&&(f=a,m=i,r.adapter.resize(a,i));const d=E(x($(` \u2691 ${r.title} \xB7 Esc closes`,e)),e,A),T=V(),B=U(r.adapter.render()).map(C=>z(` ${C}`,e,T));return[d,...B,y.border("\u2500".repeat(Math.max(0,e)))]},invalidate(){}},open:n(async e=>{if(c!==void 0&&u(),e.kind!=="page"){t.openInbox(e.dir);return}let r,a;try{const d=await g().getHumanInboxPage(e.inboxTicketId);if(d.state==="resolved"||d.state==="canceled"){t.setNotice(w(d));return}r=v(d),a=d.revision}catch{t.openInbox(e.dir);return}if(c!==void 0)return;f=Math.max(20,o.terminal.columns-2),m=b();const i={dir:e.dir,id:e.id,ticketId:e.inboxTicketId,title:e.title,revision:a,adapter:new S({ticketId:e.inboxTicketId,page:r,productKinds:q(),cols:f,rows:m,onDirty:n(()=>o.requestRender(),"onDirty"),onBack:n(()=>u(),"onBack"),onComplete:n(d=>{I(i,d)},"onComplete"),onEditorRequest:n(()=>R(i),"onEditorRequest")}),unwatch:n(()=>{},"unwatch")};i.unwatch=P(()=>{h(i)}),c=i,t.syncCursor(),t.refreshStrip(),o.requestRender()},"open"),handleKey:n(e=>{const r=c;if(r===void 0)return!1;const{input:a,key:i}=K(e);return r.adapter.handleKey(a,i),o.requestRender(),!0},"handleKey"),close:n(()=>u(),"close"),active:n(()=>c!==void 0,"active"),currentDir:n(()=>c?.dir,"currentDir")}}n(ne,"createTicketPanel");async function O(s){let t;try{t=w(await g().getHumanInboxPage(s))}catch(o){return`Ticket result is unreadable: ${p(o)}`}return t.charAt(0).toUpperCase()+t.slice(1)}n(O,"resolvedElsewhereNotice");function V(){const s=globalThis[Symbol.for("@earendil-works/pi-coding-agent:theme")];try{return s?.getBgAnsi?.("customMessageBg")}catch{return}}n(V,"contextCardBg");function z(s,t,o){if(o===void 0)return s;const y=s.replaceAll("\x1B[0m",`\x1B[0m${o}`).replaceAll("\x1B[49m",o),c=" ".repeat(Math.max(0,t-M(s)));return`${o}${y}${c}\x1B[49m`}n(z,"paintBg");function U(s){let t=s.length;for(;t>0&&x(s[t-1]).trim()==="";)t--;return s.slice(0,t)}n(U,"trimTrailingBlank");export{ne as createTicketPanel};
1
+ var N=Object.defineProperty;var n=(s,t)=>N(s,"name",{value:t,configurable:!0});import{watchInboxActivity as P}from"../../../core/human/root.js";import{resolvePageComponents as q}from"../../../core/config.js";import{fillBar as E,stripSgr as x,truncate as $,REVERSE as A}from"../../../core/canvas/nav-render.js";import{cliClient as g}from"../../../commands/api-client.js";import{visibleWidth as M}from"../../inbox/tui/ansi.js";import{pageViewFromDTO as v,settledStatusOf as w}from"../../inbox/dto-adapt.js";import{PageAdapter as S}from"../../inbox/page-adapter.js";import{decodeInboxKey as K}from"../../inbox/tui/keys.js";import{daemonErrorMessage as p,resolveFailureKind as D,resolveTicketPage as F}from"../../inbox/resolve.js";import{editBufferInEditor as H}from"../../editor-roundtrip.js";function ne(s,t){const{tui:o,pal:y}=s;let c,l=!1,f=0,m=0;const b=n(()=>Math.max(3,o.terminal.rows-10),"capRows"),u=n(()=>{const e=c;e!==void 0&&(c=void 0,e.unwatch(),e.adapter.close(),t.syncCursor(),t.refreshStrip(),o.requestRender())},"closeSession"),I=n(async(e,r)=>{l=!0;try{await F(e.id,r),u(),t.setNotice("Response sent")}catch(a){const i=D(a);if(i==="unreachable"||i==="other"){t.setNotice(p(a));return}u(),t.setNotice(i==="already_settled"?await O(e.ticketId):p(a))}finally{l=!1}},"complete"),h=n(async e=>{if(c!==e||l)return;let r;try{r=await g().getHumanInboxPage(e.ticketId)}catch(a){if(c!==e)return;u(),t.setNotice(`Ticket could not be read: ${p(a)}`);return}if(!(c!==e||l)){if(r.state==="resolved"||r.state==="canceled"){u(),t.setNotice(r.state==="canceled"?"Ticket was canceled by its requester":"Ticket was resolved elsewhere");return}if(r.revision!==e.revision){e.revision=r.revision;try{e.adapter.reload(v(r))}catch{t.setNotice("Page could not be read")}o.requestRender()}}},"onActivity"),R=n(e=>{const r=e.adapter.inputBuffer();if(r===void 0)return;const a=t.suspendForChild();let i={text:r};try{i=H(r)}finally{a(),e.adapter.setInputBuffer(i.text),i.error!==void 0&&t.setNotice(i.error),o.requestRender()}},"editPageInput");return{component:{render(e){const r=c;if(r===void 0)return[];const a=Math.max(20,e-2),i=b();(a!==f||i!==m)&&(f=a,m=i,r.adapter.resize(a,i));const d=E(x($(` \u2691 ${r.title} \xB7 Esc closes`,e)),e,A),T=V(),B=U(r.adapter.render()).map(C=>z(` ${C}`,e,T));return[d,...B,y.border("\u2500".repeat(Math.max(0,e)))]},invalidate(){}},open:n(async e=>{if(c!==void 0&&u(),e.kind!=="page"){t.openInbox(e.dir);return}let r,a;try{const d=await g().getHumanInboxPage(e.inboxTicketId);if(d.state==="resolved"||d.state==="canceled"){t.setNotice(w(d));return}r=v(d),a=d.revision}catch{t.openInbox(e.dir);return}if(c!==void 0)return;f=Math.max(20,o.terminal.columns-2),m=b();const i={dir:e.dir,id:e.id,ticketId:e.inboxTicketId,title:e.title,revision:a,adapter:new S({ticketId:e.inboxTicketId,page:r,productKinds:q(),cols:f,rows:m,onDirty:n(()=>o.requestRender(),"onDirty"),onBack:n(()=>u(),"onBack"),onComplete:n(d=>{I(i,d)},"onComplete"),onEditorRequest:n(()=>R(i),"onEditorRequest")}),unwatch:n(()=>{},"unwatch")};i.unwatch=P(()=>{h(i)}),c=i,t.syncCursor(),t.refreshStrip(),o.requestRender()},"open"),handleKey:n(e=>{const r=c;if(r===void 0)return!1;const{input:a,key:i}=K(e);return r.adapter.handleKey(a,i),o.requestRender(),!0},"handleKey"),close:n(()=>u(),"close"),active:n(()=>c!==void 0,"active"),currentDir:n(()=>c?.dir,"currentDir")}}n(ne,"createTicketPanel");async function O(s){let t;try{t=w(await g().getHumanInboxPage(s))}catch(o){return`Ticket result is unreadable: ${p(o)}`}return t.charAt(0).toUpperCase()+t.slice(1)}n(O,"resolvedElsewhereNotice");function V(){const s=globalThis[Symbol.for("@earendil-works/pi-coding-agent:theme")];try{return s?.getBgAnsi?.("customMessageBg")}catch{return}}n(V,"contextCardBg");function z(s,t,o){if(o===void 0)return s;const y=s.replaceAll("\x1B[0m",`\x1B[0m${o}`).replaceAll("\x1B[49m",o),c=" ".repeat(Math.max(0,t-M(s)));return`${o}${y}${c}\x1B[49m`}n(z,"paintBg");function U(s){let t=s.length;for(;t>0&&x(s[t-1]).trim()==="";)t--;return s.slice(0,t)}n(U,"trimTrailingBlank");export{ne as createTicketPanel};
@@ -63,7 +63,6 @@ export declare class InputController {
63
63
  attachDialog(request: RpcExtensionUIRequest): void;
64
64
  dismissDialog(id: string): void;
65
65
  setState(state: BrokerSnapshot['state']): void;
66
- openFileReviewPicker(candidates: string[], cwd: string, onChoose: (file: string) => void): void;
67
66
  /** Retained as a narrow delegate for auth affordances wired by the session. */
68
67
  openAuthPicker(prepare: Parameters<InputOverlayOwner['openAuthPicker']>[0]): Promise<void>;
69
68
  private readonly send;
@@ -1,7 +1,7 @@
1
- var p=Object.defineProperty;var n=(h,e)=>p(h,"name",{value:e,configurable:!0});import{spawn as u}from"node:child_process";import{readFileSync as f,unlinkSync as k,writeFileSync as g}from"node:fs";import{tmpdir as y}from"node:os";import{join as P}from"node:path";import{BROKER_READ_CAPS as v,encodeFrame as x}from"../../../core/runtime/broker-protocol.js";import{classifySubmit as w}from"../../conversation/submit.js";import{findRefTokens as C}from"../../../shared/inline-ref-grammar.js";import{dispatchSlashCommand as S,isSlashCommand as m}from"../slash/dispatch.js";import{viewerOperationForFrame as b}from"./capabilities.js";import{readClipboardImage as T,writeClipboardImageToFile as I}from"./clipboard-image.js";import{InputOverlayOwner as D}from"./overlay-owner.js";import{announceFallbackEditor as E,NO_EDITOR_MESSAGE as M,resolveEditor as A}from"../../../core/editor-resolver.js";const q=500,R=v.maxLineBytes-4*1024*1024;class z{static{n(this,"InputController")}tui;editor;keybindings;hooks;capabilities;overlays;state;lastEscapeAt=0;pastedImages=new Map;pasteSeq=0;constructor(e,t,o,i,s){this.tui=e,this.editor=t,this.keybindings=o,this.hooks=i,this.capabilities=s,this.overlays=new D(e,t,o,{send:n(r=>this.emitCommand(r),"send"),notify:n(r=>this.notify(r),"notify"),onDialogResponse:i.onDialogResponse,onRequest:i.onRequest,onMountPicker:i.onMountPicker,onUnmountPicker:i.onUnmountPicker,state:n(()=>this.state,"state")}),this.wire()}cycleLadder(e){this.emitCommand({type:"cycle_ladder",direction:e})}sendInterrupting(e){return this.emitDrive({type:"prompt",text:e,interrupt:!0})}abortTurn(){return this.state?.isStreaming!==!0?!1:this.emitCommand({type:"abort"})}attachDialog(e){this.overlays.attachDialog(e)}dismissDialog(e){this.overlays.dismissDialog(e)}setState(e){this.state=e}openFileReviewPicker(e,t,o){this.overlays.openFileReviewPicker(e,t,o)}openAuthPicker(e){return this.overlays.openAuthPicker(e)}send=n(e=>{this.emitCommand(e)},"send");emitCommand(e){const t=b(e),o=t===void 0?void 0:this.capabilities.refusal(t);return o===void 0?(this.hooks.onCommand(e),!0):(this.notify(o),!1)}openBrokerPicker(e){const t=this.capabilities.refusal("engine-drive");if(t!==void 0){this.notify(t);return}e()}wire(){this.editor.onSubmit=t=>this.handleSubmit(t),this.editor.onEscape=()=>{if(this.state?.isStreaming){this.emitCommand({type:"abort"});return}if(this.editor.getText().trim())return;const t=Date.now();t-this.lastEscapeAt<q?(this.lastEscapeAt=0,this.openBrokerPicker(()=>{this.overlays.openTreePicker()})):this.lastEscapeAt=t},this.editor.onPasteImage=()=>{this.handlePaste()};const e=this.editor;e.onPasteImagePath=t=>(this.attachImage(t),!0),this.editor.onAction("app.session.new",()=>this.emitCommand({type:"new_session"})),this.editor.onAction("app.model.cycleForward",()=>this.emitCommand({type:"cycle_model",direction:"forward"})),this.editor.onAction("app.model.cycleBackward",()=>this.emitCommand({type:"cycle_model",direction:"backward"})),this.editor.onAction("app.thinking.cycle",()=>this.emitCommand({type:"cycle_thinking"})),this.editor.onAction("app.message.followUp",()=>this.handleFollowUp()),this.editor.onAction("app.message.dequeue",()=>{this.handleDequeue()}),this.editor.onAction("app.tools.expand",()=>this.hooks.onMoreDetail?.()),this.editor.onAction("app.thinking.toggle",()=>this.hooks.onToggleThinking?.()),this.editor.onAction("app.editor.external",()=>{this.openExternalEditor()}),this.editor.onAction("app.model.select",()=>this.openBrokerPicker(()=>{this.overlays.openModelPicker()})),this.editor.onAction("app.session.tree",()=>this.openBrokerPicker(()=>{this.overlays.openTreePicker()})),this.editor.onAction("app.session.fork",()=>this.openBrokerPicker(()=>{this.overlays.openForkPicker()})),this.editor.onAction("app.session.resume",()=>this.openBrokerPicker(()=>{this.overlays.openSessionPicker()}))}slashContext(){return{send:this.send,notify:n(e=>this.notify(e),"notify"),capabilities:this.capabilities,state:this.state,cwd:process.cwd(),onGraph:this.hooks.onGraph,onInbox:this.hooks.onInbox,onHelp:this.hooks.onHelp,onQuit:this.hooks.onQuit,onCopy:this.hooks.onCopy,onCopyTarget:this.hooks.onCopyTarget,onToggleMouse:this.hooks.onToggleMouse,onColor:this.hooks.onColor,onNodeMetadata:this.hooks.onNodeMetadata,onMoreDetail:this.hooks.onMoreDetail,onLessDetail:this.hooks.onLessDetail,openModelPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openModelPicker()}),"openModelPicker"),openSessionPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openSessionPicker()}),"openSessionPicker"),openForkPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openForkPicker()}),"openForkPicker"),openTreePicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openTreePicker()}),"openTreePicker"),openSettingsPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openSettingsPicker()}),"openSettingsPicker"),openScopedModelsPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openScopedModelsPicker()}),"openScopedModelsPicker"),openMcpPicker:n(e=>this.overlays.openMcpPicker(e),"openMcpPicker"),openLoginPicker:this.hooks.openLoginPicker,openLogoutPicker:this.hooks.openLogoutPicker}}recordCommandUse(e){const t=this.hooks.frecency;if(!t)return;const o=e.slice(1).split(/\s/,1)[0];o&&t.record(`command:${o}`)}recordCompletionUse(e){const t=this.hooks.frecency;if(!t)return;const o=e.trim();if(m(o)){this.recordCommandUse(o);return}const i=this.hooks.knownRefNames?.();if(!i||i.size===0)return;const s=new Set;for(const r of C(e))i.has(r.candidate)&&!s.has(r.candidate)&&(s.add(r.candidate),t.record(`ref:${r.candidate}`))}handleSubmit(e){const t=e.trim();if(!t)return;if(m(t)&&S(t,this.slashContext())){this.recordCommandUse(t),this.editor.setText("");return}const o=this.hooks.isDormant?.()===!0;if(o&&(t.startsWith("/")||t.startsWith("!"))){this.notify("This node is parked \u2014 submit a message to wake it; broker commands need a live engine");return}const i=w(e,{isDormant:o,canWakeDormant:o&&this.capabilities.permits("wake-dormant")&&this.hooks.onDormantSubmit!==void 0,isStreaming:this.state?.isStreaming===!0});if(i.kind==="empty")return;if(i.kind==="dormant"){const a=this.hooks.onDormantSubmit;if(a===void 0)return;const d=this.expandImagePlaceholders(i.text);a(d),this.recordCompletionUse(e),this.editor.addToHistory(i.trimmed),this.editor.setText(""),this.clearPastedImages(),this.hooks.onMessageSent?.(d),this.hooks.onPromptSent?.();return}if(i.kind==="bash"){if(!this.emitDrive({type:"bash",command:i.command,excludeFromContext:i.excludeFromContext}))return;this.editor.addToHistory(i.trimmed),this.editor.setText("");return}const s=i.kind==="slash"?this.state?.isStreaming===!0?"steer":"prompt":i.kind;if(s!=="steer"&&s!=="prompt")return;const r=this.expandImagePlaceholders(i.kind==="slash"?e:i.text);this.emitDrive(s==="steer"?{type:"steer",text:r}:{type:"prompt",text:r})&&(this.recordCompletionUse(e),this.editor.addToHistory(i.trimmed),this.editor.setText(""),this.clearPastedImages(),s==="prompt"&&this.hooks.onMessageSent?.(r),this.hooks.onPromptSent?.())}handleFollowUp(){const e=this.editor.getText(),t=e.trim();t&&this.emitDrive({type:"follow_up",text:this.expandImagePlaceholders(e)})&&(this.editor.addToHistory(t),this.editor.setText(""),this.clearPastedImages())}async handleDequeue(){const e=this.capabilities.refusal("dequeue");if(e!==void 0){this.notify(e);return}const t=this.hooks.onRequest;if(t===void 0){this.notify("Restoring queued messages isn't available in this viewer");return}let o;try{o=await t({type:"dequeue"})}catch(s){this.notify(`Could not restore queued messages: ${s instanceof Error?s.message:String(s)}`);return}if(o.kind!=="dequeue"){this.notify("Unexpected reply restoring queued messages");return}const i=[...o.steering,...o.followUp];if(i.length===0){this.notify("No queued messages to restore");return}this.editor.setText([i.join(`
1
+ var l=Object.defineProperty;var n=(h,e)=>l(h,"name",{value:e,configurable:!0});import{spawn as u}from"node:child_process";import{readFileSync as f,unlinkSync as k,writeFileSync as g}from"node:fs";import{tmpdir as y}from"node:os";import{join as P}from"node:path";import{BROKER_READ_CAPS as v,encodeFrame as x}from"../../../core/runtime/broker-protocol.js";import{classifySubmit as C}from"../../conversation/submit.js";import{findRefTokens as S}from"../../../shared/inline-ref-grammar.js";import{dispatchSlashCommand as w,isSlashCommand as m}from"../slash/dispatch.js";import{viewerOperationForFrame as b}from"./capabilities.js";import{readClipboardImage as T,writeClipboardImageToFile as I}from"./clipboard-image.js";import{InputOverlayOwner as D}from"./overlay-owner.js";import{announceFallbackEditor as E,NO_EDITOR_MESSAGE as M,resolveEditor as A}from"../../../core/editor-resolver.js";const q=500,B=v.maxLineBytes-4*1024*1024;class z{static{n(this,"InputController")}tui;editor;keybindings;hooks;capabilities;overlays;state;lastEscapeAt=0;pastedImages=new Map;pasteSeq=0;constructor(e,t,o,i,s){this.tui=e,this.editor=t,this.keybindings=o,this.hooks=i,this.capabilities=s,this.overlays=new D(e,t,o,{send:n(r=>this.emitCommand(r),"send"),notify:n(r=>this.notify(r),"notify"),onDialogResponse:i.onDialogResponse,onRequest:i.onRequest,onMountPicker:i.onMountPicker,onUnmountPicker:i.onUnmountPicker,state:n(()=>this.state,"state")}),this.wire()}cycleLadder(e){this.emitCommand({type:"cycle_ladder",direction:e})}sendInterrupting(e){return this.emitDrive({type:"prompt",text:e,interrupt:!0})}abortTurn(){return this.state?.isStreaming!==!0?!1:this.emitCommand({type:"abort"})}attachDialog(e){this.overlays.attachDialog(e)}dismissDialog(e){this.overlays.dismissDialog(e)}setState(e){this.state=e}openAuthPicker(e){return this.overlays.openAuthPicker(e)}send=n(e=>{this.emitCommand(e)},"send");emitCommand(e){const t=b(e),o=t===void 0?void 0:this.capabilities.refusal(t);return o===void 0?(this.hooks.onCommand(e),!0):(this.notify(o),!1)}openBrokerPicker(e){const t=this.capabilities.refusal("engine-drive");if(t!==void 0){this.notify(t);return}e()}wire(){this.editor.onSubmit=t=>this.handleSubmit(t),this.editor.onEscape=()=>{if(this.state?.isStreaming){this.emitCommand({type:"abort"});return}if(this.editor.getText().trim())return;const t=Date.now();t-this.lastEscapeAt<q?(this.lastEscapeAt=0,this.openBrokerPicker(()=>{this.overlays.openTreePicker()})):this.lastEscapeAt=t},this.editor.onPasteImage=()=>{this.handlePaste()};const e=this.editor;e.onPasteImagePath=t=>(this.attachImage(t),!0),this.editor.onAction("app.session.new",()=>this.emitCommand({type:"new_session"})),this.editor.onAction("app.model.cycleForward",()=>this.emitCommand({type:"cycle_model",direction:"forward"})),this.editor.onAction("app.model.cycleBackward",()=>this.emitCommand({type:"cycle_model",direction:"backward"})),this.editor.onAction("app.thinking.cycle",()=>this.emitCommand({type:"cycle_thinking"})),this.editor.onAction("app.message.followUp",()=>this.handleFollowUp()),this.editor.onAction("app.message.dequeue",()=>{this.handleDequeue()}),this.editor.onAction("app.tools.expand",()=>this.hooks.onMoreDetail?.()),this.editor.onAction("app.thinking.toggle",()=>this.hooks.onToggleThinking?.()),this.editor.onAction("app.editor.external",()=>{this.openExternalEditor()}),this.editor.onAction("app.model.select",()=>this.openBrokerPicker(()=>{this.overlays.openModelPicker()})),this.editor.onAction("app.session.tree",()=>this.openBrokerPicker(()=>{this.overlays.openTreePicker()})),this.editor.onAction("app.session.fork",()=>this.openBrokerPicker(()=>{this.overlays.openForkPicker()})),this.editor.onAction("app.session.resume",()=>this.openBrokerPicker(()=>{this.overlays.openSessionPicker()}))}slashContext(){return{send:this.send,notify:n(e=>this.notify(e),"notify"),capabilities:this.capabilities,state:this.state,cwd:process.cwd(),onGraph:this.hooks.onGraph,onInbox:this.hooks.onInbox,onHelp:this.hooks.onHelp,onQuit:this.hooks.onQuit,onCopy:this.hooks.onCopy,onCopyTarget:this.hooks.onCopyTarget,onToggleMouse:this.hooks.onToggleMouse,onColor:this.hooks.onColor,onNodeMetadata:this.hooks.onNodeMetadata,onMoreDetail:this.hooks.onMoreDetail,onLessDetail:this.hooks.onLessDetail,openModelPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openModelPicker()}),"openModelPicker"),openSessionPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openSessionPicker()}),"openSessionPicker"),openForkPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openForkPicker()}),"openForkPicker"),openTreePicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openTreePicker()}),"openTreePicker"),openSettingsPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openSettingsPicker()}),"openSettingsPicker"),openScopedModelsPicker:n(()=>this.openBrokerPicker(()=>{this.overlays.openScopedModelsPicker()}),"openScopedModelsPicker"),openMcpPicker:n(e=>this.overlays.openMcpPicker(e),"openMcpPicker"),openLoginPicker:this.hooks.openLoginPicker,openLogoutPicker:this.hooks.openLogoutPicker}}recordCommandUse(e){const t=this.hooks.frecency;if(!t)return;const o=e.slice(1).split(/\s/,1)[0];o&&t.record(`command:${o}`)}recordCompletionUse(e){const t=this.hooks.frecency;if(!t)return;const o=e.trim();if(m(o)){this.recordCommandUse(o);return}const i=this.hooks.knownRefNames?.();if(!i||i.size===0)return;const s=new Set;for(const r of S(e))i.has(r.candidate)&&!s.has(r.candidate)&&(s.add(r.candidate),t.record(`ref:${r.candidate}`))}handleSubmit(e){const t=e.trim();if(!t)return;if(m(t)&&w(t,this.slashContext())){this.recordCommandUse(t),this.editor.setText("");return}const o=this.hooks.isDormant?.()===!0;if(o&&(t.startsWith("/")||t.startsWith("!"))){this.notify("This node is parked \u2014 submit a message to wake it; broker commands need a live engine");return}const i=C(e,{isDormant:o,canWakeDormant:o&&this.capabilities.permits("wake-dormant")&&this.hooks.onDormantSubmit!==void 0,isStreaming:this.state?.isStreaming===!0});if(i.kind==="empty")return;if(i.kind==="dormant"){const a=this.hooks.onDormantSubmit;if(a===void 0)return;const d=this.expandImagePlaceholders(i.text);a(d),this.recordCompletionUse(e),this.editor.addToHistory(i.trimmed),this.editor.setText(""),this.clearPastedImages(),this.hooks.onMessageSent?.(d),this.hooks.onPromptSent?.();return}if(i.kind==="bash"){if(!this.emitDrive({type:"bash",command:i.command,excludeFromContext:i.excludeFromContext}))return;this.editor.addToHistory(i.trimmed),this.editor.setText("");return}const s=i.kind==="slash"?this.state?.isStreaming===!0?"steer":"prompt":i.kind;if(s!=="steer"&&s!=="prompt")return;const r=this.expandImagePlaceholders(i.kind==="slash"?e:i.text);this.emitDrive(s==="steer"?{type:"steer",text:r}:{type:"prompt",text:r})&&(this.recordCompletionUse(e),this.editor.addToHistory(i.trimmed),this.editor.setText(""),this.clearPastedImages(),s==="prompt"&&this.hooks.onMessageSent?.(r),this.hooks.onPromptSent?.())}handleFollowUp(){const e=this.editor.getText(),t=e.trim();t&&this.emitDrive({type:"follow_up",text:this.expandImagePlaceholders(e)})&&(this.editor.addToHistory(t),this.editor.setText(""),this.clearPastedImages())}async handleDequeue(){const e=this.capabilities.refusal("dequeue");if(e!==void 0){this.notify(e);return}const t=this.hooks.onRequest;if(t===void 0){this.notify("Restoring queued messages isn't available in this viewer");return}let o;try{o=await t({type:"dequeue"})}catch(s){this.notify(`Could not restore queued messages: ${s instanceof Error?s.message:String(s)}`);return}if(o.kind!=="dequeue"){this.notify("Unexpected reply restoring queued messages");return}const i=[...o.steering,...o.followUp];if(i.length===0){this.notify("No queued messages to restore");return}this.editor.setText([i.join(`
2
2
 
3
3
  `),this.editor.getText()].filter(s=>s.trim()).join(`
4
4
 
5
- `)),this.tui.requestRender(),this.notify(`Restored ${i.length} queued message${i.length>1?"s":""} to editor`)}emitDrive(e){try{const t=Buffer.byteLength(x(e));if(t>R)return this.notify(`Message too large to send (${Math.round(t/(1024*1024))} MiB) \u2014 shorten the text or remove an attached image`),!1}catch{return this.notify("Message could not be encoded"),!1}return this.emitCommand(e)}async handlePaste(){try{const e=await T();if(!e){this.notify("No image in the clipboard");return}if(!e.image){this.notify(e.note??"Image not pasted");return}this.attachImage(I(e.image),e.note)}catch{this.notify("Could not read the clipboard image")}}attachImage(e,t){const o=++this.pasteSeq;this.pastedImages.set(o,e);const i=this.editor.getText();this.editor.insertTextAtCursor(`${i&&!/\s$/.test(i)?" ":""}[Image #${o}] `),this.notify(t?`Image #${o} attached (${t})`:`Image #${o} attached`),this.tui.requestRender()}expandImagePlaceholders(e){return e.replace(/\[Image #(\d+)\]/g,(t,o)=>this.pastedImages.get(Number(o))??t)}clearPastedImages(){this.pastedImages.clear(),this.pasteSeq=0}async openExternalEditor(){const e=A();if(e===null){this.notify(M);return}const t=e.command,o=this.editor,i=P(y(),`crtr-attach-editor-${Date.now()}.pi.md`);try{g(i,o.getExpandedText?.()??this.editor.getText(),"utf-8"),this.tui.stop();const[s,...r]=t.split(" ");process.stdout.write(`Launching external editor: ${t}
5
+ `)),this.tui.requestRender(),this.notify(`Restored ${i.length} queued message${i.length>1?"s":""} to editor`)}emitDrive(e){try{const t=Buffer.byteLength(x(e));if(t>B)return this.notify(`Message too large to send (${Math.round(t/(1024*1024))} MiB) \u2014 shorten the text or remove an attached image`),!1}catch{return this.notify("Message could not be encoded"),!1}return this.emitCommand(e)}async handlePaste(){try{const e=await T();if(!e){this.notify("No image in the clipboard");return}if(!e.image){this.notify(e.note??"Image not pasted");return}this.attachImage(I(e.image),e.note)}catch{this.notify("Could not read the clipboard image")}}attachImage(e,t){const o=++this.pasteSeq;this.pastedImages.set(o,e);const i=this.editor.getText();this.editor.insertTextAtCursor(`${i&&!/\s$/.test(i)?" ":""}[Image #${o}] `),this.notify(t?`Image #${o} attached (${t})`:`Image #${o} attached`),this.tui.requestRender()}expandImagePlaceholders(e){return e.replace(/\[Image #(\d+)\]/g,(t,o)=>this.pastedImages.get(Number(o))??t)}clearPastedImages(){this.pastedImages.clear(),this.pasteSeq=0}async openExternalEditor(){const e=A();if(e===null){this.notify(M);return}const t=e.command,o=this.editor,i=P(y(),`crtr-attach-editor-${Date.now()}.pi.md`);try{g(i,o.getExpandedText?.()??this.editor.getText(),"utf-8"),this.tui.stop();const[s,...r]=t.split(" ");process.stdout.write(`Launching external editor: ${t}
6
6
  The viewer resumes when it exits.
7
- `),E(e);const a=await new Promise(d=>{const c=u(s,[...r,i],{stdio:"inherit",shell:process.platform==="win32"});c.on("error",()=>d(null)),c.on("close",l=>d(l))});a===null&&e.source==="fallback"&&this.notify(`Could not launch ${t} \u2014 set $EDITOR to an editor you have installed`),a===0&&this.editor.setText(f(i,"utf-8").replace(/\n$/,""))}catch(s){this.notify(`External editor failed: ${s instanceof Error?s.message:String(s)}`)}finally{try{k(i)}catch{}this.tui.start(),this.tui.requestRender(!0)}}notify(e){this.hooks.onNotice?.(e)}}export{z as InputController};
7
+ `),E(e);const a=await new Promise(d=>{const c=u(s,[...r,i],{stdio:"inherit",shell:process.platform==="win32"});c.on("error",()=>d(null)),c.on("close",p=>d(p))});a===null&&e.source==="fallback"&&this.notify(`Could not launch ${t} \u2014 set $EDITOR to an editor you have installed`),a===0&&this.editor.setText(f(i,"utf-8").replace(/\n$/,""))}catch(s){this.notify(`External editor failed: ${s instanceof Error?s.message:String(s)}`)}finally{try{k(i)}catch{}this.tui.start(),this.tui.requestRender(!0)}}notify(e){this.hooks.onNotice?.(e)}}export{z as InputController};
@@ -34,7 +34,6 @@ export declare class InputOverlayOwner {
34
34
  openSettingsPicker(): Promise<void>;
35
35
  openScopedModelsPicker(): Promise<void>;
36
36
  openMcpPicker(serverName?: string): void;
37
- openFileReviewPicker(candidates: string[], cwd: string, onChoose: (file: string) => void): void;
38
37
  openAuthPicker(prepare: () => Promise<(controls: PickerControls) => Picker>): Promise<void>;
39
38
  private openPicker;
40
39
  private showPicker;
@@ -1 +1 @@
1
- var f=Object.defineProperty;var h=(u,e)=>f(u,"name",{value:e,configurable:!0});import{isBlockingDialog as a,renderDialog as g}from"../overlays/dialogs.js";import{buildForkPicker as P,buildModelPicker as y,buildScopedModelsPicker as m,buildSessionPicker as S,buildSettingsPicker as w,buildTreePicker as _}from"../overlays/pickers.js";import{buildMcpPicker as b,readMcpServers as M,startMcpServerAction as R,MCP_EMPTY_STATE_HINT as q}from"../overlays/mcp.js";import{buildFileReviewPicker as v}from"../overlays/file-review.js";const T={anchor:"center",width:"80%",maxHeight:"85%"};class O{static{h(this,"InputOverlayOwner")}tui;editor;keybindings;hooks;dialog;dialogId;picker;openSeq=0;constructor(e,i,t,s){this.tui=e,this.editor=i,this.keybindings=t,this.hooks=s}attachDialog(e){if(e.method==="notify"){const i=e.notifyType==="error"?"Error: ":e.notifyType==="warning"?"Warning: ":"";this.hooks.notify(`${i}${e.message}`),this.tui.requestRender();return}a(e)&&(this.dialog?.dismiss(),this.dialogId=e.id,this.dialog=g(this.tui,e,i=>{this.dialog=void 0,this.dialogId=void 0,this.hooks.onDialogResponse(i)},this.keybindings),this.tui.requestRender())}dismissDialog(e){this.dialogId===e&&(this.dialog?.dismiss(),this.dialog=void 0,this.dialogId=void 0,this.tui.requestRender())}openModelPicker(){return this.openPicker({type:"list_models"},"list_models","model",(e,i)=>y(this.tui,e,this.hooks.send,i))}openSessionPicker(){const e=this.hooks.onRequest;return e===void 0?(this.hooks.notify("The session picker isn't available in this viewer"),Promise.resolve()):(this.openSeq++,this.showPicker(i=>S(this.tui,this.hooks.state()?.sessionFile,e,this.keybindings,this.hooks.send,i.close)),Promise.resolve())}openTreePicker(){return this.openPicker({type:"get_tree"},"get_tree","tree",(e,i)=>_(this.tui,e,this.hooks.send,i))}openForkPicker(){return this.openPicker({type:"get_tree"},"get_tree","fork",(e,i)=>P(e,this.hooks.send,i))}openSettingsPicker(){return this.openPicker({type:"get_settings"},"get_settings","settings",(e,i)=>w(e,this.hooks.send,i))}openScopedModelsPicker(){return this.openPicker({type:"list_scoped_models"},"list_scoped_models","scoped-models",(e,i)=>m(e,i,this.hooks.notify))}openMcpPicker(e){const i=M();if(i.length===0){this.hooks.notify(q);return}if(e!==void 0){const t=i.find(s=>s.name===e);if(t===void 0){this.hooks.notify(`No MCP server named ${JSON.stringify(e)} \u2014 usage: /mcp [server]`);return}R(t,this.hooks.send,this.hooks.notify);return}this.showPicker(t=>b(i,this.hooks.send,t.close,this.hooks.notify))}openFileReviewPicker(e,i,t){this.showPicker(s=>v(e,i,n=>{s.close(),t(n)},s.close,this.hooks.notify))}async openAuthPicker(e){const i=++this.openSeq;let t;try{t=await e()}catch(s){this.hooks.notify(`Could not open the auth picker: ${s instanceof Error?s.message:String(s)}`);return}i===this.openSeq&&this.showPicker(t)}async openPicker(e,i,t,s){const n=this.hooks.onRequest;if(n===void 0){this.hooks.notify(`The ${t} picker isn't available in this viewer`);return}const c=++this.openSeq;let d;try{d=await n(e)}catch(r){this.hooks.notify(`Could not open the ${t} picker: ${r instanceof Error?r.message:String(r)}`);return}if(c===this.openSeq){if(d.kind!==i){this.hooks.notify(`Unexpected reply building the ${t} picker`);return}this.showPicker(r=>s(d,r.close))}}showPicker(e){this.picker?.dismiss();const i=this.hooks.onMountPicker!==void 0&&this.hooks.onUnmountPicker!==void 0;let t,s,n=!1;const c=h(()=>{const o=s?.component;try{o?.dispose?.()}catch{}},"disposeCurrent"),d=h(o=>{i?this.hooks.onMountPicker(o.component):t=this.tui.showOverlay(o.component,T),this.tui.setFocus(o.focus)},"mount"),r=h(()=>{i?this.hooks.onUnmountPicker?.():t?.hide()},"unmount"),k=h((o,p)=>{n||(c(),r(),s={component:o,focus:p},d(s),this.tui.requestRender())},"replace"),l=h(()=>{n||(n=!0,c(),r(),this.picker=void 0,this.tui.setFocus(this.editor),this.tui.requestRender())},"close");try{s=e({close:l,replace:k})}catch(o){this.hooks.notify(`Could not open picker: ${o instanceof Error?o.message:String(o)}`);return}d(s),this.picker={dismiss:h(()=>{n||(n=!0,c(),r())},"dismiss")},this.tui.requestRender()}}export{O as InputOverlayOwner};
1
+ var a=Object.defineProperty;var h=(u,e)=>a(u,"name",{value:e,configurable:!0});import{isBlockingDialog as f,renderDialog as g}from"../overlays/dialogs.js";import{buildForkPicker as y,buildModelPicker as P,buildScopedModelsPicker as m,buildSessionPicker as S,buildSettingsPicker as _,buildTreePicker as w}from"../overlays/pickers.js";import{buildMcpPicker as b,readMcpServers as M,startMcpServerAction as q,MCP_EMPTY_STATE_HINT as R}from"../overlays/mcp.js";const T={anchor:"center",width:"80%",maxHeight:"85%"};class C{static{h(this,"InputOverlayOwner")}tui;editor;keybindings;hooks;dialog;dialogId;picker;openSeq=0;constructor(e,i,t,s){this.tui=e,this.editor=i,this.keybindings=t,this.hooks=s}attachDialog(e){if(e.method==="notify"){const i=e.notifyType==="error"?"Error: ":e.notifyType==="warning"?"Warning: ":"";this.hooks.notify(`${i}${e.message}`),this.tui.requestRender();return}f(e)&&(this.dialog?.dismiss(),this.dialogId=e.id,this.dialog=g(this.tui,e,i=>{this.dialog=void 0,this.dialogId=void 0,this.hooks.onDialogResponse(i)},this.keybindings),this.tui.requestRender())}dismissDialog(e){this.dialogId===e&&(this.dialog?.dismiss(),this.dialog=void 0,this.dialogId=void 0,this.tui.requestRender())}openModelPicker(){return this.openPicker({type:"list_models"},"list_models","model",(e,i)=>P(this.tui,e,this.hooks.send,i))}openSessionPicker(){const e=this.hooks.onRequest;return e===void 0?(this.hooks.notify("The session picker isn't available in this viewer"),Promise.resolve()):(this.openSeq++,this.showPicker(i=>S(this.tui,this.hooks.state()?.sessionFile,e,this.keybindings,this.hooks.send,i.close)),Promise.resolve())}openTreePicker(){return this.openPicker({type:"get_tree"},"get_tree","tree",(e,i)=>w(this.tui,e,this.hooks.send,i))}openForkPicker(){return this.openPicker({type:"get_tree"},"get_tree","fork",(e,i)=>y(e,this.hooks.send,i))}openSettingsPicker(){return this.openPicker({type:"get_settings"},"get_settings","settings",(e,i)=>_(e,this.hooks.send,i))}openScopedModelsPicker(){return this.openPicker({type:"list_scoped_models"},"list_scoped_models","scoped-models",(e,i)=>m(e,i,this.hooks.notify))}openMcpPicker(e){const i=M();if(i.length===0){this.hooks.notify(R);return}if(e!==void 0){const t=i.find(s=>s.name===e);if(t===void 0){this.hooks.notify(`No MCP server named ${JSON.stringify(e)} \u2014 usage: /mcp [server]`);return}q(t,this.hooks.send,this.hooks.notify);return}this.showPicker(t=>b(i,this.hooks.send,t.close,this.hooks.notify))}async openAuthPicker(e){const i=++this.openSeq;let t;try{t=await e()}catch(s){this.hooks.notify(`Could not open the auth picker: ${s instanceof Error?s.message:String(s)}`);return}i===this.openSeq&&this.showPicker(t)}async openPicker(e,i,t,s){const r=this.hooks.onRequest;if(r===void 0){this.hooks.notify(`The ${t} picker isn't available in this viewer`);return}const c=++this.openSeq;let d;try{d=await r(e)}catch(n){this.hooks.notify(`Could not open the ${t} picker: ${n instanceof Error?n.message:String(n)}`);return}if(c===this.openSeq){if(d.kind!==i){this.hooks.notify(`Unexpected reply building the ${t} picker`);return}this.showPicker(n=>s(d,n.close))}}showPicker(e){this.picker?.dismiss();const i=this.hooks.onMountPicker!==void 0&&this.hooks.onUnmountPicker!==void 0;let t,s,r=!1;const c=h(()=>{const o=s?.component;try{o?.dispose?.()}catch{}},"disposeCurrent"),d=h(o=>{i?this.hooks.onMountPicker(o.component):t=this.tui.showOverlay(o.component,T),this.tui.setFocus(o.focus)},"mount"),n=h(()=>{i?this.hooks.onUnmountPicker?.():t?.hide()},"unmount"),k=h((o,p)=>{r||(c(),n(),s={component:o,focus:p},d(s),this.tui.requestRender())},"replace"),l=h(()=>{r||(r=!0,c(),n(),this.picker=void 0,this.tui.setFocus(this.editor),this.tui.requestRender())},"close");try{s=e({close:l,replace:k})}catch(o){this.hooks.notify(`Could not open picker: ${o instanceof Error?o.message:String(o)}`);return}d(s),this.picker={dismiss:h(()=>{r||(r=!0,c(),n())},"dismiss")},this.tui.requestRender()}}export{C as InputOverlayOwner};
@@ -33,8 +33,6 @@ export interface KeyHooks {
33
33
  toggleInboxStrip: () => void;
34
34
  cycleModelLadder: (direction: 'forward' | 'backward') => void;
35
35
  inspectLoadedCommand: () => void;
36
- /** The file-review chord — pick a transcript file and open its review window. */
37
- openFileReview: () => void;
38
36
  /** Search the current node's local profile project files. */
39
37
  openProfileFiles: () => void;
40
38
  /** Open incremental search over the displayed transcript. */
@@ -1 +1 @@
1
- var f=Object.defineProperty;var r=(c,e)=>f(c,"name",{value:e,configurable:!0});import{extractAttachControlInput as g}from"../../../core/keybindings/index.js";import{dispatchAttachAction as m,dispatchAttachBinding as o,dispatchAttachViewportBinding as h}from"./bindings.js";import{FOCUS_IN as l,FOCUS_OUT as d}from"./focus-events.js";const w=1e3;function y(c,e){const{tui:a,editor:u}=c;let i=0;const p={"crtr.attach.detach":e.detach,"crtr.attach.clear-or-detach":r(()=>{const t=Date.now();if(t-i<w){i=0,e.cancelTurn();return}i=t,u.setText(""),e.setNotice(`Editor cleared \u2014 press ${e.detachHint()} again to cancel the agent`),a.requestRender()},"crtr.attach.clear-or-detach"),"crtr.attach.graph.toggle":e.toggleGraph,"crtr.attach.help.toggle":e.toggleHelp,"crtr.attach.inbox.toggle":e.toggleInbox,"crtr.attach.inbox-strip":e.toggleInboxStrip,"crtr.attach.model-ladder.next":r(()=>e.cycleModelLadder("forward"),"crtr.attach.model-ladder.next"),"crtr.attach.model-ladder.previous":r(()=>e.cycleModelLadder("backward"),"crtr.attach.model-ladder.previous"),"crtr.attach.command.inspect":e.inspectLoadedCommand,"crtr.attach.file-review":e.openFileReview,"crtr.attach.profile-files":e.openProfileFiles,"crtr.attach.search":e.openSearch,"crtr.attach.whip":e.whip,"crtr.attach.reload-viewer":e.reloadViewer};return a.addInputListener(t=>{if(t.includes(l)||t.includes(d)){e.setPaneFocused(t.lastIndexOf(l)>t.lastIndexOf(d)),a.requestRender();const s=t.replaceAll(l,"").replaceAll(d,"");return s.length>0?{data:s}:{consume:!0}}const n=g(t);if(n!==void 0)return m(n.actionId,p),n.remaining.length>0?{data:n.remaining}:{consume:!0};if(!e.hasExclusiveSurface())return e.panelHandleKey(t)?{consume:!0}:e.searchHandleKey(t)?{consume:!0}:u.focused&&h(e.bindings(),t,e.viewportActions())?{consume:!0}:e.stripHandleKey(t)?{consume:!0}:e.rosterHandleKey(t)?{consume:!0}:o(e.bindings(),t,p)?{consume:!0}:void 0})}r(y,"installGlobalKeys");export{y as installGlobalKeys};
1
+ var g=Object.defineProperty;var r=(c,e)=>g(c,"name",{value:e,configurable:!0});import{extractAttachControlInput as f}from"../../../core/keybindings/index.js";import{dispatchAttachAction as o,dispatchAttachBinding as m,dispatchAttachViewportBinding as h}from"./bindings.js";import{FOCUS_IN as l,FOCUS_OUT as d}from"./focus-events.js";const x=1e3;function y(c,e){const{tui:a,editor:u}=c;let i=0;const p={"crtr.attach.detach":e.detach,"crtr.attach.clear-or-detach":r(()=>{const t=Date.now();if(t-i<x){i=0,e.cancelTurn();return}i=t,u.setText(""),e.setNotice(`Editor cleared \u2014 press ${e.detachHint()} again to cancel the agent`),a.requestRender()},"crtr.attach.clear-or-detach"),"crtr.attach.graph.toggle":e.toggleGraph,"crtr.attach.help.toggle":e.toggleHelp,"crtr.attach.inbox.toggle":e.toggleInbox,"crtr.attach.inbox-strip":e.toggleInboxStrip,"crtr.attach.model-ladder.next":r(()=>e.cycleModelLadder("forward"),"crtr.attach.model-ladder.next"),"crtr.attach.model-ladder.previous":r(()=>e.cycleModelLadder("backward"),"crtr.attach.model-ladder.previous"),"crtr.attach.command.inspect":e.inspectLoadedCommand,"crtr.attach.profile-files":e.openProfileFiles,"crtr.attach.search":e.openSearch,"crtr.attach.whip":e.whip,"crtr.attach.reload-viewer":e.reloadViewer};return a.addInputListener(t=>{if(t.includes(l)||t.includes(d)){e.setPaneFocused(t.lastIndexOf(l)>t.lastIndexOf(d)),a.requestRender();const s=t.replaceAll(l,"").replaceAll(d,"");return s.length>0?{data:s}:{consume:!0}}const n=f(t);if(n!==void 0)return o(n.actionId,p),n.remaining.length>0?{data:n.remaining}:{consume:!0};if(!e.hasExclusiveSurface())return e.panelHandleKey(t)?{consume:!0}:e.searchHandleKey(t)?{consume:!0}:u.focused&&h(e.bindings(),t,e.viewportActions())?{consume:!0}:e.stripHandleKey(t)?{consume:!0}:e.rosterHandleKey(t)?{consume:!0}:m(e.bindings(),t,p)?{consume:!0}:void 0})}r(y,"installGlobalKeys");export{y as installGlobalKeys};
@@ -48,11 +48,6 @@ export declare class ViewerSurfaceHost implements SurfaceHost {
48
48
  notice(text: string, opts?: NoticeOptions): void;
49
49
  suspendForChild(): () => void;
50
50
  focusNode(nodeId: string): Promise<boolean>;
51
- pickReviewFile(spec: {
52
- candidates: readonly string[];
53
- cwd: string;
54
- title?: string;
55
- }): Promise<string | null>;
56
51
  /** Offer wheel input to the topmost surface only. */
57
52
  handleWheel(direction: 'up' | 'down', lines: number): boolean;
58
53
  /** Whether a full-pane surface currently owns input. */
@@ -1 +1 @@
1
- var f=Object.defineProperty;var n=(r,e)=>f(r,"name",{value:e,configurable:!0});import{truncateToWidth as u}from"@earendil-works/pi-tui";import{cliClient as d}from"../../../commands/api-client.js";import{focusViewer as m}from"../../../core/runtime/focus-viewer.js";import{daemonErrorMessage as p}from"../../inbox/resolve.js";import{buildFileReviewPicker as v}from"../overlays/file-review.js";import{reportInvariant as g}from"./invariant.js";import{SurfaceFrame as w}from"./surface-frame.js";const k={anchor:"top-left",width:"100%",maxHeight:"100%",margin:0},N={anchor:"top-left",width:"100%",margin:0,nonCapturing:!0};class F{static{n(this,"ViewerSurfaceHost")}capabilities;tui;mouse;getRows;statusNotice;formatNotice;noticeMs;selfPane;stack=[];noticeOverlay;noticeTimer;constructor(e){this.tui=e.tui,this.mouse=e.mouse,this.getRows=e.rows,this.statusNotice=e.statusNotice,this.formatNotice=e.formatNotice,this.noticeMs=e.noticeMs,this.selfPane=e.selfPane,this.capabilities={...e.capabilities,selfPane:e.selfPane}}mount(e,s){this.disposeNotice();const o=new w(e,s?.focus??e,this.getRows),c=this.tui.showOverlay(o,k),t={component:e,frame:o,overlay:c,cleanup:[],closed:!1,closing:!1},i=this.stack[this.stack.length-1];return i&&i.overlay.setHidden(!0),this.stack.push(t),{close:n(()=>this.closeEntry(t,!0),"close"),invalidate:n(()=>{!t.closed&&this.stack[this.stack.length-1]===t&&this.tui.requestRender()},"invalidate"),onClose:n(a=>{if(t.closed||t.closing){l("onClose registered after surface close");return}t.cleanup.push(a)},"onClose")}}notice(e,s){if(this.disposeNotice(),this.stack.length===0){this.statusNotice(e,s);return}if(e==="")return;const o=new O(()=>this.formatNotice(e));this.noticeOverlay=this.tui.showOverlay(o,N),s?.sticky!==!0&&this.noticeMs>0&&(this.noticeTimer=setTimeout(()=>{this.noticeTimer=void 0,this.disposeNoticeOverlay()},this.noticeMs))}suspendForChild(){return this.tui.stop(),()=>{this.tui.start(),this.mouse.reassert(),this.tui.invalidate(),this.tui.requestRender(!0)}}async focusNode(e){if(!this.capabilities.canFocusNode||this.selfPane===void 0||this.selfPane==="")return this.notice("Focusing a node needs a local viewer in tmux"),!1;try{const s=d(),o=await s.getNode(e),c=await m(s,e,{pane:this.selfPane,cwd:o.cwd,name:o.name});return c.focused||this.notice("Could not open that node\u2019s viewer"),c.focused}catch(s){return this.notice(p(s)),!1}}pickReviewFile(e){return new Promise(s=>{let o,c=!1;const t=n(a=>{c||(c=!0,s(a),o.close())},"settle"),i=v(e.candidates,e.cwd,a=>t(a),()=>t(null),a=>this.notice(a));o=this.mount(y(i.component,e.title),{focus:i.focus}),o.onClose(()=>t(null))})}handleWheel(e,s){return this.stack[this.stack.length-1]?.component.handleWheel?.(e,s)??!1}hasFullPaneSurface(){return this.stack.length>0}closeAll(){const e=this.stack[0];e&&this.closeEntry(e,!1),this.disposeNotice()}closeEntry(e,s){if(e.closed||e.closing)return;if(this.stack.indexOf(e)===-1){e.closed=!0;return}for(e.closing=!0;this.stack.indexOf(e)!==-1;){const t=this.stack.indexOf(e),i=this.stack[t+1];if(!i)break;this.closeEntry(i,!1)}try{e.overlay.hide()}catch(t){l(`surface overlay hide failed: ${h(t)}`)}for(const t of e.cleanup)try{const i=t();i&&typeof i.then=="function"&&i.catch(a=>l(`surface cleanup failed: ${h(a)}`))}catch(i){l(`surface cleanup failed: ${h(i)}`)}e.cleanup.length=0,e.closed=!0,e.closing=!1;const c=this.stack.indexOf(e);if(c!==-1&&this.stack.splice(c,1),s){this.disposeNotice();const t=this.stack[this.stack.length-1];t&&t.overlay.setHidden(!1)}}disposeNotice(){this.disposeNoticeOverlay(),this.noticeTimer!==void 0&&(clearTimeout(this.noticeTimer),this.noticeTimer=void 0)}disposeNoticeOverlay(){this.noticeOverlay?.hide(),this.noticeOverlay=void 0}}class O{static{n(this,"NoticeOverlay")}text;constructor(e){this.text=e}render(e){return[u(this.text(),Math.max(0,e),"",!0)]}invalidate(){}}function y(r,e){let s=0;return{setRows:n(o=>{s=Math.max(0,Math.floor(o))},"setRows"),render:n(o=>{const c=r.render(o),i=(e===void 0?c:[u(e,Math.max(0,o),"",!0),...c.slice(1)]).slice(0,s);for(;i.length<s;)i.push("");return i},"render"),invalidate:n(()=>r.invalidate(),"invalidate")}}n(y,"titled");function l(r){g("surface-host",r)}n(l,"reportInvariant");function h(r){return r instanceof Error?r.message:String(r)}n(h,"errorMessage");export{F as ViewerSurfaceHost};
1
+ var f=Object.defineProperty;var r=(c,e)=>f(c,"name",{value:e,configurable:!0});import{truncateToWidth as u}from"@earendil-works/pi-tui";import{cliClient as d}from"../../../commands/api-client.js";import{focusViewer as m}from"../../../core/runtime/focus-viewer.js";import{daemonErrorMessage as p}from"../../inbox/resolve.js";import{reportInvariant as g}from"./invariant.js";import{SurfaceFrame as v}from"./surface-frame.js";const N={anchor:"top-left",width:"100%",maxHeight:"100%",margin:0},k={anchor:"top-left",width:"100%",margin:0,nonCapturing:!0};class R{static{r(this,"ViewerSurfaceHost")}capabilities;tui;mouse;getRows;statusNotice;formatNotice;noticeMs;selfPane;stack=[];noticeOverlay;noticeTimer;constructor(e){this.tui=e.tui,this.mouse=e.mouse,this.getRows=e.rows,this.statusNotice=e.statusNotice,this.formatNotice=e.formatNotice,this.noticeMs=e.noticeMs,this.selfPane=e.selfPane,this.capabilities={...e.capabilities,selfPane:e.selfPane}}mount(e,t){this.disposeNotice();const o=new v(e,t?.focus??e,this.getRows),n=this.tui.showOverlay(o,N),s={component:e,frame:o,overlay:n,cleanup:[],closed:!1,closing:!1},i=this.stack[this.stack.length-1];return i&&i.overlay.setHidden(!0),this.stack.push(s),{close:r(()=>this.closeEntry(s,!0),"close"),invalidate:r(()=>{!s.closed&&this.stack[this.stack.length-1]===s&&this.tui.requestRender()},"invalidate"),onClose:r(l=>{if(s.closed||s.closing){a("onClose registered after surface close");return}s.cleanup.push(l)},"onClose")}}notice(e,t){if(this.disposeNotice(),this.stack.length===0){this.statusNotice(e,t);return}if(e==="")return;const o=new w(()=>this.formatNotice(e));this.noticeOverlay=this.tui.showOverlay(o,k),t?.sticky!==!0&&this.noticeMs>0&&(this.noticeTimer=setTimeout(()=>{this.noticeTimer=void 0,this.disposeNoticeOverlay()},this.noticeMs))}suspendForChild(){return this.tui.stop(),()=>{this.tui.start(),this.mouse.reassert(),this.tui.invalidate(),this.tui.requestRender(!0)}}async focusNode(e){if(!this.capabilities.canFocusNode||this.selfPane===void 0||this.selfPane==="")return this.notice("Focusing a node needs a local viewer in tmux"),!1;try{const t=d(),o=await t.getNode(e),n=await m(t,e,{pane:this.selfPane,cwd:o.cwd,name:o.name});return n.focused||this.notice("Could not open that node\u2019s viewer"),n.focused}catch(t){return this.notice(p(t)),!1}}handleWheel(e,t){return this.stack[this.stack.length-1]?.component.handleWheel?.(e,t)??!1}hasFullPaneSurface(){return this.stack.length>0}closeAll(){const e=this.stack[0];e&&this.closeEntry(e,!1),this.disposeNotice()}closeEntry(e,t){if(e.closed||e.closing)return;if(this.stack.indexOf(e)===-1){e.closed=!0;return}for(e.closing=!0;this.stack.indexOf(e)!==-1;){const s=this.stack.indexOf(e),i=this.stack[s+1];if(!i)break;this.closeEntry(i,!1)}try{e.overlay.hide()}catch(s){a(`surface overlay hide failed: ${h(s)}`)}for(const s of e.cleanup)try{const i=s();i&&typeof i.then=="function"&&i.catch(l=>a(`surface cleanup failed: ${h(l)}`))}catch(i){a(`surface cleanup failed: ${h(i)}`)}e.cleanup.length=0,e.closed=!0,e.closing=!1;const n=this.stack.indexOf(e);if(n!==-1&&this.stack.splice(n,1),t){this.disposeNotice();const s=this.stack[this.stack.length-1];s&&s.overlay.setHidden(!1)}}disposeNotice(){this.disposeNoticeOverlay(),this.noticeTimer!==void 0&&(clearTimeout(this.noticeTimer),this.noticeTimer=void 0)}disposeNoticeOverlay(){this.noticeOverlay?.hide(),this.noticeOverlay=void 0}}class w{static{r(this,"NoticeOverlay")}text;constructor(e){this.text=e}render(e){return[u(this.text(),Math.max(0,e),"",!0)]}invalidate(){}}function b(c,e){let t=0;return{setRows:r(o=>{t=Math.max(0,Math.floor(o))},"setRows"),render:r(o=>{const n=c.render(o),i=(e===void 0?n:[u(e,Math.max(0,o),"",!0),...n.slice(1)]).slice(0,t);for(;i.length<t;)i.push("");return i},"render"),invalidate:r(()=>c.invalidate(),"invalidate")}}r(b,"titled");function a(c){g("surface-host",c)}r(a,"reportInvariant");function h(c){return c instanceof Error?c.message:String(c)}r(h,"errorMessage");export{R as ViewerSurfaceHost};