@gracefultools/astrid-sdk 0.1.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/README.md +160 -0
- package/dist/adapters/astrid-oauth.d.ts +95 -0
- package/dist/adapters/astrid-oauth.d.ts.map +1 -0
- package/dist/adapters/astrid-oauth.js +230 -0
- package/dist/adapters/astrid-oauth.js.map +1 -0
- package/dist/bin/cli.d.ts +13 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +286 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/executors/claude.d.ts +45 -0
- package/dist/executors/claude.d.ts.map +1 -0
- package/dist/executors/claude.js +654 -0
- package/dist/executors/claude.js.map +1 -0
- package/dist/executors/gemini.d.ts +23 -0
- package/dist/executors/gemini.d.ts.map +1 -0
- package/dist/executors/gemini.js +487 -0
- package/dist/executors/gemini.js.map +1 -0
- package/dist/executors/openai.d.ts +24 -0
- package/dist/executors/openai.d.ts.map +1 -0
- package/dist/executors/openai.js +502 -0
- package/dist/executors/openai.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +143 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/agent-config.d.ts +56 -0
- package/dist/utils/agent-config.d.ts.map +1 -0
- package/dist/utils/agent-config.js +125 -0
- package/dist/utils/agent-config.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini Agent Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes code implementation using Google's Gemini API with function calling.
|
|
5
|
+
*/
|
|
6
|
+
import type { ImplementationPlan, ExecutionResult, PlanningResult, Logger, ProgressCallback } from '../types/index.js';
|
|
7
|
+
export interface GeminiExecutorConfig {
|
|
8
|
+
/** Path to the cloned repository */
|
|
9
|
+
repoPath: string;
|
|
10
|
+
/** Gemini API key */
|
|
11
|
+
apiKey: string;
|
|
12
|
+
/** Model to use */
|
|
13
|
+
model?: string;
|
|
14
|
+
/** Maximum iterations for tool use loop */
|
|
15
|
+
maxIterations?: number;
|
|
16
|
+
/** Logger function */
|
|
17
|
+
logger?: Logger;
|
|
18
|
+
/** Callback for progress updates */
|
|
19
|
+
onProgress?: ProgressCallback;
|
|
20
|
+
}
|
|
21
|
+
export declare function planWithGemini(taskTitle: string, taskDescription: string | null, config: GeminiExecutorConfig): Promise<PlanningResult>;
|
|
22
|
+
export declare function executeWithGemini(plan: ImplementationPlan, taskTitle: string, taskDescription: string | null, config: GeminiExecutorConfig): Promise<ExecutionResult>;
|
|
23
|
+
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../src/executors/gemini.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,MAAM,EACN,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAO1B,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B;AA4QD,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,CAAC,CA+GzB;AAMD,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAoJ1B"}
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gemini Agent Executor
|
|
4
|
+
*
|
|
5
|
+
* Executes code implementation using Google's Gemini API with function calling.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.planWithGemini = planWithGemini;
|
|
42
|
+
exports.executeWithGemini = executeWithGemini;
|
|
43
|
+
const fs = __importStar(require("fs/promises"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const child_process_1 = require("child_process");
|
|
46
|
+
const glob_1 = require("glob");
|
|
47
|
+
const agent_config_js_1 = require("../utils/agent-config.js");
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// TOOL DEFINITIONS
|
|
50
|
+
// ============================================================================
|
|
51
|
+
const TOOL_DECLARATIONS = [
|
|
52
|
+
{
|
|
53
|
+
name: 'read_file',
|
|
54
|
+
description: 'Read the contents of a file',
|
|
55
|
+
parameters: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
file_path: { type: 'string', description: 'Path to the file' }
|
|
59
|
+
},
|
|
60
|
+
required: ['file_path']
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'write_file',
|
|
65
|
+
description: 'Write content to a file (creates or overwrites)',
|
|
66
|
+
parameters: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
70
|
+
content: { type: 'string', description: 'Content to write' }
|
|
71
|
+
},
|
|
72
|
+
required: ['file_path', 'content']
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'edit_file',
|
|
77
|
+
description: 'Edit a file by replacing old_string with new_string',
|
|
78
|
+
parameters: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
82
|
+
old_string: { type: 'string', description: 'String to find' },
|
|
83
|
+
new_string: { type: 'string', description: 'Replacement string' }
|
|
84
|
+
},
|
|
85
|
+
required: ['file_path', 'old_string', 'new_string']
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'run_bash',
|
|
90
|
+
description: 'Run a bash command',
|
|
91
|
+
parameters: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
properties: {
|
|
94
|
+
command: { type: 'string', description: 'The bash command' }
|
|
95
|
+
},
|
|
96
|
+
required: ['command']
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'glob_files',
|
|
101
|
+
description: 'Find files matching a glob pattern',
|
|
102
|
+
parameters: {
|
|
103
|
+
type: 'object',
|
|
104
|
+
properties: {
|
|
105
|
+
pattern: { type: 'string', description: 'Glob pattern' }
|
|
106
|
+
},
|
|
107
|
+
required: ['pattern']
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'grep_search',
|
|
112
|
+
description: 'Search for a pattern in files',
|
|
113
|
+
parameters: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
pattern: { type: 'string', description: 'Search pattern' },
|
|
117
|
+
file_pattern: { type: 'string', description: 'Optional glob pattern' }
|
|
118
|
+
},
|
|
119
|
+
required: ['pattern']
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'task_complete',
|
|
124
|
+
description: 'Signal task completion',
|
|
125
|
+
parameters: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
commit_message: { type: 'string', description: 'Git commit message' },
|
|
129
|
+
pr_title: { type: 'string', description: 'PR title' },
|
|
130
|
+
pr_description: { type: 'string', description: 'PR description' }
|
|
131
|
+
},
|
|
132
|
+
required: ['commit_message', 'pr_title', 'pr_description']
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
async function executeTool(name, args, repoPath) {
|
|
137
|
+
try {
|
|
138
|
+
switch (name) {
|
|
139
|
+
case 'read_file': {
|
|
140
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
141
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
142
|
+
return { success: true, result: content };
|
|
143
|
+
}
|
|
144
|
+
case 'write_file': {
|
|
145
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
146
|
+
const content = args.content;
|
|
147
|
+
let action = 'create';
|
|
148
|
+
try {
|
|
149
|
+
await fs.access(filePath);
|
|
150
|
+
action = 'modify';
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
154
|
+
}
|
|
155
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
156
|
+
return {
|
|
157
|
+
success: true,
|
|
158
|
+
result: `File ${action === 'create' ? 'created' : 'updated'}: ${args.file_path}`,
|
|
159
|
+
fileChange: { path: args.file_path, content, action }
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
case 'edit_file': {
|
|
163
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
164
|
+
const oldContent = await fs.readFile(filePath, 'utf-8');
|
|
165
|
+
const oldString = args.old_string;
|
|
166
|
+
const newString = args.new_string;
|
|
167
|
+
if (!oldContent.includes(oldString)) {
|
|
168
|
+
return { success: false, result: `Error: Could not find string in file` };
|
|
169
|
+
}
|
|
170
|
+
const newContent = oldContent.replace(oldString, newString);
|
|
171
|
+
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
172
|
+
return {
|
|
173
|
+
success: true,
|
|
174
|
+
result: `File edited: ${args.file_path}`,
|
|
175
|
+
fileChange: { path: args.file_path, content: newContent, action: 'modify' }
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
case 'run_bash': {
|
|
179
|
+
const command = args.command;
|
|
180
|
+
const dangerous = ['rm -rf /', 'sudo', '> /dev/', 'mkfs', 'dd if='];
|
|
181
|
+
if (dangerous.some(d => command.includes(d))) {
|
|
182
|
+
return { success: false, result: 'Error: Dangerous command blocked' };
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
const output = (0, child_process_1.execSync)(command, {
|
|
186
|
+
cwd: repoPath,
|
|
187
|
+
encoding: 'utf-8',
|
|
188
|
+
timeout: 60000,
|
|
189
|
+
maxBuffer: 1024 * 1024
|
|
190
|
+
});
|
|
191
|
+
return { success: true, result: output || '(no output)' };
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
const err = error;
|
|
195
|
+
return { success: false, result: `Error: ${err.stderr || err.message}` };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
case 'glob_files': {
|
|
199
|
+
const pattern = args.pattern;
|
|
200
|
+
const files = await (0, glob_1.glob)(pattern, { cwd: repoPath, nodir: true });
|
|
201
|
+
return { success: true, result: files.slice(0, 100).join('\n') || '(no matches)' };
|
|
202
|
+
}
|
|
203
|
+
case 'grep_search': {
|
|
204
|
+
const pattern = args.pattern;
|
|
205
|
+
const filePattern = args.file_pattern || '.';
|
|
206
|
+
try {
|
|
207
|
+
const output = (0, child_process_1.execSync)(`grep -rn "${pattern.replace(/"/g, '\\"')}" ${filePattern} | head -50`, { cwd: repoPath, encoding: 'utf-8', timeout: 30000 });
|
|
208
|
+
return { success: true, result: output || '(no matches)' };
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return { success: true, result: '(no matches)' };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
case 'task_complete':
|
|
215
|
+
return { success: true, result: 'Task marked complete' };
|
|
216
|
+
default:
|
|
217
|
+
return { success: false, result: `Unknown tool: ${name}` };
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
return { success: false, result: `Error: ${error instanceof Error ? error.message : String(error)}` };
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async function callGemini(contents, systemInstruction, apiKey, model) {
|
|
225
|
+
const url = `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${apiKey}`;
|
|
226
|
+
const response = await fetch(url, {
|
|
227
|
+
method: 'POST',
|
|
228
|
+
headers: { 'Content-Type': 'application/json' },
|
|
229
|
+
body: JSON.stringify({
|
|
230
|
+
systemInstruction: { parts: [{ text: systemInstruction }] },
|
|
231
|
+
contents,
|
|
232
|
+
tools: [{ functionDeclarations: TOOL_DECLARATIONS }],
|
|
233
|
+
generationConfig: { maxOutputTokens: 8192, temperature: 0.2 }
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
if (!response.ok) {
|
|
237
|
+
const error = await response.text();
|
|
238
|
+
throw new Error(`Gemini API error: ${error}`);
|
|
239
|
+
}
|
|
240
|
+
return response.json();
|
|
241
|
+
}
|
|
242
|
+
async function loadAstridMd(repoPath) {
|
|
243
|
+
try {
|
|
244
|
+
const content = await fs.readFile(path.join(repoPath, 'ASTRID.md'), 'utf-8');
|
|
245
|
+
return content.length > 8000 ? content.substring(0, 8000) + '\n\n[truncated...]' : content;
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// ============================================================================
|
|
252
|
+
// PLANNING
|
|
253
|
+
// ============================================================================
|
|
254
|
+
async function planWithGemini(taskTitle, taskDescription, config) {
|
|
255
|
+
const log = config.logger || (() => { });
|
|
256
|
+
const onProgress = config.onProgress || (() => { });
|
|
257
|
+
const model = config.model || agent_config_js_1.DEFAULT_MODELS.gemini;
|
|
258
|
+
log('info', 'Starting Gemini planning', { repoPath: config.repoPath, taskTitle });
|
|
259
|
+
onProgress('Initializing Gemini for planning...');
|
|
260
|
+
const astridMd = await loadAstridMd(config.repoPath);
|
|
261
|
+
const systemInstruction = `You are an AI coding assistant analyzing a codebase to create an implementation plan.
|
|
262
|
+
|
|
263
|
+
${astridMd ? `## Project Context\n${astridMd}\n` : ''}
|
|
264
|
+
|
|
265
|
+
## Your Task
|
|
266
|
+
Analyze the codebase and create an implementation plan for: "${taskTitle}"
|
|
267
|
+
${taskDescription ? `\nDetails: ${taskDescription}` : ''}
|
|
268
|
+
|
|
269
|
+
## Instructions
|
|
270
|
+
1. Use glob_files and grep_search to explore
|
|
271
|
+
2. Use read_file to examine relevant files
|
|
272
|
+
3. Create a focused implementation plan
|
|
273
|
+
|
|
274
|
+
When ready, respond with ONLY a JSON block:
|
|
275
|
+
\`\`\`json
|
|
276
|
+
{
|
|
277
|
+
"summary": "Brief summary",
|
|
278
|
+
"approach": "High-level approach",
|
|
279
|
+
"files": [{"path": "path/to/file.ts", "purpose": "Why", "changes": "What"}],
|
|
280
|
+
"estimatedComplexity": "simple|medium|complex",
|
|
281
|
+
"considerations": ["Note 1"]
|
|
282
|
+
}
|
|
283
|
+
\`\`\`
|
|
284
|
+
|
|
285
|
+
RULES: Maximum 5 files, be SURGICAL.`;
|
|
286
|
+
const contents = [
|
|
287
|
+
{ role: 'user', parts: [{ text: `Please analyze and create an implementation plan for: ${taskTitle}` }] }
|
|
288
|
+
];
|
|
289
|
+
let totalInputTokens = 0;
|
|
290
|
+
let totalOutputTokens = 0;
|
|
291
|
+
const maxIterations = config.maxIterations || 20;
|
|
292
|
+
try {
|
|
293
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
294
|
+
onProgress(`Planning iteration ${i + 1}...`);
|
|
295
|
+
const response = await callGemini(contents, systemInstruction, config.apiKey, model);
|
|
296
|
+
totalInputTokens += response.usageMetadata?.promptTokenCount || 0;
|
|
297
|
+
totalOutputTokens += response.usageMetadata?.candidatesTokenCount || 0;
|
|
298
|
+
const candidate = response.candidates[0];
|
|
299
|
+
if (!candidate) {
|
|
300
|
+
return { success: false, error: 'No response from Gemini' };
|
|
301
|
+
}
|
|
302
|
+
contents.push({ role: 'model', parts: candidate.content.parts });
|
|
303
|
+
const functionCalls = candidate.content.parts.filter(p => p.functionCall);
|
|
304
|
+
if (functionCalls.length > 0) {
|
|
305
|
+
const functionResponses = [];
|
|
306
|
+
for (const part of functionCalls) {
|
|
307
|
+
if (!part.functionCall)
|
|
308
|
+
continue;
|
|
309
|
+
const { name, args } = part.functionCall;
|
|
310
|
+
onProgress(`Using tool: ${name}`);
|
|
311
|
+
const result = await executeTool(name, args, config.repoPath);
|
|
312
|
+
functionResponses.push({
|
|
313
|
+
functionResponse: { name, response: { result: result.result.substring(0, 10000) } }
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
contents.push({ role: 'user', parts: functionResponses });
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const textPart = candidate.content.parts.find(p => p.text);
|
|
320
|
+
if (textPart?.text) {
|
|
321
|
+
const jsonMatch = textPart.text.match(/```json\s*([\s\S]*?)\s*```/);
|
|
322
|
+
if (jsonMatch) {
|
|
323
|
+
try {
|
|
324
|
+
const plan = JSON.parse(jsonMatch[1]);
|
|
325
|
+
return {
|
|
326
|
+
success: true,
|
|
327
|
+
plan,
|
|
328
|
+
usage: {
|
|
329
|
+
inputTokens: totalInputTokens,
|
|
330
|
+
outputTokens: totalOutputTokens,
|
|
331
|
+
costUSD: (totalInputTokens * 0.00125 + totalOutputTokens * 0.005) / 1000
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
log('warn', 'Failed to parse plan JSON', {});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (candidate.finishReason === 'STOP') {
|
|
341
|
+
contents.push({
|
|
342
|
+
role: 'user',
|
|
343
|
+
parts: [{ text: 'Please provide the implementation plan as a JSON block.' }]
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return { success: false, error: 'Max iterations reached' };
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// ============================================================================
|
|
354
|
+
// EXECUTION
|
|
355
|
+
// ============================================================================
|
|
356
|
+
async function executeWithGemini(plan, taskTitle, taskDescription, config) {
|
|
357
|
+
const log = config.logger || (() => { });
|
|
358
|
+
const onProgress = config.onProgress || (() => { });
|
|
359
|
+
const model = config.model || agent_config_js_1.DEFAULT_MODELS.gemini;
|
|
360
|
+
log('info', 'Starting Gemini execution', { repoPath: config.repoPath, filesInPlan: plan.files.length });
|
|
361
|
+
onProgress('Initializing Gemini agent...');
|
|
362
|
+
const astridMd = await loadAstridMd(config.repoPath);
|
|
363
|
+
const systemInstruction = `You are an AI coding assistant implementing changes.
|
|
364
|
+
|
|
365
|
+
${astridMd ? `## Project Context\n${astridMd}\n` : ''}
|
|
366
|
+
|
|
367
|
+
## Task
|
|
368
|
+
Implement: "${taskTitle}"
|
|
369
|
+
${taskDescription ? `\nDetails: ${taskDescription}` : ''}
|
|
370
|
+
|
|
371
|
+
## Implementation Plan
|
|
372
|
+
${JSON.stringify(plan, null, 2)}
|
|
373
|
+
|
|
374
|
+
## Instructions
|
|
375
|
+
1. Read the files mentioned in the plan
|
|
376
|
+
2. Make the necessary changes
|
|
377
|
+
3. Run tests if available
|
|
378
|
+
4. When done, call task_complete
|
|
379
|
+
|
|
380
|
+
## Rules
|
|
381
|
+
- Follow the plan
|
|
382
|
+
- Make minimal changes
|
|
383
|
+
- Test your changes`;
|
|
384
|
+
const contents = [
|
|
385
|
+
{ role: 'user', parts: [{ text: 'Please implement the changes according to the plan.' }] }
|
|
386
|
+
];
|
|
387
|
+
const fileChanges = new Map();
|
|
388
|
+
let totalInputTokens = 0;
|
|
389
|
+
let totalOutputTokens = 0;
|
|
390
|
+
const maxIterations = config.maxIterations || 50;
|
|
391
|
+
try {
|
|
392
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
393
|
+
onProgress(`Implementation iteration ${i + 1}...`);
|
|
394
|
+
const response = await callGemini(contents, systemInstruction, config.apiKey, model);
|
|
395
|
+
totalInputTokens += response.usageMetadata?.promptTokenCount || 0;
|
|
396
|
+
totalOutputTokens += response.usageMetadata?.candidatesTokenCount || 0;
|
|
397
|
+
const candidate = response.candidates[0];
|
|
398
|
+
if (!candidate) {
|
|
399
|
+
return {
|
|
400
|
+
success: false,
|
|
401
|
+
files: [],
|
|
402
|
+
commitMessage: '',
|
|
403
|
+
prTitle: '',
|
|
404
|
+
prDescription: '',
|
|
405
|
+
error: 'No response from Gemini'
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
contents.push({ role: 'model', parts: candidate.content.parts });
|
|
409
|
+
const functionCalls = candidate.content.parts.filter(p => p.functionCall);
|
|
410
|
+
if (functionCalls.length > 0) {
|
|
411
|
+
const functionResponses = [];
|
|
412
|
+
for (const part of functionCalls) {
|
|
413
|
+
if (!part.functionCall)
|
|
414
|
+
continue;
|
|
415
|
+
const { name, args } = part.functionCall;
|
|
416
|
+
onProgress(`Using tool: ${name}`);
|
|
417
|
+
if (name === 'task_complete') {
|
|
418
|
+
const files = Array.from(fileChanges.entries()).map(([p, change]) => ({
|
|
419
|
+
path: p,
|
|
420
|
+
content: change.content,
|
|
421
|
+
action: change.action
|
|
422
|
+
}));
|
|
423
|
+
return {
|
|
424
|
+
success: true,
|
|
425
|
+
files,
|
|
426
|
+
commitMessage: args.commit_message || `feat: ${taskTitle}`,
|
|
427
|
+
prTitle: args.pr_title || `feat: ${taskTitle}`,
|
|
428
|
+
prDescription: args.pr_description || taskDescription || taskTitle,
|
|
429
|
+
usage: {
|
|
430
|
+
inputTokens: totalInputTokens,
|
|
431
|
+
outputTokens: totalOutputTokens,
|
|
432
|
+
costUSD: (totalInputTokens * 0.00125 + totalOutputTokens * 0.005) / 1000
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
const result = await executeTool(name, args, config.repoPath);
|
|
437
|
+
if (result.fileChange) {
|
|
438
|
+
fileChanges.set(result.fileChange.path, {
|
|
439
|
+
content: result.fileChange.content,
|
|
440
|
+
action: result.fileChange.action
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
functionResponses.push({
|
|
444
|
+
functionResponse: { name, response: { result: result.result.substring(0, 10000) } }
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
contents.push({ role: 'user', parts: functionResponses });
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (candidate.finishReason === 'STOP') {
|
|
451
|
+
contents.push({
|
|
452
|
+
role: 'user',
|
|
453
|
+
parts: [{ text: 'Please call task_complete to finalize.' }]
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
const files = Array.from(fileChanges.entries()).map(([p, change]) => ({
|
|
458
|
+
path: p,
|
|
459
|
+
content: change.content,
|
|
460
|
+
action: change.action
|
|
461
|
+
}));
|
|
462
|
+
return {
|
|
463
|
+
success: files.length > 0,
|
|
464
|
+
files,
|
|
465
|
+
commitMessage: `feat: ${taskTitle}`,
|
|
466
|
+
prTitle: `feat: ${taskTitle}`,
|
|
467
|
+
prDescription: taskDescription || taskTitle,
|
|
468
|
+
error: 'Max iterations reached',
|
|
469
|
+
usage: {
|
|
470
|
+
inputTokens: totalInputTokens,
|
|
471
|
+
outputTokens: totalOutputTokens,
|
|
472
|
+
costUSD: (totalInputTokens * 0.00125 + totalOutputTokens * 0.005) / 1000
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
catch (error) {
|
|
477
|
+
return {
|
|
478
|
+
success: false,
|
|
479
|
+
files: [],
|
|
480
|
+
commitMessage: '',
|
|
481
|
+
prTitle: '',
|
|
482
|
+
prDescription: '',
|
|
483
|
+
error: error instanceof Error ? error.message : String(error)
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
//# sourceMappingURL=gemini.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../src/executors/gemini.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Agent Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes code implementation using OpenAI's function calling API.
|
|
5
|
+
* Provides similar capabilities to Claude Agent SDK but using GPT models.
|
|
6
|
+
*/
|
|
7
|
+
import type { ImplementationPlan, ExecutionResult, PlanningResult, Logger, ProgressCallback } from '../types/index.js';
|
|
8
|
+
export interface OpenAIExecutorConfig {
|
|
9
|
+
/** Path to the cloned repository */
|
|
10
|
+
repoPath: string;
|
|
11
|
+
/** OpenAI API key */
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/** Model to use */
|
|
14
|
+
model?: string;
|
|
15
|
+
/** Maximum iterations for tool use loop */
|
|
16
|
+
maxIterations?: number;
|
|
17
|
+
/** Logger function */
|
|
18
|
+
logger?: Logger;
|
|
19
|
+
/** Callback for progress updates */
|
|
20
|
+
onProgress?: ProgressCallback;
|
|
21
|
+
}
|
|
22
|
+
export declare function planWithOpenAI(taskTitle: string, taskDescription: string | null, config: OpenAIExecutorConfig): Promise<PlanningResult>;
|
|
23
|
+
export declare function executeWithOpenAI(plan: ImplementationPlan, taskTitle: string, taskDescription: string | null, config: OpenAIExecutorConfig): Promise<ExecutionResult>;
|
|
24
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/executors/openai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,MAAM,EACN,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAO1B,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAC9B;AAsSD,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAyGzB;AAMD,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,eAAe,CAAC,CA6I1B"}
|