@adhdev/daemon-core 1.0.18-rc.1 → 1.0.18-rc.11
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/dist/cli-adapters/cli-state-engine.d.ts +77 -0
- package/dist/cli-adapters/pty-transport.d.ts +2 -1
- package/dist/commands/process-lifecycle.d.ts +43 -0
- package/dist/commands/upgrade-helper.d.ts +7 -0
- package/dist/commands/windows-atomic-upgrade.d.ts +63 -0
- package/dist/index.js +6513 -4536
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6539 -4556
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/coordinator-prompt.d.ts +76 -0
- package/dist/mesh/mesh-active-work.d.ts +1 -1
- package/dist/mesh/mesh-disk-retention.d.ts +105 -0
- package/dist/mesh/mesh-ledger.d.ts +28 -1
- package/dist/mesh/mesh-node-identity.d.ts +23 -0
- package/dist/mesh/mesh-refine-gates.d.ts +89 -0
- package/dist/mesh/mesh-runtime-store.d.ts +11 -0
- package/dist/mesh/mesh-work-queue.d.ts +24 -1
- package/dist/providers/cli-provider-instance-types.d.ts +4 -0
- package/dist/providers/cli-provider-instance.d.ts +2 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +14 -0
- package/dist/providers/types/interactive-prompt.d.ts +18 -0
- package/package.json +3 -3
- package/src/boot/daemon-lifecycle.ts +10 -0
- package/src/cli-adapters/cli-state-engine.ts +204 -3
- package/src/cli-adapters/provider-cli-adapter.ts +39 -5
- package/src/cli-adapters/pty-transport.d.ts +2 -1
- package/src/cli-adapters/pty-transport.ts +1 -1
- package/src/cli-adapters/session-host-transport.ts +8 -3
- package/src/commands/high-family/mesh-coordinator-launch.ts +17 -2
- package/src/commands/high-family/mesh-events.ts +13 -2
- package/src/commands/med-family/mesh-queue.ts +74 -1
- package/src/commands/process-lifecycle.ts +248 -0
- package/src/commands/router-refine.ts +71 -4
- package/src/commands/router.ts +8 -0
- package/src/commands/upgrade-helper.ts +146 -79
- package/src/commands/windows-atomic-upgrade.ts +631 -0
- package/src/config/mesh-json-config.ts +8 -0
- package/src/mesh/coordinator-prompt.ts +258 -11
- package/src/mesh/mesh-active-work.ts +11 -1
- package/src/mesh/mesh-disk-retention.ts +370 -0
- package/src/mesh/mesh-event-classify.ts +19 -0
- package/src/mesh/mesh-event-forwarding.ts +46 -4
- package/src/mesh/mesh-events-utils.ts +42 -0
- package/src/mesh/mesh-ledger.ts +77 -0
- package/src/mesh/mesh-node-identity.ts +49 -0
- package/src/mesh/mesh-queue-assignment.ts +144 -2
- package/src/mesh/mesh-reconcile-loop.ts +55 -1
- package/src/mesh/mesh-refine-gates.ts +300 -0
- package/src/mesh/mesh-runtime-store.ts +21 -0
- package/src/mesh/mesh-work-queue.ts +85 -2
- package/src/providers/cli-provider-instance-types.ts +53 -0
- package/src/providers/cli-provider-instance.ts +193 -2
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +23 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +20 -0
- package/src/providers/types/interactive-prompt.ts +77 -0
- package/src/session-host/managed-host.ts +34 -0
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
type SessionHostEndpoint,
|
|
9
9
|
type SessionHostRequestType,
|
|
10
10
|
} from '@adhdev/session-host-core';
|
|
11
|
+
import { getProcessCommandLine, parseNodeScriptPath } from '../commands/process-lifecycle.js';
|
|
12
|
+
import { LOG } from '../logging/logger.js';
|
|
11
13
|
import { ensureSessionHostReady as ensureSharedSessionHostReady } from './runtime-support.js';
|
|
12
14
|
import { DEFAULT_SESSION_HOST_READY_TIMEOUT_MS } from '../runtime-defaults.js';
|
|
13
15
|
|
|
@@ -97,6 +99,16 @@ export function createManagedSessionHost(options: ManagedSessionHostOptions): Ma
|
|
|
97
99
|
return require.resolve('@adhdev/session-host-daemon');
|
|
98
100
|
}
|
|
99
101
|
|
|
102
|
+
function pathsEquivalent(left: string, right: string): boolean {
|
|
103
|
+
return path.resolve(left).toLowerCase() === path.resolve(right).toLowerCase();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getRunningSessionHostScriptPath(pid: number): string | null {
|
|
107
|
+
const commandLine = getProcessCommandLine(pid);
|
|
108
|
+
if (!commandLine || !/session-host-daemon/i.test(commandLine)) return null;
|
|
109
|
+
return parseNodeScriptPath(commandLine);
|
|
110
|
+
}
|
|
111
|
+
|
|
100
112
|
function getPidFile(): string {
|
|
101
113
|
return path.join(os.homedir(), '.adhdev', `${appName}-session-host.pid`);
|
|
102
114
|
}
|
|
@@ -178,6 +190,28 @@ export function createManagedSessionHost(options: ManagedSessionHostOptions): Ma
|
|
|
178
190
|
|
|
179
191
|
async function ensureReady(): Promise<SessionHostEndpoint> {
|
|
180
192
|
options.beforeEnsureReady?.();
|
|
193
|
+
|
|
194
|
+
// Defensive guard: on Windows the daemon may have been restarted from a
|
|
195
|
+
// new versioned prefix while a session-host from the old prefix is still
|
|
196
|
+
// running. Because the old host is reachable on the same socket endpoint,
|
|
197
|
+
// `ensureSharedSessionHostReady` would reuse it and lazy requires would
|
|
198
|
+
// resolve against the deleted tree. Detect the mismatch and stop the stale
|
|
199
|
+
// host before it can be reused; a matching or unreadable host is left alone.
|
|
200
|
+
if (process.platform === 'win32') {
|
|
201
|
+
const existingPid = getPid();
|
|
202
|
+
if (existingPid !== null) {
|
|
203
|
+
const runningPath = getRunningSessionHostScriptPath(existingPid);
|
|
204
|
+
const currentEntry = resolveEntry();
|
|
205
|
+
if (runningPath && !pathsEquivalent(runningPath, currentEntry)) {
|
|
206
|
+
LOG.warn(
|
|
207
|
+
'SessionHost',
|
|
208
|
+
`Detected stale host pid ${existingPid} running from ${runningPath}; restarting from ${currentEntry}`,
|
|
209
|
+
);
|
|
210
|
+
stopManagedSessionHostProcess();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
181
215
|
try {
|
|
182
216
|
return await ensureSharedSessionHostReady({
|
|
183
217
|
appName,
|