chore(format): applied biome formatting and removed dead code from merged prs

This commit is contained in:
can1357
2026-08-11 15:14:15 +02:00
parent 8bd621f118
commit 64baa7c1bd
23 changed files with 105 additions and 145 deletions
+1 -1
View File
@@ -738,7 +738,7 @@ export type ToolApprovalDecision =
* tool (e.g. `write` for an `xd://` device call) scope user allow/deny/
* prompt policies to the tool it dispatches into. */
policyKey?: string;
};
};
export type ToolApproval = ToolApprovalDecision | ((args: unknown) => ToolApprovalDecision);
/**
+2 -6
View File
@@ -193,9 +193,7 @@ function pushCursorPlanRails(limits: UsageLimit[], bucket: Record<string, unknow
scope: { provider: "cursor", windowId: window.id },
window,
amount: rails.fallback,
...(rails.fallback.usedFraction !== undefined
? { status: usageStatus(rails.fallback.usedFraction) }
: {}),
...(rails.fallback.usedFraction !== undefined ? { status: usageStatus(rails.fallback.usedFraction) } : {}),
});
}
}
@@ -257,9 +255,7 @@ export function parseCursorIndividualUsage(payload: unknown, fetchedAt = Date.no
scope: { provider: "cursor", windowId: window.id },
window,
amount: onDemandAmount,
...(onDemandAmount.usedFraction !== undefined
? { status: usageStatus(onDemandAmount.usedFraction) }
: {}),
...(onDemandAmount.usedFraction !== undefined ? { status: usageStatus(onDemandAmount.usedFraction) } : {}),
});
}
}
+1 -1
View File
@@ -306,7 +306,7 @@ describe("cursor usage provider", () => {
expect(report?.limits.map(limit => limit.id)).toEqual(["cursor:usd:individual-ondemand"]);
});
it("rejects disabled, malformed, and non-positive personal usage buckets", () => {
it("rejects disabled, malformed, and non-positive personal usage buckets", () => {
expect(
parseCursorIndividualUsage({
individualUsage: { overall: { enabled: false, used: 100, limit: 1000, remaining: 900 } },
+6 -1
View File
@@ -24,7 +24,12 @@ describe("buildFireworksFastSeed", () => {
const byId = new Map(seed.map(model => [model.id, model]));
it("emits one fireworks fast variant per curated base", () => {
expect([...byId.keys()].sort()).toEqual(["glm-5.1-fast", "glm-5.2-fast", "kimi-k2.6-fast", "kimi-k2.7-code-fast"]);
expect([...byId.keys()].sort()).toEqual([
"glm-5.1-fast",
"glm-5.2-fast",
"kimi-k2.6-fast",
"kimi-k2.7-code-fast",
]);
for (const model of seed) {
expect(model.provider).toBe("fireworks");
expect(isFireworksFastModelId(model.id)).toBe(true);
@@ -1449,10 +1449,7 @@ export class StatusLineComponent implements Component {
// Conservatively gate monthly status-line rendering to Cursor for now —
// Copilot/OpenCode also emit monthly windows, but their multi-bucket
// shape needs a dedicated selector before we surface `mo N%` for them.
if (
activeProvider === "cursor" &&
(windowId === "monthly" || windowId === "30d")
) {
if (activeProvider === "cursor" && (windowId === "monthly" || windowId === "30d")) {
const priority = cursorMonthlyPriority(l.id);
const shouldReplace =
!monthly ||
@@ -3564,47 +3564,43 @@ export class InteractiveMode implements InteractiveModeContext {
rest?: string,
input?: Pick<SubmittedUserInput, "images" | "imageLinks">,
): Promise<boolean> {
try {
if (this.planModeEnabled || this.planModePaused) {
this.showWarning("Exit plan mode first.");
return false;
}
if (this.vibeModeEnabled) {
this.showWarning("Exit vibe mode first.");
return false;
}
if (!this.session.settings.get("goal.enabled")) {
this.showWarning("Goal mode is disabled. Enable it in settings (goal.enabled).");
return false;
}
const { sub, rest: subRest } = parseGoalSubcommand(rest ?? "");
if (sub) return await this.#dispatchGoalSubcommand(sub, subRest, input);
if (this.goalModeEnabled) {
if (subRest) {
this.showStatus("Goal mode is already active. Use /goal to manage it, or /goal drop to start over.");
return false;
}
await this.#openGoalMenu("active");
return false;
}
const pausedState = this.#getPausedGoalState();
if (pausedState) {
if (subRest) {
this.showWarning("Resume the current goal first, or drop it before setting a new objective.");
return false;
}
await this.#openGoalMenu("paused");
return false;
}
if (subRest) return await this.#startGoalFromObjective(subRest, input);
const objective = (
await this.showHookEditor("Goal objective", undefined, undefined, { promptStyle: true })
)?.trim();
if (!objective) return false;
return await this.#startGoalFromObjective(objective, input);
} catch (error) {
throw error;
if (this.planModeEnabled || this.planModePaused) {
this.showWarning("Exit plan mode first.");
return false;
}
if (this.vibeModeEnabled) {
this.showWarning("Exit vibe mode first.");
return false;
}
if (!this.session.settings.get("goal.enabled")) {
this.showWarning("Goal mode is disabled. Enable it in settings (goal.enabled).");
return false;
}
const { sub, rest: subRest } = parseGoalSubcommand(rest ?? "");
if (sub) return await this.#dispatchGoalSubcommand(sub, subRest, input);
if (this.goalModeEnabled) {
if (subRest) {
this.showStatus("Goal mode is already active. Use /goal to manage it, or /goal drop to start over.");
return false;
}
await this.#openGoalMenu("active");
return false;
}
const pausedState = this.#getPausedGoalState();
if (pausedState) {
if (subRest) {
this.showWarning("Resume the current goal first, or drop it before setting a new objective.");
return false;
}
await this.#openGoalMenu("paused");
return false;
}
if (subRest) return await this.#startGoalFromObjective(subRest, input);
const objective = (
await this.showHookEditor("Goal objective", undefined, undefined, { promptStyle: true })
)?.trim();
if (!objective) return false;
return await this.#startGoalFromObjective(objective, input);
}
async handleGuidedGoalCommand(
rest?: string,
+14 -2
View File
@@ -144,7 +144,13 @@ export function resolveApproval(
};
}
if (effectiveUserPolicy === "deny") {
return { policy: "deny", tier: decision.tier, override: decision.override, source: "user", policyKey: userPolicyKey };
return {
policy: "deny",
tier: decision.tier,
override: decision.override,
source: "user",
policyKey: userPolicyKey,
};
}
if (mode === "yolo") {
@@ -190,7 +196,13 @@ export function resolveApproval(
}
if (effectiveUserPolicy) {
return { policy: effectiveUserPolicy, tier: decision.tier, override: false, source: "user", policyKey: userPolicyKey };
return {
policy: effectiveUserPolicy,
tier: decision.tier,
override: false,
source: "user",
policyKey: userPolicyKey,
};
}
if (modeApprovesTier(mode, decision.tier)) {
+1 -5
View File
@@ -584,11 +584,7 @@ function parseJinaReaderContent(responseBody: string): string | null {
if (markerStart < 0) return null;
const content = responseBody.slice(markerStart + JINA_MARKDOWN_MARKER.length).trim();
if (
content.length < 100 ||
content.startsWith("Loading...") ||
content.startsWith("Please enable JavaScript")
) {
if (content.length < 100 || content.startsWith("Loading...") || content.startsWith("Please enable JavaScript")) {
return null;
}
return content;
-1
View File
@@ -10,7 +10,6 @@ import type {
AgentToolResult,
AgentToolUpdateCallback,
ToolApprovalDecision,
ToolTier,
} from "@oh-my-pi/pi-agent-core";
import { type Component, Text } from "@oh-my-pi/pi-tui";
import { isEnoent, isRecord, prompt, untilAborted } from "@oh-my-pi/pi-utils";
-1
View File
@@ -83,7 +83,6 @@ export interface KagiErrorResponse {
detail?: string;
}
// ---------------------------------------------------------------------------
// Error Handling
// ---------------------------------------------------------------------------
+1 -4
View File
@@ -146,10 +146,7 @@ export function parseParallelErrorResponse(statusCode: number, responseText: str
}
}
export async function parseParallelJsonResponse(
response: Response,
operation: "search" | "extract",
): Promise<unknown> {
export async function parseParallelJsonResponse(response: Response, operation: "search" | "extract"): Promise<unknown> {
try {
return await response.json();
} catch (err) {
@@ -66,7 +66,6 @@ export interface BraveSearchParams {
fetch?: FetchImpl;
}
interface BraveSearchResponse {
web?: unknown;
}
@@ -206,8 +205,7 @@ export async function searchBrave(params: BraveSearchParams): Promise<SearchResp
});
const { response, requestId } = await withAuth(keyOrResolver, key => callBraveSearch(key, params), {
signal: params.signal,
missingKeyMessage:
'Brave credentials not found. Set BRAVE_API_KEY or configure an API key for provider "brave".',
missingKeyMessage: 'Brave credentials not found. Set BRAVE_API_KEY or configure an API key for provider "brave".',
});
const sources: SearchSource[] = [];
@@ -320,13 +320,11 @@ async function parseGeminiSearchStream(
};
}
function isGroundingRedirectUrl(url: string): boolean {
try {
const parsed = new URL(url);
return (
parsed.hostname === "vertexaisearch.cloud.google.com" &&
parsed.pathname.includes("/grounding-api-redirect")
parsed.hostname === "vertexaisearch.cloud.google.com" && parsed.pathname.includes("/grounding-api-redirect")
);
} catch {
return false;
@@ -524,9 +522,7 @@ async function callGeminiSearch(
if (!response?.ok) {
const rawErrorText = response ? await response.text() : "Network error";
const errorText = auth.accessToken
? rawErrorText.split(auth.accessToken).join("[redacted]")
: rawErrorText;
const errorText = auth.accessToken ? rawErrorText.split(auth.accessToken).join("[redacted]") : rawErrorText;
const status = response?.status ?? 502;
const classified = classifyProviderHttpError("gemini", status, errorText);
if (classified) throw classified;
@@ -580,25 +576,22 @@ async function callGeminiDeveloperSearch(
requestBody.generationConfig = generationConfig;
}
const response = await fetchWithRetry(
() => `${endpoint.url}/models/${model}:streamGenerateContent?alt=sse`,
{
method: "POST",
headers: {
...(endpoint.isCloudflareGateway
? { "cf-aig-authorization": `Bearer ${apiKey}` }
: { "x-goog-api-key": apiKey }),
"Content-Type": "application/json",
Accept: "text/event-stream",
},
body: JSON.stringify(requestBody),
signal: withHardTimeout(signal, timeoutMs),
fetch: fetchImpl,
maxAttempts: MAX_RETRIES + 1,
defaultDelayMs: attempt => BASE_DELAY_MS * 2 ** attempt,
maxDelayMs: RATE_LIMIT_BUDGET_MS,
const response = await fetchWithRetry(() => `${endpoint.url}/models/${model}:streamGenerateContent?alt=sse`, {
method: "POST",
headers: {
...(endpoint.isCloudflareGateway
? { "cf-aig-authorization": `Bearer ${apiKey}` }
: { "x-goog-api-key": apiKey }),
"Content-Type": "application/json",
Accept: "text/event-stream",
},
);
body: JSON.stringify(requestBody),
signal: withHardTimeout(signal, timeoutMs),
fetch: fetchImpl,
maxAttempts: MAX_RETRIES + 1,
defaultDelayMs: attempt => BASE_DELAY_MS * 2 ** attempt,
maxDelayMs: RATE_LIMIT_BUDGET_MS,
});
if (!response.ok) {
const rawErrorText = await response.text();
@@ -674,7 +667,7 @@ export async function searchGemini(params: GeminiSearchParams): Promise<SearchRe
if (!apiKey) {
throw new Error(
endpoint.isCloudflareGateway
? "No Cloudflare AI Gateway credential found. Configure provider \"cloudflare-ai-gateway\" or set CLOUDFLARE_AI_GATEWAY_API_KEY."
? 'No Cloudflare AI Gateway credential found. Configure provider "cloudflare-ai-gateway" or set CLOUDFLARE_AI_GATEWAY_API_KEY.'
: "No Gemini credentials found. Set GEMINI_API_KEY, configure an API key for provider \"google\", or login with 'omp /login google-gemini-cli' / 'omp /login google-antigravity' to enable Gemini web search.",
);
}
@@ -100,19 +100,10 @@ export async function searchJina(params: JinaSearchParams): Promise<SearchRespon
const response = await withAuth(
keyOrResolver,
apiKey =>
callJinaSearch(
apiKey,
params.query,
numResults,
params.site,
params.signal,
params.fetch,
params.timeoutMs,
),
callJinaSearch(apiKey, params.query, numResults, params.site, params.signal, params.fetch, params.timeoutMs),
{
signal: params.signal,
missingKeyMessage:
'Jina credentials not found. Set JINA_API_KEY or configure an API key for provider "jina".',
missingKeyMessage: 'Jina credentials not found. Set JINA_API_KEY or configure an API key for provider "jina".',
},
);
const sources: SearchSource[] = [];
@@ -323,13 +323,7 @@ function parseResponse(response: XAIResponsesResponse, resultCap: number): Searc
const content = Array.isArray(item.content) ? item.content : [];
for (const part of content) {
if (!part || typeof part !== "object") continue;
collectAnnotationSources(
part.annotations,
sources,
citations,
seenUrls,
part.output_text ?? part.text,
);
collectAnnotationSources(part.annotations, sources, citations, seenUrls, part.output_text ?? part.text);
}
}
for (const item of output) {
@@ -405,7 +405,9 @@ describe("usage status-line segment", () => {
[
{
provider: "opencode-go",
limits: [{ id: "opencode-go:usd:monthly", scope: { windowId: "monthly" }, amount: { usedFraction: 0.42 } }],
limits: [
{ id: "opencode-go:usd:monthly", scope: { windowId: "monthly" }, amount: { usedFraction: 0.42 } },
],
},
],
{ provider: "opencode-go" },
@@ -189,12 +189,12 @@ describe("decision policyKey scopes user policy to a sub-tool", () => {
});
it("device policy wins over the invoking tool's policy", () => {
expect(
resolveApproval(dispatch, {}, "always-ask", { write: "prompt", knowledge_search: "allow" }).policy,
).toBe("allow");
expect(
resolveApproval(dispatch, {}, "always-ask", { write: "allow", knowledge_search: "deny" }).policy,
).toBe("deny");
expect(resolveApproval(dispatch, {}, "always-ask", { write: "prompt", knowledge_search: "allow" }).policy).toBe(
"allow",
);
expect(resolveApproval(dispatch, {}, "always-ask", { write: "allow", knowledge_search: "deny" }).policy).toBe(
"deny",
);
});
it("names the policy key in user-deny refusals", () => {
@@ -580,9 +580,7 @@ describe("searchCodex model selection", () => {
"",
].join("\n");
const result = await searchCodex(
makeSearchParams("action sources", mockCodexFetch("gpt-5.4", sse)),
);
const result = await searchCodex(makeSearchParams("action sources", mockCodexFetch("gpt-5.4", sse)));
expect(capturedRequest?.body?.include).toEqual(["web_search_call.action.sources"]);
expect(result.requestId).toBe("resp_created_id");
@@ -576,8 +576,7 @@ describe("searchExa", () => {
expect(capturedRequestBody?.params).toEqual({
name: "web_search_exa",
arguments: {
query:
"vector databases site:qdrant.tech -site:spam.example after:2024-01-01 before:2025-01-01",
query: "vector databases site:qdrant.tech -site:spam.example after:2024-01-01 before:2025-01-01",
numResults: 4,
},
});
@@ -118,8 +118,7 @@ describe("searchGemini tools serialization", () => {
});
it("routes Cloudflare AI Gateway auth through AuthStorage without leaking a Google API key", async () => {
Bun.env.GOOGLE_GEMINI_BASE_URL =
"https://gateway.ai.cloudflare.com/v1/account/gateway/google-ai-studio";
Bun.env.GOOGLE_GEMINI_BASE_URL = "https://gateway.ai.cloudflare.com/v1/account/gateway/google-ai-studio";
const gatewayAuthStorage = {
async getOAuthAccess() {
return undefined;
@@ -284,8 +283,7 @@ describe("searchGemini tools serialization", () => {
});
it("resolves Google grounding proxy URLs in both sources and citations", async () => {
const proxyUrl =
"https://vertexaisearch.cloud.google.com/grounding-api-redirect/abc";
const proxyUrl = "https://vertexaisearch.cloud.google.com/grounding-api-redirect/abc";
const responseText = `data: ${JSON.stringify({
candidates: [
{
@@ -70,9 +70,9 @@ describe("Kagi web search error handling", () => {
await expect(searchWithKagi("invalid json", { fetch: invalidJsonFetch }, fakeAuthStorage)).rejects.toThrow(
"Kagi API returned an invalid response: invalid JSON",
);
await expect(searchWithKagi("invalid envelope", { fetch: invalidEnvelopeFetch }, fakeAuthStorage)).rejects.toThrow(
"Kagi API returned an invalid response: expected an object envelope",
);
await expect(
searchWithKagi("invalid envelope", { fetch: invalidEnvelopeFetch }, fakeAuthStorage),
).rejects.toThrow("Kagi API returned an invalid response: expected an object envelope");
});
it("recognizes errors plural in a successful HTTP envelope", async () => {
@@ -126,13 +126,9 @@ describe("SearXNG web search provider", () => {
try {
await Bun.write(
path.join(agentDir, "config.yml"),
[
"searxng:",
" endpoint: https://searx.example.org",
" categories: news",
" safesearch: 2",
"",
].join("\n"),
["searxng:", " endpoint: https://searx.example.org", " categories: news", " safesearch: 2", ""].join(
"\n",
),
);
await Settings.init({ agentDir });
@@ -87,13 +87,7 @@ describe("TinyFish web search provider", () => {
expect(captured[0].searchParams.get("query")).toBe('"error handling" rust filetype:pdf');
expect(captured[0].searchParams.get("include_domains")).toBe("github.com");
expect(captured[0].searchParams.get("exclude_domains")).toBe("gitlab.com");
expectTinyFishParams(captured[0], [
"query",
"num_results",
"page",
"include_domains",
"exclude_domains",
]);
expectTinyFishParams(captured[0], ["query", "num_results", "page", "include_domains", "exclude_domains"]);
});
it("sends directive-free queries verbatim", async () => {