@adhdev/daemon-core 0.9.82-rc.14 → 0.9.82-rc.141

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 (115) hide show
  1. package/dist/chat/source-machine.d.ts +166 -0
  2. package/dist/chat/source-resolver.d.ts +104 -0
  3. package/dist/chat/subscription-updates.d.ts +1 -0
  4. package/dist/cli-adapter-types.d.ts +5 -1
  5. package/dist/cli-adapters/cli-script-runner.d.ts +45 -0
  6. package/dist/cli-adapters/cli-state-engine.d.ts +178 -0
  7. package/dist/cli-adapters/provider-cli-adapter.d.ts +87 -63
  8. package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
  9. package/dist/cli-adapters/provider-cli-shared.d.ts +21 -0
  10. package/dist/commands/router.d.ts +22 -0
  11. package/dist/config/chat-history.d.ts +5 -0
  12. package/dist/config/config.d.ts +5 -0
  13. package/dist/config/mesh-config.d.ts +68 -1
  14. package/dist/git/git-commands.d.ts +5 -1
  15. package/dist/index.d.ts +18 -6
  16. package/dist/index.js +10431 -2827
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +10376 -2811
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/installer.d.ts +1 -4
  21. package/dist/launch.d.ts +1 -1
  22. package/dist/logging/async-batch-writer.d.ts +10 -0
  23. package/dist/mesh/beads-db.d.ts +72 -0
  24. package/dist/mesh/contracts.d.ts +164 -0
  25. package/dist/mesh/coordinator-registry.d.ts +25 -0
  26. package/dist/mesh/mesh-active-work.d.ts +90 -0
  27. package/dist/mesh/mesh-events.d.ts +77 -5
  28. package/dist/mesh/mesh-fast-forward.d.ts +39 -0
  29. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  30. package/dist/mesh/mesh-ledger.d.ts +58 -1
  31. package/dist/mesh/mesh-refine-status.d.ts +26 -0
  32. package/dist/mesh/mesh-work-queue.d.ts +44 -5
  33. package/dist/mesh/preview-freshness.d.ts +18 -0
  34. package/dist/mesh/refine-config.d.ts +193 -0
  35. package/dist/mesh/worktree-bootstrap-config.d.ts +113 -0
  36. package/dist/providers/approval-utils.d.ts +9 -0
  37. package/dist/providers/chat-message-normalization.d.ts +1 -0
  38. package/dist/providers/cli-provider-instance.d.ts +6 -1
  39. package/dist/providers/contracts.d.ts +19 -0
  40. package/dist/providers/read-chat-contract.d.ts +29 -0
  41. package/dist/providers/transcript-v2.d.ts +176 -0
  42. package/dist/repo-mesh-types.d.ts +67 -0
  43. package/dist/shared-types.d.ts +12 -0
  44. package/dist/status/reporter.d.ts +2 -0
  45. package/dist/status/snapshot.d.ts +1 -0
  46. package/dist/types.d.ts +5 -0
  47. package/package.json +3 -1
  48. package/src/boot/daemon-lifecycle.ts +3 -0
  49. package/src/chat/source-machine.ts +534 -0
  50. package/src/chat/source-resolver.ts +0 -0
  51. package/src/chat/subscription-updates.ts +14 -1
  52. package/src/cli-adapter-types.d.ts +1 -0
  53. package/src/cli-adapter-types.ts +3 -1
  54. package/src/cli-adapters/cli-script-runner.ts +145 -0
  55. package/src/cli-adapters/cli-state-engine.ts +1083 -0
  56. package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
  57. package/src/cli-adapters/provider-cli-adapter.ts +630 -1137
  58. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  59. package/src/cli-adapters/provider-cli-parse.ts +13 -0
  60. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  61. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  62. package/src/cli-adapters/provider-cli-shared.ts +51 -11
  63. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +17 -1
  64. package/src/cli-adapters/terminal-backends/xterm-backend.ts +8 -1
  65. package/src/commands/chat-commands.ts +1428 -50
  66. package/src/commands/cli-manager.ts +145 -3
  67. package/src/commands/handler.ts +8 -1
  68. package/src/commands/mesh-coordinator.ts +13 -143
  69. package/src/commands/router.ts +3271 -427
  70. package/src/config/chat-history.ts +79 -24
  71. package/src/config/config.ts +12 -0
  72. package/src/config/mesh-config.ts +249 -2
  73. package/src/config/recent-activity.ts +8 -2
  74. package/src/daemon/dev-cli-debug.ts +10 -1
  75. package/src/detection/ide-detector.ts +26 -16
  76. package/src/git/git-commands.ts +17 -5
  77. package/src/git/git-worktree.ts +8 -1
  78. package/src/index.ts +45 -5
  79. package/src/installer.d.ts +1 -1
  80. package/src/installer.ts +8 -6
  81. package/src/launch.d.ts +1 -1
  82. package/src/launch.ts +37 -28
  83. package/src/logging/async-batch-writer.ts +55 -0
  84. package/src/logging/logger.ts +2 -1
  85. package/src/mesh/beads-db.ts +479 -0
  86. package/src/mesh/contracts.ts +329 -0
  87. package/src/mesh/coordinator-prompt.ts +40 -22
  88. package/src/mesh/coordinator-registry.ts +75 -0
  89. package/src/mesh/mesh-active-work.ts +437 -0
  90. package/src/mesh/mesh-events.ts +799 -56
  91. package/src/mesh/mesh-fast-forward.ts +430 -0
  92. package/src/mesh/mesh-host-ownership.ts +73 -0
  93. package/src/mesh/mesh-ledger.ts +457 -104
  94. package/src/mesh/mesh-refine-status.ts +144 -0
  95. package/src/mesh/mesh-work-queue.ts +216 -158
  96. package/src/mesh/preview-freshness.ts +118 -0
  97. package/src/mesh/refine-config.ts +366 -0
  98. package/src/mesh/worktree-bootstrap-config.ts +247 -0
  99. package/src/providers/approval-utils.ts +39 -5
  100. package/src/providers/chat-message-normalization.ts +7 -12
  101. package/src/providers/cli-provider-instance.ts +362 -41
  102. package/src/providers/contracts.ts +19 -0
  103. package/src/providers/ide-provider-instance.ts +17 -3
  104. package/src/providers/provider-loader.ts +31 -11
  105. package/src/providers/provider-schema.ts +12 -0
  106. package/src/providers/read-chat-contract.ts +76 -16
  107. package/src/providers/transcript-v2.ts +567 -0
  108. package/src/providers/version-archive.ts +38 -20
  109. package/src/repo-mesh-types.ts +77 -0
  110. package/src/shared-types.ts +9 -0
  111. package/src/status/builders.ts +23 -6
  112. package/src/status/reporter.ts +15 -0
  113. package/src/status/snapshot.ts +35 -11
  114. package/src/system/host-memory.ts +29 -12
  115. 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[];
