multica/src/agent/sync-agent.ts
yushen 6e82219630 feat(agent): add SyncAgent and AsyncAgent wrapper classes
Introduce two wrapper classes around the core Agent:
- SyncAgent: exposes run() for synchronous request-response usage
- AsyncAgent: exposes write()/read()/close() for non-blocking streaming via Channel

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 11:37:09 +08:00

16 lines
412 B
TypeScript

import { Agent } from "./runner.js";
import type { AgentOptions, AgentRunResult } from "./types.js";
export class SyncAgent {
private readonly agent: Agent;
readonly sessionId: string;
constructor(options?: AgentOptions) {
this.agent = new Agent(options);
this.sessionId = this.agent.sessionId;
}
async run(prompt: string): Promise<AgentRunResult> {
return this.agent.run(prompt);
}
}