refactor: dedupe cli config cron and install flows

This commit is contained in:
Peter Steinberger
2026-03-02 19:48:38 +00:00
parent 9d30159fcd
commit b1c30f0ba9
80 changed files with 1379 additions and 2027 deletions

View File

@@ -1,6 +1,20 @@
import { describe, expect, it } from "vitest";
import { validateConfigObjectRaw } from "./validation.js";
function validateOpenAiApiKeyRef(apiKey: unknown) {
return validateConfigObjectRaw({
models: {
providers: {
openai: {
baseUrl: "https://api.openai.com/v1",
apiKey,
models: [{ id: "gpt-5", name: "gpt-5" }],
},
},
},
});
}
describe("config secret refs schema", () => {
it("accepts top-level secrets sources and model apiKey refs", () => {
const result = validateConfigObjectRaw({
@@ -108,16 +122,10 @@ describe("config secret refs schema", () => {
});
it("rejects invalid secret ref id", () => {
const result = validateConfigObjectRaw({
models: {
providers: {
openai: {
baseUrl: "https://api.openai.com/v1",
apiKey: { source: "env", provider: "default", id: "bad id with spaces" },
models: [{ id: "gpt-5", name: "gpt-5" }],
},
},
},
const result = validateOpenAiApiKeyRef({
source: "env",
provider: "default",
id: "bad id with spaces",
});
expect(result.ok).toBe(false);
@@ -129,16 +137,10 @@ describe("config secret refs schema", () => {
});
it("rejects env refs that are not env var names", () => {
const result = validateConfigObjectRaw({
models: {
providers: {
openai: {
baseUrl: "https://api.openai.com/v1",
apiKey: { source: "env", provider: "default", id: "/providers/openai/apiKey" },
models: [{ id: "gpt-5", name: "gpt-5" }],
},
},
},
const result = validateOpenAiApiKeyRef({
source: "env",
provider: "default",
id: "/providers/openai/apiKey",
});
expect(result.ok).toBe(false);
@@ -154,16 +156,10 @@ describe("config secret refs schema", () => {
});
it("rejects file refs that are not absolute JSON pointers", () => {
const result = validateConfigObjectRaw({
models: {
providers: {
openai: {
baseUrl: "https://api.openai.com/v1",
apiKey: { source: "file", provider: "default", id: "providers/openai/apiKey" },
models: [{ id: "gpt-5", name: "gpt-5" }],
},
},
},
const result = validateOpenAiApiKeyRef({
source: "file",
provider: "default",
id: "providers/openai/apiKey",
});
expect(result.ok).toBe(false);