monty-autonomous-fullstack-dev-multillm 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +81 -0
- package/README.md +608 -0
- package/bin/cli.js +448 -0
- package/dist/agents/coding.d.ts +15 -0
- package/dist/agents/coding.d.ts.map +1 -0
- package/dist/agents/coding.js +189 -0
- package/dist/agents/coding.js.map +1 -0
- package/dist/agents/initializer.d.ts +15 -0
- package/dist/agents/initializer.d.ts.map +1 -0
- package/dist/agents/initializer.js +87 -0
- package/dist/agents/initializer.js.map +1 -0
- package/dist/agents/prompts/arbitrator.md +143 -0
- package/dist/agents/prompts/coding.md +247 -0
- package/dist/agents/prompts/initializer.md +98 -0
- package/dist/config/agent-config.d.ts +103 -0
- package/dist/config/agent-config.d.ts.map +1 -0
- package/dist/config/agent-config.js +138 -0
- package/dist/config/agent-config.js.map +1 -0
- package/dist/config/auth-config.d.ts +152 -0
- package/dist/config/auth-config.d.ts.map +1 -0
- package/dist/config/auth-config.js +139 -0
- package/dist/config/auth-config.js.map +1 -0
- package/dist/config/mcp-config.d.ts +109 -0
- package/dist/config/mcp-config.d.ts.map +1 -0
- package/dist/config/mcp-config.js +234 -0
- package/dist/config/mcp-config.js.map +1 -0
- package/dist/config/provider-config.d.ts +139 -0
- package/dist/config/provider-config.d.ts.map +1 -0
- package/dist/config/provider-config.js +344 -0
- package/dist/config/provider-config.js.map +1 -0
- package/dist/config/subagents-config.d.ts +85 -0
- package/dist/config/subagents-config.d.ts.map +1 -0
- package/dist/config/subagents-config.js +430 -0
- package/dist/config/subagents-config.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +385 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator/arbitrator.d.ts +93 -0
- package/dist/orchestrator/arbitrator.d.ts.map +1 -0
- package/dist/orchestrator/arbitrator.js +330 -0
- package/dist/orchestrator/arbitrator.js.map +1 -0
- package/dist/orchestrator/index.d.ts +113 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +217 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/review-coordinator.d.ts +143 -0
- package/dist/orchestrator/review-coordinator.d.ts.map +1 -0
- package/dist/orchestrator/review-coordinator.js +401 -0
- package/dist/orchestrator/review-coordinator.js.map +1 -0
- package/dist/orchestrator/task-classifier.d.ts +87 -0
- package/dist/orchestrator/task-classifier.d.ts.map +1 -0
- package/dist/orchestrator/task-classifier.js +250 -0
- package/dist/orchestrator/task-classifier.js.map +1 -0
- package/dist/providers/anthropic-provider.d.ts +64 -0
- package/dist/providers/anthropic-provider.d.ts.map +1 -0
- package/dist/providers/anthropic-provider.js +264 -0
- package/dist/providers/anthropic-provider.js.map +1 -0
- package/dist/providers/base-provider.d.ts +219 -0
- package/dist/providers/base-provider.d.ts.map +1 -0
- package/dist/providers/base-provider.js +143 -0
- package/dist/providers/base-provider.js.map +1 -0
- package/dist/providers/cursor-provider.d.ts +82 -0
- package/dist/providers/cursor-provider.d.ts.map +1 -0
- package/dist/providers/cursor-provider.js +321 -0
- package/dist/providers/cursor-provider.js.map +1 -0
- package/dist/providers/google-provider.d.ts +75 -0
- package/dist/providers/google-provider.d.ts.map +1 -0
- package/dist/providers/google-provider.js +274 -0
- package/dist/providers/google-provider.js.map +1 -0
- package/dist/providers/index.d.ts +92 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +233 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/openai-provider.d.ts +83 -0
- package/dist/providers/openai-provider.d.ts.map +1 -0
- package/dist/providers/openai-provider.js +295 -0
- package/dist/providers/openai-provider.js.map +1 -0
- package/dist/templates/feature_list.template.json +66 -0
- package/dist/templates/progress.template.txt +51 -0
- package/dist/utils/auth-manager.d.ts +121 -0
- package/dist/utils/auth-manager.d.ts.map +1 -0
- package/dist/utils/auth-manager.js +560 -0
- package/dist/utils/auth-manager.js.map +1 -0
- package/dist/utils/budget-enforcer.d.ts +181 -0
- package/dist/utils/budget-enforcer.d.ts.map +1 -0
- package/dist/utils/budget-enforcer.js +386 -0
- package/dist/utils/budget-enforcer.js.map +1 -0
- package/dist/utils/chatgpt-detector.d.ts +51 -0
- package/dist/utils/chatgpt-detector.d.ts.map +1 -0
- package/dist/utils/chatgpt-detector.js +274 -0
- package/dist/utils/chatgpt-detector.js.map +1 -0
- package/dist/utils/claude-code-detector.d.ts +39 -0
- package/dist/utils/claude-code-detector.d.ts.map +1 -0
- package/dist/utils/claude-code-detector.js +153 -0
- package/dist/utils/claude-code-detector.js.map +1 -0
- package/dist/utils/code-quality.d.ts +58 -0
- package/dist/utils/code-quality.d.ts.map +1 -0
- package/dist/utils/code-quality.js +258 -0
- package/dist/utils/code-quality.js.map +1 -0
- package/dist/utils/context-primer.d.ts +50 -0
- package/dist/utils/context-primer.d.ts.map +1 -0
- package/dist/utils/context-primer.js +429 -0
- package/dist/utils/context-primer.js.map +1 -0
- package/dist/utils/dependency-management.d.ts +40 -0
- package/dist/utils/dependency-management.d.ts.map +1 -0
- package/dist/utils/dependency-management.js +123 -0
- package/dist/utils/dependency-management.js.map +1 -0
- package/dist/utils/environment-validation.d.ts +33 -0
- package/dist/utils/environment-validation.d.ts.map +1 -0
- package/dist/utils/environment-validation.js +136 -0
- package/dist/utils/environment-validation.js.map +1 -0
- package/dist/utils/error-recovery.d.ts +60 -0
- package/dist/utils/error-recovery.d.ts.map +1 -0
- package/dist/utils/error-recovery.js +183 -0
- package/dist/utils/error-recovery.js.map +1 -0
- package/dist/utils/feature-list.d.ts +102 -0
- package/dist/utils/feature-list.d.ts.map +1 -0
- package/dist/utils/feature-list.js +191 -0
- package/dist/utils/feature-list.js.map +1 -0
- package/dist/utils/gemini-detector.d.ts +65 -0
- package/dist/utils/gemini-detector.d.ts.map +1 -0
- package/dist/utils/gemini-detector.js +340 -0
- package/dist/utils/gemini-detector.js.map +1 -0
- package/dist/utils/git-utils.d.ts +48 -0
- package/dist/utils/git-utils.d.ts.map +1 -0
- package/dist/utils/git-utils.js +110 -0
- package/dist/utils/git-utils.js.map +1 -0
- package/dist/utils/health-check.d.ts +32 -0
- package/dist/utils/health-check.d.ts.map +1 -0
- package/dist/utils/health-check.js +152 -0
- package/dist/utils/health-check.js.map +1 -0
- package/dist/utils/hooks-manager.d.ts +154 -0
- package/dist/utils/hooks-manager.d.ts.map +1 -0
- package/dist/utils/hooks-manager.js +359 -0
- package/dist/utils/hooks-manager.js.map +1 -0
- package/dist/utils/multi-auth-manager.d.ts +144 -0
- package/dist/utils/multi-auth-manager.d.ts.map +1 -0
- package/dist/utils/multi-auth-manager.js +588 -0
- package/dist/utils/multi-auth-manager.js.map +1 -0
- package/dist/utils/progress.d.ts +49 -0
- package/dist/utils/progress.d.ts.map +1 -0
- package/dist/utils/progress.js +209 -0
- package/dist/utils/progress.js.map +1 -0
- package/dist/utils/project-detection.d.ts +40 -0
- package/dist/utils/project-detection.d.ts.map +1 -0
- package/dist/utils/project-detection.js +230 -0
- package/dist/utils/project-detection.js.map +1 -0
- package/dist/utils/session-manager.d.ts +119 -0
- package/dist/utils/session-manager.d.ts.map +1 -0
- package/dist/utils/session-manager.js +389 -0
- package/dist/utils/session-manager.js.map +1 -0
- package/dist/utils/skills-manager.d.ts +113 -0
- package/dist/utils/skills-manager.d.ts.map +1 -0
- package/dist/utils/skills-manager.js +332 -0
- package/dist/utils/skills-manager.js.map +1 -0
- package/dist/utils/structured-output.d.ts +117 -0
- package/dist/utils/structured-output.d.ts.map +1 -0
- package/dist/utils/structured-output.js +191 -0
- package/dist/utils/structured-output.js.map +1 -0
- package/dist/utils/subagent-manager.d.ts +143 -0
- package/dist/utils/subagent-manager.d.ts.map +1 -0
- package/dist/utils/subagent-manager.js +326 -0
- package/dist/utils/subagent-manager.js.map +1 -0
- package/dist/utils/supabase-setup.d.ts +50 -0
- package/dist/utils/supabase-setup.d.ts.map +1 -0
- package/dist/utils/supabase-setup.js +151 -0
- package/dist/utils/supabase-setup.js.map +1 -0
- package/dist/utils/token-refresh.d.ts +21 -0
- package/dist/utils/token-refresh.d.ts.map +1 -0
- package/dist/utils/token-refresh.js +77 -0
- package/dist/utils/token-refresh.js.map +1 -0
- package/dist/utils/tos-warning.d.ts +115 -0
- package/dist/utils/tos-warning.d.ts.map +1 -0
- package/dist/utils/tos-warning.js +304 -0
- package/dist/utils/tos-warning.js.map +1 -0
- package/dist/utils/usage-monitor.d.ts +156 -0
- package/dist/utils/usage-monitor.d.ts.map +1 -0
- package/dist/utils/usage-monitor.js +296 -0
- package/dist/utils/usage-monitor.js.map +1 -0
- package/package.json +105 -0
- package/scripts/init.ps1 +73 -0
- package/scripts/init.sh +86 -0
- package/scripts/test-auth.sh +90 -0
- package/templates/feature_list.template.json +66 -0
- package/templates/progress.template.txt +51 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Provider (Cloud Agents API)
|
|
3
|
+
* Wrapper around Cursor's Cloud Agents REST API for multi-provider orchestration.
|
|
4
|
+
* Supports IDE-integrated workflows and rapid prototyping.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 Dobeu Tech Solutions LLC
|
|
7
|
+
* Licensed under CC BY-NC 4.0
|
|
8
|
+
*/
|
|
9
|
+
import { BaseProvider, } from './base-provider.js';
|
|
10
|
+
import { PROVIDER_CONFIGS, } from '../config/provider-config.js';
|
|
11
|
+
/**
|
|
12
|
+
* Cursor Provider Implementation
|
|
13
|
+
* Wraps the Cursor Cloud Agents API for use in multi-provider orchestration
|
|
14
|
+
*/
|
|
15
|
+
export class CursorProvider extends BaseProvider {
|
|
16
|
+
name = 'cursor';
|
|
17
|
+
displayName = 'Cursor Cloud Agents';
|
|
18
|
+
packageName = null; // REST API only
|
|
19
|
+
config = PROVIDER_CONFIGS.cursor;
|
|
20
|
+
apiKey = null;
|
|
21
|
+
baseUrl = 'https://api.cursor.com/v0';
|
|
22
|
+
currentTaskId = null;
|
|
23
|
+
constructor(apiKey) {
|
|
24
|
+
super();
|
|
25
|
+
this.apiKey = apiKey ?? process.env.CURSOR_API_KEY ?? null;
|
|
26
|
+
this.status.authenticated = !!this.apiKey;
|
|
27
|
+
this.status.available = this.status.authenticated;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Execute a query using the Cursor Cloud Agents API
|
|
31
|
+
*/
|
|
32
|
+
async *query(prompt, options) {
|
|
33
|
+
const startTime = Date.now();
|
|
34
|
+
if (!this.apiKey) {
|
|
35
|
+
yield {
|
|
36
|
+
type: 'error',
|
|
37
|
+
content: [{
|
|
38
|
+
type: 'text',
|
|
39
|
+
text: 'Cursor API key not configured. Set CURSOR_API_KEY environment variable.',
|
|
40
|
+
}],
|
|
41
|
+
metadata: {
|
|
42
|
+
provider: this.name,
|
|
43
|
+
latency_ms: Date.now() - startTime,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
// Map standard tools to Cursor tools
|
|
50
|
+
const cursorTools = options.tools
|
|
51
|
+
? this.mapToolNames(options.tools)
|
|
52
|
+
: undefined;
|
|
53
|
+
// Build request body
|
|
54
|
+
const requestBody = {
|
|
55
|
+
prompt,
|
|
56
|
+
tools: cursorTools,
|
|
57
|
+
model: options.model,
|
|
58
|
+
workspace_context: {
|
|
59
|
+
cwd: process.cwd(),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
// Submit task
|
|
63
|
+
const submitResponse = await fetch(`${this.baseUrl}/agents`, {
|
|
64
|
+
method: 'POST',
|
|
65
|
+
headers: {
|
|
66
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
},
|
|
69
|
+
body: JSON.stringify(requestBody),
|
|
70
|
+
});
|
|
71
|
+
if (!submitResponse.ok) {
|
|
72
|
+
const errorText = await submitResponse.text();
|
|
73
|
+
throw new Error(`Cursor API error (${submitResponse.status}): ${errorText}`);
|
|
74
|
+
}
|
|
75
|
+
const task = await submitResponse.json();
|
|
76
|
+
this.currentTaskId = task.id;
|
|
77
|
+
// Poll for completion (Cursor API is async)
|
|
78
|
+
const result = await this.pollForCompletion(task.id, options.timeout_ms ?? 120000);
|
|
79
|
+
// Normalize and yield result
|
|
80
|
+
const message = this.normalizeMessage(result);
|
|
81
|
+
message.metadata = {
|
|
82
|
+
...message.metadata,
|
|
83
|
+
provider: this.name,
|
|
84
|
+
latency_ms: Date.now() - startTime,
|
|
85
|
+
};
|
|
86
|
+
yield message;
|
|
87
|
+
// Yield final result message
|
|
88
|
+
yield {
|
|
89
|
+
type: 'result',
|
|
90
|
+
subtype: result.status === 'completed' ? 'success' : 'error',
|
|
91
|
+
content: [],
|
|
92
|
+
metadata: {
|
|
93
|
+
provider: this.name,
|
|
94
|
+
latency_ms: Date.now() - startTime,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
this.updateStatus(result.status === 'completed');
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
101
|
+
this.updateStatus(false, errorMessage);
|
|
102
|
+
yield {
|
|
103
|
+
type: 'error',
|
|
104
|
+
content: [{
|
|
105
|
+
type: 'text',
|
|
106
|
+
text: `Cursor provider error: ${errorMessage}`,
|
|
107
|
+
}],
|
|
108
|
+
metadata: {
|
|
109
|
+
provider: this.name,
|
|
110
|
+
latency_ms: Date.now() - startTime,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Poll for task completion
|
|
117
|
+
*/
|
|
118
|
+
async pollForCompletion(taskId, timeout) {
|
|
119
|
+
const startTime = Date.now();
|
|
120
|
+
const pollInterval = 1000; // 1 second
|
|
121
|
+
while (Date.now() - startTime < timeout) {
|
|
122
|
+
const response = await fetch(`${this.baseUrl}/agents/${taskId}`, {
|
|
123
|
+
method: 'GET',
|
|
124
|
+
headers: {
|
|
125
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
if (!response.ok) {
|
|
129
|
+
throw new Error(`Failed to get task status: ${response.status}`);
|
|
130
|
+
}
|
|
131
|
+
const task = await response.json();
|
|
132
|
+
if (task.status === 'completed' || task.status === 'failed') {
|
|
133
|
+
return task;
|
|
134
|
+
}
|
|
135
|
+
// Wait before polling again
|
|
136
|
+
await new Promise(resolve => setTimeout(resolve, pollInterval));
|
|
137
|
+
}
|
|
138
|
+
throw new Error(`Task timed out after ${timeout}ms`);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Validate Cursor API credentials
|
|
142
|
+
*/
|
|
143
|
+
async validateCredentials() {
|
|
144
|
+
const key = this.apiKey ?? process.env.CURSOR_API_KEY;
|
|
145
|
+
if (!key) {
|
|
146
|
+
this.status.authenticated = false;
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
// Make a health check request
|
|
151
|
+
const response = await fetch(`${this.baseUrl}/health`, {
|
|
152
|
+
method: 'GET',
|
|
153
|
+
headers: {
|
|
154
|
+
'Authorization': `Bearer ${key}`,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
const isValid = response.status === 200;
|
|
158
|
+
this.status.authenticated = isValid;
|
|
159
|
+
this.status.available = isValid;
|
|
160
|
+
return isValid;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
console.warn('Could not validate Cursor API key online');
|
|
164
|
+
// Assume valid if we can't check (network error)
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* List available Cursor models
|
|
170
|
+
*/
|
|
171
|
+
async listModels() {
|
|
172
|
+
return this.config.models.map(model => ({
|
|
173
|
+
id: model.id,
|
|
174
|
+
name: model.name,
|
|
175
|
+
contextWindow: model.contextWindow,
|
|
176
|
+
costPerMToken: model.costPerMToken,
|
|
177
|
+
capabilities: model.capabilities,
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get Cursor provider capabilities
|
|
182
|
+
*/
|
|
183
|
+
getCapabilities() {
|
|
184
|
+
return { ...this.config.capabilities };
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get list of supported standard tools
|
|
188
|
+
*/
|
|
189
|
+
getSupportedTools() {
|
|
190
|
+
return Object.entries(this.config.toolMapping)
|
|
191
|
+
.filter(([_, mapped]) => mapped !== null)
|
|
192
|
+
.map(([standard]) => standard);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Map standard tool name to Cursor tool name
|
|
196
|
+
*/
|
|
197
|
+
mapToolName(standardTool) {
|
|
198
|
+
const mapped = this.config.toolMapping[standardTool];
|
|
199
|
+
return mapped ?? null;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get current task ID
|
|
203
|
+
*/
|
|
204
|
+
getCurrentTaskId() {
|
|
205
|
+
return this.currentTaskId;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Cancel current task (if running)
|
|
209
|
+
*/
|
|
210
|
+
async cancelCurrentTask() {
|
|
211
|
+
if (!this.currentTaskId || !this.apiKey) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const response = await fetch(`${this.baseUrl}/agents/${this.currentTaskId}/cancel`, {
|
|
216
|
+
method: 'POST',
|
|
217
|
+
headers: {
|
|
218
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
return response.ok;
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Normalize Cursor response to standard format
|
|
229
|
+
*/
|
|
230
|
+
normalizeMessage(rawMessage) {
|
|
231
|
+
const response = rawMessage;
|
|
232
|
+
const content = [];
|
|
233
|
+
// Handle errors
|
|
234
|
+
if (response.status === 'failed') {
|
|
235
|
+
content.push({
|
|
236
|
+
type: 'text',
|
|
237
|
+
text: response.error ?? 'Task failed without error message',
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
type: 'error',
|
|
241
|
+
content,
|
|
242
|
+
metadata: {
|
|
243
|
+
provider: this.name,
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
// Add main content
|
|
248
|
+
if (response.result?.content) {
|
|
249
|
+
content.push({
|
|
250
|
+
type: 'text',
|
|
251
|
+
text: response.result.content,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
// Add tool calls if present
|
|
255
|
+
if (response.result?.tool_calls) {
|
|
256
|
+
for (const toolCall of response.result.tool_calls) {
|
|
257
|
+
content.push({
|
|
258
|
+
type: 'tool_use',
|
|
259
|
+
id: `tool_${Date.now()}_${Math.random().toString(36).slice(2)}`,
|
|
260
|
+
name: toolCall.tool,
|
|
261
|
+
input: toolCall.input,
|
|
262
|
+
});
|
|
263
|
+
if (toolCall.output) {
|
|
264
|
+
content.push({
|
|
265
|
+
type: 'tool_result',
|
|
266
|
+
tool_use_id: `tool_${Date.now()}`,
|
|
267
|
+
content: toolCall.output,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// Add files modified info
|
|
273
|
+
if (response.result?.files_modified && response.result.files_modified.length > 0) {
|
|
274
|
+
content.push({
|
|
275
|
+
type: 'text',
|
|
276
|
+
text: `\n\nFiles modified:\n${response.result.files_modified.map(f => ` - ${f}`).join('\n')}`,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
type: 'assistant',
|
|
281
|
+
content,
|
|
282
|
+
metadata: {
|
|
283
|
+
provider: this.name,
|
|
284
|
+
usage: response.usage ? {
|
|
285
|
+
input_tokens: response.usage.tokens_used,
|
|
286
|
+
output_tokens: 0, // Cursor doesn't separate input/output
|
|
287
|
+
} : undefined,
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Set API key at runtime
|
|
293
|
+
*/
|
|
294
|
+
setApiKey(key) {
|
|
295
|
+
this.apiKey = key;
|
|
296
|
+
this.status.authenticated = true;
|
|
297
|
+
this.status.available = true;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Get the current API key (masked for display)
|
|
301
|
+
*/
|
|
302
|
+
getApiKeyPreview() {
|
|
303
|
+
if (!this.apiKey)
|
|
304
|
+
return null;
|
|
305
|
+
return `${this.apiKey.slice(0, 8)}...${this.apiKey.slice(-4)}`;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Set custom API endpoint (for self-hosted instances)
|
|
309
|
+
*/
|
|
310
|
+
setBaseUrl(url) {
|
|
311
|
+
this.baseUrl = url;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Create a new Cursor provider instance
|
|
316
|
+
*/
|
|
317
|
+
export function createCursorProvider(apiKey) {
|
|
318
|
+
return new CursorProvider(apiKey);
|
|
319
|
+
}
|
|
320
|
+
export default CursorProvider;
|
|
321
|
+
//# sourceMappingURL=cursor-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-provider.js","sourceRoot":"","sources":["../../src/providers/cursor-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,GAKb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AAiCtC;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,YAAY;IACrC,IAAI,GAAiB,QAAQ,CAAC;IAC9B,WAAW,GAAG,qBAAqB,CAAC;IACpC,WAAW,GAAG,IAAI,CAAC,CAAC,gBAAgB;IAErC,MAAM,GAAG,gBAAgB,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C;IAC/B,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAC9B,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,GAAW;QACpB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;IACrB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAe;IAClD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Provider (Gemini ADK)
|
|
3
|
+
* Wrapper around Google's Agent Development Kit for multi-provider orchestration.
|
|
4
|
+
* Supports multi-agent workflows and large context windows.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 Dobeu Tech Solutions LLC
|
|
7
|
+
* Licensed under CC BY-NC 4.0
|
|
8
|
+
*/
|
|
9
|
+
import { BaseProvider, type AgentMessage, type QueryOptions, type ProviderCapabilities, type ModelInfo } from './base-provider.js';
|
|
10
|
+
import { type ProviderName } from '../config/provider-config.js';
|
|
11
|
+
/**
|
|
12
|
+
* Google Provider Implementation
|
|
13
|
+
* Wraps the Google ADK for use in multi-provider orchestration
|
|
14
|
+
*/
|
|
15
|
+
export declare class GoogleProvider extends BaseProvider {
|
|
16
|
+
readonly name: ProviderName;
|
|
17
|
+
readonly displayName = "Gemini (Google ADK)";
|
|
18
|
+
readonly packageName = "@google/adk";
|
|
19
|
+
private config;
|
|
20
|
+
private apiKey;
|
|
21
|
+
private agent;
|
|
22
|
+
private LlmAgentClass;
|
|
23
|
+
private FunctionToolClass;
|
|
24
|
+
constructor(apiKey?: string);
|
|
25
|
+
/**
|
|
26
|
+
* Initialize the Google ADK client
|
|
27
|
+
*/
|
|
28
|
+
private initializeClient;
|
|
29
|
+
/**
|
|
30
|
+
* Create an agent instance with the given configuration
|
|
31
|
+
*/
|
|
32
|
+
private createAgent;
|
|
33
|
+
/**
|
|
34
|
+
* Execute a query using the Google ADK
|
|
35
|
+
*/
|
|
36
|
+
query(prompt: string, options: QueryOptions): AsyncGenerator<AgentMessage, void, unknown>;
|
|
37
|
+
/**
|
|
38
|
+
* Validate Google API credentials
|
|
39
|
+
*/
|
|
40
|
+
validateCredentials(): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* List available Gemini models
|
|
43
|
+
*/
|
|
44
|
+
listModels(): Promise<ModelInfo[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Get Google provider capabilities
|
|
47
|
+
*/
|
|
48
|
+
getCapabilities(): ProviderCapabilities;
|
|
49
|
+
/**
|
|
50
|
+
* Get list of supported standard tools
|
|
51
|
+
*/
|
|
52
|
+
getSupportedTools(): string[];
|
|
53
|
+
/**
|
|
54
|
+
* Map standard tool name to Google tool name
|
|
55
|
+
*/
|
|
56
|
+
mapToolName(standardTool: string): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Normalize ADK result to standard format
|
|
59
|
+
*/
|
|
60
|
+
protected normalizeMessage(rawMessage: unknown): AgentMessage;
|
|
61
|
+
/**
|
|
62
|
+
* Set API key at runtime
|
|
63
|
+
*/
|
|
64
|
+
setApiKey(key: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get the current API key (masked for display)
|
|
67
|
+
*/
|
|
68
|
+
getApiKeyPreview(): string | null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a new Google provider instance
|
|
72
|
+
*/
|
|
73
|
+
export declare function createGoogleProvider(apiKey?: string): GoogleProvider;
|
|
74
|
+
export default GoogleProvider;
|
|
75
|
+
//# sourceMappingURL=google-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|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GAAG,IAAI;IAS5B;;OAEG;IACH,gBAAgB,IAAI,MAAM,GAAG,IAAI;CAIlC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAEpE;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Provider (Gemini ADK)
|
|
3
|
+
* Wrapper around Google's Agent Development Kit for multi-provider orchestration.
|
|
4
|
+
* Supports multi-agent workflows and large context windows.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 Dobeu Tech Solutions LLC
|
|
7
|
+
* Licensed under CC BY-NC 4.0
|
|
8
|
+
*/
|
|
9
|
+
import { BaseProvider, } from './base-provider.js';
|
|
10
|
+
import { PROVIDER_CONFIGS, } from '../config/provider-config.js';
|
|
11
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
12
|
+
/**
|
|
13
|
+
* Google Provider Implementation
|
|
14
|
+
* Wraps the Google ADK for use in multi-provider orchestration
|
|
15
|
+
*/
|
|
16
|
+
export class GoogleProvider extends BaseProvider {
|
|
17
|
+
name = 'google';
|
|
18
|
+
displayName = 'Gemini (Google ADK)';
|
|
19
|
+
packageName = '@google/adk';
|
|
20
|
+
config = PROVIDER_CONFIGS.google;
|
|
21
|
+
apiKey = null;
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
agent = null;
|
|
24
|
+
LlmAgentClass = null;
|
|
25
|
+
FunctionToolClass = null;
|
|
26
|
+
constructor(apiKey) {
|
|
27
|
+
super();
|
|
28
|
+
this.apiKey = apiKey ?? process.env.GOOGLE_API_KEY ?? null;
|
|
29
|
+
this.status.authenticated = !!this.apiKey;
|
|
30
|
+
this.status.available = false; // Will be set after SDK initialization
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the Google ADK client
|
|
34
|
+
*/
|
|
35
|
+
async initializeClient() {
|
|
36
|
+
if (this.LlmAgentClass)
|
|
37
|
+
return true;
|
|
38
|
+
try {
|
|
39
|
+
// Dynamic import of Google ADK (optional dependency)
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
let ADKModule;
|
|
42
|
+
try {
|
|
43
|
+
ADKModule = await import('@google/adk');
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
console.error('Google ADK not found. Install with: npm install @google/adk');
|
|
47
|
+
this.status.available = false;
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
this.LlmAgentClass = ADKModule.LlmAgent;
|
|
51
|
+
this.FunctionToolClass = ADKModule.FunctionTool;
|
|
52
|
+
if (!this.LlmAgentClass) {
|
|
53
|
+
console.error('Google ADK not found. Install with: npm install @google/adk');
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// Set API key in environment for ADK
|
|
57
|
+
if (this.apiKey) {
|
|
58
|
+
process.env.GOOGLE_API_KEY = this.apiKey;
|
|
59
|
+
}
|
|
60
|
+
this.status.available = true;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
65
|
+
console.warn(`Could not initialize Google ADK: ${message}`);
|
|
66
|
+
console.warn('Install with: npm install @google/adk');
|
|
67
|
+
this.status.available = false;
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create an agent instance with the given configuration
|
|
73
|
+
*/
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
createAgent(model) {
|
|
76
|
+
if (!this.LlmAgentClass)
|
|
77
|
+
return null;
|
|
78
|
+
const selectedModel = model ?? this.config.defaultModel;
|
|
79
|
+
return new this.LlmAgentClass({
|
|
80
|
+
name: 'monty_gemini_agent',
|
|
81
|
+
model: selectedModel,
|
|
82
|
+
description: 'Full-stack development assistant powered by Gemini',
|
|
83
|
+
instruction: `You are a helpful full-stack development assistant.
|
|
84
|
+
You help with coding tasks, research, documentation, and architectural decisions.
|
|
85
|
+
Always provide clear, accurate, and well-structured responses.`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Execute a query using the Google ADK
|
|
90
|
+
*/
|
|
91
|
+
async *query(prompt, options) {
|
|
92
|
+
const startTime = Date.now();
|
|
93
|
+
try {
|
|
94
|
+
// Initialize client if needed
|
|
95
|
+
if (!await this.initializeClient()) {
|
|
96
|
+
yield {
|
|
97
|
+
type: 'error',
|
|
98
|
+
content: [{
|
|
99
|
+
type: 'text',
|
|
100
|
+
text: 'Google ADK not available. Install with: npm install @google/adk',
|
|
101
|
+
}],
|
|
102
|
+
metadata: {
|
|
103
|
+
provider: this.name,
|
|
104
|
+
latency_ms: Date.now() - startTime,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
// Create agent for this query
|
|
110
|
+
this.agent = this.createAgent(options.model);
|
|
111
|
+
if (!this.agent) {
|
|
112
|
+
throw new Error('Failed to create Gemini agent');
|
|
113
|
+
}
|
|
114
|
+
// Execute query
|
|
115
|
+
const result = await this.agent.run(prompt);
|
|
116
|
+
// Normalize and yield result
|
|
117
|
+
const message = this.normalizeMessage(result);
|
|
118
|
+
message.metadata = {
|
|
119
|
+
...message.metadata,
|
|
120
|
+
provider: this.name,
|
|
121
|
+
model: options.model ?? this.config.defaultModel,
|
|
122
|
+
latency_ms: Date.now() - startTime,
|
|
123
|
+
};
|
|
124
|
+
yield message;
|
|
125
|
+
// Yield final result message
|
|
126
|
+
yield {
|
|
127
|
+
type: 'result',
|
|
128
|
+
subtype: 'success',
|
|
129
|
+
content: [],
|
|
130
|
+
metadata: {
|
|
131
|
+
provider: this.name,
|
|
132
|
+
latency_ms: Date.now() - startTime,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
this.updateStatus(true);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
139
|
+
this.updateStatus(false, errorMessage);
|
|
140
|
+
yield {
|
|
141
|
+
type: 'error',
|
|
142
|
+
content: [{
|
|
143
|
+
type: 'text',
|
|
144
|
+
text: `Google provider error: ${errorMessage}`,
|
|
145
|
+
}],
|
|
146
|
+
metadata: {
|
|
147
|
+
provider: this.name,
|
|
148
|
+
latency_ms: Date.now() - startTime,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Validate Google API credentials
|
|
155
|
+
*/
|
|
156
|
+
async validateCredentials() {
|
|
157
|
+
const key = this.apiKey ?? process.env.GOOGLE_API_KEY;
|
|
158
|
+
if (!key) {
|
|
159
|
+
this.status.authenticated = false;
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
// Make a minimal API request to validate the key
|
|
164
|
+
const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models?key=${key}`, { method: 'GET' });
|
|
165
|
+
const isValid = response.status === 200;
|
|
166
|
+
this.status.authenticated = isValid;
|
|
167
|
+
return isValid;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
console.warn('Could not validate Google API key online');
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* List available Gemini models
|
|
176
|
+
*/
|
|
177
|
+
async listModels() {
|
|
178
|
+
return this.config.models.map(model => ({
|
|
179
|
+
id: model.id,
|
|
180
|
+
name: model.name,
|
|
181
|
+
contextWindow: model.contextWindow,
|
|
182
|
+
costPerMToken: model.costPerMToken,
|
|
183
|
+
capabilities: model.capabilities,
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get Google provider capabilities
|
|
188
|
+
*/
|
|
189
|
+
getCapabilities() {
|
|
190
|
+
return { ...this.config.capabilities };
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get list of supported standard tools
|
|
194
|
+
*/
|
|
195
|
+
getSupportedTools() {
|
|
196
|
+
return Object.entries(this.config.toolMapping)
|
|
197
|
+
.filter(([_, mapped]) => mapped !== null)
|
|
198
|
+
.map(([standard]) => standard);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Map standard tool name to Google tool name
|
|
202
|
+
*/
|
|
203
|
+
mapToolName(standardTool) {
|
|
204
|
+
const mapped = this.config.toolMapping[standardTool];
|
|
205
|
+
return mapped ?? null;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Normalize ADK result to standard format
|
|
209
|
+
*/
|
|
210
|
+
normalizeMessage(rawMessage) {
|
|
211
|
+
const result = rawMessage;
|
|
212
|
+
const content = [];
|
|
213
|
+
// Add main content
|
|
214
|
+
if (result.content) {
|
|
215
|
+
content.push({
|
|
216
|
+
type: 'text',
|
|
217
|
+
text: result.content,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
// Add tool calls if present
|
|
221
|
+
if (result.tool_calls) {
|
|
222
|
+
for (const toolCall of result.tool_calls) {
|
|
223
|
+
content.push({
|
|
224
|
+
type: 'tool_use',
|
|
225
|
+
id: `tool_${Date.now()}_${Math.random().toString(36).slice(2)}`,
|
|
226
|
+
name: toolCall.name,
|
|
227
|
+
input: toolCall.arguments,
|
|
228
|
+
});
|
|
229
|
+
if (toolCall.result) {
|
|
230
|
+
content.push({
|
|
231
|
+
type: 'tool_result',
|
|
232
|
+
tool_use_id: `tool_${Date.now()}`,
|
|
233
|
+
content: toolCall.result,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
type: 'assistant',
|
|
240
|
+
content,
|
|
241
|
+
metadata: {
|
|
242
|
+
provider: this.name,
|
|
243
|
+
usage: result.usage,
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Set API key at runtime
|
|
249
|
+
*/
|
|
250
|
+
setApiKey(key) {
|
|
251
|
+
this.apiKey = key;
|
|
252
|
+
this.status.authenticated = true;
|
|
253
|
+
// Update environment for ADK
|
|
254
|
+
process.env.GOOGLE_API_KEY = key;
|
|
255
|
+
// Reset agent to use new key
|
|
256
|
+
this.agent = null;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get the current API key (masked for display)
|
|
260
|
+
*/
|
|
261
|
+
getApiKeyPreview() {
|
|
262
|
+
if (!this.apiKey)
|
|
263
|
+
return null;
|
|
264
|
+
return `${this.apiKey.slice(0, 8)}...${this.apiKey.slice(-4)}`;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Create a new Google provider instance
|
|
269
|
+
*/
|
|
270
|
+
export function createGoogleProvider(apiKey) {
|
|
271
|
+
return new GoogleProvider(apiKey);
|
|
272
|
+
}
|
|
273
|
+
export default GoogleProvider;
|
|
274
|
+
//# sourceMappingURL=google-provider.js.map
|