Add canvas artifact RPC foundation for A2UI

This commit is contained in:
William Valentin
2026-02-16 12:36:02 -08:00
parent fe8674e108
commit 8a0b4f3dbb
11 changed files with 497 additions and 3 deletions
+40
View File
@@ -234,6 +234,46 @@ describe('GatewayServer integration', () => {
expect(methods).toContain('sessions.create');
expect(methods).toContain('tools.list');
expect(methods).toContain('tools.invoke');
expect(methods).toContain('canvas.put');
expect(methods).toContain('canvas.list');
});
it('supports canvas artifact lifecycle via gateway RPC', async () => {
if (!LISTEN_ALLOWED) {
return;
}
const ws = await createClient();
try {
const put = await sendAndReceive(ws, {
id: 31,
method: 'canvas.put',
params: {
sessionId: 'ws:test-canvas',
artifactId: 'a1',
type: 'note',
content: { text: 'draft' },
},
});
expect((put as GatewayResponse).id).toBe(31);
const list = await sendAndReceive(ws, {
id: 32,
method: 'canvas.list',
params: { sessionId: 'ws:test-canvas' },
});
const artifacts = ((list as GatewayResponse).result as { artifacts: Array<{ id: string }> }).artifacts;
expect(artifacts).toHaveLength(1);
expect(artifacts[0]?.id).toBe('a1');
const clear = await sendAndReceive(ws, {
id: 33,
method: 'canvas.clear',
params: { sessionId: 'ws:test-canvas' },
});
expect(((clear as GatewayResponse).result as { cleared: number }).cleared).toBe(1);
} finally {
ws.close();
}
});
// ── HTTP static file serving tests ────────────────────────────