poly-weaver 0.5.0 → 0.6.0

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 (146) hide show
  1. package/dist/agents/implementors/handler.d.ts.map +1 -1
  2. package/dist/agents/implementors/handler.js +2 -1
  3. package/dist/agents/implementors/handler.js.map +1 -1
  4. package/dist/agents/planners/handler.d.ts.map +1 -1
  5. package/dist/agents/planners/handler.js +2 -1
  6. package/dist/agents/planners/handler.js.map +1 -1
  7. package/dist/agents/reviewers/handler.d.ts.map +1 -1
  8. package/dist/agents/reviewers/handler.js +9 -2
  9. package/dist/agents/reviewers/handler.js.map +1 -1
  10. package/dist/agents/runner.d.ts +40 -1
  11. package/dist/agents/runner.d.ts.map +1 -1
  12. package/dist/agents/runner.js +213 -14
  13. package/dist/agents/runner.js.map +1 -1
  14. package/dist/agents/simplifiers/handler.d.ts.map +1 -1
  15. package/dist/agents/simplifiers/handler.js +2 -1
  16. package/dist/agents/simplifiers/handler.js.map +1 -1
  17. package/dist/ansi.d.ts +26 -0
  18. package/dist/ansi.d.ts.map +1 -1
  19. package/dist/ansi.js +26 -0
  20. package/dist/ansi.js.map +1 -1
  21. package/dist/cli.js +46 -16
  22. package/dist/cli.js.map +1 -1
  23. package/dist/flow/built-in/default.js +1 -1
  24. package/dist/flow/built-in/default.js.map +1 -1
  25. package/dist/flow/built-in/default.ts +1 -1
  26. package/dist/flow/built-in/why-so-serious.js +1 -1
  27. package/dist/flow/built-in/why-so-serious.js.map +1 -1
  28. package/dist/flow/executor.d.ts.map +1 -1
  29. package/dist/flow/executor.js +7 -2
  30. package/dist/flow/executor.js.map +1 -1
  31. package/dist/flow/types.d.ts +5 -0
  32. package/dist/flow/types.d.ts.map +1 -1
  33. package/dist/flow/types.js.map +1 -1
  34. package/dist/orchestrator.d.ts +10 -4
  35. package/dist/orchestrator.d.ts.map +1 -1
  36. package/dist/orchestrator.js +34 -14
  37. package/dist/orchestrator.js.map +1 -1
  38. package/dist/providers/claude/session.d.ts +3 -1
  39. package/dist/providers/claude/session.d.ts.map +1 -1
  40. package/dist/providers/claude/session.js +10 -2
  41. package/dist/providers/claude/session.js.map +1 -1
  42. package/dist/providers/codex/session.d.ts +6 -3
  43. package/dist/providers/codex/session.d.ts.map +1 -1
  44. package/dist/providers/codex/session.js +24 -4
  45. package/dist/providers/codex/session.js.map +1 -1
  46. package/dist/providers/copilot/session.d.ts +3 -1
  47. package/dist/providers/copilot/session.d.ts.map +1 -1
  48. package/dist/providers/copilot/session.js +15 -2
  49. package/dist/providers/copilot/session.js.map +1 -1
  50. package/dist/providers/types.d.ts +14 -2
  51. package/dist/providers/types.d.ts.map +1 -1
  52. package/dist/providers/types.js.map +1 -1
  53. package/dist/pty/exit.d.ts +13 -5
  54. package/dist/pty/exit.d.ts.map +1 -1
  55. package/dist/pty/exit.js +19 -19
  56. package/dist/pty/exit.js.map +1 -1
  57. package/dist/pty/spawn.d.ts +12 -6
  58. package/dist/pty/spawn.d.ts.map +1 -1
  59. package/dist/pty/spawn.js +22 -70
  60. package/dist/pty/spawn.js.map +1 -1
  61. package/dist/pty/types.d.ts +12 -3
  62. package/dist/pty/types.d.ts.map +1 -1
  63. package/dist/session/locator.d.ts +23 -2
  64. package/dist/session/locator.d.ts.map +1 -1
  65. package/dist/session/locator.js +67 -4
  66. package/dist/session/locator.js.map +1 -1
  67. package/dist/status-bar.d.ts +21 -1
  68. package/dist/status-bar.d.ts.map +1 -1
  69. package/dist/status-bar.js +109 -34
  70. package/dist/status-bar.js.map +1 -1
  71. package/dist/terminal/cleanup.d.ts +21 -0
  72. package/dist/terminal/cleanup.d.ts.map +1 -0
  73. package/dist/terminal/cleanup.js +22 -0
  74. package/dist/terminal/cleanup.js.map +1 -0
  75. package/dist/terminal/host.d.ts +244 -0
  76. package/dist/terminal/host.d.ts.map +1 -0
  77. package/dist/terminal/host.js +642 -0
  78. package/dist/terminal/host.js.map +1 -0
  79. package/dist/terminal/input-router.d.ts +146 -0
  80. package/dist/terminal/input-router.d.ts.map +1 -0
  81. package/dist/terminal/input-router.js +426 -0
  82. package/dist/terminal/input-router.js.map +1 -0
  83. package/dist/terminal/layout.d.ts +55 -0
  84. package/dist/terminal/layout.d.ts.map +1 -0
  85. package/dist/terminal/layout.js +51 -0
  86. package/dist/terminal/layout.js.map +1 -0
  87. package/dist/terminal/output.d.ts +83 -0
  88. package/dist/terminal/output.d.ts.map +1 -0
  89. package/dist/terminal/output.js +107 -0
  90. package/dist/terminal/output.js.map +1 -0
  91. package/dist/terminal/render.d.ts +36 -0
  92. package/dist/terminal/render.d.ts.map +1 -0
  93. package/dist/terminal/render.js +233 -0
  94. package/dist/terminal/render.js.map +1 -0
  95. package/dist/terminal/virtual-terminal.d.ts +54 -0
  96. package/dist/terminal/virtual-terminal.d.ts.map +1 -0
  97. package/dist/terminal/virtual-terminal.js +110 -0
  98. package/dist/terminal/virtual-terminal.js.map +1 -0
  99. package/dist/terminal-input.d.ts +10 -0
  100. package/dist/terminal-input.d.ts.map +1 -1
  101. package/dist/terminal-input.js +46 -0
  102. package/dist/terminal-input.js.map +1 -1
  103. package/dist/user/auto-curate-prompt.d.ts +17 -0
  104. package/dist/user/auto-curate-prompt.d.ts.map +1 -0
  105. package/dist/user/auto-curate-prompt.js +22 -0
  106. package/dist/user/auto-curate-prompt.js.map +1 -0
  107. package/dist/user/curate-handler.d.ts.map +1 -1
  108. package/dist/user/curate-handler.js +10 -2
  109. package/dist/user/curate-handler.js.map +1 -1
  110. package/dist/user/curate-prompt.d.ts +9 -7
  111. package/dist/user/curate-prompt.d.ts.map +1 -1
  112. package/dist/user/curate-prompt.js +2 -341
  113. package/dist/user/curate-prompt.js.map +1 -1
  114. package/dist/user/handler.d.ts +13 -1
  115. package/dist/user/handler.d.ts.map +1 -1
  116. package/dist/user/handler.js +27 -15
  117. package/dist/user/handler.js.map +1 -1
  118. package/dist/user/hard-wrap.d.ts +11 -0
  119. package/dist/user/hard-wrap.d.ts.map +1 -0
  120. package/dist/user/hard-wrap.js +44 -0
  121. package/dist/user/hard-wrap.js.map +1 -0
  122. package/dist/user/host-curate-prompt.d.ts +34 -0
  123. package/dist/user/host-curate-prompt.d.ts.map +1 -0
  124. package/dist/user/host-curate-prompt.js +453 -0
  125. package/dist/user/host-curate-prompt.js.map +1 -0
  126. package/dist/user/host-prompt.d.ts +21 -0
  127. package/dist/user/host-prompt.d.ts.map +1 -0
  128. package/dist/user/host-prompt.js +337 -0
  129. package/dist/user/host-prompt.js.map +1 -0
  130. package/dist/user/index.d.ts +3 -3
  131. package/dist/user/index.d.ts.map +1 -1
  132. package/dist/user/index.js +2 -2
  133. package/dist/user/index.js.map +1 -1
  134. package/dist/user/plan-pane.d.ts +18 -0
  135. package/dist/user/plan-pane.d.ts.map +1 -0
  136. package/dist/user/plan-pane.js +33 -0
  137. package/dist/user/plan-pane.js.map +1 -0
  138. package/dist/user/prompt.d.ts +25 -42
  139. package/dist/user/prompt.d.ts.map +1 -1
  140. package/dist/user/prompt.js +16 -278
  141. package/dist/user/prompt.js.map +1 -1
  142. package/dist/user/split-surface.d.ts +32 -0
  143. package/dist/user/split-surface.d.ts.map +1 -0
  144. package/dist/user/split-surface.js +66 -0
  145. package/dist/user/split-surface.js.map +1 -0
  146. package/package.json +2 -1
