@adhdev/daemon-core 0.9.82-rc.13 → 0.9.82-rc.130

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 (82) hide show
  1. package/dist/chat/subscription-updates.d.ts +1 -0
  2. package/dist/cli-adapter-types.d.ts +4 -1
  3. package/dist/cli-adapters/provider-cli-adapter.d.ts +25 -1
  4. package/dist/cli-adapters/provider-cli-parse.d.ts +1 -0
  5. package/dist/cli-adapters/provider-cli-shared.d.ts +14 -0
  6. package/dist/commands/router.d.ts +22 -0
  7. package/dist/config/chat-history.d.ts +4 -0
  8. package/dist/config/mesh-config.d.ts +68 -1
  9. package/dist/git/git-commands.d.ts +5 -1
  10. package/dist/index.d.ts +15 -5
  11. package/dist/index.js +7461 -1380
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +7417 -1364
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/installer.d.ts +1 -4
  16. package/dist/launch.d.ts +1 -1
  17. package/dist/logging/async-batch-writer.d.ts +10 -0
  18. package/dist/mesh/beads-db.d.ts +18 -0
  19. package/dist/mesh/mesh-active-work.d.ts +73 -0
  20. package/dist/mesh/mesh-events.d.ts +54 -5
  21. package/dist/mesh/mesh-fast-forward.d.ts +39 -0
  22. package/dist/mesh/mesh-host-ownership.d.ts +9 -0
  23. package/dist/mesh/mesh-ledger.d.ts +38 -1
  24. package/dist/mesh/mesh-refine-status.d.ts +27 -0
  25. package/dist/mesh/mesh-work-queue.d.ts +27 -5
  26. package/dist/mesh/preview-freshness.d.ts +18 -0
  27. package/dist/mesh/refine-config.d.ts +193 -0
  28. package/dist/mesh/worktree-bootstrap-config.d.ts +115 -0
  29. package/dist/providers/chat-message-normalization.d.ts +1 -0
  30. package/dist/providers/cli-provider-instance.d.ts +6 -1
  31. package/dist/repo-mesh-types.d.ts +62 -0
  32. package/dist/status/reporter.d.ts +2 -0
  33. package/package.json +3 -1
  34. package/src/boot/daemon-lifecycle.ts +1 -0
  35. package/src/chat/subscription-updates.ts +5 -1
  36. package/src/cli-adapter-types.ts +2 -1
  37. package/src/cli-adapters/provider-cli-adapter.ts +473 -18
  38. package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
  39. package/src/cli-adapters/provider-cli-parse.ts +4 -0
  40. package/src/cli-adapters/provider-cli-runtime.ts +3 -1
  41. package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
  42. package/src/cli-adapters/provider-cli-shared.ts +32 -10
  43. package/src/commands/chat-commands.ts +960 -40
  44. package/src/commands/cli-manager.ts +138 -2
  45. package/src/commands/handler.ts +8 -1
  46. package/src/commands/mesh-coordinator.ts +13 -143
  47. package/src/commands/router.ts +3238 -423
  48. package/src/config/chat-history.ts +37 -9
  49. package/src/config/mesh-config.ts +249 -2
  50. package/src/config/recent-activity.ts +8 -2
  51. package/src/daemon/dev-cli-debug.ts +10 -1
  52. package/src/detection/ide-detector.ts +26 -16
  53. package/src/git/git-commands.ts +17 -5
  54. package/src/index.ts +41 -4
  55. package/src/installer.d.ts +1 -1
  56. package/src/installer.ts +8 -6
  57. package/src/launch.d.ts +1 -1
  58. package/src/launch.ts +37 -28
  59. package/src/logging/async-batch-writer.ts +55 -0
  60. package/src/logging/logger.ts +2 -1
  61. package/src/mesh/beads-db.ts +176 -0
  62. package/src/mesh/coordinator-prompt.ts +31 -8
  63. package/src/mesh/mesh-active-work.ts +295 -0
  64. package/src/mesh/mesh-events.ts +595 -48
  65. package/src/mesh/mesh-fast-forward.ts +430 -0
  66. package/src/mesh/mesh-host-ownership.ts +73 -0
  67. package/src/mesh/mesh-ledger.ts +138 -1
  68. package/src/mesh/mesh-refine-status.ts +145 -0
  69. package/src/mesh/mesh-work-queue.ts +199 -137
  70. package/src/mesh/preview-freshness.ts +118 -0
  71. package/src/mesh/refine-config.ts +366 -0
  72. package/src/mesh/worktree-bootstrap-config.ts +234 -0
  73. package/src/providers/approval-utils.ts +12 -5
  74. package/src/providers/chat-message-normalization.ts +7 -12
  75. package/src/providers/cli-provider-instance.ts +289 -36
  76. package/src/providers/ide-provider-instance.ts +17 -3
  77. package/src/providers/provider-loader.ts +10 -4
  78. package/src/providers/read-chat-contract.ts +1 -1
  79. package/src/providers/version-archive.ts +38 -20
  80. package/src/repo-mesh-types.ts +67 -0
  81. package/src/status/reporter.ts +15 -0
  82. package/src/system/host-memory.ts +29 -12
