@autifyhq/muon
Version:
Muon - AI-Powered Playwright Test Coding Agent with Advanced Test Fixing Capabilities
123 lines (122 loc) • 3.15 kB
TypeScript
import type { MuonAuth } from './auth.js';
export interface StreamingAgentConfig {
projectPath?: string;
serverUrl: string;
agentType?: 'general';
apiKey?: string;
accessToken?: string;
nlstepMode?: boolean;
auth?: MuonAuth;
}
export interface ConversationMessage {
role: 'user' | 'assistant' | 'tool' | 'system';
content: string | null;
tool_calls?: Array<{
id: string;
type: 'function';
function: {
name: string;
arguments: string;
};
}>;
tool_call_id?: string;
name?: string;
}
export interface AgentResponseRequest {
messages: ConversationMessage[];
agentType?: 'general';
projectPath?: string;
stream?: boolean;
sessionId?: string;
}
export interface NLStepRequest {
task: string;
url: string;
pageContext?: {
url: string;
title: string;
mainFrame?: string;
iframes?: Array<{
name?: string;
src?: string;
}>;
stats?: {
totalElements: number;
iframeCount: number;
};
};
options?: {
timeout?: number;
retries?: number;
waitForNavigation?: boolean;
};
viewport?: {
width: number;
height: number;
};
messages?: Array<{
role: 'user' | 'assistant' | 'tool';
content?: string;
tool_calls?: Array<{
id: string;
type: 'function';
function: {
name: string;
arguments: string;
};
}>;
tool_call_id?: string;
name?: string;
}>;
}
export interface NLStepResponse {
success: boolean;
task: string;
url: string;
aiResponse: {
content: string;
toolCalls: Array<{
id: string;
type: 'function';
function: {
name: string;
arguments: string;
};
}>;
};
timestamp: string;
}
export interface MuonMessage {
type: 'user' | 'assistant' | 'assistant_start' | 'assistant_delta' | 'assistant_complete' | 'system' | 'tool_call' | 'tool_result' | 'error' | 'stream_complete';
content: string;
session_id: string;
timestamp: Date;
tool_calls?: any[];
tool_call_id?: string;
}
export interface MuonResultMessage {
type: 'result';
subtype: 'success' | 'error' | 'interrupted';
duration_ms: number;
session_id: string;
result?: string;
error?: string;
}
export declare class StreamingMuonAgent {
private config;
private tools;
private httpClient;
private sessionId;
private conversationHistory;
private abortController?;
constructor(config: StreamingAgentConfig);
private generateSessionId;
interrupt(): void;
query(prompt: string): AsyncGenerator<MuonMessage, MuonResultMessage, void>;
private executeToolCall;
abort(): void;
executeNLStep(request: NLStepRequest): Promise<NLStepResponse>;
cleanup(): Promise<void>;
getConversationHistory(): ConversationMessage[];
clearConversationHistory(): void;
}