@adhdev/daemon-core 0.9.82-rc.364 → 0.9.82-rc.366

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 (41) hide show
  1. package/dist/commands/high-family/index.d.ts +3 -0
  2. package/dist/commands/high-family/mesh-coordinator-launch.d.ts +2 -0
  3. package/dist/commands/high-family/mesh-events.d.ts +2 -0
  4. package/dist/commands/high-family/mesh-status.d.ts +2 -0
  5. package/dist/commands/high-family/types.d.ts +60 -0
  6. package/dist/commands/med-family/cli-agent.d.ts +2 -0
  7. package/dist/commands/med-family/fast-forward.d.ts +2 -0
  8. package/dist/commands/med-family/ide.d.ts +10 -0
  9. package/dist/commands/med-family/index.d.ts +3 -0
  10. package/dist/commands/med-family/mesh-crud.d.ts +2 -0
  11. package/dist/commands/med-family/mesh-host-pairing.d.ts +2 -0
  12. package/dist/commands/med-family/mesh-queue.d.ts +2 -0
  13. package/dist/commands/med-family/types.d.ts +116 -0
  14. package/dist/commands/router.d.ts +291 -0
  15. package/dist/index.js +3824 -3565
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +3811 -3553
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/mesh/mesh-events-coordinator.d.ts +8 -0
  20. package/dist/system/hash.d.ts +8 -0
  21. package/package.json +2 -2
  22. package/src/commands/cli-manager.ts +30 -3
  23. package/src/commands/high-family/index.ts +28 -0
  24. package/src/commands/high-family/mesh-coordinator-launch.ts +592 -0
  25. package/src/commands/high-family/mesh-events.ts +47 -0
  26. package/src/commands/high-family/mesh-status.ts +639 -0
  27. package/src/commands/high-family/types.ts +76 -0
  28. package/src/commands/med-family/cli-agent.ts +218 -0
  29. package/src/commands/med-family/fast-forward.ts +198 -0
  30. package/src/commands/med-family/ide.ts +163 -0
  31. package/src/commands/med-family/index.ts +35 -0
  32. package/src/commands/med-family/mesh-crud.ts +788 -0
  33. package/src/commands/med-family/mesh-host-pairing.ts +234 -0
  34. package/src/commands/med-family/mesh-queue.ts +131 -0
  35. package/src/commands/med-family/types.ts +120 -0
  36. package/src/commands/mesh-coordinator.ts +2 -2
  37. package/src/commands/router.ts +328 -2847
  38. package/src/config/mesh-config.ts +3 -2
  39. package/src/mesh/mesh-active-work.ts +59 -81
  40. package/src/mesh/mesh-events-coordinator.ts +35 -1
  41. package/src/system/hash.ts +23 -0
@@ -59,6 +59,14 @@ export interface MeshQueueTriggerResult {
59
59
  status?: string;
60
60
  }>;
61
61
  autoLaunchStarted: boolean;
62
+ /**
63
+ * True when a worker session is already on its way to claim a still-pending task —
64
+ * either launched this tick (autoLaunchStarted) or launched on a prior tick and still
65
+ * booting/awaiting-claim. Callers MUST treat this as "wait, do not launch another
66
+ * session": a second launch double-edits the worktree. Mutually informative with
67
+ * `noIdleMeshSessionAvailable`, which is suppressed whenever this is true.
68
+ */
69
+ autoLaunchPending?: boolean;
62
70
  noIdleMeshSessionAvailable?: boolean;
63
71
  }
64
72
  export declare function triggerMeshQueue(components: DaemonComponents, meshId: string): Promise<MeshQueueTriggerResult>;
