fix(hwlab): expose d518 code agent runtime config

This commit is contained in:
Codex
2026-06-27 16:04:20 +00:00
parent f8f0741073
commit 4227211544
5 changed files with 316 additions and 9 deletions
+42
View File
@@ -313,6 +313,19 @@ export interface HwlabRuntimeCodeAgentProviderSpec {
readonly opencodeSourceKey?: string;
}
export interface HwlabRuntimeCodeAgentRuntimeSpec {
readonly enabled: boolean;
readonly adapter: string;
readonly managerUrl: string;
readonly apiKeySecretName: string;
readonly apiKeySecretKey: string;
readonly runnerNamespace: string;
readonly secretNamespace: string;
readonly repoUrlFrom: "runtimeGitReadUrl";
readonly providerIdFrom: "runtimeNodeId";
readonly defaultProviderProfile: string;
}
export interface HwlabRuntimeSourceWorkspaceSpec {
readonly requiredCommands: readonly string[];
readonly requiredFiles: readonly string[];
@@ -361,6 +374,7 @@ export interface HwlabRuntimeLaneSpec {
readonly buildkit?: HwlabRuntimeBuildkitSpec;
readonly bootstrapAdmin?: HwlabRuntimeBootstrapAdminSpec;
readonly codeAgentProvider?: HwlabRuntimeCodeAgentProviderSpec;
readonly codeAgentRuntime?: HwlabRuntimeCodeAgentRuntimeSpec;
readonly sourceWorkspace?: HwlabRuntimeSourceWorkspaceSpec;
readonly externalPostgres?: HwlabRuntimeExternalPostgresSpec;
readonly runtimeStore?: HwlabRuntimeStoreSpec;
@@ -412,6 +426,7 @@ interface HwlabLaneConfig {
readonly buildkit?: HwlabRuntimeBuildkitSpec;
readonly bootstrapAdmin?: HwlabRuntimeBootstrapAdminSpec;
readonly codeAgentProvider?: HwlabRuntimeCodeAgentProviderSpec;
readonly codeAgentRuntime?: HwlabRuntimeCodeAgentRuntimeSpec;
readonly sourceWorkspace?: HwlabRuntimeSourceWorkspaceSpec;
readonly externalPostgres?: HwlabRuntimeExternalPostgresSpec;
readonly runtimeStore?: HwlabRuntimeStoreSpec;
@@ -655,6 +670,7 @@ function laneConfig(id: HwlabRuntimeLane, raw: Record<string, unknown>): HwlabLa
buildkit: buildkitConfig(raw.buildkit, `lanes.${id}.buildkit`),
bootstrapAdmin: bootstrapAdminConfig(raw.bootstrapAdmin, `lanes.${id}.bootstrapAdmin`),
codeAgentProvider: codeAgentProviderConfig(raw.codeAgentProvider, `lanes.${id}.codeAgentProvider`),
codeAgentRuntime: codeAgentRuntimeConfig(raw.codeAgentRuntime, `lanes.${id}.codeAgentRuntime`),
sourceWorkspace: sourceWorkspaceConfig(raw.sourceWorkspace, `lanes.${id}.sourceWorkspace`),
externalPostgres: externalPostgresConfig(raw.externalPostgres, `lanes.${id}.externalPostgres`),
runtimeStore: runtimeStoreConfig(raw.runtimeStore, `lanes.${id}.runtimeStore`),
@@ -679,6 +695,7 @@ function laneTargetConfig(id: HwlabRuntimeLane, nodeId: string, baseRaw: Record<
buildkit: mergeOptionalRecord(baseRaw.buildkit, targetRaw.buildkit),
bootstrapAdmin: mergeOptionalRecord(baseRaw.bootstrapAdmin, targetRaw.bootstrapAdmin),
codeAgentProvider: mergeOptionalRecord(baseRaw.codeAgentProvider, targetRaw.codeAgentProvider),
codeAgentRuntime: mergeOptionalRecord(baseRaw.codeAgentRuntime, targetRaw.codeAgentRuntime),
sourceWorkspace: mergeOptionalRecord(baseRaw.sourceWorkspace, targetRaw.sourceWorkspace),
externalPostgres: mergeOptionalRecord(baseRaw.externalPostgres, targetRaw.externalPostgres),
runtimeStore: mergeOptionalRecord(baseRaw.runtimeStore, targetRaw.runtimeStore),
@@ -746,6 +763,30 @@ function codeAgentProviderConfig(value: unknown, path: string): HwlabRuntimeCode
};
}
function codeAgentRuntimeConfig(value: unknown, path: string): HwlabRuntimeCodeAgentRuntimeSpec | undefined {
if (value === undefined) return undefined;
const raw = asRecord(value, path);
const managerUrl = stringField(raw, "managerUrl", path);
try {
const parsed = new URL(managerUrl);
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new Error("unsupported protocol");
} catch {
throw new Error(`${path}.managerUrl must be an http(s) URL`);
}
return {
enabled: booleanField(raw, "enabled", path),
adapter: stringField(raw, "adapter", path),
managerUrl,
apiKeySecretName: stringField(raw, "apiKeySecretName", path),
apiKeySecretKey: secretKeyField(raw, "apiKeySecretKey", path),
runnerNamespace: stringField(raw, "runnerNamespace", path),
secretNamespace: stringField(raw, "secretNamespace", path),
repoUrlFrom: enumStringField(raw, "repoUrlFrom", path, ["runtimeGitReadUrl"]),
providerIdFrom: enumStringField(raw, "providerIdFrom", path, ["runtimeNodeId"]),
defaultProviderProfile: stringField(raw, "defaultProviderProfile", path),
};
}
function commandNameField(value: string, path: string): string {
if (!/^[A-Za-z0-9._+-]+$/u.test(value)) throw new Error(`${path} must be a simple command name`);
return value;
@@ -1351,6 +1392,7 @@ function buildRuntimeLaneSpec(config: HwlabLaneConfig): HwlabRuntimeLaneSpec {
...(config.buildkit === undefined ? {} : { buildkit: config.buildkit }),
...(config.bootstrapAdmin === undefined ? {} : { bootstrapAdmin: config.bootstrapAdmin }),
...(config.codeAgentProvider === undefined ? {} : { codeAgentProvider: config.codeAgentProvider }),
...(config.codeAgentRuntime === undefined ? {} : { codeAgentRuntime: config.codeAgentRuntime }),
...(config.sourceWorkspace === undefined ? {} : { sourceWorkspace: config.sourceWorkspace }),
...(config.externalPostgres === undefined ? {} : { externalPostgres: config.externalPostgres }),
...(config.runtimeStore === undefined ? {} : { runtimeStore: config.runtimeStore }),