fix(server): use CLI for OpenCode health check instead of spawning server (#4153)
This commit is contained in:
1 parent
f4da4f3b40
commit
0ca3240691
6 files changed
+466
-21
No files matched your search
@@ -221,6 +221,14 @@ const OpenCodeRuntimeTestDouble: OpenCodeRuntimeShape = {
|
||||
cause: null,
|
||||
}),
|
||||
),
|
||||
loadInventoryFromCli: () =>
|
||||
Effect.fail(
|
||||
new OpenCodeRuntimeError({
|
||||
operation: "loadInventoryFromCli",
|
||||
detail: "OpenCodeRuntimeTestDouble.loadInventoryFromCli not used in this test",
|
||||
cause: null,
|
||||
}),
|
||||
),
|
||||
};
|
||||
|
||||
const providerSessionDirectoryTestLayer = Layer.succeed(ProviderSessionDirectory, {
|
||||
|
||||
@@ -95,6 +95,13 @@ const OpenCodeRuntimeTestDouble: OpenCodeRuntimeShape = {
|
||||
}),
|
||||
)
|
||||
: Effect.succeed(runtimeMock.state.inventory as OpenCodeInventory),
|
||||
loadInventoryFromCli: () =>
|
||||
runtimeMock.state.inventoryError
|
||||
? Effect.succeed({
|
||||
providerList: { all: [], default: {}, connected: [] as string[] },
|
||||
agents: [],
|
||||
} as OpenCodeInventory)
|
||||
: Effect.succeed(runtimeMock.state.inventory as OpenCodeInventory),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -197,11 +204,22 @@ it.layer(testLayer)("checkOpenCodeProviderStatus", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("closes the local OpenCode server scope after provider refresh", () =>
|
||||
it.effect("does not spawn a local server for health check (uses CLI instead)", () =>
|
||||
Effect.gen(function* () {
|
||||
yield* checkOpenCodeProviderStatus(makeOpenCodeSettings(), process.cwd());
|
||||
|
||||
NodeAssert.equal(runtimeMock.state.closeCalls, 1);
|
||||
NodeAssert.equal(runtimeMock.state.closeCalls, 0);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("degrades gracefully on CLI failure for local installs", () =>
|
||||
Effect.gen(function* () {
|
||||
runtimeMock.state.inventoryError = new Error("opencode models failed");
|
||||
const snapshot = yield* checkOpenCodeProviderStatus(makeOpenCodeSettings(), process.cwd());
|
||||
|
||||
NodeAssert.equal(snapshot.status, "warning");
|
||||
NodeAssert.equal(snapshot.installed, true);
|
||||
NodeAssert.equal(snapshot.models.length, 0);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -409,26 +409,32 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
|
||||
}
|
||||
|
||||
const inventoryExit = yield* Effect.exit(
|
||||
Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const server = yield* openCodeRuntime.connectToOpenCodeServer({
|
||||
binaryPath: openCodeSettings.binaryPath,
|
||||
serverUrl: openCodeSettings.serverUrl,
|
||||
environment: resolvedEnvironment,
|
||||
});
|
||||
return yield* openCodeRuntime.loadOpenCodeInventory(
|
||||
openCodeRuntime.createOpenCodeSdkClient({
|
||||
baseUrl: server.url,
|
||||
directory: cwd,
|
||||
...(isExternalServer && openCodeSettings.serverPassword
|
||||
? { serverPassword: openCodeSettings.serverPassword }
|
||||
: {}),
|
||||
(isExternalServer
|
||||
? Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
const server = yield* openCodeRuntime.connectToOpenCodeServer({
|
||||
binaryPath: openCodeSettings.binaryPath,
|
||||
serverUrl: openCodeSettings.serverUrl,
|
||||
environment: resolvedEnvironment,
|
||||
});
|
||||
return yield* openCodeRuntime.loadOpenCodeInventory(
|
||||
openCodeRuntime.createOpenCodeSdkClient({
|
||||
baseUrl: server.url,
|
||||
directory: cwd,
|
||||
...(openCodeSettings.serverPassword
|
||||
? { serverPassword: openCodeSettings.serverPassword }
|
||||
: {}),
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}).pipe(
|
||||
Effect.mapError(
|
||||
(cause) => new OpenCodeProbeError({ cause, detail: openCodeRuntimeErrorDetail(cause) }),
|
||||
),
|
||||
)
|
||||
: openCodeRuntime.loadInventoryFromCli({
|
||||
binaryPath: openCodeSettings.binaryPath,
|
||||
environment: resolvedEnvironment,
|
||||
})
|
||||
).pipe(
|
||||
Effect.mapError(
|
||||
(cause) => new OpenCodeProbeError({ cause, detail: openCodeRuntimeErrorDetail(cause) }),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
import * as NodeAssert from "node:assert/strict";
|
||||
|
||||
import { describe, it } from "vite-plus/test";
|
||||
|
||||
import { parseModelsCliOutput, parseAgentListCliOutput } from "./opencodeRuntime.ts";
|
||||
|
||||
describe("parseModelsCliOutput", () => {
|
||||
it("parses a single model from a single provider", () => {
|
||||
const stdout = [
|
||||
"anthropic/claude-sonnet-4-5",
|
||||
JSON.stringify({
|
||||
id: "claude-sonnet-4-5",
|
||||
providerID: "anthropic",
|
||||
name: "Claude Sonnet 4.5",
|
||||
capabilities: { temperature: true, reasoning: true, toolcall: true },
|
||||
cost: { input: 3, output: 15 },
|
||||
limit: { context: 200000, output: 8192 },
|
||||
status: "active",
|
||||
options: {},
|
||||
headers: {},
|
||||
release_date: "2025-01-01",
|
||||
}),
|
||||
].join("\n");
|
||||
|
||||
const result = parseModelsCliOutput(stdout);
|
||||
NodeAssert.equal(result.providers.size, 1);
|
||||
NodeAssert.equal(result.connected.length, 1);
|
||||
NodeAssert.equal(result.connected[0], "anthropic");
|
||||
|
||||
const provider = result.providers.get("anthropic")!;
|
||||
NodeAssert.ok(provider);
|
||||
NodeAssert.equal(provider.id, "anthropic");
|
||||
NodeAssert.equal(provider.name, "anthropic");
|
||||
NodeAssert.equal(Object.keys(provider.models).length, 1);
|
||||
|
||||
const model = provider.models["claude-sonnet-4-5"]!;
|
||||
NodeAssert.ok(model);
|
||||
NodeAssert.equal(model.id, "claude-sonnet-4-5");
|
||||
NodeAssert.equal(model.providerID, "anthropic");
|
||||
NodeAssert.equal(model.name, "Claude Sonnet 4.5");
|
||||
});
|
||||
|
||||
it("parses multiple models from multiple providers", () => {
|
||||
const stdout = [
|
||||
"anthropic/claude-sonnet-4-5",
|
||||
JSON.stringify({ id: "claude-sonnet-4-5", providerID: "anthropic", name: "Sonnet 4.5" }),
|
||||
"anthropic/claude-haiku-4-5",
|
||||
JSON.stringify({ id: "claude-haiku-4-5", providerID: "anthropic", name: "Haiku 4.5" }),
|
||||
"openai/gpt-4o",
|
||||
JSON.stringify({ id: "gpt-4o", providerID: "openai", name: "GPT-4o" }),
|
||||
].join("\n");
|
||||
|
||||
const result = parseModelsCliOutput(stdout);
|
||||
NodeAssert.equal(result.providers.size, 2);
|
||||
NodeAssert.equal(result.connected.length, 2);
|
||||
NodeAssert.equal([...result.connected].sort().join(","), "anthropic,openai");
|
||||
NodeAssert.equal(Object.keys(result.providers.get("anthropic")!.models).length, 2);
|
||||
NodeAssert.equal(Object.keys(result.providers.get("openai")!.models).length, 1);
|
||||
});
|
||||
|
||||
it("handles empty input", () => {
|
||||
const result = parseModelsCliOutput("");
|
||||
NodeAssert.equal(result.providers.size, 0);
|
||||
NodeAssert.equal(result.connected.length, 0);
|
||||
});
|
||||
|
||||
it("skips unparseable JSON blocks", () => {
|
||||
const stdout = [
|
||||
"anthropic/claude-sonnet-4-5",
|
||||
"this is not valid json {{{",
|
||||
"anthropic/claude-haiku-4-5",
|
||||
JSON.stringify({ id: "claude-haiku-4-5", providerID: "anthropic", name: "Haiku 4.5" }),
|
||||
].join("\n");
|
||||
|
||||
const result = parseModelsCliOutput(stdout);
|
||||
NodeAssert.equal(result.providers.size, 1);
|
||||
const provider = result.providers.get("anthropic")!;
|
||||
NodeAssert.equal(Object.keys(provider.models).length, 1);
|
||||
NodeAssert.ok(provider.models["claude-haiku-4-5"]);
|
||||
});
|
||||
|
||||
it("handles Windows-style CRLF line endings", () => {
|
||||
const stdout =
|
||||
"anthropic/claude-sonnet-4-5\r\n" +
|
||||
JSON.stringify({ id: "claude-sonnet-4-5", providerID: "anthropic", name: "Sonnet" }) +
|
||||
"\r\n";
|
||||
|
||||
const result = parseModelsCliOutput(stdout);
|
||||
NodeAssert.equal(result.providers.size, 1);
|
||||
NodeAssert.ok(result.providers.get("anthropic")!.models["claude-sonnet-4-5"]);
|
||||
});
|
||||
|
||||
it("handles model JSON with variants and nested fields", () => {
|
||||
const stdout = [
|
||||
"opencode/gpt-5.4",
|
||||
JSON.stringify({
|
||||
id: "gpt-5.4",
|
||||
providerID: "opencode",
|
||||
name: "GPT-5.4",
|
||||
family: "gpt",
|
||||
capabilities: {
|
||||
temperature: true,
|
||||
reasoning: true,
|
||||
attachment: false,
|
||||
toolcall: true,
|
||||
input: { text: true, audio: false, image: false, video: false, pdf: false },
|
||||
output: { text: true, audio: false, image: false, video: false, pdf: false },
|
||||
interleaved: false,
|
||||
},
|
||||
cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
|
||||
limit: { context: 200000, input: 160000, output: 32000 },
|
||||
status: "active",
|
||||
options: {},
|
||||
headers: {},
|
||||
release_date: "2025-01-01",
|
||||
variants: { none: {}, low: {}, medium: {}, high: {} },
|
||||
}),
|
||||
].join("\n");
|
||||
|
||||
const result = parseModelsCliOutput(stdout);
|
||||
const model = result.providers.get("opencode")!.models["gpt-5.4"]!;
|
||||
NodeAssert.ok(model);
|
||||
NodeAssert.ok(model.capabilities);
|
||||
NodeAssert.equal(model.capabilities!.reasoning, true);
|
||||
NodeAssert.ok(model.variants);
|
||||
NodeAssert.equal(model.variants!["medium"] !== undefined, true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseAgentListCliOutput", () => {
|
||||
it("parses a single agent", () => {
|
||||
const stdout = [
|
||||
"build (primary)",
|
||||
" " + JSON.stringify([{ permission: "*", action: "allow", pattern: "*" }]),
|
||||
].join("\n");
|
||||
|
||||
const result = parseAgentListCliOutput(stdout);
|
||||
NodeAssert.equal(result.length, 1);
|
||||
NodeAssert.equal(result[0]!.name, "build");
|
||||
NodeAssert.equal(result[0]!.mode, "primary");
|
||||
NodeAssert.equal(result[0]!.permission.length, 1);
|
||||
});
|
||||
|
||||
it("parses multiple agents", () => {
|
||||
const stdout = [
|
||||
"build (primary)",
|
||||
" " + JSON.stringify([{ permission: "*", action: "allow", pattern: "*" }]),
|
||||
"explore (subagent)",
|
||||
" " + JSON.stringify([{ permission: "read", action: "allow", pattern: "*" }]),
|
||||
"plan (primary)",
|
||||
" " + JSON.stringify([{ permission: "edit", action: "ask", pattern: "*.md" }]),
|
||||
].join("\n");
|
||||
|
||||
const result = parseAgentListCliOutput(stdout);
|
||||
NodeAssert.equal(result.length, 3);
|
||||
NodeAssert.equal(result[0]!.name, "build");
|
||||
NodeAssert.equal(result[0]!.mode, "primary");
|
||||
NodeAssert.equal(result[1]!.name, "explore");
|
||||
NodeAssert.equal(result[1]!.mode, "subagent");
|
||||
NodeAssert.equal(result[2]!.name, "plan");
|
||||
NodeAssert.equal(result[2]!.mode, "primary");
|
||||
});
|
||||
|
||||
it("handles empty input", () => {
|
||||
const result = parseAgentListCliOutput("");
|
||||
NodeAssert.equal(result.length, 0);
|
||||
});
|
||||
|
||||
it("skips agents with unparseable permission JSON", () => {
|
||||
const stdout = [
|
||||
"build (primary)",
|
||||
" not valid json {",
|
||||
"explore (subagent)",
|
||||
" " + JSON.stringify([{ permission: "read", action: "allow", pattern: "*" }]),
|
||||
].join("\n");
|
||||
|
||||
const result = parseAgentListCliOutput(stdout);
|
||||
NodeAssert.equal(result.length, 1);
|
||||
NodeAssert.equal(result[0]!.name, "explore");
|
||||
});
|
||||
|
||||
it("handles real-world permission blocks with nested paths", () => {
|
||||
const permissions = [
|
||||
{ permission: "*", action: "allow", pattern: "*" },
|
||||
{
|
||||
permission: "external_directory",
|
||||
pattern: "C:\\Users\\test\\.local\\*",
|
||||
action: "allow",
|
||||
},
|
||||
{ permission: "read", pattern: "*.env", action: "ask" },
|
||||
];
|
||||
const stdout = ["build (primary)", " " + JSON.stringify(permissions)].join("\n");
|
||||
|
||||
const result = parseAgentListCliOutput(stdout);
|
||||
NodeAssert.equal(result.length, 1);
|
||||
NodeAssert.equal(result[0]!.permission.length, 3);
|
||||
NodeAssert.equal(result[0]!.permission[0]!.action, "allow");
|
||||
NodeAssert.equal(result[0]!.permission[2]!.action, "ask");
|
||||
});
|
||||
|
||||
it("handles agent names with spaces", () => {
|
||||
const stdout = [
|
||||
"code reviewer (subagent)",
|
||||
" " + JSON.stringify([{ permission: "read", action: "allow", pattern: "*" }]),
|
||||
"my custom agent (primary)",
|
||||
" " + JSON.stringify([{ permission: "edit", action: "ask", pattern: "*.ts" }]),
|
||||
].join("\n");
|
||||
|
||||
const result = parseAgentListCliOutput(stdout);
|
||||
NodeAssert.equal(result.length, 2);
|
||||
NodeAssert.equal(result[0]!.name, "code reviewer");
|
||||
NodeAssert.equal(result[0]!.mode, "subagent");
|
||||
NodeAssert.equal(result[1]!.name, "my custom agent");
|
||||
NodeAssert.equal(result[1]!.mode, "primary");
|
||||
});
|
||||
|
||||
it("marks known hidden agents", () => {
|
||||
const stdout = [
|
||||
"compaction (primary)",
|
||||
" " + JSON.stringify([{ permission: "*", action: "allow", pattern: "*" }]),
|
||||
"build (primary)",
|
||||
" " + JSON.stringify([{ permission: "*", action: "allow", pattern: "*" }]),
|
||||
].join("\n");
|
||||
|
||||
const result = parseAgentListCliOutput(stdout);
|
||||
NodeAssert.equal(result[0]!.hidden, true);
|
||||
NodeAssert.equal(result[1]!.hidden, false);
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
createOpencodeClient,
|
||||
type Agent,
|
||||
type FilePartInput,
|
||||
type Model,
|
||||
type OpencodeClient,
|
||||
type PermissionRuleset,
|
||||
type ProviderListResponse,
|
||||
@@ -147,6 +148,10 @@ export interface OpenCodeRuntimeShape {
|
||||
readonly loadOpenCodeInventory: (
|
||||
client: OpencodeClient,
|
||||
) => Effect.Effect<OpenCodeInventory, OpenCodeRuntimeError>;
|
||||
readonly loadInventoryFromCli: (input: {
|
||||
readonly binaryPath: string;
|
||||
readonly environment?: NodeJS.ProcessEnv;
|
||||
}) => Effect.Effect<OpenCodeInventory, OpenCodeRuntimeError>;
|
||||
}
|
||||
|
||||
function parseServerUrlFromOutput(output: string): string | null {
|
||||
@@ -160,6 +165,113 @@ function parseServerUrlFromOutput(output: string): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
const SLUG_LINE_RE = /^(\S+\/\S+)\s*$/;
|
||||
const AGENT_HEADER_RE = /^(.+)\s+\((\S+)\)\s*$/;
|
||||
|
||||
// Agents that are always hidden in OpenCode but the CLI "agent list" command
|
||||
// does not expose the hidden flag. Keep in sync with OpenCode agent
|
||||
// definitions (in the OpenCode repo: packages/opencode/src/agent/agent.ts).
|
||||
const KNOWN_HIDDEN_AGENTS = new Set(["compaction", "summary", "title"]);
|
||||
|
||||
/** @internal */
|
||||
export function parseModelsCliOutput(stdout: string): {
|
||||
readonly providers: ReadonlyMap<
|
||||
string,
|
||||
{ readonly id: string; readonly name: string; readonly models: { [key: string]: Model } }
|
||||
>;
|
||||
readonly connected: ReadonlyArray<string>;
|
||||
} {
|
||||
const providers = new Map<
|
||||
string,
|
||||
{ id: string; name: string; models: { [key: string]: Model } }
|
||||
>();
|
||||
const lines = stdout.split("\n");
|
||||
let currentSlug: string | null = null;
|
||||
const jsonLines: Array<string> = [];
|
||||
|
||||
const flushModel = () => {
|
||||
if (currentSlug !== null && jsonLines.length > 0) {
|
||||
const jsonStr = jsonLines.join("\n").trim();
|
||||
if (jsonStr.length > 0) {
|
||||
try {
|
||||
const model = JSON.parse(jsonStr) as Model;
|
||||
const separator = currentSlug.indexOf("/");
|
||||
if (separator > 0) {
|
||||
const providerID = currentSlug.slice(0, separator);
|
||||
const modelID = currentSlug.slice(separator + 1);
|
||||
let provider = providers.get(providerID);
|
||||
if (!provider) {
|
||||
provider = { id: providerID, name: providerID, models: {} };
|
||||
providers.set(providerID, provider);
|
||||
}
|
||||
provider.models[modelID] = model;
|
||||
}
|
||||
} catch {
|
||||
// Skip unparseable model JSON
|
||||
}
|
||||
}
|
||||
}
|
||||
currentSlug = null;
|
||||
jsonLines.length = 0;
|
||||
};
|
||||
|
||||
for (const line of lines) {
|
||||
const slugMatch = SLUG_LINE_RE.exec(line);
|
||||
if (slugMatch) {
|
||||
flushModel();
|
||||
currentSlug = slugMatch[1]!;
|
||||
} else if (currentSlug !== null) {
|
||||
jsonLines.push(line);
|
||||
}
|
||||
}
|
||||
flushModel();
|
||||
|
||||
return { providers, connected: [...providers.keys()] };
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function parseAgentListCliOutput(stdout: string): ReadonlyArray<Agent> {
|
||||
const agents: Array<Agent> = [];
|
||||
const lines = stdout.split("\n");
|
||||
let currentHeader: { name: string; mode: string } | null = null;
|
||||
const blockLines: Array<string> = [];
|
||||
|
||||
const flushAgent = () => {
|
||||
if (currentHeader !== null) {
|
||||
const jsonStr = blockLines.join("\n").trim();
|
||||
if (jsonStr.length > 0) {
|
||||
try {
|
||||
const permission = JSON.parse(jsonStr);
|
||||
agents.push({
|
||||
name: currentHeader.name,
|
||||
mode: currentHeader.mode as Agent["mode"],
|
||||
hidden: KNOWN_HIDDEN_AGENTS.has(currentHeader.name),
|
||||
permission,
|
||||
options: {},
|
||||
});
|
||||
} catch {
|
||||
// Skip unparseable agent
|
||||
}
|
||||
}
|
||||
}
|
||||
currentHeader = null;
|
||||
blockLines.length = 0;
|
||||
};
|
||||
|
||||
for (const line of lines) {
|
||||
const match = AGENT_HEADER_RE.exec(line);
|
||||
if (match) {
|
||||
flushAgent();
|
||||
currentHeader = { name: match[1]!, mode: match[2]! };
|
||||
} else if (currentHeader !== null) {
|
||||
blockLines.push(line);
|
||||
}
|
||||
}
|
||||
flushAgent();
|
||||
|
||||
return agents;
|
||||
}
|
||||
|
||||
export function parseOpenCodeModelSlug(
|
||||
slug: string | null | undefined,
|
||||
): ParsedOpenCodeModelSlug | null {
|
||||
@@ -542,12 +654,76 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
|
||||
Effect.map(([providerList, agents]) => ({ providerList, agents })),
|
||||
);
|
||||
|
||||
const loadInventoryFromCli: OpenCodeRuntimeShape["loadInventoryFromCli"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const env = input.environment !== undefined ? { environment: input.environment } : ({} as {});
|
||||
|
||||
const runModelsCli = () =>
|
||||
runOpenCodeCommand({
|
||||
binaryPath: input.binaryPath,
|
||||
args: ["models", "--verbose"],
|
||||
...env,
|
||||
}).pipe(Effect.exit);
|
||||
const runAgentsCli = () =>
|
||||
runOpenCodeCommand({ binaryPath: input.binaryPath, args: ["agent", "list"], ...env }).pipe(
|
||||
Effect.exit,
|
||||
);
|
||||
|
||||
// First attempt — run both in parallel
|
||||
let [modelsResult, agentsResult] = yield* Effect.all([runModelsCli(), runAgentsCli()], {
|
||||
concurrency: "unbounded",
|
||||
});
|
||||
|
||||
// Retry once after 1s on transient failures (e.g. SQLite "database is locked")
|
||||
const needsModelsRetry = modelsResult._tag === "Failure" || modelsResult.value.code !== 0;
|
||||
const needsAgentsRetry = agentsResult._tag === "Failure" || agentsResult.value.code !== 0;
|
||||
if (needsModelsRetry || needsAgentsRetry) {
|
||||
yield* Effect.sleep("1 second");
|
||||
const [m2, a2] = yield* Effect.all(
|
||||
[
|
||||
needsModelsRetry ? runModelsCli() : Effect.succeed(modelsResult),
|
||||
needsAgentsRetry ? runAgentsCli() : Effect.succeed(agentsResult),
|
||||
],
|
||||
{ concurrency: "unbounded" },
|
||||
);
|
||||
modelsResult = m2;
|
||||
agentsResult = a2;
|
||||
}
|
||||
|
||||
// Degrade gracefully on failure — return empty inventory (warning status, not error)
|
||||
let connected: string[] = [];
|
||||
let allProviders: ProviderListResponse["all"] = [];
|
||||
if (modelsResult._tag === "Success" && modelsResult.value.code === 0) {
|
||||
const parsed = parseModelsCliOutput(modelsResult.value.stdout);
|
||||
connected = [...parsed.connected];
|
||||
allProviders = [...parsed.providers.values()].map((p) => ({
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
source: "config" as const,
|
||||
env: [],
|
||||
options: {},
|
||||
models: p.models,
|
||||
}));
|
||||
}
|
||||
|
||||
let agents: ReadonlyArray<Agent> = [];
|
||||
if (agentsResult._tag === "Success" && agentsResult.value.code === 0) {
|
||||
agents = parseAgentListCliOutput(agentsResult.value.stdout);
|
||||
}
|
||||
|
||||
return {
|
||||
providerList: { all: allProviders, default: {}, connected },
|
||||
agents,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
startOpenCodeServerProcess,
|
||||
connectToOpenCodeServer,
|
||||
runOpenCodeCommand,
|
||||
createOpenCodeSdkClient,
|
||||
loadOpenCodeInventory,
|
||||
loadInventoryFromCli,
|
||||
} satisfies OpenCodeRuntimeShape;
|
||||
});
|
||||
|
||||
|
||||
@@ -107,6 +107,14 @@ const OpenCodeRuntimeTestDouble: OpenCodeRuntime.OpenCodeRuntimeShape = {
|
||||
cause: null,
|
||||
}),
|
||||
),
|
||||
loadInventoryFromCli: () =>
|
||||
Effect.fail(
|
||||
new OpenCodeRuntime.OpenCodeRuntimeError({
|
||||
operation: "loadInventoryFromCli",
|
||||
detail: "OpenCodeRuntimeTestDouble.loadInventoryFromCli not used in this test",
|
||||
cause: null,
|
||||
}),
|
||||
),
|
||||
};
|
||||
|
||||
const DEFAULT_TEST_MODEL_SELECTION = {
|
||||
|
||||
Reference in new issue
Block a user