fix: clean up lint + guardCancel typing

This commit is contained in:
Peter Steinberger
2026-01-12 07:02:49 +00:00
parent 3ba2eb6298
commit f00667ea25
5 changed files with 235 additions and 221 deletions

View File

@@ -52,6 +52,8 @@
### Fixes
- Models/Onboarding: configure MiniMax (minimax.io) via Anthropic-compatible `/anthropic` endpoint by default (keep `minimax-api` as a legacy alias).
- Models: normalize Gemini 3 Pro/Flash IDs to preview names for live model lookups. (#769) — thanks @steipete.
- CLI: fix guardCancel typing for configure prompts. (#769) — thanks @steipete.
- Gateway/WebChat: include handshake validation details in the WebSocket close reason for easier debugging; preserve close codes.
- Gateway/Auth: send invalid connect responses before closing the handshake; stabilize invalid-connect auth test.
- Gateway: tighten gateway listener detection.

View File

@@ -166,10 +166,7 @@ describe("models config", () => {
providers: Record<string, { models: Array<{ id: string }> }>;
};
const ids = parsed.providers.google?.models?.map((model) => model.id);
expect(ids).toEqual([
"gemini-3-pro-preview",
"gemini-3-flash-preview",
]);
expect(ids).toEqual(["gemini-3-pro-preview", "gemini-3-flash-preview"]);
});
});
});

View File

@@ -151,9 +151,6 @@ describeLive("live models (profile keys)", () => {
const authStorage = discoverAuthStorage(agentDir);
const modelRegistry = discoverModels(authStorage, agentDir);
const models = modelRegistry.getAll() as Array<Model<Api>>;
const modelByKey = new Map(
models.map((model) => [`${model.provider}/${model.id}`, model]),
);
const rawModels = process.env.CLAWDBOT_LIVE_MODELS?.trim();
const useModern = rawModels === "modern" || rawModels === "all";
@@ -348,10 +345,15 @@ describeLive("live models (profile keys)", () => {
isAnthropicRateLimitError(message) &&
attempt + 1 < attemptMax
) {
logProgress(`${progressLabel}: rate limit, retrying with next key`);
logProgress(
`${progressLabel}: rate limit, retrying with next key`,
);
continue;
}
if (model.provider === "google" && isGoogleModelNotFoundError(err)) {
if (
model.provider === "google" &&
isGoogleModelNotFoundError(err)
) {
skipped.push({ model: id, reason: message });
logProgress(`${progressLabel}: skip (google model not found)`);
break;

View File

@@ -9,7 +9,7 @@ import {
discoverAuthStorage,
discoverModels,
} from "@mariozechner/pi-coding-agent";
import { describe, expect, it } from "vitest";
import { describe, it } from "vitest";
import { resolveClawdbotAgentDir } from "../agents/agent-paths.js";
import {
collectAnthropicApiKeys,
@@ -34,8 +34,7 @@ const GATEWAY_LIVE = process.env.CLAWDBOT_LIVE_GATEWAY === "1";
const ZAI_FALLBACK = process.env.CLAWDBOT_LIVE_GATEWAY_ZAI_FALLBACK === "1";
const PROVIDERS = parseFilter(process.env.CLAWDBOT_LIVE_GATEWAY_PROVIDERS);
const THINKING_LEVEL = "high";
const THINKING_TAG_RE =
/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking)\s*>/i;
const THINKING_TAG_RE = /<\s*\/?\s*(?:think(?:ing)?|thought|antthinking)\s*>/i;
const FINAL_TAG_RE = /<\s*\/?\s*final\s*>/i;
const describeLive = LIVE || GATEWAY_LIVE ? describe : describe.skip;
@@ -286,7 +285,11 @@ function buildMinimaxProviderOverride(params: {
baseUrl: string;
}): ModelProviderConfig | null {
const existing = params.cfg.models?.providers?.minimax;
if (!existing || !Array.isArray(existing.models) || existing.models.length === 0)
if (
!existing ||
!Array.isArray(existing.models) ||
existing.models.length === 0
)
return null;
return {
...existing,
@@ -356,7 +359,9 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
const anthropicKeys = collectAnthropicApiKeys();
if (anthropicKeys.length > 0) {
process.env.ANTHROPIC_API_KEY = anthropicKeys[0];
logProgress(`[${params.label}] anthropic keys loaded: ${anthropicKeys.length}`);
logProgress(
`[${params.label}] anthropic keys loaded: ${anthropicKeys.length}`,
);
}
const sessionKey = `agent:dev:${params.label}`;
const failures: Array<{ model: string; error: string }> = [];
@@ -444,7 +449,9 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
{ expectFinal: true },
);
if (toolProbe?.status !== "ok") {
throw new Error(`tool probe failed: status=${String(toolProbe?.status)}`);
throw new Error(
`tool probe failed: status=${String(toolProbe?.status)}`,
);
}
const toolText = extractPayloadText(toolProbe?.result);
assertNoReasoningTags({
@@ -572,7 +579,9 @@ async function runGatewayModelSuite(params: GatewayModelSuiteParams) {
{ expectFinal: true },
);
if (first?.status !== "ok") {
throw new Error(`tool-only turn failed: status=${String(first?.status)}`);
throw new Error(
`tool-only turn failed: status=${String(first?.status)}`,
);
}
const firstText = extractPayloadText(first?.result);
assertNoReasoningTags({
@@ -686,7 +695,6 @@ describeLive("gateway live (dev agent, profile keys)", () => {
const candidates: Array<Model<Api>> = [];
for (const model of wanted) {
const id = `${model.provider}/${model.id}`;
if (PROVIDERS && !PROVIDERS.has(model.provider)) continue;
try {
// eslint-disable-next-line no-await-in-loop
@@ -721,9 +729,13 @@ describeLive("gateway live (dev agent, profile keys)", () => {
thinkingLevel: THINKING_LEVEL,
});
const minimaxCandidates = candidates.filter((model) => model.provider === "minimax");
const minimaxCandidates = candidates.filter(
(model) => model.provider === "minimax",
);
if (minimaxCandidates.length === 0) {
logProgress("[minimax] no candidates with keys; skipping dual endpoint probes");
logProgress(
"[minimax] no candidates with keys; skipping dual endpoint probes",
);
return;
}
@@ -743,7 +755,9 @@ describeLive("gateway live (dev agent, profile keys)", () => {
providerOverrides: { minimax: minimaxOpenAi },
});
} else {
logProgress("[minimax-openai] missing minimax provider config; skipping");
logProgress(
"[minimax-openai] missing minimax provider config; skipping",
);
}
const minimaxAnthropic = buildMinimaxProviderOverride({
@@ -762,7 +776,9 @@ describeLive("gateway live (dev agent, profile keys)", () => {
providerOverrides: { minimax: minimaxAnthropic },
});
} else {
logProgress("[minimax-anthropic] missing minimax provider config; skipping");
logProgress(
"[minimax-anthropic] missing minimax provider config; skipping",
);
}
},
20 * 60 * 1000,

View File

@@ -18,10 +18,7 @@ function loadProfileEnv(): void {
try {
const output = execFileSync(
"/bin/bash",
[
"-lc",
`set -a; source \"${profilePath}\" >/dev/null 2>&1; env -0`,
],
["-lc", `set -a; source "${profilePath}" >/dev/null 2>&1; env -0`],
{ encoding: "utf8" },
);
const entries = output.split("\0");