diff --git a/libs/types/package.json b/libs/types/package.json new file mode 100644 index 00000000..032c8a19 --- /dev/null +++ b/libs/types/package.json @@ -0,0 +1,18 @@ +{ + "name": "@automaker/types", + "version": "1.0.0", + "description": "Shared type definitions for AutoMaker", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsc", + "watch": "tsc --watch" + }, + "keywords": ["automaker", "types"], + "author": "", + "license": "MIT", + "devDependencies": { + "@types/node": "^22.10.5", + "typescript": "^5.7.3" + } +} diff --git a/libs/types/src/error.ts b/libs/types/src/error.ts new file mode 100644 index 00000000..6c0459a4 --- /dev/null +++ b/libs/types/src/error.ts @@ -0,0 +1,16 @@ +/** + * Error type classification + */ +export type ErrorType = "authentication" | "cancellation" | "abort" | "execution" | "unknown"; + +/** + * Classified error information + */ +export interface ErrorInfo { + type: ErrorType; + message: string; + isAbort: boolean; + isAuth: boolean; + isCancellation: boolean; + originalError: unknown; +} diff --git a/libs/types/src/feature.ts b/libs/types/src/feature.ts new file mode 100644 index 00000000..9d98eacb --- /dev/null +++ b/libs/types/src/feature.ts @@ -0,0 +1,40 @@ +/** + * Feature types for AutoMaker feature management + */ + +export interface Feature { + id: string; + category: string; + description: string; + steps?: string[]; + passes?: boolean; + priority?: number; + status?: string; + dependencies?: string[]; + spec?: string; + model?: string; + imagePaths?: Array; + // Branch info - worktree path is derived at runtime from branchName + branchName?: string; // Name of the feature branch (undefined = use current worktree) + skipTests?: boolean; + thinkingLevel?: string; + planningMode?: 'skip' | 'lite' | 'spec' | 'full'; + requirePlanApproval?: boolean; + planSpec?: { + status: 'pending' | 'generating' | 'generated' | 'approved' | 'rejected'; + content?: string; + version: number; + generatedAt?: string; + approvedAt?: string; + reviewedByUser: boolean; + tasksCompleted?: number; + tasksTotal?: number; + }; + error?: string; + summary?: string; + startedAt?: string; + [key: string]: unknown; // Keep catch-all for extensibility +} + +export type FeatureStatus = 'pending' | 'running' | 'completed' | 'failed' | 'verified'; +export type PlanningMode = 'skip' | 'lite' | 'spec' | 'full'; diff --git a/libs/types/src/image.ts b/libs/types/src/image.ts new file mode 100644 index 00000000..3cf54db8 --- /dev/null +++ b/libs/types/src/image.ts @@ -0,0 +1,21 @@ +/** + * Image data with base64 encoding and metadata + */ +export interface ImageData { + base64: string; + mimeType: string; + filename: string; + originalPath: string; +} + +/** + * Content block for image (Claude SDK format) + */ +export interface ImageContentBlock { + type: "image"; + source: { + type: "base64"; + media_type: string; + data: string; + }; +} diff --git a/libs/types/src/index.ts b/libs/types/src/index.ts new file mode 100644 index 00000000..1d533817 --- /dev/null +++ b/libs/types/src/index.ts @@ -0,0 +1,50 @@ +/** + * @automaker/types + * Shared type definitions for AutoMaker + */ + +// Provider types +export type { + ProviderConfig, + ConversationMessage, + ExecuteOptions, + ContentBlock, + ProviderMessage, + InstallationStatus, + ValidationResult, + ModelDefinition, +} from './provider'; + +// Feature types +export type { + Feature, + FeatureStatus, + PlanningMode, +} from './feature'; + +// Session types +export type { + AgentSession, + SessionListItem, + CreateSessionParams, + UpdateSessionParams, +} from './session'; + +// Error types +export type { + ErrorType, + ErrorInfo, +} from './error'; + +// Image types +export type { + ImageData, + ImageContentBlock, +} from './image'; + +// Model types and constants +export { + CLAUDE_MODEL_MAP, + DEFAULT_MODELS, + type ModelAlias, +} from './model'; diff --git a/libs/types/src/model.ts b/libs/types/src/model.ts new file mode 100644 index 00000000..fe310e7a --- /dev/null +++ b/libs/types/src/model.ts @@ -0,0 +1,17 @@ +/** + * Model alias mapping for Claude models + */ +export const CLAUDE_MODEL_MAP: Record = { + haiku: "claude-haiku-4-5", + sonnet: "claude-sonnet-4-20250514", + opus: "claude-opus-4-5-20251101", +} as const; + +/** + * Default models per provider + */ +export const DEFAULT_MODELS = { + claude: "claude-opus-4-5-20251101", +} as const; + +export type ModelAlias = keyof typeof CLAUDE_MODEL_MAP; diff --git a/libs/types/src/provider.ts b/libs/types/src/provider.ts new file mode 100644 index 00000000..6a05b6df --- /dev/null +++ b/libs/types/src/provider.ts @@ -0,0 +1,104 @@ +/** + * Shared types for AI model providers + */ + +/** + * Configuration for a provider instance + */ +export interface ProviderConfig { + apiKey?: string; + cliPath?: string; + env?: Record; +} + +/** + * Message in conversation history + */ +export interface ConversationMessage { + role: "user" | "assistant"; + content: string | Array<{ type: string; text?: string; source?: object }>; +} + +/** + * Options for executing a query via a provider + */ +export interface ExecuteOptions { + prompt: string | Array<{ type: string; text?: string; source?: object }>; + model: string; + cwd: string; + systemPrompt?: string; + maxTurns?: number; + allowedTools?: string[]; + mcpServers?: Record; + abortController?: AbortController; + conversationHistory?: ConversationMessage[]; // Previous messages for context + sdkSessionId?: string; // Claude SDK session ID for resuming conversations +} + +/** + * Content block in a provider message (matches Claude SDK format) + */ +export interface ContentBlock { + type: "text" | "tool_use" | "thinking" | "tool_result"; + text?: string; + thinking?: string; + name?: string; + input?: unknown; + tool_use_id?: string; + content?: string; +} + +/** + * Message returned by a provider (matches Claude SDK streaming format) + */ +export interface ProviderMessage { + type: "assistant" | "user" | "error" | "result"; + subtype?: "success" | "error"; + session_id?: string; + message?: { + role: "user" | "assistant"; + content: ContentBlock[]; + }; + result?: string; + error?: string; + parent_tool_use_id?: string | null; +} + +/** + * Installation status for a provider + */ +export interface InstallationStatus { + installed: boolean; + path?: string; + version?: string; + method?: "cli" | "npm" | "brew" | "sdk"; + hasApiKey?: boolean; + authenticated?: boolean; + error?: string; +} + +/** + * Validation result + */ +export interface ValidationResult { + valid: boolean; + errors: string[]; + warnings?: string[]; +} + +/** + * Model definition + */ +export interface ModelDefinition { + id: string; + name: string; + modelString: string; + provider: string; + description: string; + contextWindow?: number; + maxOutputTokens?: number; + supportsVision?: boolean; + supportsTools?: boolean; + tier?: "basic" | "standard" | "premium"; + default?: boolean; +} diff --git a/libs/types/src/session.ts b/libs/types/src/session.ts new file mode 100644 index 00000000..a4fea93c --- /dev/null +++ b/libs/types/src/session.ts @@ -0,0 +1,31 @@ +/** + * Session types for agent conversations + */ + +export interface AgentSession { + id: string; + name: string; + projectPath: string; + createdAt: string; + updatedAt: string; + messageCount: number; + isArchived: boolean; + isDirty?: boolean; // Indicates session has completed work that needs review + tags?: string[]; +} + +export interface SessionListItem extends AgentSession { + preview?: string; // Last message preview +} + +export interface CreateSessionParams { + name: string; + projectPath: string; + workingDirectory?: string; +} + +export interface UpdateSessionParams { + id: string; + name?: string; + tags?: string[]; +} diff --git a/libs/types/tsconfig.json b/libs/types/tsconfig.json new file mode 100644 index 00000000..54e9774b --- /dev/null +++ b/libs/types/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "lib": ["ES2020"], + "types": ["node"], + "declaration": true, + "declarationMap": true, + "outDir": "./dist", + "rootDir": "./src", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "moduleResolution": "node" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +}