@adhdev/daemon-core 0.9.82-rc.467 → 0.9.82-rc.469

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 (37) hide show
  1. package/dist/index.d.ts +7 -5
  2. package/dist/index.js +955 -726
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +953 -731
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/mesh/mesh-completion-synthesis.d.ts +4 -0
  7. package/dist/mesh/mesh-delivery-policy.d.ts +0 -27
  8. package/dist/mesh/mesh-events-pending.d.ts +40 -0
  9. package/dist/mesh/mesh-events.d.ts +2 -2
  10. package/dist/mesh/mesh-ledger.d.ts +1 -1
  11. package/dist/mesh/mesh-reconcile-config.d.ts +6 -0
  12. package/dist/mesh/mesh-remote-event-pull.d.ts +15 -0
  13. package/dist/mesh/mesh-runtime-store.d.ts +0 -22
  14. package/dist/mesh/mesh-work-queue.d.ts +45 -0
  15. package/dist/providers/cli-provider-effect-format.d.ts +30 -0
  16. package/dist/providers/cli-provider-instance-types.d.ts +45 -0
  17. package/dist/providers/cli-provider-instance.d.ts +12 -6
  18. package/dist/providers/cli-provider-transcript-merge.d.ts +7 -0
  19. package/package.json +3 -3
  20. package/src/index.ts +11 -5
  21. package/src/mesh/coordinator-prompt.ts +15 -0
  22. package/src/mesh/mesh-completion-synthesis.ts +398 -0
  23. package/src/mesh/mesh-delivery-policy.ts +7 -38
  24. package/src/mesh/mesh-event-forwarding.ts +9 -10
  25. package/src/mesh/mesh-events-pending.ts +178 -0
  26. package/src/mesh/mesh-events.ts +6 -1
  27. package/src/mesh/mesh-ledger.ts +5 -0
  28. package/src/mesh/mesh-queue-assignment.ts +16 -2
  29. package/src/mesh/mesh-reconcile-config.ts +66 -0
  30. package/src/mesh/mesh-reconcile-loop.ts +21 -647
  31. package/src/mesh/mesh-remote-event-pull.ts +279 -0
  32. package/src/mesh/mesh-runtime-store.ts +92 -83
  33. package/src/mesh/mesh-work-queue.ts +90 -0
  34. package/src/providers/cli-provider-effect-format.ts +53 -0
  35. package/src/providers/cli-provider-instance-types.ts +131 -0
  36. package/src/providers/cli-provider-instance.ts +87 -303
  37. package/src/providers/cli-provider-transcript-merge.ts +114 -0
@@ -0,0 +1,4 @@
1
+ import type { DaemonComponents } from '../boot/daemon-lifecycle.js';
2
+ import type { LocalMeshEntry } from '../repo-mesh-types.js';
3
+ export declare function reconcileUnterminatedDirectDispatches(components: DaemonComponents, mesh: LocalMeshEntry, selfIds: string[], localDaemonId: string | undefined): Promise<void>;
4
+ export declare function autoPruneStaleDirectDispatches(components: DaemonComponents, mesh: LocalMeshEntry, selfIds: string[], localDaemonId: string | undefined, minAgeMs: number): Promise<void>;
@@ -96,33 +96,6 @@ export declare function getActiveSessionDeliveries(meshId: string, sessionId?: s
96
96
  createdAt: string;
97
97
  updatedAt: string;
98
98
  }[];
99
- /**
100
- * Record a completion conflict diagnostic when a duplicate event points to
101
- * different task/session than the already-seen event with the same fingerprint.
102
- */
103
- export declare function recordCompletionConflict(opts: {
104
- meshId: string;
105
- fingerprint: string;
106
- conflictingTaskId?: string;
107
- conflictingSessionId?: string;
108
- originalTaskId?: string;
109
- originalSessionId?: string;
110
- event: string;
111
- }): void;
112
- /**
113
- * Get recent completion conflicts for diagnostic inspection.
114
- */
115
- export declare function getRecentCompletionConflicts(meshId: string, limitMs?: number): {
116
- id: string;
117
- meshId: string;
118
- fingerprint: string;
119
- conflictingTaskId: string | null;
120
- conflictingSessionId: string | null;
121
- originalTaskId: string | null;
122
- originalSessionId: string | null;
123
- event: string;
124
- createdAt: string;
125
- }[];
126
99
  export declare function __clearSessionDeliveriesForTests(meshId: string): void;
127
100
  /**
128
101
  * Mark all active (queued/delivering/delivered/acked) deliveries for a session as completed or failed.
@@ -201,6 +201,46 @@ export declare function __clearMeshPendingEventsForTests(meshId: string): void;
201
201
  * version-skewed remote relays, so tests inject those rows directly through this.
202
202
  */
203
203
  export declare function __persistUnstampedPendingEventForTests(event: PendingMeshCoordinatorEvent): boolean;
