@adhdev/daemon-core 0.9.82-rc.228 → 0.9.82-rc.229

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.228",
3
+ "version": "0.9.82-rc.229",
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",
@@ -2549,12 +2549,18 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
2549
2549
  const registrySessionWorkspace = targetSid
2550
2550
  ? (h.ctx?.sessionRegistry?.get?.(targetSid) as any)?.workspace
2551
2551
  : undefined;
2552
- const workspace = typeof (h.currentSession as any)?.workspace === 'string'
2552
+ const currentSessionWorkspace = typeof (h.currentSession as any)?.workspace === 'string'
2553
2553
  ? (h.currentSession as any).workspace
2554
- : typeof registrySessionWorkspace === 'string'
2555
- ? registrySessionWorkspace
2556
- : undefined;
2557
- const intendedWorkspace = typeof args?.workspace === 'string' ? args.workspace : undefined;
2554
+ : undefined;
2555
+ const argsWorkspace = typeof args?.workspace === 'string' ? args.workspace : undefined;
2556
+ // When reading a different session (targetSid), prefer that session's registered
2557
+ // workspace (or the caller-supplied args.workspace) over the current (coordinator)
2558
+ // session's workspace — otherwise the coordinator's cwd shadows the worker's cwd
2559
+ // and history lookups find the wrong files.
2560
+ const workspace = targetSid
2561
+ ? (typeof registrySessionWorkspace === 'string' ? registrySessionWorkspace : argsWorkspace ?? currentSessionWorkspace)
2562
+ : (typeof currentSessionWorkspace === 'string' ? currentSessionWorkspace : undefined);
2563
+ const intendedWorkspace = argsWorkspace;
2558
2564
  const supportsNative = supportsCliNativeTranscript(agentStr, provider)
2559
2565
  && isNativeSourceCanonicalHistory(provider?.nativeHistory);
2560
2566
  const history = supportsNative
@@ -6,7 +6,7 @@ import { detectCLI } from '../detection/cli-detector.js';
6
6
  import { LOG } from '../logging/logger.js';
7
7
  import { appendLedgerEntry, buildTaskCompletionEvidence, getSessionRecoveryContext, isIntentionalCleanupStopEntry, readLedgerEntries } from './mesh-ledger.js';
8
8
  import type { MeshLedgerKind, SessionRecoveryContext } from './mesh-ledger.js';
9
- import { buildMeshNodeCapabilityTags, claimNextTask, updateSessionTaskStatus, enqueueTask, updateTaskStatus, getQueue, recordTaskAutoLaunch, updateDirectDispatchStatus, cleanupTerminalDirectDispatches, getActiveDirectDispatches, hasPendingDependents } from './mesh-work-queue.js';
9
+ import { buildMeshNodeCapabilityTags, nodeSatisfiesRequiredTags, claimNextTask, updateSessionTaskStatus, enqueueTask, updateTaskStatus, getQueue, recordTaskAutoLaunch, updateDirectDispatchStatus, cleanupTerminalDirectDispatches, getActiveDirectDispatches, hasPendingDependents } from './mesh-work-queue.js';
10
10
  import { fastForwardMeshNode } from './mesh-fast-forward.js';
11
11
  import { createSessionDelivery, markSessionDeliveriesTerminal, updateSessionDeliveryStatus, recordCompletionConflict } from './mesh-delivery-policy.js';
12
12
  import { MeshRuntimeStore } from './mesh-runtime-store.js';
@@ -499,7 +499,12 @@ function markAutoLaunch(meshId: string, taskId: string, args: {
499
499
  });
500
500
  }
501
501
 
502
- async function resolveUsableProvider(components: DaemonComponents, nodeId: string, node: any): Promise<{ providerType?: string; reason?: string }> {
502
+ async function resolveUsableProvider(
503
+ components: DaemonComponents,
504
+ nodeId: string,
505
+ node: any,
506
+ requiredTags?: string[],
507
+ ): Promise<{ providerType?: string; reason?: string }> {
503
508
  const providerPriority = normalizeProviderPriority(node?.policy);
504
509
  if (!providerPriority.length) return { reason: 'missing_provider_priority' };
505
510
  const providerLoader = components.providerLoader;
@@ -510,6 +515,12 @@ async function resolveUsableProvider(components: DaemonComponents, nodeId: strin
510
515
  const normalizedType = typeof providerLoader.resolveAlias === 'function'
511
516
  ? providerLoader.resolveAlias(requestedType)
512
517
  : requestedType;
518
+ // Skip providers that can't satisfy the task's requiredTags (e.g. provider=hermes-cli
519
+ // means only hermes-cli qualifies, not any other type in providerPriority).
520
+ if (requiredTags?.length && !nodeSatisfiesRequiredTags(requiredTags, buildMeshNodeCapabilityTags(node, normalizedType))) {
521
+ failed.push(`${requestedType}: required_tags_mismatch`);
522
+ continue;
523
+ }
513
524
  if (typeof providerLoader.isMachineProviderEnabled === 'function' && !providerLoader.isMachineProviderEnabled(normalizedType)) {
514
525
  failed.push(`${requestedType}: disabled`);
515
526
  continue;
@@ -552,10 +563,23 @@ async function maybeAutoLaunchOneQueueSession(components: DaemonComponents, mesh
552
563
  }
553
564
 
554
565
  const candidateNodes = Array.isArray(mesh?.nodes)
555
- ? mesh.nodes.filter((node: any) => task.targetNodeId ? node?.id === task.targetNodeId : true)
566
+ ? mesh.nodes.filter((node: any) => {
567
+ if (task.targetNodeId && node?.id !== task.targetNodeId) return false;
568
+ // Skip nodes that can never satisfy requiredTags regardless of which provider
569
+ // from providerPriority is selected. A node satisfies tags if at least one
570
+ // provider in its priority list would produce matching capability tags.
571
+ if (task.requiredTags?.length) {
572
+ const priorities = normalizeProviderPriority(node?.policy);
573
+ const providerCandidates = priorities.length ? priorities : [undefined as unknown as string];
574
+ return providerCandidates.some(p =>
575
+ nodeSatisfiesRequiredTags(task.requiredTags, buildMeshNodeCapabilityTags(node, p))
576
+ );
577
+ }
578
+ return true;
579
+ })
556
580
  : [];
557
581
  if (!candidateNodes.length) {
558
- markAutoLaunch(meshId, task.id, { status: 'skipped', reason: 'no_matching_node', nodeId: task.targetNodeId });
582
+ markAutoLaunch(meshId, task.id, { status: 'skipped', reason: 'no_node_satisfies_required_tags', nodeId: task.targetNodeId });
559
583
  continue;
560
584
  }
561
585
 
@@ -599,7 +623,7 @@ async function maybeAutoLaunchOneQueueSession(components: DaemonComponents, mesh
599
623
 
600
624
  autoLaunchInProgress.add(launchKey);
601
625
  try {
602
- const resolved = await resolveUsableProvider(components, nodeId, node);
626
+ const resolved = await resolveUsableProvider(components, nodeId, node, task.requiredTags);
603
627
  if (!resolved.providerType) {
604
628
  markAutoLaunch(meshId, task.id, { status: 'skipped', reason: resolved.reason || 'provider_unusable', nodeId });
605
629
  continue;