Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import * as Predicate from "effect/Predicate";
import * as FileSystem from "effect/FileSystem";
import * as Fiber from "effect/Fiber";
import * as Layer from "effect/Layer";
import * as PlatformError from "effect/PlatformError";
import * as Ref from "effect/Ref";
import * as Schema from "effect/Schema";
import * as Stream from "effect/Stream";
Expand All @@ -46,6 +47,10 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";

import * as McpProviderSession from "../../mcp/McpProviderSession.ts";
import type { EventNdjsonLogger } from "../../provider/Layers/EventNdjsonLogger.ts";
import {
NoOpProviderEventLoggers,
ProviderEventLoggers,
} from "../../provider/Layers/ProviderEventLoggers.ts";
import { layer as idAllocatorLayer, IdAllocatorV2 } from "../IdAllocator.ts";
import { OrchestrationEffectWorkerV2 } from "../EffectWorker.ts";
import { OrchestratorV2 } from "../Orchestrator.ts";
Expand All @@ -68,6 +73,8 @@ import {
codexFileChangeApprovalPrompt,
codexProviderTurnTokenUsage,
codexThreadRuntimeParams,
CodexAppServerClientFactory,
codexAppServerClientFactoryFromSettingsLayer,
type CodexAppServerClientFactoryShape,
makeCodexAdapterV2,
makeCodexAppServerProtocolLogger,
Expand Down Expand Up @@ -695,6 +702,49 @@ describe("CodexAdapterV2 process spawning", () => {
Effect.provideService(SpawnExecutableResolution, () => "C:\\bin\\codex.exe"),
),
);

it.effect("launches the app-server with the configured launch arguments", () =>
Effect.gen(function* () {
const spawnedArgs: Array<ReadonlyArray<string>> = [];
const spawner = ChildProcessSpawner.make((command) => {
if (ChildProcess.isStandardCommand(command)) spawnedArgs.push(command.args);
return Effect.fail(
PlatformError.systemError({ _tag: "NotFound", module: "ChildProcess", method: "spawn" }),
);
});
const factory = yield* CodexAppServerClientFactory.pipe(
Effect.provide(codexAppServerClientFactoryFromSettingsLayer),
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
Effect.provideService(ProviderEventLoggers, NoOpProviderEventLoggers),
);
const open = (environment: NodeJS.ProcessEnv) =>
factory
.open({
instanceId: CODEX_DEFAULT_INSTANCE_ID,
threadId: ThreadId.make("thread-launch-args"),
providerSessionId: ProviderSessionId.make("provider-session-launch-args"),
runtimePolicy: ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace",
}),
settings: {
...DEFAULT_CODEX_SETTINGS,
launchArgs: " --strict-config -c model_reasoning_summary=detailed ",
},
environment,
})
.pipe(Effect.scoped, Effect.exit);

yield* open({});
yield* open({ T3CODE_CODEX_LAUNCH_ARGS: " --enable env-feature " });

assert.deepEqual(spawnedArgs, [
["app-server", "--strict-config", "-c", "model_reasoning_summary=detailed"],
["app-server", "--enable", "env-feature"],
]);
}).pipe(Effect.provideService(HostProcessPlatform, "linux")),
);
});

describe("CodexAdapterV2 dynamic tool projection", () => {
Expand Down
8 changes: 7 additions & 1 deletion apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ import {
shouldPersistProviderEvent,
} from "../../provider/Layers/EventNdjsonLogger.ts";
import { ProviderEventLoggers } from "../../provider/Layers/ProviderEventLoggers.ts";
import {
codexAppServerArgs,
resolveCodexLaunchArgs,
} from "../../provider/Layers/codexLaunchArgs.ts";
import { mergeProviderInstanceEnvironment } from "../../provider/ProviderInstanceEnvironment.ts";
import * as McpProviderSession from "../../mcp/McpProviderSession.ts";
import {
Expand Down Expand Up @@ -1325,7 +1329,9 @@ export const codexAppServerClientFactoryFromSettingsLayer: Layer.Layer<
};
const command = yield* makeCodexAppServerSpawnCommand({
command: input.settings.binaryPath || "codex",
args: ["app-server"],
args: codexAppServerArgs(
resolveCodexLaunchArgs(input.settings.launchArgs, input.environment),
),
env: environment,
});
const handle = yield* spawner.spawn(command).pipe(
Expand Down
Loading