All TypeScript interfaces and type definitions are in src/types.ts. This document covers the core types used throughout the codebase.
Standard wrapper for all tool operation results.
interface ToolResponse<T = unknown> {
success: boolean;
data?: T;
error?: string;
}All tools return ToolResponse<SomeData>. Check success before accessing data.
interface ListAppsResponse {
apps: string[];
}interface ExecuteResponse {
stdout: string;
stderr: string;
exitCode: number;
}interface ExecuteParams {
script: string;
timeout?: number;
}interface GetDictionaryParams {
app: string;
}These types represent parsed AppleScript dictionaries (SDEF).
interface AppleScriptDictionary {
application: string;
suites: DictionarySuite[];
version?: string | undefined;
}interface DictionarySuite {
name: string;
code?: string | undefined;
description?: string | undefined;
classes: DictionaryClass[];
commands: DictionaryCommand[];
enumerations: DictionaryEnumeration[];
}interface DictionaryClass {
name: string;
code?: string | undefined;
description?: string | undefined;
plural?: string | undefined;
inherits?: string | undefined;
properties: DictionaryProperty[];
elements: DictionaryElement[];
respondsTo?: string[] | undefined;
}interface DictionaryProperty {
name: string;
code?: string | undefined;
type: string;
access: 'r' | 'w' | 'rw';
description?: string | undefined;
}interface DictionaryElement {
type: string;
description?: string | undefined;
access?: string | undefined;
}interface DictionaryCommand {
name: string;
code?: string | undefined;
description?: string | undefined;
directParameter?: {
type: string;
description?: string | undefined;
optional: boolean;
};
parameters: CommandParameter[];
result?: {
type: string;
description?: string | undefined;
};
}interface CommandParameter {
name: string;
code?: string | undefined;
type: string;
description?: string | undefined;
optional: boolean;
}interface DictionaryEnumeration {
name: string;
code?: string | undefined;
description?: string | undefined;
values: EnumerationValue[];
}interface EnumerationValue {
name: string;
code?: string | undefined;
description?: string | undefined;
}interface CacheEntry<T> {
data: T;
timestamp: number;
appPath: string;
}function isExecuteParams(value: unknown): value is ExecuteParamsValidates that value has required script string and optional timeout number.
function isGetDictionaryParams(value: unknown): value is GetDictionaryParamsValidates that value has required app string.
interface SafetyAnalysis {
safe: boolean;
risk: 'none' | 'low' | 'medium' | 'high' | 'critical';
warnings: string[];
requiresConfirmation: boolean;
}interface ExecutionRecord {
id: string;
timestamp: string;
intent: string;
apps: string[];
script: string;
success: boolean;
result: string;
category: 'media' | 'files' | 'communication' | 'productivity' | 'system' | 'other';
actions: string[];
successCount: number;
keywords: string[];
}interface SystemState {
timestamp: string;
frontmostApp: string;
runningApps: string[];
finderSelection: string[];
clipboardText: string | null;
currentVolume: number;
musicPlaying: {
isPlaying: boolean;
track: string | null;
artist: string | null;
album: string | null;
};
safariTabs: Array<{ title: string; url: string }>;
}interface FailureAnalysis {
errorType: ErrorType;
rootCause: string;
suggestions: string[];
relatedSuccessfulPattern: string | null;
fixedScript: string | null;
confidence: 'high' | 'medium' | 'low';
}
type ErrorType =
| 'permission_denied'
| 'app_not_running'
| 'syntax_error'
| 'object_not_found'
| 'property_not_found'
| 'command_not_understood'
| 'timeout'
| 'type_mismatch'
| 'index_out_of_bounds'
| 'missing_value'
| 'user_cancelled'
| 'unknown';The project uses strict TypeScript settings:
{
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noImplicitOverride": true
}Notable settings:
noUncheckedIndexedAccess: Array/object index access returnsT | undefinedexactOptionalPropertyTypes: Optional properties cannot haveundefinedas a value unless explicitly typed