Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(e2e): client-grants reads whoami's own result block, not the notice blocks after it
garrytan306dec0338b1
diff --git a/test/e2e/client-grants.test.ts b/test/e2e/client-grants.test.tsindex 0334dece13..65d4ac1ef0 100644--- a/test/e2e/client-grants.test.ts+++ b/test/e2e/client-grants.test.ts@@ -142,18 +142,21 @@ suite('client capability grants — Postgres and admin HTTP', () => {expect(response.status).toBe(200);return (await response.json() as any).access_token;};- const callTool = async (token: string, name: string, args: Record<string, unknown>): Promise<{ isError: boolean; text: string }> => {+ const callTool = async (token: string, name: string, args: Record<string, unknown>): Promise<{ isError: boolean; text: string; result: string }> => {const response = await fetch(base + '/mcp', { method: 'POST',headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' },body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name, arguments: args } }) });const raw = await response.text();const data = raw.split('\n').find(line => line.startsWith('data:'));const rpc = JSON.parse(data ? data.slice(5) : raw);- if (rpc.error) return { isError: true, text: JSON.stringify(rpc.error) };- return { isError: rpc.result?.isError === true, text: (rpc.result?.content ?? []).map((b: any) => b?.text ?? '').join('\n') };+ if (rpc.error) return { isError: true, text: JSON.stringify(rpc.error), result: JSON.stringify(rpc.error) };+ const blocks: string[] = (rpc.result?.content ?? []).map((b: any) => b?.text ?? '');+ // `result` is the tool's own output, the first block; notice blocks follow it (e.g. the one-time behavior_changes+ // notice a client's first successful call gets on a brain created more than an hour ago).+ return { isError: rpc.result?.isError === true, text: blocks.join('\n'), result: blocks[0] ?? '' };};const onePage = (slug: string) => ({ pages: [{ slug, content: `---\ntitle: ${slug}\n---\nD4 bulk write fixture.\n` }], request_id: randomUUID() });- const whoamiDiagnosis = async (token: string) => JSON.parse((await callTool(token, 'whoami', {})).text).grant_diagnosis;+ const whoamiDiagnosis = async (token: string) => JSON.parse((await callTool(token, 'whoami', {})).result).grant_diagnosis;test('D4: a fresh memory-writer registered through the admin API calls put_pages', async () => {const registration = await post('/admin/api/register-client', { name: 'd4-writer-' + randomUUID(), profile: 'memory-writer', sourceId: 'default' });