204
+ /** Narrowing filter for {@link requeueHeldMeshCoordinatorEvents}, scoped within one mesh. */
205
+ export interface MeshHeldEventRequeueFilter {
206
+ /** Restore only held events whose worker task id matches (from the held event's metadata/taskId). */
207
+ taskId?: string;
208
+ /** Restore only held events originating from this node. */
209
+ nodeId?: string;
210
+ /** Restore only held events of this event name (e.g. 'session:completed'). */
211
+ event?: string;
212
+ /** Restore only held entries recorded at/after this ISO timestamp. */
213
+ since?: string;
214
+ /** Restore only held entries with this hold reason (e.g. 'pending_trim_dropped'). */
215
+ reason?: string;
216
+ }
217
+ export interface MeshHeldEventRequeueResult {
218
+ meshId: string;
219
+ /** event_held entries considered after the filter. */
220
+ matched: number;
221
+ /** entries skipped because a prior requeue already recovered them. */
222
+ alreadyRequeued: number;
223
+ /** entries skipped because they carried no restorable original event / were not recoverable. */
224
+ unrecoverable: number;
225
+ /** entries handed to the pending queue (some may have been dedup-suppressed downstream). */
226
+ requeued: number;
227
+ /** of `requeued`, how many the pending-queue dedup collapsed onto a live event. */
228
+ dedupSuppressed: number;
229
+ entries: Array<{
230
+ heldEntryId: string;
231
+ event: string;
232
+ nodeId?: string;
233
+ taskId?: string;
234
+ reason?: string;
235
+ outcome: 'requeued' | 'already_requeued' | 'unrecoverable';
236
+ }>;
237
+ }
238
+ /**
239
+ * Restore recoverable `event_held` ledger entries back to the pending coordinator
240
+ * queue for `meshId`. See the block comment above for the no-loss / no-double-requeue
241
+ * invariants. Returns per-entry outcomes for the caller to surface.
242
+ */
243
+ export declare function requeueHeldMeshCoordinatorEvents(meshId: string, filter?: MeshHeldEventRequeueFilter): MeshHeldEventRequeueResult;
204
244
  /** Explicitly clear all pending coordinator events for a mesh (and coordinator if scoped). */
205
245
  export declare function clearPendingMeshCoordinatorEvents(meshId?: string, coordinatorDaemonId?: string): void;
206
246
  export {};
@@ -1,5 +1,5 @@
1
- export type { PendingMeshCoordinatorEvent } from './mesh-events-pending.js';
2
- export { queuePendingMeshCoordinatorEvent, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, serializeV2EnvelopeToWire, readV2EnvelopeFromWire, getMeshV2DrainCounters, isMeshProtocolV2EnforceEnabled, } from './mesh-events-pending.js';
1
+ export type { PendingMeshCoordinatorEvent, MeshHeldEventRequeueFilter, MeshHeldEventRequeueResult, } from './mesh-events-pending.js';
2
+ export { queuePendingMeshCoordinatorEvent, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, requeueHeldMeshCoordinatorEvents, serializeV2EnvelopeToWire, readV2EnvelopeFromWire, getMeshV2DrainCounters, isMeshProtocolV2EnforceEnabled, } from './mesh-events-pending.js';
3
3
  export { reconcileDirectDispatchCompletionFromTranscript, } from './mesh-events-stale.js';
4
4
  export { setupMeshReconcileLoop, runMeshReconcileTick, resolveCoordinatorDrainDeliverability, shouldHoldPendingDrainForBusyLocalCoordinator, getMeshV2BackstopCounters, } from './mesh-reconcile-loop.js';
5
5
  export type { MeshQueueTriggerResult } from './mesh-events-coordinator.js';
@@ -15,7 +15,7 @@
15
15
  import { EventEmitter } from 'events';
16
16
  import { MeshRuntimeStore } from './mesh-runtime-store.js';
17
17
  import { type MeshLedgerOriginatingCoordinatorV2 } from './contracts.js';