@@ -0,0 +1,115 @@
1
+ import { type MeshRefineValidationCommandPlan, type RepoMeshRefineValidationCommandConfig } from './refine-config.js';
2
+ export type WorktreeBootstrapStatus = 'ready' | 'running' | 'failed' | 'not_configured' | 'disabled' | 'stale';
3
+ export interface RepoMeshWorktreeBootstrapConfig {
4
+ version: 1;
5
+ enabled?: boolean;
6
+ runOnClone?: boolean;
7
+ required?: boolean;
8
+ commands?: RepoMeshRefineValidationCommandConfig[];
9
+ staleInputs?: string[];
10
+ }
11
+ export interface WorktreeBootstrapState {
12
+ status: WorktreeBootstrapStatus;
13
+ required: boolean;
14
+ configSource?: string;
15
+ configSourceType?: 'repo_file' | 'mesh_policy' | 'unavailable' | 'invalid';
16
+ startedAt?: string;
17
+ completedAt?: string;
18
+ lastCommand?: string;
19
+ exitCode?: number | null;
20
+ error?: string;
21
+ commandsRun?: Array<Record<string, unknown>>;
22
+ staleInputs?: string[];
23
+ }
24
+ export interface WorktreeBootstrapConfigLoadResult {
25
+ config?: RepoMeshWorktreeBootstrapConfig;
26
+ source: string;
27
+ sourceType: 'repo_file' | 'mesh_policy' | 'unavailable' | 'invalid';
28
+ path?: string;
29
+ error?: string;
30
+ }
31
+ export declare const MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS: string[];
32
+ export declare const MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA: {
33
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
34
+ readonly title: "ADHDev Repo Mesh Worktree Bootstrap Config";
35
+ readonly type: "object";
36
+ readonly additionalProperties: false;
37
+ readonly required: readonly ["version"];
38
+ readonly properties: {
39
+ readonly version: {
40
+ readonly const: 1;
41
+ };
42
+ readonly enabled: {
43
+ readonly type: "boolean";
44
+ readonly default: true;
45
+ };
46
+ readonly runOnClone: {
47
+ readonly type: "boolean";
48
+ readonly default: true;
49
+ };
50
+ readonly required: {
51
+ readonly type: "boolean";
52
+ readonly default: true;
53
+ };
54
+ readonly staleInputs: {
55
+ readonly type: "array";
56
+ readonly maxItems: 16;
57
+ readonly items: {
58
+ readonly type: "string";
59
+ readonly minLength: 1;
60
+ };
61
+ };
62
+ readonly commands: {
63
+ readonly type: "array";
64
+ readonly minItems: 1;
65
+ readonly maxItems: 4;
66
+ readonly items: {
67
+ readonly type: "object";
68
+ readonly additionalProperties: false;
69
+ readonly required: readonly ["command"];
70
+ readonly properties: {
71
+ readonly command: {
72
+ readonly type: "string";
73
+ readonly minLength: 1;
74
+ };
75
+ readonly args: {
76
+ readonly type: "array";
77
+ readonly items: {
78
+ readonly type: "string";
79
+ };
80
+ };
81
+ readonly category: {
82
+ readonly enum: readonly ["typecheck", "test", "lint", "build", "custom"];
83
+ };
84
+ readonly cwd: {
85
+ readonly type: "string";
86
+ };
87
+ readonly timeoutMs: {
88
+ readonly type: "number";
89
+ readonly minimum: 1000;
90
+ readonly maximum: 600000;
91
+ };
92
+ readonly outputLimitBytes: {
93
+ readonly type: "number";
94
+ readonly minimum: 1024;
95
+ readonly maximum: 1048576;
96
+ };
97
+ readonly env: {
98
+ readonly type: "object";
99
+ readonly additionalProperties: {
100
+ readonly type: "string";
101
+ };
102
+ };
103
+ };
104
+ };
105
+ };
106
+ };
107
+ };
108
+ export declare function validateMeshWorktreeBootstrapConfig(config: unknown, source?: string): {
109
+ valid: boolean;
110
+ errors: string[];
111
+ commands: MeshRefineValidationCommandPlan[];
112
+ rejectedCommands: Array<Record<string, unknown>>;
113
+ };
114
+ export declare function loadMeshWorktreeBootstrapConfig(mesh: any, workspace: string): WorktreeBootstrapConfigLoadResult;
115
+ export declare function runMeshWorktreeBootstrap(mesh: any, workspace: string): Promise<WorktreeBootstrapState>;
@@ -1,4 +1,5 @@
1
1
  import type { ChatMessage } from '../types.js';
