Repository navigation
Expand file tree
/
Copy pathbase.ts
More file actions
136 lines (116 loc) · 2.91 KB
/
Copy pathbase.ts
File metadata and controls
136 lines (116 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/**
* Base CLI Adapter Interface
*
* This abstract interface defines the contract for all CLI adapters,
* enabling the modular architecture where amp can be swapped for other CLIs.
*/
export interface CLIAdapter {
/**
* Name and display information
*/
name: string;
displayName: string;
/**
* Get configuration schema for this CLI
* Used to dynamically generate UI configuration fields
*/
getConfigSchema(): CLIConfigSchema;
/**
* Initialize the CLI adapter with configuration
*/
initialize(config: CLIConfig): Promise<void>;
/**
* Execute a task with streaming response
* Returns an async iterable of stream messages
*/
execute(request: ExecuteRequest): AsyncIterable<StreamMessage>;
/**
* Create a new thread for isolated execution
* @returns Thread ID
*/
createThread(workingDir: string): Promise<string>;
/**
* Resume an existing thread
*/
resumeThread(threadId: string): Promise<void>;
/**
* Stop a running thread
*/
stopThread(threadId: string): Promise<void>;
/**
* Get the capabilities of this CLI adapter
*/
getCapabilities(): CLICapabilities;
}
export interface CLIConfig {
apiKey: string;
cwd: string;
mode?: 'smart' | 'rush'; // smart = Opus 4.5, rush = Haiku 4.5
logLevel?: 'debug' | 'info' | 'error';
permissions?: PermissionRule[];
maxConcurrentAgents?: number;
}
export interface ExecuteRequest {
prompt: string;
threadId?: string; // Optional: resume existing thread
context?: ContextData; // Optional: injected memory context
permissions?: PermissionRule[];
// Phase detection fields
isSubtaskGeneration?: boolean;
isQuestionGeneration?: boolean;
}
export interface StreamMessage {
type: 'system' | 'assistant' | 'tool' | 'result' | 'error' | 'validation' | 'feedback';
timestamp: number;
data: unknown;
threadId: string;
}
export interface CLICapabilities {
supportsThreads: boolean;
supportsModes: string[];
maxConcurrentAgents: number;
supportsPermissions: boolean;
}
export interface PermissionRule {
action: string;
allowed: boolean;
}
export interface ContextData {
patterns?: Pattern[];
gotchas?: Gotcha[];
history?: HistoryEntry[];
}
export interface Pattern {
category: string;
description: string;
example?: string;
addedAt: number;
}
export interface Gotcha {
issue: string;
solution: string;
context?: string;
addedAt: number;
}
export interface HistoryEntry {
taskId: string;
phase: string;
success: boolean;
duration: number;
timestamp: number;
}
/**
* Configuration Schema - Defines UI fields for CLI configuration
* Allows dynamic form generation based on selected CLI tool
*/
export interface CLIConfigSchema {
fields: ConfigField[];
}
export interface ConfigField {
name: string;
label: string;
type: 'select' | 'number' | 'boolean' | 'text';
options?: { value: string; label: string }[];
default?: unknown;
description?: string;
}