@adhdev/daemon-core 0.9.82-rc.78 → 0.9.82-rc.79
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/index.js +74 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -39
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-events.d.ts +1 -0
- package/package.json +1 -1
- package/src/commands/router.ts +44 -28
- package/src/mesh/mesh-events.ts +40 -11
|
@@ -6,6 +6,7 @@ export interface PendingMeshCoordinatorEvent {
|
|
|
6
6
|
nodeId?: string;
|
|
7
7
|
workspace?: string;
|
|
8
8
|
metadataEvent: Record<string, unknown>;
|
|
9
|
+
coordinatorMessage?: string;
|
|
9
10
|
queuedAt: number;
|
|
10
11
|
}
|
|
11
12
|
export declare function queuePendingMeshCoordinatorEvent(event: PendingMeshCoordinatorEvent): boolean;
|
package/package.json
CHANGED
package/src/commands/router.ts
CHANGED
|
@@ -55,7 +55,7 @@ import { getSessionCompletionMarker } from '../status/snapshot.js';
|
|
|
55
55
|
import { execNpmCommandSync, resolveCurrentGlobalInstallSurface, spawnDetachedDaemonUpgradeHelper } from './upgrade-helper.js';
|
|
56
56
|
import { getMeshQueueRevision } from '../mesh/mesh-work-queue.js';
|
|
57
57
|
import type { RepoMeshSessionCleanupMode } from '../repo-mesh-types.js';
|
|
58
|
-
import { homedir
|
|
58
|
+
import { homedir } from 'os';
|
|
59
59
|
import { basename as pathBasename, join as pathJoin, resolve as pathResolve } from 'path';
|
|
60
60
|
import * as fs from 'fs';
|
|
61
61
|
|
|
@@ -1281,16 +1281,9 @@ async function runMeshRefineSubmoduleReachabilityGate(
|
|
|
1281
1281
|
});
|
|
1282
1282
|
return String(stdout || '');
|
|
1283
1283
|
};
|
|
1284
|
-
const verifyRemoteMainContainsCommit = async (
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
await runGit(probeDir, ['init', '-q']);
|
|
1288
|
-
await runGit(probeDir, ['-c', 'protocol.file.allow=always', 'fetch', '--depth=1', remoteUrl, `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
|
|
1289
|
-
await runGit(probeDir, ['cat-file', '-e', `${commit}^{commit}`]);
|
|
1290
|
-
await runGit(probeDir, ['merge-base', '--is-ancestor', commit, `refs/remotes/origin/${branch}`]);
|
|
1291
|
-
} finally {
|
|
1292
|
-
fs.rmSync(probeDir, { recursive: true, force: true });
|
|
1293
|
-
}
|
|
1284
|
+
const verifyRemoteMainContainsCommit = async (submodulePath: string, commit: string, branch = 'main'): Promise<void> => {
|
|
1285
|
+
await runGit(submodulePath, ['-c', 'protocol.file.allow=always', 'fetch', 'origin', `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
|
|
1286
|
+
await runGit(submodulePath, ['merge-base', '--is-ancestor', commit, `refs/remotes/origin/${branch}`]);
|
|
1294
1287
|
};
|
|
1295
1288
|
|
|
1296
1289
|
const treeOutput = await runGit(repoRoot, ['ls-tree', '-r', '-z', mergedTree]);
|
|
@@ -1341,7 +1334,7 @@ async function runMeshRefineSubmoduleReachabilityGate(
|
|
|
1341
1334
|
continue;
|
|
1342
1335
|
}
|
|
1343
1336
|
entry.remoteMainBranch = 'main';
|
|
1344
|
-
await verifyRemoteMainContainsCommit(
|
|
1337
|
+
await verifyRemoteMainContainsCommit(submodulePath, gitlink.commit, 'main');
|
|
1345
1338
|
entry.fetchedFromOrigin = true;
|
|
1346
1339
|
entry.remoteReachable = true;
|
|
1347
1340
|
entry.remoteMainReachable = true;
|
|
@@ -2558,28 +2551,51 @@ export class DaemonCommandRouter {
|
|
|
2558
2551
|
}
|
|
2559
2552
|
|
|
2560
2553
|
private queueRefineJobEvent(event: 'refine:accepted' | 'refine:completed' | 'refine:failed', handle: MeshRefineJobHandle, result?: Record<string, unknown>): void {
|
|
2561
|
-
|
|
2554
|
+
const metadataEvent = {
|
|
2555
|
+
source: 'refine_mesh_node_async_job',
|
|
2556
|
+
jobId: handle.jobId,
|
|
2557
|
+
interactionId: handle.interactionId,
|
|
2558
|
+
meshId: handle.meshId,
|
|
2559
|
+
nodeId: handle.targetNodeId,
|
|
2560
|
+
targetDaemonId: handle.targetDaemonId,
|
|
2561
|
+
workspace: handle.workspace,
|
|
2562
|
+
status: handle.status,
|
|
2563
|
+
startedAt: handle.startedAt,
|
|
2564
|
+
completedAt: handle.completedAt,
|
|
2565
|
+
retryOfJobId: handle.retryOfJobId,
|
|
2566
|
+
...(result ? { result } : {}),
|
|
2567
|
+
};
|
|
2568
|
+
const eventPayload = {
|
|
2562
2569
|
event,
|
|
2563
2570
|
meshId: handle.meshId,
|
|
2564
2571
|
nodeLabel: handle.targetNodeId,
|
|
2565
2572
|
nodeId: handle.targetNodeId,
|
|
2566
2573
|
workspace: handle.workspace,
|
|
2567
|
-
metadataEvent
|
|
2568
|
-
source: 'refine_mesh_node_async_job',
|
|
2569
|
-
jobId: handle.jobId,
|
|
2570
|
-
interactionId: handle.interactionId,
|
|
2571
|
-
meshId: handle.meshId,
|
|
2572
|
-
nodeId: handle.targetNodeId,
|
|
2573
|
-
targetDaemonId: handle.targetDaemonId,
|
|
2574
|
-
workspace: handle.workspace,
|
|
2575
|
-
status: handle.status,
|
|
2576
|
-
startedAt: handle.startedAt,
|
|
2577
|
-
completedAt: handle.completedAt,
|
|
2578
|
-
retryOfJobId: handle.retryOfJobId,
|
|
2579
|
-
...(result ? { result } : {}),
|
|
2580
|
-
},
|
|
2574
|
+
metadataEvent,
|
|
2581
2575
|
queuedAt: Date.now(),
|
|
2582
|
-
}
|
|
2576
|
+
};
|
|
2577
|
+
if (typeof this.deps.instanceManager?.getByCategory === 'function') {
|
|
2578
|
+
const forwarded = handleMeshForwardEvent(
|
|
2579
|
+
{ instanceManager: this.deps.instanceManager } as any,
|
|
2580
|
+
{
|
|
2581
|
+
event,
|
|
2582
|
+
meshId: handle.meshId,
|
|
2583
|
+
nodeId: handle.targetNodeId,
|
|
2584
|
+
workspace: handle.workspace,
|
|
2585
|
+
jobId: handle.jobId,
|
|
2586
|
+
interactionId: handle.interactionId,
|
|
2587
|
+
status: handle.status,
|
|
2588
|
+
targetDaemonId: handle.targetDaemonId,
|
|
2589
|
+
startedAt: handle.startedAt,
|
|
2590
|
+
completedAt: handle.completedAt,
|
|
2591
|
+
retryOfJobId: handle.retryOfJobId,
|
|
2592
|
+
...(result ? { result } : {}),
|
|
2593
|
+
},
|
|
2594
|
+
);
|
|
2595
|
+
if (forwarded?.success === true) return;
|
|
2596
|
+
LOG.warn('Mesh', `[Refinery] Failed to forward async refine event ${event}: ${forwarded?.error || 'unknown error'}`);
|
|
2597
|
+
}
|
|
2598
|
+
queuePendingMeshCoordinatorEvent(eventPayload);
|
|
2583
2599
|
}
|
|
2584
2600
|
|
|
2585
2601
|
private async appendRefineJobLedger(kind: 'task_dispatched' | 'task_completed' | 'task_failed', handle: MeshRefineJobHandle, result?: Record<string, unknown>): Promise<void> {
|
package/src/mesh/mesh-events.ts
CHANGED
|
@@ -55,6 +55,7 @@ export interface PendingMeshCoordinatorEvent {
|
|
|
55
55
|
nodeId?: string;
|
|
56
56
|
workspace?: string;
|
|
57
57
|
metadataEvent: Record<string, unknown>;
|
|
58
|
+
coordinatorMessage?: string;
|
|
58
59
|
queuedAt: number;
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -750,27 +751,54 @@ function buildMeshSystemMessage(args: {
|
|
|
750
751
|
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
751
752
|
const result = readRecord(args.metadataEvent.result);
|
|
752
753
|
const validationSummary = readRecord(result?.validationSummary);
|
|
754
|
+
const patchEquivalence = readRecord(result?.patchEquivalence);
|
|
755
|
+
const finalConvergence = readRecord(result?.finalBranchConvergenceState);
|
|
753
756
|
const validationStatus = readNonEmptyString(validationSummary?.status);
|
|
757
|
+
const patchStatus = readNonEmptyString(patchEquivalence?.status)
|
|
758
|
+
|| (patchEquivalence?.equivalent === true ? 'passed' : '');
|
|
754
759
|
const into = readNonEmptyString(result?.into);
|
|
755
760
|
const branch = readNonEmptyString(result?.branch);
|
|
761
|
+
const mergeStatus = result?.merged === true ? 'merged' : readNonEmptyString(finalConvergence?.status);
|
|
762
|
+
const convergenceStatus = readNonEmptyString(finalConvergence?.status);
|
|
763
|
+
const nextStep = readNonEmptyString(result?.nextStep)
|
|
764
|
+
|| readNonEmptyString(finalConvergence?.nextStep)
|
|
765
|
+
|| 'Continue from the updated mesh state.';
|
|
756
766
|
const details = [
|
|
757
767
|
jobId ? `job_id=${jobId}` : '',
|
|
758
768
|
branch && into ? `${branch}→${into}` : '',
|
|
759
769
|
validationStatus ? `validation=${validationStatus}` : '',
|
|
770
|
+
patchStatus ? `patch_equivalence=${patchStatus}` : '',
|
|
771
|
+
mergeStatus ? `merge=${mergeStatus}` : '',
|
|
772
|
+
convergenceStatus ? `final_convergence=${convergenceStatus}` : '',
|
|
760
773
|
].filter(Boolean).join('; ');
|
|
761
|
-
return `[System] Refinery async job for ${args.nodeLabel} completed successfully${details ? ` (${details})` : ''}
|
|
774
|
+
return `[System] Refinery async job for ${args.nodeLabel} completed successfully${details ? ` (${details})` : ''}.\nNext step: ${nextStep}`;
|
|
762
775
|
}
|
|
763
776
|
if (args.event === 'refine:failed') {
|
|
764
777
|
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
765
778
|
const result = readRecord(args.metadataEvent.result);
|
|
779
|
+
const validationSummary = readRecord(result?.validationSummary);
|
|
780
|
+
const patchEquivalence = readRecord(result?.patchEquivalence);
|
|
781
|
+
const finalConvergence = readRecord(result?.finalBranchConvergenceState);
|
|
766
782
|
const code = readNonEmptyString(result?.code);
|
|
767
783
|
const error = readNonEmptyString(result?.error);
|
|
768
|
-
const
|
|
784
|
+
const validationStatus = readNonEmptyString(validationSummary?.status);
|
|
785
|
+
const patchStatus = readNonEmptyString(patchEquivalence?.status)
|
|
786
|
+
|| (patchEquivalence?.equivalent === true ? 'passed' : '');
|
|
787
|
+
const mergeStatus = result?.merged === true
|
|
788
|
+
? 'merged'
|
|
789
|
+
: finalConvergence?.merged === false
|
|
790
|
+
? 'not_merged'
|
|
791
|
+
: '';
|
|
792
|
+
const convergenceStatus = readNonEmptyString(result?.convergenceStatus)
|
|
793
|
+
|| readNonEmptyString(finalConvergence?.status);
|
|
769
794
|
const blockedReason = readNonEmptyString(result?.blockedReason);
|
|
770
|
-
const nextStep = readNonEmptyString(result?.nextStep) || readNonEmptyString(
|
|
795
|
+
const nextStep = readNonEmptyString(result?.nextStep) || readNonEmptyString(finalConvergence?.nextStep);
|
|
771
796
|
const details = [
|
|
772
797
|
jobId ? `job_id=${jobId}` : '',
|
|
773
798
|
code ? `code=${code}` : '',
|
|
799
|
+
validationStatus ? `validation=${validationStatus}` : '',
|
|
800
|
+
patchStatus ? `patch_equivalence=${patchStatus}` : '',
|
|
801
|
+
mergeStatus ? `merge=${mergeStatus}` : '',
|
|
774
802
|
convergenceStatus ? `convergence=${convergenceStatus}` : '',
|
|
775
803
|
blockedReason ? `reason=${blockedReason}` : '',
|
|
776
804
|
].filter(Boolean).join('; ');
|
|
@@ -1028,6 +1056,14 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
1028
1056
|
}
|
|
1029
1057
|
}
|
|
1030
1058
|
|
|
1059
|
+
const messageText = buildMeshSystemMessage({
|
|
1060
|
+
event: args.event,
|
|
1061
|
+
nodeLabel: args.nodeLabel,
|
|
1062
|
+
metadataEvent: args.metadataEvent,
|
|
1063
|
+
recoveryContext,
|
|
1064
|
+
});
|
|
1065
|
+
if (!messageText) return { success: false, error: 'unsupported mesh event' };
|
|
1066
|
+
|
|
1031
1067
|
const coordinatorInstances = components.instanceManager.getByCategory('cli').filter((inst) => {
|
|
1032
1068
|
const instState = inst.getState();
|
|
1033
1069
|
if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
|
|
@@ -1047,6 +1083,7 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
1047
1083
|
...args.metadataEvent,
|
|
1048
1084
|
...(recoveryContext ? { recoveryContext } : {}),
|
|
1049
1085
|
},
|
|
1086
|
+
coordinatorMessage: messageText,
|
|
1050
1087
|
queuedAt: Date.now(),
|
|
1051
1088
|
})) {
|
|
1052
1089
|
LOG.info('MeshEvents', `Queued ${args.event} for MCP coordinator (mesh ${args.meshId})`);
|
|
@@ -1054,14 +1091,6 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
1054
1091
|
return { success: true, forwarded: 0 };
|
|
1055
1092
|
}
|
|
1056
1093
|
|
|
1057
|
-
const messageText = buildMeshSystemMessage({
|
|
1058
|
-
event: args.event,
|
|
1059
|
-
nodeLabel: args.nodeLabel,
|
|
1060
|
-
metadataEvent: args.metadataEvent,
|
|
1061
|
-
recoveryContext,
|
|
1062
|
-
});
|
|
1063
|
-
if (!messageText) return { success: false, error: 'unsupported mesh event' };
|
|
1064
|
-
|
|
1065
1094
|
for (const coord of coordinatorInstances) {
|
|
1066
1095
|
const coordState = coord.getState();
|
|
1067
1096
|
LOG.info('MeshEvents', `Forwarding mesh event to coordinator ${coordState.instanceId}`);
|