@adhdev/daemon-core 0.9.82-rc.428 → 0.9.82-rc.429

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.
@@ -92,7 +92,8 @@ export interface MedFamilyContext {
92
92
  mode: RepoMeshSessionCleanupMode;
93
93
  sessionIds?: string[];
94
94
  dryRun?: boolean;
95
- source?: 'mesh_cleanup_sessions' | 'mesh_remove_node';
95
+ source?: 'mesh_cleanup_sessions' | 'mesh_remove_node' | 'magi_session_cleanup';
96
+ requireAutoLaunchedForTaskIds?: Record<string, string>;
96
97
  }) => Promise<{
97
98
  success: boolean;
98
99
  [key: string]: unknown;
package/dist/index.d.ts CHANGED
@@ -7,8 +7,8 @@ export type { ChatBubbleState, ChatMessage, ExtensionInfo, CommandResult as Core
7
7
  export type { SessionEntry, CompactSessionEntry, CompactDaemonEntry, CloudDaemonSummaryEntry, DashboardBootstrapDaemonEntry, VersionUpdateReason, CloudStatusReportPayload, DaemonStatusEventPayload, DashboardStatusEventPayload, SessionTransport, SessionKind, SessionCapability, AgentSessionStream, ReadChatCursor, ReadChatSyncResult, TransportTopic, SessionChatTailSubscriptionParams, SessionRuntimeOutputSubscriptionParams, MachineRuntimeSubscriptionParams, SessionHostDiagnosticsSubscriptionParams, SessionModalSubscriptionParams, DaemonMetadataSubscriptionParams, WorkspaceGitSubscriptionParams, SessionChatTailUpdate, MachineRuntimeUpdate, SessionHostDiagnosticsUpdate, SessionModalUpdate, DaemonMetadataUpdate, TopicUpdateEnvelope, SubscribeRequest, UnsubscribeRequest, StandaloneWsStatusPayload, AvailableProviderInfo, AcpConfigOption, AcpMode, ProviderControlSchema, StatusReportPayload, MachineInfo, SessionHostDiagnosticsSnapshot, SessionHostRecord, SessionHostWriteOwner, SessionHostAttachedClient, SessionHostLogEntry, SessionHostRequestTrace, SessionHostRuntimeTransition, DetectedIdeInfo, WorkspaceEntry, ProviderSummaryItem, ProviderSummaryMetadata, ProviderState, ProviderStatus, ProviderErrorReason, SessionActiveChatData, ActiveChatData, IdeProviderState, CliProviderState, AcpProviderState, ExtensionProviderState, MessageInputSupport, InputMediaStrategyDescriptor, InputAttachmentStrategy, InputMediaType, } from './shared-types.js';
8
8
  export type { InteractivePrompt, InteractiveQuestion, InteractiveOption, InteractivePromptResponse, InteractiveAnswer, } from './providers/types/interactive-prompt.js';
9
9
  export { normalizeInteractivePrompt, normalizeInteractivePromptResponse, buildClaudeInteractiveToolResult, interactivePromptFromClaudeAskUserQuestion, detectClaudeAskUserQuestionPromptFromJson, } from './providers/types/interactive-prompt.js';
10
- export type { RepoMesh, RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostPairingMetadata, RepoMeshHostStatus, RepoMeshNode, RepoMeshNodeHealth, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshRelatedRepo, RepoMeshNodeCapabilities, DetectedCommand, ProjectContextSnapshot, ProjectContextSource, RepoMeshCoordinatorConfig, LocalMeshConfig, LocalMeshEntry, LocalMeshNodeEntry, RepoMeshStatus, RepoMeshNodeStatus, RepoMeshPeerConnectionStatus, RepoMeshPeerConnectionState, RepoMeshPeerConnectionTransport, RepoMeshSessionStatus, RepoMeshQueueTask, RepoMeshQueueTaskStatus, RepoMeshQueueSummary, RepoMeshQueueStatus, RepoMeshLedgerEntryStatus, RepoMeshLedgerSummaryStatus, RepoMeshLedgerStatus, MeshAsyncJobLifecycle, RepoMeshSchedulingStrategy, RepoMeshSchedulingStatus, RepoMeshNodeSchedulingStatus, RepoMeshNodeProviderSchedulingStatus, } from './repo-mesh-types.js';
11
- export { DEFAULT_MESH_POLICY, resolveDelegatedWorkerAutoApprove, MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, normalizeMeshSchedulingStrategy, resolveNodeSchedulingPriority, resolveProviderMaxParallel, mergeAndNormalizePolicy, normalizeAutoFastForwardPolicy, resolveMaxParallelTasks, MESH_MAX_PARALLEL_TASKS_MIN, MESH_MAX_PARALLEL_TASKS_MAX, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, resolveAutoConvergeCodeChange, } from './repo-mesh-types.js';
10
+ export type { RepoMesh, RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostPairingMetadata, RepoMeshHostStatus, RepoMeshNode, RepoMeshNodeHealth, RepoMeshPolicy, RepoMeshMagiSessionCleanupMode, RepoMeshNodePolicy, RepoMeshRelatedRepo, RepoMeshNodeCapabilities, DetectedCommand, ProjectContextSnapshot, ProjectContextSource, RepoMeshCoordinatorConfig, LocalMeshConfig, LocalMeshEntry, LocalMeshNodeEntry, RepoMeshStatus, RepoMeshNodeStatus, RepoMeshPeerConnectionStatus, RepoMeshPeerConnectionState, RepoMeshPeerConnectionTransport, RepoMeshSessionStatus, RepoMeshQueueTask, RepoMeshQueueTaskStatus, RepoMeshQueueSummary, RepoMeshQueueStatus, RepoMeshLedgerEntryStatus, RepoMeshLedgerSummaryStatus, RepoMeshLedgerStatus, MeshAsyncJobLifecycle, RepoMeshSchedulingStrategy, RepoMeshSchedulingStatus, RepoMeshNodeSchedulingStatus, RepoMeshNodeProviderSchedulingStatus, } from './repo-mesh-types.js';
11
+ export { DEFAULT_MESH_POLICY, resolveDelegatedWorkerAutoApprove, resolveMagiSessionCleanupMode, magiAutoLaunchedSessionCleanupDecision, MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, normalizeMeshSchedulingStrategy, resolveNodeSchedulingPriority, resolveProviderMaxParallel, mergeAndNormalizePolicy, normalizeAutoFastForwardPolicy, resolveMaxParallelTasks, MESH_MAX_PARALLEL_TASKS_MIN, MESH_MAX_PARALLEL_TASKS_MAX, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, resolveAutoConvergeCodeChange, } from './repo-mesh-types.js';
12
12
  export * from './git/index.js';
13
13
  import type { RuntimeWriteOwner as _RuntimeWriteOwner } from './shared-types-extra.js';
14
14
  import type { RuntimeAttachedClient as _RuntimeAttachedClient } from './shared-types-extra.js';
@@ -30,7 +30,7 @@ export { getSavedProviderSessions, upsertSavedProviderSession } from './config/s
30
30
  export type { SavedProviderSessionEntry } from './config/saved-sessions.js';
31
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, MagiReplicaGitRef, MagiGitSkew, MagiSynthesizedResponse, MagiClusterCategory, MagiClusterMember, MagiClaimCluster, MagiSynthesis, } from '@adhdev/mesh-shared';
33
+ export type { MagiPanel, MagiPanelMember, MagiPanelMap, MagiMode, MagiTaskKind, MagiPanelDefaultKind, 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';
package/dist/index.js CHANGED
@@ -43,6 +43,20 @@ function resolveNodeSchedulingPriority(nodePolicy) {
43
43
  function resolveAutoConvergeCodeChange(policy) {
44
44
  return policy?.autoConvergeCodeChange === true;
45
45
  }
46
+ function resolveMagiSessionCleanupMode(value) {
47
+ if (value === void 0 || value === null) return DEFAULT_MESH_POLICY.magiSessionCleanup;
48
+ if (typeof value === "boolean") return value ? "stop_and_delete" : "preserve";
49
+ return value === "preserve" || value === "stop_and_delete" ? value : DEFAULT_MESH_POLICY.magiSessionCleanup;
50
+ }
51
+ function magiAutoLaunchedSessionCleanupDecision(args) {
52
+ const marker = typeof args.recordMarker === "string" ? args.recordMarker.trim() : "";
53
+ const expected = typeof args.expectedTaskId === "string" ? args.expectedTaskId.trim() : "";
54
+ if (args.isCoordinatorSession) return { allow: false, reason: "auto_launch_marker_skip_coordinator_session" };
55
+ if (!expected) return { allow: false, reason: "auto_launch_marker_mismatch" };
56
+ if (!marker) return { allow: false, reason: "auto_launch_marker_absent_session_not_auto_launched" };
57
+ if (marker !== expected) return { allow: false, reason: "auto_launch_marker_mismatch" };
58
+ return { allow: true, reason: "auto_launch_marker_match" };
59
+ }
46
60
  function resolveMaxReadonlyParallelTasks(maxParallelTasks, multiplier) {
47
61
  const raw = Number(multiplier);
48
62
  const mult = Number.isFinite(raw) && raw >= 1 ? Math.floor(raw) : DEFAULT_MESH_READONLY_MULTIPLIER;
@@ -82,6 +96,7 @@ function mergeAndNormalizePolicy(base, patch) {
82
96
  if (!SESSION_CLEANUP_MODES.has(policy.sessionCleanupOnNodeRemove)) {
83
97
  policy.sessionCleanupOnNodeRemove = "preserve";
84
98
  }
99
+ policy.magiSessionCleanup = resolveMagiSessionCleanupMode(policy.magiSessionCleanup);
85
100
  if (!SPAWNED_SESSION_VISIBILITY_MODES.has(policy.spawnedSessionVisibility)) {
86
101
  policy.spawnedSessionVisibility = DEFAULT_MESH_POLICY.spawnedSessionVisibility;
87
102
  }
@@ -149,6 +164,11 @@ var init_repo_mesh_types = __esm({
149
164
  spawnedSessionVisibility: "hidden",
150
165
  delegatedWorkerAutoApprove: true,
151
166
  sessionCleanupOnNodeRemove: "preserve",
167
+ // MAGI auto-launches a worker session per pinned replica target with no idle
168
+ // session; those stay idle-LIVE after their turn. Default ON (stop_and_delete)
169
+ // so repeated reviews don't pile up idle worker sessions. Only marker-verified
170
+ // auto-launched sessions are cleaned — see RepoMeshMagiSessionCleanupMode.
171
+ magiSessionCleanup: "stop_and_delete",
152
172
  autoFastForward: { enabled: true },
153
173
  maxTaskRetries: 1
154
174
  };
@@ -389,10 +409,10 @@ function readInjected(value) {
389
409
  }
390
410
  function getDaemonBuildInfo() {
391
411
  if (cached) return cached;
392
- const commit = readInjected(true ? "332aa731fdfe32e5c872cd1b5b9b5dcfe78594ce" : void 0) ?? "unknown";
393
- const commitShort = readInjected(true ? "332aa731" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
394
- const version = readInjected(true ? "0.9.82-rc.428" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
395
- const builtAt = readInjected(true ? "2026-06-30T00:11:11.503Z" : void 0);
412
+ const commit = readInjected(true ? "5278a1a4b75ca08a30a9f98e7e5888daa84e37e2" : void 0) ?? "unknown";
413
+ const commitShort = readInjected(true ? "5278a1a4" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
414
+ const version = readInjected(true ? "0.9.82-rc.429" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
415
+ const builtAt = readInjected(true ? "2026-06-30T03:05:39.361Z" : void 0);
396
416
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
397
417
  return cached;
398
418
  }
@@ -2953,6 +2973,18 @@ function normalizeReplicaCount(value) {
2953
2973
  const n = Math.floor(value);
2954
2974
  return n >= 1 ? n : void 0;
2955
2975
  }
2976
+ function normalizeMagiPanelDefaultKind(raw) {
2977
+ if (raw == null) return void 0;
2978
+ const s2 = typeof raw === "string" ? raw.trim().toLowerCase() : "";
2979
+ if (s2 === "claim_audit" || s2 === "rca" || s2 === "design") return s2;
2980
+ if (s2 === "freeform") {
2981
+ console.warn(
2982
+ "[magi] panel defaultKind='freeform' rejected \u2014 freeform contributes no structured claims to cross-verification; dropping (use claim_audit / rca / design, or omit)."
2983
+ );
2984
+ return void 0;
2985
+ }
2986
+ return void 0;
2987
+ }
2956
2988
  function normalizeMagiPanel(config) {
2957
2989
  if (!config || typeof config !== "object" || Array.isArray(config)) {
2958
2990
  throw new Error("invalid_magi_panel: config must be an object");
@@ -2986,10 +3018,12 @@ function normalizeMagiPanel(config) {
2986
3018
  });
2987
3019
  const description = typeof raw.description === "string" && raw.description.trim() ? raw.description.trim().slice(0, 200) : void 0;
2988
3020
  const defaultN = normalizeReplicaCount(raw.defaultN);
3021
+ const defaultKind = normalizeMagiPanelDefaultKind(raw.defaultKind);
2989
3022
  return {
2990
3023
  ...description ? { description } : {},
2991
3024
  members,
2992
3025
  ...defaultN !== void 0 ? { defaultN } : {},
3026
+ ...defaultKind !== void 0 ? { defaultKind } : {},
2993
3027
  // dedupExempt is always meaningful for a MAGI panel (intentional same-prompt
2994
3028
  // fan-out). Persist it true unless the caller explicitly disables it.
2995
3029
  dedupExempt: raw.dedupExempt === false ? false : true
@@ -23604,6 +23638,7 @@ __export(index_exports, {
23604
23638
  loadState: () => loadState,
23605
23639
  logCommand: () => logCommand,
23606
23640
  machineCoreFromDaemonId: () => machineCoreFromDaemonId,
23641
+ magiAutoLaunchedSessionCleanupDecision: () => magiAutoLaunchedSessionCleanupDecision,
23607
23642
  markSessionDeliveriesTerminal: () => markSessionDeliveriesTerminal,
23608
23643
  markSetupComplete: () => markSetupComplete,
23609
23644
  markStaleDirectDispatches: () => markStaleDirectDispatches,
@@ -23678,6 +23713,7 @@ __export(index_exports, {
23678
23713
  resolveDelegatedWorkerAutoApprove: () => resolveDelegatedWorkerAutoApprove,
23679
23714
  resolveDeliveryDecision: () => resolveDeliveryDecision,
23680
23715
  resolveGitRepository: () => resolveGitRepository,
23716
+ resolveMagiSessionCleanupMode: () => resolveMagiSessionCleanupMode,
23681
23717
  resolveMaxParallelTasks: () => resolveMaxParallelTasks,
23682
23718
  resolveMeshHostStatus: () => resolveMeshHostStatus,
23683
23719
  resolveMeshNodeAttribution: () => resolveMeshNodeAttribution,
@@ -44394,12 +44430,14 @@ var DaemonCliManager = class {
44394
44430
  this.adapters.set(key2, cliInstance.getAdapter());
44395
44431
  const launchMeshNodeId = typeof settings?.meshNodeId === "string" ? settings.meshNodeId.trim() : "";
44396
44432
  const launchMeshNodeFor = typeof settings?.meshNodeFor === "string" ? settings.meshNodeFor.trim() : "";
44397
- if (launchMeshNodeId || launchMeshNodeFor) {
44433
+ const launchAutoLaunchedForQueueTaskId = typeof settings?.autoLaunchedForQueueTaskId === "string" ? settings.autoLaunchedForQueueTaskId.trim() : "";
44434
+ if (launchMeshNodeId || launchMeshNodeFor || launchAutoLaunchedForQueueTaskId) {
44398
44435
  try {
44399
44436
  cliInstance.getAdapter().updateRuntimeMeta?.({
44400
44437
  ...launchMeshNodeId ? { meshNodeId: launchMeshNodeId } : {},
44401
44438
  ...launchMeshNodeFor ? { meshNodeFor: launchMeshNodeFor } : {},
44402
- ...settings?.launchedByCoordinator === true ? { launchedByCoordinator: true } : {}
44439
+ ...settings?.launchedByCoordinator === true ? { launchedByCoordinator: true } : {},
44440
+ ...launchAutoLaunchedForQueueTaskId ? { autoLaunchedForQueueTaskId: launchAutoLaunchedForQueueTaskId } : {}
44403
44441
  });
44404
44442
  } catch {
44405
44443
  }
@@ -49499,6 +49537,8 @@ var meshCrudHandlers = {
49499
49537
  if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
49500
49538
  const mode = ctx.normalizeMeshSessionCleanupMode(args?.mode ?? mesh?.policy?.sessionCleanupOnNodeRemove);
49501
49539
  const sessionIds = Array.isArray(args?.sessionIds) ? args.sessionIds.map((id) => typeof id === "string" ? id.trim() : "").filter(Boolean) : void 0;
49540
+ const source = args?.source === "magi_session_cleanup" ? "magi_session_cleanup" : "mesh_cleanup_sessions";
49541
+ const requireAutoLaunchedForTaskIds = args?.requireAutoLaunchedForTaskIds && typeof args.requireAutoLaunchedForTaskIds === "object" && !Array.isArray(args.requireAutoLaunchedForTaskIds) ? args.requireAutoLaunchedForTaskIds : void 0;
49502
49542
  const result = await ctx.cleanupMeshSessions({
49503
49543
  meshId,
49504
49544
  nodeId,
@@ -49506,7 +49546,8 @@ var meshCrudHandlers = {
49506
49546
  mode,
49507
49547
  sessionIds,
49508
49548
  dryRun: args?.dryRun === true,
49509
- source: "mesh_cleanup_sessions"
49549
+ source,
49550
+ requireAutoLaunchedForTaskIds
49510
49551
  });
49511
49552
  return result;
49512
49553
  } catch (e) {
@@ -55406,6 +55447,7 @@ var DaemonCommandRouter = class {
55406
55447
  const skippedLiveSessionIds = [];
55407
55448
  const skippedCoordinatorSessionIds = [];
55408
55449
  const skippedLiveSessionReasons = [];
55450
+ const skippedMarkerMismatchSessionIds = [];
55409
55451
  const actedLiveDelegateSessionIds = [];
55410
55452
  const deleteUnsupportedSessionIds = [];
55411
55453
  const recordsRemainSessionIds = [];
@@ -55448,6 +55490,19 @@ var DaemonCommandRouter = class {
55448
55490
  skippedCoordinatorSessionIds.push(sessionId);
55449
55491
  continue;
55450
55492
  }
55493
+ if (args.requireAutoLaunchedForTaskIds) {
55494
+ const decision = magiAutoLaunchedSessionCleanupDecision({
55495
+ recordMarker: readStringValue(record?.meta?.autoLaunchedForQueueTaskId),
55496
+ expectedTaskId: args.requireAutoLaunchedForTaskIds[sessionId],
55497
+ isCoordinatorSession: coordinatorSession
55498
+ });
55499
+ if (!decision.allow) {
55500
+ skippedSessionIds.push(sessionId);
55501
+ skippedMarkerMismatchSessionIds.push(sessionId);
55502
+ skippedLiveSessionReasons.push({ sessionId, reason: decision.reason });
55503
+ continue;
55504
+ }
55505
+ }
55451
55506
  const matchedByWorkspaceOnly = !recordNodeId;
55452
55507
  const isWorktreeNodeRemoval = cleanupSource === "mesh_remove_node" && args.node?.isLocalWorktree === true;
55453
55508
  const cleanWorkspaceOnlyForWorktree = isWorktreeNodeRemoval && matchedByWorkspaceOnly;
@@ -55531,6 +55586,7 @@ var DaemonCommandRouter = class {
55531
55586
  skippedSessionIds,
55532
55587
  skippedLiveSessionIds,
55533
55588
  skippedCoordinatorSessionIds,
55589
+ ...skippedMarkerMismatchSessionIds.length ? { skippedMarkerMismatchSessionIds } : {},
55534
55590
  ...actedLiveDelegateSessionIds.length ? { actedLiveDelegateSessionIds } : {},
55535
55591
  ...skippedLiveSessionReasons.length ? { skippedLiveSessionReasons } : {},
55536
55592
  ...deleteUnsupported ? {
@@ -65477,6 +65533,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
65477
65533
  loadState,
65478
65534
  logCommand,
65479
65535
  machineCoreFromDaemonId,
65536
+ magiAutoLaunchedSessionCleanupDecision,
65480
65537
  markSessionDeliveriesTerminal,
65481
65538
  markSetupComplete,
65482
65539
  markStaleDirectDispatches,
@@ -65551,6 +65608,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
65551
65608
  resolveDelegatedWorkerAutoApprove,
65552
65609
  resolveDeliveryDecision,
65553
65610
  resolveGitRepository,
65611
+ resolveMagiSessionCleanupMode,
65554
65612
  resolveMaxParallelTasks,
65555
65613
  resolveMeshHostStatus,
65556
65614
  resolveMeshNodeAttribution,