11import assert from 'node:assert/strict' ;
22import fs from 'node:fs' ;
3- import path from 'node:path' ;
4- import { afterEach , test , vi } from 'vitest' ;
3+ import { afterEach , beforeAll , test , vi } from 'vitest' ;
54import { mkdtempForTestSync } from '../../__tests__/test-utils/tmp-dir.ts' ;
65
76vi . mock ( '@agent-device/host-kit/command' , async ( importOriginal ) => ( {
@@ -33,8 +32,8 @@ import { resolveDaemonPaths, type DaemonPaths } from '../../daemon-resolution.ts
3332import { sendToDaemon } from '../daemon-client.ts' ;
3433import { runCmdDetachedMonitored , type ExecDetachedExit } from '@agent-device/host-kit/command' ;
3534import { sleep } from '@agent-device/host-kit/retry' ;
36- import { findProjectRoot , readVersion } from '@agent-device/host-kit/version' ;
37- import { computeDaemonCodeSignature } from '@agent-device/host-kit/code-signature ' ;
35+ import { readVersion } from '@agent-device/host-kit/version' ;
36+ import { resolveLocalDaemonCodeIdentity } from '../daemon-launch-spec.ts ' ;
3837import {
3938 startHttpDaemonFixture ,
4039 type HttpDaemonFixture ,
@@ -58,16 +57,13 @@ afterEach(() => {
5857 vi . unstubAllEnvs ( ) ;
5958} ) ;
6059
61- /** The code signature this client expects of a daemon it may reuse. */
62- function currentDaemonCodeSignature ( ) : string {
63- const root = findProjectRoot ( ) ;
64- const distPath = path . join ( root , 'dist' , 'src' , 'internal' , 'daemon.js' ) ;
65- const entryPath =
66- process . execArgv . includes ( '--experimental-strip-types' ) || ! fs . existsSync ( distPath )
67- ? path . join ( root , 'src' , 'daemon.ts' )
68- : distPath ;
69- return computeDaemonCodeSignature ( entryPath , root ) ;
70- }
60+ /** The code signature this client stamps on, and expects of, a daemon it may reuse. */
61+ let codeSignature : string | undefined ;
62+
63+ beforeAll ( async ( ) => {
64+ const identity = await resolveLocalDaemonCodeIdentity ( ) ;
65+ codeSignature = identity . origin === 'installed' ? undefined : identity . codeSignature ;
66+ } ) ;
7167
7268/** Records the winning daemon the way it would: the startup lock, then its reachable metadata. */
7369function writeWinner (
@@ -88,7 +84,7 @@ function writeWinner(
8884 token : 'winner-secret' ,
8985 pid : WINNER_PID ,
9086 version,
91- codeSignature : currentDaemonCodeSignature ( ) ,
87+ codeSignature,
9288 processStartTime : 'winner' ,
9389 httpPort : fixture . port ,
9490 transport : 'http' ,
0 commit comments