import { type WingmanGraphState } from "./state/graph"; import { type BackgroundAgentEventEmitter, type BackgroundAgentStatus } from "./tools/background_agent"; import { type WingmanAgentConfig } from "./config"; export type { BackgroundAgentStatus, BackgroundAgentEventEmitter }; /** * Request object for agent invocation * * @example * ```typescript * const request: WingmanRequest = { * input: "Create a new React component for user authentication", * threadId: "user-session-123", * contextFiles: ["src/types/user.ts", "src/utils/auth.ts"], * contextDirectories: ["src/components"] * }; * ``` */ export type WingmanRequest = { /** The user's input/request to the agent */ input: string; /** Optional thread ID for conversation continuity */ threadId?: string; /** Optional list of files to provide as context */ contextFiles?: string[]; /** Optional list of directories to provide as context */ contextDirectories?: string[]; }; /** * Main Wingman AI Agent class * * @example * ```typescript * import { WingmanAgent } from '@wingman-ai/agent'; * import { ChatOpenAI } from '@langchain/openai'; * * const agent = new WingmanAgent({ * name: "My Assistant", * model: new ChatOpenAI({ model: "gpt-4" }), * workingDirectory: process.cwd(), * backgroundAgentConfig: { * pushToRemote: true, * createPullRequest: true * } * }); * * await agent.initialize(); * * // Stream responses * for await (const chunk of agent.stream({ input: "Create a new feature" })) { * console.log(chunk); * } * * // Or get final result * const result = await agent.invoke({ input: "Fix the bug in auth.ts" }); * ``` */ export declare class WingmanAgent { private readonly mcpAdapter; private readonly config; private readonly storagePath; private readonly logger; private tools; private app; private backgroundAgentEventEmitter; currentThreadId: string | undefined; /** * Event emitter for background agent status updates * * @example * ```typescript * agent.events.on('status', (status) => { * console.log(`Agent ${status.agentName}: ${status.status}`); * }); * * agent.events.on('complete', (data) => { * console.log(`Agent completed with status: ${data.status}`); * }); * ``` */ get events(): BackgroundAgentEventEmitter; /** * Creates a new Wingman Agent instance * * @param wingmanConfig - Configuration object for the agent * * @example * ```typescript * const agent = new WingmanAgent({ * name: "Code Assistant", * model: new ChatOpenAI({ model: "gpt-4" }), * mode: "vibe", * tools: ["edit_file", "command_execute", "background_agent"] * }); * ``` */ constructor(wingmanConfig: WingmanAgentConfig); private setupBackgroundAgentEventHandlers; private handleBackgroundAgentStatusUpdate; private buildSystemPrompt; /** * Initialize the agent and set up tools * Must be called before using the agent * * @example * ```typescript * const agent = new WingmanAgent(config); * await agent.initialize(); * // Agent is now ready to use * ``` */ initialize(): Promise; private callModel; private routerAfterLLM; /** * Compact conversation messages to save memory * Useful for long conversations to prevent context window overflow * * @param threadId - Thread ID to compact messages for * * @example * ```typescript * await agent.compactMessages("thread-123"); * ``` */ compactMessages: (threadId: string) => Promise; /** * Stream agent responses in real-time * * @param request - Request object with input and optional context * @returns Async generator yielding response chunks * * @example * ```typescript * for await (const chunk of agent.stream({ input: "Create a new component" })) { * console.log(chunk); * } * ``` */ stream(request: WingmanRequest): AsyncGenerator, void, unknown>; /** * Stream agent events for detailed monitoring * * @param request - Request object with input and optional context * @returns Async generator yielding event updates * * @example * ```typescript * for await (const event of agent.streamEvents({ input: "Debug the issue" })) { * if (event.event === 'on_tool_start') { * console.log(`Tool started: ${event.name}`); * } * } * ``` */ streamEvents(request: WingmanRequest): AsyncGenerator; /** * Invoke the agent and wait for completion * * @param request - Request object with input and optional context * @returns Promise resolving to the final result * * @example * ```typescript * const result = await agent.invoke({ * input: "Fix the TypeScript errors in auth.ts", * contextFiles: ["src/auth.ts", "src/types/user.ts"] * }); * ``` */ invoke(request: WingmanRequest): Promise>; /** * Get the current graph state for a thread * * @param threadId - Thread ID to get state for * @returns Promise resolving to the graph state or undefined * * @example * ```typescript * const state = await agent.getGraphState("thread-123"); * console.log(state?.messages.length); * ``` */ getGraphState: (threadId: string) => Promise; /** * Terminate all active background agents * * @example * ```typescript * agent.terminateBackgroundAgents(); * ``` */ terminateBackgroundAgents(): void; /** * Terminate a specific background agent * * @param threadId - Thread ID of the background agent to terminate * * @example * ```typescript * agent.terminateBackgroundAgent("bg-agent-123"); * ``` */ terminateBackgroundAgent(threadId: string): void; }