@@ -0,0 +1,8 @@
1
+ /** Full lowercase hex SHA-256 digest of `input`. */
2
+ export declare function sha256Hex(input: string): string;
3
+ /**
4
+ * Truncated SHA-256 hex digest — the first `length` hex chars (default 16).
5
+ * Used for stable short identifiers (workspace hashes, token ids, coordinator
6
+ * home dirs) where collision risk at 16 hex chars (64 bits) is negligible.
7
+ */
8
+ export declare function shortHash(input: string, length?: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.364",
3
+ "version": "0.9.82-rc.366",
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",
@@ -46,7 +46,7 @@
46
46
  "author": "vilmire",
47
47
  "license": "AGPL-3.0-or-later",
48
48
  "dependencies": {
49
- "@adhdev/mesh-shared": "0.9.82-rc.364",
49
+ "@adhdev/mesh-shared": "0.9.82-rc.366",
50
50
  "@adhdev/session-host-core": "*",
51
51
  "@agentclientprotocol/sdk": "^0.16.1",
52
52
  "ajv": "^8.20.0",
@@ -18,7 +18,8 @@ import { loadConfig } from '../config/config.js';
18
18
  import { loadState, saveState } from '../config/state-store.js';
19
19
  import { getWorkspaceState, resolveLaunchDirectory } from '../config/workspaces.js';
20
20
  import { appendRecentActivity } from '../config/recent-activity.js';
21
- import { unregisterMeshCoordinator, getCoordinatorForSession } from '../mesh/coordinator-registry.js';
21
+ import { shortHash } from '../system/hash.js';
22
+ import { unregisterMeshCoordinator, getCoordinatorForSession, listCoordinatorsForWorkspace } from '../mesh/coordinator-registry.js';
22
23
  import { upsertSavedProviderSession } from '../config/saved-sessions.js';
23
24
  import { buildLegacyModelModeSummaryMetadata, normalizeProviderSummaryMetadata } from '../providers/summary-metadata.js';
24
25
  import { CliProviderInstance } from '../providers/cli-provider-instance.js';
@@ -301,7 +302,7 @@ function hasConfigOverride(args: string[], key: string): boolean {
301
302
  function ensureEmptyDelegatedMcpConfig(workspace: string): string {
302
303
  const baseDir = path.join(os.tmpdir(), 'adhdev-delegated-agent-empty-mcp');
303
304
  mkdirSync(baseDir, { recursive: true });
304
- const workspaceHash = crypto.createHash('sha256').update(path.resolve(workspace || os.tmpdir())).digest('hex').slice(0, 16);
305
+ const workspaceHash = shortHash(path.resolve(workspace || os.tmpdir()));
305
306
  const filePath = path.join(baseDir, `${workspaceHash}.json`);
306
307
  writeFileSync(filePath, JSON.stringify({ mcpServers: {} }, null, 2), 'utf-8');
307
308
  return filePath;
@@ -1068,7 +1069,33 @@ export class DaemonCliManager {
1068
1069
  // Both restores are provider-agnostic — getSettings is keyed by provider type and the
1069
1070
  // registry mark is type-independent.
1070
1071
  const restoredSettings: Record<string, any> = { ...this.providerLoader.getSettings(normalizedType) };
1071
- const coordinatorEntry = getCoordinatorForSession(record.runtimeId);
1072
+ // Primary rebind: exact persisted-registry match by runtimeId (stable across
1073
+ // restart, see session-host runtimeId = runtimeRecord.sessionId).
1074
+ let coordinatorEntry = getCoordinatorForSession(record.runtimeId);
1075
+ // CORDBADGE fallback: the by-id match misses when a coordinator's runtime
1076
+ // re-attaches under a different runtimeId than the one it was registered with
1077
+ // (the registry survived, but its key no longer lines up). Without a rebind the
1078
+ // restored session silently loses meshCoordinatorFor → the coordinator badge and
1079
+ // selfIdentification block vanish and pending mesh events stop draining into its
1080
+ // PTY, and the only recovery is a manual coordinator restart. Recover the mark
1081
+ // from the persisted registry scoped to this exact workspace, but ONLY when it is
1082
+ // UNAMBIGUOUS: exactly one registered coordinator for this workspace AND its
1083
+ // cliType matches the restored session's type. The registry never holds worker
1084
+ // sessions (only launch_mesh_coordinator registrations), so this cannot mis-mark a
1085
+ // delegated worker; the uniqueness + cliType gate keeps it from guessing when two
1086
+ // coordinators ever shared a workspace. Anything ambiguous stays unbound (we would
1087
+ // rather miss a badge than mis-attribute one).
1088
+ if (!coordinatorEntry?.meshId && record.workspace) {
1089
+ const workspaceCoordinators = listCoordinatorsForWorkspace(record.workspace)
1090
+ .filter(e => e.meshId && (!e.cliType || e.cliType === record.cliType));
1091
+ if (workspaceCoordinators.length === 1) {
1092
+ coordinatorEntry = workspaceCoordinators[0];
1093
+ LOG.info(
1094
+ 'CLI',
1095
+ `↻ Rebound coordinator mark by workspace for ${record.runtimeKey || record.runtimeId} (mesh ${coordinatorEntry.meshId} @ ${record.workspace}); registry key did not match runtimeId`
1096
+ );
1097
+ }
1098
+ }
1072
1099
  if (coordinatorEntry?.meshId) {
1073
1100
  restoredSettings.meshCoordinatorFor = coordinatorEntry.meshId;
1074
1101
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * RF-ROUTER HIGH family — command registry.
3
+ *
4
+ * Aggregates the high-coupling command handlers extracted from
5
+ * DaemonCommandRouter.executeDaemonCommand into a single cmd → handler map. The
6
+ * router consults this registry after the LOW- and MED-family registries and
7
+ * before its remaining switch (registry hit → return the handler result; miss →
8
+ * fall through to the switch / CommandHandler delegation), so the facade and
9
+ * dispatch semantics are unchanged.
10
+ *
11
+ * HIGH handlers are the most router-coupled: beyond the MED collaborators they
12
+ * reach the router's aggregate-status memory cache and running-refine-job table.
13
+ * The router binds those onto HighFamilyContext at dispatch — see types.ts.
14
+ */
15
+ import { meshEventsHandlers } from './mesh-events.js';
16
+ import { meshCoordinatorLaunchHandlers } from './mesh-coordinator-launch.js';
17
+ import { meshStatusHandlers } from './mesh-status.js';
18
+ import type { HighFamilyRegistry } from './types.js';
19
+
20
+ export type { HighFamilyContext, HighFamilyHandler, HighFamilyRegistry } from './types.js';
21
+
22
+ export const highFamilyRegistry: HighFamilyRegistry = new Map(
23
+ Object.entries({
24
+ ...meshEventsHandlers,
25
+ ...meshCoordinatorLaunchHandlers,
26
+ ...meshStatusHandlers,
27
+ }),
28
+ );