refactor: streamline query requests and session storage
Generic Container CI/CD / test-build-publish (push) Successful in 2m4s
Agent CI/CD / build-test-publish-and-deploy (push) Successful in 2m4s

This commit is contained in:
2026-11-09 18:49:32 +08:00
parent 6279a4b555
commit 5ee93329a4
25 changed files with 111 additions and 100 deletions
+18
View File
@@ -26,6 +26,24 @@ const resourceToken = jwt("resource");
const token = () => Response.json({ access_token: resourceToken, token_type: "Bearer", expires_in: 300 });
function credential(id: string) { sessions.push(id); bindSessionCredential(id, { authorization: `Bearer ${jwt(id)}`, projectId: "project" }); }
it("uses cached tool definitions without fetching the catalog on each query", async () => {
const id = "cached-tool-definition"; credential(id);
const client = fixture((async (url, init) => {
if (String(url).includes("/token")) return token();
return init?.method === "POST"
? Response.json({ context_handle: "x".repeat(43) })
: new Response(null, { status: 204 });
}) as McpHttpFetch);
const definition = { ...catalog[0], outputSchema: { type: "object", properties: { ok: { type: "boolean" } } } };
Object.assign(client, { tools: [definition], withClient: async (_token: string, _project: string, _signal: AbortSignal, run: (client: unknown) => Promise<unknown>) => run({
callTool: async (_params: unknown, options: { toolDefinition: unknown }) => {
expect(options.toolDefinition).toBe(definition);
return { content: [], structuredContent: { ok: true } };
},
}) });
expect((await client.query(id, owner(id), definition.name, {}, "call")).structuredContent).toEqual({ ok: true });
});
it("owns simulation HTTP budgets and rejects model overrides before OAuth", async () => {
const id = "mcp-calculation-budget"; credential(id);
let requests = 0, transportTimeout = 0, sdkTimeout = 0;