@@ -13,6 +13,7 @@ import {
1313 ThreadId ,
1414} from "@t3tools/contracts" ;
1515import * as NetService from "@t3tools/shared/Net" ;
16+ import { HostProcessEnvironment } from "@t3tools/shared/hostProcess" ;
1617import { assert , it } from "@effect/vitest" ;
1718import * as Effect from "effect/Effect" ;
1819import * as DateTime from "effect/DateTime" ;
@@ -26,6 +27,11 @@ import * as TestConsole from "effect/testing/TestConsole";
2627import { Command } from "effect/unstable/cli" ;
2728
2829import { cli , makeCli } from "./bin.ts" ;
30+ import * as ServiceLauncherClient from "./cloud/serviceLauncherClient.ts" ;
31+ import {
32+ SERVICE_LAUNCHER_CONTEXT_ENV ,
33+ SERVICE_LAUNCHER_PROTOCOL ,
34+ } from "./cloud/serviceProtocol.ts" ;
2935import * as ServerConfig from "./config.ts" ;
3036import * as ServerEnvironment from "./environment/ServerEnvironment.ts" ;
3137import * as ProjectionSnapshotQuery from "./orchestration/Services/ProjectionSnapshotQuery.ts" ;
@@ -43,7 +49,24 @@ import * as ServerSecretStore from "./auth/ServerSecretStore.ts";
4349import * as EnvironmentAuth from "./auth/EnvironmentAuth.ts" ;
4450import { environmentAuthenticatedAuthLayer } from "./auth/http.ts" ;
4551
52+ import packageJson from "../package.json" with { type : "json" } ;
53+
4654const CliRuntimeLayer = Layer . mergeAll ( NodeServices . layer , NetService . layer ) ;
55+ const DisconnectedLauncherChildLayer = Layer . mergeAll (
56+ Layer . succeed ( HostProcessEnvironment , {
57+ ...process . env ,
58+ [ SERVICE_LAUNCHER_CONTEXT_ENV ] : JSON . stringify ( {
59+ protocol : SERVICE_LAUNCHER_PROTOCOL ,
60+ childVersion : packageJson . version ,
61+ } ) ,
62+ } ) ,
63+ Layer . succeed ( ServiceLauncherClient . ServiceLauncherHostProcess , {
64+ connected : false ,
65+ send : ( ) => false ,
66+ on : ( ) => undefined ,
67+ off : ( ) => undefined ,
68+ } ) ,
69+ ) ;
4770class ProjectCliHttpApi extends HttpApi . make ( "environment" ) . add ( EnvironmentOrchestrationHttpApi ) { }
4871
4972const connectCli = makeCli ( { cloudEnabled : true } ) ;
@@ -128,7 +151,7 @@ const withLiveProjectCliServer = <A, E, R>(baseDir: string, run: () => Effect.Ef
128151 Layer . provideMerge (
129152 EnvironmentAuth . layer . pipe (
130153 Layer . provideMerge ( SqlitePersistenceLayerLive ) ,
131- Layer . provide ( ServerEnvironment . layer . pipe ( Layer . provide ( ServerSecretStore . layer ) ) ) ,
154+ Layer . provide ( ServerEnvironment . identityLayer ) ,
132155 Layer . provide ( ServerSecretStore . layer ) ,
133156 ) ,
134157 ) ,
@@ -239,7 +262,7 @@ it.layer(NodeServices.layer)("bin cli parsing", (it) => {
239262 assert . equal ( status . linked , false ) ;
240263 assert . equal ( status . cloudUserId , null ) ;
241264 assert . equal ( status . relayUrl , null ) ;
242- } ) ,
265+ } ) . pipe ( Effect . provide ( DisconnectedLauncherChildLayer ) ) ,
243266 ) ;
244267
245268 it . effect ( "reports actionable human-readable headless connect state" , ( ) =>
@@ -410,7 +433,7 @@ it.layer(NodeServices.layer)("bin cli parsing", (it) => {
410433 "relay:write" ,
411434 ] ) ;
412435 assert . equal ( "token" in ( listed [ 0 ] ?? { } ) , false ) ;
413- } ) ,
436+ } ) . pipe ( Effect . provide ( DisconnectedLauncherChildLayer ) ) ,
414437 ) ;
415438
416439 it . effect ( "rejects invalid ttl values before running auth commands" , ( ) =>
0 commit comments