@adhdev/daemon-core 0.9.82-rc.377 → 0.9.82-rc.379

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.
@@ -38,6 +38,11 @@ import { loadFsmSpec } from './fsm-loader.js';
38
38
  import { applyPreLaunchTrust } from './pre-launch-trust.js';
39
39
  import type { Control, DelegateTrigger } from './types.js';
40
40
  import { LOG } from '../../logging/logger.js';
41
+ import {
42
+ WIN32_PTY_WRITE_CHUNK_CHARS,
43
+ WIN32_PTY_WRITE_CHUNK_GAP_MS,
44
+ chunkPreservingSurrogates as chunkPreservingSurrogatesShared,
45
+ } from '../../cli-adapters/pty-write-chunking.js';
41
46
 
42
47
  // ── Shared driver types (formerly in driver.ts) ───────────────────────────
43
48
 
@@ -169,12 +174,9 @@ const WIN32_SUBMIT_MAX_RESENDS = 14;
169
174
  // cadence while it waits for the body to echo.
170
175
  const WIN32_SUBMIT_SETTLE_MS = 500;
171
176
  const WIN32_SUBMIT_SETTLE_POLL_MS = 120;
172
- // Defensive paced PTY write. A single unbounded ConPTY write can overflow the
173
- // input pipe and drop leading bytes; split a large body into bounded chunks with a
174
- // short inter-chunk gap so the console input buffer keeps up. Small bodies still
175
- // write in one shot.
176
- const WIN32_PTY_WRITE_CHUNK_CHARS = 1024;
177
- const WIN32_PTY_WRITE_CHUNK_GAP_MS = 8;
177
+ // Defensive paced PTY write tuning (WIN32_PTY_WRITE_CHUNK_CHARS / _GAP_MS) and the
178
+ // surrogate-safe splitter now live in the shared pty-write-chunking module so this
179
+ // driver and the legacy ProviderCliAdapter cannot drift apart see the import above.
178
180
  // Echo-gate for the win32 FIRST submit CR (supersedes the bare output-quiet settle).
179
181
  // The body write can race claude-cli's boot — its stdin reader is not wired until the
180
182
  // composer renders (~5–7s in, later under load), so a too-early write is buffered and
@@ -202,26 +204,11 @@ export function resolveSubmitDelayMs(specBeforeSubmit: number | undefined, text:
202
204
  return Math.max(spec, SUBMIT_DELAY_FLOOR_MS + linesBonus);
203
205
  }
204
206
 
205
- /** Split `text` into chunks of at most `size` UTF-16 units without ever cutting
206
- * between a high and low surrogate (which would corrupt an astral char — emoji,
207
- * etc. on the UTF-8 PTY write). */
208
- export function chunkPreservingSurrogates(text: string, size: number): string[] {
209
- const chunks: string[] = [];
210
- let offset = 0;
211
- while (offset < text.length) {
212
- let end = Math.min(text.length, offset + size);
213
- if (end < text.length) {
214
- const code = text.charCodeAt(end - 1);
215
- // Boundary lands on a high surrogate → pull back one so the pair stays
216
- // together in the next chunk.
217
- if (code >= 0xd800 && code <= 0xdbff) end -= 1;
218
- }
219
- if (end <= offset) end = Math.min(text.length, offset + size); // size 1 on a lone surrogate
220
- chunks.push(text.slice(offset, end));
221
- offset = end;
222
- }
223
- return chunks;
224
- }
207
+ /** Re-export of the shared surrogate-safe splitter so existing imports of
208
+ * `chunkPreservingSurrogates` from this module keep working. The implementation
209
+ * lives in ../../cli-adapters/pty-write-chunking so the spec driver and the
210
+ * legacy adapter share one definition. */
211
+ export const chunkPreservingSurrogates = chunkPreservingSurrogatesShared;
225
212
 
226
213
  export function guessExt(mime: string): string {
227
214
  if (/png/i.test(mime)) return '.png';