@adhdev/daemon-core 0.9.82-rc.415 → 0.9.82-rc.417

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.
@@ -126,6 +126,14 @@ export declare function updateNode(meshId: string, nodeId: string, opts: {
126
126
  reportedPlatform?: string;
127
127
  reportedArch?: string;
128
128
  }): LocalMeshNodeEntry | undefined;
129
+ /**
130
+ * Validate + normalize a panel config before persisting. Mirrors the node-config
131
+ * normalization style (mesh-config addNode/updateNode): trims strings, drops
132
+ * empties, requires a provider per member, clamps replica counts. Throws on
133
+ * structurally invalid input so the calling tool returns a clear error rather than
134
+ * writing a malformed panel.
135
+ */
136
+ export declare function normalizeMagiPanel(config: unknown): MagiPanel;
129
137
  /** All configured MAGI panels (machine-local), keyed by name. Empty when none. */
130
138
  export declare function listMagiPanels(): Record<string, MagiPanel>;
131
139
  /** A single panel by name, or undefined when not configured. */
package/dist/index.d.ts CHANGED
@@ -28,9 +28,9 @@ export { appendRecentActivity, getRecentActivity } from './config/recent-activit
28
28
  export type { RecentActivityEntry } from './config/recent-activity.js';
29
29
  export { getSavedProviderSessions, upsertSavedProviderSession } from './config/saved-sessions.js';
30
30
  export type { SavedProviderSessionEntry } from './config/saved-sessions.js';
31
- export { listMeshes, getMesh, getMeshByRepo, createMesh, updateMesh, deleteMesh, addNode, removeNode, updateNode, normalizeRepoIdentity, listMagiPanels, getMagiPanel, upsertMagiPanel, removeMagiPanel, } from './config/mesh-config.js';
31
+ export { listMeshes, getMesh, getMeshByRepo, createMesh, updateMesh, deleteMesh, addNode, removeNode, updateNode, normalizeRepoIdentity, listMagiPanels, getMagiPanel, upsertMagiPanel, removeMagiPanel, normalizeMagiPanel, } from './config/mesh-config.js';
32
32
  export type { CreateMeshOptions, UpdateMeshOptions, AddNodeOptions } from './config/mesh-config.js';
33
- export type { MagiPanel, MagiPanelMember, MagiPanelMap, MagiMode, MagiClaim, MagiClaimStance, MagiAgentResponse, MagiResponseSource, MagiSynthesizedResponse, MagiClusterCategory, MagiClusterMember, MagiClaimCluster, MagiSynthesis, } from '@adhdev/mesh-shared';
33
+ export type { MagiPanel, MagiPanelMember, MagiPanelMap, MagiMode, MagiClaim, MagiClaimStance, MagiAgentResponse, MagiResponseSource, MagiReplicaGitRef, MagiGitSkew, MagiSynthesizedResponse, MagiClusterCategory, MagiClusterMember, MagiClaimCluster, MagiSynthesis, } from '@adhdev/mesh-shared';
34
34
  export { expandDaemonIdForms, daemonIdsEquivalent, machineCoreFromDaemonId, canonicalDaemonId } from '@adhdev/mesh-shared';
35
35
  export { normalizeMeshNodeId, meshNodeIdMatches } from '@adhdev/mesh-shared';
36
36
  export { buildCoordinatorSystemPrompt } from './mesh/coordinator-prompt.js';