@@ -31,15 +31,30 @@ export class StatusBar {
31
31
  gitInfo = null;
32
32
  flashTimer;
33
33
  flashMessage;
34
- constructor(out) {
34
+ hostManaged;
35
+ onChange;
36
+ constructor(out, options) {
35
37
  this.out = out ?? process.stdout;
36
- this.enabled =
37
- this.out.isTTY === true && (this.out.rows ?? 0) >= 5;
38
+ this.hostManaged = options?.hostManaged ?? false;
39
+ this.onChange = options?.onChange;
40
+ // Host-managed mode does not gate on terminal height — the host's
41
+ // layout module handles the small-terminal policy (1-row terminal
42
+ // gets no status row; 2-4 row terminals get a compact status row).
43
+ // Legacy mode still requires >= 5 rows because its scroll-region
44
+ // approach needs at least one row above the bar.
45
+ this.enabled = this.hostManaged
46
+ ? this.out.isTTY === true
47
+ : this.out.isTTY === true && (this.out.rows ?? 0) >= 5;
38
48
  this.barRow = this.out.rows ?? 0;
39
49
  }
40
50
  init() {
41
51
  if (!this.enabled)
42
52
  return;
53
+ if (this.hostManaged) {
54
+ // Host owns the screen; just notify so it can paint the bar.
55
+ this.notify();
56
+ return;
57
+ }
43
58
  this.barRow = this.out.rows;
44
59
  // Set scroll region with cursor save/restore (no cursor homing)
45
60
  this.out.write(`\x1b7\x1b[1;${this.barRow - 1}r\x1b8`);
@@ -62,6 +77,11 @@ export class StatusBar {
62
77
  if (!this.enabled)
63
78
  return;
64
79
  this.lastCtx = ctx;
80
+ if (this.hostManaged) {
81
+ if (!this.flashMessage)
82
+ this.notify();
83
+ return;
84
+ }
65
85
  if (!this.flashMessage)
66
86
  this.drawBar();
67
87
  }
@@ -78,18 +98,33 @@ export class StatusBar {
78
98
  }
79
99
  this.flashMessage = message;
80
100
  this.lastDrawnOutput = undefined;
81
- this.drawBar();
101
+ if (this.hostManaged) {
102
+ this.notify();
103
+ }
104
+ else {
105
+ this.drawBar();
106
+ }
82
107
  this.flashTimer = setTimeout(() => {
83
108
  this.flashTimer = undefined;
84
109
  this.flashMessage = undefined;
85
110
  this.lastDrawnOutput = undefined;
86
- this.drawBar();
111
+ if (this.hostManaged) {
112
+ this.notify();
113
+ }
114
+ else {
115
+ this.drawBar();
116
+ }
87
117
  }, durationMs);
88
118
  }
89
119
  setGitInfo(info) {
90
120
  this.gitInfo = info;
91
- if (this.enabled)
92
- this.drawBar();
121
+ if (!this.enabled)
122
+ return;
123
+ if (this.hostManaged) {
124
+ this.notify();
125
+ return;
126
+ }
127
+ this.drawBar();
93
128
  }
94
129
  destroy() {
95
130
  if (!this.enabled)
@@ -107,12 +142,49 @@ export class StatusBar {
107
142
  this.out.removeListener("resize", this.resizeHandler);
108
143
  this.resizeHandler = undefined;
109
144
  }
145
+ if (this.hostManaged) {
146
+ // Host owns cleanup of the alternate screen; nothing to write here.
147
+ return;
148
+ }
110
149
  // Clear bar and reset scroll region (cursor-safe)
111
150
  this.out.write(`\x1b7\x1b[${this.barRow};1H\x1b[2K\x1b[r\x1b8`);
112
151
  }
113
152
  get reservedRows() {
114
153
  return this.enabled ? 1 : 0;
115
154
  }
155
+ /**
156
+ * Pure rendering: return the bar content padded/clipped to `columns`,
157
+ * including reverse-video on/off. Used by the orchestration host to
158
+ * paint the status row over the child viewport.
159
+ */
160
+ render(columns) {
161
+ const content = this.formatContent();
162
+ const padded = padOrClip(content, columns);
163
+ return `\x1b[0m\x1b[7m${padded}\x1b[27m\x1b[0m`;
164
+ }
165
+ /** Plain content used both by host render() and legacy drawBar(). */
166
+ formatContent() {
167
+ if (this.flashMessage) {
168
+ return ` ${this.flashMessage}`;
169
+ }
170
+ const gitSeg = this.formatGitSegment();
171
+ if (!this.lastCtx) {
172
+ return gitSeg
173
+ ? ` poly-weaver v${APP_VERSION} │ ${gitSeg}`
174
+ : ` poly-weaver v${APP_VERSION}`;
175
+ }
176
+ const phaseLabel = this.lastCtx.phase;
177
+ const ctx = formatContext(this.lastCtx);
178
+ const segments = [` poly-weaver v${APP_VERSION}`];
179
+ if (gitSeg)
180
+ segments.push(gitSeg);
181
+ segments.push(phaseLabel);
182
+ if (this.lastCtx.agent)
183
+ segments.push(this.lastCtx.agent);
184
+ if (ctx)
185
+ segments.push(ctx);
186
+ return segments.join(" │ ");
187
+ }
116
188
  formatGitSegment() {
117
189
  if (!this.gitInfo)
118
190
  return null;
@@ -120,36 +192,14 @@ export class StatusBar {
120
192
  const wt = this.gitInfo.isWorktree ? " \u{1F332}" : "";
121
193
  return `${animal} ${this.gitInfo.branch}${wt}`;
122
194
  }
195
+ notify() {
196
+ this.onChange?.();
197
+ }
123
198
  drawBar() {
124
199
  const columns = this.out.columns ?? 80;
125
- let content;
126
- if (this.flashMessage) {
127
- content = ` ${this.flashMessage}`;
128
- }
129
- else {
130
- const gitSeg = this.formatGitSegment();
131
- if (!this.lastCtx) {
132
- content = gitSeg
133
- ? ` poly-weaver v${APP_VERSION} \u2502 ${gitSeg}`
134
- : ` poly-weaver v${APP_VERSION}`;
135
- }
136
- else {
137
- const phaseLabel = this.lastCtx.phase;
138
- const ctx = formatContext(this.lastCtx);
139
- const segments = [` poly-weaver v${APP_VERSION}`];
140
- if (gitSeg)
141
- segments.push(gitSeg);
142
- segments.push(phaseLabel);
143
- if (this.lastCtx.agent)
144
- segments.push(this.lastCtx.agent);
145
- if (ctx)
146
- segments.push(ctx);
147
- content = segments.join(" \u2502 ");
148
- }
149
- }
200
+ const content = this.formatContent();
150
201
  // Pad visible content to full terminal width
151
- const pad = columns - visibleLength(content);
152
- const padded = pad > 0 ? content + " ".repeat(pad) : content;
202
+ const padded = padOrClip(content, columns);
153
203
  // Atomic write: save cursor, re-establish scroll region, draw bar, restore cursor
154
204
  const output = `\x1b7` +
155
205
  `\x1b[1;${this.barRow - 1}r` +
@@ -166,4 +216,29 @@ export class StatusBar {
166
216
  this.out.write(output);
167
217
  }
168
218
  }
219
+ function padOrClip(content, columns) {
220
+ const vis = visibleLength(content);
221
+ if (vis === columns)
222
+ return content;
223
+ if (vis < columns)
224
+ return content + " ".repeat(columns - vis);
225
+ // Clip on visible characters; preserve any inline ANSI escape sequences.
226
+ let out = "";
227
+ let count = 0;
228
+ let i = 0;
229
+ while (i < content.length && count < columns) {
230
+ if (content[i] === "\x1b" && content[i + 1] === "[") {
231
+ const m = content.slice(i).match(/^\x1b\[[0-9;]*m/);
232
+ if (m) {
233
+ out += m[0];
234
+ i += m[0].length;
235
+ continue;
236
+ }
237
+ }
238
+ out += content[i];
239
+ count += 1;
240
+ i += 1;
241
+ }
242
+ return out;
243
+ }
169
244
  //# sourceMappingURL=status-bar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../src/status-bar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,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C;QACH,CAAC;QACD,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;QAClB,KAAK,IAAI,CAAC,CAAC;QACX,CAAC,IAAI,CAAC,CAAC;IACT,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Best-effort terminal cleanup payload written by the abrupt-exit
3
+ * fallback in `src/cli.ts`. The host's `TerminalHost.stop()` performs
4
+ * the equivalent set of writes during normal shutdown; this constant
5
+ * covers the abrupt path (SIGINT, unhandled exception, or a
6
+ * `process.exit()` from outside the orchestration `finally` block).
7
+ *
8
+ * Order:
9
+ * 1. RESET_SCROLL_REGION — undo any legacy StatusBar scroll region.
10
+ * 2. CLEAR_SCREEN — wipe the visible buffer.
11
+ * 3. CURSOR_HOME — move the cursor home so the user does not see a
12
+ * stale prompt at row N.
13
+ * 4. ALT_SCREEN_OFF — leave the alternate screen so the user lands
14
+ * back on their original terminal contents.
15
+ * 5. SHOW_CURSOR — undo the host's `HIDE_CURSOR`.
16
+ *
17
+ * Exported as a constant so tests can verify the sequence without
18
+ * importing `src/cli.ts` (which has top-level side effects).
19
+ */
20
+ export declare const ABRUPT_EXIT_CLEANUP: string;
21
+ //# sourceMappingURL=cleanup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/terminal/cleanup.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,QACiD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { ALT_SCREEN_OFF, CLEAR_SCREEN, CURSOR_HOME, RESET_SCROLL_REGION, SHOW_CURSOR, } from "../ansi.js";
2
+ /**
3
+ * Best-effort terminal cleanup payload written by the abrupt-exit
4
+ * fallback in `src/cli.ts`. The host's `TerminalHost.stop()` performs
5
+ * the equivalent set of writes during normal shutdown; this constant
6
+ * covers the abrupt path (SIGINT, unhandled exception, or a
7
+ * `process.exit()` from outside the orchestration `finally` block).
8
+ *
9
+ * Order:
10
+ * 1. RESET_SCROLL_REGION — undo any legacy StatusBar scroll region.
11
+ * 2. CLEAR_SCREEN — wipe the visible buffer.
12
+ * 3. CURSOR_HOME — move the cursor home so the user does not see a
13
+ * stale prompt at row N.
14
+ * 4. ALT_SCREEN_OFF — leave the alternate screen so the user lands
15
+ * back on their original terminal contents.
16
+ * 5. SHOW_CURSOR — undo the host's `HIDE_CURSOR`.
17
+ *
18
+ * Exported as a constant so tests can verify the sequence without
19
+ * importing `src/cli.ts` (which has top-level side effects).
20
+ */
21
+ export const ABRUPT_EXIT_CLEANUP = RESET_SCROLL_REGION + CLEAR_SCREEN + CURSOR_HOME + ALT_SCREEN_OFF + SHOW_CURSOR;
22
+ //# sourceMappingURL=cleanup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup.js","sourceRoot":"","sources":["../../src/terminal/cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC9B,mBAAmB,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,WAAW,CAAC"}
@@ -0,0 +1,244 @@
1
+ import { type TerminalLayout } from "./layout.js";
2
+ import { BufferOrchestrationOutput, type OrchestrationOutput } from "./output.js";
3
+ import { type ParentUiMode } from "./input-router.js";
4
+ import type { PtyHandle } from "../pty/types.js";
5
+ import type { StatusBar } from "../status-bar.js";
6
+ export interface TerminalHostOptions {
7
+ stdin?: NodeJS.ReadStream;
8
+ stdout?: NodeJS.WriteStream;
9
+ /** Status model (host-managed). */
10
+ statusBar?: StatusBar;
11
+ /** Override host-managed output sink. Defaults to a fresh BufferOrchestrationOutput. */
12
+ output?: BufferOrchestrationOutput;
13
+ /** Trigger to capture a debug dump (e.g. wire to DumpService). */
14
+ onDump?: () => void;
15
+ }
16
+ /**
17
+ * I/O surface handed to a callback running inside `runIsolatedAltScreen`.
18
+ * The callback owns the alternate screen for its duration; the host has
19
+ * left its own alt screen and removed its stdin listener.
20
+ */
21
+ export interface IsolatedAltScreenIo {
22
+ stdin: NodeJS.ReadStream;
23
+ stdout: NodeJS.WriteStream;
24
+ /** Current terminal columns. */
25
+ columns: number;
26
+ /** Current terminal rows. */
27
+ rows: number;
28
+ /** Trigger the host's configured dump callback. No-op when none. */
29
+ triggerDump(): void;
30
+ }
31
+ /**
32
+ * A parent UI mode that contributes display lines and an optional cursor
33
+ * placement to the host's frame. The host renders these lines in the area
34
+ * between the child viewport and the status bar.
35
+ */
36
+ export interface HostUiSurface {
37
+ /** Lines (top-to-bottom) to render inside the host-controlled UI area. */
38
+ lines: string[];
39
+ /**
40
+ * Cursor placement relative to `lines`. `row` is 0-based row index into
41
+ * `lines`. `col` is the visible column (0-based). When undefined, the
42
+ * host hides the cursor.
43
+ */
44
+ cursor?: {
45
+ row: number;
46
+ col: number;
47
+ };
48
+ }
49
+ /**
50
+ * Host-backed parent UI mode. Combines `ParentUiMode.onInput` (input)
51
+ * with a `getSurface()` query that contributes rendered content. The host
52
+ * calls `getSurface()` on every frame.
53
+ */
54
+ export interface HostParentUiMode extends ParentUiMode {
55
+ getSurface(): HostUiSurface;
56
+ }
57
+ /**
58
+ * Parent-owned orchestration terminal host.
59
+ *
60
+ * While `started`, the host:
61
+ * - Owns the alternate screen, raw stdin mode, and `process.stdout` writes
62
+ * for the orchestration phase.
63
+ * - Maintains a `@xterm/headless` virtual terminal sized from the host
64
+ * layout. PTY data passes through the virtual terminal before display.
65
+ * - Schedules coalesced repaints so bursty PTY output renders as one frame.
66
+ * - Renders, in order: child viewport, parent UI / message area,
67
+ * and finally the status bar on `layout.statusRow`.
68
+ * - Routes stdin through global shortcuts (dump hotkey, host scrollback,
69
+ * host interrupt), then the active parent UI mode (review prompts,
70
+ * etc.), then the attached child.
71
+ * - Enables SGR mouse reporting on the real terminal so wheel events
72
+ * drive the host-managed scrollback viewport, and disables it on
73
+ * teardown / suspension so foreign UIs and the post-host shell are
74
+ * not left with mouse mode turned on.
75
+ */
76
+ export declare class TerminalHost {
77
+ private readonly stdin;
78
+ private readonly stdout;
79
+ private readonly router;
80
+ private readonly bufferOutput;
81
+ private readonly onDump;
82
+ private readonly interruptListeners;
83
+ private statusBar;
84
+ private childHandle;
85
+ private vt;
86
+ private layout;
87
+ private started;
88
+ private stopped;
89
+ private suspended;
90
+ private prevRawMode;
91
+ private resizeListener;
92
+ private renderScheduled;
93
+ private pendingFlush;
94
+ /**
95
+ * Set whenever any caller requests a full repaint (PTY output, resize,
96
+ * output buffer changes, status updates, attach/detach). When false at
97
+ * flush time AND a parent UI is attached with a full-height surface,
98
+ * the host can skip the child viewport render and only repaint the
99
+ * parent UI surface + status row. Any subsequent full request before
100
+ * flush flips it back to true.
101
+ */
102
+ private pendingFullRender;
103
+ private stdinListener;
104
+ private parentUi;
105
+ constructor(opts?: TerminalHostOptions);
106
+ /** True only when the host has entered the alternate screen. */
107
+ get isActive(): boolean;
108
+ /**
109
+ * True when the host's configured stdin is a TTY. Host-backed prompts
110
+ * gate interactivity on this — never on `process.stdin.isTTY` — so an
111
+ * embedded host with a non-default stdin still drives prompt I/O off
112
+ * the host-owned stream.
113
+ */
114
+ get isInteractive(): boolean;
115
+ /** Public output sink — orchestration code writes here. */
116
+ get output(): OrchestrationOutput;
117
+ /** Current layout snapshot. Computed on demand when not yet started. */
118
+ getLayout(): TerminalLayout;
119
+ /** Replace the status model after construction. */
120
+ attachStatusBar(bar: StatusBar): void;
121
+ /**
122
+ * Subscribe to host interrupt events (raw Ctrl+C while no parent UI
123
+ * consumes the byte). Returns an idempotent unsubscribe function.
124
+ *
125
+ * The host does not rely on process-level `SIGINT` — raw mode prevents
126
+ * the parent process from receiving SIGINT normally. Listeners are
127
+ * cleared on `stop()` so stale callbacks cannot fire after teardown.
128
+ */
129
+ onInterrupt(callback: () => void): () => void;
130
+ start(): void;
131
+ stop(): void;
132
+ /**
133
+ * Attach a PTY handle to the host. The host begins routing PTY data
134
+ * through the virtual terminal and displays it on the next render tick.
135
+ *
136
+ * The closure-bound handle is captured inside the data callback. After
137
+ * `detachChild()`, late `onData` events for the previously attached
138
+ * handle no longer feed the virtual terminal — so provider exit chatter
139
+ * cannot leak onto the screen even though node-pty does not expose an
140
+ * `off` for the listener.
141
+ *
142
+ * The returned function detaches the child idempotently.
143
+ */
144
+ attachChild(handle: PtyHandle): () => void;
145
+ detachChild(handle?: PtyHandle): void;
146
+ /**
147
+ * Discard the current child surface (VT screen + scrollback) and
148
+ * schedule a render. Use this after a provider run completes so the
149
+ * next host frame is blank instead of showing the finished agent's
150
+ * trailing output.
151
+ */
152
+ clearChildSurface(): void;
153
+ /** Dispose the current `VirtualTerminal` and create a fresh one sized to the current layout. */
154
+ private resetVirtualTerminal;
155
+ /**
156
+ * Attach a parent UI mode. The host routes stdin through the mode's
157
+ * `onInput` and queries `getSurface()` (when present) on every frame.
158
+ * Returns a detach function.
159
+ */
160
+ attachParentUi(mode: ParentUiMode): () => void;
161
+ detachParentUi(mode?: ParentUiMode): void;
162
+ /**
163
+ * Suspend the host and run `run` while a foreign UI owns the terminal.
164
+ *
165
+ * The host:
166
+ * - leaves its own alternate screen,
167
+ * - disables mouse reporting so the foreign UI is not flooded with
168
+ * SGR mouse sequences,
169
+ * - removes its stdin data listener,
170
+ * - restores the prior raw-mode state,
171
+ * - blocks `scheduleRender()`/`renderNow()` until resume,
172
+ * - keeps the virtual terminal, output buffer, router, and status bar
173
+ * intact so any data buffered during suspension is preserved for
174
+ * repaint after resume.
175
+ *
176
+ * On resume the host re-enters its alt screen, re-enables mouse
177
+ * reporting, re-installs its raw-mode stdin listener, recomputes
178
+ * layout, resizes the attached child if any, and schedules a repaint.
179
+ *
180
+ * Throws when the host is not active. The `finally` clause always
181
+ * restores host ownership, even when `run` throws.
182
+ */
183
+ runIsolatedAltScreen<T>(run: (io: IsolatedAltScreenIo) => Promise<T>): Promise<T>;
184
+ /** Force an immediate render (synchronously composes one frame). */
185
+ renderNow(): void;
186
+ /**
187
+ * Schedule a coalesced full render; multiple events in the same tick
188
+ * produce one frame. Use this for any change that can affect the child
189
+ * viewport, output buffer, status content, or layout.
190
+ */
191
+ scheduleRender(): void;
192
+ /**
193
+ * Schedule a coalesced parent-UI-only render. Used by host-backed
194
+ * prompts when only their own state changed (typing, scroll, cursor
195
+ * move). Skips the child viewport pass so prompt keystrokes do not
196
+ * cause a visible repaint of the unchanged child area.
197
+ *
198
+ * If any other request in the same tick demands a full render, the
199
+ * coalesced flush upgrades to a full render automatically.
200
+ *
201
+ * If the parent UI surface is shorter than `layout.childRows` at flush
202
+ * time, the host falls back to a full render — correctness must not
203
+ * depend on the prompt always producing a full-height surface.
204
+ */
205
+ scheduleParentUiRender(): void;
206
+ private scheduleFlush;
207
+ private fireInterrupt;
208
+ private handleScrollBackLines;
209
+ private handleScrollForwardLines;
210
+ private handleScrollPages;
211
+ private handleScrollToTop;
212
+ private handleScrollToBottom;
213
+ private renderUiSurface;
214
+ private renderMessages;
215
+ private handleResize;
216
+ private computeLayout;
217
+ /**
218
+ * Buffer-change hook. Recomputes layout — the warning strip grows or
219
+ * shrinks with buffered message count — and propagates child-viewport
220
+ * size changes to the virtual terminal and the attached child PTY
221
+ * before scheduling a coalesced repaint.
222
+ */
223
+ private handleOutputChange;
224
+ }
225
+ /**
226
+ * Map a surface-relative cursor position to a 1-based screen position.
227
+ *
228
+ * When the surface fits inside the child rows, the entire surface paints
229
+ * starting at row `childRows - lines.length + 1` (1-based) and the cursor
230
+ * row maps directly. When the surface overflows, the host paints only the
231
+ * trailing window — `lines.slice(-childRows)` — at the top of the host
232
+ * region. The cursor row is meaningful only when it falls inside that
233
+ * window; otherwise the visible position is undefined and the host hides
234
+ * the cursor instead of clamping to a wrong row.
235
+ *
236
+ * Returns 1-based `{ row, col }` (so callers can paste into `\x1b[r;cH`)
237
+ * when the cursor is visible, or `undefined` when it's outside the
238
+ * visible window.
239
+ */
240
+ export declare function mapSurfaceCursorToScreen(layout: TerminalLayout, surface: HostUiSurface): {
241
+ row: number;
242
+ col: number;
243
+ } | undefined;
244
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/terminal/host.ts"],"names":[],"mappings":"AAYA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,EACL,yBAAyB,EAEzB,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,mCAAmC;IACnC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,wFAAwF;IACxF,MAAM,CAAC,EAAE,yBAAyB,CAAC;IACnC,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;IAC3B,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,WAAW,IAAI,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,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