Skip to content
Open
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
7 changes: 6 additions & 1 deletion apps/server/src/provider/Layers/CodexProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { ServerSettingsError } from "@t3tools/contracts";
import { createModelCapabilities } from "@t3tools/shared/model";
import { buildServerProvider, type ServerProviderDraft } from "../providerSnapshot.ts";
import { expandHomePath } from "../../pathExpansion.ts";
import { ServerConfig } from "../../config.ts";
import { scopedSafeTeardown } from "./scopedSafeTeardown.ts";
import packageJson from "../../../package.json" with { type: "json" };
const isCodexAppServerSpawnError = Schema.is(CodexErrors.CodexAppServerSpawnError);
Expand Down Expand Up @@ -421,6 +422,7 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
ServerSettingsError,
ChildProcessSpawner.ChildProcessSpawner
> {
const serverConfig = yield* Effect.serviceOption(ServerConfig);
const checkedAt = DateTime.formatIso(yield* DateTime.now);
const emptyModels = emptyCodexModelsFromSettings(codexSettings);

Expand All @@ -444,7 +446,10 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
const probeResult = yield* probe({
binaryPath: codexSettings.binaryPath,
homePath: codexSettings.homePath,
cwd: process.cwd(),
cwd: Option.match(serverConfig, {
onNone: () => process.cwd(),
onSome: (config) => config.cwd,
}),
customModels: codexSettings.customModels,
environment,
}).pipe(Effect.timeoutOption(Duration.millis(PROVIDER_PROBE_TIMEOUT_MS)), Effect.result);
Expand Down
22 changes: 22 additions & 0 deletions apps/server/src/provider/Layers/ProviderRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,28 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsService.layerTest(), T
"ProviderRegistry",
(it) => {
describe("checkCodexProviderStatus", () => {
it.effect("uses configured server cwd for Codex skill discovery when available", () => {
const configuredCwd = `${process.cwd()}-provider-cwd`;
const requestedInputs: Array<{ readonly cwd: string }> = [];

return checkCodexProviderStatus(defaultCodexSettings, (input) => {
requestedInputs.push({ cwd: input.cwd });
return Effect.succeed(makeCodexProbeSnapshot());
}).pipe(
Effect.tap(() =>
Effect.sync(() => {
assert.deepStrictEqual(requestedInputs, [{ cwd: configuredCwd }]);
}),
),
Effect.provide(
Layer.provideMerge(
ServerConfig.layerTest(configuredCwd, { prefix: "t3-provider-registry-" }),
NodeServices.layer,
),
),
);
});

it.effect("uses the app-server account and model list for provider status", () =>
Effect.gen(function* () {
const status = yield* checkCodexProviderStatus(defaultCodexSettings, () =>
Expand Down
Loading