Restore maxTurnsPerRun field, add config schema tests
Keep adapter-specific maxTurnsPerRun (default 1000) in the config schema since the platform UI does not provide it for external adapters. Platform-provided fields (model, effort, instructionsFilePath, timeoutSec, graceSec) remain excluded to avoid duplication. Add config-schema.test.ts with assertions that platform-provided fields are absent and adapter-specific fields have correct defaults. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { getConfigSchema } from "./config-schema.js";
|
||||||
|
|
||||||
|
interface ConfigFieldSchema {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
type: string;
|
||||||
|
default?: unknown;
|
||||||
|
options?: { label: string; value: string }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("getConfigSchema", () => {
|
||||||
|
it("returns a non-empty schema", () => {
|
||||||
|
const schema = getConfigSchema();
|
||||||
|
expect(schema.fields.length).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not include platform-provided fields", () => {
|
||||||
|
const schema = getConfigSchema();
|
||||||
|
const keys = schema.fields.map((f: ConfigFieldSchema) => f.key);
|
||||||
|
// These fields are provided by the platform and should not be duplicated
|
||||||
|
expect(keys).not.toContain("model");
|
||||||
|
expect(keys).not.toContain("effort");
|
||||||
|
expect(keys).not.toContain("instructionsFilePath");
|
||||||
|
expect(keys).not.toContain("timeoutSec");
|
||||||
|
expect(keys).not.toContain("graceSec");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("maxTurnsPerRun defaults to 1000", () => {
|
||||||
|
const schema = getConfigSchema();
|
||||||
|
const field = schema.fields.find((f: ConfigFieldSchema) => f.key === "maxTurnsPerRun");
|
||||||
|
expect(field).toBeDefined();
|
||||||
|
expect(field!.type).toBe("number");
|
||||||
|
expect(field!.default).toBe(1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("dangerouslySkipPermissions defaults to true", () => {
|
||||||
|
const schema = getConfigSchema();
|
||||||
|
const field = schema.fields.find((f: ConfigFieldSchema) => f.key === "dangerouslySkipPermissions");
|
||||||
|
expect(field).toBeDefined();
|
||||||
|
expect(field!.type).toBe("toggle");
|
||||||
|
expect(field!.default).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has imagePullPolicy as select with correct options", () => {
|
||||||
|
const schema = getConfigSchema();
|
||||||
|
const field = schema.fields.find((f: ConfigFieldSchema) => f.key === "imagePullPolicy");
|
||||||
|
expect(field).toBeDefined();
|
||||||
|
expect(field!.type).toBe("select");
|
||||||
|
expect(field!.options).toEqual([
|
||||||
|
{ label: "IfNotPresent", value: "IfNotPresent" },
|
||||||
|
{ label: "Always", value: "Always" },
|
||||||
|
{ label: "Never", value: "Never" },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -23,8 +23,17 @@ interface AdapterConfigSchema {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getConfigSchema(): AdapterConfigSchema {
|
export function getConfigSchema(): AdapterConfigSchema {
|
||||||
|
// model, effort, instructionsFilePath, timeoutSec, graceSec are provided
|
||||||
|
// by the platform UI and must not be duplicated here.
|
||||||
const fields: ConfigFieldSchema[] = [
|
const fields: ConfigFieldSchema[] = [
|
||||||
// Core Claude fields
|
// Core Claude fields
|
||||||
|
{
|
||||||
|
type: "number",
|
||||||
|
key: "maxTurnsPerRun",
|
||||||
|
label: "Max Turns Per Run",
|
||||||
|
hint: "Maximum number of agentic turns (tool calls) per heartbeat run. 0 means unlimited.",
|
||||||
|
default: 1000,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "toggle",
|
type: "toggle",
|
||||||
key: "dangerouslySkipPermissions",
|
key: "dangerouslySkipPermissions",
|
||||||
|
|||||||
Reference in New Issue
Block a user