@posthog/wizard
Version:
The PostHog wizard helps you to configure your project
82 lines (81 loc) • 2.91 kB
TypeScript
/**
* Shared agent interface for PostHog wizards
* Uses Claude Agent SDK directly with PostHog LLM gateway
*/
import clack from '../utils/clack';
import type { WizardOptions } from '../utils/types';
type McpServersConfig = any;
export declare const AgentSignals: {
/** Signal emitted when the agent reports progress to the user */
readonly STATUS: "[STATUS]";
/** Signal emitted when the agent cannot access the PostHog MCP server */
readonly ERROR_MCP_MISSING: "[ERROR-MCP-MISSING]";
/** Signal emitted when the agent cannot access the setup resource */
readonly ERROR_RESOURCE_MISSING: "[ERROR-RESOURCE-MISSING]";
/** Signal emitted when the agent provides a remark about its run */
readonly WIZARD_REMARK: "[WIZARD-REMARK]";
};
export type AgentSignal = (typeof AgentSignals)[keyof typeof AgentSignals];
/**
* Error types that can be returned from agent execution.
* These correspond to the error signals that the agent emits.
*/
export declare enum AgentErrorType {
/** Agent could not access the PostHog MCP server */
MCP_MISSING = "WIZARD_MCP_MISSING",
/** Agent could not access the setup resource */
RESOURCE_MISSING = "WIZARD_RESOURCE_MISSING",
/** API rate limit exceeded */
RATE_LIMIT = "WIZARD_RATE_LIMIT",
/** Generic API error */
API_ERROR = "WIZARD_API_ERROR"
}
export type AgentConfig = {
workingDirectory: string;
posthogMcpUrl: string;
posthogApiKey: string;
posthogApiHost: string;
};
/**
* Internal configuration object returned by initializeAgent
*/
type AgentRunConfig = {
workingDirectory: string;
mcpServers: McpServersConfig;
model: string;
};
/**
* Permission hook that allows only safe commands.
* - Package manager install commands
* - Build/typecheck/lint commands for verification
* - Piping to tail/head for output limiting is allowed
* - Stderr redirection (2>&1) is allowed
* - PostHog skill installation commands from MCP
*/
export declare function wizardCanUseTool(toolName: string, input: Record<string, unknown>): {
behavior: 'allow';
updatedInput: Record<string, unknown>;
} | {
behavior: 'deny';
message: string;
};
/**
* Initialize agent configuration for the LLM gateway
*/
export declare function initializeAgent(config: AgentConfig, options: WizardOptions): AgentRunConfig;
/**
* Execute an agent with the provided prompt and options
* Handles the full lifecycle: spinner, execution, error handling
*
* @returns An object containing any error detected in the agent's output
*/
export declare function runAgent(agentConfig: AgentRunConfig, prompt: string, options: WizardOptions, spinner: ReturnType<typeof clack.spinner>, config?: {
estimatedDurationMinutes?: number;
spinnerMessage?: string;
successMessage?: string;
errorMessage?: string;
}): Promise<{
error?: AgentErrorType;
message?: string;
}>;
export {};