chore(lint): satisfy biome checks
This commit is contained in:
@@ -20,6 +20,11 @@ const noopAsync = async () => {};
|
|||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
const authProfilePathFor = (agentDir: string) =>
|
const authProfilePathFor = (agentDir: string) =>
|
||||||
path.join(agentDir, "auth-profiles.json");
|
path.join(agentDir, "auth-profiles.json");
|
||||||
|
const requireAgentDir = () => {
|
||||||
|
const agentDir = process.env.CLAWDBOT_AGENT_DIR;
|
||||||
|
if (!agentDir) throw new Error("CLAWDBOT_AGENT_DIR not set");
|
||||||
|
return agentDir;
|
||||||
|
};
|
||||||
|
|
||||||
describe("applyAuthChoice", () => {
|
describe("applyAuthChoice", () => {
|
||||||
const previousStateDir = process.env.CLAWDBOT_STATE_DIR;
|
const previousStateDir = process.env.CLAWDBOT_STATE_DIR;
|
||||||
@@ -113,9 +118,7 @@ describe("applyAuthChoice", () => {
|
|||||||
mode: "api_key",
|
mode: "api_key",
|
||||||
});
|
});
|
||||||
|
|
||||||
const authProfilePath = authProfilePathFor(
|
const authProfilePath = authProfilePathFor(requireAgentDir());
|
||||||
process.env.CLAWDBOT_AGENT_DIR!,
|
|
||||||
);
|
|
||||||
const raw = await fs.readFile(authProfilePath, "utf8");
|
const raw = await fs.readFile(authProfilePath, "utf8");
|
||||||
const parsed = JSON.parse(raw) as {
|
const parsed = JSON.parse(raw) as {
|
||||||
profiles?: Record<string, { key?: string }>;
|
profiles?: Record<string, { key?: string }>;
|
||||||
@@ -168,9 +171,7 @@ describe("applyAuthChoice", () => {
|
|||||||
mode: "api_key",
|
mode: "api_key",
|
||||||
});
|
});
|
||||||
|
|
||||||
const authProfilePath = authProfilePathFor(
|
const authProfilePath = authProfilePathFor(requireAgentDir());
|
||||||
process.env.CLAWDBOT_AGENT_DIR!,
|
|
||||||
);
|
|
||||||
const raw = await fs.readFile(authProfilePath, "utf8");
|
const raw = await fs.readFile(authProfilePath, "utf8");
|
||||||
const parsed = JSON.parse(raw) as {
|
const parsed = JSON.parse(raw) as {
|
||||||
profiles?: Record<string, { key?: string }>;
|
profiles?: Record<string, { key?: string }>;
|
||||||
@@ -331,9 +332,7 @@ describe("applyAuthChoice", () => {
|
|||||||
"openrouter/auto",
|
"openrouter/auto",
|
||||||
);
|
);
|
||||||
|
|
||||||
const authProfilePath = authProfilePathFor(
|
const authProfilePath = authProfilePathFor(requireAgentDir());
|
||||||
process.env.CLAWDBOT_AGENT_DIR!,
|
|
||||||
);
|
|
||||||
const raw = await fs.readFile(authProfilePath, "utf8");
|
const raw = await fs.readFile(authProfilePath, "utf8");
|
||||||
const parsed = JSON.parse(raw) as {
|
const parsed = JSON.parse(raw) as {
|
||||||
profiles?: Record<string, { key?: string }>;
|
profiles?: Record<string, { key?: string }>;
|
||||||
@@ -416,9 +415,7 @@ describe("applyAuthChoice", () => {
|
|||||||
mode: "oauth",
|
mode: "oauth",
|
||||||
});
|
});
|
||||||
|
|
||||||
const authProfilePath = authProfilePathFor(
|
const authProfilePath = authProfilePathFor(requireAgentDir());
|
||||||
process.env.CLAWDBOT_AGENT_DIR!,
|
|
||||||
);
|
|
||||||
const raw = await fs.readFile(authProfilePath, "utf8");
|
const raw = await fs.readFile(authProfilePath, "utf8");
|
||||||
const parsed = JSON.parse(raw) as {
|
const parsed = JSON.parse(raw) as {
|
||||||
profiles?: Record<
|
profiles?: Record<
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ export function noteSourceInstallIssues(root: string | null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(srcEntry) && !fs.existsSync(tsxBin)) {
|
if (fs.existsSync(srcEntry) && !fs.existsSync(tsxBin)) {
|
||||||
warnings.push(
|
warnings.push("- tsx binary is missing for source runs. Run: pnpm install");
|
||||||
"- tsx binary is missing for source runs. Run: pnpm install",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warnings.length > 0) {
|
if (warnings.length > 0) {
|
||||||
|
|||||||
@@ -29,10 +29,7 @@ export async function maybeRepairUiProtocolFreshness(
|
|||||||
|
|
||||||
if (schemaStats && !uiStats) {
|
if (schemaStats && !uiStats) {
|
||||||
note(
|
note(
|
||||||
[
|
["- Control UI assets are missing.", "- Run: pnpm ui:build"].join("\n"),
|
||||||
"- Control UI assets are missing.",
|
|
||||||
"- Run: pnpm ui:build",
|
|
||||||
].join("\n"),
|
|
||||||
"UI",
|
"UI",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,19 @@ import {
|
|||||||
applySyntheticConfig,
|
applySyntheticConfig,
|
||||||
applySyntheticProviderConfig,
|
applySyntheticProviderConfig,
|
||||||
OPENROUTER_DEFAULT_MODEL_REF,
|
OPENROUTER_DEFAULT_MODEL_REF,
|
||||||
setMinimaxApiKey,
|
|
||||||
SYNTHETIC_DEFAULT_MODEL_ID,
|
SYNTHETIC_DEFAULT_MODEL_ID,
|
||||||
SYNTHETIC_DEFAULT_MODEL_REF,
|
SYNTHETIC_DEFAULT_MODEL_REF,
|
||||||
|
setMinimaxApiKey,
|
||||||
writeOAuthCredentials,
|
writeOAuthCredentials,
|
||||||
} from "./onboard-auth.js";
|
} from "./onboard-auth.js";
|
||||||
|
|
||||||
const authProfilePathFor = (agentDir: string) =>
|
const authProfilePathFor = (agentDir: string) =>
|
||||||
path.join(agentDir, "auth-profiles.json");
|
path.join(agentDir, "auth-profiles.json");
|
||||||
|
const requireAgentDir = () => {
|
||||||
|
const agentDir = process.env.CLAWDBOT_AGENT_DIR;
|
||||||
|
if (!agentDir) throw new Error("CLAWDBOT_AGENT_DIR not set");
|
||||||
|
return agentDir;
|
||||||
|
};
|
||||||
|
|
||||||
describe("writeOAuthCredentials", () => {
|
describe("writeOAuthCredentials", () => {
|
||||||
const previousStateDir = process.env.CLAWDBOT_STATE_DIR;
|
const previousStateDir = process.env.CLAWDBOT_STATE_DIR;
|
||||||
@@ -68,9 +73,7 @@ describe("writeOAuthCredentials", () => {
|
|||||||
|
|
||||||
await writeOAuthCredentials("openai-codex", creds);
|
await writeOAuthCredentials("openai-codex", creds);
|
||||||
|
|
||||||
const authProfilePath = authProfilePathFor(
|
const authProfilePath = authProfilePathFor(requireAgentDir());
|
||||||
process.env.CLAWDBOT_AGENT_DIR!,
|
|
||||||
);
|
|
||||||
const raw = await fs.readFile(authProfilePath, "utf8");
|
const raw = await fs.readFile(authProfilePath, "utf8");
|
||||||
const parsed = JSON.parse(raw) as {
|
const parsed = JSON.parse(raw) as {
|
||||||
profiles?: Record<string, OAuthCredentials & { type?: string }>;
|
profiles?: Record<string, OAuthCredentials & { type?: string }>;
|
||||||
@@ -83,7 +86,13 @@ describe("writeOAuthCredentials", () => {
|
|||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
fs.readFile(
|
fs.readFile(
|
||||||
path.join(tempStateDir, "agents", "main", "agent", "auth-profiles.json"),
|
path.join(
|
||||||
|
tempStateDir,
|
||||||
|
"agents",
|
||||||
|
"main",
|
||||||
|
"agent",
|
||||||
|
"auth-profiles.json",
|
||||||
|
),
|
||||||
"utf8",
|
"utf8",
|
||||||
),
|
),
|
||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
@@ -119,19 +128,22 @@ describe("setMinimaxApiKey", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("writes to CLAWDBOT_AGENT_DIR when set", async () => {
|
it("writes to CLAWDBOT_AGENT_DIR when set", async () => {
|
||||||
tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-minimax-"));
|
tempStateDir = await fs.mkdtemp(
|
||||||
|
path.join(os.tmpdir(), "clawdbot-minimax-"),
|
||||||
|
);
|
||||||
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
||||||
process.env.CLAWDBOT_AGENT_DIR = path.join(tempStateDir, "custom-agent");
|
process.env.CLAWDBOT_AGENT_DIR = path.join(tempStateDir, "custom-agent");
|
||||||
process.env.PI_CODING_AGENT_DIR = process.env.CLAWDBOT_AGENT_DIR;
|
process.env.PI_CODING_AGENT_DIR = process.env.CLAWDBOT_AGENT_DIR;
|
||||||
|
|
||||||
await setMinimaxApiKey("sk-minimax-test");
|
await setMinimaxApiKey("sk-minimax-test");
|
||||||
|
|
||||||
const customAuthPath = authProfilePathFor(
|
const customAuthPath = authProfilePathFor(requireAgentDir());
|
||||||
process.env.CLAWDBOT_AGENT_DIR!,
|
|
||||||
);
|
|
||||||
const raw = await fs.readFile(customAuthPath, "utf8");
|
const raw = await fs.readFile(customAuthPath, "utf8");
|
||||||
const parsed = JSON.parse(raw) as {
|
const parsed = JSON.parse(raw) as {
|
||||||
profiles?: Record<string, { type?: string; provider?: string; key?: string }>;
|
profiles?: Record<
|
||||||
|
string,
|
||||||
|
{ type?: string; provider?: string; key?: string }
|
||||||
|
>;
|
||||||
};
|
};
|
||||||
expect(parsed.profiles?.["minimax:default"]).toMatchObject({
|
expect(parsed.profiles?.["minimax:default"]).toMatchObject({
|
||||||
type: "api_key",
|
type: "api_key",
|
||||||
@@ -141,7 +153,13 @@ describe("setMinimaxApiKey", () => {
|
|||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
fs.readFile(
|
fs.readFile(
|
||||||
path.join(tempStateDir, "agents", "main", "agent", "auth-profiles.json"),
|
path.join(
|
||||||
|
tempStateDir,
|
||||||
|
"agents",
|
||||||
|
"main",
|
||||||
|
"agent",
|
||||||
|
"auth-profiles.json",
|
||||||
|
),
|
||||||
"utf8",
|
"utf8",
|
||||||
),
|
),
|
||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ function ensureExperimentalWarningSuppressed(): void {
|
|||||||
const nodeOptions = process.env.NODE_OPTIONS ?? "";
|
const nodeOptions = process.env.NODE_OPTIONS ?? "";
|
||||||
if (hasExperimentalWarningSuppressed(nodeOptions)) return;
|
if (hasExperimentalWarningSuppressed(nodeOptions)) return;
|
||||||
process.env.CLAWDBOT_NODE_OPTIONS_READY = "1";
|
process.env.CLAWDBOT_NODE_OPTIONS_READY = "1";
|
||||||
process.env.NODE_OPTIONS = `${nodeOptions} ${EXPERIMENTAL_WARNING_FLAG}`.trim();
|
process.env.NODE_OPTIONS =
|
||||||
|
`${nodeOptions} ${EXPERIMENTAL_WARNING_FLAG}`.trim();
|
||||||
const result = spawnSync(process.execPath, process.argv.slice(1), {
|
const result = spawnSync(process.execPath, process.argv.slice(1), {
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
env: process.env,
|
env: process.env,
|
||||||
|
|||||||
Reference in New Issue
Block a user