@posthog/agent
Version:
TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog
193 lines • 5.27 kB
TypeScript
import type { SessionNotification } from "@agentclientprotocol/sdk";
import type { CanUseTool, PermissionResult } from "@anthropic-ai/claude-agent-sdk";
export type { CanUseTool, PermissionResult, SessionNotification };
/**
* Stored custom notification following ACP extensibility model.
* Custom notifications use underscore-prefixed methods (e.g., `_posthog/phase_start`).
* See: https://agentclientprotocol.com/docs/extensibility
*/
export interface StoredNotification {
type: "notification";
/** When this notification was stored */
timestamp: string;
/** JSON-RPC 2.0 notification (no id field = notification, not request) */
notification: {
jsonrpc: "2.0";
method: string;
params?: Record<string, unknown>;
};
}
/**
* Type alias for stored log entries.
*/
export type StoredEntry = StoredNotification;
export interface Task {
id: string;
task_number?: number;
slug?: string;
title: string;
description: string;
origin_product: "error_tracking" | "eval_clusters" | "user_created" | "support_queue" | "session_summaries";
github_integration?: number | null;
repository: string;
json_schema?: Record<string, unknown> | null;
created_at: string;
updated_at: string;
created_by?: {
id: number;
uuid: string;
distinct_id: string;
first_name: string;
email: string;
};
latest_run?: TaskRun;
}
export type ArtifactType = "plan" | "context" | "reference" | "output" | "artifact";
export interface TaskRunArtifact {
name: string;
type: ArtifactType;
size?: number;
content_type?: string;
storage_path?: string;
uploaded_at?: string;
}
export type TaskRunStatus = "not_started" | "queued" | "in_progress" | "completed" | "failed" | "cancelled";
export type TaskRunEnvironment = "local" | "cloud";
export interface TaskRun {
id: string;
task: string;
team: number;
branch: string | null;
stage: string | null;
environment: TaskRunEnvironment;
status: TaskRunStatus;
log_url: string;
error_message: string | null;
output: Record<string, unknown> | null;
state: Record<string, unknown>;
artifacts?: TaskRunArtifact[];
created_at: string;
updated_at: string;
completed_at: string | null;
}
export interface SupportingFile {
name: string;
content: string;
type: ArtifactType;
created_at: string;
}
export interface TaskArtifactUploadPayload {
name: string;
type: ArtifactType;
content: string;
content_type?: string;
}
export declare enum PermissionMode {
PLAN = "plan",
DEFAULT = "default",
ACCEPT_EDITS = "acceptEdits",
BYPASS = "bypassPermissions"
}
export interface ExecutionOptions {
repositoryPath?: string;
permissionMode?: PermissionMode;
}
export interface TaskExecutionOptions {
repositoryPath?: string;
permissionMode?: PermissionMode;
isCloudMode?: boolean;
createPR?: boolean;
autoProgress?: boolean;
queryOverrides?: Record<string, unknown>;
canUseTool?: CanUseTool;
skipGitBranch?: boolean;
}
export interface ExecutionResult {
results: any[];
}
export interface PlanResult {
plan: string;
}
export interface TaskExecutionResult {
task: Task;
plan?: string;
executionResult?: ExecutionResult;
}
export type McpServerConfig = {
type?: "stdio";
command: string;
args?: string[];
env?: Record<string, string>;
} | {
type: "sse";
url: string;
headers?: Record<string, string>;
} | {
type: "http";
url: string;
headers?: Record<string, string>;
} | {
type: "sdk";
name: string;
instance?: any;
};
export type LogLevel = "debug" | "info" | "warn" | "error";
export type OnLogCallback = (level: LogLevel, scope: string, message: string, data?: unknown) => void;
export interface AgentConfig {
workingDirectory?: string;
posthogApiUrl?: string;
posthogApiKey?: string;
posthogProjectId?: number;
posthogMcpUrl?: string;
mcpServers?: Record<string, McpServerConfig>;
debug?: boolean;
onLog?: OnLogCallback;
canUseTool?: CanUseTool;
}
export interface PostHogAPIConfig {
apiUrl: string;
apiKey: string;
projectId: number;
}
export type ResourceType = "error" | "experiment" | "insight" | "feature_flag" | "generic";
export interface PostHogResource {
type: ResourceType;
id: string;
url: string;
title?: string;
content: string;
metadata?: Record<string, any>;
}
export interface UrlMention {
url: string;
type: ResourceType;
id?: string;
label?: string;
}
export interface ResearchQuestion {
id: string;
question: string;
options: string[];
}
export interface ResearchAnswer {
questionId: string;
selectedOption: string;
customInput?: string;
}
export interface ResearchEvaluation {
actionabilityScore: number;
context: string;
keyFiles: string[];
blockers?: string[];
questions?: ResearchQuestion[];
answered?: boolean;
answers?: ResearchAnswer[];
}
export interface WorktreeInfo {
worktreePath: string;
worktreeName: string;
branchName: string;
baseBranch: string;
createdAt: string;
}
//# sourceMappingURL=types.d.ts.map