@posthog/agent
Version:
TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog
48 lines • 2.42 kB
TypeScript
import type { PostHogAPIConfig, PostHogResource, StoredEntry, Task, TaskArtifactUploadPayload, TaskRun, TaskRunArtifact, UrlMention } from "./types.js";
export type TaskRunUpdate = Partial<Pick<TaskRun, "status" | "branch" | "stage" | "error_message" | "output" | "state">>;
export type TaskCreatePayload = Pick<Task, "description"> & Partial<Pick<Task, "title" | "repository" | "origin_product">>;
export declare class PostHogAPIClient {
private config;
constructor(config: PostHogAPIConfig);
private get baseUrl();
private get headers();
private apiRequest;
getTeamId(): number;
getBaseUrl(): string;
getApiKey(): string;
getLlmGatewayUrl(): string;
fetchTask(taskId: string): Promise<Task>;
listTasks(filters?: {
repository?: string;
organization?: string;
origin_product?: string;
}): Promise<Task[]>;
updateTask(taskId: string, updates: Partial<Task>): Promise<Task>;
createTask(payload: TaskCreatePayload): Promise<Task>;
listTaskRuns(taskId: string): Promise<TaskRun[]>;
getTaskRun(taskId: string, runId: string): Promise<TaskRun>;
createTaskRun(taskId: string, payload?: Partial<Omit<TaskRun, "id" | "task" | "team" | "created_at" | "updated_at" | "completed_at" | "artifacts">>): Promise<TaskRun>;
updateTaskRun(taskId: string, runId: string, payload: TaskRunUpdate): Promise<TaskRun>;
setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun>;
appendTaskRunLog(taskId: string, runId: string, entries: StoredEntry[]): Promise<TaskRun>;
uploadTaskArtifacts(taskId: string, runId: string, artifacts: TaskArtifactUploadPayload[]): Promise<TaskRunArtifact[]>;
/**
* Fetch logs from S3 using presigned URL from TaskRun
* @param taskRun - The task run containing the log_url
* @returns Array of stored entries, or empty array if no logs available
*/
fetchTaskRunLogs(taskRun: TaskRun): Promise<StoredEntry[]>;
/**
* Fetch error details from PostHog error tracking
*/
fetchErrorDetails(errorId: string, projectId?: string): Promise<PostHogResource>;
/**
* Generic resource fetcher by URL or ID
*/
fetchResourceByUrl(urlMention: UrlMention): Promise<PostHogResource>;
/**
* Format error data for agent consumption
*/
private formatErrorContent;
}
//# sourceMappingURL=posthog-api.d.ts.map