@adhdev/daemon-core 0.9.82-rc.113 → 0.9.82-rc.115

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.
@@ -41,6 +41,14 @@ export interface MeshActiveWorkSummary {
41
41
  */
42
42
  staleDirectNote?: string;
43
43
  }
44
+ export interface MeshStaleDirectWorkSummary {
45
+ count: number;
46
+ sampleLimit: number;
47
+ sample: Array<Pick<MeshActiveWorkRecord, 'taskId' | 'status' | 'nodeId' | 'sessionId' | 'taskTitle' | 'createdAt' | 'staleReason'>>;
48
+ reasonCounts: Record<string, number>;
49
+ detailHint: string;
50
+ note?: string;
51
+ }
44
52
  export interface BuildMeshActiveWorkOptions {
45
53
  meshId: string;
46
54
  queue?: MeshWorkQueueEntry[];
@@ -58,3 +66,8 @@ export declare function buildMeshActiveWork(opts: BuildMeshActiveWorkOptions): {
58
66
  terminalDirectWork: MeshActiveWorkRecord[];
59
67
  summary: MeshActiveWorkSummary;
60
68
  };
69
+ export declare function buildCompactStaleDirectWorkSummary(staleDirectWork: MeshActiveWorkRecord[], opts?: {
70
+ sampleLimit?: number;
71
+ detailHint?: string;
72
+ note?: string;
73
+ }): MeshStaleDirectWorkSummary;
@@ -0,0 +1,27 @@
1
+ import type { MeshLedgerEntry } from './mesh-ledger.js';
2
+ import type { PendingMeshCoordinatorEvent } from './mesh-events.js';
3
+ export type MeshAsyncRefineJobStatus = 'accepted' | 'running' | 'completed' | 'failed';
4
+ export interface MeshAsyncRefineJobSummary {
5
+ jobId: string;
6
+ interactionId?: string;
7
+ status: MeshAsyncRefineJobStatus;
8
+ meshId?: string;
9
+ nodeId?: string;
10
+ targetNodeId?: string;
11
+ targetDaemonId?: string;
12
+ workspace?: string;
13
+ branch?: string;
14
+ into?: string;
15
+ startedAt?: string;
16
+ completedAt?: string;
17
+ retryOfJobId?: string;
18
+ lastEvent?: string;
19
+ lastLedgerKind?: string;
20
+ lastUpdatedAt?: string;
21
+ instruction: string;
22
+ }
23
+ export declare function buildMeshAsyncRefineJobs(args: {
24
+ meshId?: string;
25
+ ledgerEntries?: MeshLedgerEntry[];
26
+ pendingEvents?: PendingMeshCoordinatorEvent[];
27
+ }): MeshAsyncRefineJobSummary[];
@@ -0,0 +1,18 @@
1
+ export type PreviewFreshnessStatus = 'fresh' | 'stale' | 'unknown' | 'not_configured';
2
+ export interface PreviewFreshness {
3
+ status: PreviewFreshnessStatus;
4
+ lastPreviewCommit: string | null;
5
+ currentMainCommit: string | null;
6
+ currentMainCommitSource: 'origin/main' | 'HEAD' | 'unknown';
7
+ recordPath: string;
8
+ lastDeployedAt?: string;
9
+ lastTarget?: string;
10
+ previewVersion?: string;
11
+ targets: Record<'npm' | 'server' | 'web', {
12
+ commit: string | null;
13
+ deployedAt?: string;
14
+ status: PreviewFreshnessStatus;
15
+ }>;
16
+ nextAction: string;
17
+ }
18
+ export declare function buildPreviewFreshness(repoRoot: string): PreviewFreshness;
@@ -8,6 +8,7 @@ export interface RepoMeshRefineValidationCommandConfig {
8
8
  category?: MeshRefineValidationCategory;
9
9
  cwd?: string;
10
10
  timeoutMs?: number;
11
+ outputLimitBytes?: number;
11
12
  env?: Record<string, string>;
12
13
  }
13
14
  export interface RepoMeshRefineConfig {
@@ -37,6 +38,7 @@ export interface MeshRefineValidationCommandPlan {
37
38
  source: string;
38
39
  cwd?: string;
39
40
  timeoutMs?: number;
41
+ outputLimitBytes?: number;
40
42
  env?: Record<string, string>;
41
43
  }
42
44
  export interface MeshRefineConfigLoadResult {
@@ -110,6 +112,11 @@ export declare const MESH_REFINE_CONFIG_SCHEMA: {
110
112
  readonly minimum: 1000;
111
113
  readonly maximum: 600000;
112
114
  };
115
+ readonly outputLimitBytes: {
116
+ readonly type: "number";
117
+ readonly minimum: 1024;
118
+ readonly maximum: 1048576;
119
+ };
113
120
  readonly env: {
114
121
  readonly type: "object";
115
122
  readonly additionalProperties: {
@@ -148,6 +155,11 @@ export declare const MESH_REFINE_CONFIG_SCHEMA: {
148
155
  readonly minimum: 1000;
149
156
  readonly maximum: 600000;
150
157
  };
158
+ readonly outputLimitBytes: {
159
+ readonly type: "number";
160
+ readonly minimum: 1024;
161
+ readonly maximum: 1048576;
162
+ };
151
163
  readonly env: {
152
164
  readonly type: "object";
153
165
  readonly additionalProperties: {
@@ -161,6 +173,11 @@ export declare const MESH_REFINE_CONFIG_SCHEMA: {
161
173
  };
162
174
  };
163
175
  };
176
+ export declare function isMeshConfigRecord(value: unknown): value is Record<string, unknown>;
177
+ export declare function normalizeMeshCommandConfig(entry: unknown, source: string): {
178
+ command?: MeshRefineValidationCommandPlan;
179
+ rejected?: Record<string, unknown>;
180
+ };
164
181
  export declare function validateMeshRefineConfig(config: unknown, source?: string): {
165
182
  valid: boolean;
166
183
  errors: string[];
@@ -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>;
@@ -240,6 +240,20 @@ export interface LocalMeshNodeEntry {
240
240
  worktreeBranch?: string;
241
241
  /** Node ID this worktree was cloned from */
242
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
+ };
243
257
  /** Optional associated/external repos configured as node metadata. */
244
258
  relatedRepos?: RepoMeshRelatedRepo[];
245
259
  role?: RepoMeshDaemonRole;
@@ -304,6 +318,9 @@ export interface RepoMeshNodeStatus {
304
318
  activeSessionDetails?: RepoMeshSessionStatus[];
305
319
  providerPriority?: string[];
306
320
  launchReady?: boolean;
321
+ worktreeBootstrap?: LocalMeshNodeEntry['worktreeBootstrap'];
322
+ launchBlockedReason?: string;
323
+ launchBlockedMessage?: string;
307
324
  lastSeenAt?: string;
308
325
  updatedAt?: string;
309
326
  connection?: RepoMeshPeerConnectionStatus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.113",
3
+ "version": "0.9.82-rc.115",
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",
@@ -279,7 +279,18 @@ function readHistorySessionIdFromMessages(messages: ChatMessage[]): string | und
279
279
  return undefined;
280
280
  }
281
281
 
282
- function normalizeNativeHistoryMessages(providerType: string, messages: ChatMessage[]): ChatMessage[] {
282
+ function shouldPreserveNativeIdentity(providerType: string, sessionId: string, message: ChatMessage): boolean {
283
+ const providerUnitKey = typeof message.providerUnitKey === 'string' ? message.providerUnitKey.trim() : '';
284
+ const turnKey = typeof message._turnKey === 'string' ? message._turnKey.trim() : '';
285
+ if (!providerUnitKey || !turnKey) return false;
286
+ if (providerType === 'hermes-cli' && sessionId) {
287
+ return providerUnitKey.startsWith(`${providerType}:native:${sessionId}:`)
288
+ && turnKey.startsWith(`${providerType}:native-turn:${sessionId}:`);
289
+ }
290
+ return true;
291
+ }
292
+
293
+ function normalizeNativeHistoryMessages(providerType: string, messages: ChatMessage[], nativeSessionId?: string): ChatMessage[] {
283
294
  let turnIndex = 0;
284
295
  return normalizeChatMessages(messages).map((message, index) => {
285
296
  const role = typeof message.role === 'string' ? message.role.trim().toLowerCase() : '';
@@ -296,9 +307,13 @@ function normalizeNativeHistoryMessages(providerType: string, messages: ChatMess
296
307
  kind,
297
308
  flattenContent(message.content),
298
309
  ]).slice(0, 12);
299
- const providerUnitKey = typeof message.providerUnitKey === 'string' && message.providerUnitKey.trim()
300
- ? message.providerUnitKey.trim()
301
- : `${providerType}:native:${historySessionId || 'workspace'}:${index}:${role || 'message'}:${kind}:${contentHash}`;
310
+ const nativeIdentitySessionId = historySessionId || (typeof nativeSessionId === 'string' ? nativeSessionId.trim() : '');
311
+ const preserveNativeIdentity = shouldPreserveNativeIdentity(providerType, nativeIdentitySessionId, message);
312
+ const existingProviderUnitKey = typeof message.providerUnitKey === 'string' ? message.providerUnitKey.trim() : '';
313
+ const existingTurnKey = typeof message._turnKey === 'string' ? message._turnKey.trim() : '';
314
+ const providerUnitKey = preserveNativeIdentity
315
+ ? existingProviderUnitKey
316
+ : `${providerType}:native:${nativeIdentitySessionId || 'workspace'}:${index}:${role || 'message'}:${kind}:${contentHash}`;
302
317
  const meta = message.meta && typeof message.meta === 'object' ? message.meta as Record<string, unknown> : undefined;
303
318
  const isSystemSessionStart = role === 'system' || kind === 'system' || kind === 'session_start';
304
319
  const isActivity = role === 'assistant' && (kind === 'tool' || kind === 'terminal' || kind === 'thought');
@@ -308,11 +323,12 @@ function normalizeNativeHistoryMessages(providerType: string, messages: ChatMess
308
323
  kind: isSystemSessionStart ? 'system' : kind,
309
324
  providerUnitKey,
310
325
  bubbleId: typeof message.bubbleId === 'string' && message.bubbleId.trim()
326
+ && preserveNativeIdentity
311
327
  ? message.bubbleId.trim()
312
328
  : `bubble:${providerUnitKey}`,
313
- _turnKey: typeof message._turnKey === 'string' && message._turnKey.trim()
314
- ? message._turnKey.trim()
315
- : `${providerType}:native-turn:${historySessionId || 'workspace'}:${turnIndex}`,
329
+ _turnKey: preserveNativeIdentity
330
+ ? existingTurnKey
331
+ : `${providerType}:native-turn:${nativeIdentitySessionId || 'workspace'}:${turnIndex}`,
316
332
  bubbleState: message.bubbleState || 'final',
317
333
  ...(isSystemSessionStart ? {
318
334
  visibility: message.visibility || 'hidden',
@@ -1194,7 +1210,9 @@ export async function handleChatHistory(h: CommandHelpers, args: any): Promise<C
1194
1210
  });
1195
1211
  if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
1196
1212
  const lookup = (result as any).lookup === 'workspace' ? 'workspace' : 'session';
1197
- const messages = Array.isArray((result as any).messages) ? normalizeNativeHistoryMessages(agentStr, (result as any).messages as ChatMessage[]) : [];
1213
+ const messages = Array.isArray((result as any).messages)
1214
+ ? normalizeNativeHistoryMessages(agentStr, (result as any).messages as ChatMessage[], (result as any)?.providerSessionId)
1215
+ : [];
1198
1216
  const historyProviderSessionId = typeof (result as any)?.providerSessionId === 'string'
1199
1217
  ? (result as any).providerSessionId
1200
1218
  : readHistorySessionIdFromMessages(messages) || historySessionId;
@@ -1335,7 +1353,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1335
1353
 
1336
1354
  if (nativeHistory) {
1337
1355
  const nativeMessages = Array.isArray((nativeHistory as any).messages)
1338
- ? normalizeNativeHistoryMessages(agentStr, (nativeHistory as any).messages as ChatMessage[])
1356
+ ? normalizeNativeHistoryMessages(agentStr, (nativeHistory as any).messages as ChatMessage[], (nativeHistory as any)?.providerSessionId)
1339
1357
  : [];
1340
1358
  const historyProviderSessionId = typeof (nativeHistory as any)?.providerSessionId === 'string'
1341
1359
  ? (nativeHistory as any).providerSessionId
@@ -1497,7 +1515,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1497
1515
  });
1498
1516
  const lookup = (history as any).lookup === 'workspace' ? 'workspace' : 'session';
1499
1517
  const historyMessages = Array.isArray((history as any)?.messages)
1500
- ? normalizeNativeHistoryMessages(agentStr, (history as any).messages as ChatMessage[])
1518
+ ? normalizeNativeHistoryMessages(agentStr, (history as any).messages as ChatMessage[], (history as any)?.providerSessionId)
1501
1519
  : [];
1502
1520
  const historyProviderSessionId = typeof (history as any)?.providerSessionId === 'string'
1503
1521
  ? (history as any).providerSessionId