18
- export type MeshLedgerKind = 'task_dispatched' | 'task_completed' | 'task_failed' | 'task_stalled' | 'task_approval_needed' | 'p2p_dispatch_failed' | 'session_launched' | 'session_auto_launch' | 'session_stopped' | 'checkpoint_created' | 'node_cloned' | 'node_joined' | 'node_removed' | 'coordinator_started' | 'recovery_attempted' | 'ledger_replicated' | 'ledger_reconciled' | 'direct_fast_forward' | 'delivery_unroutable' | 'direct_dispatch_pruned' | 'event_held' | 'task_reclaimed' | 'coordinator_operating_note' | 'coordinator_operating_note_tombstone' | 'mission_created' | 'mission_status_changed' | 'mission_goal_updated' | 'magi_dispatched' | 'magi_synthesis';
18
+ export type MeshLedgerKind = 'task_dispatched' | 'task_completed' | 'task_failed' | 'task_stalled' | 'task_approval_needed' | 'p2p_dispatch_failed' | 'session_launched' | 'session_auto_launch' | 'session_stopped' | 'checkpoint_created' | 'node_cloned' | 'node_joined' | 'node_removed' | 'coordinator_started' | 'recovery_attempted' | 'ledger_replicated' | 'ledger_reconciled' | 'direct_fast_forward' | 'delivery_unroutable' | 'direct_dispatch_pruned' | 'event_held' | 'event_held_requeued' | 'task_reclaimed' | 'coordinator_operating_note' | 'coordinator_operating_note_tombstone' | 'mission_created' | 'mission_status_changed' | 'mission_goal_updated' | 'magi_dispatched' | 'magi_synthesis';
19
19
  export interface MeshLedgerEntry {
20
20
  id: string;
21
21
  meshId: string;
@@ -0,0 +1,6 @@
1
+ export declare const DEFAULT_RECONCILE_INTERVAL_MS = 4000;
2
+ export declare const DEFAULT_AUTO_PRUNE_MIN_AGE_MS: number;
3
+ export declare function resolveAutoPruneMinAgeMs(): number;
4
+ export declare const DEFAULT_PENDING_HELD_DRAIN_ESCALATE_MS = 12000;
5
+ export declare function resolvePendingHeldDrainEscalateMs(): number;
6
+ export declare function resolveReconcileIntervalMs(): number;
@@ -0,0 +1,15 @@
1
+ import type { DaemonComponents } from '../boot/daemon-lifecycle.js';
2
+ import type { LocalMeshEntry } from '../repo-mesh-types.js';
3
+ export declare function pullRemoteNodeQueues(components: DaemonComponents, mesh: LocalMeshEntry, localDaemonId: string | undefined, candidateDaemonIds: string[]): Promise<void>;
4
+ export declare function unwrapReadChatPayload(raw: unknown): Record<string, unknown> | null;
5
+ export declare function readChatPayloadStatus(payload: Record<string, unknown> | null): string;
6
+ export declare function realTerminalEmitPendingForTask(meshId: string, taskId: string): boolean;
7
+ export declare function reprobeWorkerStatus(components: DaemonComponents, args: {
8
+ isLocalNode: boolean;
9
+ nodeDaemonId: string;
10
+ readArgs: Record<string, unknown>;
11
+ }): Promise<string | null>;
12
+ export declare function collectLiveNodesWithSessions(components: DaemonComponents, mesh: LocalMeshEntry, selfIds: string[], localDaemonId: string | undefined): Promise<any[]>;
13
+ export declare function extractStatusMetadataSessions(raw: unknown): any[];
14
+ export declare function extractPendingEvents(raw: unknown): any[];
15
+ export declare function buildForwardPayloadFromPending(event: any): Record<string, unknown>;
@@ -241,28 +241,6 @@ export declare class MeshRuntimeStore {
241
241
  taskHasConfirmedDelivery(meshId: string, taskId: string): boolean;
242
242
  expireStaleSessionDeliveries(meshId: string): void;
243
243
  deleteSessionDeliveries(meshId: string): void;
244
- recordCompletionConflict(entry: {
245
- id: string;
246
- meshId: string;
247
- fingerprint: string;
248
- conflictingTaskId?: string;
249
- conflictingSessionId?: string;
250
- originalTaskId?: string;
251
- originalSessionId?: string;
252
- event: string;
253
- createdAt: string;
254
- }): void;
255
- getRecentCompletionConflicts(meshId: string, limitMs?: number): Array<{
256
- id: string;
257
- meshId: string;
258
- fingerprint: string;
259
- conflictingTaskId: string | null;
260
- conflictingSessionId: string | null;
261
- originalTaskId: string | null;
262
- originalSessionId: string | null;
263
- event: string;
264
- createdAt: string;
265
- }>;
266
244
  /**
267
245
  * Record a mesh tool call and check whether this mesh+tool combination is
268
246
  * being called too rapidly (sliding window rate guard).
@@ -4,9 +4,32 @@ export type MeshTaskStatus = 'pending' | 'assigned' | 'completed' | 'failed' | '
4
4
  export type MeshActiveTaskStatus = Extract<MeshTaskStatus, 'pending' | 'assigned'>;
5
5
  export type MeshHistoricalTaskStatus = Extract<MeshTaskStatus, 'completed' | 'failed' | 'cancelled'>;
6
6
  export type MeshTaskMode = 'code_change' | 'validation' | 'live_debug_readonly' | 'launch_app' | 'convergence';
7
+ /** G6: task-level scheduling priority. Ranks which task a node pulls first (created_at tie-break). */
8
+ export type MeshTaskPriority = 'low' | 'normal' | 'high';
7
9
  export declare const ACTIVE_MESH_QUEUE_STATUSES: MeshActiveTaskStatus[];
8
10
  export declare const HISTORICAL_MESH_QUEUE_STATUSES: MeshHistoricalTaskStatus[];
9
11
  export declare const MESH_TASK_MODES: MeshTaskMode[];
12
+ export declare const MESH_TASK_PRIORITIES: MeshTaskPriority[];
13
+ /**
14
+ * G6: numeric rank of a task priority (higher = pulled first). Absent/unknown → 'normal' (1).
15
+ * Shared by the claim-candidate ordering and any surface that must sort by task priority.
16
+ */
17
+ export declare function meshTaskPriorityRank(priority: unknown): number;
18
+ /** G6: coerce an arbitrary input to a valid MeshTaskPriority, or undefined when not one of the three. */
19
+ export declare function normalizeMeshTaskPriority(value: unknown): MeshTaskPriority | undefined;
20
+ /**
21
+ * G7: resolve a not_before input to a stored ISO string (or undefined when absent/invalid).
22
+ * Accepts an ISO/date string, an absolute epoch-ms number, or a small relative-ms offset from
23
+ * `nowMs`. Disambiguation for numbers: a value below {@link NOT_BEFORE_RELATIVE_THRESHOLD_MS}
24
+ * (~1 year in ms) is treated as a relative offset added to now; a larger value is an absolute
25
+ * epoch-ms timestamp. A past/negative result is normalized to now (immediately claimable).
26
+ */
27
+ export declare const NOT_BEFORE_RELATIVE_THRESHOLD_MS: number;
28
+ export declare function resolveNotBefore(value: unknown, nowMs?: number): string | undefined;
29
+ /** G7: is a task claimable now, or is it still held back by its notBefore gate? */
30
+ export declare function meshTaskNotBeforeReady(task: {
31
+ notBefore?: string;
32
+ } | null | undefined, nowMs?: number): boolean;
10
33
  /**
11
34
  * QUEUE-NODE-SERIALIZATION: single source of truth for "is this task read-only?".
12
35
  *
@@ -57,6 +80,22 @@ export interface MeshWorkQueueEntry {
57
80
  targetSessionId?: string;
58
81
  /** If specified, a node must expose all tags before it can claim the task. */
59
82
  requiredTags?: string[];
83
+ /**
84
+ * G6 (task-level scheduling priority): 'low' | 'normal' | 'high'. Orders the
85
+ * claim candidate list so a high-priority task is pulled ahead of an older
86
+ * normal/low task within the same claim tier (created_at is the tie-break).
87
+ * Absent → treated as 'normal'. This is the TASK-level priority, distinct from
88
+ * the NODE-level schedulingPriority (resolveNodeSchedulingPriority), which ranks
89
+ * which node a task goes to, not which task a node pulls first.
90
+ */
91
+ priority?: MeshTaskPriority;
92
+ /**
93
+ * G7 (delayed execution): ISO timestamp before which the task is NOT claimable.
94
+ * The claim gate holds the task pending while now < notBefore; once the wall
95
+ * clock passes it the task becomes a normal claim candidate. A pure time gate —
96
+ * cron/webhook triggers are out of scope. Absent → immediately claimable.
97
+ */
98
+ notBefore?: string;
60
99
  /**
61
100
  * M1: ids of tasks that must reach 'completed' before this task is claimable.
62
101
  * Forward references (ids not yet enqueued) are allowed for batch flows and
@@ -190,6 +229,12 @@ export declare function enqueueTask(meshId: string, message: string, opts?: {
190
229
  requiredTags?: string[];
191
230
  /** M1: tasks that must complete before this one is claimable. */
192
231
  dependsOn?: string[];
232
+ /** G6: task-level scheduling priority ('low' | 'normal' | 'high'). Absent → 'normal'. */
233
+ priority?: MeshTaskPriority | string;
234
+ /** G7: hold the task pending until this time. ISO string, absolute epoch-ms, or relative-ms offset from now. */
235
+ notBefore?: string | number;
236
+ /** P3: max automatic requeue attempts before the task auto-fails. Absent → policy default (1). */
237
+ maxRetries?: number;
193
238
  /** M1/M3: mission this task belongs to. */
194
239
  missionId?: string;
195
240
  /** MAGI: consensus group id shared by every replica of a mesh_magi_review fan-out. */
@@ -0,0 +1,30 @@
1
+ export declare function getEffectDedupKey(effect: {
2
+ id?: string;
3
+ type: string;
4
+ message?: {
5
+ content?: unknown;
6
+ };
7
+ toast?: {
8
+ message?: string;
9
+ };
10
+ notification?: {
11
+ title?: string;
12
+ body?: string;
13
+ };
14
+ }): string;
15
+ export declare function getPersistedEffectContent(effect: {
16
+ type: string;
17
+ message?: {
18
+ content?: unknown;
19
+ };
20
+ toast?: {
21
+ message?: string;
22
+ };
23
+ notification?: {
24
+ title?: string;
25
+ body?: string;
26
+ bubbleContent?: unknown;
27
+ };
28
+ }): string | null;
29
+ export declare function formatApprovalRequestMessage(modalMessage?: string, buttons?: string[]): string;
30
+ export declare function formatMarkerTimestamp(timestamp: number): string;
@@ -0,0 +1,45 @@
1
+ export declare const STATUS_HYDRATION_TAIL_LIMIT = 200;
2
+ export type CompletedDebouncePending = {
3
+ chatTitle: string;
4
+ duration: number;
5
+ timestamp: number;
6
+ firstObservedAt: number;
7
+ previousStatus: string;
8
+ loggedBlockReason?: string;
9
+ loggedTranscriptProbe?: boolean;
10
+ transcriptProbeHistory?: ExternalTranscriptProbe[];
11
+ taskId?: string;
12
+ turnStartedAt?: number;
13
+ busyEpochAtArm?: number;
14
+ lastOutputAtArm?: number;
15
+ };
16
+ export type CompletedFinalizationBlock = {
17
+ reason: string;
18
+ terminal?: boolean;
19
+ allowTimeout?: boolean;
20
+ holdForTranscript?: boolean;
21
+ };
22
+ export type CompletionFinalAssistantEvidence = {
23
+ present: boolean;
24
+ messages: unknown[];
25
+ source: 'parsed' | 'external-native' | 'unavailable';
26
+ };
27
+ export type ExternalTranscriptProbe = {
28
+ readAt: number;
29
+ msgCount: number;
30
+ lastRole: string | null;
31
+ lastKind: string | null;
32
+ contentLen: number;
33
+ sourcePath: string | null;
34
+ sourceMtimeMs: number | null;
35
+ mtimeAgeMs: number | null;
36
+ };
37
+ export declare const COMPLETED_FINALIZATION_RETRY_MS = 1000;
38
+ export declare const COMPLETED_FINALIZATION_MAX_WAIT_MS = 30000;
39
+ export declare const NATIVE_HISTORY_MESH_IDLE_SETTLE_MS = 4000;
40
+ export declare const USER_INPUT_ACK_DEDUP_WINDOW_MS = 60000;
41
+ export declare const STARTUP_GRACE_IDLE_COLLAPSE_WINDOW_MS = 12000;
42
+ /** Events that signal a dispatched mesh task has reached a terminal state.
43
+ * Detach the mesh assignment after emitting one of these so the worker's
44
+ * next unrelated turn doesn't impersonate another completion. */
45
+ export declare const TERMINAL_MESH_EVENTS: Set<string>;
@@ -278,7 +278,6 @@ export declare class CliProviderInstance implements ProviderInstance {
278
278
  private lastExternalCompletionProbe;
279
279
  private enforceFreshSessionLaunchIfNeeded;
280
280
  private completionHasFinalAssistantMessage;
281
- private buildExternalTranscriptProbe;
282
281
  private recordPendingTranscriptProbe;
283
282
  /**
284
283
  * The spawned CLI's env overrides (e.g. the mesh coordinator points hermes
@@ -312,6 +311,18 @@ export declare class CliProviderInstance implements ProviderInstance {
312
311
  * genuine resolution frees the gate promptly.
313
312
  */
314
313
  private autoApproveContinuityWindowMs;
314
+ /**
315
+ * The settle-gate identity signature for a raw activeModal, or null when the
316
+ * modal is NOT a concrete auto-approvable consent prompt (no captured buttons,
317
+ * a picker/confirm kind, or no reliable affirmative+decline anchor). Mirrors the
318
+ * gates the auto-approve fire path applies before computing modalSignature, so
319
+ * the mask-stall nudge can ask the SAME question the settle gate is tracking —
320
+ * "is THIS frame's modal the identity the settle clock is accruing against?" —
321
+ * without duplicating the button-pick logic. The signature is message +
322
+ * normalized affirmative label only (no volatile counters/button set), matching
323
+ * the fire path exactly (AUTOAPPROVE-SETTLE-FLAP).
324
+ */
325
+ private approvableModalSignature;
315
326
  private isAutonomousMeshSession;
316
327
  /**
317
328
  * ARCH-REFACTOR R1: the taskId to attribute the CURRENTLY-completing turn to.
@@ -378,8 +389,6 @@ export declare class CliProviderInstance implements ProviderInstance {
378
389
  private pushEvent;
379
390
  private flushEvents;
380
391
  private applyProviderResponse;
381
- private getEffectDedupKey;
382
- private getPersistedEffectContent;
383
392
  getAdapter(): ProviderCliAdapter;
384
393
  get cliType(): string;
385
394
  get cliName(): string;
@@ -422,13 +431,10 @@ export declare class CliProviderInstance implements ProviderInstance {
422
431
  private maybeEmitStalledApprovalNudge;
423
432
  private recordAutoApproval;
424
433
  recordApprovalSelection(buttonText: string): void;
425
- private formatMarkerTimestamp;
426
434
  private maybeAppendRuntimeRecoveryMessage;
427
435
  private appendRuntimeSystemMessage;
428
436
  private appendRuntimeMessage;
429
437
  mergeRuntimeChatMessages(parsedMessages: ChatMessage[]): ChatMessage[];
430
- private mergeConversationMessages;
431
- private formatApprovalRequestMessage;
432
438
  private promoteProviderSessionId;
433
439
  private shouldHydrateExistingProviderHistory;
434
440
  private shouldSuppressFreshLaunchStartupReplay;
@@ -0,0 +1,7 @@
1
+ import type { ChatMessage } from '../types.js';
2
+ import type { ExternalTranscriptProbe } from './cli-provider-instance-types.js';
3
+ export declare function mergeConversationMessages(runtimeMessages: Array<{
4
+ key: string;
5
+ message: ChatMessage;
6
+ }>, parsedMessages: any[]): ChatMessage[];
7
+ export declare function buildExternalTranscriptProbe(messages: unknown[], sourcePath?: string, sourceMtimeMs?: number): ExternalTranscriptProbe;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.467",
3
+ "version": "0.9.82-rc.469",
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",
@@ -47,8 +47,8 @@
47
47
  "author": "vilmire",
48
48
  "license": "AGPL-3.0-or-later",
49
49
  "dependencies": {
50
- "@adhdev/mesh-shared": "0.9.82-rc.467",
51
- "@adhdev/session-host-core": "0.9.82-rc.467",
50
+ "@adhdev/mesh-shared": "0.9.82-rc.469",
51
+ "@adhdev/session-host-core": "0.9.82-rc.469",
52
52
  "@agentclientprotocol/sdk": "^0.16.1",
53
53
  "ajv": "^8.20.0",
54
54
  "ajv-formats": "^3.0.1",
package/src/index.ts CHANGED
@@ -219,6 +219,12 @@ export { MAGI_RAW_ANSWER_CAP } from '@adhdev/mesh-shared';
219
219
  // @adhdev/mesh-shared dependency). ──
220
220
  export { expandDaemonIdForms, daemonIdsEquivalent, machineCoreFromDaemonId, canonicalDaemonId } from '@adhdev/mesh-shared';
221
221
  export { normalizeMeshNodeId, meshNodeIdMatches } from '@adhdev/mesh-shared';
222
+ // Canonical mesh tool-name registry (SSOT for the schema ↔ prompt ↔ barrel-comment
223
+ // consistency the 6-6 test enforces). Re-exported so mcp-server (which depends on
224
+ // daemon-core, not on mesh-shared directly) and the daemon-core prompt test both
225
+ // reference one list.
226
+ export { CANONICAL_MESH_TOOL_NAMES, CANONICAL_MESH_TOOL_COUNT } from '@adhdev/mesh-shared';
227
+ export type { CanonicalMeshToolName } from '@adhdev/mesh-shared';
222
228
 
223
229
  // ── Mesh Coordinator ──
224
230
  export { buildCoordinatorSystemPrompt } from './mesh/coordinator-prompt.js';
@@ -270,8 +276,8 @@ export { buildMeshLedgerReconciliationEvidence, buildMeshLedgerReplicaEvidence }
270
276
  export type { AnyLedgerSlice, MeshLedgerReconciliationEvidence, MeshLedgerReplicaEvidence, MeshLedgerReplicaStatus } from './mesh/mesh-ledger-reconciliation.js';
271
277
 
272
278
  // ── Mesh Work Queue (GUPP) ──
273
- export { enqueueTask, recordDirectDispatchTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats, getMeshQueueRevision, normalizeMeshTaskMode, validateMeshTaskModeRequest, isTaskReadonly, buildMeshNodeCapabilityTags, nodeSatisfiesRequiredTags, normalizeMeshCapabilityTags, resolveConvergeRequiredTags, insertDirectDispatch, getActiveDirectDispatches, updateDirectDispatchStatus, cleanupTerminalDirectDispatches, markStaleDirectDispatches, deleteDirectDispatchesByTaskId, recordMeshToolCall, assertNoDependencyCycle, hasPendingDependents, describeTaskDependencyState, taskDependenciesSatisfied } from './mesh/mesh-work-queue.js';
274
- export type { MeshWorkQueueEntry, MeshTaskStatus, MeshTaskMode, MeshWorkQueueStats, MeshQueueMutationOptions, MeshTaskModeValidationResult, DirectDispatchRecord, MeshToolCallRateResult } from './mesh/mesh-work-queue.js';
279
+ export { enqueueTask, recordDirectDispatchTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask, getMeshQueueStats, getMeshQueueRevision, normalizeMeshTaskMode, validateMeshTaskModeRequest, isTaskReadonly, buildMeshNodeCapabilityTags, nodeSatisfiesRequiredTags, normalizeMeshCapabilityTags, resolveConvergeRequiredTags, insertDirectDispatch, getActiveDirectDispatches, updateDirectDispatchStatus, cleanupTerminalDirectDispatches, markStaleDirectDispatches, deleteDirectDispatchesByTaskId, recordMeshToolCall, assertNoDependencyCycle, hasPendingDependents, describeTaskDependencyState, taskDependenciesSatisfied, normalizeMeshTaskPriority, meshTaskPriorityRank, resolveNotBefore, meshTaskNotBeforeReady, MESH_TASK_PRIORITIES, NOT_BEFORE_RELATIVE_THRESHOLD_MS } from './mesh/mesh-work-queue.js';
280
+ export type { MeshWorkQueueEntry, MeshTaskStatus, MeshTaskMode, MeshTaskPriority, MeshWorkQueueStats, MeshQueueMutationOptions, MeshTaskModeValidationResult, DirectDispatchRecord, MeshToolCallRateResult } from './mesh/mesh-work-queue.js';
275
281
  export { buildCompactStaleDirectWorkSummary, buildMeshActiveWork, buildMeshActiveWorkSummary, classifyStaleDirectForPrune, pruneStaleDirectDispatches, PRUNABLE_ORPHAN_STALE_REASONS } from './mesh/mesh-active-work.js';
276
282
  export type { StaleDirectPruneClassification, StaleDirectPruneResult, PruneStaleDirectDispatchesOptions } from './mesh/mesh-active-work.js';
277
283
  export type { MeshActiveWorkRecord, MeshActiveWorkStatus, MeshActiveWorkSummary, MeshActiveWorkSource, MeshStaleDirectWorkSummary } from './mesh/mesh-active-work.js';
@@ -295,8 +301,8 @@ export { buildMeshHostRequiredFailure, createDefaultMeshHostMetadata, isMeshHost
295
301
  // export type { MeshGraph, MeshGraphNode, MeshGraphEdge, MeshGraphNodeType, MeshGraphEdgeType } from './mesh/mesh-visualization.js';
296
302
 
297
303
  // ── Mesh Events ──
298
- export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, queuePendingMeshCoordinatorEvent, serializeV2EnvelopeToWire, readV2EnvelopeFromWire, reconcileDirectDispatchCompletionFromTranscript } from './mesh/mesh-events.js';
299
- export type { PendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
304
+ export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, queuePendingMeshCoordinatorEvent, requeueHeldMeshCoordinatorEvents, serializeV2EnvelopeToWire, readV2EnvelopeFromWire, reconcileDirectDispatchCompletionFromTranscript } from './mesh/mesh-events.js';
305
+ export type { PendingMeshCoordinatorEvent, MeshHeldEventRequeueFilter, MeshHeldEventRequeueResult } from './mesh/mesh-events.js';
300
306
  // The coordinator-side preview surfaced from a worker's completion/status event
301
307
  // (finalSummary / workerResult.summary / lastMessagePreview). Same data the mobile
302
308
  // inbox is fed; reused by mesh_read_chat's cache fallback when the live P2P read path
@@ -304,7 +310,7 @@ export type { PendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
304
310
  export { resolveMeshSurfacedSessionPreview, readMeshCompletionSummary, isWeakCompletionEvidence } from './mesh/mesh-events-utils.js';
305
311
 
306
312
  // ── Mesh Delivery Policy ──
307
- export { resolveDeliveryDecision, createSessionDelivery, updateSessionDeliveryStatus, getActiveSessionDeliveries, markSessionDeliveriesTerminal, recordCompletionConflict, getRecentCompletionConflicts } from './mesh/mesh-delivery-policy.js';
313
+ export { resolveDeliveryDecision, createSessionDelivery, updateSessionDeliveryStatus, getActiveSessionDeliveries, markSessionDeliveriesTerminal } from './mesh/mesh-delivery-policy.js';
308
314
  export type { MeshSessionDeliveryStatus, MeshSessionDeliveryKind, MeshDeliveryDecision, MeshDeliveryPolicyResult, SessionDeliveryRecord } from './mesh/mesh-delivery-policy.js';
309
315
 
310
316
  // ── Mesh P2P Relay Failure Classification ──
@@ -615,24 +615,39 @@ const TOOLS_SECTION = `## Available Tools
615
615
  | \`mesh_queue_cancel\` | Cancel a queue task without deleting audit history |
616
616
  | \`mesh_queue_requeue\` | Return a task to pending for retry; clears stale session targets |
617
617
  | \`mesh_send_task\` | Legacy push: enqueue a task targeted at a specific node |
618
+ | \`mesh_mission_upsert\` | Create/update a persistent mission so a multi-task plan survives coordinator restarts; set status completed/abandoned when the outcome is decided |
619
+ | \`mesh_mission_list\` | List every mission with goal, status, and live task progress — the authority for "what work remains" (never hidden by status) |
618
620
  | \`mesh_launch_session\` | Start a new agent session on a node |
619
621
  | \`mesh_read_chat\` | Read recent chat messages from a delegated agent session |
620
622
  | \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
621
623
  | \`mesh_task_history\` | Read the task ledger — dispatches, completions, failures. Use to understand what has been done before deciding next steps |
624
+ | \`mesh_reconcile_ledger\` | Reconcile daemon-local ledgers over P2P — import missing entries from remote nodes into the coordinator local ledger |
625
+ | \`mesh_requeue_held_events\` | Restore recoverable held coordinator events (T6 quarantine / pending-trim) back to the pending queue; lossless, no double-requeue |
626
+ | \`mesh_review_inbox\` | List local worktree nodes needing human review — merge candidates and Refinery-blocked results with evidence/diff summaries |
622
627
  | \`mesh_record_note\` | Record a durable, provider-neutral operating note (provider quirk / pattern to avoid / recovery lesson). Future coordinators see it under "## Operating Notes" at launch |
623
628
  | \`mesh_forget_note\` | Retract a stale/wrong operating note by note_id or exact text so it stops riding into future coordinators' prompts (append-only tombstone; history preserved) |
624
629
  | \`mesh_git_status\` | Check git status on a specific node |
625
630
  | \`mesh_read_node_logs\` | Fetch a remote node's daemon log tail directly over P2P (grep/since/byte-bounded, secrets redacted) — no session/PowerShell needed to debug a node's daemon |
626
631
  | \`mesh_fast_forward_node\` | Safely dry-run or explicitly execute an obvious clean fast-forward without launching an agent session |
632
+ | \`mesh_restart_daemon\` | Update a node's daemon to the latest published version on its channel and restart it (the dashboard "preview update" path, as a mesh command) |
627
633
  | \`mesh_checkpoint\` | Create a git checkpoint on a node |
628
634
  | \`mesh_approve\` | Approve/reject a pending agent action |
629
635
  | \`mesh_clone_node\` | Create a worktree node for isolated parallel branch work |
630
636
  | \`mesh_refine_node\` | Validate and merge a completed worktree node back into its base branch |
637
+ | \`mesh_refine_batch\` | Batch Refinery: converge multiple sibling worktree nodes onto the base branch in one conflict-aware sequential pipeline |
638
+ | \`mesh_refine_plan\` | Dry-run Refinery plan for a worktree node — config source, validation commands, merge/cleanup intent — without executing validation or git merge |
639
+ | \`mesh_refine_config\` | Refinery config helper (read-only) — unified entry for schema/validate/suggest via a required \`mode\` |
640
+ | \`mesh_change_impact_config\` | Change Impact config helper — unified entry for schema/validate/suggest via a required \`mode\` |
631
641
  | \`mesh_remove_node\` | Remove a node (cleans up worktree if applicable) |
632
642
  | \`mesh_cleanup_sessions\` | Manually clean up delegated session records for a node |
643
+ | \`mesh_prune_stale_direct\` | Prune orphaned staleDirect dispatch records (dry-run by default); live/pending work and audit history preserved |
633
644
  | \`mesh_init\` | Guided onboarding for a fresh repo: dry-run scan → suggest \`.adhdev/*\` configs (refine/bootstrap/change-impact) + providerPriority + current-config echo; gated write on approval |
634
645
  | \`mesh_reinit\` | Re-onboard an already-configured repo: re-suggest with overwrite semantics + current-vs-suggested diff; dry-run preview first, per-section approval before write |
635
646
  | \`mesh_write_mesh_json_config\` | Gated write of \`.adhdev/mesh.json\` (repo coordinator-prompt config) from the mesh entry — dry-run/overwrite like mesh_init |
647
+ | \`mesh_magi_review\` | Cross-verify a read-only investigation across a standing panel of independent mesh agents (different machines/providers) instead of a single worker |
648
+ | \`mesh_magi_collect\` | Collect + synthesize a previously dispatched MAGI fan-out by its consensus group id (async companion to mesh_magi_review wait:false) |
649
+ | \`mesh_magi_panel_set\` | Upsert a named MAGI panel (standing set of independent node×provider members) into machine-local config |
650
+ | \`mesh_magi_panel_list\` | List configured MAGI panels and resolve each member's availability against the current mesh (read-only) |
636
651
  | \`mesh_magi_kind_panel_set\` | Bind a task_kind → MAGI kind-panel slots (machine-local, wholesale replacement — approve current-vs-new first) |
637
652
  | \`mesh_magi_kind_panel_list\` | List configured task_kind → MAGI kind-panel slot bindings (machine-local, read-only) |`;
638
653