@adhdev/daemon-core 0.9.82-rc.15 → 0.9.82-rc.151
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.
- package/dist/boot/process-hardening.d.ts +50 -0
- package/dist/chat/source-machine.d.ts +166 -0
- package/dist/chat/source-resolver.d.ts +104 -0
- package/dist/chat/subscription-updates.d.ts +1 -0
- package/dist/cli-adapter-types.d.ts +5 -1
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +104 -63
- package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +27 -0
- package/dist/commands/handler.d.ts +66 -0
- package/dist/commands/router.d.ts +22 -0
- package/dist/config/chat-history.d.ts +5 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +68 -1
- package/dist/git/git-commands.d.ts +5 -1
- package/dist/index.d.ts +20 -6
- package/dist/index.js +13153 -3031
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13099 -3023
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +1 -4
- package/dist/ipc/local-ipc-server.d.ts +91 -0
- package/dist/launch.d.ts +1 -1
- package/dist/logging/async-batch-writer.d.ts +10 -0
- package/dist/mesh/beads-db.d.ts +72 -0
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-registry.d.ts +25 -0
- package/dist/mesh/mesh-active-work.d.ts +90 -0
- package/dist/mesh/mesh-events.d.ts +77 -5
- package/dist/mesh/mesh-fast-forward.d.ts +39 -0
- package/dist/mesh/mesh-host-ownership.d.ts +9 -0
- package/dist/mesh/mesh-ledger.d.ts +58 -1
- package/dist/mesh/mesh-refine-status.d.ts +26 -0
- package/dist/mesh/mesh-work-queue.d.ts +44 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +193 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +113 -0
- package/dist/providers/approval-utils.d.ts +9 -0
- package/dist/providers/cli-provider-instance.d.ts +6 -1
- package/dist/providers/contracts.d.ts +50 -5
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
- package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
- package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
- package/dist/providers/native-history/index.d.ts +11 -0
- package/dist/providers/provider-loader.d.ts +19 -1
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +64 -0
- package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
- package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
- package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
- package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
- package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
- package/dist/providers/sdk/v1/index.d.ts +30 -0
- package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
- package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
- package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
- package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
- package/dist/providers/sdk/v1/types/common/index.d.ts +169 -0
- package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
- package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
- package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/repo-mesh-types.d.ts +67 -0
- package/dist/shared-types.d.ts +12 -0
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +1 -0
- package/dist/types.d.ts +5 -0
- package/package.json +6 -2
- package/src/boot/daemon-lifecycle.ts +17 -10
- package/src/boot/process-hardening.ts +89 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +14 -1
- package/src/cli-adapter-types.d.ts +1 -0
- package/src/cli-adapter-types.ts +3 -1
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1086 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +664 -1137
- package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
- package/src/cli-adapters/provider-cli-parse.ts +13 -0
- package/src/cli-adapters/provider-cli-runtime.ts +3 -1
- package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
- package/src/cli-adapters/provider-cli-shared.ts +57 -11
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +17 -1
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +8 -1
- package/src/commands/chat-commands.ts +1451 -52
- package/src/commands/cli-manager.ts +184 -3
- package/src/commands/handler.ts +547 -2
- package/src/commands/mesh-coordinator.ts +13 -143
- package/src/commands/router.ts +3273 -428
- package/src/config/chat-history.ts +79 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +249 -2
- package/src/config/recent-activity.ts +8 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/detection/ide-detector.ts +26 -16
- package/src/git/git-commands.ts +17 -5
- package/src/git/git-worktree.ts +8 -1
- package/src/index.ts +72 -5
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/logger.ts +2 -1
- package/src/mesh/beads-db.ts +479 -0
- package/src/mesh/contracts.ts +329 -0
- package/src/mesh/coordinator-prompt.ts +40 -22
- package/src/mesh/coordinator-registry.ts +75 -0
- package/src/mesh/mesh-active-work.ts +437 -0
- package/src/mesh/mesh-events.ts +820 -61
- package/src/mesh/mesh-fast-forward.ts +430 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-ledger.ts +457 -104
- package/src/mesh/mesh-refine-status.ts +144 -0
- package/src/mesh/mesh-work-queue.ts +216 -158
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +366 -0
- package/src/mesh/worktree-bootstrap-config.ts +247 -0
- package/src/providers/approval-utils.ts +39 -5
- package/src/providers/chat-message-normalization.ts +4 -11
- package/src/providers/cli-provider-instance.ts +380 -44
- package/src/providers/contracts.ts +52 -5
- package/src/providers/ide-provider-instance.ts +17 -3
- package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
- package/src/providers/native-history/claude-cli-transcript.ts +396 -0
- package/src/providers/native-history/codex-cli-transcript.ts +419 -0
- package/src/providers/native-history/index.ts +23 -0
- package/src/providers/provider-loader.ts +294 -28
- package/src/providers/provider-schema.ts +31 -13
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +245 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +444 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +119 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +210 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/version-archive.ts +38 -20
- package/src/repo-mesh-types.ts +77 -0
- package/src/shared-types.ts +9 -0
- package/src/status/builders.ts +23 -6
- package/src/status/reporter.ts +15 -0
- package/src/status/snapshot.ts +35 -11
- package/src/system/host-memory.ts +29 -12
- package/src/types.ts +5 -0
|
@@ -15,6 +15,7 @@ export declare function buildCliParseInput(options: {
|
|
|
15
15
|
accumulatedRawBuffer: string;
|
|
16
16
|
recentOutputBuffer: string;
|
|
17
17
|
terminalScreenText: string;
|
|
18
|
+
workingDir?: string;
|
|
18
19
|
baseMessages: CliChatMessage[];
|
|
19
20
|
partialResponse: string;
|
|
20
21
|
isWaitingForResponse?: boolean;
|
|
@@ -35,22 +35,30 @@ export function buildCliParseInput(options: {
|
|
|
35
35
|
accumulatedRawBuffer: string;
|
|
36
36
|
recentOutputBuffer: string;
|
|
37
37
|
terminalScreenText: string;
|
|
38
|
+
workingDir?: string;
|
|
39
|
+
providerSessionId?: string;
|
|
40
|
+
historySessionId?: string;
|
|
38
41
|
baseMessages: CliChatMessage[];
|
|
39
42
|
partialResponse: string;
|
|
40
43
|
isWaitingForResponse?: boolean;
|
|
41
44
|
scope?: TurnParseScope | null;
|
|
42
45
|
runtimeSettings: Record<string, any>;
|
|
46
|
+
spawnAt?: number;
|
|
43
47
|
}): CliScriptInput {
|
|
44
48
|
const {
|
|
45
49
|
accumulatedBuffer,
|
|
46
50
|
accumulatedRawBuffer,
|
|
47
51
|
recentOutputBuffer,
|
|
48
52
|
terminalScreenText,
|
|
53
|
+
workingDir,
|
|
54
|
+
providerSessionId,
|
|
55
|
+
historySessionId,
|
|
49
56
|
baseMessages,
|
|
50
57
|
partialResponse,
|
|
51
58
|
isWaitingForResponse,
|
|
52
59
|
scope,
|
|
53
60
|
runtimeSettings,
|
|
61
|
+
spawnAt,
|
|
54
62
|
} = options;
|
|
55
63
|
const buffer = scope
|
|
56
64
|
? sliceFromOffset(accumulatedBuffer, scope.bufferStart)
|
|
@@ -66,6 +74,10 @@ export function buildCliParseInput(options: {
|
|
|
66
74
|
rawBuffer,
|
|
67
75
|
recentBuffer,
|
|
68
76
|
screenText,
|
|
77
|
+
workspace: workingDir,
|
|
78
|
+
workingDir,
|
|
79
|
+
providerSessionId,
|
|
80
|
+
historySessionId,
|
|
69
81
|
screen: buildCliScreenSnapshot(screenText),
|
|
70
82
|
bufferScreen: buildCliScreenSnapshot(buffer),
|
|
71
83
|
recentScreen: buildCliScreenSnapshot(recentBuffer),
|
|
@@ -74,6 +86,7 @@ export function buildCliParseInput(options: {
|
|
|
74
86
|
isWaitingForResponse,
|
|
75
87
|
promptText: scope?.prompt || '',
|
|
76
88
|
settings: { ...runtimeSettings },
|
|
89
|
+
...(typeof spawnAt === 'number' && spawnAt > 0 ? { spawnAt } : {}),
|
|
77
90
|
};
|
|
78
91
|
}
|
|
79
92
|
|
|
@@ -36,7 +36,9 @@ export function resolveCliSpawnPlan(options: {
|
|
|
36
36
|
: spawnConfig.command;
|
|
37
37
|
const binaryPath = findBinary(configuredCommand);
|
|
38
38
|
const isWin = os.platform() === 'win32';
|
|
39
|
-
const allArgs = [...spawnConfig.args, ...extraArgs]
|
|
39
|
+
const allArgs = [...spawnConfig.args, ...extraArgs].map((arg) =>
|
|
40
|
+
typeof arg === 'string' ? arg.replace(/\{\{workingDir\}\}/g, workingDir) : arg,
|
|
41
|
+
);
|
|
40
42
|
|
|
41
43
|
let shellCmd: string;
|
|
42
44
|
let shellArgs: string[];
|
|
@@ -28,8 +28,17 @@ export interface CliSessionStatus {
|
|
|
28
28
|
messages: CliChatMessage[];
|
|
29
29
|
workingDir: string;
|
|
30
30
|
activeModal: { message: string; buttons: string[] } | null;
|
|
31
|
+
pendingOutboundCount?: number;
|
|
32
|
+
pendingOutboundMessages?: Array<{
|
|
33
|
+
id: string;
|
|
34
|
+
role: 'user';
|
|
35
|
+
content: string;
|
|
36
|
+
queuedAt: number;
|
|
37
|
+
source: string;
|
|
38
|
+
}>;
|
|
31
39
|
errorMessage?: string;
|
|
32
40
|
errorReason?: string;
|
|
41
|
+
providerSessionId?: string;
|
|
33
42
|
bufferState?: {
|
|
34
43
|
responseBuffer?: { truncated: boolean; droppedChars: number; maxChars: number };
|
|
35
44
|
recentOutputBuffer?: { truncated: boolean; droppedChars: number; maxChars: number };
|
|
@@ -43,6 +52,9 @@ export interface ParsedSession {
|
|
|
43
52
|
messages: any[];
|
|
44
53
|
modal: { message: string; buttons: string[] } | null;
|
|
45
54
|
parsedStatus: string | null;
|
|
55
|
+
errorMessage?: string;
|
|
56
|
+
errorReason?: string;
|
|
57
|
+
providerSessionId?: string;
|
|
46
58
|
transcriptAuthority?: 'provider' | 'daemon';
|
|
47
59
|
coverage?: 'full' | 'tail' | 'current-turn';
|
|
48
60
|
}
|
|
@@ -94,6 +106,10 @@ export interface CliScriptInput {
|
|
|
94
106
|
rawBuffer: string;
|
|
95
107
|
recentBuffer: string;
|
|
96
108
|
screenText: string;
|
|
109
|
+
workspace?: string;
|
|
110
|
+
workingDir?: string;
|
|
111
|
+
providerSessionId?: string;
|
|
112
|
+
historySessionId?: string;
|
|
97
113
|
screen: CliScreenSnapshot;
|
|
98
114
|
bufferScreen: CliScreenSnapshot;
|
|
99
115
|
recentScreen: CliScreenSnapshot;
|
|
@@ -103,6 +119,7 @@ export interface CliScriptInput {
|
|
|
103
119
|
promptText?: string;
|
|
104
120
|
settings?: Record<string, any>;
|
|
105
121
|
args?: Record<string, any>;
|
|
122
|
+
spawnAt?: number;
|
|
106
123
|
}
|
|
107
124
|
|
|
108
125
|
export interface CliStatusInput {
|
|
@@ -141,16 +158,26 @@ export interface CliProviderModule {
|
|
|
141
158
|
binary: string;
|
|
142
159
|
approvalKeys?: Record<number, string>;
|
|
143
160
|
sendDelayMs?: number;
|
|
161
|
+
/** Wall-clock budget (ms) for a single provider script invocation. Default 50. Range 1..5000.
|
|
162
|
+
* Exceeding the budget records `timedOut: true` on the invocation trace and emits a
|
|
163
|
+
* throttled WARN — it does NOT abort the script (Node CJS can't interrupt sync code). */
|
|
164
|
+
scriptCallBudgetMs?: number;
|
|
144
165
|
sendKey?: string;
|
|
145
166
|
submitStrategy?: 'wait_for_echo' | 'immediate';
|
|
146
167
|
/** Require the typed prompt to be visible on the PTY screen before sending Enter. */
|
|
147
168
|
requirePromptEchoBeforeSubmit?: boolean;
|
|
148
169
|
/** Allow sending another prompt while the CLI is still generating so users can intervene mid-turn. */
|
|
149
170
|
allowInputDuringGeneration?: boolean;
|
|
171
|
+
/** When true, only transition to idle after the parsed transcript includes a final standard assistant message. */
|
|
172
|
+
requiresFinalAssistantBeforeIdle?: boolean;
|
|
173
|
+
/** When true, allow providers to augment stale snapshot data before parse. Reserved for future use. */
|
|
174
|
+
augmentStaleSnapshot?: boolean;
|
|
150
175
|
/** When provider-owned, daemon treats provider parser output as canonical transcript authority. */
|
|
151
176
|
transcriptAuthority?: 'provider' | 'daemon';
|
|
152
177
|
/** Full context lets provider-owned parsers canonicalize retained history instead of daemon prefix stitching. */
|
|
153
178
|
transcriptContext?: 'full' | 'tail';
|
|
179
|
+
/** v1 declarative tui block — used by CliScriptRunner to synthesize SDK helpers (declarativeDetectStatus, declarativeParseApproval). */
|
|
180
|
+
tui?: Record<string, unknown>;
|
|
154
181
|
scripts?: CliScripts;
|
|
155
182
|
spawn: {
|
|
156
183
|
command: string;
|
|
@@ -342,7 +369,18 @@ export class TerminalTranscriptAccumulator {
|
|
|
342
369
|
this.ensureRow();
|
|
343
370
|
if (final === 'A') this.row = Math.max(0, this.row - count);
|
|
344
371
|
else if (final === 'B') this.row += count;
|
|
345
|
-
else if (final === 'C')
|
|
372
|
+
else if (final === 'C') {
|
|
373
|
+
// (fix) Cursor-forward must materialize spaces in the cells it
|
|
374
|
+
// skips, otherwise rendered transcripts collapse "Do you" written
|
|
375
|
+
// as "Do\x1b[1Cyou" into "Doyou". That mis-rendering broke
|
|
376
|
+
// Claude Code's approval-prompt and prompt-line detection
|
|
377
|
+
// (parseApproval saw "Doyouwanttoproceed?" and returned null).
|
|
378
|
+
const line = this.lines[this.row];
|
|
379
|
+
for (let c = this.col; c < this.col + count; c += 1) {
|
|
380
|
+
if (line[c] === undefined) line[c] = ' ';
|
|
381
|
+
}
|
|
382
|
+
this.col += count;
|
|
383
|
+
}
|
|
346
384
|
else if (final === 'D') this.col = Math.max(0, this.col - count);
|
|
347
385
|
else if (final === 'G') this.col = Math.max(0, count - 1);
|
|
348
386
|
else if (final === 'H' || final === 'f') {
|
|
@@ -484,17 +522,25 @@ export function findBinary(name: string): string {
|
|
|
484
522
|
return path.isAbsolute(expanded) ? expanded : path.resolve(expanded);
|
|
485
523
|
}
|
|
486
524
|
const isWin = os.platform() === 'win32';
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
525
|
+
const paths = (process.env.PATH || '').split(path.delimiter);
|
|
526
|
+
const exes = isWin ? ['.exe', '.cmd', '.bat', ''] : [''];
|
|
527
|
+
|
|
528
|
+
for (const p of paths) {
|
|
529
|
+
if (!p) continue;
|
|
530
|
+
for (const ext of exes) {
|
|
531
|
+
const fullPath = path.join(p, trimmed + ext);
|
|
532
|
+
try {
|
|
533
|
+
const fs = require('fs');
|
|
534
|
+
if (fs.existsSync(fullPath)) {
|
|
535
|
+
const stat = fs.statSync(fullPath);
|
|
536
|
+
if (stat.isFile() && (isWin || (stat.mode & 0o111))) {
|
|
537
|
+
return fullPath;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
} catch { }
|
|
541
|
+
}
|
|
497
542
|
}
|
|
543
|
+
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
498
544
|
}
|
|
499
545
|
|
|
500
546
|
export function isScriptBinary(binaryPath: string): boolean {
|
|
@@ -121,7 +121,23 @@ export class GhosttyVtTerminalBackend implements TerminalViewportBackend {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
getText(): string {
|
|
124
|
-
|
|
124
|
+
// (fix) ghostty's `trim:true` mode strips trailing whitespace per row
|
|
125
|
+
// AND collapses cells that were touched only by cursor-forward (ESC[<n>C)
|
|
126
|
+
// without a printable glyph. Many TUIs (Claude Code most prominently)
|
|
127
|
+
// render inter-word spaces via CUF rather than literal spaces, so
|
|
128
|
+
// trim:true would smash "Do you want to proceed?" into
|
|
129
|
+
// "Doyouwanttoproceed?" and break every downstream regex
|
|
130
|
+
// (approval detection, prompt-line discovery, etc.). Keep the per-row
|
|
131
|
+
// padding, then trim each row's trailing whitespace ourselves so the
|
|
132
|
+
// serialized text matches what the user sees in the terminal.
|
|
133
|
+
const raw = this.terminal.formatPlainText({ trim: false }) || '';
|
|
134
|
+
if (!raw) return '';
|
|
135
|
+
const lines = raw.split('\n').map((row) => row.replace(/\s+$/, ''));
|
|
136
|
+
let first = 0;
|
|
137
|
+
let last = lines.length;
|
|
138
|
+
while (first < last && !lines[first]) first += 1;
|
|
139
|
+
while (last > first && !lines[last - 1]) last -= 1;
|
|
140
|
+
return lines.slice(first, last).join('\n');
|
|
125
141
|
}
|
|
126
142
|
|
|
127
143
|
getCursorPosition(): { col: number; row: number } {
|
|
@@ -64,7 +64,14 @@ export class XtermTerminalBackend implements TerminalViewportBackend {
|
|
|
64
64
|
|
|
65
65
|
for (let i = start; i < end; i++) {
|
|
66
66
|
const line = buffer.getLine(i);
|
|
67
|
-
|
|
67
|
+
// (fix) translateToString(true) strips trailing whitespace per row
|
|
68
|
+
// AND collapses cells touched only by cursor-forward (ESC[<n>C),
|
|
69
|
+
// so Claude Code's "Do you want to proceed?" arrives as
|
|
70
|
+
// "Doyouwanttoproceed?" — every downstream approval/prompt regex
|
|
71
|
+
// misses. Use false to preserve inter-word padding; we trim each
|
|
72
|
+
// row's trailing whitespace ourselves below.
|
|
73
|
+
const raw = line ? line.translateToString(false) : '';
|
|
74
|
+
lines.push(raw.replace(/\s+$/, ''));
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
let first = 0;
|