@adhdev/daemon-core 0.8.50 → 0.8.51

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/session-host-core",
3
- "version": "0.8.50",
3
+ "version": "0.8.51",
4
4
  "description": "ADHDev local session host core — session registry, protocol, buffers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.8.50",
3
+ "version": "0.8.51",
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,6 +46,7 @@ export interface DaemonInitConfig {
46
46
  removeAgentTracking: (key: string) => void;
47
47
  createPtyTransportFactory?: (params: CliTransportFactoryParams) => PtyTransportFactory | null;
48
48
  listHostedCliRuntimes?: () => Promise<HostedCliRuntimeDescriptor[]>;
49
+ hostedRuntimeManagerTag?: string;
49
50
  };
50
51
 
51
52
  /** CDP config */
@@ -27,6 +27,7 @@ import type { PtyTransportFactory } from '../cli-adapters/pty-transport.js';
27
27
  import type { SessionRegistry } from '../sessions/registry.js';
28
28
  import type { ProviderInstance } from '../providers/provider-instance.js';
29
29
  import { LOG } from '../logging/logger.js';
30
+ import { shouldRestoreHostedRuntime } from './hosted-runtime-restore.js';
30
31
 
31
32
  // ─── external dependency interface ──────────────────────────
32
33
 
@@ -43,6 +44,7 @@ export interface CliManagerDeps {
43
44
  getSessionRegistry?(): SessionRegistry | null;
44
45
  createPtyTransportFactory?: (params: CliTransportFactoryParams) => PtyTransportFactory | null;
45
46
  listHostedCliRuntimes?: () => Promise<HostedCliRuntimeDescriptor[]>;
47
+ hostedRuntimeManagerTag?: string;
46
48
  }
47
49
 
48
50
  type CommandResult = { success: boolean;[key: string]: unknown };
@@ -67,6 +69,7 @@ export interface HostedCliRuntimeDescriptor {
67
69
  workspace: string;
68
70
  cliArgs?: string[];
69
71
  providerSessionId?: string;
72
+ managedBy?: string;
70
73
  }
71
74
 
72
75
  type CliPresentationInstance = ProviderInstance & {
@@ -707,9 +710,17 @@ export class DaemonCliManager {
707
710
  const sessions = records || await this.deps.listHostedCliRuntimes?.() || [];
708
711
  let restored = 0;
709
712
  const restoredBindings = new Set<string>();
713
+ const managerTag = this.deps.hostedRuntimeManagerTag;
710
714
 
711
715
  for (const record of sessions) {
712
716
  if (!record?.runtimeId || !record?.cliType || !record?.workspace) continue;
717
+ if (!shouldRestoreHostedRuntime(record, managerTag)) {
718
+ LOG.info(
719
+ 'CLI',
720
+ `↷ Skipping hosted runtime restore owned by ${record.managedBy}: ${record.runtimeKey || record.runtimeId}`
721
+ );
722
+ continue;
723
+ }
713
724
  if (this.adapters.has(record.runtimeId) || instanceManager.getInstance(record.runtimeId)) continue;
714
725
  const normalizedType = this.providerLoader.resolveAlias(record.cliType);
715
726
  const providerMeta = this.providerLoader.getMeta(normalizedType);
@@ -0,0 +1,9 @@
1
+ export function shouldRestoreHostedRuntime(
2
+ record: { managedBy?: string | null | undefined },
3
+ managerTag?: string,
4
+ ): boolean {
5
+ if (!managerTag) return true
6
+ const managedBy = typeof record.managedBy === 'string' ? record.managedBy.trim() : ''
7
+ if (!managedBy) return true
8
+ return managedBy === managerTag
9
+ }
@@ -65,6 +65,7 @@ export async function listHostedCliRuntimes(endpoint: SessionHostEndpoint): Prom
65
65
  workspace: record.workspace,
66
66
  cliArgs: Array.isArray(record.meta?.cliArgs) ? (record.meta.cliArgs as string[]) : [],
67
67
  providerSessionId: typeof record.meta?.providerSessionId === 'string' ? String(record.meta.providerSessionId) : undefined,
68
+ managedBy: typeof record.meta?.managedBy === 'string' ? String(record.meta.managedBy) : undefined,
68
69
  }));
69
70
  } finally {
70
71
  await client.close().catch(() => {});