@@ -55,6 +55,8 @@ export interface CliScriptInput {
55
55
  rawBuffer: string;
56
56
  recentBuffer: string;
57
57
  screenText: string;
58
+ workspace?: string;
59
+ workingDir?: string;
58
60
  screen: CliScreenSnapshot;
59
61
  bufferScreen: CliScreenSnapshot;
60
62
  recentScreen: CliScreenSnapshot;
@@ -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 {
@@ -147,6 +164,10 @@ export interface CliProviderModule {
147
164
  requirePromptEchoBeforeSubmit?: boolean;
148
165
  /** Allow sending another prompt while the CLI is still generating so users can intervene mid-turn. */
149
166
  allowInputDuringGeneration?: boolean;
167
+ /** When true, only transition to idle after the parsed transcript includes a final standard assistant message. */
168
+ requiresFinalAssistantBeforeIdle?: boolean;
169
+ /** When true, allow providers to augment stale snapshot data before parse. Reserved for future use. */
170
+ augmentStaleSnapshot?: boolean;
150
171
  /** When provider-owned, daemon treats provider parser output as canonical transcript authority. */
151
172
  transcriptAuthority?: 'provider' | 'daemon';
152
173
  /** Full context lets provider-owned parsers canonicalize retained history instead of daemon prefix stitching. */
@@ -342,7 +363,18 @@ export class TerminalTranscriptAccumulator {
342
363
  this.ensureRow();
343
364
  if (final === 'A') this.row = Math.max(0, this.row - count);
344
365
  else if (final === 'B') this.row += count;
345
- else if (final === 'C') this.col += count;
366
+ else if (final === 'C') {
367
+ // (fix) Cursor-forward must materialize spaces in the cells it
368
+ // skips, otherwise rendered transcripts collapse "Do you" written
369
+ // as "Do\x1b[1Cyou" into "Doyou". That mis-rendering broke
370
+ // Claude Code's approval-prompt and prompt-line detection
371
+ // (parseApproval saw "Doyouwanttoproceed?" and returned null).
372
+ const line = this.lines[this.row];
373
+ for (let c = this.col; c < this.col + count; c += 1) {
374
+ if (line[c] === undefined) line[c] = ' ';
375
+ }
376
+ this.col += count;
377
+ }
346
378
  else if (final === 'D') this.col = Math.max(0, this.col - count);
347
379
  else if (final === 'G') this.col = Math.max(0, count - 1);
348
380
  else if (final === 'H' || final === 'f') {
@@ -484,17 +516,25 @@ export function findBinary(name: string): string {
484
516
  return path.isAbsolute(expanded) ? expanded : path.resolve(expanded);
485
517
  }
486
518
  const isWin = os.platform() === 'win32';
487
- try {
488
- const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
489
- return execSync(cmd, {
490
- encoding: 'utf-8',
491
- timeout: 5000,
492
- stdio: ['pipe', 'pipe', 'pipe'],
493
- ...(isWin ? { windowsHide: true } : {}),
494
- }).trim().split('\n')[0].trim();
495
- } catch {
496
- return isWin ? `${trimmed}.cmd` : trimmed;
519
+ const paths = (process.env.PATH || '').split(path.delimiter);
520
+ const exes = isWin ? ['.exe', '.cmd', '.bat', ''] : [''];
521
+
522
+ for (const p of paths) {
523
+ if (!p) continue;
524
+ for (const ext of exes) {
525
+ const fullPath = path.join(p, trimmed + ext);
526
+ try {
527
+ const fs = require('fs');
528
+ if (fs.existsSync(fullPath)) {
529
+ const stat = fs.statSync(fullPath);
530
+ if (stat.isFile() && (isWin || (stat.mode & 0o111))) {
531
+ return fullPath;
532
+ }
533
+ }
534
+ } catch { }
535
+ }
497
536
  }
537
+ return isWin ? `${trimmed}.cmd` : trimmed;
498
538
  }
499
539
 
500
540
  export function isScriptBinary(binaryPath: string): boolean {
@@ -121,7 +121,23 @@ export class GhosttyVtTerminalBackend implements TerminalViewportBackend {
121
121
  }
122
122
 
123
123
  getText(): string {
124
- return this.terminal.formatPlainText({ trim: true }) || '';
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
- lines.push(line ? line.translateToString(true) : '');
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;