chore: format sources and update protocol outputs
This commit is contained in:
@@ -24,9 +24,9 @@ describe("sanitizeSessionHistory (google thinking)", () => {
|
||||
sessionId: "session:google",
|
||||
});
|
||||
|
||||
const assistant = out.find(
|
||||
(msg) => (msg as { role?: string }).role === "assistant",
|
||||
) as { content?: Array<{ type?: string; text?: string }> };
|
||||
const assistant = out.find((msg) => (msg as { role?: string }).role === "assistant") as {
|
||||
content?: Array<{ type?: string; text?: string }>;
|
||||
};
|
||||
expect(assistant.content?.map((block) => block.type)).toEqual(["text"]);
|
||||
expect(assistant.content?.[0]?.text).toBe("reasoning");
|
||||
});
|
||||
@@ -51,9 +51,9 @@ describe("sanitizeSessionHistory (google thinking)", () => {
|
||||
sessionId: "session:google",
|
||||
});
|
||||
|
||||
const assistant = out.find(
|
||||
(msg) => (msg as { role?: string }).role === "assistant",
|
||||
) as { content?: Array<{ type?: string; thinking?: string; thinkingSignature?: string }> };
|
||||
const assistant = out.find((msg) => (msg as { role?: string }).role === "assistant") as {
|
||||
content?: Array<{ type?: string; thinking?: string; thinkingSignature?: string }>;
|
||||
};
|
||||
expect(assistant.content?.map((block) => block.type)).toEqual(["thinking"]);
|
||||
expect(assistant.content?.[0]?.thinking).toBe("reasoning");
|
||||
expect(assistant.content?.[0]?.thinkingSignature).toBe("sig");
|
||||
@@ -83,9 +83,9 @@ describe("sanitizeSessionHistory (google thinking)", () => {
|
||||
sessionId: "session:google-mixed",
|
||||
});
|
||||
|
||||
const assistant = out.find(
|
||||
(msg) => (msg as { role?: string }).role === "assistant",
|
||||
) as { content?: Array<{ type?: string; text?: string }> };
|
||||
const assistant = out.find((msg) => (msg as { role?: string }).role === "assistant") as {
|
||||
content?: Array<{ type?: string; text?: string }>;
|
||||
};
|
||||
expect(assistant.content?.map((block) => block.type)).toEqual(["text", "text", "text"]);
|
||||
expect(assistant.content?.[1]?.text).toBe("internal note");
|
||||
});
|
||||
@@ -113,9 +113,9 @@ describe("sanitizeSessionHistory (google thinking)", () => {
|
||||
sessionId: "session:google-mixed-signatures",
|
||||
});
|
||||
|
||||
const assistant = out.find(
|
||||
(msg) => (msg as { role?: string }).role === "assistant",
|
||||
) as { content?: Array<{ type?: string; thinking?: string; text?: string }> };
|
||||
const assistant = out.find((msg) => (msg as { role?: string }).role === "assistant") as {
|
||||
content?: Array<{ type?: string; thinking?: string; text?: string }>;
|
||||
};
|
||||
expect(assistant.content?.map((block) => block.type)).toEqual(["thinking", "text"]);
|
||||
expect(assistant.content?.[0]?.thinking).toBe("signed");
|
||||
expect(assistant.content?.[1]?.text).toBe("unsigned");
|
||||
@@ -141,9 +141,7 @@ describe("sanitizeSessionHistory (google thinking)", () => {
|
||||
sessionId: "session:google-empty",
|
||||
});
|
||||
|
||||
const assistant = out.find(
|
||||
(msg) => (msg as { role?: string }).role === "assistant",
|
||||
);
|
||||
const assistant = out.find((msg) => (msg as { role?: string }).role === "assistant");
|
||||
expect(assistant).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -167,9 +165,9 @@ describe("sanitizeSessionHistory (google thinking)", () => {
|
||||
sessionId: "session:openai",
|
||||
});
|
||||
|
||||
const assistant = out.find(
|
||||
(msg) => (msg as { role?: string }).role === "assistant",
|
||||
) as { content?: Array<{ type?: string }> };
|
||||
const assistant = out.find((msg) => (msg as { role?: string }).role === "assistant") as {
|
||||
content?: Array<{ type?: string }>;
|
||||
};
|
||||
expect(assistant.content?.map((block) => block.type)).toEqual(["thinking"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -299,9 +299,7 @@ async function waitForSubagentCompletion(runId: string, waitTimeoutMs: number) {
|
||||
mutated = true;
|
||||
}
|
||||
entry.outcome =
|
||||
wait.status === "error"
|
||||
? { status: "error", error: wait.error }
|
||||
: { status: "ok" };
|
||||
wait.status === "error" ? { status: "error", error: wait.error } : { status: "ok" };
|
||||
mutated = true;
|
||||
if (mutated) persistSubagentRuns();
|
||||
if (!beginSubagentAnnounce(runId)) return;
|
||||
|
||||
@@ -138,10 +138,7 @@ export function createGatewayTool(opts?: {
|
||||
} else {
|
||||
const rawSnapshot = (snapshot as { raw?: unknown }).raw;
|
||||
if (typeof rawSnapshot === "string") {
|
||||
baseHash = crypto
|
||||
.createHash("sha256")
|
||||
.update(rawSnapshot)
|
||||
.digest("hex");
|
||||
baseHash = crypto.createHash("sha256").update(rawSnapshot).digest("hex");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,9 +105,7 @@ function resolveFetchEnabled(params: { fetch?: WebFetchConfig; sandboxed?: boole
|
||||
|
||||
function resolveSearchApiKey(search?: WebSearchConfig): string | undefined {
|
||||
const fromConfig =
|
||||
search && "apiKey" in search && typeof search.apiKey === "string"
|
||||
? search.apiKey.trim()
|
||||
: "";
|
||||
search && "apiKey" in search && typeof search.apiKey === "string" ? search.apiKey.trim() : "";
|
||||
const fromEnv = (process.env.BRAVE_API_KEY ?? "").trim();
|
||||
return fromConfig || fromEnv || undefined;
|
||||
}
|
||||
@@ -160,12 +158,7 @@ function readCache<T>(
|
||||
return { value: entry.value, cached: true };
|
||||
}
|
||||
|
||||
function writeCache<T>(
|
||||
cache: Map<string, CacheEntry<T>>,
|
||||
key: string,
|
||||
value: T,
|
||||
ttlMs: number,
|
||||
) {
|
||||
function writeCache<T>(cache: Map<string, CacheEntry<T>>, key: string, value: T, ttlMs: number) {
|
||||
if (ttlMs <= 0) return;
|
||||
if (cache.size >= DEFAULT_CACHE_MAX_ENTRIES) {
|
||||
const oldest = cache.keys().next();
|
||||
@@ -319,7 +312,7 @@ async function runWebSearch(params: {
|
||||
}
|
||||
|
||||
const data = (await res.json()) as BraveSearchResponse;
|
||||
const results = Array.isArray(data.web?.results) ? data.web?.results ?? [] : [];
|
||||
const results = Array.isArray(data.web?.results) ? (data.web?.results ?? []) : [];
|
||||
const mapped = results.map((entry) => ({
|
||||
title: entry.title ?? "",
|
||||
url: entry.url ?? "",
|
||||
@@ -463,8 +456,7 @@ export function createWebFetchTool(options?: {
|
||||
execute: async (_toolCallId, args) => {
|
||||
const params = args as Record<string, unknown>;
|
||||
const url = readStringParam(params, "url", { required: true });
|
||||
const extractMode =
|
||||
readStringParam(params, "extractMode") === "text" ? "text" : "markdown";
|
||||
const extractMode = readStringParam(params, "extractMode") === "text" ? "text" : "markdown";
|
||||
const maxChars = readNumberParam(params, "maxChars", { integer: true });
|
||||
const result = await runWebFetch({
|
||||
url,
|
||||
|
||||
Reference in New Issue
Block a user