@@ -61,6 +61,8 @@ export type { StaleDirectPruneClassification, StaleDirectPruneResult, PruneStale
61
61
  export type { MeshActiveWorkRecord, MeshActiveWorkStatus, MeshActiveWorkSummary, MeshActiveWorkSource, MeshStaleDirectWorkSummary } from './mesh/mesh-active-work.js';
62
62
  export { buildMeshAsyncRefineJobs, summarizeMeshAsyncRefineJobs, STALE_TERMINAL_REFINE_WINDOW_MS, RECENT_TERMINAL_REFINE_CAP } from './mesh/mesh-refine-status.js';
63
63
  export type { MeshAsyncRefineJobStatus, MeshAsyncRefineJobSummary, MeshAsyncRefineJobsSummary } from './mesh/mesh-refine-status.js';
64
+ export { buildMeshMagiActivity, summarizeMeshMagiActivity, getMeshMagiActivityByGroup, STALE_MAGI_WINDOW_MS, RECENT_MAGI_CAP, MAGI_NEEDS_VERIFICATION_PREVIEW_CAP } from './mesh/mesh-magi-status.js';
65
+ export type { MeshMagiActivityStatus, MeshMagiActivitySummary, MeshMagiActivitySummaryFold, MeshMagiNeedsVerificationItem } from './mesh/mesh-magi-status.js';
64
66
  export { buildMeshSchedulingRuntime } from './mesh/mesh-scheduling-runtime.js';
65
67
  export type { MeshSchedulingRuntime, MeshNodeSchedulingRuntime, MeshNodeProviderSchedulingRuntime } from './mesh/mesh-scheduling-runtime.js';
66
68
  export { buildMeshHostRequiredFailure, createDefaultMeshHostMetadata, isMeshHostOwner, normalizeMeshDaemonRole, requireMeshHostQueueOwner, resolveMeshHostStatus } from './mesh/mesh-host-ownership.js';
package/dist/index.js CHANGED
@@ -389,10 +389,10 @@ function readInjected(value) {
389
389
  }
390
390
  function getDaemonBuildInfo() {
391
391
  if (cached) return cached;
392
- const commit = readInjected(true ? "eeb6bb4fcd32cf1844ed87bb4a7c2760e132e69d" : void 0) ?? "unknown";
393
- const commitShort = readInjected(true ? "eeb6bb4f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
394
- const version = readInjected(true ? "0.9.82-rc.415" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
395
- const builtAt = readInjected(true ? "2026-06-28T13:43:23.868Z" : void 0);
392
+ const commit = readInjected(true ? "aebe69a58bc80d5e1db908141ea4d03792bd0b5d" : void 0) ?? "unknown";
393
+ const commitShort = readInjected(true ? "aebe69a5" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
394
+ const version = readInjected(true ? "0.9.82-rc.417" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
395
+ const builtAt = readInjected(true ? "2026-06-28T16:29:44.906Z" : void 0);
396
396
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
397
397
  return cached;
398
398
  }
@@ -2568,6 +2568,7 @@ __export(mesh_config_exports, {
2568
2568
  listMagiPanels: () => listMagiPanels,
2569
2569
  listMeshes: () => listMeshes,
2570
2570
  markMeshHostPairingJoined: () => markMeshHostPairingJoined,
2571
+ normalizeMagiPanel: () => normalizeMagiPanel,
2571
2572
  normalizeRepoIdentity: () => normalizeRepoIdentity,
2572
2573
  removeMagiPanel: () => removeMagiPanel,
2573
2574
  removeNode: () => removeNode,
@@ -10275,7 +10276,7 @@ var init_mesh_scheduling_runtime = __esm({
10275
10276
  function readNonEmptyString2(value) {
10276
10277
  return typeof value === "string" && value.trim() ? value.trim() : "";
10277
10278
  }
10278
- function readRecord4(value) {
10279
+ function readRecord5(value) {
10279
10280
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
10280
10281
  }
10281
10282
  function buildMeshWorkerRelayStamp(currentSettings, meshContext) {
@@ -10303,17 +10304,17 @@ function resolveEventSessionId(event, fallback) {
10303
10304
  return readNonEmptyString2(event.targetSessionId) || readNonEmptyString2(event.sessionId) || readNonEmptyString2(event.instanceId) || readNonEmptyString2(fallback);
10304
10305
  }
10305
10306
  function readRefineJobId(event) {
10306
- const metadata = readRecord4(event.metadataEvent) || event;
10307
- const result = readRecord4(metadata.result);
10308
- const refineJob = readRecord4(result?.refineJob);
10307
+ const metadata = readRecord5(event.metadataEvent) || event;
10308
+ const result = readRecord5(metadata.result);
10309
+ const refineJob = readRecord5(result?.refineJob);
10309
10310
  return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
10310
10311
  }
10311
10312
  function readWorkerResultMetadata(event) {
10312
- return readRecord4(event.workerResult) || readRecord4(event.meshWorkerResult) || readRecord4(event.structuredResult);
10313
+ return readRecord5(event.workerResult) || readRecord5(event.meshWorkerResult) || readRecord5(event.structuredResult);
10313
10314
  }
10314
10315
  function readMeshCompletionSummary(metadataEvent) {
10315
10316
  const workerResult = readWorkerResultMetadata(metadataEvent);
10316
- const resultRecord = readRecord4(metadataEvent.result);
10317
+ const resultRecord = readRecord5(metadataEvent.result);
10317
10318
  return readNonEmptyString2(metadataEvent.finalSummary) || readNonEmptyString2(workerResult?.summary) || readNonEmptyString2(workerResult?.finalSummary) || readNonEmptyString2(resultRecord?.summary) || readNonEmptyString2(resultRecord?.finalSummary);
10318
10319
  }
10319
10320
  function truncateSurfacedPreview(text) {
@@ -10351,7 +10352,7 @@ function readEventTimestampValue(value) {
10351
10352
  return 0;
10352
10353
  }
10353
10354
  function isMissingFinalAssistantDiagnostic(record) {
10354
- const diag = readRecord4(record?.completionDiagnostic);
10355
+ const diag = readRecord5(record?.completionDiagnostic);
10355
10356
  return diag?.finalAssistantPresent === false || diag?.blockReason === "missing_final_assistant";
10356
10357
  }
10357
10358
  function isFalseIdleCompletion(record) {
@@ -10460,10 +10461,10 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
10460
10461
  }
10461
10462
  if (args.event === "refine:completed") {
10462
10463
  const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
10463
- const result = readRecord4(args.metadataEvent.result);
10464
- const validationSummary = readRecord4(result?.validationSummary);
10465
- const patchEquivalence = readRecord4(result?.patchEquivalence);
10466
- const finalConvergence = readRecord4(result?.finalBranchConvergenceState);
10464
+ const result = readRecord5(args.metadataEvent.result);
10465
+ const validationSummary = readRecord5(result?.validationSummary);
10466
+ const patchEquivalence = readRecord5(result?.patchEquivalence);
10467
+ const finalConvergence = readRecord5(result?.finalBranchConvergenceState);
10467
10468
  const validationStatus = readNonEmptyString2(validationSummary?.status);
10468
10469
  const patchStatus = readNonEmptyString2(patchEquivalence?.status) || (patchEquivalence?.equivalent === true ? "passed" : "");
10469
10470
  const into = readNonEmptyString2(result?.into);
@@ -10484,10 +10485,10 @@ Next step: ${nextStep}`;
10484
10485
  }
10485
10486
  if (args.event === "refine:failed") {
10486
10487
  const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
10487
- const result = readRecord4(args.metadataEvent.result);
10488
- const validationSummary = readRecord4(result?.validationSummary);
10489
- const patchEquivalence = readRecord4(result?.patchEquivalence);
10490
- const finalConvergence = readRecord4(result?.finalBranchConvergenceState);
10488
+ const result = readRecord5(args.metadataEvent.result);
10489
+ const validationSummary = readRecord5(result?.validationSummary);
10490
+ const patchEquivalence = readRecord5(result?.patchEquivalence);
10491
+ const finalConvergence = readRecord5(result?.finalBranchConvergenceState);
10491
10492
  const code = readNonEmptyString2(result?.code);
10492
10493
  const error = readNonEmptyString2(result?.error);
10493
10494
  const validationStatus = readNonEmptyString2(validationSummary?.status);
@@ -10527,9 +10528,9 @@ function normalizeCoordinatorDaemonIds(coordinatorDaemonId) {
10527
10528
  return expandDaemonIdForms(coordinatorDaemonId);
10528
10529
  }
10529
10530
  function readRefineJobId2(event) {
10530
- const metadata = readRecord4(event.metadataEvent) || event;
10531
- const result = readRecord4(metadata.result);
10532
- const refineJob = readRecord4(result?.refineJob);
10531
+ const metadata = readRecord5(event.metadataEvent) || event;
10532
+ const result = readRecord5(metadata.result);
10533
+ const refineJob = readRecord5(result?.refineJob);
10533
10534
  return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
10534
10535
  }
10535
10536
  function hasPendingRefineTerminalEventDuplicate(event) {
@@ -10541,12 +10542,12 @@ function hasPendingRefineTerminalEventDuplicate(event) {
10541
10542
  );
10542
10543
  }
10543
10544
  function buildPendingEventFingerprint(event) {
10544
- const metadata = readRecord4(event.metadataEvent) || {};
10545
+ const metadata = readRecord5(event.metadataEvent) || {};
10545
10546
  if (event.event === "worktree_bootstrap_complete" || event.event === "worktree_bootstrap_failed") {
10546
10547
  return [event.meshId, event.event, event.nodeId || ""].join("::");
10547
10548
  }
10548
10549
  if (TERMINAL_COMPLETION_EVENTS.has(event.event)) {
10549
- const terminalTaskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord4(metadata.payload)?.taskId);
10550
+ const terminalTaskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord5(metadata.payload)?.taskId);
10550
10551
  if (terminalTaskId) {
10551
10552
  return [
10552
10553
  event.meshId,
@@ -10556,14 +10557,14 @@ function buildPendingEventFingerprint(event) {
10556
10557
  ].join("::");
10557
10558
  }
10558
10559
  }
10559
- const consensusGroupId = readNonEmptyString2(metadata.consensusGroupId) || readNonEmptyString2(readRecord4(metadata.payload)?.consensusGroupId);
10560
+ const consensusGroupId = readNonEmptyString2(metadata.consensusGroupId) || readNonEmptyString2(readRecord5(metadata.payload)?.consensusGroupId);
10560
10561
  if (consensusGroupId) {
10561
- const groupTaskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord4(metadata.payload)?.taskId);
10562
+ const groupTaskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord5(metadata.payload)?.taskId);
10562
10563
  return [event.meshId, event.event, groupTaskId || "", consensusGroupId, "group"].join("::");
10563
10564
  }
10564
10565
  const sessionId = resolveEventSessionId(metadata);
10565
10566
  const providerSessionId = readNonEmptyString2(metadata.providerSessionId);
10566
- const taskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord4(metadata.payload)?.taskId);
10567
+ const taskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord5(metadata.payload)?.taskId);
10567
10568
  const jobId = readRefineJobId2(event);
10568
10569
  const timestamp = metadata.timestamp !== void 0 && metadata.timestamp !== null ? String(metadata.timestamp) : "";
10569
10570
  return [
@@ -10631,15 +10632,15 @@ function refineTerminalEventFromLedger(meshId, pending) {
10631
10632
  for (let i = entries.length - 1; i >= 0; i--) {
10632
10633
  const entry = entries[i];
10633
10634
  if (entry.kind !== "task_completed" && entry.kind !== "task_failed") continue;
10634
- const payload = readRecord4(entry.payload);
10635
+ const payload = readRecord5(entry.payload);
10635
10636
  if (payload?.source !== "refine_mesh_node_async_job") continue;
10636
- const refineJob = readRecord4(payload.refineJob);
10637
+ const refineJob = readRecord5(payload.refineJob);
10637
10638
  const jobId = readNonEmptyString2(refineJob?.jobId);
10638
10639
  if (!jobId || !acceptedJobIds.has(jobId)) continue;
10639
10640
  const eventName = entry.kind === "task_completed" ? "refine:completed" : "refine:failed";
10640
10641
  if (existingTerminalJobIds.has(`${eventName}:${jobId}`)) continue;
10641
10642
  existingTerminalJobIds.add(`${eventName}:${jobId}`);
10642
- const result = readRecord4(payload.result);
10643
+ const result = readRecord5(payload.result);
10643
10644
  const metadataEvent = {
10644
10645
  source: "refine_mesh_node_async_job",
10645
10646
  jobId,
@@ -11147,7 +11148,7 @@ function buildNoProgressCompletionReconciliation(args) {
11147
11148
  const providerType = readNonEmptyString2(args.metadataEvent.providerType);
11148
11149
  const providerSessionId = readNonEmptyString2(args.metadataEvent.providerSessionId);
11149
11150
  const workerResult = readWorkerResultMetadata(args.metadataEvent);
11150
- const completionDiagnostic = readRecord4(args.metadataEvent.completionDiagnostic);
11151
+ const completionDiagnostic = readRecord5(args.metadataEvent.completionDiagnostic);
11151
11152
  const finalSummary = readNonEmptyString2(args.metadataEvent.finalSummary);
11152
11153
  const status = readNonEmptyString2(args.metadataEvent.status).toLowerCase();
11153
11154
  const explicitCompletionEvidence = Boolean(
@@ -23159,6 +23160,7 @@ __export(index_exports, {
23159
23160
  IdeProviderInstance: () => IdeProviderInstance,
23160
23161
  InMemoryGitSnapshotStore: () => InMemoryGitSnapshotStore,
23161
23162
  LOG: () => LOG,
23163
+ MAGI_NEEDS_VERIFICATION_PREVIEW_CAP: () => MAGI_NEEDS_VERIFICATION_PREVIEW_CAP,
23162
23164
  MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
23163
23165
  MESH_CONVERGE_FAST_FORWARD_TAG: () => MESH_CONVERGE_FAST_FORWARD_TAG,
23164
23166
  MESH_CONVERGE_REFINE_TAG: () => MESH_CONVERGE_REFINE_TAG,
@@ -23180,8 +23182,10 @@ __export(index_exports, {
23180
23182
  ProviderCliAdapter: () => ProviderCliAdapter,
23181
23183
  ProviderInstanceManager: () => ProviderInstanceManager,
23182
23184
  ProviderLoader: () => ProviderLoader,
23185
+ RECENT_MAGI_CAP: () => RECENT_MAGI_CAP,
23183
23186
  RECENT_TERMINAL_REFINE_CAP: () => RECENT_TERMINAL_REFINE_CAP,
23184
23187
  RawTerminalAttachment: () => RawTerminalAttachment,
23188
+ STALE_MAGI_WINDOW_MS: () => STALE_MAGI_WINDOW_MS,
23185
23189
  STALE_TERMINAL_REFINE_WINDOW_MS: () => STALE_TERMINAL_REFINE_WINDOW_MS,
23186
23190
  STANDALONE_CDP_SCAN_INTERVAL_MS: () => STANDALONE_CDP_SCAN_INTERVAL_MS,
23187
23191
  SessionHostPtyTransportFactory: () => SessionHostPtyTransportFactory,
@@ -23211,6 +23215,7 @@ __export(index_exports, {
23211
23215
  buildMeshHostRequiredFailure: () => buildMeshHostRequiredFailure,
23212
23216
  buildMeshLedgerReconciliationEvidence: () => buildMeshLedgerReconciliationEvidence,
23213
23217
  buildMeshLedgerReplicaEvidence: () => buildMeshLedgerReplicaEvidence,
23218
+ buildMeshMagiActivity: () => buildMeshMagiActivity,
23214
23219
  buildMeshNodeCapabilityTags: () => buildMeshNodeCapabilityTags,
23215
23220
  buildMeshNodeDataFreshness: () => buildMeshNodeDataFreshness,
23216
23221
  buildMeshNodeProbeFreshness: () => buildMeshNodeProbeFreshness,
@@ -23300,6 +23305,7 @@ __export(index_exports, {
23300
23305
  getMagiPanel: () => getMagiPanel,
23301
23306
  getMesh: () => getMesh,
23302
23307
  getMeshByRepo: () => getMeshByRepo,
23308
+ getMeshMagiActivityByGroup: () => getMeshMagiActivityByGroup,
23303
23309
  getMeshMission: () => getMeshMission,
23304
23310
  getMeshMissions: () => getMeshMissions,
23305
23311
  getMeshQueueRevision: () => getMeshQueueRevision,
@@ -23384,6 +23390,7 @@ __export(index_exports, {
23384
23390
  normalizeInputEnvelope: () => normalizeInputEnvelope,
23385
23391
  normalizeInteractivePrompt: () => normalizeInteractivePrompt,
23386
23392
  normalizeInteractivePromptResponse: () => normalizeInteractivePromptResponse,
23393
+ normalizeMagiPanel: () => normalizeMagiPanel,
23387
23394
  normalizeManagedStatus: () => normalizeManagedStatus,
23388
23395
  normalizeMeshCapabilityTags: () => normalizeMeshCapabilityTags,
23389
23396
  normalizeMeshDaemonRole: () => normalizeMeshDaemonRole,
@@ -23465,6 +23472,7 @@ __export(index_exports, {
23465
23472
  suggestMeshRefineConfig: () => suggestMeshRefineConfig,
23466
23473
  summarizeGitStatus: () => summarizeGitStatus,
23467
23474
  summarizeMeshAsyncRefineJobs: () => summarizeMeshAsyncRefineJobs,
23475
+ summarizeMeshMagiActivity: () => summarizeMeshMagiActivity,
23468
23476
  summarizeMeshMission: () => summarizeMeshMission,
23469
23477
  summarizeMissionTasks: () => summarizeMissionTasks,
23470
23478
  triggerMeshQueue: () => triggerMeshQueue,
@@ -24826,6 +24834,124 @@ function buildMeshLedgerReconciliationEvidence(meshId, replicas) {
24826
24834
  init_mesh_work_queue();
24827
24835
  init_mesh_active_work();
24828
24836
  init_mesh_refine_status();
24837
+
24838
+ // src/mesh/mesh-magi-status.ts
24839
+ function readString7(value) {
24840
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
24841
+ }
24842
+ function readRecord4(value) {
24843
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
24844
+ }
24845
+ function readNumber2(value) {
24846
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
24847
+ }
24848
+ var MAGI_NEEDS_VERIFICATION_PREVIEW_CAP = 8;
24849
+ function summarizeNeedsVerification(synthesis) {
24850
+ const list = Array.isArray(synthesis?.needsVerification) ? synthesis.needsVerification : void 0;
24851
+ if (!list) return void 0;
24852
+ const items = [];
24853
+ for (const raw of list.slice(0, MAGI_NEEDS_VERIFICATION_PREVIEW_CAP)) {
24854
+ const r = readRecord4(raw);
24855
+ const claim = readString7(r?.claim);
24856
+ if (!claim) continue;
24857
+ items.push({ claim, category: readString7(r?.category) || "needs_verification" });
24858
+ }
24859
+ return items;
24860
+ }
24861
+ function mergeGroup(groups, patch) {
24862
+ const consensusGroupId = readString7(patch.consensusGroupId);
24863
+ if (!consensusGroupId) return;
24864
+ const previous = groups.get(consensusGroupId);
24865
+ const status = patch.status === "synthesized" || previous?.status === "synthesized" ? "synthesized" : "running";
24866
+ const definedPatch = Object.fromEntries(
24867
+ Object.entries(patch).filter(([, v]) => v !== void 0)
24868
+ );
24869
+ groups.set(consensusGroupId, { ...previous, ...definedPatch, consensusGroupId, status });
24870
+ }
24871
+ function buildMeshMagiActivity(args) {
24872
+ const groups = /* @__PURE__ */ new Map();
24873
+ for (const entry of args.ledgerEntries || []) {
24874
+ const payload = readRecord4(entry.payload);
24875
+ if (payload?.source !== "magi") continue;
24876
+ const consensusGroupId = readString7(payload.consensusGroupId);
24877
+ if (!consensusGroupId) continue;
24878
+ if (entry.kind === "magi_synthesis") {
24879
+ const synthesis = readRecord4(payload.synthesis);
24880
+ mergeGroup(groups, {
24881
+ consensusGroupId,
24882
+ status: "synthesized",
24883
+ missionId: readString7(payload.missionId),
24884
+ panel: readString7(payload.panel),
24885
+ question: readString7(payload.question),
24886
+ replicaCount: readNumber2(synthesis?.replicasExpected) ?? readNumber2(payload.replicaCount),
24887
+ answered: readNumber2(synthesis?.replicasAnswered),
24888
+ missing: readNumber2(synthesis?.replicasMissing),
24889
+ staleReplicas: readNumber2(payload.staleReplicas) ?? readNumber2(synthesis?.staleReplicas),
24890
+ needsVerificationCount: Array.isArray(synthesis?.needsVerification) ? synthesis.needsVerification.length : void 0,
24891
+ agreedCount: Array.isArray(synthesis?.agreed) ? synthesis.agreed.length : void 0,
24892
+ independenceBanner: synthesis && "independenceBanner" in synthesis ? synthesis.independenceBanner : void 0,
24893
+ gitSkew: readRecord4(synthesis?.gitSkew),
24894
+ needsVerification: summarizeNeedsVerification(synthesis),
24895
+ openQuestions: Array.isArray(synthesis?.openQuestions) ? synthesis.openQuestions.slice(0, 10) : void 0,
24896
+ lastLedgerKind: entry.kind,
24897
+ lastUpdatedAt: entry.timestamp
24898
+ });
24899
+ } else if (entry.kind === "magi_dispatched") {
24900
+ mergeGroup(groups, {
24901
+ consensusGroupId,
24902
+ status: "running",
24903
+ missionId: readString7(payload.missionId),
24904
+ panel: readString7(payload.panel),
24905
+ question: readString7(payload.question),
24906
+ replicaCount: readNumber2(payload.replicaCount),
24907
+ lastLedgerKind: entry.kind,
24908
+ lastUpdatedAt: entry.timestamp
24909
+ });
24910
+ }
24911
+ }
24912
+ return Array.from(groups.values()).sort((a, b) => {
24913
+ const at = new Date(a.lastUpdatedAt || "").getTime();
24914
+ const bt = new Date(b.lastUpdatedAt || "").getTime();
24915
+ return (Number.isFinite(bt) ? bt : 0) - (Number.isFinite(at) ? at : 0);
24916
+ });
24917
+ }
24918
+ var STALE_MAGI_WINDOW_MS = 6 * 60 * 60 * 1e3;
24919
+ var RECENT_MAGI_CAP = 6;
24920
+ function activityTime(g) {
24921
+ const t = new Date(g.lastUpdatedAt || "").getTime();
24922
+ return Number.isFinite(t) ? t : 0;
24923
+ }
24924
+ function summarizeMeshMagiActivity(activity) {
24925
+ const running = [];
24926
+ const synthesized = [];
24927
+ for (const g of activity) {
24928
+ if (g.status === "synthesized") synthesized.push(g);
24929
+ else running.push(g);
24930
+ }
24931
+ let newest = 0;
24932
+ for (const g of activity) newest = Math.max(newest, activityTime(g));
24933
+ const cutoff = newest - STALE_MAGI_WINDOW_MS;
24934
+ const synthesizedByRecency = [...synthesized].sort((a, b) => activityTime(b) - activityTime(a));
24935
+ const freshSynthesized = synthesizedByRecency.filter((g) => activityTime(g) >= cutoff).slice(0, RECENT_MAGI_CAP);
24936
+ const byStatus = {};
24937
+ for (const g of [...running, ...freshSynthesized]) {
24938
+ byStatus[g.status] = (byStatus[g.status] ?? 0) + 1;
24939
+ }
24940
+ const runningByRecency = [...running].sort((a, b) => activityTime(b) - activityTime(a));
24941
+ return {
24942
+ total: running.length + freshSynthesized.length,
24943
+ byStatus,
24944
+ staleSynthesized: synthesized.length - freshSynthesized.length,
24945
+ groups: [...runningByRecency, ...freshSynthesized]
24946
+ };
24947
+ }
24948
+ function getMeshMagiActivityByGroup(ledgerEntries, consensusGroupId) {
24949
+ const key2 = readString7(consensusGroupId);
24950
+ if (!key2) return void 0;
24951
+ return buildMeshMagiActivity({ ledgerEntries }).find((g) => g.consensusGroupId === key2);
24952
+ }
24953
+
24954
+ // src/index.ts
24829
24955
  init_mesh_scheduling_runtime();
24830
24956
  init_mesh_host_ownership();
24831
24957
  init_mesh_events();
@@ -37998,10 +38124,15 @@ var FsmDriver = class {
37998
38124
  this.win32SubmitTimer = null;
37999
38125
  }
38000
38126
  const startedAt = Date.now();
38001
- const probe = normalizeForEcho(body).slice(-WIN32_ECHO_PROBE_CHARS);
38127
+ const normBody = normalizeForEcho(body);
38128
+ const headProbe = normBody.slice(0, WIN32_ECHO_PROBE_CHARS);
38129
+ const tailProbe = normBody.slice(-WIN32_ECHO_PROBE_CHARS);
38002
38130
  const bodyEchoed = () => {
38003
- if (!probe) return true;
38004
- return normalizeForEcho(this.adapter.snapshot()).includes(probe);
38131
+ if (!normBody) return true;
38132
+ const visible = normalizeForEcho(this.adapter.snapshot());
38133
+ if (!visible.includes(tailProbe)) return false;
38134
+ const full = normalizeForEcho(this.adapter.snapshotWithScrollback());
38135
+ return full.includes(headProbe);
38005
38136
  };
38006
38137
  const fire = (attempt) => {
38007
38138
  this.win32SubmitTimer = null;
@@ -50733,7 +50864,7 @@ function runGit2(repoRoot, args) {
50733
50864
  return "";
50734
50865
  }
50735
50866
  }
50736
- function readRecord5(repoRoot) {
50867
+ function readRecord6(repoRoot) {
50737
50868
  const path43 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
50738
50869
  if (!(0, import_node_fs4.existsSync)(path43)) return null;
50739
50870
  try {
@@ -50773,7 +50904,7 @@ function readCurrentMainCommit(repoRoot) {
50773
50904
  }
50774
50905
  function buildPreviewFreshness(repoRoot) {
50775
50906
  const current = readCurrentMainCommit(repoRoot);
50776
- const record = readRecord5(repoRoot);
50907
+ const record = readRecord6(repoRoot);
50777
50908
  const lastPreviewCommit = normalizeCommit(record?.lastPreviewCommit);
50778
50909
  const targets = readTargetFreshness(record, current.currentMainCommit);
50779
50910
  let status = "unknown";
@@ -64628,6 +64759,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
64628
64759
  IdeProviderInstance,
64629
64760
  InMemoryGitSnapshotStore,
64630
64761
  LOG,
64762
+ MAGI_NEEDS_VERIFICATION_PREVIEW_CAP,
64631
64763
  MAX_LEDGER_SLICE_LIMIT,
64632
64764
  MESH_CONVERGE_FAST_FORWARD_TAG,
64633
64765
  MESH_CONVERGE_REFINE_TAG,
@@ -64649,8 +64781,10 @@ var V1_CONTRACT_VERSION = "1.0.0";
64649
64781
  ProviderCliAdapter,
64650
64782
  ProviderInstanceManager,
64651
64783
  ProviderLoader,
64784
+ RECENT_MAGI_CAP,
64652
64785
  RECENT_TERMINAL_REFINE_CAP,
64653
64786
  RawTerminalAttachment,
64787
+ STALE_MAGI_WINDOW_MS,
64654
64788
  STALE_TERMINAL_REFINE_WINDOW_MS,
64655
64789
  STANDALONE_CDP_SCAN_INTERVAL_MS,
64656
64790
  SessionHostPtyTransportFactory,
@@ -64680,6 +64814,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
64680
64814
  buildMeshHostRequiredFailure,
64681
64815
  buildMeshLedgerReconciliationEvidence,
64682
64816
  buildMeshLedgerReplicaEvidence,
64817
+ buildMeshMagiActivity,
64683
64818
  buildMeshNodeCapabilityTags,
64684
64819
  buildMeshNodeDataFreshness,
64685
64820
  buildMeshNodeProbeFreshness,
@@ -64769,6 +64904,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
64769
64904
  getMagiPanel,
64770
64905
  getMesh,
64771
64906
  getMeshByRepo,
64907
+ getMeshMagiActivityByGroup,
64772
64908
  getMeshMission,
64773
64909
  getMeshMissions,
64774
64910
  getMeshQueueRevision,
@@ -64853,6 +64989,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
64853
64989
  normalizeInputEnvelope,
64854
64990
  normalizeInteractivePrompt,
64855
64991
  normalizeInteractivePromptResponse,
64992
+ normalizeMagiPanel,
64856
64993
  normalizeManagedStatus,
64857
64994
  normalizeMeshCapabilityTags,
64858
64995
  normalizeMeshDaemonRole,
@@ -64934,6 +65071,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
64934
65071
  suggestMeshRefineConfig,
64935
65072
  summarizeGitStatus,
64936
65073
  summarizeMeshAsyncRefineJobs,
65074
+ summarizeMeshMagiActivity,
64937
65075
  summarizeMeshMission,
64938
65076
  summarizeMissionTasks,
64939
65077
  triggerMeshQueue,