feat: add @automaker/types package

- Extract shared type definitions from server and UI
- Add provider types (ProviderConfig, ExecuteOptions, etc.)
- Add feature types (Feature, FeatureStatus, PlanningMode)
- Add session types (AgentSession, CreateSessionParams)
- Add error types (ErrorType, ErrorInfo)
- Add image types (ImageData, ImageContentBlock)
- Add model constants (CLAUDE_MODEL_MAP, DEFAULT_MODELS)

This package provides centralized type definitions for both server and UI.
No dependencies - pure TypeScript interfaces.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Kacper
2025-12-19 23:30:14 +01:00
parent 9110693c75
commit b149607747
9 changed files with 317 additions and 0 deletions

18
libs/types/package.json Normal file
View File

@@ -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"
}
}

16
libs/types/src/error.ts Normal file
View File

@@ -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;
}

40
libs/types/src/feature.ts Normal file
View File

@@ -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<string | { path: string; [key: string]: unknown }>;
// 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';

21
libs/types/src/image.ts Normal file
View File

@@ -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;
};
}

50
libs/types/src/index.ts Normal file
View File

@@ -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';

17
libs/types/src/model.ts Normal file
View File

@@ -0,0 +1,17 @@
/**
* Model alias mapping for Claude models
*/
export const CLAUDE_MODEL_MAP: Record<string, string> = {
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;

104
libs/types/src/provider.ts Normal file
View File

@@ -0,0 +1,104 @@
/**
* Shared types for AI model providers
*/
/**
* Configuration for a provider instance
*/
export interface ProviderConfig {
apiKey?: string;
cliPath?: string;
env?: Record<string, string>;
}
/**
* 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<string, unknown>;
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;
}

31
libs/types/src/session.ts Normal file
View File

@@ -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[];
}

20
libs/types/tsconfig.json Normal file
View File

@@ -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"]
}