2
+ export declare const DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4000;
2
3
  export declare function extractFinalSummaryFromMessages(messages: ChatMessage[] | null | undefined, maxChars?: number): string;
3
4
  export declare const BUILTIN_CHAT_MESSAGE_KINDS: readonly ["standard", "thought", "tool", "terminal", "system"];
4
5
  export type BuiltinChatMessageKind = typeof BUILTIN_CHAT_MESSAGE_KINDS[number];
@@ -48,6 +48,7 @@ export declare class CliProviderInstance implements ProviderInstance {
48
48
  private lastApprovalEventAt;
49
49
  private autoApproveBusy;
50
50
  private autoApproveBusyTimer;
51
+ private lastAutoApprovalSignature;
51
52
  private controlValues;
52
53
  private summaryMetadata;
53
54
  private appliedEffectKeys;
@@ -96,14 +97,16 @@ export declare class CliProviderInstance implements ProviderInstance {
96
97
  getSessionModalState(): SessionModalState;
97
98
  updateSettings(newSettings: Record<string, any>): void;
98
99
  onEvent(event: string, data?: any): void;
100
+ recordAcknowledgedUserInput(input: InputEnvelope | string): void;
99
101
  dispose(): void;
100
102
  private completedDebounceTimer;
101
103
  private completedDebouncePending;
102
104
  private enforceFreshSessionLaunchIfNeeded;
103
105
  private completionHasFinalAssistantMessage;
106
+ private buildCompletedFinalizationDiagnostic;
104
107
  private hasAdapterPendingResponse;
105
108
  private shouldSuppressStaleParsedBusyStatus;
106
- private getCompletedFinalizationBlockReason;
109
+ private getCompletedFinalizationBlock;
107
110
  private scheduleCompletedDebounceFlush;
108
111
  private flushCompletedDebounceIfFinalized;
109
112
  private maybeAutoApproveStatus;
@@ -127,6 +130,8 @@ export declare class CliProviderInstance implements ProviderInstance {
127
130
  private mergeConversationMessages;
128
131
  private formatApprovalRequestMessage;
129
132
  private promoteProviderSessionId;
133
+ private shouldHydrateExistingProviderHistory;
134
+ private shouldSuppressFreshLaunchStartupReplay;
130
135
  private syncCanonicalSavedHistoryIfNeeded;
131
136
  private restorePersistedHistoryFromCurrentSession;
132
137
  private getProbeDirectories;
@@ -19,10 +19,37 @@ export interface RepoMesh {
19
19
  defaultBranch?: string;
20
20
  policy: RepoMeshPolicy;
21
21
  coordinator: RepoMeshCoordinatorConfig;
22
+ meshHost?: RepoMeshHostMetadata;
22
23
  projectContext: ProjectContextSnapshot;
23
24
  nodes: RepoMeshNode[];
24
25
  status: 'active' | 'archived' | 'deleted';
25
26
  }
27
+ export type RepoMeshDaemonRole = 'host' | 'member';
28
+ export interface RepoMeshHostPairingMetadata {
29
+ status: 'not_configured' | 'pairing' | 'paired' | 'rejected' | 'revoked';
30
+ tokenId?: string;
31
+ joinedAt?: string;
32
+ lastPairedAt?: string;
33
+ lastRejectedAt?: string;
34
+ expiresAt?: string;
35
+ }
36
+ export interface RepoMeshHostMetadata {
37
+ /** Local daemon role for this mesh. Missing metadata defaults to host for standalone compatibility. */
38
+ role: RepoMeshDaemonRole;
39
+ /** Daemon that owns mesh truth/status/git/queue/session/ledger/coordinator ownership. */
40
+ hostDaemonId?: string;
41
+ /** Mesh node that represents the host daemon, when known. */
42
+ hostNodeId?: string;
43
+ /** Future standalone manual pairing endpoint entered by member daemons. */
44
+ hostAddress?: string;
45
+ /** Redacted pairing state only; raw join tokens must not be persisted here. */
46
+ pairing?: RepoMeshHostPairingMetadata;
47
+ }
48
+ export interface RepoMeshHostStatus extends RepoMeshHostMetadata {
49
+ canOwnCoordinator: boolean;
50
+ canOwnQueue: boolean;
51
+ defaulted: boolean;
52
+ }
26
53
  export interface RepoMeshNode {
27
54
  id: string;
28
55
  daemonId: string;
@@ -37,6 +64,7 @@ export interface RepoMeshNode {
37
64
  effectiveCapabilities: RepoMeshNodeCapabilities;
38
65
  policy: RepoMeshNodePolicy;
39
66
  health: RepoMeshNodeHealth;
67
+ role?: RepoMeshDaemonRole;
40
68
  status: 'enabled' | 'disabled' | 'removed';
41
69
  }
42
70
  export type RepoMeshNodeHealth = 'online' | 'offline' | 'degraded' | 'dirty' | 'wrong_branch' | 'unknown';
@@ -46,6 +74,13 @@ export interface RepoMeshPolicy {
46
74
  requirePreTaskCheckpoint: boolean;
47
75
  requirePostTaskCheckpoint: boolean;
48
76
  requireApprovalForPush: boolean;
77
+ /**
78
+ * Narrow Refinery opt-in: when validation and patch-equivalence have passed,
79
+ * allow Refinery to publish submodule gitlink commits to each submodule's
80
+ * configured remote main branch with a non-force push, then verify reachability.
81
+ * Defaults to false; root branch pushes/merges are not affected.
82
+ */
83
+ allowAutoPublishSubmoduleMainCommits?: boolean;
49
84
  requireApprovalForDestructiveGit: boolean;
50
85
  dirtyWorkspaceBehavior: 'block' | 'warn' | 'checkpoint_then_continue';
51
86
  maxParallelTasks: number;
@@ -185,6 +220,7 @@ export interface LocalMeshEntry {
185
220
  defaultBranch?: string;
186
221
  policy: RepoMeshPolicy;
187
222
  coordinator: RepoMeshCoordinatorConfig;
223
+ meshHost?: RepoMeshHostMetadata;
188
224
  nodes: LocalMeshNodeEntry[];
189
225
  createdAt: string;
190
226
  updatedAt: string;
@@ -204,8 +240,23 @@ export interface LocalMeshNodeEntry {
204
240
  worktreeBranch?: string;
205
241
  /** Node ID this worktree was cloned from */
206
242
  clonedFromNodeId?: string;
243
+ /** Repo-local preparation result for ADHDev-created worktree nodes. */
244
+ worktreeBootstrap?: {
245
+ status: 'ready' | 'running' | 'failed' | 'not_configured' | 'disabled' | 'stale';
246
+ required?: boolean;
247
+ configSource?: string;
248
+ configSourceType?: string;
249
+ startedAt?: string;
250
+ completedAt?: string;
251
+ lastCommand?: string;
252
+ exitCode?: number | null;
253
+ error?: string;
254
+ commandsRun?: Array<Record<string, unknown>>;
255
+ staleInputs?: string[];
256
+ };
207
257
  /** Optional associated/external repos configured as node metadata. */
208
258
  relatedRepos?: RepoMeshRelatedRepo[];
259
+ role?: RepoMeshDaemonRole;
209
260
  }
210
261
  export interface RepoMeshStatus {
211
262
  meshId: string;
@@ -213,6 +264,7 @@ export interface RepoMeshStatus {
213
264
  repoIdentity: string;
214
265
  defaultBranch?: string;
215
266
  refreshedAt: string;
267
+ meshHost?: RepoMeshHostStatus;
216
268
  nodes: RepoMeshNodeStatus[];
217
269
  queue?: RepoMeshQueueStatus;
218
270
  ledger?: RepoMeshLedgerStatus;
@@ -249,16 +301,26 @@ export interface RepoMeshNodeStatus {
249
301
  repoRoot?: string;
250
302
  daemonId?: string;
251
303
  machineId?: string;
304
+ role?: RepoMeshDaemonRole;
252
305
  machineStatus?: string;
253
306
  isLocalWorktree?: boolean;
254
307
  worktreeBranch?: string;
255
308
  health: RepoMeshNodeHealth;
256
309
  git?: GitRepoStatus;
310
+ /**
311
+ * True when the selected coordinator has evidence that a peer git probe is still
312
+ * in flight or just timed out during initial mesh handshake, so callers should
313
+ * treat missing git data as pending instead of authoritative absence.
314
+ */
315
+ gitProbePending?: boolean;
257
316
  providers: string[];
258
317
  activeSessions: string[];
259
318
  activeSessionDetails?: RepoMeshSessionStatus[];
260
319
  providerPriority?: string[];
261
320
  launchReady?: boolean;
321
+ worktreeBootstrap?: LocalMeshNodeEntry['worktreeBootstrap'];
322
+ launchBlockedReason?: string;
323
+ launchBlockedMessage?: string;
262
324
  lastSeenAt?: string;
263
325
  updatedAt?: string;
264
326
  connection?: RepoMeshPeerConnectionStatus;
@@ -46,6 +46,8 @@ export declare class DaemonStatusReporter {
46
46
  private lastStatusSentAt;
47
47
  private statusPendingThrottle;
48
48
  private lastP2PStatusHash;
49
+ private lastP2PStatusSentAt;
50
+ private p2pDebounceTimer;
49
51
  private lastServerStatusHash;
50
52
  private lastStatusSummary;
51
53
  private statusTimer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.13",
3
+ "version": "0.9.82-rc.130",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -49,6 +49,7 @@
49
49
  "@adhdev/session-host-core": "*",
50
50
  "@agentclientprotocol/sdk": "^0.16.1",
51
51
  "@xterm/xterm": "^6.0.0",
52
+ "better-sqlite3": "^12.10.0",
52
53
  "chalk": "^5.3.0",
53
54
  "chokidar": "^4.0.3",
54
55
  "conf": "^13.0.0",
@@ -60,6 +61,7 @@
60
61
  "@adhdev/ghostty-vt-node": "*"
61
62
  },
62
63
  "devDependencies": {
64
+ "@types/better-sqlite3": "^7.6.13",
63
65
  "@types/js-yaml": "^4.0.9",
64
66
  "@types/node": "^22.0.0",
65
67
  "@types/ws": "^8.18.1",
@@ -309,6 +309,7 @@ export async function initDaemonComponents(config: DaemonInitConfig): Promise<Da
309
309
  statusInstanceId: config.statusInstanceId,
310
310
  statusVersion: config.statusVersion,
311
311
  getMeshPeerConnectionStatus: config.getMeshPeerConnectionStatus,
312
+ dispatchMeshCommand: config.dispatchMeshCommand,
312
313
  getCdpLogFn: config.getCdpLogFn || ((ideType: string) => LOG.forComponent(`CDP:${ideType}`).asLogFn()),
313
314
  });
314
315
 
@@ -17,6 +17,7 @@ export interface ChatTailSubscriptionCursor {
17
17
  export type SessionChatTailCommandResult = Partial<Omit<ReadChatSyncResult, 'activeModal'>> & {
18
18
  success?: boolean
19
19
  activeModal?: unknown
20
+ messagesTail?: unknown
20
21
  }
21
22
 
22
23
  export interface PrepareSessionChatTailUpdateInput {
@@ -102,7 +103,10 @@ export function prepareSessionChatTailUpdate(
102
103
  }
103
104
  }
104
105
 
105
- const fullMessages = normalizeChatMessages(Array.isArray(result.messages) ? result.messages as any[] : [])
106
+ const rawMessages = Array.isArray(result.messages)
107
+ ? result.messages as any[]
108
+ : (Array.isArray(result.messagesTail) ? result.messagesTail as any[] : [])
109
+ const fullMessages = normalizeChatMessages(rawMessages)
106
110
  const messages = fullMessages
107
111
  const title = typeof result.title === 'string' ? result.title : undefined
108
112
  const activeModal = normalizeChatTailActiveModal(result.activeModal)
@@ -38,7 +38,8 @@ export interface CliAdapter {
38
38
  workingDir: string;
39
39
  _acpInstance?: AcpAdapterHandle;
40
40
  spawn(): Promise<void>;
41
- sendMessage(text: string): Promise<void>;
41
+ sendMessage(text: string, options?: { force?: boolean }): Promise<void>;
42
+ forceSendMessage?(text: string): Promise<void>;
42
43
  getStatus(): CliAdapterStatus;
43
44
  getScriptParsedStatus?(): unknown;
44
45
  getDebugSnapshot?(): unknown;