/** * kernel-a2a.ts - Agent-to-Agent (A2A) methods for KernelClient * * Installed onto KernelClient.prototype via installA2aMethods(). */ import { invoke } from '@tauri-apps/api/core'; import type { KernelClient } from './kernel-client'; export function installA2aMethods(ClientClass: { prototype: KernelClient }): void { const proto = ClientClass.prototype as unknown as Record; // ─── A2A (Agent-to-Agent) API ─── /** * Send a direct A2A message from one agent to another */ proto.a2aSend = async function (this: KernelClient, from: string, to: string, payload: unknown, messageType?: string): Promise { await invoke('agent_a2a_send', { from, to, payload, messageType: messageType || 'notification', }); }; /** * Broadcast a message from an agent to all other agents */ proto.a2aBroadcast = async function (this: KernelClient, from: string, payload: unknown): Promise { await invoke('agent_a2a_broadcast', { from, payload }); }; /** * Discover agents that have a specific capability */ proto.a2aDiscover = async function (this: KernelClient, capability: string): Promise; role: string; priority: number; }>> { return await invoke('agent_a2a_discover', { capability }); }; /** * Delegate a task to another agent and wait for response */ proto.a2aDelegateTask = async function (this: KernelClient, from: string, to: string, task: string, timeoutMs?: number): Promise { return await invoke('agent_a2a_delegate_task', { from, to, task, timeoutMs: timeoutMs || 30000, }); }; }