@@ -2,9 +2,9 @@ import * as FileSystem from "@effect/platform/FileSystem"
22import * as Path from "@effect/platform/Path"
33import { Effect } from "effect"
44
5- import { decodeAuthSnapshot , decodeProjectAuthSnapshot } from "./api-auth-codec .js"
5+ import { readProjectOutput , resolveCreateRequestPaths } from "./api-client-helpers .js"
66import { request , requestTextStream , requestVoid } from "./api-http.js"
7- import { asArray , asObject , asString , type JsonRequest , type JsonValue } from "./api-json.js"
7+ import { asArray , asObject , type JsonRequest } from "./api-json.js"
88import { decodeProjectDetails , decodeProjectSummary } from "./api-project-codec.js"
99import { decodeTerminalSession } from "./api-terminal-codec.js"
1010import type {
@@ -66,11 +66,6 @@ const codexLoginFailureMessage = (output: string, exitCode: string | null): stri
6666 : `Codex login failed (${ exitCode } ).`
6767}
6868
69- const readProjectOutput = ( payload : JsonValue ) : string => {
70- const object = asObject ( payload )
71- return asString ( object ?. [ "output" ] ) ?? ""
72- }
73-
7469export const listProjects = ( ) =>
7570 request ( "GET" , "/projects" ) . pipe (
7671 Effect . map ( ( payload ) => {
@@ -93,6 +88,7 @@ export const getProject = (projectId: string) =>
9388export const createProject = ( command : CreateCommand ) =>
9489 Effect . gen ( function * ( _ ) {
9590 const config = command . config
91+ const resolvedPaths = yield * _ ( resolveCreateRequestPaths ( command ) )
9692 const body = {
9793 repoUrl : config . repoUrl ,
9894 repoRef : config . repoRef ,
@@ -102,6 +98,11 @@ export const createProject = (command: CreateCommand) =>
10298 containerName : config . containerName ,
10399 serviceName : config . serviceName ,
104100 volumeName : config . volumeName ,
101+ authorizedKeysPath : resolvedPaths . authorizedKeysPath ,
102+ envGlobalPath : config . envGlobalPath ,
103+ envProjectPath : config . envProjectPath ,
104+ codexAuthPath : config . codexAuthPath ,
105+ codexHome : config . codexHome ,
105106 cpuLimit : config . cpuLimit ,
106107 ramLimit : config . ramLimit ,
107108 dockerNetworkMode : config . dockerNetworkMode ,
@@ -166,44 +167,6 @@ export const createAuthTerminalSession = (
166167
167168export const deleteTerminalSessionByPath = ( path : string ) => requestVoid ( "DELETE" , path )
168169
169- export const loadAuthSnapshot = ( ) =>
170- request ( "GET" , "/auth/menu" ) . pipe (
171- Effect . map ( ( payload ) => decodeAuthSnapshot ( payload ) )
172- )
173-
174- export const runAuthMenuFlow = ( requestBody : {
175- readonly flow : string
176- readonly label ?: string | null
177- readonly token ?: string | null
178- readonly user ?: string | null
179- readonly apiKey ?: string | null
180- } ) =>
181- request ( "POST" , "/auth/menu" , {
182- flow : requestBody . flow ,
183- label : requestBody . label ?? undefined ,
184- token : requestBody . token ?? undefined ,
185- user : requestBody . user ?? undefined ,
186- apiKey : requestBody . apiKey ?? undefined
187- } ) . pipe (
188- Effect . map ( ( payload ) => decodeAuthSnapshot ( payload ) )
189- )
190-
191- export const loadProjectAuthSnapshot = ( projectId : string ) =>
192- request ( "GET" , projectPath ( projectId , "/auth/menu" ) ) . pipe (
193- Effect . map ( ( payload ) => decodeProjectAuthSnapshot ( payload ) )
194- )
195-
196- export const runProjectAuthFlow = (
197- projectId : string ,
198- requestBody : { readonly flow : string ; readonly label ?: string | null }
199- ) =>
200- request ( "POST" , projectPath ( projectId , "/auth/menu" ) , {
201- flow : requestBody . flow ,
202- label : requestBody . label ?? undefined
203- } ) . pipe (
204- Effect . map ( ( payload ) => decodeProjectAuthSnapshot ( payload ) )
205- )
206-
207170export const applyAllProjects = ( activeOnly : boolean ) => requestVoid ( "POST" , "/projects/apply-all" , { activeOnly } )
208171
209172export const downAllProjects = ( ) => requestVoid ( "POST" , "/projects/down-all" )
0 commit comments